Skip to content

Commit cbc0f67

Browse files
chore: cherry-pick 22871e619f from chromium (#42057)
* chore: cherry-pick 22871e619f from chromium * chore: update patches --------- Co-authored-by: PatchUp <73610968+patchup[bot]@users.noreply.github.com>
1 parent 8fbabea commit cbc0f67

File tree

2 files changed

+57
-0
lines changed

2 files changed

+57
-0
lines changed

patches/chromium/.patches

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,3 +138,4 @@ bindings_refactor_domdatastore.patch
138138
merge_fix_domarraybuffer_isdetached_and_comment_out_a_check.patch
139139
cherry-pick-98bcf9ef5cdd.patch
140140
cherry-pick-c1f25647c2fc.patch
141+
a11y_avoid_clearing_resetting_focus_on_an_already_focus_event.patch
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2+
From: Benjamin Beaudry <[email protected]>
3+
Date: Fri, 8 Mar 2024 21:16:50 +0000
4+
Subject: Avoid clearing/resetting focus on an already focus event
5+
MIME-Version: 1.0
6+
Content-Type: text/plain; charset=UTF-8
7+
Content-Transfer-Encoding: 8bit
8+
9+
When we set the focus via an accessibility API on an element that
10+
is already focused, we first remove the focus and reset it. This
11+
leads to blur/focusout/focusin events being fired again.
12+
13+
This behavior is different than the one we get when we set focus
14+
programmatically, with a mouse, or a keyboard, on an already
15+
focused element. In order to keep the same experience across all
16+
input modalities, this CL removes the divergent focus behavior
17+
for accessibility APIs.
18+
19+
We tried to remove this code two years ago (CL:3547796) but it
20+
got reverted due to bug:40850837. This time, I made sure to discuss
21+
this issue with the Chrome Android accessibility owners to make 
22+
sure it's safe to remove. They landed CL:5345750, and then gave
23+
us the green light to land this CL.
24+
25+
Fixed: 40830307
26+
Change-Id: I8ad70ed6813e0ae52238292f1b7e6d038a5238f1
27+
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5356613
28+
Reviewed-by: Mark Schillaci <[email protected]>
29+
Commit-Queue: Benjamin Beaudry <[email protected]>
30+
Auto-Submit: Benjamin Beaudry <[email protected]>
31+
Cr-Commit-Position: refs/heads/main@{#1270380}
32+
33+
diff --git a/third_party/blink/renderer/modules/accessibility/ax_node_object.cc b/third_party/blink/renderer/modules/accessibility/ax_node_object.cc
34+
index a94e88e79c4fb5ed1336a776eafe3e302f5d50f8..a5c4b06e278f805e81799b2d19f27bffe0701c68 100644
35+
--- a/third_party/blink/renderer/modules/accessibility/ax_node_object.cc
36+
+++ b/third_party/blink/renderer/modules/accessibility/ax_node_object.cc
37+
@@ -5095,19 +5095,6 @@ bool AXNodeObject::OnNativeFocusAction() {
38+
return true;
39+
}
40+
41+
- // If this node is already the currently focused node, then calling
42+
- // focus() won't do anything. That is a problem when focus is removed
43+
- // from the webpage to chrome, and then returns. In these cases, we need
44+
- // to do what keyboard and mouse focus do, which is reset focus first.
45+
- if (document->FocusedElement() == element) {
46+
- document->ClearFocusedElement();
47+
-
48+
- // Calling ClearFocusedElement could result in changes to the document,
49+
- // like this AXObject becoming detached.
50+
- if (IsDetached())
51+
- return false;
52+
- }
53+
-
54+
if (base::FeatureList::IsEnabled(blink::features::kSimulateClickOnAXFocus)) {
55+
// If the object is not natively focusable but can be focused using an ARIA
56+
// active descendant, perform a native click instead. This will enable Web

0 commit comments

Comments
 (0)