Chromium Code Reviews| 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 "core/CoreExport.h" | 8 #include "core/CoreExport.h" |
| 9 #include "platform/geometry/LayoutPoint.h" | 9 #include "platform/geometry/LayoutPoint.h" |
| 10 #include "platform/graphics/paint/ClipPaintPropertyNode.h" | 10 #include "platform/graphics/paint/ClipPaintPropertyNode.h" |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 22 | 22 |
| 23 // This class stores property tree related information associated with a LayoutO bject. | 23 // This class stores property tree related information associated with a LayoutO bject. |
| 24 // Currently there are two groups of information: | 24 // Currently there are two groups of information: |
| 25 // 1. The set of property nodes created locally by this LayoutObject. | 25 // 1. The set of property nodes created locally by this LayoutObject. |
| 26 // 2. [Optional] A suite of property nodes (PaintChunkProperties) and paint offs et | 26 // 2. [Optional] A suite of property nodes (PaintChunkProperties) and paint offs et |
| 27 // that can be used to paint the border box of this LayoutObject. | 27 // that can be used to paint the border box of this LayoutObject. |
| 28 class CORE_EXPORT ObjectPaintProperties { | 28 class CORE_EXPORT ObjectPaintProperties { |
| 29 WTF_MAKE_NONCOPYABLE(ObjectPaintProperties); | 29 WTF_MAKE_NONCOPYABLE(ObjectPaintProperties); |
| 30 USING_FAST_MALLOC(ObjectPaintProperties); | 30 USING_FAST_MALLOC(ObjectPaintProperties); |
| 31 public: | 31 public: |
| 32 struct LocalBorderBoxProperties; | |
| 33 | |
| 34 static std::unique_ptr<ObjectPaintProperties> create() | 32 static std::unique_ptr<ObjectPaintProperties> create() |
| 35 { | 33 { |
| 36 return wrapUnique(new ObjectPaintProperties()); | 34 return wrapUnique(new ObjectPaintProperties()); |
| 37 } | 35 } |
| 38 | 36 |
| 39 // The hierarchy of the transform subtree created by a LayoutObject is as fo llows: | 37 // The hierarchy of the transform subtree created by a LayoutObject is as fo llows: |
| 40 // [ paintOffsetTranslation ] Normally paint offset is accumulated without creating a node | 38 // [ paintOffsetTranslation ] Normally paint offset is accumulated without creating a node |
| 41 // | until we see, for example, transform or position:fixed. | 39 // | until we see, for example, transform or position:fixed. |
| 42 // +---[ transform ] The space created by CSS transform. | 40 // +---[ transform ] The space created by CSS transform. |
| 43 // | This is the local border box space, see: LocalBorderBoxProperties below. | 41 // | This is the local border box space, see: LocalBorderBoxProperties below. |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 65 | 63 |
| 66 // The hierarchy of the clip subtree created by a LayoutObject is as follows : | 64 // The hierarchy of the clip subtree created by a LayoutObject is as follows : |
| 67 // [ css clip ] | 65 // [ css clip ] |
| 68 // [ css clip fixed position] | 66 // [ css clip fixed position] |
| 69 // | | 67 // | |
| 70 // +--- [ overflow clip ] | 68 // +--- [ overflow clip ] |
| 71 const ClipPaintPropertyNode* cssClip() const { return m_cssClip.get(); } | 69 const ClipPaintPropertyNode* cssClip() const { return m_cssClip.get(); } |
| 72 const ClipPaintPropertyNode* cssClipFixedPosition() const { return m_cssClip FixedPosition.get(); } | 70 const ClipPaintPropertyNode* cssClipFixedPosition() const { return m_cssClip FixedPosition.get(); } |
| 73 const ClipPaintPropertyNode* overflowClip() const { return m_overflowClip.ge t(); } | 71 const ClipPaintPropertyNode* overflowClip() const { return m_overflowClip.ge t(); } |
| 74 | 72 |
| 75 // This is a complete set of property nodes that should be used as a startin g point to paint | |
| 76 // this layout object. It is needed becauase some property inherits from the containing block, | |
| 77 // not painting parent, thus can't be derived in O(1) during paint walk. | |
| 78 // Note: If this layout object has transform or stacking-context effects, th ose are already | |
| 79 // baked into in the context here. However for properties that affects only children, | |
| 80 // for example, perspective and overflow clip, those should be applied by th e painter | |
| 81 // at the right painting step. | |
| 82 struct LocalBorderBoxProperties { | |
| 83 LayoutPoint paintOffset; | |
| 84 GeometryPropertyTreeState geometryPropertyTreeState; | |
| 85 const ScrollPaintPropertyNode* scroll; | |
| 86 }; | |
| 87 const LocalBorderBoxProperties* localBorderBoxProperties() const { return m_ localBorderBoxProperties.get(); } | |
| 88 // ContentsProperties is the GeometryPropertyTreeState that is the same as i n | |
| 89 // localBorderBoxProperties, except that it is inside any clips and scrolls caused by this | |
| 90 // object. This GeometryPropertyTreeState is suitable as the destination for paint invalidation. | |
| 91 void getContentsProperties(GeometryPropertyTreeState&) const; | |
| 92 | |
| 93 void clearPaintOffsetTranslation() { m_paintOffsetTranslation = nullptr; } | 73 void clearPaintOffsetTranslation() { m_paintOffsetTranslation = nullptr; } |
| 94 void clearTransform() { m_transform = nullptr; } | 74 void clearTransform() { m_transform = nullptr; } |
| 95 void clearEffect() { m_effect = nullptr; } | 75 void clearEffect() { m_effect = nullptr; } |
| 96 void clearCssClip() { m_cssClip = nullptr; } | 76 void clearCssClip() { m_cssClip = nullptr; } |
| 97 void clearCssClipFixedPosition() { m_cssClipFixedPosition = nullptr; } | 77 void clearCssClipFixedPosition() { m_cssClipFixedPosition = nullptr; } |
| 98 void clearOverflowClip() { m_overflowClip = nullptr; } | 78 void clearOverflowClip() { m_overflowClip = nullptr; } |
| 99 void clearPerspective() { m_perspective = nullptr; } | 79 void clearPerspective() { m_perspective = nullptr; } |
| 100 void clearSvgLocalToBorderBoxTransform() { m_svgLocalToBorderBoxTransform = nullptr; } | 80 void clearSvgLocalToBorderBoxTransform() { m_svgLocalToBorderBoxTransform = nullptr; } |
| 101 void clearScrollTranslation() { m_scrollTranslation = nullptr; } | 81 void clearScrollTranslation() { m_scrollTranslation = nullptr; } |
| 102 void clearScrollbarPaintOffset() { m_scrollbarPaintOffset = nullptr; } | 82 void clearScrollbarPaintOffset() { m_scrollbarPaintOffset = nullptr; } |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 115 DCHECK(!svgLocalToBorderBoxTransform()) << "SVG elements cannot scroll s o there should never be both a scroll translation and an SVG local to border box transform."; | 95 DCHECK(!svgLocalToBorderBoxTransform()) << "SVG elements cannot scroll s o there should never be both a scroll translation and an SVG local to border box transform."; |
| 116 return createOrUpdateProperty(m_scrollTranslation, std::forward<Args>(ar gs)...); | 96 return createOrUpdateProperty(m_scrollTranslation, std::forward<Args>(ar gs)...); |
| 117 } | 97 } |
| 118 template <typename... Args> TransformPaintPropertyNode* createOrUpdateScroll barPaintOffset(Args&&... args) { return createOrUpdateProperty(m_scrollbarPaintO ffset, std::forward<Args>(args)...); } | 98 template <typename... Args> TransformPaintPropertyNode* createOrUpdateScroll barPaintOffset(Args&&... args) { return createOrUpdateProperty(m_scrollbarPaintO ffset, std::forward<Args>(args)...); } |
| 119 template <typename... Args> ScrollPaintPropertyNode* createOrUpdateScroll(Ar gs&&... args) { return createOrUpdateProperty(m_scroll, std::forward<Args>(args) ...); } | 99 template <typename... Args> ScrollPaintPropertyNode* createOrUpdateScroll(Ar gs&&... args) { return createOrUpdateProperty(m_scroll, std::forward<Args>(args) ...); } |
| 120 template <typename... Args> EffectPaintPropertyNode* createOrUpdateEffect(Ar gs&&... args) { return createOrUpdateProperty(m_effect, std::forward<Args>(args) ...); } | 100 template <typename... Args> EffectPaintPropertyNode* createOrUpdateEffect(Ar gs&&... args) { return createOrUpdateProperty(m_effect, std::forward<Args>(args) ...); } |
| 121 template <typename... Args> ClipPaintPropertyNode* createOrUpdateCssClip(Arg s&&... args) { return createOrUpdateProperty(m_cssClip, std::forward<Args>(args) ...); } | 101 template <typename... Args> ClipPaintPropertyNode* createOrUpdateCssClip(Arg s&&... args) { return createOrUpdateProperty(m_cssClip, std::forward<Args>(args) ...); } |
| 122 template <typename... Args> ClipPaintPropertyNode* createOrUpdateCssClipFixe dPosition(Args&&... args) { return createOrUpdateProperty(m_cssClipFixedPosition , std::forward<Args>(args)...); } | 102 template <typename... Args> ClipPaintPropertyNode* createOrUpdateCssClipFixe dPosition(Args&&... args) { return createOrUpdateProperty(m_cssClipFixedPosition , std::forward<Args>(args)...); } |
| 123 template <typename... Args> ClipPaintPropertyNode* createOrUpdateOverflowCli p(Args&&... args) { return createOrUpdateProperty(m_overflowClip, std::forward<A rgs>(args)...); } | 103 template <typename... Args> ClipPaintPropertyNode* createOrUpdateOverflowCli p(Args&&... args) { return createOrUpdateProperty(m_overflowClip, std::forward<A rgs>(args)...); } |
| 124 | 104 |
| 105 // This is a complete set of property nodes that should be used as a startin g point to paint | |
| 106 // this layout object. It is needed becauase some property inherits from the containing block, | |
|
jbroman
2016/09/21 15:23:17
nit: s/becauase/because/
| |
| 107 // not painting parent, thus can't be derived in O(1) during paint walk. | |
| 108 // Note: If this layout object has transform or stacking-context effects, th ose are already | |
| 109 // baked into in the context here. However for properties that affects only children, | |
| 110 // for example, perspective and overflow clip, those should be applied by th e painter | |
| 111 // at the right painting step. | |
| 112 struct LocalBorderBoxProperties { | |
| 113 LayoutPoint paintOffset; | |
| 114 const TransformPaintPropertyNode* transform; | |
| 115 const ClipPaintPropertyNode* clip; | |
| 116 const EffectPaintPropertyNode* effect; | |
| 117 const ScrollPaintPropertyNode* scroll; | |
| 118 }; | |
| 119 | |
| 125 void setLocalBorderBoxProperties(std::unique_ptr<LocalBorderBoxProperties> p roperties) { m_localBorderBoxProperties = std::move(properties); } | 120 void setLocalBorderBoxProperties(std::unique_ptr<LocalBorderBoxProperties> p roperties) { m_localBorderBoxProperties = std::move(properties); } |
| 121 const LocalBorderBoxProperties* localBorderBoxProperties() const { return m_ localBorderBoxProperties.get(); } | |
| 122 | |
| 123 // ContentsProperties returns the same property tree state in localBorderBox Properties | |
| 124 // but modified to be inside any clips and scrolls caused by this object. Th is | |
| 125 // GeometryPropertyTreeState is suitable as the destination for paint invali dation. | |
| 126 GeometryPropertyTreeState getContentsProperties() const; | |
| 126 | 127 |
| 127 private: | 128 private: |
| 128 ObjectPaintProperties() { } | 129 ObjectPaintProperties() { } |
| 129 | 130 |
| 130 template <typename PaintPropertyNode, typename... Args> | 131 template <typename PaintPropertyNode, typename... Args> |
| 131 PaintPropertyNode* createOrUpdateProperty(RefPtr<PaintPropertyNode>& field, Args&&... args) | 132 PaintPropertyNode* createOrUpdateProperty(RefPtr<PaintPropertyNode>& field, Args&&... args) |
| 132 { | 133 { |
| 133 if (field) | 134 if (field) |
| 134 field->update(std::forward<Args>(args)...); | 135 field->update(std::forward<Args>(args)...); |
| 135 else | 136 else |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 149 RefPtr<TransformPaintPropertyNode> m_scrollTranslation; | 150 RefPtr<TransformPaintPropertyNode> m_scrollTranslation; |
| 150 RefPtr<TransformPaintPropertyNode> m_scrollbarPaintOffset; | 151 RefPtr<TransformPaintPropertyNode> m_scrollbarPaintOffset; |
| 151 RefPtr<ScrollPaintPropertyNode> m_scroll; | 152 RefPtr<ScrollPaintPropertyNode> m_scroll; |
| 152 | 153 |
| 153 std::unique_ptr<LocalBorderBoxProperties> m_localBorderBoxProperties; | 154 std::unique_ptr<LocalBorderBoxProperties> m_localBorderBoxProperties; |
| 154 }; | 155 }; |
| 155 | 156 |
| 156 } // namespace blink | 157 } // namespace blink |
| 157 | 158 |
| 158 #endif // ObjectPaintProperties_h | 159 #endif // ObjectPaintProperties_h |
| OLD | NEW |