Move Mac accessible table column and table header container code out of Blink.
On macOS, an accessible table needs not only nodes for every row, but also for
every column - and it also needs a "table header container", which has all of
the table's headers as its children.
Previously those "special" nodes were created in Blink, but they were computationally
expensive, and they cluttered up all of the non-Mac platforms.
Replace that with some new "fake" AXNodes generated by AXTableInfo with a bit of
logic to make those nodes part of the accessibility tree on Mac only.
I did plenty of manual testing with VoiceOver to be confident that this code is
working correctly.
TBR: [email protected], [email protected]
Bug: 832289
Cq-Include-Trybots: luci.chromium.try:closure_compilation
Change-Id: Idfaaf3710eb4ae4dedb4ce59da8d8da682da5dd6
Reviewed-on: https://chromium-review.googlesource.com/1100553
Commit-Queue: Dominic Mazzoni <[email protected]>
Reviewed-by: David Trainor <[email protected]>
Reviewed-by: Aaron Leventhal <[email protected]>
Cr-Commit-Position: refs/heads/master@{#570927}
diff --git a/ui/accessibility/ax_tree.h b/ui/accessibility/ax_tree.h
index 165255e..4d702e27 100644
--- a/ui/accessibility/ax_tree.h
+++ b/ui/accessibility/ax_tree.h
@@ -249,6 +249,16 @@
int size() { return static_cast<int>(id_map_.size()); }
+ // Call this to enable support for extra Mac nodes - for each table,
+ // a table column header and a node for each column.
+ void SetEnableExtraMacNodes(bool enabled);
+ bool enable_extra_mac_nodes() const { return enable_extra_mac_nodes_; }
+
+ // Return a negative number that's suitable to use for a node ID for
+ // internal nodes created automatically by an AXTree, so as not to
+ // conflict with positive-numbered node IDs from tree sources.
+ int32_t GetNextNegativeInternalNodeId();
+
private:
AXNode* CreateNode(AXNode* parent,
int32_t id,
@@ -291,9 +301,6 @@
std::vector<AXNode*>* new_children,
AXTreeUpdateState* update_state);
- // Clear any cached AXTableInfo objects.
- void ClearTables();
-
AXTreeDelegate* delegate_ = nullptr;
AXNode* root_ = nullptr;
base::hash_map<int32_t, AXNode*> id_map_;
@@ -308,8 +315,17 @@
IntListReverseRelationMap intlist_reverse_relations_;
// Map from node ID to cached table info, if the given node is a table.
- // Cleared every time the tree is updated.
+ // Invalidated every time the tree is updated.
base::hash_map<int32_t, AXTableInfo*> table_info_map_;
+
+ // The next negative node ID to use for internal nodes.
+ int32_t next_negative_internal_node_id_ = -1;
+
+ // Whether we should create extra nodes that
+ // are only useful on macOS. Implemented using this flag to allow
+ // this code to be unit-tested on other platforms (for example, more
+ // code sanitizers run on Linux).
+ bool enable_extra_mac_nodes_ = false;
};
} // namespace ui