diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-10-12 14:27:29 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-10-13 09:35:20 +0000 |
commit | c30a6232df03e1efbd9f3b226777b07e087a1122 (patch) | |
tree | e992f45784689f373bcc38d1b79a239ebe17ee23 /chromium/ui/accessibility/ax_tree.cc | |
parent | 7b5b123ac58f58ffde0f4f6e488bcd09aa4decd3 (diff) | |
download | qtwebengine-chromium-85-based.tar.gz |
BASELINE: Update Chromium to 85.0.4183.14085-based
Change-Id: Iaa42f4680837c57725b1344f108c0196741f6057
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'chromium/ui/accessibility/ax_tree.cc')
-rw-r--r-- | chromium/ui/accessibility/ax_tree.cc | 88 |
1 files changed, 66 insertions, 22 deletions
diff --git a/chromium/ui/accessibility/ax_tree.cc b/chromium/ui/accessibility/ax_tree.cc index 5a2b447abbc..003f2770723 100644 --- a/chromium/ui/accessibility/ax_tree.cc +++ b/chromium/ui/accessibility/ax_tree.cc @@ -925,6 +925,11 @@ const std::set<AXTreeID> AXTree::GetAllChildTreeIds() const { } bool AXTree::Unserialize(const AXTreeUpdate& update) { + event_intents_ = update.event_intents; + base::ScopedClosureRunner clear_event_intents(base::BindOnce( + [](std::vector<AXEventIntent>* event_intents) { event_intents->clear(); }, + &event_intents_)); + AXTreeUpdateState update_state(*this); const AXNode::AXID old_root_id = root_ ? root_->id() : AXNode::kInvalidAXID; @@ -2202,30 +2207,69 @@ void AXTree::ComputeSetSizePosInSetAndCacheHelper( } // End of iterating over each item in |ordered_set_content|. } -// Returns the pos_in_set of item. Looks in |node_set_size_pos_in_set_info_map_| -// for cached value. Calculates pos_in_set and set_size for item (and all other -// items in the same ordered set) if no value is present in the cache. This -// function is guaranteed to be only called on nodes that can hold pos_in_set -// values, minimizing the size of the cache. -int32_t AXTree::GetPosInSet(const AXNode& node, const AXNode* ordered_set) { - // If item's id is not in the cache, compute it. - if (node_set_size_pos_in_set_info_map_.find(node.id()) == - node_set_size_pos_in_set_info_map_.end()) - ComputeSetSizePosInSetAndCache(node, ordered_set); - return node_set_size_pos_in_set_info_map_[node.id()].pos_in_set; +base::Optional<int> AXTree::GetPosInSet(const AXNode& node) { + if (node_set_size_pos_in_set_info_map_.find(node.id()) != + node_set_size_pos_in_set_info_map_.end()) { + // If item's id is in the cache, return stored PosInSet value. + return node_set_size_pos_in_set_info_map_[node.id()].pos_in_set; + } + + if (GetTreeUpdateInProgressState()) + return base::nullopt; + + // Only allow this to be called on nodes that can hold PosInSet values, + // which are defined in the ARIA spec. + if (!node.IsOrderedSetItem() || node.IsIgnored()) + return base::nullopt; + + const AXNode* ordered_set = node.GetOrderedSet(); + if (!ordered_set) + return base::nullopt; + + // Compute, cache, then return. + ComputeSetSizePosInSetAndCache(node, ordered_set); + base::Optional<int> pos_in_set = + node_set_size_pos_in_set_info_map_[node.id()].pos_in_set; + if (pos_in_set.has_value() && pos_in_set.value() < 1) + return base::nullopt; + + return pos_in_set; } -// Returns the set_size of node. node could be an ordered set or an item. -// Looks in |node_set_size_pos_in_set_info_map_| for cached value. Calculates -// pos_in_set and set_size for all nodes in same ordered set if no value is -// present in the cache. This function is guaranteed to be only called on nodes -// that can hold set_size values, minimizing the size of the cache. -int32_t AXTree::GetSetSize(const AXNode& node, const AXNode* ordered_set) { - // If node's id is not in the cache, compute it. - if (node_set_size_pos_in_set_info_map_.find(node.id()) == - node_set_size_pos_in_set_info_map_.end()) - ComputeSetSizePosInSetAndCache(node, ordered_set); - return node_set_size_pos_in_set_info_map_[node.id()].set_size; +base::Optional<int> AXTree::GetSetSize(const AXNode& node) { + if (node_set_size_pos_in_set_info_map_.find(node.id()) != + node_set_size_pos_in_set_info_map_.end()) { + // If item's id is in the cache, return stored SetSize value. + return node_set_size_pos_in_set_info_map_[node.id()].set_size; + } + + if (GetTreeUpdateInProgressState()) + return base::nullopt; + + // Only allow this to be called on nodes that can hold SetSize values, which + // are defined in the ARIA spec. However, we allow set-like items to receive + // SetSize values for internal purposes. + if ((!node.IsOrderedSetItem() && !node.IsOrderedSet()) || node.IsIgnored() || + node.IsEmbeddedGroup()) { + return base::nullopt; + } + + // If |node| is item-like, find its outerlying ordered set. Otherwise, + // |node| is the ordered set. + const AXNode* ordered_set = &node; + if (IsItemLike(node.data().role)) + ordered_set = node.GetOrderedSet(); + if (!ordered_set) + return base::nullopt; + + // Compute, cache, then return. + ComputeSetSizePosInSetAndCache(node, ordered_set); + base::Optional<int> set_size = + node_set_size_pos_in_set_info_map_[node.id()].set_size; + if (set_size.has_value() && set_size.value() < 0) + return base::nullopt; + + return set_size; } AXTree::Selection AXTree::GetUnignoredSelection() const { |