| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 ObjectPaintProperties_h | 5 #ifndef ObjectPaintProperties_h |
| 6 #define ObjectPaintProperties_h | 6 #define ObjectPaintProperties_h |
| 7 | 7 |
| 8 #include "platform/geometry/LayoutPoint.h" |
| 8 #include "platform/graphics/paint/ClipPaintPropertyNode.h" | 9 #include "platform/graphics/paint/ClipPaintPropertyNode.h" |
| 9 #include "platform/graphics/paint/EffectPaintPropertyNode.h" | 10 #include "platform/graphics/paint/EffectPaintPropertyNode.h" |
| 11 #include "platform/graphics/paint/PaintChunkProperties.h" |
| 10 #include "platform/graphics/paint/TransformPaintPropertyNode.h" | 12 #include "platform/graphics/paint/TransformPaintPropertyNode.h" |
| 11 #include "wtf/PassOwnPtr.h" | 13 #include "wtf/PassOwnPtr.h" |
| 12 #include "wtf/PassRefPtr.h" | 14 #include "wtf/PassRefPtr.h" |
| 13 #include "wtf/RefPtr.h" | 15 #include "wtf/RefPtr.h" |
| 14 | 16 |
| 15 namespace blink { | 17 namespace blink { |
| 16 | 18 |
| 17 // The minimal set of paint properties created by a |LayoutObject|. These | 19 // This class stores property tree related information associated with a LayoutO
bject. |
| 18 // properties encode a hierachy of transforms, clips, effects, etc, both between | 20 // Currently there are two groups of information: |
| 19 // LayoutObjects (each property has a parent) and among the properties of a | 21 // 1. The set of property nodes created locally by this LayoutObject. |
| 20 // single LayoutObject (e.g., transform and perspective with the correct parent | 22 // 2. [Optional] A suite of property nodes (PaintChunkProperties) and paint offs
et |
| 21 // relationship to represent ordering). | 23 // that can be used to paint the border box of this LayoutObject. |
| 22 // | |
| 23 // This differs from |PaintChunkProperties| because it can store multiple | |
| 24 // properties of the same type (e.g., transform and perspective which are both | |
| 25 // transforms). | |
| 26 class ObjectPaintProperties { | 24 class ObjectPaintProperties { |
| 27 WTF_MAKE_NONCOPYABLE(ObjectPaintProperties); | 25 WTF_MAKE_NONCOPYABLE(ObjectPaintProperties); |
| 28 USING_FAST_MALLOC(ObjectPaintProperties); | 26 USING_FAST_MALLOC(ObjectPaintProperties); |
| 29 public: | 27 public: |
| 28 struct LocalBorderBoxProperties; |
| 29 |
| 30 static PassOwnPtr<ObjectPaintProperties> create( | 30 static PassOwnPtr<ObjectPaintProperties> create( |
| 31 PassRefPtr<TransformPaintPropertyNode> paintOffsetTranslation, | 31 PassRefPtr<TransformPaintPropertyNode> paintOffsetTranslation, |
| 32 PassRefPtr<TransformPaintPropertyNode> transform, | 32 PassRefPtr<TransformPaintPropertyNode> transform, |
| 33 PassRefPtr<EffectPaintPropertyNode> effect, | 33 PassRefPtr<EffectPaintPropertyNode> effect, |
| 34 PassRefPtr<ClipPaintPropertyNode> overflowClip, | 34 PassRefPtr<ClipPaintPropertyNode> overflowClip, |
| 35 PassRefPtr<TransformPaintPropertyNode> perspective, | 35 PassRefPtr<TransformPaintPropertyNode> perspective, |
| 36 PassRefPtr<TransformPaintPropertyNode> scrollTranslation) | 36 PassRefPtr<TransformPaintPropertyNode> scrollTranslation, |
| 37 PassOwnPtr<LocalBorderBoxProperties> localBorderBoxProperties) |
| 37 { | 38 { |
| 38 return adoptPtr(new ObjectPaintProperties(paintOffsetTranslation, transf
orm, effect, overflowClip, perspective, scrollTranslation)); | 39 return adoptPtr(new ObjectPaintProperties(paintOffsetTranslation, transf
orm, effect, overflowClip, perspective, scrollTranslation, localBorderBoxPropert
ies)); |
| 39 } | 40 } |
| 40 | 41 |
| 41 // The hierarchy of transform subtree created by a LayoutObject. | 42 // The hierarchy of transform subtree created by a LayoutObject. |
| 42 // [ paintOffsetTranslation ] Normally paint offset is accumulated
without creating a node | 43 // [ paintOffsetTranslation ] Normally paint offset is accumulated
without creating a node |
| 43 // | until we see, for example, transform
or position:fixed. | 44 // | until we see, for example, transform
or position:fixed. |
| 44 // +---[ transform ] The space created by CSS transform. | 45 // +---[ transform ] The space created by CSS transform. |
| 46 // | This is the local border box space,
see: LocalBorderBoxProperties below. |
| 45 // +---[ perspective ] The space created by CSS perspective
. | 47 // +---[ perspective ] The space created by CSS perspective
. |
| 46 // +---[ scrollTranslation ] The space created by overflow clip. | 48 // +---[ scrollTranslation ] The space created by overflow clip. |
| 47 TransformPaintPropertyNode* paintOffsetTranslation() const { return m_paintO
ffsetTranslation.get(); } | 49 TransformPaintPropertyNode* paintOffsetTranslation() const { return m_paintO
ffsetTranslation.get(); } |
| 48 TransformPaintPropertyNode* transform() const { return m_transform.get(); } | 50 TransformPaintPropertyNode* transform() const { return m_transform.get(); } |
| 49 TransformPaintPropertyNode* perspective() const { return m_perspective.get()
; } | 51 TransformPaintPropertyNode* perspective() const { return m_perspective.get()
; } |
| 50 TransformPaintPropertyNode* scrollTranslation() const { return m_scrollTrans
lation.get(); } | 52 TransformPaintPropertyNode* scrollTranslation() const { return m_scrollTrans
lation.get(); } |
| 51 | 53 |
| 52 // Transform that applies to layer contents, or nullptr if this object | 54 // Transform that applies to layer contents, or nullptr if this object |
| 53 // doesn't define one. | 55 // doesn't define one. |
| 54 TransformPaintPropertyNode* transformForLayerContents() const; | 56 TransformPaintPropertyNode* transformForLayerContents() const; |
| 55 | 57 |
| 56 EffectPaintPropertyNode* effect() const { return m_effect.get(); } | 58 EffectPaintPropertyNode* effect() const { return m_effect.get(); } |
| 57 | 59 |
| 58 ClipPaintPropertyNode* overflowClip() const { return m_overflowClip.get(); } | 60 ClipPaintPropertyNode* overflowClip() const { return m_overflowClip.get(); } |
| 59 | 61 |
| 62 // This is a complete set of property nodes that should be used as a startin
g point to paint |
| 63 // this layout object. It is needed becauase some property inherits from the
containing block, |
| 64 // not painting parent, thus can't be derived in O(1) during paint walk. |
| 65 // Note: If this layout object has transform or stacking-context effects, th
ose are already |
| 66 // baked into in the context here. However for properties that affects only
children, |
| 67 // for example, perspective and overflow clip, those should be applied by th
e painter |
| 68 // at the right painting step. |
| 69 struct LocalBorderBoxProperties { |
| 70 LayoutPoint paintOffset; |
| 71 PaintChunkProperties properties; |
| 72 }; |
| 73 LocalBorderBoxProperties* localBorderBoxProperties() const { return m_localB
orderBoxProperties.get(); } |
| 74 |
| 60 private: | 75 private: |
| 61 ObjectPaintProperties( | 76 ObjectPaintProperties( |
| 62 PassRefPtr<TransformPaintPropertyNode> paintOffsetTranslation, | 77 PassRefPtr<TransformPaintPropertyNode> paintOffsetTranslation, |
| 63 PassRefPtr<TransformPaintPropertyNode> transform, | 78 PassRefPtr<TransformPaintPropertyNode> transform, |
| 64 PassRefPtr<EffectPaintPropertyNode> effect, | 79 PassRefPtr<EffectPaintPropertyNode> effect, |
| 65 PassRefPtr<ClipPaintPropertyNode> overflowClip, | 80 PassRefPtr<ClipPaintPropertyNode> overflowClip, |
| 66 PassRefPtr<TransformPaintPropertyNode> perspective, | 81 PassRefPtr<TransformPaintPropertyNode> perspective, |
| 67 PassRefPtr<TransformPaintPropertyNode> scrollTranslation) | 82 PassRefPtr<TransformPaintPropertyNode> scrollTranslation, |
| 83 PassOwnPtr<LocalBorderBoxProperties> localBorderBoxProperties) |
| 68 : m_paintOffsetTranslation(paintOffsetTranslation) | 84 : m_paintOffsetTranslation(paintOffsetTranslation) |
| 69 , m_transform(transform) | 85 , m_transform(transform) |
| 70 , m_effect(effect) | 86 , m_effect(effect) |
| 71 , m_overflowClip(overflowClip) | 87 , m_overflowClip(overflowClip) |
| 72 , m_perspective(perspective) | 88 , m_perspective(perspective) |
| 73 , m_scrollTranslation(scrollTranslation) { } | 89 , m_scrollTranslation(scrollTranslation) |
| 90 , m_localBorderBoxProperties(localBorderBoxProperties) { } |
| 74 | 91 |
| 75 RefPtr<TransformPaintPropertyNode> m_paintOffsetTranslation; | 92 RefPtr<TransformPaintPropertyNode> m_paintOffsetTranslation; |
| 76 RefPtr<TransformPaintPropertyNode> m_transform; | 93 RefPtr<TransformPaintPropertyNode> m_transform; |
| 77 RefPtr<EffectPaintPropertyNode> m_effect; | 94 RefPtr<EffectPaintPropertyNode> m_effect; |
| 78 RefPtr<ClipPaintPropertyNode> m_overflowClip; | 95 RefPtr<ClipPaintPropertyNode> m_overflowClip; |
| 79 RefPtr<TransformPaintPropertyNode> m_perspective; | 96 RefPtr<TransformPaintPropertyNode> m_perspective; |
| 80 RefPtr<TransformPaintPropertyNode> m_scrollTranslation; | 97 RefPtr<TransformPaintPropertyNode> m_scrollTranslation; |
| 98 |
| 99 OwnPtr<LocalBorderBoxProperties> m_localBorderBoxProperties; |
| 81 }; | 100 }; |
| 82 | 101 |
| 83 } // namespace blink | 102 } // namespace blink |
| 84 | 103 |
| 85 #endif // ObjectPaintProperties_h | 104 #endif // ObjectPaintProperties_h |
| OLD | NEW |