Commit 54b3389c authored by ianwen's avatar ianwen Committed by Commit bot

[Android] Fix a bug where the suggestion list can't scroll

After we placed omnibox suggestion list as a child of
CompositorViewHolder, it no longer is able to scroll.

The investigation of this regression gave interesting result: if an
ACTION_MOVE is dispatched to a ListView or a ScrollView and the
ViewGroup intercepts it, the framework will generate an ACTION_CANCEL to
the ViewGroup's children. The behavior, however, will steal this cancel
event and send to the ViewGroup again, causing scroll to fail. Thus we
should specifically not catch ACTION_CANCEL in behavior.

BUG=648136

Review-Url: https://codereview.chromium.org/2526673004
Cr-Commit-Position: refs/heads/master@{#434761}
parent 298ed466
...@@ -40,7 +40,13 @@ public class CompositorViewHolderBehavior extends Behavior<View> { ...@@ -40,7 +40,13 @@ public class CompositorViewHolderBehavior extends Behavior<View> {
@Override @Override
public boolean onTouchEvent(CoordinatorLayout parent, View child, MotionEvent ev) { public boolean onTouchEvent(CoordinatorLayout parent, View child, MotionEvent ev) {
if (!mShouldIntercept) return false; // If an ACTION_MOVE is dispatched to a ListView or a ScrollView and the ViewGroup
// intercepts it, the framework will generate an ACTION_CANCEL to the ViewGroup's children.
// This class, however, will steal this cancel event and send to the ViewGroup again,
// causing scroll to fail. Thus we should specifically not catch ACTION_CANCEL in behavior.
// In theory, stopping ACTION_CANCEL will cause problem when CompositorViewHolder scrolls.
// Yet currently CompositorViewHolder does not scroll.
if (!mShouldIntercept || ev.getActionMasked() == MotionEvent.ACTION_CANCEL) return false;
ev.offsetLocation(-child.getX(), -child.getY()); ev.offsetLocation(-child.getX(), -child.getY());
child.dispatchTouchEvent(ev); child.dispatchTouchEvent(ev);
return true; return true;
......
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