Index: cc/trees/property_tree.h |
diff --git a/cc/trees/property_tree.h b/cc/trees/property_tree.h |
index b00d090a3d863eb43bbd2946455cf70dc4cc4cf9..7aa86d60bc9ba2033540f38655d0453079220591 100644 |
--- a/cc/trees/property_tree.h |
+++ b/cc/trees/property_tree.h |
@@ -67,6 +67,10 @@ class CC_EXPORT PropertyTree { |
~PropertyTree(); |
PropertyTree<T>& operator=(const PropertyTree<T>&); |
+ // Property tree node starts from index 0. |
+ static const int kInvalidNodeId = -1; |
+ static const int kRootNodeId = 0; |
+ |
bool operator==(const PropertyTree<T>& other) const; |
int Insert(const T& tree_node, int parent_id); |
@@ -82,8 +86,12 @@ class CC_EXPORT PropertyTree { |
return i > -1 ? &nodes_[i] : nullptr; |
} |
- T* parent(const T* t) { return Node(t->parent_id); } |
- const T* parent(const T* t) const { return Node(t->parent_id); } |
+ T* parent(const T* t) { |
+ return t->parent_id >= 0 ? Node(t->parent_id) : nullptr; |
+ } |
+ const T* parent(const T* t) const { |
+ return t->parent_id >= 0 ? Node(t->parent_id) : nullptr; |
+ } |
T* back() { return size() ? &nodes_.back() : nullptr; } |
const T* back() const { return size() ? &nodes_.back() : nullptr; } |
@@ -129,6 +137,13 @@ class CC_EXPORT TransformTree final : public PropertyTree<TransformNode> { |
~TransformTree(); |
TransformTree& operator=(const TransformTree&); |
+ // Transform tree requires a dummy node 0 representing device space. The root |
+ // node of transform tree with real information is node 1, unlike all other |
+ // property trees. When transform tree is created, it is created with dummy |
+ // node 0. |
+ static const int kDeviceNodeId = 0; |
+ static const int kRootNodeId = 1; |
+ |
bool operator==(const TransformTree& other) const; |
int Insert(const TransformNode& tree_node, int parent_id); |
@@ -309,6 +324,8 @@ class CC_EXPORT TransformTree final : public PropertyTree<TransformNode> { |
class CC_EXPORT ClipTree final : public PropertyTree<ClipNode> { |
public: |
+ static const int kViewportNodeId = 0; |
+ |
bool operator==(const ClipTree& other) const; |
void SetViewportClip(gfx::RectF viewport_rect); |