| commit | 01b2bf1ec0c43a1924269c22c07ff7a2cbccb6d7 | [log] [tgz] |
|---|---|---|
| author | Linyu He <linyuh@google.com> | Tue May 20 23:34:05 2025 |
| committer | Chromium LUCI CQ <chromium-scoped@luci-project-accounts.iam.gserviceaccount.com> | Tue May 20 23:34:05 2025 |
| tree | b77fd8855eb302293725cd85a7db81c97712bf9d | |
| parent | a98e47b6d95e90fbbf44ad364d09c6391d653275 [diff] |
Consolidate how MotionEvent info is passed for tab closure
TL;DR:
* This CL is a no-op; it only changes method signatures.
* Reviewers: please follow the "Changes" section below to get a clearer
view of the changes.
Context:
We needed info from the MotionEvent that triggered a click to
differentiate between a peripheral click and other clicks so that tab
closure behavior can be customized. For example, we don't want to show
the undo snackbar when a tab is closed by a peripheral.
Multiple UI surfaces have been updated so far, and we used two ways to
pass MotionEvent info.
(1) For a View that has OnClickListener:
We attach an OnPeripheralClickListener to intercept MotionEvents
from peripherals, then pass the raw MotionEvent to the
click-handling logic.
(2) For a ListView that relies on OnItemClickListener instead of adding
OnClickListener to its individual child Views:
We use TouchTrackingListView to watch (but not intercept) touch
events and store the last relevant event as a state. Then, when
OnItemClickListener is triggered, a child View can query that state
to get motion info.
Since MotionEvent will be recycled by Android framework, the state
is in the form of a plain old data class containing motion info
(ListViewTouchInfo).
So far the UI surfaces are either (1) or (2) at compile time. However,
there is at least one place that are both (1) and (2) at compile time.
They become either (1) or (2) at runtime depending on the
usage/configuration. TabListEditorMenu is one example.
To better support such places, we need to consolidate how motion info is
passed for (1) and (2) so that the click-handling methods can have a
single signature:
* Instead of:
* handleClick(MotionEvent) // for (1)
* handleClick(ListViewTouchInfo) // for (2)
* It would be better to have:
* handleClick(MotionEventInfo) // for both (1) and (2)
Changes:
* Move ListViewTouchInfo out of ListViewTouchTracker, to
//browser_ui/util/motion/MotionEventInfo.
We will use this class to pass motion info around for both (1) and
(2).
* Update OnPeripheralClickListener to pass the new MotionEventInfo
object instead of a raw MotionEvent.
* The rest of the CL is to fix method signatures for the two changes
above.
Note:
Generally it's also safer to pass motion info as a data object instead
of using a raw MotionEvent since the correctness of the latter requires
the MotionEvent not to be recycled by the Android framework before it's
read.
Bug: 375468032
Change-Id: I19c0a468761403a7fa29d072e9b51ff73013dc5c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6565526
Reviewed-by: Neil Coronado <nemco@google.com>
Reviewed-by: Wenyu Fu <wenyufu@chromium.org>
Reviewed-by: Sky Malice <skym@chromium.org>
Commit-Queue: Linyu He <linyuh@google.com>
Cr-Commit-Position: refs/heads/main@{#1463084}
Chromium is an open-source browser project that aims to build a safer, faster, and more stable way for all users to experience the web.
The project's web site is https://www.chromium.org.
To check out the source code locally, don't use git clone! Instead, follow the instructions on how to get the code.
Documentation in the source is rooted in docs/README.md.
Learn how to Get Around the Chromium Source Code Directory Structure.
For historical reasons, there are some small top level directories. Now the guidance is that new top level directories are for product (e.g. Chrome, Android WebView, Ash). Even if these products have multiple executables, the code should be in subdirectories of the product.
If you found a bug, please file it at https://crbug.com/new.