Request focus on mouse down events on Android [chromium/src : main]

1 view
Skip to first unread message

Mark Schillaci (Gerrit)

unread,
May 28, 2026, 6:20:00 PM (3 days ago) May 28
to Theresa Wellington, Salvador Guerrero Ramos, Fiaz Muhammad, android-bu...@system.gserviceaccount.com, Chromium LUCI CQ, chromium...@chromium.org, Zhe Su, alexmo...@chromium.org, creis...@chromium.org, keithle...@chromium.org, navigation...@chromium.org, nona+...@chromium.org, shuche...@chromium.org, tranbaod...@chromium.org, yhanad...@chromium.org
Attention needed from Theresa Wellington

Mark Schillaci added 1 comment

Patchset-level comments
File-level comment, Patchset 2 (Latest):
Mark Schillaci . resolved

Theresa - PTAL
Sal / Fiaz - cc for FYI

Open in Gerrit

Related details

Attention is currently required from:
  • Theresa Wellington
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: I8421c2396689ab80ff823369204da8ded7eb4984
Gerrit-Change-Number: 7883526
Gerrit-PatchSet: 2
Gerrit-Owner: Mark Schillaci <mschi...@google.com>
Gerrit-Reviewer: Mark Schillaci <mschi...@google.com>
Gerrit-Reviewer: Theresa Wellington <twell...@chromium.org>
Gerrit-CC: Fiaz Muhammad <mf...@google.com>
Gerrit-CC: Salvador Guerrero Ramos <sa...@google.com>
Gerrit-CC: Zhe Su <su...@chromium.org>
Gerrit-Attention: Theresa Wellington <twell...@chromium.org>
Gerrit-Comment-Date: Thu, 28 May 2026 22:19:47 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Theresa Wellington (Gerrit)

unread,
May 28, 2026, 6:43:56 PM (3 days ago) May 28
to Mark Schillaci, Bo Liu, Mustaq Ahmed, Salvador Guerrero Ramos, Fiaz Muhammad, android-bu...@system.gserviceaccount.com, Chromium LUCI CQ, chromium...@chromium.org, Zhe Su, alexmo...@chromium.org, creis...@chromium.org, keithle...@chromium.org, navigation...@chromium.org, nona+...@chromium.org, shuche...@chromium.org, tranbaod...@chromium.org, yhanad...@chromium.org
Attention needed from Bo Liu, Mark Schillaci and Mustaq Ahmed

Theresa Wellington voted and added 1 comment

Votes added by Theresa Wellington

Code-Review+1

1 comment

Patchset-level comments
Theresa Wellington . resolved

Thanks for the great description / explanation, Mark!

This seems reasonable to me, but adding @boliu who appears to have reviewed in this space before and @mustaq@ for any needed web input expertise

Open in Gerrit

Related details

