Chromium Code Reviews| Index: cc/trees/property_tree.h |
| diff --git a/cc/trees/property_tree.h b/cc/trees/property_tree.h |
| index 622f652f342ab30e74c780abe79eacb37028b312..f7da521876e36d79ed9405d75c2606b7aabadc94 100644 |
| --- a/cc/trees/property_tree.h |
| +++ b/cc/trees/property_tree.h |
| @@ -360,6 +360,10 @@ class CC_EXPORT PropertyTree { |
| PropertyTree(const PropertyTree& other) = delete; |
| ~PropertyTree(); |
| + // 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); |
| @@ -375,8 +379,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; |
|
ajuma
2016/06/22 13:29:51
The Node method already checks if its argument is
|
| + } |
| + const T* parent(const T* t) const { |
| + return t->parent_id >= 0 ? Node(t->parent_id) : nullptr; |
| + } |
| T* back() { return size() ? &nodes_[nodes_.size() - 1] : nullptr; } |
| const T* back() const { |
| @@ -417,6 +425,13 @@ class CC_EXPORT TransformTree final : public PropertyTree<TransformNode> { |
| TransformTree(); |
| ~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); |
| @@ -597,6 +612,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); |