Skip to content

Commit

Permalink
Consume mouse button events on toolbar
Browse files Browse the repository at this point in the history
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

Change-Id: I3e0e3ede01ba73d589b3d3e3fa3a55b2577c0957
Reviewed-on: https://chromium-review.googlesource.com/582053
Reviewed-by: Yusuf Ozuysal <yusufo@chromium.org>
Commit-Queue: Jinsuk Kim <jinsukkim@chromium.org>
Cr-Commit-Position: refs/heads/master@{#489123}
  • Loading branch information
JinsukKim authored and Commit Bot committed Jul 24, 2017
1 parent 7eaaf65 commit ddd3b95
Showing 1 changed file with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
import android.graphics.drawable.Drawable;
import android.os.SystemClock;
import android.util.AttributeSet;
import android.view.InputDevice;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
Expand Down Expand Up @@ -534,6 +536,21 @@ protected void updateTabCountVisuals(int numberOfTabs) { }
*/
protected void onDefaultSearchEngineChanged() { }

@Override
public boolean onGenericMotionEvent(MotionEvent event) {
// Consumes mouse button events on toolbar so they don't get leaked to content layer.
// See https://crbug.com/740855.
if ((event.getSource() & InputDevice.SOURCE_CLASS_POINTER) != 0
&& event.getToolType(0) == MotionEvent.TOOL_TYPE_MOUSE) {
int action = event.getActionMasked();
if (action == MotionEvent.ACTION_BUTTON_PRESS
|| action == MotionEvent.ACTION_BUTTON_RELEASE) {
return true;
}
}
return super.onGenericMotionEvent(event);
}

@Override
public void getLocationBarContentRect(Rect outRect) {
View container = getLocationBar().getContainerView();
Expand Down

0 comments on commit ddd3b95

Please sign in to comment.