Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(9)

Unified Diff: ui/accessibility/ax_tree.h

Issue 90853002: Make tree serialization more robust and add more unit tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rename update0 to unused_update Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/accessibility/ax_serializable_tree.cc ('k') | ui/accessibility/ax_tree.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/accessibility/ax_tree.h
diff --git a/ui/accessibility/ax_tree.h b/ui/accessibility/ax_tree.h
index 84108e05910d99572c0423e20579388b9d0691af..773a773adf548da10b2940d7ecaec3d35edccc71 100644
--- a/ui/accessibility/ax_tree.h
+++ b/ui/accessibility/ax_tree.h
@@ -5,8 +5,9 @@
#ifndef UI_ACCESSIBILITY_AX_TREE_H_
#define UI_ACCESSIBILITY_AX_TREE_H_
-#include "base/containers/hash_tables.h"
+#include <set>
+#include "base/containers/hash_tables.h"
#include "ui/accessibility/ax_export.h"
#include "ui/accessibility/ax_tree.h"
#include "ui/accessibility/ax_tree_update.h"
@@ -29,15 +30,26 @@ class AX_EXPORT AXTree {
virtual AXNode* GetRoot() const;
virtual AXNode* GetFromId(int32 id) const;
+ // Returns true on success. If it returns false, it's a fatal error
+ // and this tree should be destroyed, and the source of the tree update
+ // should not be trusted any longer.
virtual bool Unserialize(const AXTreeUpdate& update);
+ // A string describing the error from an unsuccessful Unserialize,
+ // for testing and debugging.
+ const std::string& error() { return error_; }
+
protected:
// Subclasses can override this to use a subclass of AXNode.
virtual AXNode* CreateNode(AXNode* parent, int32 id, int32 index_in_parent);
// This is called from within Unserialize(), it returns true on success.
- // Subclasses can override this to do additional processing.
- virtual bool UpdateNode(const AXNodeData& src);
+ // Subclasses can override this to do additional processing. |pending_nodes|
+ // is updated to contain all nodes that have been implicitly referenced
+ // as part of this update, but haven't been updated yet. It's an error if
+ // there are any pending nodes at the end of Unserialize.
+ virtual bool UpdateNode(const AXNodeData& src,
+ std::set<AXNode*>* pending_nodes);
// Subclasses can override this to do special behavior when the root changes.
virtual void OnRootChanged();
@@ -61,13 +73,16 @@ class AX_EXPORT AXTree {
// pointers to child nodes, reusing existing nodes already in the tree
// if they exist, and creating otherwise. Reparenting is disallowed, so
// if the id already exists as the child of another node, that's an
- // error. Returns true on success, false on fatal error.
+ // error. Returns true on success, false on fatal error. See
+ // UpdateNode, above, for an explanation of |pending_nodes|.
bool CreateNewChildVector(AXNode* node,
const std::vector<int32> new_child_ids,
- std::vector<AXNode*>* new_children);
+ std::vector<AXNode*>* new_children,
+ std::set<AXNode*>* pending_nodes);
AXNode* root_;
base::hash_map<int32, AXNode*> id_map_;
+ std::string error_;
};
} // namespace ui
« no previous file with comments | « ui/accessibility/ax_serializable_tree.cc ('k') | ui/accessibility/ax_tree.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698