Updating trunk VERSION from 2139.0 to 2140.0
[chromium-blink-merge.git] / ui / accessibility / ax_tree_update.h
blob314a78f823af20dbc7be2d53009a74918af0a038
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.
5 #ifndef UI_ACCESSIBILITY_AX_TREE_UPDATE_H_
6 #define UI_ACCESSIBILITY_AX_TREE_UPDATE_H_
8 #include <vector>
10 #include "ui/accessibility/ax_node_data.h"
12 namespace ui {
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
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
18 // die with a fatal assertion.
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.
25 // Suppose that the next AXNodeData to be applied is |node|. The following
26 // invariants must hold:
27 // 1. Either |node.id| is already in the tree, or else the tree is empty,
28 // |node| is the new root of the tree, and
29 // |node.role| == WebAXRoleRootWebArea.
30 // 2. Every child id in |node.child_ids| must either be already a child
31 // of this node, or a new id not previously in the tree. It is not
32 // allowed to "reparent" a child to this node without first removing
33 // that child from its previous parent.
34 // 3. When a new id appears in |node.child_ids|, the tree should create a
35 // new uninitialized placeholder node for it immediately. That
36 // placeholder must be updated within the same AXTreeUpdate, otherwise
37 // it's a fatal error. This guarantees the tree is always complete
38 // before or after an AXTreeUpdate.
39 struct AX_EXPORT AXTreeUpdate {
40 AXTreeUpdate();
41 ~AXTreeUpdate();
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;
50 // A vector of nodes to update, according to the rules above.
51 std::vector<AXNodeData> nodes;
53 // Return a multi-line indented string representation, for logging.
54 std::string ToString() const;
56 // TODO(dmazzoni): location changes
59 } // namespace ui
61 #endif // UI_ACCESSIBILITY_AX_TREE_UPDATE_H_