Skip to content

Commit

Permalink
[a11y] Fix GetClosestElement to skip over pseudo element descendants
Browse files Browse the repository at this point in the history
(cherry picked from commit 1136ca6)

Fixed: 1486913
Change-Id: I622dacb69be310a032e7ebd92c7f680525606a11
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4894915
Reviewed-by: Aaron Leventhal <aleventhal@chromium.org>
Reviewed-by: Nektarios Paisios <nektar@chromium.org>
Commit-Queue: Benjamin Beaudry <benjamin.beaudry@microsoft.com>
Cr-Original-Commit-Position: refs/heads/main@{#1202882}
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4926575
Cr-Commit-Position: refs/branch-heads/5993@{#1238}
Cr-Branched-From: 5113507-refs/heads/main@{#1192594}
  • Loading branch information
benbeaudry authored and Chromium LUCI CQ committed Oct 10, 2023
1 parent 36f40e1 commit 438cb68
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions third_party/blink/renderer/modules/accessibility/ax_object.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5620,8 +5620,12 @@ Element* AXObject::GetClosestElement() const {
if (!element) {
for (AXObject* parent = ParentObject(); parent;
parent = parent->ParentObject()) {
if (parent) {
return parent->GetElement();
// It's possible to have a parent without a node here if the parent is a
// pseudo element descendant. Since we're looking for the nearest element,
// keep going up the ancestor chain until we find a parent that has one.
element = parent->GetElement();
if (element) {
return element;
}
}
}
Expand Down

0 comments on commit 438cb68

Please sign in to comment.