| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef UI_ACCESSIBILITY_AX_TREE_UPDATE_H_ | 5 #ifndef UI_ACCESSIBILITY_AX_TREE_UPDATE_H_ |
| 6 #define UI_ACCESSIBILITY_AX_TREE_UPDATE_H_ | 6 #define UI_ACCESSIBILITY_AX_TREE_UPDATE_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "ui/accessibility/ax_node_data.h" | 10 #include "ui/accessibility/ax_node_data.h" |
| 11 | 11 |
| 12 namespace ui { | 12 namespace ui { |
| 13 | 13 |
| 14 // An AXTreeUpdate is a serialized representation of an atomic change | 14 // An AXTreeUpdate is a serialized representation of an atomic change |
| 15 // to an AXTree. The sender and receiver must be in sync; the update | 15 // to an AXTree. The sender and receiver must be in sync; the update |
| 16 // is only meant to bring the tree from a specific previous state into | 16 // is only meant to bring the tree from a specific previous state into |
| 17 // its next state. Trying to apply it to the wrong tree should immediately | 17 // its next state. Trying to apply it to the wrong tree should immediately |
| 18 // die with a fatal assertion. An AXTreeUpdate is just an ordered vector | 18 // die with a fatal assertion. |
| 19 // of AXNodeData structures to be applied to the tree in order. | 19 // |
| 20 // An AXTreeUpdate consists of an optional node id to clear (meaning |
| 21 // that all of that node's children and their descendants are deleted), |
| 22 // followed by an ordered vector of AXNodeData structures to be applied |
| 23 // to the tree in order. |
| 20 // | 24 // |
| 21 // Suppose that the next AXNodeData to be applied is |node|. The following | 25 // Suppose that the next AXNodeData to be applied is |node|. The following |
| 22 // invariants must hold: | 26 // invariants must hold: |
| 23 // 1. Either |node.id| is already in the tree, or else |node| is the new | 27 // 1. Either |node.id| is already in the tree, or else the tree is empty, |
| 24 // root of the tree and |node.role| == WebAXRoleRootWebArea. | 28 // |node| is the new root of the tree, and |
| 29 // |node.role| == WebAXRoleRootWebArea. |
| 25 // 2. Every child id in |node.child_ids| must either be already a child | 30 // 2. Every child id in |node.child_ids| must either be already a child |
| 26 // of this node, or a new id not previously in the tree. It is not | 31 // of this node, or a new id not previously in the tree. It is not |
| 27 // allowed to "reparent" a child to this node without first removing | 32 // allowed to "reparent" a child to this node without first removing |
| 28 // that child from its previous parent. | 33 // that child from its previous parent. |
| 29 // 3. When a new id appears in |node.child_ids|, the tree should create a | 34 // 3. When a new id appears in |node.child_ids|, the tree should create a |
| 30 // new uninitialized placeholder node for it immediately. That | 35 // new uninitialized placeholder node for it immediately. That |
| 31 // placeholder must be updated within the same AXTreeUpdate, otherwise | 36 // placeholder must be updated within the same AXTreeUpdate, otherwise |
| 32 // it's a fatal error. This guarantees the tree is always complete | 37 // it's a fatal error. This guarantees the tree is always complete |
| 33 // before or after an AXTreeUpdate. | 38 // before or after an AXTreeUpdate. |
| 34 struct AX_EXPORT AXTreeUpdate { | 39 struct AX_EXPORT AXTreeUpdate { |
| 35 AXTreeUpdate(); | 40 AXTreeUpdate(); |
| 36 ~AXTreeUpdate(); | 41 ~AXTreeUpdate(); |
| 37 | 42 |
| 43 // The id of a node to clear, before applying any updates, |
| 44 // or 0 if no nodes should be cleared. Clearing a node means deleting |
| 45 // all of its children and their descendants, but leaving that node in |
| 46 // the tree. It's an error to clear a node but not subsequently update it |
| 47 // as part of the tree update. |
| 48 int node_id_to_clear; |
| 49 |
| 50 // A vector of nodes to update, according to the rules above. |
| 38 std::vector<AXNodeData> nodes; | 51 std::vector<AXNodeData> nodes; |
| 39 | 52 |
| 40 // TODO(dmazzoni): location changes | 53 // TODO(dmazzoni): location changes |
| 41 }; | 54 }; |
| 42 | 55 |
| 43 } // namespace ui | 56 } // namespace ui |
| 44 | 57 |
| 45 #endif // UI_ACCESSIBILITY_AX_TREE_UPDATE_H_ | 58 #endif // UI_ACCESSIBILITY_AX_TREE_UPDATE_H_ |
| OLD | NEW |