Fix injected touch coordinates for OOPIF touch emulation [chromium/src : main]

0 views
Skip to first unread message

赵裕 (Gerrit)

unread,
Jul 24, 2026, 12:28:29 AM (3 days ago) Jul 24
to android-bu...@system.gserviceaccount.com, Jonathan Ross, David Bokan, Stephen Nusko, Arthur Sonzogni, Kartar Singh, chromium...@chromium.org, devtools...@chromium.org, alexmo...@chromium.org, creis...@chromium.org, dtapuska+ch...@chromium.org, navigation...@chromium.org
Attention needed from Jonathan Ross and Kartar Singh

赵裕 added 4 comments

File components/input/render_widget_host_input_event_router.cc
Line 2105, Patchset 8: last_emulated_event_root_view_ = target->GetRootView();
if (!last_emulated_event_root_view_) {
last_emulated_event_root_view_ = target;
}
Kartar Singh . unresolved

Nit: Modify the logic to:

```
RenderWidgetHostViewInput* root_view = target->GetRootView();
last_emulated_event_root_view_ = root_view ? root_view : target;
```

```
if (!last_emulated_event_root_view_) {
last_emulated_event_root_view_ = target;
}
```
This was slightly counter-intuitive, given what we really want to check was if `target->GetRootView()` is null or not.
赵裕

Done in Patchset 10. I now store target->GetRootView() in a local root_view and assign last_emulated_event_root_view_ to root_view ? root_view : target, making the fallback explicit.

Line 2109, Patchset 7 (Parent): last_mouse_move_root_view_ ? last_mouse_move_root_view_.get() : target;
Kartar Singh . unresolved

Would just doing `target->GetRootView()` be sufficient here?

And can you please provide more context on why is this bit of code modification needed?

赵裕

target->GetRootView() is the intended value for the normal case. The fallback is retained because a child frame's GetRootView() can return null during teardown; using target preserves the router's prior fallback behavior for that case. The key change is to stop reusing last_mouse_move_root_view_, which is historical state and can refer to a different root than the injected touch's target. This keeps the touch sequence and synthesized gestures associated with the target's root view, as covered by the added regression test.

Kartar Singh

Thanks for the explanation. Makes sense.

Can we please add this to commit description to call out we are moving away from using `last_mouse_move_root_view_` as the root view for emulated touch events.

赵裕

Done in Patchset 10. The commit description now calls out that injected touch events no longer use last_mouse_move_root_view_; the router uses the injected target's root view instead, which is correct when there was no preceding mouse move.

File content/browser/devtools/protocol/input_handler.cc
File content/browser/renderer_host/render_widget_host_input_event_router_unittest.cc
Line 453, Patchset 8: EXPECT_EQ(kPointInRoot,
child.view->TransformPointToRootCoordSpaceF(kPointInChild));
Kartar Singh . unresolved

Nit: Let's reverse the check here and in other places.

`Prefer (foo == 0) to (0 == foo).`

https://chromium.googlesource.com/chromium/src/+/HEAD/styleguide/c++/c++.md#code-formatting

赵裕

Done in Patchset 10. Reversed the comparison operands in the regression test as suggested.

Open in Gerrit

Related details

Attention is currently required from:
  • Jonathan Ross
  • Kartar Singh
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: I842e242d1594d5f9f0efb85be75d086ebb30034a
Gerrit-Change-Number: 8128317
Gerrit-PatchSet: 10
Gerrit-Owner: 赵裕 <vime...@gmail.com>
Gerrit-Reviewer: Arthur Sonzogni <arthurs...@chromium.org>
Gerrit-Reviewer: Kartar Singh <karta...@google.com>
Gerrit-CC: David Bokan <bo...@chromium.org>
Gerrit-CC: Jonathan Ross <jon...@chromium.org>
Gerrit-CC: Stephen Nusko <nus...@chromium.org>
Gerrit-Attention: Jonathan Ross <jon...@chromium.org>
Gerrit-Attention: Kartar Singh <karta...@google.com>
Gerrit-Comment-Date: Fri, 24 Jul 2026 04:28:21 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: 赵裕 <vime...@gmail.com>
Comment-In-Reply-To: Kartar Singh <karta...@google.com>
satisfied_requirement
unsatisfied_requirement
open
diffy

Kartar Singh (Gerrit)

unread,
Jul 24, 2026, 6:43:08 AM (2 days ago) Jul 24
to 赵裕, android-bu...@system.gserviceaccount.com, Jonathan Ross, David Bokan, Stephen Nusko, Arthur Sonzogni, chromium...@chromium.org, devtools...@chromium.org, alexmo...@chromium.org, creis...@chromium.org, dtapuska+ch...@chromium.org, navigation...@chromium.org
Attention needed from Arthur Sonzogni, Jonathan Ross and 赵裕