Attention is currently required from:
  • Bo Liu
  • Mark Schillaci
  • Mustaq Ahmed
Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not 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: I8421c2396689ab80ff823369204da8ded7eb4984
    Gerrit-Change-Number: 7883526
    Gerrit-PatchSet: 2
    Gerrit-Owner: Mark Schillaci <mschi...@google.com>
    Gerrit-Reviewer: Bo Liu <bo...@chromium.org>
    Gerrit-Reviewer: Mark Schillaci <mschi...@google.com>
    Gerrit-Reviewer: Mustaq Ahmed <mus...@chromium.org>
    Gerrit-Reviewer: Theresa Wellington <twell...@chromium.org>
    Gerrit-CC: Fiaz Muhammad <mf...@google.com>
    Gerrit-CC: Salvador Guerrero Ramos <sa...@google.com>
    Gerrit-CC: Zhe Su <su...@chromium.org>
    Gerrit-Attention: Mark Schillaci <mschi...@google.com>
    Gerrit-Attention: Mustaq Ahmed <mus...@chromium.org>
    Gerrit-Attention: Bo Liu <bo...@chromium.org>
    Gerrit-Comment-Date: Thu, 28 May 2026 22:43:42 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: Yes
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Mark Schillaci (Gerrit)

    unread,
    May 28, 2026, 8:30:54 PM (3 days ago) May 28
    to Bo Liu, Mustaq Ahmed, Theresa Wellington, Salvador Guerrero Ramos, Fiaz Muhammad, android-bu...@system.gserviceaccount.com, Chromium LUCI CQ, chromium...@chromium.org, Zhe Su, alexmo...@chromium.org, creis...@chromium.org, keithle...@chromium.org, navigation...@chromium.org, nona+...@chromium.org, shuche...@chromium.org, tranbaod...@chromium.org, yhanad...@chromium.org
    Attention needed from Bo Liu and Mustaq Ahmed

    Mark Schillaci added 1 comment

    Patchset-level comments
    Mark Schillaci . resolved

    Thank you Theresa for the review!

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Bo Liu
    • Mustaq Ahmed
    Gerrit-Attention: Mustaq Ahmed <mus...@chromium.org>
    Gerrit-Attention: Bo Liu <bo...@chromium.org>
    Gerrit-Comment-Date: Fri, 29 May 2026 00:30:39 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Bo Liu (Gerrit)

    unread,
    May 28, 2026, 10:09:35 PM (3 days ago) May 28
    to Mark Schillaci, Bo Liu, Mustaq Ahmed, Theresa Wellington, Salvador Guerrero Ramos, Fiaz Muhammad, android-bu...@system.gserviceaccount.com, Chromium LUCI CQ, chromium...@chromium.org, Zhe Su, alexmo...@chromium.org, creis...@chromium.org, keithle...@chromium.org, navigation...@chromium.org, nona+...@chromium.org, shuche...@chromium.org, tranbaod...@chromium.org, yhanad...@chromium.org
    Attention needed from Mark Schillaci and Mustaq Ahmed

    Bo Liu added 2 comments

    File content/browser/renderer_host/render_widget_host_view_android.cc
    Line 3100, Patchset 3 (Latest): // touch ACTION_DOWN is filtered out in Java. We explicitly request focus
    Bo Liu . unresolved

    what is this referring to? can you link to code?

    Line 3102, Patchset 3 (Latest): // This mirrors the touch-focus logic inside OnTouchEvent().
    Bo Liu . unresolved
    Open in Gerrit

    Related details

    Attention is currently required from:
    • Mark Schillaci
    • Mustaq Ahmed
    Submit Requirements:
      • requirement satisfiedCode-Coverage
      • requirement is not satisfiedCode-Owners
      • requirement satisfiedCode-Review
      • requirement is not satisfiedNo-Unresolved-Comments
      • 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: I8421c2396689ab80ff823369204da8ded7eb4984
      Gerrit-Change-Number: 7883526
      Gerrit-PatchSet: 3
      Gerrit-Owner: Mark Schillaci <mschi...@google.com>
      Gerrit-Reviewer: Bo Liu <bo...@chromium.org>
      Gerrit-Reviewer: Mark Schillaci <mschi...@google.com>
      Gerrit-Reviewer: Mustaq Ahmed <mus...@chromium.org>
      Gerrit-Reviewer: Theresa Wellington <twell...@chromium.org>
      Gerrit-CC: Fiaz Muhammad <mf...@google.com>
      Gerrit-CC: Salvador Guerrero Ramos <sa...@google.com>
      Gerrit-CC: Zhe Su <su...@chromium.org>
      Gerrit-Attention: Mark Schillaci <mschi...@google.com>
      Gerrit-Attention: Mustaq Ahmed <mus...@chromium.org>
      Gerrit-Comment-Date: Fri, 29 May 2026 02:09:20 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: No
      satisfied_requirement
      unsatisfied_requirement
      open
      diffy

      Mark Schillaci (Gerrit)

      unread,
      May 29, 2026, 11:56:04 AM (3 days ago) May 29
      to Bo Liu, Mustaq Ahmed, Theresa Wellington, Salvador Guerrero Ramos, Fiaz Muhammad, android-bu...@system.gserviceaccount.com, Chromium LUCI CQ, chromium...@chromium.org, Zhe Su, alexmo...@chromium.org, creis...@chromium.org, keithle...@chromium.org, navigation...@chromium.org, nona+...@chromium.org, shuche...@chromium.org, tranbaod...@chromium.org, yhanad...@chromium.org
      Attention needed from Bo Liu and Mustaq Ahmed

      Mark Schillaci added 3 comments

      Patchset-level comments
      File-level comment, Patchset 4 (Latest):
      Mark Schillaci . resolved

      Thank you Bo for the review! Comments addressed!

      File content/browser/renderer_host/render_widget_host_view_android.cc
      Line 3100, Patchset 3: // touch ACTION_DOWN is filtered out in Java. We explicitly request focus
      Bo Liu . resolved

      what is this referring to? can you link to code?

      Mark Schillaci
      Line 3102, Patchset 3: // This mirrors the touch-focus logic inside OnTouchEvent().
      Bo Liu . unresolved

      both seem kinda sketchy though.. I would expect container view to shift focus back for these cases here:
      https://source.chromium.org/chromium/chromium/src/+/main:components/embedder_support/android/java/src/org/chromium/components/embedder_support/view/ContentView.java;drc=2e070bfa61f747388fddaafd8eaf9519f89e80de;l=412

      why doesn't that work?

      Mark Schillaci

      ContentView.java#onFocusChanged is never called in this case because ContentView.java#onTouchEvent doesn't ever call super.onTouchEvent. Normally that would be where a standard Android View would request focus. But we plumb our clicks/taps down to C++ to be natively handled, and it is the C++ code that actually triggers the ContentView.java#onFocusChanged call. For OnTouchEvents (taps), the Focus() call is what triggers this via JNI: https://source.chromium.org/chromium/chromium/src/+/main:content/browser/renderer_host/render_widget_host_view_android.cc;drc=2c42d1f2cc1b1b5730aad0524d18c94f61352c55;l=1578
      but without an explicit Focus() call, RWHVA::OnMouseEvent isn't ever triggering ContentView.java#onFocusChanged.

      As far as sketchiness - I think this is an artifact of managing all the touch/focus in C++ so we can send it to Blink and may be something to address at a more holistic level. This CL is really just bringing symmetry to the existing implementation to effectively complete the API contract so mouse clicks act the same way as taps.

      lmkwyt!

      Open in Gerrit

      Related details

      Attention is currently required from:
      • Bo Liu
      • Mustaq Ahmed
      Submit Requirements:
      • requirement satisfiedCode-Coverage
      • requirement is not satisfiedCode-Owners
      • requirement satisfiedCode-Review
      • requirement is not satisfiedNo-Unresolved-Comments
      • 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: I8421c2396689ab80ff823369204da8ded7eb4984
      Gerrit-Change-Number: 7883526
      Gerrit-PatchSet: 4
      Gerrit-Owner: Mark Schillaci <mschi...@google.com>
      Gerrit-Reviewer: Bo Liu <bo...@chromium.org>
      Gerrit-Reviewer: Mark Schillaci <mschi...@google.com>
      Gerrit-Reviewer: Mustaq Ahmed <mus...@chromium.org>
      Gerrit-Reviewer: Theresa Wellington <twell...@chromium.org>
      Gerrit-CC: Fiaz Muhammad <mf...@google.com>
      Gerrit-CC: Salvador Guerrero Ramos <sa...@google.com>
      Gerrit-CC: Zhe Su <su...@chromium.org>
      Gerrit-Attention: Mustaq Ahmed <mus...@chromium.org>
      Gerrit-Attention: Bo Liu <bo...@chromium.org>
      Gerrit-Comment-Date: Fri, 29 May 2026 15:55:50 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: No
      Comment-In-Reply-To: Bo Liu <bo...@chromium.org>
      satisfied_requirement
      unsatisfied_requirement
      open
      diffy

      Mustaq Ahmed (Gerrit)

      unread,
      May 29, 2026, 12:23:51 PM (3 days ago) May 29
      to Mark Schillaci, Bo Liu, Theresa Wellington, Salvador Guerrero Ramos, Fiaz Muhammad, android-bu...@system.gserviceaccount.com, Chromium LUCI CQ, chromium...@chromium.org, Zhe Su, alexmo...@chromium.org, creis...@chromium.org, keithle...@chromium.org, navigation...@chromium.org, nona+...@chromium.org, shuche...@chromium.org, tranbaod...@chromium.org, yhanad...@chromium.org
      Attention needed from Bo Liu and Mark Schillaci

      Mustaq Ahmed added 2 comments

      Commit Message
      Line 25, Patchset 4 (Latest):explicitly request focus. This matches the existing touch logic for
      focus in OnTouchEvent (which is why taps did not have this issue).
      Mustaq Ahmed . unresolved

      WebView is [excluded](https://crsrc.org/c/android_webview/browser/aw_field_trials.cc;drc=44669f73ac4d53bdfd4bc0be0957405c25277eef;l=235) from that touch focusing logic. Do we want to match that special case here too? If that's not the case, please add a comment in the code explaining why.

      File content/browser/renderer_host/render_widget_host_view_android.cc
      Line 3101, Patchset 4 (Latest): if (!HasFocus()) {
      Mustaq Ahmed . unresolved

      May we please guard this behind a flag? We seem to have encountered regressions when adding the corresponding touch-event focusing: https://crbug.com/378779896, https://crbug.com/373672168.

      Open in Gerrit

      Related details

      Attention is currently required from:
      • Bo Liu
      • Mark Schillaci
      Gerrit-Attention: Mark Schillaci <mschi...@google.com>
      Gerrit-Attention: Bo Liu <bo...@chromium.org>
      Gerrit-Comment-Date: Fri, 29 May 2026 16:23:36 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: No
      satisfied_requirement
      unsatisfied_requirement
      open
      diffy

      Mark Schillaci (Gerrit)

      unread,
      May 29, 2026, 4:45:13 PM (2 days ago) May 29
      to Bo Liu, Mustaq Ahmed, Theresa Wellington, Salvador Guerrero Ramos, Fiaz Muhammad, android-bu...@system.gserviceaccount.com, Chromium LUCI CQ, chromium...@chromium.org, Zhe Su, alexmo...@chromium.org, creis...@chromium.org, keithle...@chromium.org, navigation...@chromium.org, nona+...@chromium.org, shuche...@chromium.org, tranbaod...@chromium.org, yhanad...@chromium.org
      Attention needed from Bo Liu

      Mark Schillaci added 3 comments

      Patchset-level comments
      File-level comment, Patchset 5 (Latest):
      Mark Schillaci . resolved

      Thank you Mustaq for the review! Comments addressed!

      Commit Message
      Line 25, Patchset 4:explicitly request focus. This matches the existing touch logic for

      focus in OnTouchEvent (which is why taps did not have this issue).
      Mustaq Ahmed . unresolved

      WebView is [excluded](https://crsrc.org/c/android_webview/browser/aw_field_trials.cc;drc=44669f73ac4d53bdfd4bc0be0957405c25277eef;l=235) from that touch focusing logic. Do we want to match that special case here too? If that's not the case, please add a comment in the code explaining why.

      Mark Schillaci

      Oh great catch, thank you! So I did some research and I think we want to include this even on WebView. The issue with touchs/taps for WebViews AFAIU is that they would steal the focus from the native views. Even scrolling on the page would still the focus. However mouse clicks are not for scrolling and would not steal focus during a scroll, but clicks are meant to bring focus to the view. I added a comment in the code for the same.

      please lmkwyt!

      File content/browser/renderer_host/render_widget_host_view_android.cc
      Line 3101, Patchset 4: if (!HasFocus()) {
      Mustaq Ahmed . unresolved

      May we please guard this behind a flag? We seem to have encountered regressions when adding the corresponding touch-event focusing: https://crbug.com/378779896, https://crbug.com/373672168.

      Mark Schillaci

      Sure, sounds good!

      I have an in-flight CL to add a flag, once landed I'll use it in this CL: crrev.com/c/7884688

      Moving this CL to WIP until that time. Thanks!

      Open in Gerrit

      Related details

      Attention is currently required from:
      • Bo Liu
      Submit Requirements:
      • requirement satisfiedCode-Coverage
      • requirement is not satisfiedCode-Owners
      • requirement satisfiedCode-Review
      • requirement is not satisfiedNo-Unresolved-Comments
      • 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: I8421c2396689ab80ff823369204da8ded7eb4984
      Gerrit-Change-Number: 7883526
      Gerrit-PatchSet: 5
      Gerrit-Owner: Mark Schillaci <mschi...@google.com>
      Gerrit-Reviewer: Bo Liu <bo...@chromium.org>
      Gerrit-Reviewer: Mark Schillaci <mschi...@google.com>
      Gerrit-Reviewer: Mustaq Ahmed <mus...@chromium.org>
      Gerrit-Reviewer: Theresa Wellington <twell...@chromium.org>
      Gerrit-CC: Fiaz Muhammad <mf...@google.com>
      Gerrit-CC: Salvador Guerrero Ramos <sa...@google.com>
      Gerrit-CC: Zhe Su <su...@chromium.org>
      Gerrit-Attention: Bo Liu <bo...@chromium.org>
      Gerrit-Comment-Date: Fri, 29 May 2026 20:44:59 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: No
      Comment-In-Reply-To: Mustaq Ahmed <mus...@chromium.org>
      satisfied_requirement
      unsatisfied_requirement
      open
      diffy

      Bo Liu (Gerrit)

      unread,
      May 31, 2026, 11:11:35 PM (1 hour ago) May 31
      to Mark Schillaci, Bo Liu, Mustaq Ahmed, Theresa Wellington, Salvador Guerrero Ramos, Fiaz Muhammad, android-bu...@system.gserviceaccount.com, Chromium LUCI CQ, chromium...@chromium.org, Zhe Su, alexmo...@chromium.org, creis...@chromium.org, keithle...@chromium.org, navigation...@chromium.org, nona+...@chromium.org, shuche...@chromium.org, tranbaod...@chromium.org, yhanad...@chromium.org
      Attention needed from Mark Schillaci

      Bo Liu added 2 comments

      File content/browser/renderer_host/render_widget_host_view_android.cc
      Line 3100, Patchset 3: // touch ACTION_DOWN is filtered out in Java. We explicitly request focus
      Bo Liu . resolved

      what is this referring to? can you link to code?

      Mark Schillaci

      ContentView's onTouchEvent plumbs to the EventForwarder.onTouchEvent here: https://source.chromium.org/chromium/chromium/src/+/main:components/embedder_support/android/java/src/org/chromium/components/embedder_support/view/ContentView.java;drc=511e00094eaca80cb55a3be19511128e15fb2ae7;l=511

      which ultimately calls through to sendNativeMouseEvent, where the ACTION_DOWN and ACTION_UP actions are consumed before going to JNI:
      https://source.chromium.org/chromium/chromium/src/+/main:ui/android/java/src/org/chromium/ui/base/EventForwarder.java;drc=fcc8e2e643f4beab78d87a7a8566f0ed50332666;l=520

      Added a comment to the code, thanks!

      Bo Liu

      well, "filtering" sounds kinda weird.. It's more like ContentView "handles" the event by returning true?

      but according to the other comment, it's not returning true that's the problem, it's not calling the default onTouchEvent (ie calling super.onTouchEvent, which we obviously do not want to do) that's skipping focus request?

      Line 3102, Patchset 3: // This mirrors the touch-focus logic inside OnTouchEvent().
      Bo Liu . unresolved

      both seem kinda sketchy though.. I would expect container view to shift focus back for these cases here:
      https://source.chromium.org/chromium/chromium/src/+/main:components/embedder_support/android/java/src/org/chromium/components/embedder_support/view/ContentView.java;drc=2e070bfa61f747388fddaafd8eaf9519f89e80de;l=412

      why doesn't that work?

      Mark Schillaci

      ContentView.java#onFocusChanged is never called in this case because ContentView.java#onTouchEvent doesn't ever call super.onTouchEvent. Normally that would be where a standard Android View would request focus. But we plumb our clicks/taps down to C++ to be natively handled, and it is the C++ code that actually triggers the ContentView.java#onFocusChanged call. For OnTouchEvents (taps), the Focus() call is what triggers this via JNI: https://source.chromium.org/chromium/chromium/src/+/main:content/browser/renderer_host/render_widget_host_view_android.cc;drc=2c42d1f2cc1b1b5730aad0524d18c94f61352c55;l=1578
      but without an explicit Focus() call, RWHVA::OnMouseEvent isn't ever triggering ContentView.java#onFocusChanged.

      As far as sketchiness - I think this is an artifact of managing all the touch/focus in C++ so we can send it to Blink and may be something to address at a more holistic level. This CL is really just bringing symmetry to the existing implementation to effectively complete the API contract so mouse clicks act the same way as taps.

      lmkwyt!

      Bo Liu

      existing implementation is hacky, and buggy on webview..

      can this be handled entirely within java side? so ContentView for chrome, and AwContents for webview

      Open in Gerrit

      Related details

      Attention is currently required from:
      • Mark Schillaci
      Gerrit-Attention: Mark Schillaci <mschi...@google.com>
      Gerrit-Comment-Date: Mon, 01 Jun 2026 03:11:20 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: No
      Comment-In-Reply-To: Mark Schillaci <mschi...@google.com>
      Comment-In-Reply-To: Bo Liu <bo...@chromium.org>
      satisfied_requirement
      unsatisfied_requirement
      open
      diffy
      Reply all
      Reply to author
      Forward
      0 new messages