[email protected] | 4b02bbca | 2013-11-22 08:59:03 | [diff] [blame] | 1 | // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef UI_ACCESSIBILITY_AX_TREE_H_ |
| 6 | #define UI_ACCESSIBILITY_AX_TREE_H_ |
| 7 | |
avi | 9c81217b | 2015-12-24 23:40:05 | [diff] [blame] | 8 | #include <stdint.h> |
| 9 | |
Lei Zhang | a0614478 | 2020-03-13 09:28:47 | [diff] [blame] | 10 | #include <map> |
Chris Hall | 3420818 | 2019-03-13 02:26:18 | [diff] [blame] | 11 | #include <memory> |
[email protected] | d4e27346 | 2013-12-04 04:37:58 | [diff] [blame] | 12 | #include <set> |
Lei Zhang | a0614478 | 2020-03-13 09:28:47 | [diff] [blame] | 13 | #include <string> |
Lei Zhang | a0614478 | 2020-03-13 09:28:47 | [diff] [blame] | 14 | #include <vector> |
[email protected] | 4b02bbca | 2013-11-22 08:59:03 | [diff] [blame] | 15 | |
Jacob Francis | 78735e3 | 2022-06-30 22:02:52 | [diff] [blame] | 16 | #include "base/containers/flat_map.h" |
Aaron Leventhal | bc649ff | 2022-08-11 18:53:23 | [diff] [blame] | 17 | #include "base/debug/crash_logging.h" |
Keishi Hattori | 0e45c02 | 2021-11-27 09:25:52 | [diff] [blame] | 18 | #include "base/memory/raw_ptr.h" |
Jacques Newman | 5846e62 | 2021-01-15 02:15:59 | [diff] [blame] | 19 | #include "base/metrics/histogram_functions.h" |
Dominic Mazzoni | 8549eb68 | 2018-12-11 23:48:32 | [diff] [blame] | 20 | #include "base/observer_list.h" |
Nektarios Paisios | 77c422a | 2021-10-19 10:37:00 | [diff] [blame] | 21 | #include "third_party/abseil-cpp/absl/types/optional.h" |
James Cook | 36cab7c | 2019-10-29 23:26:40 | [diff] [blame] | 22 | #include "ui/accessibility/ax_enums.mojom-forward.h" |
[email protected] | 4b02bbca | 2013-11-22 08:59:03 | [diff] [blame] | 23 | #include "ui/accessibility/ax_export.h" |
dmazzoni | 329fd01 | 2015-10-22 20:05:35 | [diff] [blame] | 24 | #include "ui/accessibility/ax_tree_data.h" |
[email protected] | 4b02bbca | 2013-11-22 08:59:03 | [diff] [blame] | 25 | #include "ui/accessibility/ax_tree_update.h" |
| 26 | |
| 27 | namespace ui { |
| 28 | |
David Tseng | 41f13cbd | 2021-11-06 18:39:03 | [diff] [blame] | 29 | struct AXEvent; |
Alexander Surkov | 4ab64cf | 2022-09-01 20:07:46 | [diff] [blame] | 30 | class AXLanguageDetectionManager; |
| 31 | class AXNode; |
| 32 | struct AXNodeData; |
Dominic Mazzoni | 3d9b5b9 | 2018-04-18 21:36:38 | [diff] [blame] | 33 | class AXTableInfo; |
Dominic Mazzoni | 8549eb68 | 2018-12-11 23:48:32 | [diff] [blame] | 34 | class AXTreeObserver; |
[email protected] | e736e81b | 2014-02-24 07:15:58 | [diff] [blame] | 35 | struct AXTreeUpdateState; |
Alexander Surkov | 253235e | 2022-08-23 01:52:12 | [diff] [blame] | 36 | class AXSelection; |
[email protected] | e736e81b | 2014-02-24 07:15:58 | [diff] [blame] | 37 | |
Jacques Newman | 5846e62 | 2021-01-15 02:15:59 | [diff] [blame] | 38 | // These values are persisted to logs. Entries should not be renumbered and |
| 39 | // numeric values should never be reused. |
| 40 | enum class AXTreeUnserializeError { |
| 41 | // Tree has no root. |
| 42 | kNoRoot = 0, |
| 43 | // Node will not be in the tree and is not the new root. |
| 44 | kNotInTree = 1, |
| 45 | // Node is already pending for creation, cannot be the new root |
| 46 | kCreationPending = 2, |
| 47 | // Node has duplicate child. |
| 48 | kDuplicateChild = 3, |
| 49 | // Node is already pending for creation, cannot be a new child. |
| 50 | kCreationPendingForChild = 4, |
| 51 | // Node is not marked for destruction, would be reparented. |
| 52 | kReparent = 5, |
| 53 | // Nodes are left pending by the update. |
| 54 | kPendingNodes = 6, |
| 55 | // Changes left pending by the update; |
| 56 | kPendingChanges = 7, |
| 57 | // This must always be the last enum. It's okay for its value to |
| 58 | // increase, but none of the other enum values may change. |
| 59 | kMaxValue = kPendingChanges |
| 60 | }; |
| 61 | |
| 62 | #define ACCESSIBILITY_TREE_UNSERIALIZE_ERROR_HISTOGRAM(enum_value) \ |
| 63 | base::UmaHistogramEnumeration( \ |
| 64 | "Accessibility.Reliability.Tree.UnserializeError", enum_value) |
| 65 | |
[email protected] | 4b02bbca | 2013-11-22 08:59:03 | [diff] [blame] | 66 | // AXTree is a live, managed tree of AXNode objects that can receive |
| 67 | // updates from another AXTreeSource via AXTreeUpdates, and it can be |
| 68 | // used as a source for sending updates to another client tree. |
| 69 | // It's designed to be subclassed to implement support for native |
| 70 | // accessibility APIs on a specific platform. |
Alexander Surkov | 4ab64cf | 2022-09-01 20:07:46 | [diff] [blame] | 71 | class AX_EXPORT AXTree { |
[email protected] | 4b02bbca | 2013-11-22 08:59:03 | [diff] [blame] | 72 | public: |
Lei Zhang | a0614478 | 2020-03-13 09:28:47 | [diff] [blame] | 73 | using IntReverseRelationMap = |
Nektarios Paisios | 527d33fb5 | 2021-02-23 19:23:28 | [diff] [blame] | 74 | std::map<ax::mojom::IntAttribute, std::map<AXNodeID, std::set<AXNodeID>>>; |
Lei Zhang | a0614478 | 2020-03-13 09:28:47 | [diff] [blame] | 75 | using IntListReverseRelationMap = |
| 76 | std::map<ax::mojom::IntListAttribute, |
Nektarios Paisios | 527d33fb5 | 2021-02-23 19:23:28 | [diff] [blame] | 77 | std::map<AXNodeID, std::set<AXNodeID>>>; |
David Tseng | ef6b480d | 2018-02-19 12:48:42 | [diff] [blame] | 78 | |
Nektarios Paisios | 77c422a | 2021-10-19 10:37:00 | [diff] [blame] | 79 | // If called, the focused node in this tree will never be ignored, even if it |
| 80 | // has the ignored state set. For now, this boolean will be set to false for |
| 81 | // all trees except in test scenarios, in order to thoroughly test the |
| 82 | // relevant code without causing any potential regressions. Ultimately, we |
| 83 | // want to expose all focused nodes so that a user of an assistive technology |
| 84 | // will be able to interact with the application / website, even if there is |
| 85 | // an authoring error, e.g. the aria-hidden attribute has been applied to the |
| 86 | // focused element. |
| 87 | // TODO(nektar): Removed once the feature has been fully tested. |
| 88 | static void SetFocusedNodeShouldNeverBeIgnored(); |
| 89 | |
| 90 | // Determines the ignored state of a node, given information about the node |
| 91 | // and the tree. |
| 92 | static bool ComputeNodeIsIgnored(const AXTreeData* optional_tree_data, |
| 93 | const AXNodeData& node_data); |
| 94 | |
| 95 | // Determines whether a node has flipped its ignored state, given information |
| 96 | // about the previous and current state of the node / tree. |
| 97 | static bool ComputeNodeIsIgnoredChanged( |
| 98 | const AXTreeData* optional_old_tree_data, |
| 99 | const AXNodeData& old_node_data, |
| 100 | const AXTreeData* optional_new_tree_data, |
| 101 | const AXNodeData& new_node_data); |
| 102 | |
[email protected] | 4b02bbca | 2013-11-22 08:59:03 | [diff] [blame] | 103 | AXTree(); |
dmazzoni | 329fd01 | 2015-10-22 20:05:35 | [diff] [blame] | 104 | explicit AXTree(const AXTreeUpdate& initial_state); |
[email protected] | 4b02bbca | 2013-11-22 08:59:03 | [diff] [blame] | 105 | virtual ~AXTree(); |
| 106 | |
Lei Zhang | a0614478 | 2020-03-13 09:28:47 | [diff] [blame] | 107 | // AXTree owns pointers so copying is non-trivial. |
| 108 | AXTree(const AXTree&) = delete; |
| 109 | AXTree& operator=(const AXTree&) = delete; |
| 110 | |
Dominic Mazzoni | 8549eb68 | 2018-12-11 23:48:32 | [diff] [blame] | 111 | void AddObserver(AXTreeObserver* observer); |
| 112 | bool HasObserver(AXTreeObserver* observer); |
Nektarios Paisios | db7b5ee | 2020-02-18 21:28:11 | [diff] [blame] | 113 | void RemoveObserver(AXTreeObserver* observer); |
Dominic Mazzoni | 8549eb68 | 2018-12-11 23:48:32 | [diff] [blame] | 114 | |
| 115 | base::ObserverList<AXTreeObserver>& observers() { return observers_; } |
[email protected] | e736e81b | 2014-02-24 07:15:58 | [diff] [blame] | 116 | |
tfarina | 6b1c1e08 | 2015-02-20 23:47:07 | [diff] [blame] | 117 | AXNode* root() const { return root_; } |
| 118 | |
Alexander Surkov | 4ab64cf | 2022-09-01 20:07:46 | [diff] [blame] | 119 | const AXTreeData& data() const; |
dmazzoni | 329fd01 | 2015-10-22 20:05:35 | [diff] [blame] | 120 | |
Nektarios Paisios | db7b5ee | 2020-02-18 21:28:11 | [diff] [blame] | 121 | // Destroys the tree and notifies all observers. |
| 122 | void Destroy(); |
| 123 | |
Adam Ettenberger | 86af253 | 2019-09-17 20:04:46 | [diff] [blame] | 124 | // Returns the globally unique ID of this accessibility tree. |
Alexander Surkov | 4ab64cf | 2022-09-01 20:07:46 | [diff] [blame] | 125 | const AXTreeID& GetAXTreeID() const; |
Adam Ettenberger | 86af253 | 2019-09-17 20:04:46 | [diff] [blame] | 126 | |
Alexander Surkov | 4ab64cf | 2022-09-01 20:07:46 | [diff] [blame] | 127 | // Given a node in this accessibility tree that corresponds to a table |
| 128 | // or grid, return an object containing information about the |
| 129 | // table structure. This object is computed lazily on-demand and |
| 130 | // cached until the next time the tree is updated. Clients should |
| 131 | // not retain this pointer, they should just request it every time |
| 132 | // it's needed. |
| 133 | // |
| 134 | // Returns nullptr if the node is not a valid table. |
| 135 | AXTableInfo* GetTableInfo(const AXNode* table_node) const; |
| 136 | |
tfarina | 6b1c1e08 | 2015-02-20 23:47:07 | [diff] [blame] | 137 | // Returns the AXNode with the given |id| if it is part of this AXTree. |
Alexander Surkov | 4ab64cf | 2022-09-01 20:07:46 | [diff] [blame] | 138 | AXNode* GetFromId(AXNodeID id) const; |
[email protected] | 4b02bbca | 2013-11-22 08:59:03 | [diff] [blame] | 139 | |
[email protected] | d4e27346 | 2013-12-04 04:37:58 | [diff] [blame] | 140 | // Returns true on success. If it returns false, it's a fatal error |
| 141 | // and this tree should be destroyed, and the source of the tree update |
| 142 | // should not be trusted any longer. |
dmazzoni | 329fd01 | 2015-10-22 20:05:35 | [diff] [blame] | 143 | virtual bool Unserialize(const AXTreeUpdate& update); |
| 144 | |
Nektarios Paisios | 26ac2b4 | 2021-06-02 18:24:19 | [diff] [blame] | 145 | // Used by tests to update the tree data without changing any of the nodes in |
| 146 | // the tree, notifying all tree observers in the process. |
| 147 | virtual void UpdateDataForTesting(const AXTreeData& data); |
[email protected] | 4b02bbca | 2013-11-22 08:59:03 | [diff] [blame] | 148 | |
Dominic Mazzoni | 2410fc6 | 2017-06-09 22:19:18 | [diff] [blame] | 149 | // Convert any rectangle from the local coordinate space of one node in |
| 150 | // the tree, to bounds in the coordinate space of the tree. |
Katie Dektar | 2c6052d | 2017-09-27 00:32:32 | [diff] [blame] | 151 | // If set, updates |offscreen| boolean to be true if the node is offscreen |
| 152 | // relative to its rootWebArea. Callers should initialize |offscreen| |
| 153 | // to false: this method may get called multiple times in a row and |
| 154 | // |offscreen| will be propagated. |
Katie Dektar | db71ad94 | 2017-11-29 20:07:48 | [diff] [blame] | 155 | // If |clip_bounds| is true, result bounds will be clipped. |
Dominic Mazzoni | 2410fc6 | 2017-06-09 22:19:18 | [diff] [blame] | 156 | gfx::RectF RelativeToTreeBounds(const AXNode* node, |
Katie Dektar | 2c6052d | 2017-09-27 00:32:32 | [diff] [blame] | 157 | gfx::RectF node_bounds, |
Katie Dektar | db71ad94 | 2017-11-29 20:07:48 | [diff] [blame] | 158 | bool* offscreen = nullptr, |
David Tseng | 7bf30c3c | 2022-07-22 15:13:37 | [diff] [blame] | 159 | bool clip_bounds = true, |
| 160 | bool skip_container_offset = false) const; |
Dominic Mazzoni | 2410fc6 | 2017-06-09 22:19:18 | [diff] [blame] | 161 | |
| 162 | // Get the bounds of a node in the coordinate space of the tree. |
Katie Dektar | 2c6052d | 2017-09-27 00:32:32 | [diff] [blame] | 163 | // If set, updates |offscreen| boolean to be true if the node is offscreen |
| 164 | // relative to its rootWebArea. Callers should initialize |offscreen| |
| 165 | // to false: this method may get called multiple times in a row and |
| 166 | // |offscreen| will be propagated. |
Katie Dektar | db71ad94 | 2017-11-29 20:07:48 | [diff] [blame] | 167 | // If |clip_bounds| is true, result bounds will be clipped. |
| 168 | gfx::RectF GetTreeBounds(const AXNode* node, |
| 169 | bool* offscreen = nullptr, |
| 170 | bool clip_bounds = true) const; |
Dominic Mazzoni | 2410fc6 | 2017-06-09 22:19:18 | [diff] [blame] | 171 | |
Dominic Mazzoni | 35f2a525 | 2017-09-26 00:56:04 | [diff] [blame] | 172 | // Given a node ID attribute (one where IsNodeIdIntAttribute is true), |
| 173 | // and a destination node ID, return a set of all source node IDs that |
| 174 | // have that relationship attribute between them and the destination. |
Nektarios Paisios | 527d33fb5 | 2021-02-23 19:23:28 | [diff] [blame] | 175 | std::set<AXNodeID> GetReverseRelations(ax::mojom::IntAttribute attr, |
| 176 | AXNodeID dst_id) const; |
Dominic Mazzoni | 35f2a525 | 2017-09-26 00:56:04 | [diff] [blame] | 177 | |
| 178 | // Given a node ID list attribute (one where |
| 179 | // IsNodeIdIntListAttribute is true), and a destination node ID, |
| 180 | // return a set of all source node IDs that have that relationship |
| 181 | // attribute between them and the destination. |
Nektarios Paisios | 527d33fb5 | 2021-02-23 19:23:28 | [diff] [blame] | 182 | std::set<AXNodeID> GetReverseRelations(ax::mojom::IntListAttribute attr, |
| 183 | AXNodeID dst_id) const; |
Dominic Mazzoni | 35f2a525 | 2017-09-26 00:56:04 | [diff] [blame] | 184 | |
Dominic Mazzoni | aa77482 | 2018-08-29 20:33:58 | [diff] [blame] | 185 | // Given a child tree ID, return the node IDs of all nodes in the tree who |
| 186 | // have a kChildTreeId int attribute with that value. |
Nektarios Paisios | 50e579f1 | 2022-05-19 19:22:39 | [diff] [blame] | 187 | // |
| 188 | // TODO(accessibility): There should really be only one host node per child |
| 189 | // tree, so the return value should not be a set but a single node ID or |
| 190 | // `kInvalidAXNodeID`. |
Nektarios Paisios | 527d33fb5 | 2021-02-23 19:23:28 | [diff] [blame] | 191 | std::set<AXNodeID> GetNodeIdsForChildTreeId(AXTreeID child_tree_id) const; |
Dominic Mazzoni | aa77482 | 2018-08-29 20:33:58 | [diff] [blame] | 192 | |
Dominic Mazzoni | 748888c | 2018-11-01 22:34:59 | [diff] [blame] | 193 | // Get all of the child tree IDs referenced by any node in this tree. |
| 194 | const std::set<AXTreeID> GetAllChildTreeIds() const; |
| 195 | |
David Tseng | ef6b480d | 2018-02-19 12:48:42 | [diff] [blame] | 196 | // Map from a relation attribute to a map from a target id to source ids. |
| 197 | const IntReverseRelationMap& int_reverse_relations() { |
| 198 | return int_reverse_relations_; |
| 199 | } |
| 200 | const IntListReverseRelationMap& intlist_reverse_relations() { |
| 201 | return intlist_reverse_relations_; |
| 202 | } |
Dominic Mazzoni | 3d9b5b9 | 2018-04-18 21:36:38 | [diff] [blame] | 203 | |
[email protected] | 5eec2f5 | 2014-01-06 22:30:54 | [diff] [blame] | 204 | // Return a multi-line indented string representation, for logging. |
| 205 | std::string ToString() const; |
| 206 | |
[email protected] | d4e27346 | 2013-12-04 04:37:58 | [diff] [blame] | 207 | // A string describing the error from an unsuccessful Unserialize, |
| 208 | // for testing and debugging. |
tfarina | d0bfb4b6 | 2015-02-18 17:20:32 | [diff] [blame] | 209 | const std::string& error() const { return error_; } |
[email protected] | d4e27346 | 2013-12-04 04:37:58 | [diff] [blame] | 210 | |
Aaron Leventhal | 0ebbf7c | 2022-08-24 14:29:41 | [diff] [blame] | 211 | void DisallowFailFastForFuzzing() { disallow_fail_fast_ = true; } |
| 212 | |
dmazzoni | ee2eaca | 2015-03-18 18:13:07 | [diff] [blame] | 213 | int size() { return static_cast<int>(id_map_.size()); } |
| 214 | |
Dominic Mazzoni | d42e00a | 2018-06-27 23:14:23 | [diff] [blame] | 215 | // Return a negative number that's suitable to use for a node ID for |
| 216 | // internal nodes created automatically by an AXTree, so as not to |
| 217 | // conflict with positive-numbered node IDs from tree sources. |
Nektarios Paisios | 527d33fb5 | 2021-02-23 19:23:28 | [diff] [blame] | 218 | AXNodeID GetNextNegativeInternalNodeId(); |
Dominic Mazzoni | d42e00a | 2018-06-27 23:14:23 | [diff] [blame] | 219 | |
Akihiro Ota | f42a7d0 | 2020-06-12 19:07:56 | [diff] [blame] | 220 | // Returns the PosInSet of |node|. Looks in node_set_size_pos_in_set_info_map_ |
| 221 | // for cached value. Calls |ComputeSetSizePosInSetAndCache|if no value is |
| 222 | // present in the cache. |
Alexander Surkov | 4ab64cf | 2022-09-01 20:07:46 | [diff] [blame] | 223 | absl::optional<int> GetPosInSet(const AXNode& node); |
| 224 | |
Akihiro Ota | f42a7d0 | 2020-06-12 19:07:56 | [diff] [blame] | 225 | // Returns the SetSize of |node|. Looks in node_set_size_pos_in_set_info_map_ |
| 226 | // for cached value. Calls |ComputeSetSizePosInSetAndCache|if no value is |
| 227 | // present in the cache. |
Alexander Surkov | 4ab64cf | 2022-09-01 20:07:46 | [diff] [blame] | 228 | absl::optional<int> GetSetSize(const AXNode& node); |
Akihiro Ota | 413ca72 | 2018-12-03 23:29:00 | [diff] [blame] | 229 | |
Nektarios Paisios | d3e82c6d | 2022-08-12 19:06:55 | [diff] [blame] | 230 | // Returns the part of the current selection that falls within this |
| 231 | // accessibility tree, if any. |
Alexander Surkov | 4ab64cf | 2022-09-01 20:07:46 | [diff] [blame] | 232 | AXSelection GetSelection() const; |
Nektarios Paisios | d3e82c6d | 2022-08-12 19:06:55 | [diff] [blame] | 233 | |
| 234 | // Returns the part of the current selection that falls within this |
| 235 | // accessibility tree, if any, adjusting its endpoints to be within unignored |
| 236 | // nodes. (An "ignored" node is a node that is not exposed to platform APIs: |
| 237 | // See `AXNode::IsIgnored`.) |
Alexander Surkov | 4ab64cf | 2022-09-01 20:07:46 | [diff] [blame] | 238 | AXSelection GetUnignoredSelection() const; |
Jacques Newman | 339afc6 | 2019-08-14 00:49:22 | [diff] [blame] | 239 | |
Alexander Surkov | 4ab64cf | 2022-09-01 20:07:46 | [diff] [blame] | 240 | bool GetTreeUpdateInProgressState() const; |
Akihiro Ota | e3e420e | 2019-04-17 19:57:40 | [diff] [blame] | 241 | |
Kurt Catti-Schmidt | c8445a1 | 2019-08-07 18:52:58 | [diff] [blame] | 242 | // Returns true if the tree represents a paginated document |
Alexander Surkov | 4ab64cf | 2022-09-01 20:07:46 | [diff] [blame] | 243 | bool HasPaginationSupport() const; |
Kurt Catti-Schmidt | c8445a1 | 2019-08-07 18:52:58 | [diff] [blame] | 244 | |
Chris Hall | 697d99b | 2019-07-09 02:36:11 | [diff] [blame] | 245 | // Language detection manager, entry point to language detection features. |
| 246 | // TODO(chrishall): Should this be stored by pointer or value? |
| 247 | // When should we initialize this? |
| 248 | std::unique_ptr<AXLanguageDetectionManager> language_detection_manager; |
Chris Hall | 3420818 | 2019-03-13 02:26:18 | [diff] [blame] | 249 | |
David Tseng | 41f13cbd | 2021-11-06 18:39:03 | [diff] [blame] | 250 | // Event metadata while applying a tree update during unserialization. |
| 251 | AXEvent* event_data() const { return event_data_.get(); } |
David Tseng | b0d4366 | 2020-05-20 20:47:28 | [diff] [blame] | 252 | |
Benjamin Beaudry | e8f23a2 | 2020-12-17 20:08:02 | [diff] [blame] | 253 | // Notify the delegate that the tree manager for |previous_tree_id| will be |
| 254 | // removed from the AXTreeManagerMap. Because we sometimes remove the tree |
| 255 | // manager after the tree's id has been modified, we need to pass the (old) |
| 256 | // tree id associated with the manager we are removing even though it is the |
| 257 | // same tree. |
| 258 | void NotifyTreeManagerWillBeRemoved(AXTreeID previous_tree_id); |
| 259 | |
[email protected] | e736e81b | 2014-02-24 07:15:58 | [diff] [blame] | 260 | private: |
Nektarios Paisios | 8eb31fc | 2022-02-18 16:37:58 | [diff] [blame] | 261 | friend class ScopedTreeUpdateInProgressStateSetter; |
Dominic Mazzoni | ecfb4fd | 2018-10-23 07:34:20 | [diff] [blame] | 262 | friend class AXTableInfoTest; |
| 263 | |
Nektarios Paisios | 77c422a | 2021-10-19 10:37:00 | [diff] [blame] | 264 | // Indicates if the node with the focus should never be ignored, (see |
| 265 | // `SetFocusedNodeShouldNeverBeIgnored` above). |
| 266 | static bool is_focused_node_always_unignored_; |
| 267 | |
Aaron Leventhal | a674d63 | 2020-09-30 07:05:36 | [diff] [blame] | 268 | // Accumulate errors as there can be more than one before Chrome is crashed |
| 269 | // via AccessibilityFatalError(); |
Aaron Leventhal | bc649ff | 2022-08-11 18:53:23 | [diff] [blame] | 270 | // In an AX_FAIL_FAST_BUILD, will assert/crash immediately. |
| 271 | void RecordError(const AXTreeUpdateState& update_state, |
| 272 | std::string new_error); |
Aaron Leventhal | a674d63 | 2020-09-30 07:05:36 | [diff] [blame] | 273 | |
dtseng | 5a7b3d9 | 2016-09-08 06:35:58 | [diff] [blame] | 274 | AXNode* CreateNode(AXNode* parent, |
Dominic Mazzoni | 9ccdedb2 | 2021-01-30 17:59:42 | [diff] [blame] | 275 | AXNodeID id, |
Peter Kasting | 94a07a1 | 2019-05-22 19:26:28 | [diff] [blame] | 276 | size_t index_in_parent, |
dtseng | 5a7b3d9 | 2016-09-08 06:35:58 | [diff] [blame] | 277 | AXTreeUpdateState* update_state); |
[email protected] | 4b02bbca | 2013-11-22 08:59:03 | [diff] [blame] | 278 | |
Adam Ettenberger | d9d8d58a | 2019-08-06 16:54:08 | [diff] [blame] | 279 | // Accumulates the work that will be required to update the AXTree. |
| 280 | // This allows us to notify observers of structure changes when the |
| 281 | // tree is still in a stable and unchanged state. |
| 282 | bool ComputePendingChanges(const AXTreeUpdate& update, |
Lei Zhang | a0614478 | 2020-03-13 09:28:47 | [diff] [blame] | 283 | AXTreeUpdateState* update_state); |
Adam Ettenberger | d9d8d58a | 2019-08-06 16:54:08 | [diff] [blame] | 284 | |
| 285 | // Populates |update_state| with information about actions that will |
| 286 | // be performed on the tree during the update, such as adding or |
| 287 | // removing nodes in the tree. Returns true on success. |
| 288 | // Nothing within this call should modify tree structure or node data. |
| 289 | bool ComputePendingChangesToNode(const AXNodeData& new_data, |
| 290 | bool is_new_root, |
| 291 | AXTreeUpdateState* update_state); |
| 292 | |
[email protected] | 4b02bbca | 2013-11-22 08:59:03 | [diff] [blame] | 293 | // This is called from within Unserialize(), it returns true on success. |
dmazzoni | 67b4db2 | 2016-04-23 00:40:04 | [diff] [blame] | 294 | bool UpdateNode(const AXNodeData& src, |
| 295 | bool is_new_root, |
| 296 | AXTreeUpdateState* update_state); |
[email protected] | 4b02bbca | 2013-11-22 08:59:03 | [diff] [blame] | 297 | |
Adam Ettenberger | d9d8d58a | 2019-08-06 16:54:08 | [diff] [blame] | 298 | // Notify the delegate that the subtree rooted at |node| will be |
| 299 | // destroyed or reparented. |
| 300 | void NotifySubtreeWillBeReparentedOrDeleted( |
| 301 | AXNode* node, |
| 302 | const AXTreeUpdateState* update_state); |
| 303 | |
| 304 | // Notify the delegate that |node| will be destroyed or reparented. |
| 305 | void NotifyNodeWillBeReparentedOrDeleted( |
| 306 | AXNode* node, |
| 307 | const AXTreeUpdateState* update_state); |
| 308 | |
| 309 | // Notify the delegate that |node| and all of its descendants will be |
Victor Fei | e3cce4c | 2019-11-14 18:35:41 | [diff] [blame] | 310 | // destroyed. This function is called during AXTree teardown. |
| 311 | void RecursivelyNotifyNodeDeletedForTreeTeardown(AXNode* node); |
| 312 | |
| 313 | // Notify the delegate that the node marked by |node_id| has been deleted. |
| 314 | // We are passing the node id instead of ax node is because by the time this |
| 315 | // function is called, the ax node in the tree will already have been |
Adam Ettenberger | d9d8d58a | 2019-08-06 16:54:08 | [diff] [blame] | 316 | // destroyed. |
Dominic Mazzoni | 9ccdedb2 | 2021-01-30 17:59:42 | [diff] [blame] | 317 | void NotifyNodeHasBeenDeleted(AXNodeID node_id); |
Adam Ettenberger | d9d8d58a | 2019-08-06 16:54:08 | [diff] [
|