Kartar Singh voted and added 6 comments

Votes added by Kartar Singh

Code-Review+1

6 comments

Patchset-level comments
File-level comment, Patchset 8:
Arthur Sonzogni . resolved

I am defering to @karta...@google.com: Please close this once he approved.

Kartar Singh

Done

File-level comment, Patchset 10 (Latest):
Kartar Singh . resolved

LGTM, Thanks for the fix :)

File components/input/render_widget_host_input_event_router.cc
Line 2105, Patchset 8: last_emulated_event_root_view_ = target->GetRootView();
if (!last_emulated_event_root_view_) {
last_emulated_event_root_view_ = target;
}
Kartar Singh . resolved

Nit: Modify the logic to:

```
RenderWidgetHostViewInput* root_view = target->GetRootView();
last_emulated_event_root_view_ = root_view ? root_view : target;
```

```
if (!last_emulated_event_root_view_) {
last_emulated_event_root_view_ = target;
}
```
This was slightly counter-intuitive, given what we really want to check was if `target->GetRootView()` is null or not.
赵裕

Done in Patchset 10. I now store target->GetRootView() in a local root_view and assign last_emulated_event_root_view_ to root_view ? root_view : target, making the fallback explicit.

Kartar Singh

Acknowledged. Feel free to generally mark comments `Resolved`, once you have addressed them.

Line 2109, Patchset 7 (Parent): last_mouse_move_root_view_ ? last_mouse_move_root_view_.get() : target;
Kartar Singh . resolved

Would just doing `target->GetRootView()` be sufficient here?

And can you please provide more context on why is this bit of code modification needed?

赵裕

target->GetRootView() is the intended value for the normal case. The fallback is retained because a child frame's GetRootView() can return null during teardown; using target preserves the router's prior fallback behavior for that case. The key change is to stop reusing last_mouse_move_root_view_, which is historical state and can refer to a different root than the injected touch's target. This keeps the touch sequence and synthesized gestures associated with the target's root view, as covered by the added regression test.

Kartar Singh

Thanks for the explanation. Makes sense.

Can we please add this to commit description to call out we are moving away from using `last_mouse_move_root_view_` as the root view for emulated touch events.

赵裕

Done in Patchset 10. The commit description now calls out that injected touch events no longer use last_mouse_move_root_view_; the router uses the injected target's root view instead, which is correct when there was no preceding mouse move.

Kartar Singh

Acknowledged

File content/browser/devtools/protocol/input_handler.cc
File content/browser/renderer_host/render_widget_host_input_event_router_unittest.cc
Line 453, Patchset 8: EXPECT_EQ(kPointInRoot,
child.view->TransformPointToRootCoordSpaceF(kPointInChild));
Kartar Singh . resolved

Nit: Let's reverse the check here and in other places.

`Prefer (foo == 0) to (0 == foo).`

https://chromium.googlesource.com/chromium/src/+/HEAD/styleguide/c++/c++.md#code-formatting

赵裕

Done in Patchset 10. Reversed the comparison operands in the regression test as suggested.

Kartar Singh

Acknowledged

Open in Gerrit

Related details

