| 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" |
| 11 #include "platform/graphics/paint/EffectPaintPropertyNode.h" | 11 #include "platform/graphics/paint/EffectPaintPropertyNode.h" |
| 12 #include "platform/graphics/paint/PaintChunkProperties.h" | 12 #include "platform/graphics/paint/PaintChunkProperties.h" |
| 13 #include "platform/graphics/paint/PropertyTreeState.h" | 13 #include "platform/graphics/paint/PropertyTreeState.h" |
| 14 #include "platform/graphics/paint/ScrollPaintPropertyNode.h" |
| 14 #include "platform/graphics/paint/TransformPaintPropertyNode.h" | 15 #include "platform/graphics/paint/TransformPaintPropertyNode.h" |
| 15 #include "wtf/PassRefPtr.h" | 16 #include "wtf/PassRefPtr.h" |
| 16 #include "wtf/PtrUtil.h" | 17 #include "wtf/PtrUtil.h" |
| 17 #include "wtf/RefPtr.h" | 18 #include "wtf/RefPtr.h" |
| 18 #include <memory> | 19 #include <memory> |
| 19 | 20 |
| 20 namespace blink { | 21 namespace blink { |
| 21 | 22 |
| 22 // 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. |
| 23 // Currently there are two groups of information: | 24 // Currently there are two groups of information: |
| (...skipping 24 matching lines...) Expand all Loading... |
| 48 // This is equivalent to the local bord
er box space above, | 49 // This is equivalent to the local bord
er box space above, |
| 49 // with pixel snapped paint offset bake
d in. It is really redundant, | 50 // with pixel snapped paint offset bake
d in. It is really redundant, |
| 50 // but it is a pain to teach scrollbars
to paint with an offset. | 51 // but it is a pain to teach scrollbars
to paint with an offset. |
| 51 const TransformPaintPropertyNode* paintOffsetTranslation() const { return m_
paintOffsetTranslation.get(); } | 52 const TransformPaintPropertyNode* paintOffsetTranslation() const { return m_
paintOffsetTranslation.get(); } |
| 52 const TransformPaintPropertyNode* transform() const { return m_transform.get
(); } | 53 const TransformPaintPropertyNode* transform() const { return m_transform.get
(); } |
| 53 const TransformPaintPropertyNode* perspective() const { return m_perspective
.get(); } | 54 const TransformPaintPropertyNode* perspective() const { return m_perspective
.get(); } |
| 54 const TransformPaintPropertyNode* svgLocalToBorderBoxTransform() const { ret
urn m_svgLocalToBorderBoxTransform.get(); } | 55 const TransformPaintPropertyNode* svgLocalToBorderBoxTransform() const { ret
urn m_svgLocalToBorderBoxTransform.get(); } |
| 55 const TransformPaintPropertyNode* scrollTranslation() const { return m_scrol
lTranslation.get(); } | 56 const TransformPaintPropertyNode* scrollTranslation() const { return m_scrol
lTranslation.get(); } |
| 56 const TransformPaintPropertyNode* scrollbarPaintOffset() const { return m_sc
rollbarPaintOffset.get(); } | 57 const TransformPaintPropertyNode* scrollbarPaintOffset() const { return m_sc
rollbarPaintOffset.get(); } |
| 57 | 58 |
| 59 // Auxiliary scrolling information. Includes information such as the hierarc
hy of scrollable |
| 60 // areas, the extent that can be scrolled, etc. The actual scroll offset is
stored in the |
| 61 // transform tree (m_scrollTranslation). |
| 62 const ScrollPaintPropertyNode* scroll() const { return m_scroll.get(); } |
| 63 |
| 58 const EffectPaintPropertyNode* effect() const { return m_effect.get(); } | 64 const EffectPaintPropertyNode* effect() const { return m_effect.get(); } |
| 59 | 65 |
| 60 // The hierarchy of the clip subtree created by a LayoutObject is as follows
: | 66 // The hierarchy of the clip subtree created by a LayoutObject is as follows
: |
| 61 // [ css clip ] | 67 // [ css clip ] |
| 62 // [ css clip fixed position] | 68 // [ css clip fixed position] |
| 63 // | | 69 // | |
| 64 // +--- [ overflow clip ] | 70 // +--- [ overflow clip ] |
| 65 const ClipPaintPropertyNode* cssClip() const { return m_cssClip.get(); } | 71 const ClipPaintPropertyNode* cssClip() const { return m_cssClip.get(); } |
| 66 const ClipPaintPropertyNode* cssClipFixedPosition() const { return m_cssClip
FixedPosition.get(); } | 72 const ClipPaintPropertyNode* cssClipFixedPosition() const { return m_cssClip
FixedPosition.get(); } |
| 67 const ClipPaintPropertyNode* overflowClip() const { return m_overflowClip.ge
t(); } | 73 const ClipPaintPropertyNode* overflowClip() const { return m_overflowClip.ge
t(); } |
| 68 | 74 |
| 69 // This is a complete set of property nodes that should be used as a startin
g point to paint | 75 // This is a complete set of property nodes that should be used as a startin
g point to paint |
| 70 // this layout object. It is needed becauase some property inherits from the
containing block, | 76 // this layout object. It is needed becauase some property inherits from the
containing block, |
| 71 // not painting parent, thus can't be derived in O(1) during paint walk. | 77 // not painting parent, thus can't be derived in O(1) during paint walk. |
| 72 // Note: If this layout object has transform or stacking-context effects, th
ose are already | 78 // Note: If this layout object has transform or stacking-context effects, th
ose are already |
| 73 // baked into in the context here. However for properties that affects only
children, | 79 // baked into in the context here. However for properties that affects only
children, |
| 74 // for example, perspective and overflow clip, those should be applied by th
e painter | 80 // for example, perspective and overflow clip, those should be applied by th
e painter |
| 75 // at the right painting step. | 81 // at the right painting step. |
| 76 struct LocalBorderBoxProperties { | 82 struct LocalBorderBoxProperties { |
| 77 LayoutPoint paintOffset; | 83 LayoutPoint paintOffset; |
| 84 // TODO(pdr): Rename this GeometryPropertyTreeState because it does not
contain scroll. |
| 78 PropertyTreeState propertyTreeState; | 85 PropertyTreeState propertyTreeState; |
| 86 const ScrollPaintPropertyNode* scroll; |
| 79 }; | 87 }; |
| 80 const LocalBorderBoxProperties* localBorderBoxProperties() const { return m_
localBorderBoxProperties.get(); } | 88 const LocalBorderBoxProperties* localBorderBoxProperties() const { return m_
localBorderBoxProperties.get(); } |
| 81 // ContentsProperties is the PropertyTreeState state that is the same as in
localBorderBoxProperties, except that it is inside | 89 // ContentsProperties is the PropertyTreeState state that is the same as in
localBorderBoxProperties, except that it is inside |
| 82 // any clips and scrolls caused by this object. This PropertyTreeState is su
itable as the destination for paint invalidation. | 90 // any clips and scrolls caused by this object. This PropertyTreeState is su
itable as the destination for paint invalidation. |
| 83 void getContentsProperties(PropertyTreeState&) const; | 91 void getContentsProperties(PropertyTreeState&) const; |
| 84 | 92 |
| 85 void clearPaintOffsetTranslation() { m_paintOffsetTranslation = nullptr; } | 93 void clearPaintOffsetTranslation() { m_paintOffsetTranslation = nullptr; } |
| 86 void clearTransform() { m_transform = nullptr; } | 94 void clearTransform() { m_transform = nullptr; } |
| 87 void clearEffect() { m_effect = nullptr; } | 95 void clearEffect() { m_effect = nullptr; } |
| 88 void clearCssClip() { m_cssClip = nullptr; } | 96 void clearCssClip() { m_cssClip = nullptr; } |
| 89 void clearCssClipFixedPosition() { m_cssClipFixedPosition = nullptr; } | 97 void clearCssClipFixedPosition() { m_cssClipFixedPosition = nullptr; } |
| 90 void clearOverflowClip() { m_overflowClip = nullptr; } | 98 void clearOverflowClip() { m_overflowClip = nullptr; } |
| 91 void clearPerspective() { m_perspective = nullptr; } | 99 void clearPerspective() { m_perspective = nullptr; } |
| 92 void clearSvgLocalToBorderBoxTransform() { m_svgLocalToBorderBoxTransform =
nullptr; } | 100 void clearSvgLocalToBorderBoxTransform() { m_svgLocalToBorderBoxTransform =
nullptr; } |
| 93 void clearScrollTranslation() { m_scrollTranslation = nullptr; } | 101 void clearScrollTranslation() { m_scrollTranslation = nullptr; } |
| 94 void clearScrollbarPaintOffset() { m_scrollbarPaintOffset = nullptr; } | 102 void clearScrollbarPaintOffset() { m_scrollbarPaintOffset = nullptr; } |
| 103 void clearScroll() { m_scroll = nullptr; } |
| 95 | 104 |
| 96 template <typename... Args> TransformPaintPropertyNode* createOrUpdatePaintO
ffsetTranslation(Args&&... args) { return createOrUpdateProperty(m_paintOffsetTr
anslation, std::forward<Args>(args)...); } | 105 template <typename... Args> TransformPaintPropertyNode* createOrUpdatePaintO
ffsetTranslation(Args&&... args) { return createOrUpdateProperty(m_paintOffsetTr
anslation, std::forward<Args>(args)...); } |
| 97 template <typename... Args> TransformPaintPropertyNode* createOrUpdateTransf
orm(Args&&... args) { return createOrUpdateProperty(m_transform, std::forward<Ar
gs>(args)...); } | 106 template <typename... Args> TransformPaintPropertyNode* createOrUpdateTransf
orm(Args&&... args) { return createOrUpdateProperty(m_transform, std::forward<Ar
gs>(args)...); } |
| 98 template <typename... Args> TransformPaintPropertyNode* createOrUpdatePerspe
ctive(Args&&... args) { return createOrUpdateProperty(m_perspective, std::forwar
d<Args>(args)...); } | 107 template <typename... Args> TransformPaintPropertyNode* createOrUpdatePerspe
ctive(Args&&... args) { return createOrUpdateProperty(m_perspective, std::forwar
d<Args>(args)...); } |
| 99 template <typename... Args> TransformPaintPropertyNode* createOrUpdateSvgLoc
alToBorderBoxTransform(Args&&... args) | 108 template <typename... Args> TransformPaintPropertyNode* createOrUpdateSvgLoc
alToBorderBoxTransform(Args&&... args) |
| 100 { | 109 { |
| 101 DCHECK(!scrollTranslation()) << "SVG elements cannot scroll so there sho
uld never be both a scroll translation and an SVG local to border box transform.
"; | 110 DCHECK(!scrollTranslation()) << "SVG elements cannot scroll so there sho
uld never be both a scroll translation and an SVG local to border box transform.
"; |
| 102 return createOrUpdateProperty(m_svgLocalToBorderBoxTransform, std::forwa
rd<Args>(args)...); | 111 return createOrUpdateProperty(m_svgLocalToBorderBoxTransform, std::forwa
rd<Args>(args)...); |
| 103 } | 112 } |
| 104 template <typename... Args> TransformPaintPropertyNode* createOrUpdateScroll
Translation(Args&&... args) | 113 template <typename... Args> TransformPaintPropertyNode* createOrUpdateScroll
Translation(Args&&... args) |
| 105 { | 114 { |
| 106 DCHECK(!svgLocalToBorderBoxTransform()) << "SVG elements cannot scroll s
o there should never be both a scroll translation and an SVG local to border box
transform."; | 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."; |
| 107 return createOrUpdateProperty(m_scrollTranslation, std::forward<Args>(ar
gs)...); | 116 return createOrUpdateProperty(m_scrollTranslation, std::forward<Args>(ar
gs)...); |
| 108 } | 117 } |
| 109 template <typename... Args> TransformPaintPropertyNode* createOrUpdateScroll
barPaintOffset(Args&&... args) { return createOrUpdateProperty(m_scrollbarPaintO
ffset, std::forward<Args>(args)...); } | 118 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)
...); } |
| 110 template <typename... Args> EffectPaintPropertyNode* createOrUpdateEffect(Ar
gs&&... args) { return createOrUpdateProperty(m_effect, std::forward<Args>(args)
...); } | 120 template <typename... Args> EffectPaintPropertyNode* createOrUpdateEffect(Ar
gs&&... args) { return createOrUpdateProperty(m_effect, std::forward<Args>(args)
...); } |
| 111 template <typename... Args> ClipPaintPropertyNode* createOrUpdateCssClip(Arg
s&&... args) { return createOrUpdateProperty(m_cssClip, std::forward<Args>(args)
...); } | 121 template <typename... Args> ClipPaintPropertyNode* createOrUpdateCssClip(Arg
s&&... args) { return createOrUpdateProperty(m_cssClip, std::forward<Args>(args)
...); } |
| 112 template <typename... Args> ClipPaintPropertyNode* createOrUpdateCssClipFixe
dPosition(Args&&... args) { return createOrUpdateProperty(m_cssClipFixedPosition
, std::forward<Args>(args)...); } | 122 template <typename... Args> ClipPaintPropertyNode* createOrUpdateCssClipFixe
dPosition(Args&&... args) { return createOrUpdateProperty(m_cssClipFixedPosition
, std::forward<Args>(args)...); } |
| 113 template <typename... Args> ClipPaintPropertyNode* createOrUpdateOverflowCli
p(Args&&... args) { return createOrUpdateProperty(m_overflowClip, std::forward<A
rgs>(args)...); } | 123 template <typename... Args> ClipPaintPropertyNode* createOrUpdateOverflowCli
p(Args&&... args) { return createOrUpdateProperty(m_overflowClip, std::forward<A
rgs>(args)...); } |
| 114 | 124 |
| 115 void setLocalBorderBoxProperties(std::unique_ptr<LocalBorderBoxProperties> p
roperties) { m_localBorderBoxProperties = std::move(properties); } | 125 void setLocalBorderBoxProperties(std::unique_ptr<LocalBorderBoxProperties> p
roperties) { m_localBorderBoxProperties = std::move(properties); } |
| 116 | 126 |
| 117 private: | 127 private: |
| 118 ObjectPaintProperties() { } | 128 ObjectPaintProperties() { } |
| 119 | 129 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 131 RefPtr<TransformPaintPropertyNode> m_transform; | 141 RefPtr<TransformPaintPropertyNode> m_transform; |
| 132 RefPtr<EffectPaintPropertyNode> m_effect; | 142 RefPtr<EffectPaintPropertyNode> m_effect; |
| 133 RefPtr<ClipPaintPropertyNode> m_cssClip; | 143 RefPtr<ClipPaintPropertyNode> m_cssClip; |
| 134 RefPtr<ClipPaintPropertyNode> m_cssClipFixedPosition; | 144 RefPtr<ClipPaintPropertyNode> m_cssClipFixedPosition; |
| 135 RefPtr<ClipPaintPropertyNode> m_overflowClip; | 145 RefPtr<ClipPaintPropertyNode> m_overflowClip; |
| 136 RefPtr<TransformPaintPropertyNode> m_perspective; | 146 RefPtr<TransformPaintPropertyNode> m_perspective; |
| 137 // TODO(pdr): Only LayoutSVGRoot needs this and it should be moved there. | 147 // TODO(pdr): Only LayoutSVGRoot needs this and it should be moved there. |
| 138 RefPtr<TransformPaintPropertyNode> m_svgLocalToBorderBoxTransform; | 148 RefPtr<TransformPaintPropertyNode> m_svgLocalToBorderBoxTransform; |
| 139 RefPtr<TransformPaintPropertyNode> m_scrollTranslation; | 149 RefPtr<TransformPaintPropertyNode> m_scrollTranslation; |
| 140 RefPtr<TransformPaintPropertyNode> m_scrollbarPaintOffset; | 150 RefPtr<TransformPaintPropertyNode> m_scrollbarPaintOffset; |
| 151 RefPtr<ScrollPaintPropertyNode> m_scroll; |
| 141 | 152 |
| 142 std::unique_ptr<LocalBorderBoxProperties> m_localBorderBoxProperties; | 153 std::unique_ptr<LocalBorderBoxProperties> m_localBorderBoxProperties; |
| 143 }; | 154 }; |
| 144 | 155 |
| 145 } // namespace blink | 156 } // namespace blink |
| 146 | 157 |
| 147 #endif // ObjectPaintProperties_h | 158 #endif // ObjectPaintProperties_h |
| OLD | NEW |