diff options
author | Ben Murdoch <benm@google.com> | 2014-11-12 18:52:08 +0000 |
---|---|---|
committer | Ben Murdoch <benm@google.com> | 2014-11-12 18:52:08 +0000 |
commit | c016285e1e5f5f035c0063c966ef3d7f29ca550f (patch) | |
tree | 3df96bf0cee9d229ee6cf68f29c50c5de65430dc | |
parent | f66cc3b6f091903a97b577e413da0c2acd80d3b7 (diff) | |
download | chromium_org-c016285e1e5f5f035c0063c966ef3d7f29ca550f.tar.gz |
Cherry pick [Android] Stop temporarily hiding selection handles
Bug: 18066784
Original change description:
Previously, selection handles would be hidden when the content view
became unfocused. This approach worked fine in Chrome, where the focus
model is predictable, but led to undesirable consequences in WebView,
e.g., the handles never being shown. For now, avoid making any kind of
visibility changes to the handles when the focus changes, ensuring
handle visibility is consistent with the selection.
Also ensure timely cleanup of the PopupTouchHandleDrawable Java object
after its native counterpart has been destroyed.
BUG=430859
(internal b/18066784)
Change-Id: I1741f81c5a12f71c053796cde37989366d2fcf10
Committed: https://crrev.com/1ba4ec56cb8f8e76f5d0cd37db09ebe41129c9c8
Cr-Commit-Position: refs/heads/master@{#303728}
6 files changed, 4 insertions, 46 deletions
diff --git a/content/browser/android/popup_touch_handle_drawable.cc b/content/browser/android/popup_touch_handle_drawable.cc index ac2f57bffc..8a7cf845f7 100644 --- a/content/browser/android/popup_touch_handle_drawable.cc +++ b/content/browser/android/popup_touch_handle_drawable.cc @@ -16,6 +16,9 @@ PopupTouchHandleDrawable::PopupTouchHandleDrawable( } PopupTouchHandleDrawable::~PopupTouchHandleDrawable() { + // Explicitly disabling ensures that any external references to the Java + // object are cleared, allowing it to be GC'ed in a timely fashion. + SetEnabled(false); } void PopupTouchHandleDrawable::SetEnabled(bool enabled) { diff --git a/content/browser/renderer_host/input/touch_selection_controller.cc b/content/browser/renderer_host/input/touch_selection_controller.cc index e904e283ee..d57b96f0aa 100644 --- a/content/browser/renderer_host/input/touch_selection_controller.cc +++ b/content/browser/renderer_host/input/touch_selection_controller.cc @@ -160,20 +160,6 @@ void TouchSelectionController::HideAndDisallowShowingAutomatically() { activate_selection_automatically_ = false; } -void TouchSelectionController::SetTemporarilyHidden(bool hidden) { - if (temporarily_hidden_ == hidden) - return; - temporarily_hidden_ = hidden; - - TouchHandle::AnimationStyle animation_style = GetAnimationStyle(true); - if (is_selection_active_) { - start_selection_handle_->SetVisible(GetStartVisible(), animation_style); - end_selection_handle_->SetVisible(GetEndVisible(), animation_style); - } - if (is_insertion_active_) - insertion_handle_->SetVisible(GetStartVisible(), animation_style); -} - void TouchSelectionController::OnSelectionEditable(bool editable) { if (selection_editable_ == editable) return; diff --git a/content/browser/renderer_host/input/touch_selection_controller.h b/content/browser/renderer_host/input/touch_selection_controller.h index 13031e12b9..452dde0cc3 100644 --- a/content/browser/renderer_host/input/touch_selection_controller.h +++ b/content/browser/renderer_host/input/touch_selection_controller.h @@ -69,9 +69,6 @@ class CONTENT_EXPORT TouchSelectionController : public TouchHandleClient { // showing allowance. void HideAndDisallowShowingAutomatically(); - // Override the handle visibility according to |hidden|. - void SetTemporarilyHidden(bool hidden); - // To be called when the editability of the focused region changes. void OnSelectionEditable(bool editable); diff --git a/content/browser/renderer_host/input/touch_selection_controller_unittest.cc b/content/browser/renderer_host/input/touch_selection_controller_unittest.cc index 5bdf57273f..c3422077dd 100644 --- a/content/browser/renderer_host/input/touch_selection_controller_unittest.cc +++ b/content/browser/renderer_host/input/touch_selection_controller_unittest.cc @@ -632,31 +632,6 @@ TEST_F(TouchSelectionControllerTest, Animation) { EXPECT_FALSE(GetAndResetNeedsAnimate()); } -TEST_F(TouchSelectionControllerTest, TemporarilyHidden) { - controller().OnTapEvent(); - controller().OnSelectionEditable(true); - - gfx::RectF insertion_rect(5, 5, 0, 10); - - bool visible = true; - ChangeInsertion(insertion_rect, visible); - EXPECT_FALSE(GetAndResetNeedsAnimate()); - - controller().SetTemporarilyHidden(true); - EXPECT_TRUE(GetAndResetNeedsAnimate()); - - visible = false; - ChangeInsertion(insertion_rect, visible); - EXPECT_FALSE(GetAndResetNeedsAnimate()); - - visible = true; - ChangeInsertion(insertion_rect, visible); - EXPECT_FALSE(GetAndResetNeedsAnimate()); - - controller().SetTemporarilyHidden(false); - EXPECT_TRUE(GetAndResetNeedsAnimate()); -} - TEST_F(TouchSelectionControllerTest, SelectionClearOnTap) { gfx::RectF start_rect(5, 5, 0, 10); gfx::RectF end_rect(50, 5, 0, 10); diff --git a/content/browser/renderer_host/render_widget_host_view_android.cc b/content/browser/renderer_host/render_widget_host_view_android.cc index 205650f949..66c9fcdd74 100644 --- a/content/browser/renderer_host/render_widget_host_view_android.cc +++ b/content/browser/renderer_host/render_widget_host_view_android.cc @@ -477,8 +477,6 @@ void RenderWidgetHostViewAndroid::Focus() { host_->SetInputMethodActive(true); if (overscroll_effect_) overscroll_effect_->Enable(); - if (selection_controller_) - selection_controller_->SetTemporarilyHidden(false); } void RenderWidgetHostViewAndroid::Blur() { @@ -486,8 +484,6 @@ void RenderWidgetHostViewAndroid::Blur() { host_->Blur(); if (overscroll_effect_) overscroll_effect_->Disable(); - if (selection_controller_) - selection_controller_->SetTemporarilyHidden(true); } bool RenderWidgetHostViewAndroid::HasFocus() const { diff --git a/content/public/android/java/src/org/chromium/content/browser/input/PopupTouchHandleDrawable.java b/content/public/android/java/src/org/chromium/content/browser/input/PopupTouchHandleDrawable.java index ffb03af20e..c23e4d534e 100644 --- a/content/public/android/java/src/org/chromium/content/browser/input/PopupTouchHandleDrawable.java +++ b/content/public/android/java/src/org/chromium/content/browser/input/PopupTouchHandleDrawable.java @@ -220,6 +220,7 @@ public class PopupTouchHandleDrawable extends View { } private void doInvalidate() { + if (!mContainer.isShowing()) return; updatePosition(); updateVisibility(); invalidate(); |