summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorvarunjain@chromium.org <varunjain@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-09-10 21:42:15 +0000
committervarunjain@chromium.org <varunjain@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-09-10 21:42:15 +0000
commita09064fd5be94ecd658e90ba96610fd9e9ac79ff (patch)
treec102e747e9e613a4b704e01b7bc4eeac1af657ab
parent5e72e37762bce1206a77885451467e62cab99a56 (diff)
downloadchromium_src-a09064fd5be94ecd658e90ba96610fd9e9ac79ff.zip
chromium_src-a09064fd5be94ecd658e90ba96610fd9e9ac79ff.tar.gz
chromium_src-a09064fd5be94ecd658e90ba96610fd9e9ac79ff.tar.bz2
Merge 220969 "Touch selection: Hide selection handles when overs..."
> Touch selection: Hide selection handles when overscroll is in progress and show > them only after the overscroll animation is complete. > Tests are in separate patch so that merging this patch into the branch is easy. > Patch with test: crrev.com/23620016 > > BUG=263368 > R=sky@chromium.org > > Review URL: https://codereview.chromium.org/23852003 TBR=varunjain@chromium.org Review URL: https://codereview.chromium.org/23757030 git-svn-id: svn://svn.chromium.org/chrome/branches/1599/src@222352 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--content/browser/web_contents/touch_editable_impl_aura.cc39
-rw-r--r--content/browser/web_contents/touch_editable_impl_aura.h11
-rw-r--r--content/browser/web_contents/web_contents_view_aura.cc6
3 files changed, 54 insertions, 2 deletions
diff --git a/content/browser/web_contents/touch_editable_impl_aura.cc b/content/browser/web_contents/touch_editable_impl_aura.cc
index fb430d0..d38f5f5 100644
--- a/content/browser/web_contents/touch_editable_impl_aura.cc
+++ b/content/browser/web_contents/touch_editable_impl_aura.cc
@@ -53,7 +53,7 @@ void TouchEditableImplAura::UpdateEditingController() {
// there is non-zero selection on the page. And the current event is a
// gesture event (we dont want to show handles if the user is selecting
// using mouse or keyboard).
- if (selection_gesture_in_process_ &&
+ if (selection_gesture_in_process_ && !scroll_in_progress_ &&
selection_anchor_rect_ != selection_focus_rect_)
StartTouchEditing();
@@ -66,6 +66,29 @@ void TouchEditableImplAura::UpdateEditingController() {
}
}
+void TouchEditableImplAura::OverscrollStarted() {
+ overscroll_in_progress_ = true;
+}
+
+void TouchEditableImplAura::OverscrollCompleted() {
+ // We might receive multiple OverscrollStarted() and OverscrollCompleted()
+ // during the same scroll session (for example, when the scroll direction
+ // changes). We want to show the handles only when:
+ // 1. Overscroll has completed
+ // 2. Scrolling session is over, i.e. we have received ET_GESTURE_SCROLL_END.
+ // 3. If we had hidden the handles when scrolling started
+ // 4. If there is still a need to show handles (there is a non-empty selection
+ // or non-NONE |text_input_type_|)
+ if (overscroll_in_progress_ && !scroll_in_progress_ &&
+ handles_hidden_due_to_scroll_ &&
+ (selection_anchor_rect_ != selection_focus_rect_ ||
+ text_input_type_ != ui::TEXT_INPUT_TYPE_NONE)) {
+ StartTouchEditing();
+ UpdateEditingController();
+ }
+ overscroll_in_progress_ = false;
+}
+
////////////////////////////////////////////////////////////////////////////////
// TouchEditableImplAura, RenderWidgetHostViewAura::TouchEditingClient
// implementation:
@@ -145,18 +168,24 @@ bool TouchEditableImplAura::HandleInputEvent(const ui::Event* event) {
// when scrolling ends. So we set |handles_hidden_due_to_scroll_| so that
// we can re-start touch editing when we call |UpdateEditingController()|
// on scroll end gesture.
+ scroll_in_progress_ = true;
handles_hidden_due_to_scroll_ = false;
if (touch_selection_controller_)
handles_hidden_due_to_scroll_ = true;
EndTouchEditing();
break;
case ui::ET_GESTURE_SCROLL_END:
- if (handles_hidden_due_to_scroll_ &&
+ // Scroll has ended, but we might still be in overscroll animation.
+ if (handles_hidden_due_to_scroll_ && !overscroll_in_progress_ &&
(selection_anchor_rect_ != selection_focus_rect_ ||
text_input_type_ != ui::TEXT_INPUT_TYPE_NONE)) {
StartTouchEditing();
UpdateEditingController();
}
+ // fall through to reset |scroll_in_progress_|.
+ case ui::ET_SCROLL_FLING_START:
+ selection_gesture_in_process_ = false;
+ scroll_in_progress_ = false;
break;
default:
break;
@@ -330,6 +359,8 @@ TouchEditableImplAura::TouchEditableImplAura()
rwhva_(NULL),
selection_gesture_in_process_(false),
handles_hidden_due_to_scroll_(false),
+ scroll_in_progress_(false),
+ overscroll_in_progress_(false),
is_tap_on_focused_textfield_(false) {
}
@@ -338,7 +369,11 @@ void TouchEditableImplAura::Cleanup() {
rwhva_->set_touch_editing_client(NULL);
rwhva_ = NULL;
}
+ text_input_type_ = ui::TEXT_INPUT_TYPE_NONE;
touch_selection_controller_.reset();
+ handles_hidden_due_to_scroll_ = false;
+ scroll_in_progress_ = false;
+ overscroll_in_progress_ = false;
}
} // namespace content
diff --git a/content/browser/web_contents/touch_editable_impl_aura.h b/content/browser/web_contents/touch_editable_impl_aura.h
index c31d86a..7f1ea84 100644
--- a/content/browser/web_contents/touch_editable_impl_aura.h
+++ b/content/browser/web_contents/touch_editable_impl_aura.h
@@ -37,6 +37,9 @@ class CONTENT_EXPORT TouchEditableImplAura
// depending on the current selection and cursor state.
void UpdateEditingController();
+ void OverscrollStarted();
+ void OverscrollCompleted();
+
// Overridden from RenderWidgetHostViewAura::TouchEditingClient.
virtual void StartTouchEditing() OVERRIDE;
virtual void EndTouchEditing() OVERRIDE;
@@ -87,8 +90,16 @@ class CONTENT_EXPORT TouchEditableImplAura
// change in selection (long press, double tap or triple tap).
bool selection_gesture_in_process_;
+ // Set to true if handles are hidden when user is scrolling. Used to determine
+ // whether to re-show handles after a scrolling session.
bool handles_hidden_due_to_scroll_;
+ // Keeps track of when the user is scrolling.
+ bool scroll_in_progress_;
+
+ // Set to true when the page starts an overscroll.
+ bool overscroll_in_progress_;
+
// Used to track if the current tap gesture is on a focused textfield.
bool is_tap_on_focused_textfield_;
diff --git a/content/browser/web_contents/web_contents_view_aura.cc b/content/browser/web_contents/web_contents_view_aura.cc
index 043efca..013edc7 100644
--- a/content/browser/web_contents/web_contents_view_aura.cc
+++ b/content/browser/web_contents/web_contents_view_aura.cc
@@ -1362,6 +1362,9 @@ void WebContentsViewAura::OnOverscrollModeChange(OverscrollMode old_mode,
// Reset any in-progress overscroll animation first.
ResetOverscrollTransform();
+ if (new_mode != OVERSCROLL_NONE && touch_editable_)
+ touch_editable_->OverscrollStarted();
+
if (new_mode == OVERSCROLL_NONE ||
!GetContentNativeView() ||
((new_mode == OVERSCROLL_EAST || new_mode == OVERSCROLL_WEST) &&
@@ -1402,6 +1405,9 @@ void WebContentsViewAura::OnImplicitAnimationsCompleted() {
completed_overscroll_gesture_)) {
PrepareOverscrollNavigationOverlay();
web_contents_->GetController().GoBack();
+ } else {
+ if (touch_editable_)
+ touch_editable_->OverscrollCompleted();
}
aura::Window* content = GetContentNativeView();