| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef PropertyTreeState_h | 5 #ifndef PropertyTreeState_h |
| 6 #define PropertyTreeState_h | 6 #define PropertyTreeState_h |
| 7 | 7 |
| 8 #include "platform/graphics/paint/ClipPaintPropertyNode.h" | 8 #include "platform/graphics/paint/ClipPaintPropertyNode.h" |
| 9 #include "platform/graphics/paint/EffectPaintPropertyNode.h" | 9 #include "platform/graphics/paint/EffectPaintPropertyNode.h" |
| 10 #include "platform/graphics/paint/ScrollPaintPropertyNode.h" | 10 #include "platform/graphics/paint/ScrollPaintPropertyNode.h" |
| 11 #include "platform/graphics/paint/TransformPaintPropertyNode.h" | 11 #include "platform/graphics/paint/TransformPaintPropertyNode.h" |
| 12 #include "wtf/HashFunctions.h" | 12 #include "wtf/HashFunctions.h" |
| 13 #include "wtf/HashTraits.h" | 13 #include "wtf/HashTraits.h" |
| 14 | 14 |
| 15 namespace blink { | 15 namespace blink { |
| 16 | 16 |
| 17 // A complete set of paint properties including those that are inherited from | 17 // A complete set of paint properties including those that are inherited from |
| 18 // other objects. RefPtrs are used to guard against use-after-free bugs and | 18 // other objects. RefPtrs are used to guard against use-after-free bugs and |
| 19 // DCHECKs ensure PropertyTreeState never retains the last reference to a | 19 // DCHECKs ensure PropertyTreeState never retains the last reference to a |
| 20 // property tree node. | 20 // property tree node. |
| 21 class PropertyTreeState { | 21 class PLATFORM_EXPORT PropertyTreeState { |
| 22 public: | 22 public: |
| 23 PropertyTreeState(const TransformPaintPropertyNode* transform, | 23 PropertyTreeState(const TransformPaintPropertyNode* transform, |
| 24 const ClipPaintPropertyNode* clip, | 24 const ClipPaintPropertyNode* clip, |
| 25 const EffectPaintPropertyNode* effect, | 25 const EffectPaintPropertyNode* effect, |
| 26 const ScrollPaintPropertyNode* scroll) | 26 const ScrollPaintPropertyNode* scroll) |
| 27 : m_transform(transform), | 27 : m_transform(transform), |
| 28 m_clip(clip), | 28 m_clip(clip), |
| 29 m_effect(effect), | 29 m_effect(effect), |
| 30 m_scroll(scroll) { | 30 m_scroll(scroll) { |
| 31 DCHECK(!m_transform || !m_transform->hasOneRef()); | 31 DCHECK(!m_transform || !m_transform->hasOneRef()); |
| 32 DCHECK(!m_clip || !m_clip->hasOneRef()); | 32 DCHECK(!m_clip || !m_clip->hasOneRef()); |
| 33 DCHECK(!m_effect || !m_effect->hasOneRef()); | 33 DCHECK(!m_effect || !m_effect->hasOneRef()); |
| 34 DCHECK(!m_scroll || !m_scroll->hasOneRef()); | 34 DCHECK(!m_scroll || !m_scroll->hasOneRef()); |
| 35 } | 35 } |
| 36 | 36 |
| 37 bool hasDirectCompositingReasons() const; |
| 38 |
| 37 const TransformPaintPropertyNode* transform() const { | 39 const TransformPaintPropertyNode* transform() const { |
| 38 DCHECK(!m_transform || !m_transform->hasOneRef()); | 40 DCHECK(!m_transform || !m_transform->hasOneRef()); |
| 39 return m_transform.get(); | 41 return m_transform.get(); |
| 40 } | 42 } |
| 41 void setTransform(RefPtr<const TransformPaintPropertyNode> node) { | 43 void setTransform(RefPtr<const TransformPaintPropertyNode> node) { |
| 42 m_transform = std::move(node); | 44 m_transform = std::move(node); |
| 43 } | 45 } |
| 44 | 46 |
| 45 const ClipPaintPropertyNode* clip() const { | 47 const ClipPaintPropertyNode* clip() const { |
| 46 DCHECK(!m_clip || !m_clip->hasOneRef()); | 48 DCHECK(!m_clip || !m_clip->hasOneRef()); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 59 } | 61 } |
| 60 | 62 |
| 61 const ScrollPaintPropertyNode* scroll() const { | 63 const ScrollPaintPropertyNode* scroll() const { |
| 62 DCHECK(!m_scroll || !m_scroll->hasOneRef()); | 64 DCHECK(!m_scroll || !m_scroll->hasOneRef()); |
| 63 return m_scroll.get(); | 65 return m_scroll.get(); |
| 64 } | 66 } |
| 65 void setScroll(RefPtr<const ScrollPaintPropertyNode> node) { | 67 void setScroll(RefPtr<const ScrollPaintPropertyNode> node) { |
| 66 m_scroll = std::move(node); | 68 m_scroll = std::move(node); |
| 67 } | 69 } |
| 68 | 70 |
| 71 enum InnermostNode { |
| 72 None, // None means that all nodes are their root values |
| 73 Transform, |
| 74 Clip, |
| 75 Effect, |
| 76 }; |
| 77 |
| 78 // There is always a well-defined order in which the transform, clip |
| 79 // and effect of a PropertyTreeState apply. This method returns which |
| 80 // of them applies first. |
| 81 InnermostNode innermostNode() const; |
| 82 |
| 69 private: | 83 private: |
| 70 RefPtr<const TransformPaintPropertyNode> m_transform; | 84 RefPtr<const TransformPaintPropertyNode> m_transform; |
| 71 RefPtr<const ClipPaintPropertyNode> m_clip; | 85 RefPtr<const ClipPaintPropertyNode> m_clip; |
| 72 RefPtr<const EffectPaintPropertyNode> m_effect; | 86 RefPtr<const EffectPaintPropertyNode> m_effect; |
| 73 RefPtr<const ScrollPaintPropertyNode> m_scroll; | 87 RefPtr<const ScrollPaintPropertyNode> m_scroll; |
| 74 }; | 88 }; |
| 75 | 89 |
| 76 inline bool operator==(const PropertyTreeState& a, const PropertyTreeState& b) { | 90 inline bool operator==(const PropertyTreeState& a, const PropertyTreeState& b) { |
| 77 return a.transform() == b.transform() && a.clip() == b.clip() && | 91 return a.transform() == b.transform() && a.clip() == b.clip() && |
| 78 a.effect() == b.effect() && a.scroll() == b.scroll(); | 92 a.effect() == b.effect() && a.scroll() == b.scroll(); |
| 79 } | 93 } |
| 80 | 94 |
| 95 // Iterates over the sequence transforms, clips and effects for a |
| 96 // PropertyTreeState |
| 97 // between that state and the "root" state (all nodes equal to *::Root()), |
| 98 // in the order that they apply. |
| 99 class PLATFORM_EXPORT PropertyTreeStateIterator { |
| 100 public: |
| 101 PropertyTreeStateIterator(const PropertyTreeState& properties) |
| 102 : m_properties(properties) {} |
| 103 const PropertyTreeState* next(); |
| 104 |
| 105 private: |
| 106 PropertyTreeState m_properties; |
| 107 }; |
| 108 |
| 81 } // namespace blink | 109 } // namespace blink |
| 82 | 110 |
| 83 #endif // PropertyTreeState_h | 111 #endif // PropertyTreeState_h |
| OLD | NEW |