Skip to content

Commit

Permalink
[accessibility] Only call GetParentPlatformNodeWin when needed
Browse files Browse the repository at this point in the history
When remapping kSelection events in AXPlatformNodeWin's
NotifyAccessibilityEvent, only call GetParentPlatformNodeWin() when the
value is actually needed.

Bug: none
Change-Id: Icd8f075cb9785fb4f91439fa199944d31b46eab6
AX-Relnotes: n/a.
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4774593
Auto-Submit: Greg Thompson <[email protected]>
Reviewed-by: Aaron Leventhal <[email protected]>
Commit-Queue: Aaron Leventhal <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1183599}
  • Loading branch information
GregTho authored and Chromium LUCI CQ committed Aug 15, 2023
1 parent 1d63bbc commit 89b43d5
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions ui/accessibility/platform/ax_platform_node_win.cc
Original file line number Diff line number Diff line change
Expand Up @@ -639,9 +639,7 @@ void AXPlatformNodeWin::NotifyAccessibilityEvent(ax::mojom::Event event_type) {
// A menu item could have something other than a role of
// |ROLE_SYSTEM_MENUITEM|. Zoom modification controls for example have a
// role of button.
auto* parent = GetParentPlatformNodeWin();
int role = MSAARole();
if (role == ROLE_SYSTEM_MENUITEM) {
if (int role = MSAARole(); role == ROLE_SYSTEM_MENUITEM) {
event_type = ax::mojom::Event::kFocus;
} else if (role == ROLE_SYSTEM_LISTITEM) {
if (const AXPlatformNodeBase* container = GetSelectionContainer()) {
Expand All @@ -651,9 +649,9 @@ void AXPlatformNodeWin::NotifyAccessibilityEvent(ax::mojom::Event event_type) {
event_type = ax::mojom::Event::kFocus;
}
}
} else if (parent) {
int parent_role = parent->MSAARole();
if (parent_role == ROLE_SYSTEM_MENUPOPUP ||
} else if (auto* parent = GetParentPlatformNodeWin(); parent) {
if (int parent_role = parent->MSAARole();
parent_role == ROLE_SYSTEM_MENUPOPUP ||
parent_role == ROLE_SYSTEM_LIST) {
event_type = ax::mojom::Event::kFocus;
}
Expand Down

0 comments on commit 89b43d5

Please sign in to comment.