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}
49 files changed
tree: b77fd8855eb302293725cd85a7db81c97712bf9d
  1. android_webview/
  2. apps/
  3. ash/
  4. base/
  5. build/
  6. build_overrides/
  7. buildtools/
  8. cc/
  9. chrome/
  10. chromecast/
  11. chromeos/
  12. codelabs/
  13. components/
  14. content/
  15. crypto/
  16. dbus/
  17. device/
  18. docs/
  19. extensions/
  20. fuchsia_web/
  21. gin/
  22. google_apis/
  23. gpu/
  24. headless/
  25. infra/
  26. ios/
  27. ipc/
  28. media/
  29. mojo/
  30. native_client_sdk/
  31. net/
  32. pdf/
  33. ppapi/
  34. printing/
  35. remoting/
  36. rlz/
  37. sandbox/
  38. services/
  39. skia/
  40. sql/
  41. storage/
  42. styleguide/
  43. testing/
  44. third_party/
  45. tools/
  46. ui/
  47. url/
  48. webkit/
  49. .clang-format
  50. .clang-tidy
  51. .clangd
  52. .git-blame-ignore-revs
  53. .gitallowed
  54. .gitattributes
  55. .gitignore
  56. .gitmodules
  57. .gn
  58. .mailmap
  59. .rustfmt.toml
  60. .vpython3
  61. .yapfignore
  62. ATL_OWNERS
  63. AUTHORS
  64. BUILD.gn
  65. CODE_OF_CONDUCT.md
  66. codereview.settings
  67. CPPLINT.cfg
  68. CRYPTO_OWNERS
  69. DEPS
  70. DIR_METADATA
  71. LICENSE
  72. LICENSE.chromium_os
  73. OWNERS
  74. PRESUBMIT.py
  75. PRESUBMIT_test.py
  76. PRESUBMIT_test_mocks.py
  77. README.md
  78. SECURITY_OWNERS
  79. WATCHLISTS
README.md

Logo Chromium

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.