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

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: Created 7 years, 1 month 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
Index: ui/accessibility/ax_tree.h
diff --git a/ui/accessibility/ax_tree.h b/ui/accessibility/ax_tree.h
index 84108e05910d99572c0423e20579388b9d0691af..a56a0b2754130d48b4f624083d883aa2067f55c7 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,23 @@ 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.
aboxhall 2013/12/02 17:18:08 Could you comment what orphaned_nodes is used for?
dmazzoni 2013/12/03 08:35:04 Done. Sorry, I renamed it to pending_nodes in the
- virtual bool UpdateNode(const AXNodeData& src);
+ virtual bool UpdateNode(const AXNodeData& src,
+ std::set<AXNode*>* orphaned_nodes);
// Subclasses can override this to do special behavior when the root changes.
virtual void OnRootChanged();
@@ -64,10 +73,12 @@ class AX_EXPORT AXTree {
// error. Returns true on success, false on fatal error.
aboxhall 2013/12/02 17:18:08 Could you comment what pending_nodes is used for?
dmazzoni 2013/12/03 08:35:04 Done.
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

Powered by Google App Engine
This is Rietveld 408576698