Skip to content

Commit 2011da0

Browse files
committed
Consume mouse button events on toolbar
A regression was letting mouse button click events on toolbar to be passed down to content layer, and causing the content hidden behind the toolbar react to the events as well, while they should have triggered corresponding action on the toolbar only. This CL stop the leak. BUG=740855 NOTRY=true NOPRESUBMIT=true [email protected] (cherry picked from commit ddd3b95) Change-Id: I3e0e3ede01ba73d589b3d3e3fa3a55b2577c0957 Reviewed-on: https://chromium-review.googlesource.com/582053 Reviewed-by: Yusuf Ozuysal <[email protected]> Commit-Queue: Jinsuk Kim <[email protected]> Cr-Original-Commit-Position: refs/heads/master@{#489123} Reviewed-on: https://chromium-review.googlesource.com/585509 Reviewed-by: Jinsuk Kim <[email protected]> Cr-Commit-Position: refs/branch-heads/3163@{#52} Cr-Branched-From: ff259ba-refs/heads/master@{#488528}
1 parent 21257d2 commit 2011da0

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

chrome/android/java/src/org/chromium/chrome/browser/toolbar/ToolbarLayout.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
import android.graphics.drawable.Drawable;
1616
import android.os.SystemClock;
1717
import android.util.AttributeSet;
18+
import android.view.InputDevice;
19+
import android.view.MotionEvent;
1820
import android.view.View;
1921
import android.view.ViewGroup;
2022
import android.widget.FrameLayout;
@@ -534,6 +536,21 @@ protected void updateTabCountVisuals(int numberOfTabs) { }
534536
*/
535537
protected void onDefaultSearchEngineChanged() { }
536538

539+
@Override
540+
public boolean onGenericMotionEvent(MotionEvent event) {
541+
// Consumes mouse button events on toolbar so they don't get leaked to content layer.
542+
// See https://crbug.com/740855.
543+
if ((event.getSource() & InputDevice.SOURCE_CLASS_POINTER) != 0
544+
&& event.getToolType(0) == MotionEvent.TOOL_TYPE_MOUSE) {
545+
int action = event.getActionMasked();
546+
if (action == MotionEvent.ACTION_BUTTON_PRESS
547+
|| action == MotionEvent.ACTION_BUTTON_RELEASE) {
548+
return true;
549+
}
550+
}
551+
return super.onGenericMotionEvent(event);
552+
}
553+
537554
@Override
538555
public void getLocationBarContentRect(Rect outRect) {
539556
View container = getLocationBar().getContainerView();

0 commit comments

Comments
 (0)