Commit deec3198 authored by Collin Baker's avatar Collin Baker Committed by Commit Bot

Use pre-target handler for drag-to-open, handling only vertical drags

The Omnibox consumes all ET_GESTURE_SCROLL_* events in its bounds for
text scrolling. All drags in the Omnibox area therefore weren't
compatible with drag-to-open using a post-target handler.

This uses a pre-target handler instead. To allow text scrolling to work,
only scroll events starting with a larger vertical component are
handled.

Bug: 1043374
Change-Id: I589d6716e333f587952cf3e64e90171fb03a6dda
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2099362Reviewed-by: default avatarDana Fried <dfried@chromium.org>
Reviewed-by: default avatarRobert Liao <robliao@chromium.org>
Commit-Queue: Collin Baker <collinbaker@chromium.org>
Cr-Commit-Position: refs/heads/master@{#749727}
parent 71f516df
...@@ -162,17 +162,25 @@ class WebUITabStripContainerView::DragToOpenHandler : public ui::EventHandler { ...@@ -162,17 +162,25 @@ class WebUITabStripContainerView::DragToOpenHandler : public ui::EventHandler {
views::View* drag_handle) views::View* drag_handle)
: container_(container), drag_handle_(drag_handle) { : container_(container), drag_handle_(drag_handle) {
DCHECK(container_); DCHECK(container_);
drag_handle_->AddPostTargetHandler(this); drag_handle_->AddPreTargetHandler(this);
} }
~DragToOpenHandler() override { drag_handle_->RemovePostTargetHandler(this); } ~DragToOpenHandler() override { drag_handle_->RemovePreTargetHandler(this); }
void OnGestureEvent(ui::GestureEvent* event) override { void OnGestureEvent(ui::GestureEvent* event) override {
switch (event->type()) { switch (event->type()) {
case ui::ET_GESTURE_SCROLL_BEGIN: case ui::ET_GESTURE_SCROLL_BEGIN:
drag_in_progress_ = true; // Only treat this scroll as drag-to-open if the y component is
container_->UpdateHeightForDragToOpen(event->details().scroll_y_hint()); // larger. Otherwise, leave the event unhandled. Horizontal
event->SetHandled(); // scrolls are used in the toolbar, e.g. for text scrolling in
// the Omnibox.
if (event->details().scroll_y_hint() >
event->details().scroll_x_hint()) {
drag_in_progress_ = true;
container_->UpdateHeightForDragToOpen(
event->details().scroll_y_hint());
event->SetHandled();
}
break; break;
case ui::ET_GESTURE_SCROLL_UPDATE: case ui::ET_GESTURE_SCROLL_UPDATE:
if (drag_in_progress_) { if (drag_in_progress_) {
...@@ -217,9 +225,6 @@ class WebUITabStripContainerView::DragToOpenHandler : public ui::EventHandler { ...@@ -217,9 +225,6 @@ class WebUITabStripContainerView::DragToOpenHandler : public ui::EventHandler {
WebUITabStripContainerView* const container_; WebUITabStripContainerView* const container_;
views::View* const drag_handle_; views::View* const drag_handle_;
// True between ET_GESTURE_SCROLL_BEGIN event received and gesture
// end. Used to track when an unsupported gesture ends to reset the
// container to a good state.
bool drag_in_progress_ = false; bool drag_in_progress_ = false;
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment