summaryrefslogtreecommitdiff
path: root/chromium/content/browser/accessibility/browser_accessibility_manager_win.cc
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2017-11-20 10:33:36 +0100
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2017-11-22 11:45:12 +0000
commitbe59a35641616a4cf23c4a13fa0632624b021c1b (patch)
tree9da183258bdf9cc413f7562079d25ace6955467f /chromium/content/browser/accessibility/browser_accessibility_manager_win.cc
parentd702e4b6a64574e97fc7df8fe3238cde70242080 (diff)
downloadqtwebengine-chromium-be59a35641616a4cf23c4a13fa0632624b021c1b.tar.gz
BASELINE: Update Chromium to 62.0.3202.101
Change-Id: I2d5eca8117600df6d331f6166ab24d943d9814ac Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'chromium/content/browser/accessibility/browser_accessibility_manager_win.cc')
-rw-r--r--chromium/content/browser/accessibility/browser_accessibility_manager_win.cc136
1 files changed, 122 insertions, 14 deletions
diff --git a/chromium/content/browser/accessibility/browser_accessibility_manager_win.cc b/chromium/content/browser/accessibility/browser_accessibility_manager_win.cc
index bc7c0747547..92bd3041a77 100644
--- a/chromium/content/browser/accessibility/browser_accessibility_manager_win.cc
+++ b/chromium/content/browser/accessibility/browser_accessibility_manager_win.cc
@@ -21,6 +21,28 @@
namespace content {
+namespace {
+
+bool IsContainerWithSelectableChildrenRole(ui::AXRole role) {
+ switch (role) {
+ case ui::AX_ROLE_COMBO_BOX:
+ case ui::AX_ROLE_GRID:
+ case ui::AX_ROLE_LIST_BOX:
+ case ui::AX_ROLE_MENU:
+ case ui::AX_ROLE_MENU_BAR:
+ case ui::AX_ROLE_RADIO_GROUP:
+ case ui::AX_ROLE_TAB_LIST:
+ case ui::AX_ROLE_TOOLBAR:
+ case ui::AX_ROLE_TREE:
+ case ui::AX_ROLE_TREE_GRID:
+ return true;
+ default:
+ return false;
+ }
+}
+
+} // namespace
+
// static
BrowserAccessibilityManager* BrowserAccessibilityManager::Create(
const ui::AXTreeUpdate& initial_tree,
@@ -59,7 +81,7 @@ ui::AXTreeUpdate
ui::AXNodeData empty_document;
empty_document.id = 0;
empty_document.role = ui::AX_ROLE_ROOT_WEB_AREA;
- empty_document.AddState(ui::AX_STATE_BUSY);
+ empty_document.AddBoolAttribute(ui::AX_ATTR_BUSY, true);
ui::AXTreeUpdate update;
update.root_id = empty_document.id;
@@ -86,7 +108,7 @@ void BrowserAccessibilityManagerWin::OnIAccessible2Used() {
// enable basic web accessibility support. (Full screen reader support is
// detected later when specific more advanced APIs are accessed.)
BrowserAccessibilityStateImpl::GetInstance()->AddAccessibilityModeFlags(
- AccessibilityMode::kNativeAPIs | AccessibilityMode::kWebContents);
+ ui::AXMode::kNativeAPIs | ui::AXMode::kWebContents);
}
void BrowserAccessibilityManagerWin::UserIsReloading() {
@@ -175,6 +197,9 @@ BrowserAccessibilityEvent::Result
if (user_is_navigating_away_)
return BrowserAccessibilityEvent::DiscardedBecauseUserNavigatingAway;
+ if (!target)
+ return BrowserAccessibilityEvent::FailedBecauseNoFocus;
+
// Inline text boxes are an internal implementation detail, we don't
// expose them to Windows.
if (target->GetRole() == ui::AX_ROLE_INLINE_TEXT_BOX)
@@ -186,9 +211,6 @@ BrowserAccessibilityEvent::Result
return BrowserAccessibilityEvent::DiscardedBecauseLiveRegionBusy;
}
- if (!target)
- return BrowserAccessibilityEvent::FailedBecauseNoFocus;
-
event->set_target(target);
// It doesn't make sense to fire a REORDER event on a leaf node; that
@@ -202,7 +224,7 @@ BrowserAccessibilityEvent::Result
// argument to NotifyWinEvent; the AT client will then call get_accChild
// on the HWND's accessibility object and pass it that same id, which
// we can use to retrieve the IAccessible for this node.
- LONG child_id = -target->unique_id();
+ LONG child_id = -(ToBrowserAccessibilityWin(target)->GetCOM()->unique_id());
::NotifyWinEvent(win_event_type, hwnd, OBJID_CLIENT, child_id);
return BrowserAccessibilityEvent::Sent;
}
@@ -243,6 +265,26 @@ gfx::Rect BrowserAccessibilityManagerWin::GetViewBounds() {
return gfx::Rect();
}
+void BrowserAccessibilityManagerWin::OnTreeDataChanged(
+ ui::AXTree* tree,
+ const ui::AXTreeData& old_tree_data,
+ const ui::AXTreeData& new_tree_data) {
+ BrowserAccessibilityManager::OnTreeDataChanged(tree, old_tree_data,
+ new_tree_data);
+ if (new_tree_data.loaded && !old_tree_data.loaded)
+ tree_events_[tree->root()->id()].insert(ui::AX_EVENT_LOAD_COMPLETE);
+ if (new_tree_data.sel_anchor_object_id !=
+ old_tree_data.sel_anchor_object_id ||
+ new_tree_data.sel_anchor_offset != old_tree_data.sel_anchor_offset ||
+ new_tree_data.sel_anchor_affinity != old_tree_data.sel_anchor_affinity ||
+ new_tree_data.sel_focus_object_id != old_tree_data.sel_focus_object_id ||
+ new_tree_data.sel_focus_offset != old_tree_data.sel_focus_offset ||
+ new_tree_data.sel_focus_affinity != old_tree_data.sel_focus_affinity) {
+ tree_events_[tree->root()->id()].insert(
+ ui::AX_EVENT_DOCUMENT_SELECTION_CHANGED);
+ }
+}
+
void BrowserAccessibilityManagerWin::OnNodeCreated(ui::AXTree* tree,
ui::AXNode* node) {
DCHECK(node);
@@ -254,6 +296,53 @@ void BrowserAccessibilityManagerWin::OnNodeCreated(ui::AXTree* tree,
return;
}
+void BrowserAccessibilityManagerWin::OnNodeDataWillChange(
+ ui::AXTree* tree,
+ const ui::AXNodeData& old_node_data,
+ const ui::AXNodeData& new_node_data) {
+ if (new_node_data.child_ids != old_node_data.child_ids &&
+ new_node_data.role != ui::AX_ROLE_STATIC_TEXT) {
+ tree_events_[new_node_data.id].insert(ui::AX_EVENT_CHILDREN_CHANGED);
+ }
+}
+
+void BrowserAccessibilityManagerWin::OnStateChanged(ui::AXTree* tree,
+ ui::AXNode* node,
+ ui::AXState state,
+ bool new_value) {
+ if (state == ui::AX_STATE_SELECTED) {
+ ui::AXNode* container = node;
+ while (container &&
+ !IsContainerWithSelectableChildrenRole(container->data().role))
+ container = container->parent();
+ if (container) {
+ tree_events_[container->id()].insert(
+ ui::AX_EVENT_SELECTED_CHILDREN_CHANGED);
+ }
+ }
+}
+
+void BrowserAccessibilityManagerWin::OnIntAttributeChanged(
+ ui::AXTree* tree,
+ ui::AXNode* node,
+ ui::AXIntAttribute attr,
+ int32_t old_value,
+ int32_t new_value) {
+ BrowserAccessibilityManager::OnIntAttributeChanged(tree, node, attr,
+ old_value, new_value);
+ switch (attr) {
+ case ui::AX_ATTR_ACTIVEDESCENDANT_ID:
+ tree_events_[node->id()].insert(ui::AX_EVENT_ACTIVEDESCENDANTCHANGED);
+ break;
+ case ui::AX_ATTR_SCROLL_X:
+ case ui::AX_ATTR_SCROLL_Y:
+ tree_events_[node->id()].insert(ui::AX_EVENT_SCROLL_POSITION_CHANGED);
+ break;
+ default:
+ break;
+ }
+}
+
void BrowserAccessibilityManagerWin::OnAtomicUpdateFinished(
ui::AXTree* tree,
bool root_changed,
@@ -261,25 +350,44 @@ void BrowserAccessibilityManagerWin::OnAtomicUpdateFinished(
BrowserAccessibilityManager::OnAtomicUpdateFinished(
tree, root_changed, changes);
+ if (root_changed && tree->data().loaded)
+ tree_events_[tree->root()->id()].insert(ui::AX_EVENT_LOAD_COMPLETE);
+
+ // Handle live region changes.
+ for (size_t i = 0; i < changes.size(); ++i) {
+ const ui::AXNode* node = changes[i].node;
+ DCHECK(node);
+ if (node->data().HasStringAttribute(ui::AX_ATTR_CONTAINER_LIVE_STATUS)) {
+ const ui::AXNode* container = node;
+ while (container &&
+ !container->data().HasStringAttribute(ui::AX_ATTR_LIVE_STATUS)) {
+ container = container->parent();
+ }
+ if (container)
+ tree_events_[container->id()].insert(ui::AX_EVENT_LIVE_REGION_CHANGED);
+ }
+ }
+
// Do a sequence of Windows-specific updates on each node. Each one is
// done in a single pass that must complete before the next step starts.
// The first step moves win_attributes_ to old_win_attributes_ and then
// recomputes all of win_attributes_ other than IAccessibleText.
- for (size_t i = 0; i < changes.size(); ++i) {
- const ui::AXNode* changed_node = changes[i].node;
+ for (const auto& change : changes) {
+ const ui::AXNode* changed_node = change.node;
DCHECK(changed_node);
BrowserAccessibility* obj = GetFromAXNode(changed_node);
- if (obj && obj->IsNative() && !obj->PlatformIsChildOfLeaf())
+ if (obj && obj->IsNative() && !obj->PlatformIsChildOfLeaf()) {
ToBrowserAccessibilityWin(obj)
->GetCOM()
->UpdateStep1ComputeWinAttributes();
+ }
}
// The next step updates the hypertext of each node, which is a
// concatenation of all of its child text nodes, so it can't run until
// the text of all of the nodes was computed in the previous step.
- for (size_t i = 0; i < changes.size(); ++i) {
- const ui::AXNode* changed_node = changes[i].node;
+ for (const auto& change : changes) {
+ const ui::AXNode* changed_node = change.node;
DCHECK(changed_node);
BrowserAccessibility* obj = GetFromAXNode(changed_node);
if (obj && obj->IsNative() && !obj->PlatformIsChildOfLeaf())
@@ -294,13 +402,13 @@ void BrowserAccessibilityManagerWin::OnAtomicUpdateFinished(
// client may walk the tree when it receives any of these events.
// At the end, it deletes old_win_attributes_ since they're not needed
// anymore.
- for (size_t i = 0; i < changes.size(); ++i) {
- const ui::AXNode* changed_node = changes[i].node;
+ for (const auto& change : changes) {
+ const ui::AXNode* changed_node = change.node;
DCHECK(changed_node);
BrowserAccessibility* obj = GetFromAXNode(changed_node);
if (obj && obj->IsNative() && !obj->PlatformIsChildOfLeaf()) {
ToBrowserAccessibilityWin(obj)->GetCOM()->UpdateStep3FireEvents(
- changes[i].type == AXTreeDelegate::SUBTREE_CREATED);
+ change.type == AXTreeDelegate::SUBTREE_CREATED);
}
}
}