Attention is currently required from:
  • Arthur Sonzogni
  • Jonathan Ross
  • 赵裕
Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not satisfiedCode-Owners
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedReview-Enforcement
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: I842e242d1594d5f9f0efb85be75d086ebb30034a
    Gerrit-Change-Number: 8128317
    Gerrit-PatchSet: 10
    Gerrit-Owner: 赵裕 <vime...@gmail.com>
    Gerrit-Reviewer: Arthur Sonzogni <arthurs...@chromium.org>
    Gerrit-Reviewer: Kartar Singh <karta...@google.com>
    Gerrit-CC: David Bokan <bo...@chromium.org>
    Gerrit-CC: Jonathan Ross <jon...@chromium.org>
    Gerrit-CC: Stephen Nusko <nus...@chromium.org>
    Gerrit-Attention: Jonathan Ross <jon...@chromium.org>
    Gerrit-Attention: 赵裕 <vime...@gmail.com>
    Gerrit-Attention: Arthur Sonzogni <arthurs...@chromium.org>
    Gerrit-Comment-Date: Fri, 24 Jul 2026 10:42:49 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: Yes
    Comment-In-Reply-To: 赵裕 <vime...@gmail.com>
    Comment-In-Reply-To: Arthur Sonzogni <arthurs...@chromium.org>
    Comment-In-Reply-To: Kartar Singh <karta...@google.com>
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Arthur Sonzogni (Gerrit)

    unread,
    Jul 24, 2026, 7:48:37 AM (2 days ago) Jul 24
    to 赵裕, Chromium LUCI CQ, Kartar Singh, android-bu...@system.gserviceaccount.com, Jonathan Ross, David Bokan, Stephen Nusko, chromium...@chromium.org, devtools...@chromium.org, alexmo...@chromium.org, creis...@chromium.org, dtapuska+ch...@chromium.org, navigation...@chromium.org
    Attention needed from Jonathan Ross and 赵裕

    Arthur Sonzogni voted and added 1 comment

    Votes added by Arthur Sonzogni

    Code-Review+1
    Commit-Queue+2

    1 comment

    Patchset-level comments
    File-level comment, Patchset 10 (Latest):
    Arthur Sonzogni . resolved

    Thanks!

    STAMP (defered to input owners)

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Jonathan Ross
    • 赵裕
    Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement satisfiedCode-Owners
    • requirement satisfiedCode-Review
    • requirement satisfiedReview-Enforcement
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: I842e242d1594d5f9f0efb85be75d086ebb30034a
    Gerrit-Change-Number: 8128317
    Gerrit-PatchSet: 10
    Gerrit-Owner: 赵裕 <vime...@gmail.com>
    Gerrit-Reviewer: Arthur Sonzogni <arthurs...@chromium.org>
    Gerrit-Reviewer: Kartar Singh <karta...@google.com>
    Gerrit-CC: David Bokan <bo...@chromium.org>
    Gerrit-CC: Jonathan Ross <jon...@chromium.org>
    Gerrit-CC: Stephen Nusko <nus...@chromium.org>
    Gerrit-Attention: Jonathan Ross <jon...@chromium.org>
    Gerrit-Attention: 赵裕 <vime...@gmail.com>
    Gerrit-Comment-Date: Fri, 24 Jul 2026 11:48:18 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: Yes
    satisfied_requirement
    open
    diffy

    Chromium LUCI CQ (Gerrit)

    unread,
    Jul 24, 2026, 8:24:53 AM (2 days ago) Jul 24
    to 赵裕, Arthur Sonzogni, Kartar Singh, android-bu...@system.gserviceaccount.com, Jonathan Ross, David Bokan, Stephen Nusko, chromium...@chromium.org, devtools...@chromium.org, alexmo...@chromium.org, creis...@chromium.org, dtapuska+ch...@chromium.org, navigation...@chromium.org

    Chromium LUCI CQ submitted the change

    Change information

    Commit message:
    Fix injected touch coordinates for OOPIF touch emulation

    DevTools injected touch points are specified in root-view coordinates.
    After OOPIF hit testing, the legacy injection path converted them to the
    target view's coordinates, and TouchEmulatorImpl then converted them back
    to root coordinates for gesture synthesis. This round trip could apply an
    OOPIF offset twice to synthesized compatibility clicks and gestures.

    Keep injected touch points in root-view coordinates through the touch
    emulator and emulated event router. The input event router performs the
    single root-to-target conversion only when dispatching to the renderer.
    Compute screen coordinates from the root view as well.

    Also stop using last_mouse_move_root_view_ for injected touch events.
    Instead, route the emulated touch sequence through the root view of the
    injected target, which remains correct when no prior mouse move exists.
    Bug: 537416055
    Test: content_unittests
    Change-Id: I842e242d1594d5f9f0efb85be75d086ebb30034a
    Reviewed-by: Arthur Sonzogni <arthurs...@chromium.org>
    Reviewed-by: Kartar Singh <karta...@google.com>
    Commit-Queue: Arthur Sonzogni <arthurs...@chromium.org>
    Cr-Commit-Position: refs/heads/main@{#1667791}
    Files:
    • M AUTHORS
    • M components/input/render_widget_host_input_event_router.cc
    • M content/browser/devtools/protocol/input_handler.cc
    • M content/browser/renderer_host/input/touch_emulator_impl.cc
    • M content/browser/renderer_host/render_widget_host_input_event_router_unittest.cc
    Change size: M
    Delta: 5 files changed, 132 insertions(+), 14 deletions(-)
    Branch: refs/heads/main
    Submit Requirements:
    • requirement satisfiedCode-Review: +1 by Kartar Singh, +1 by Arthur Sonzogni
    Open in Gerrit
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: merged
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: I842e242d1594d5f9f0efb85be75d086ebb30034a
    Gerrit-Change-Number: 8128317
    Gerrit-PatchSet: 11
    Gerrit-Owner: 赵裕 <vime...@gmail.com>
    Gerrit-Reviewer: Arthur Sonzogni <arthurs...@chromium.org>
    Gerrit-Reviewer: Chromium LUCI CQ <chromiu...@luci-project-accounts.iam.gserviceaccount.com>
    Gerrit-Reviewer: Kartar Singh <karta...@google.com>
    open
    diffy
    satisfied_requirement

    luci-bisection@appspot.gserviceaccount.com (Gerrit)

    unread,
    Jul 24, 2026, 5:21:04 PM (2 days ago) Jul 24
    to 赵裕, Chromium LUCI CQ, Arthur Sonzogni, Kartar Singh, android-bu...@system.gserviceaccount.com, Jonathan Ross, David Bokan, Stephen Nusko, chromium...@chromium.org, devtools...@chromium.org, alexmo...@chromium.org, creis...@chromium.org, dtapuska+ch...@chromium.org, navigation...@chromium.org

    Message from luci-bi...@appspot.gserviceaccount.com

    LUCI Bisection has identified this change as the cause of a test failure. See the analysis: https://ci.chromium.org/ui/p/chromium/bisection/test-analysis/b/4684306447335424

    Sample build with failed test: https://ci.chromium.org/b/8675393698746547873
    Affected test(s):
    [://\:chrome_wpt_tests!webtest::external/wpt/event-timing#event-click-visibilitychange.html](https://ci.chromium.org/ui/test/chromium/:%2F%2F%5C:chrome_wpt_tests%21webtest::external%2Fwpt%2Fevent-timing%23event-click-visibilitychange.html?q=VHash%3A6129bda16b001a29)
    [://\:chrome_wpt_tests!webtest::external/wpt/pointerevents#pointerevent_capture_touch_and_release_at_got_capture.html](https://ci.chromium.org/ui/test/chromium/:%2F%2F%5C:chrome_wpt_tests%21webtest::external%2Fwpt%2Fpointerevents%23pointerevent_capture_touch_and_release_at_got_capture.html?q=VHash%3A6129bda16b001a29)
    [://\:chrome_wpt_tests!webtest::external/wpt/pointerevents#pointerevent_click_during_parent_capture.html?pointerType=touch&preventDefault=touchstart](https://ci.chromium.org/ui/test/chromium/:%2F%2F%5C:chrome_wpt_tests%21webtest::external%2Fwpt%2Fpointerevents%23pointerevent_click_during_parent_capture.html%3FpointerType=touch&preventDefault=touchstart?q=VHash%3A6129bda16b001a29)
    [://\:chrome_wpt_tests!webtest::external/wpt/pointerevents#pointerevent_disabled_form_control.html?touch](https://ci.chromium.org/ui/test/chromium/:%2F%2F%5C:chrome_wpt_tests%21webtest::external%2Fwpt%2Fpointerevents%23pointerevent_disabled_form_control.html%3Ftouch?q=VHash%3A6129bda16b001a29)
    [://\:chrome_wpt_tests!webtest::external/wpt/pointerevents#pointerevent_element_haspointercapture.html?touch](https://ci.chromium.org/ui/test/chromium/:%2F%2F%5C:chrome_wpt_tests%21webtest::external%2Fwpt%2Fpointerevents%23pointerevent_element_haspointercapture.html%3Ftouch?q=VHash%3A6129bda16b001a29)
    and 7 more ...
    A revert for this change was not created because the builder that this CL broke is not watched by gardeners, therefore less important. You can consider revert this CL, fix forward or let builder owners resolve it themselves.

    If this is a false positive, please report it at http://b.corp.google.com/createIssue?component=1199205&description=Analysis%3A+https%3A%2F%2Fci.chromium.org%2Fui%2Fp%2Fchromium%2Fbisection%2Ftest-analysis%2Fb%2F4684306447335424&format=PLAIN&priority=P3&title=Wrongly+blamed+https%3A%2F%2Fchromium-review.googlesource.com%2Fc%2Fchromium%2Fsrc%2F%2B%2F8128317&type=BUG

    Open in Gerrit

    Related details

    Attention set is empty
    Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement satisfiedCode-Owners
    • requirement satisfiedCode-Review
    • requirement satisfiedReview-Enforcement
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: I842e242d1594d5f9f0efb85be75d086ebb30034a
    Gerrit-Change-Number: 8128317
    Gerrit-PatchSet: 11
    Gerrit-Owner: 赵裕 <vime...@gmail.com>
    Gerrit-Reviewer: Arthur Sonzogni <arthurs...@chromium.org>
    Gerrit-Reviewer: Chromium LUCI CQ <chromiu...@luci-project-accounts.iam.gserviceaccount.com>
    Gerrit-Reviewer: Kartar Singh <karta...@google.com>
    Gerrit-CC: David Bokan <bo...@chromium.org>
    Gerrit-CC: Jonathan Ross <jon...@chromium.org>
    Gerrit-CC: Stephen Nusko <nus...@chromium.org>
    Gerrit-Comment-Date: Fri, 24 Jul 2026 21:20:51 +0000
    Gerrit-HasComments: No
    Gerrit-Has-Labels: No
    satisfied_requirement
    open
    diffy
    Reply all
    Reply to author
    Forward
    0 new messages