OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef PropertyTreeState_h |
| 6 #define PropertyTreeState_h |
| 7 |
| 8 #include "platform/graphics/paint/ClipPaintPropertyNode.h" |
| 9 #include "platform/graphics/paint/EffectPaintPropertyNode.h" |
| 10 #include "platform/graphics/paint/ScrollPaintPropertyNode.h" |
| 11 #include "platform/graphics/paint/TransformPaintPropertyNode.h" |
| 12 #include "wtf/HashFunctions.h" |
| 13 #include "wtf/HashTraits.h" |
| 14 |
| 15 namespace blink { |
| 16 |
| 17 // A complete set of paint properties including those that are inherited from ot
her objects. |
| 18 // RefPtrs are used to guard against use-after-free bugs and DCHECKs ensure Prop
ertyTreeState |
| 19 // never retains the last reference to a property tree node. |
| 20 class PropertyTreeState { |
| 21 public: |
| 22 PropertyTreeState(const TransformPaintPropertyNode* transform, |
| 23 const ClipPaintPropertyNode* clip, |
| 24 const EffectPaintPropertyNode* effect, |
| 25 const ScrollPaintPropertyNode* scroll) |
| 26 : m_transform(transform), |
| 27 m_clip(clip), |
| 28 m_effect(effect), |
| 29 m_scroll(scroll) { |
| 30 DCHECK(!m_transform->hasOneRef() && !m_clip->hasOneRef() && |
| 31 !m_effect->hasOneRef() && !m_scroll->hasOneRef()); |
| 32 } |
| 33 |
| 34 const TransformPaintPropertyNode* transform() const { |
| 35 DCHECK(!m_transform->hasOneRef()); |
| 36 return m_transform.get(); |
| 37 } |
| 38 void setTransform(const TransformPaintPropertyNode* node) { |
| 39 m_transform = node; |
| 40 DCHECK(!node->hasOneRef()); |
| 41 } |
| 42 |
| 43 const ClipPaintPropertyNode* clip() const { |
| 44 DCHECK(!m_clip->hasOneRef()); |
| 45 return m_clip.get(); |
| 46 } |
| 47 void setClip(const ClipPaintPropertyNode* node) { |
| 48 m_clip = node; |
| 49 DCHECK(!node->hasOneRef()); |
| 50 } |
| 51 |
| 52 const EffectPaintPropertyNode* effect() const { |
| 53 DCHECK(!m_effect->hasOneRef()); |
| 54 return m_effect.get(); |
| 55 } |
| 56 void setEffect(const EffectPaintPropertyNode* node) { |
| 57 m_effect = node; |
| 58 DCHECK(!node->hasOneRef()); |
| 59 } |
| 60 |
| 61 const ScrollPaintPropertyNode* scroll() const { |
| 62 DCHECK(!m_scroll->hasOneRef()); |
| 63 return m_scroll.get(); |
| 64 } |
| 65 void setScroll(const ScrollPaintPropertyNode* node) { |
| 66 m_scroll = node; |
| 67 DCHECK(!node->hasOneRef()); |
| 68 } |
| 69 |
| 70 private: |
| 71 RefPtr<const TransformPaintPropertyNode> m_transform; |
| 72 RefPtr<const ClipPaintPropertyNode> m_clip; |
| 73 RefPtr<const EffectPaintPropertyNode> m_effect; |
| 74 RefPtr<const ScrollPaintPropertyNode> m_scroll; |
| 75 }; |
| 76 } // namespace blink |
| 77 |
| 78 #endif // PropertyTreeState_h |
OLD | NEW |