Commit 7dfa8233 authored by Mansi Awasthi's avatar Mansi Awasthi Committed by Commit Bot

Raise UIA event on document selection change for windows

Fire UIA selection changed event in browser_accessibility_manager_win.cc
when document selection is changed.

Bug: 1030731
Change-Id: Ibeb72db403222d1e5a9bef540fafc42b9e01b02d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1975693Reviewed-by: default avatarIan Prest <iapres@microsoft.com>
Commit-Queue: Mansi Awasthi <maawas@microsoft.com>
Cr-Commit-Position: refs/heads/master@{#728793}
parent e1097b43
...@@ -130,7 +130,7 @@ void BrowserAccessibilityManagerWin::FireBlinkEvent( ...@@ -130,7 +130,7 @@ void BrowserAccessibilityManagerWin::FireBlinkEvent(
FireUiaTextContainerEvent(UIA_Text_TextChangedEventId, node); FireUiaTextContainerEvent(UIA_Text_TextChangedEventId, node);
break; break;
case ax::mojom::Event::kTextSelectionChanged: case ax::mojom::Event::kTextSelectionChanged:
FireUiaTextContainerEvent(UIA_Text_TextSelectionChangedEventId, node); text_selection_changed_events_.insert(node);
break; break;
default: default:
break; break;
...@@ -211,8 +211,10 @@ void BrowserAccessibilityManagerWin::FireGeneratedEvent( ...@@ -211,8 +211,10 @@ void BrowserAccessibilityManagerWin::FireGeneratedEvent(
// Fire the event on the object where the focus of the selection is. // Fire the event on the object where the focus of the selection is.
int32_t focus_id = ax_tree()->GetUnignoredSelection().focus_object_id; int32_t focus_id = ax_tree()->GetUnignoredSelection().focus_object_id;
BrowserAccessibility* focus_object = GetFromID(focus_id); BrowserAccessibility* focus_object = GetFromID(focus_id);
if (focus_object && focus_object->HasVisibleCaretOrSelection()) if (focus_object && focus_object->HasVisibleCaretOrSelection()) {
FireWinAccessibilityEvent(IA2_EVENT_TEXT_CARET_MOVED, focus_object); FireWinAccessibilityEvent(IA2_EVENT_TEXT_CARET_MOVED, focus_object);
text_selection_changed_events_.insert(node);
}
break; break;
} }
// aria-dropeffect is deprecated in WAI-ARIA 1.1. // aria-dropeffect is deprecated in WAI-ARIA 1.1.
...@@ -771,6 +773,12 @@ void BrowserAccessibilityManagerWin::FinalizeAccessibilityEvents() { ...@@ -771,6 +773,12 @@ void BrowserAccessibilityManagerWin::FinalizeAccessibilityEvents() {
} }
aria_properties_events_.clear(); aria_properties_events_.clear();
for (auto&& sel_event_node : text_selection_changed_events_) {
FireUiaTextContainerEvent(UIA_Text_TextSelectionChangedEventId,
sel_event_node);
}
text_selection_changed_events_.clear();
for (auto&& selected : selection_events_) { for (auto&& selected : selection_events_) {
auto* container = selected.first; auto* container = selected.first;
auto&& changes = selected.second; auto&& changes = selected.second;
......
...@@ -105,6 +105,13 @@ class CONTENT_EXPORT BrowserAccessibilityManagerWin ...@@ -105,6 +105,13 @@ class CONTENT_EXPORT BrowserAccessibilityManagerWin
// changes, so we only fire the event once for every node. // changes, so we only fire the event once for every node.
std::unordered_set<BrowserAccessibility*> aria_properties_events_; std::unordered_set<BrowserAccessibility*> aria_properties_events_;
// Since there could be duplicate text selection changed events on a node
// raised from both FireBlinkEvent and FireGeneratedEvent, we use an unordered
// set here to keep track of the unique nodes that had
// UIA_Text_TextSelectionChangedEventId, so we only fire the event once for
// every node.
std::unordered_set<BrowserAccessibility*> text_selection_changed_events_;
// When the ignored state changes for a node, we only want to fire the // When the ignored state changes for a node, we only want to fire the
// events relevant to the ignored state change (e.g. show / hide). // events relevant to the ignored state change (e.g. show / hide).
// This set keeps track of what nodes should suppress superfluous events. // This set keeps track of what nodes should suppress superfluous events.
......
Text_TextSelectionChanged on role=document Text_TextSelectionChanged on role=document
=== Start Continuation === === Start Continuation ===
Text_TextSelectionChanged on role=document
Text_TextSelectionChanged on role=textbox, name=input Text_TextSelectionChanged on role=textbox, name=input
=== Start Continuation === === Start Continuation ===
Text_TextSelectionChanged on role=document
Text_TextSelectionChanged on role=textbox, name=textarea Text_TextSelectionChanged on role=textbox, name=textarea
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment