| 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/ScrollPaintPropertyNode.h" |
| 15 #include "platform/graphics/paint/TransformPaintPropertyNode.h" | 15 #include "platform/graphics/paint/TransformPaintPropertyNode.h" |
| 16 #include "wtf/PassRefPtr.h" | 16 #include "wtf/PassRefPtr.h" |
| 17 #include "wtf/PtrUtil.h" | 17 #include "wtf/PtrUtil.h" |
| 18 #include "wtf/RefPtr.h" | 18 #include "wtf/RefPtr.h" |
| 19 #include <memory> | 19 #include <memory> |
| 20 | 20 |
| 21 namespace blink { | 21 namespace blink { |
| 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 |
| 24 // LayoutObject. |
| 24 // Currently there are two groups of information: | 25 // Currently there are two groups of information: |
| 25 // 1. The set of property nodes created locally by this LayoutObject. | 26 // 1. The set of property nodes created locally by this LayoutObject. |
| 26 // 2. The set of property nodes (inherited, or created locally) and paint offset
that can be used | 27 // 2. The set of property nodes (inherited, or created locally) and paint offset |
| 27 // to paint the border box of this LayoutObject (see: localBorderBoxPropertie
s). | 28 // that can be used to paint the border box of this LayoutObject (see: |
| 29 // localBorderBoxProperties). |
| 28 class CORE_EXPORT ObjectPaintProperties { | 30 class CORE_EXPORT ObjectPaintProperties { |
| 29 WTF_MAKE_NONCOPYABLE(ObjectPaintProperties); | 31 WTF_MAKE_NONCOPYABLE(ObjectPaintProperties); |
| 30 USING_FAST_MALLOC(ObjectPaintProperties); | 32 USING_FAST_MALLOC(ObjectPaintProperties); |
| 31 | 33 |
| 32 public: | 34 public: |
| 33 static std::unique_ptr<ObjectPaintProperties> create() { | 35 static std::unique_ptr<ObjectPaintProperties> create() { |
| 34 return wrapUnique(new ObjectPaintProperties()); | 36 return wrapUnique(new ObjectPaintProperties()); |
| 35 } | 37 } |
| 36 | 38 |
| 37 // The hierarchy of the transform subtree created by a LayoutObject is as foll
ows: | 39 // The hierarchy of the transform subtree created by a LayoutObject is as |
| 38 // [ paintOffsetTranslation ] Normally paint offset is accumulated w
ithout creating a node | 40 // follows: |
| 39 // | until we see, for example, transform o
r position:fixed. | 41 // [ paintOffsetTranslation ] Normally paint offset is accumulated |
| 42 // | without creating a node until we see, |
| 43 // | for example, transform or |
| 44 // | position:fixed. |
| 40 // +---[ transform ] The space created by CSS transform. | 45 // +---[ transform ] The space created by CSS transform. |
| 41 // | This is the local border box space, se
e: localBorderBoxProperties below. | 46 // | This is the local border box space, |
| 47 // | see: localBorderBoxProperties below. |
| 42 // +---[ perspective ] The space created by CSS perspective. | 48 // +---[ perspective ] The space created by CSS perspective. |
| 43 // | +---[ svgLocalToBorderBoxTransform ] Additional transform for child
ren of the outermost root SVG. | 49 // | +---[ svgLocalToBorderBoxTransform ] Additional transform for |
| 50 // children of the outermost root SVG. |
| 44 // | OR (SVG does not support scrolling.) | 51 // | OR (SVG does not support scrolling.) |
| 45 // | +---[ scrollTranslation ] The space created by overflow clip. | 52 // | +---[ scrollTranslation ] The space created by overflow clip. |
| 46 // +---[ scrollbarPaintOffset ] TODO(trchen): Remove this once we bake
the paint offset into frameRect. | 53 // +---[ scrollbarPaintOffset ] TODO(trchen): Remove this once we bake |
| 47 // This is equivalent to the local border
box space above, | 54 // the paint offset into frameRect. This |
| 48 // with pixel snapped paint offset baked
in. It is really redundant, | 55 // is equivalent to the local border box |
| 49 // but it is a pain to teach scrollbars t
o paint with an offset. | 56 // space above, with pixel snapped paint |
| 57 // offset baked in. It is really |
| 58 // redundant, but it is a pain to teach |
| 59 // scrollbars to paint with an offset. |
| 50 const TransformPaintPropertyNode* paintOffsetTranslation() const { | 60 const TransformPaintPropertyNode* paintOffsetTranslation() const { |
| 51 return m_paintOffsetTranslation.get(); | 61 return m_paintOffsetTranslation.get(); |
| 52 } | 62 } |
| 53 const TransformPaintPropertyNode* transform() const { | 63 const TransformPaintPropertyNode* transform() const { |
| 54 return m_transform.get(); | 64 return m_transform.get(); |
| 55 } | 65 } |
| 56 const TransformPaintPropertyNode* perspective() const { | 66 const TransformPaintPropertyNode* perspective() const { |
| 57 return m_perspective.get(); | 67 return m_perspective.get(); |
| 58 } | 68 } |
| 59 const TransformPaintPropertyNode* svgLocalToBorderBoxTransform() const { | 69 const TransformPaintPropertyNode* svgLocalToBorderBoxTransform() const { |
| 60 return m_svgLocalToBorderBoxTransform.get(); | 70 return m_svgLocalToBorderBoxTransform.get(); |
| 61 } | 71 } |
| 62 const TransformPaintPropertyNode* scrollTranslation() const { | 72 const TransformPaintPropertyNode* scrollTranslation() const { |
| 63 return m_scrollTranslation.get(); | 73 return m_scrollTranslation.get(); |
| 64 } | 74 } |
| 65 const TransformPaintPropertyNode* scrollbarPaintOffset() const { | 75 const TransformPaintPropertyNode* scrollbarPaintOffset() const { |
| 66 return m_scrollbarPaintOffset.get(); | 76 return m_scrollbarPaintOffset.get(); |
| 67 } | 77 } |
| 68 | 78 |
| 69 // Auxiliary scrolling information. Includes information such as the hierarchy
of scrollable | 79 // Auxiliary scrolling information. Includes information such as the hierarchy |
| 70 // areas, the extent that can be scrolled, etc. The actual scroll offset is st
ored in the | 80 // of scrollable areas, the extent that can be scrolled, etc. The actual |
| 71 // transform tree (m_scrollTranslation). | 81 // scroll offset is stored in the transform tree (m_scrollTranslation). |
| 72 const ScrollPaintPropertyNode* scroll() const { return m_scroll.get(); } | 82 const ScrollPaintPropertyNode* scroll() const { return m_scroll.get(); } |
| 73 | 83 |
| 74 const EffectPaintPropertyNode* effect() const { return m_effect.get(); } | 84 const EffectPaintPropertyNode* effect() const { return m_effect.get(); } |
| 75 | 85 |
| 76 // The hierarchy of the clip subtree created by a LayoutObject is as follows: | 86 // The hierarchy of the clip subtree created by a LayoutObject is as follows: |
| 77 // [ css clip ] | 87 // [ css clip ] |
| 78 // [ css clip fixed position] | 88 // [ css clip fixed position] |
| 79 // [ inner border radius clip ] Clip created by a rounded border with overflow
clip. This clip | 89 // [ inner border radius clip ] Clip created by a rounded border with overflow |
| 80 // is not inset by scrollbars. | 90 // clip. This clip is not inset by scrollbars. |
| 81 // +--- [ overflow clip ] Clip created by overflow clip and is inset by
the scrollbars. | 91 // +--- [ overflow clip ] Clip created by overflow clip and is inset by |
| 92 // the scrollbars. |
| 82 const ClipPaintPropertyNode* cssClip() const { return m_cssClip.get(); } | 93 const ClipPaintPropertyNode* cssClip() const { return m_cssClip.get(); } |
| 83 const ClipPaintPropertyNode* cssClipFixedPosition() const { | 94 const ClipPaintPropertyNode* cssClipFixedPosition() const { |
| 84 return m_cssClipFixedPosition.get(); | 95 return m_cssClipFixedPosition.get(); |
| 85 } | 96 } |
| 86 const ClipPaintPropertyNode* innerBorderRadiusClip() const { | 97 const ClipPaintPropertyNode* innerBorderRadiusClip() const { |
| 87 return m_innerBorderRadiusClip.get(); | 98 return m_innerBorderRadiusClip.get(); |
| 88 } | 99 } |
| 89 const ClipPaintPropertyNode* overflowClip() const { | 100 const ClipPaintPropertyNode* overflowClip() const { |
| 90 return m_overflowClip.get(); | 101 return m_overflowClip.get(); |
| 91 } | 102 } |
| 92 | 103 |
| 93 // The complete set of property tree nodes (inherited, or created locally) and
paint offset that | 104 // The complete set of property tree nodes (inherited, or created locally) and |
| 94 // can be used to paint. |paintOffset| is relative to the propertyTreeState's
transform space. | 105 // paint offset that can be used to paint. |paintOffset| is relative to the |
| 106 // propertyTreeState's transform space. |
| 95 // See: localBorderBoxProperties and contentsProperties. | 107 // See: localBorderBoxProperties and contentsProperties. |
| 96 struct PropertyTreeStateWithOffset { | 108 struct PropertyTreeStateWithOffset { |
| 97 PropertyTreeStateWithOffset(LayoutPoint offset, PropertyTreeState treeState) | 109 PropertyTreeStateWithOffset(LayoutPoint offset, PropertyTreeState treeState) |
| 98 : paintOffset(offset), propertyTreeState(treeState) {} | 110 : paintOffset(offset), propertyTreeState(treeState) {} |
| 99 LayoutPoint paintOffset; | 111 LayoutPoint paintOffset; |
| 100 PropertyTreeState propertyTreeState; | 112 PropertyTreeState propertyTreeState; |
| 101 }; | 113 }; |
| 102 | 114 |
| 103 // This is a complete set of property nodes and paint offset that should be us
ed as a starting | 115 // This is a complete set of property nodes and paint offset that should be |
| 104 // point to paint this layout object. This is cached because some properties i
nherit from the | 116 // used as a starting point to paint this layout object. This is cached |
| 105 // containing block chain instead of the painting parent and cannot be derived
in O(1) during | 117 // because some properties inherit from the containing block chain instead of |
| 106 // the paint walk. | 118 // the painting parent and cannot be derived in O(1) during the paint walk. |
| 107 // For example, <div style='opacity: 0.3; position: relative; margin: 11px;'/>
would have a | 119 // For example, <div style='opacity: 0.3; position: relative; margin: 11px;'/> |
| 108 // paint offset of (11px, 11px) and propertyTreeState.effect() would be an eff
ect node with | 120 // would have a paint offset of (11px, 11px) and propertyTreeState.effect() |
| 109 // opacity of 0.3 which was created by the div itself. Note that propertyTreeS
tate.transform() | 121 // would be an effect node with opacity of 0.3 which was created by the div |
| 110 // would not be null but would instead point to the transform space setup by d
iv's ancestors. | 122 // itself. Note that propertyTreeState.transform() would not be null but would |
| 123 // instead point to the transform space setup by div's ancestors. |
| 111 const PropertyTreeStateWithOffset* localBorderBoxProperties() const { | 124 const PropertyTreeStateWithOffset* localBorderBoxProperties() const { |
| 112 return m_localBorderBoxProperties.get(); | 125 return m_localBorderBoxProperties.get(); |
| 113 } | 126 } |
| 114 void setLocalBorderBoxProperties( | 127 void setLocalBorderBoxProperties( |
| 115 std::unique_ptr<PropertyTreeStateWithOffset> properties) { | 128 std::unique_ptr<PropertyTreeStateWithOffset> properties) { |
| 116 m_localBorderBoxProperties = std::move(properties); | 129 m_localBorderBoxProperties = std::move(properties); |
| 117 } | 130 } |
| 118 | 131 |
| 119 // This is the complete set of property nodes and paint offset that can be use
d to paint the | 132 // This is the complete set of property nodes and paint offset that can be |
| 120 // contents of this object. It is similar to localBorderBoxProperties but incl
udes properties | 133 // used to paint the contents of this object. It is similar to |
| 121 // (e.g., overflow clip, scroll translation) that apply to contents. This is s
uitable for paint | 134 // localBorderBoxProperties but includes properties (e.g., overflow clip, |
| 135 // scroll translation) that apply to contents. This is suitable for paint |
| 122 // invalidation. | 136 // invalidation. |
| 123 ObjectPaintProperties::PropertyTreeStateWithOffset contentsProperties() const; | 137 ObjectPaintProperties::PropertyTreeStateWithOffset contentsProperties() const; |
| 124 | 138 |
| 125 void clearPaintOffsetTranslation() { m_paintOffsetTranslation = nullptr; } | 139 void clearPaintOffsetTranslation() { m_paintOffsetTranslation = nullptr; } |
| 126 void clearTransform() { m_transform = nullptr; } | 140 void clearTransform() { m_transform = nullptr; } |
| 127 void clearEffect() { m_effect = nullptr; } | 141 void clearEffect() { m_effect = nullptr; } |
| 128 void clearCssClip() { m_cssClip = nullptr; } | 142 void clearCssClip() { m_cssClip = nullptr; } |
| 129 void clearCssClipFixedPosition() { m_cssClipFixedPosition = nullptr; } | 143 void clearCssClipFixedPosition() { m_cssClipFixedPosition = nullptr; } |
| 130 void clearInnerBorderRadiusClip() { m_innerBorderRadiusClip = nullptr; } | 144 void clearInnerBorderRadiusClip() { m_innerBorderRadiusClip = nullptr; } |
| 131 void clearOverflowClip() { m_overflowClip = nullptr; } | 145 void clearOverflowClip() { m_overflowClip = nullptr; } |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 RefPtr<TransformPaintPropertyNode> m_scrollTranslation; | 241 RefPtr<TransformPaintPropertyNode> m_scrollTranslation; |
| 228 RefPtr<TransformPaintPropertyNode> m_scrollbarPaintOffset; | 242 RefPtr<TransformPaintPropertyNode> m_scrollbarPaintOffset; |
| 229 RefPtr<ScrollPaintPropertyNode> m_scroll; | 243 RefPtr<ScrollPaintPropertyNode> m_scroll; |
| 230 | 244 |
| 231 std::unique_ptr<PropertyTreeStateWithOffset> m_localBorderBoxProperties; | 245 std::unique_ptr<PropertyTreeStateWithOffset> m_localBorderBoxProperties; |
| 232 }; | 246 }; |
| 233 | 247 |
| 234 } // namespace blink | 248 } // namespace blink |
| 235 | 249 |
| 236 #endif // ObjectPaintProperties_h | 250 #endif // ObjectPaintProperties_h |
| OLD | NEW |