CrOS Shelf: For overflow, only forward to bubble events it can handle

Bug: 882991
Change-Id: I952c5e9ed4d2153b50fb7cfb2bc15b4f7557b9fb
Reviewed-on: https://chromium-review.googlesource.com/c/1373809
Reviewed-by: Xiyuan Xia <xiyuan@chromium.org>
Commit-Queue: Manu Cornet <manucornet@chromium.org>
Cr-Commit-Position: refs/heads/master@{#615982}
diff --git a/ash/shelf/overflow_bubble_view.cc b/ash/shelf/overflow_bubble_view.cc
index f3032ca..6bab6362 100644
--- a/ash/shelf/overflow_bubble_view.cc
+++ b/ash/shelf/overflow_bubble_view.cc
@@ -86,15 +86,22 @@
   AddChildView(shelf_view_);
 }
 
-void OverflowBubbleView::ProcessGestureEvent(const ui::GestureEvent& event) {
+bool OverflowBubbleView::ProcessGestureEvent(const ui::GestureEvent& event) {
+  // Handle scroll-related events, but don't do anything special for begin and
+  // end.
+  if (event.type() == ui::ET_GESTURE_SCROLL_BEGIN ||
+      event.type() == ui::ET_GESTURE_SCROLL_END) {
+    return true;
+  }
   if (event.type() != ui::ET_GESTURE_SCROLL_UPDATE)
-    return;
+    return false;
 
   if (shelf_->IsHorizontalAlignment())
     ScrollByXOffset(static_cast<int>(-event.details().scroll_x()));
   else
     ScrollByYOffset(static_cast<int>(-event.details().scroll_y()));
   Layout();
+  return true;
 }
 
 void OverflowBubbleView::ScrollByXOffset(int x_offset) {
diff --git a/ash/shelf/overflow_bubble_view.h b/ash/shelf/overflow_bubble_view.h
index 131f2a6..a6d825c 100644
--- a/ash/shelf/overflow_bubble_view.h
+++ b/ash/shelf/overflow_bubble_view.h
@@ -27,8 +27,9 @@
   // ShelfView containing the overflow items.
   void InitOverflowBubble(views::View* anchor, ShelfView* shelf_view);
 
-  // Scrolls the bubble contents if it is a scroll update event.
-  void ProcessGestureEvent(const ui::GestureEvent& event);
+  // Handles events for scrolling the bubble. Returns whether the event
+  // has been consumed.
+  bool ProcessGestureEvent(const ui::GestureEvent& event);
 
   // views::BubbleDialogDelegateView:
   int GetDialogButtons() const override;
diff --git a/ash/shelf/shelf_view.cc b/ash/shelf/shelf_view.cc
index a1846a9..fc7f314 100644
--- a/ash/shelf/shelf_view.cc
+++ b/ash/shelf/shelf_view.cc
@@ -1799,11 +1799,13 @@
   if (shelf_->ProcessGestureEvent(*event))
     event->StopPropagation();
   else if (is_overflow_mode()) {
-    // If the event hasn't been processed and the overflow shelf is showing,
-    // let the bubble process the event.
-    main_shelf_->overflow_bubble()->bubble_view()->ProcessGestureEvent(*event);
-    event->StopPropagation();
-    return;
+    // If the event hasn't been processed yet and the overflow shelf is showing,
+    // give the bubble a chance to process the event.
+    if (main_shelf_->overflow_bubble()->bubble_view()->ProcessGestureEvent(
+            *event)) {
+      event->StopPropagation();
+      return;
+    }
   }
 }