Rewrite IAccessibleRelation interface support
Previously, every time we created an AXPlatformNodeWin, we constructed an
IAccessibleRelation with every forward and reverse relation. This required
some extra memory and bookkeeping, even though much of the time these
relations were never asked for by AT.
Replace this with a mostly-lazy implementation. AXTree now keeps track of
reverse relations automatically for us in a very compact, efficient way.
This part is not lazy, it's still faster to keep track of reverse relations
as we go. However, AXPlatformNodeWin doesn't compute anything on the fly
anymore. Instead, a new function AXPlatformRelationWin::EnumerateRelationships
does all of the work of iterating over all possible forward and reverse
IAccessible2 relations of a node based on the internal attributes.
When a specific IAccessibleRelation is requested, we construct a new
AXPlatformRelationWin on the fly, and then invalidate it whenever the node
that created it changes.
As a side benefit, this completes the implementation of relationTargetsOfType.
Bug: 757707
Change-Id: I5cf250a95566f38d629d29f66a52f0b631fbf2f6
Reviewed-on: https://chromium-review.googlesource.com/834588
Commit-Queue: Dominic Mazzoni <[email protected]>
Reviewed-by: Doug Turner <[email protected]>
Cr-Commit-Position: refs/heads/master@{#526117}
diff --git a/ui/accessibility/ax_tree.h b/ui/accessibility/ax_tree.h
index 068ecad7..d733df9 100644
--- a/ui/accessibility/ax_tree.h
+++ b/ui/accessibility/ax_tree.h
@@ -204,14 +204,15 @@
// Given a node ID attribute (one where IsNodeIdIntAttribute is true),
// and a destination node ID, return a set of all source node IDs that
// have that relationship attribute between them and the destination.
- std::set<int32_t> GetReverseRelations(AXIntAttribute attr, int32_t dst_id);
+ std::set<int32_t> GetReverseRelations(AXIntAttribute attr,
+ int32_t dst_id) const;
// Given a node ID list attribute (one where
// IsNodeIdIntListAttribute is true), and a destination node ID,
// return a set of all source node IDs that have that relationship
// attribute between them and the destination.
std::set<int32_t> GetReverseRelations(AXIntListAttribute attr,
- int32_t dst_id);
+ int32_t dst_id) const;
// Return a multi-line indented string representation, for logging.
std::string ToString() const;