| 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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 const TransformPaintPropertyNode* svgLocalToBorderBoxTransform() const { | 84 const TransformPaintPropertyNode* svgLocalToBorderBoxTransform() const { |
| 85 return m_svgLocalToBorderBoxTransform.get(); | 85 return m_svgLocalToBorderBoxTransform.get(); |
| 86 } | 86 } |
| 87 const TransformPaintPropertyNode* scrollTranslation() const { | 87 const TransformPaintPropertyNode* scrollTranslation() const { |
| 88 return m_scrollTranslation.get(); | 88 return m_scrollTranslation.get(); |
| 89 } | 89 } |
| 90 const TransformPaintPropertyNode* scrollbarPaintOffset() const { | 90 const TransformPaintPropertyNode* scrollbarPaintOffset() const { |
| 91 return m_scrollbarPaintOffset.get(); | 91 return m_scrollbarPaintOffset.get(); |
| 92 } | 92 } |
| 93 | 93 |
| 94 // Auxiliary scrolling information. Includes information such as the hierarchy | |
| 95 // of scrollable areas, the extent that can be scrolled, etc. The actual | |
| 96 // scroll offset is stored in the transform tree (m_scrollTranslation). | |
| 97 const ScrollPaintPropertyNode* scroll() const { return m_scroll.get(); } | |
| 98 | |
| 99 const EffectPaintPropertyNode* effect() const { return m_effect.get(); } | 94 const EffectPaintPropertyNode* effect() const { return m_effect.get(); } |
| 100 | 95 |
| 101 // The hierarchy of the clip subtree created by a LayoutObject is as follows: | 96 // The hierarchy of the clip subtree created by a LayoutObject is as follows: |
| 102 // [ css clip ] | 97 // [ css clip ] |
| 103 // [ css clip fixed position] | 98 // [ css clip fixed position] |
| 104 // [ inner border radius clip ] Clip created by a rounded border with overflow | 99 // [ inner border radius clip ] Clip created by a rounded border with overflow |
| 105 // clip. This clip is not inset by scrollbars. | 100 // clip. This clip is not inset by scrollbars. |
| 106 // +--- [ overflow clip ] Clip created by overflow clip and is inset by | 101 // +--- [ overflow clip ] Clip created by overflow clip and is inset by |
| 107 // the scrollbars. | 102 // the scrollbars. |
| 108 const ClipPaintPropertyNode* cssClip() const { return m_cssClip.get(); } | 103 const ClipPaintPropertyNode* cssClip() const { return m_cssClip.get(); } |
| 109 const ClipPaintPropertyNode* cssClipFixedPosition() const { | 104 const ClipPaintPropertyNode* cssClipFixedPosition() const { |
| 110 return m_cssClipFixedPosition.get(); | 105 return m_cssClipFixedPosition.get(); |
| 111 } | 106 } |
| 112 const ClipPaintPropertyNode* innerBorderRadiusClip() const { | 107 const ClipPaintPropertyNode* innerBorderRadiusClip() const { |
| 113 return m_innerBorderRadiusClip.get(); | 108 return m_innerBorderRadiusClip.get(); |
| 114 } | 109 } |
| 115 const ClipPaintPropertyNode* overflowClip() const { | 110 const ClipPaintPropertyNode* overflowClip() const { |
| 116 return m_overflowClip.get(); | 111 return m_overflowClip.get(); |
| 117 } | 112 } |
| 118 | 113 |
| 119 // This is a complete set of property nodes and paint offset that should be | 114 // This is a complete set of property nodes that should be used as a starting |
| 120 // used as a starting point to paint this layout object. This is cached | 115 // point to paint this layout object. This is cached because some properties |
| 121 // because some properties inherit from the containing block chain instead of | 116 // inherit from the containing block chain instead of the painting parent and |
| 122 // the painting parent and cannot be derived in O(1) during the paint walk. | 117 // cannot be derived in O(1) during the paint walk. For example: |
| 123 // For example, <div style='opacity: 0.3; position: relative; margin: 11px;'/> | 118 // <div style='opacity: 0.3;'/> would have a propertyTreeState.effect() |
| 124 // would have a paint offset of (11px, 11px) and propertyTreeState.effect() | 119 // with opacity of 0.3 which was created by the div itself. Note that |
| 125 // would be an effect node with opacity of 0.3 which was created by the div | 120 // propertyTreeState.transform() would not be null but would instead point to |
| 126 // itself. Note that propertyTreeState.transform() would not be null but would | 121 // the transform space setup by div's ancestors. |
| 127 // instead point to the transform space setup by div's ancestors. | |
| 128 const PropertyTreeState* localBorderBoxProperties() const { | 122 const PropertyTreeState* localBorderBoxProperties() const { |
| 129 return m_localBorderBoxProperties.get(); | 123 return m_localBorderBoxProperties.get(); |
| 130 } | 124 } |
| 131 | 125 |
| 132 // This is the complete set of property nodes and paint offset that can be | 126 // This is the complete set of property nodes that can be used to paint the |
| 133 // used to paint the contents of this object. It is similar to | 127 // contents of this object. It is similar to localBorderBoxProperties but |
| 134 // localBorderBoxProperties but includes properties (e.g., overflow clip, | 128 // includes properties (e.g., overflow clip, scroll translation) that apply to |
| 135 // scroll translation) that apply to contents. This is suitable for paint | 129 // contents. This is suitable for paint invalidation. |
| 136 // invalidation. | |
| 137 const PropertyTreeState* contentsProperties() const { | 130 const PropertyTreeState* contentsProperties() const { |
| 138 if (!m_contentsProperties) { | 131 if (!m_contentsProperties) { |
| 139 if (!m_localBorderBoxProperties) | 132 if (!m_localBorderBoxProperties) |
| 140 return nullptr; | 133 return nullptr; |
| 141 updateContentsProperties(); | 134 updateContentsProperties(); |
| 142 } else { | 135 } else { |
| 143 #if DCHECK_IS_ON() | 136 #if DCHECK_IS_ON() |
| 144 // Check if the cached m_contentsProperties is valid. | 137 // Check if the cached m_contentsProperties is valid. |
| 145 DCHECK(m_localBorderBoxProperties); | 138 DCHECK(m_localBorderBoxProperties); |
| 146 std::unique_ptr<PropertyTreeState> oldProperties = | 139 std::unique_ptr<PropertyTreeState> oldProperties = |
| 147 std::move(m_contentsProperties); | 140 std::move(m_contentsProperties); |
| 148 updateContentsProperties(); | 141 updateContentsProperties(); |
| 149 DCHECK(*m_contentsProperties == *oldProperties); | 142 DCHECK(*m_contentsProperties == *oldProperties); |
| 150 #endif | 143 #endif |
| 151 } | 144 } |
| 152 return m_contentsProperties.get(); | 145 return m_contentsProperties.get(); |
| 153 }; | 146 }; |
| 154 | 147 |
| 155 void updateLocalBorderBoxProperties( | 148 void updateLocalBorderBoxProperties( |
| 156 const TransformPaintPropertyNode* transform, | 149 const TransformPaintPropertyNode* transform, |
| 157 const ClipPaintPropertyNode* clip, | 150 const ClipPaintPropertyNode* clip, |
| 158 const EffectPaintPropertyNode* effect, | 151 const EffectPaintPropertyNode* effect) { |
| 159 const ScrollPaintPropertyNode* scroll) { | |
| 160 if (m_localBorderBoxProperties) { | 152 if (m_localBorderBoxProperties) { |
| 161 m_localBorderBoxProperties->setTransform(transform); | 153 m_localBorderBoxProperties->setTransform(transform); |
| 162 m_localBorderBoxProperties->setClip(clip); | 154 m_localBorderBoxProperties->setClip(clip); |
| 163 m_localBorderBoxProperties->setEffect(effect); | 155 m_localBorderBoxProperties->setEffect(effect); |
| 164 m_localBorderBoxProperties->setScroll(scroll); | |
| 165 } else { | 156 } else { |
| 166 m_localBorderBoxProperties = WTF::wrapUnique(new PropertyTreeState( | 157 m_localBorderBoxProperties = WTF::wrapUnique( |
| 167 PropertyTreeState(transform, clip, effect, scroll))); | 158 new PropertyTreeState(PropertyTreeState(transform, clip, effect))); |
| 168 } | 159 } |
| 169 m_contentsProperties = nullptr; | 160 m_contentsProperties = nullptr; |
| 170 } | 161 } |
| 171 void clearLocalBorderBoxProperties() { | 162 void clearLocalBorderBoxProperties() { |
| 172 m_localBorderBoxProperties = nullptr; | 163 m_localBorderBoxProperties = nullptr; |
| 173 m_contentsProperties = nullptr; | 164 m_contentsProperties = nullptr; |
| 174 } | 165 } |
| 175 | 166 |
| 176 // The following clear* functions return true if the property tree structure | 167 // The following clear* functions return true if the property tree structure |
| 177 // changes (an existing node was deleted), and false otherwise. See the | 168 // changes (an existing node was deleted), and false otherwise. See the |
| 178 // class-level comment ("update & clear implementation note") for details | 169 // class-level comment ("update & clear implementation note") for details |
| 179 // about why this is needed for efficient updates. | 170 // about why this is needed for efficient updates. |
| 180 bool clearPaintOffsetTranslation() { return clear(m_paintOffsetTranslation); } | 171 bool clearPaintOffsetTranslation() { return clear(m_paintOffsetTranslation); } |
| 181 bool clearTransform() { return clear(m_transform); } | 172 bool clearTransform() { return clear(m_transform); } |
| 182 bool clearEffect() { return clear(m_effect); } | 173 bool clearEffect() { return clear(m_effect); } |
| 183 bool clearCssClip() { return clear(m_cssClip); } | 174 bool clearCssClip() { return clear(m_cssClip); } |
| 184 bool clearCssClipFixedPosition() { return clear(m_cssClipFixedPosition); } | 175 bool clearCssClipFixedPosition() { return clear(m_cssClipFixedPosition); } |
| 185 bool clearInnerBorderRadiusClip() { return clear(m_innerBorderRadiusClip); } | 176 bool clearInnerBorderRadiusClip() { return clear(m_innerBorderRadiusClip); } |
| 186 bool clearOverflowClip() { return clear(m_overflowClip); } | 177 bool clearOverflowClip() { return clear(m_overflowClip); } |
| 187 bool clearPerspective() { return clear(m_perspective); } | 178 bool clearPerspective() { return clear(m_perspective); } |
| 188 bool clearSvgLocalToBorderBoxTransform() { | 179 bool clearSvgLocalToBorderBoxTransform() { |
| 189 return clear(m_svgLocalToBorderBoxTransform); | 180 return clear(m_svgLocalToBorderBoxTransform); |
| 190 } | 181 } |
| 191 bool clearScrollTranslation() { return clear(m_scrollTranslation); } | 182 bool clearScrollTranslation() { return clear(m_scrollTranslation); } |
| 192 bool clearScrollbarPaintOffset() { return clear(m_scrollbarPaintOffset); } | 183 bool clearScrollbarPaintOffset() { return clear(m_scrollbarPaintOffset); } |
| 193 bool clearScroll() { return clear(m_scroll); } | |
| 194 | 184 |
| 195 // The following update* functions return true if the property tree structure | 185 // The following update* functions return true if the property tree structure |
| 196 // changes (a new node was created), and false otherwise. See the class-level | 186 // changes (a new node was created), and false otherwise. See the class-level |
| 197 // comment ("update & clear implementation note") for details about why this | 187 // comment ("update & clear implementation note") for details about why this |
| 198 // is needed for efficient updates. | 188 // is needed for efficient updates. |
| 199 template <typename... Args> | 189 template <typename... Args> |
| 200 bool updatePaintOffsetTranslation(Args&&... args) { | 190 bool updatePaintOffsetTranslation(Args&&... args) { |
| 201 return update(m_paintOffsetTranslation, std::forward<Args>(args)...); | 191 return update(m_paintOffsetTranslation, std::forward<Args>(args)...); |
| 202 } | 192 } |
| 203 template <typename... Args> | 193 template <typename... Args> |
| 204 bool updateTransform(Args&&... args) { | 194 bool updateTransform(Args&&... args) { |
| 205 return update(m_transform, std::forward<Args>(args)...); | 195 return update(m_transform, std::forward<Args>(args)...); |
| 206 } | 196 } |
| 207 template <typename... Args> | 197 template <typename... Args> |
| 208 bool updatePerspective(Args&&... args) { | 198 bool updatePerspective(Args&&... args) { |
| 209 return update(m_perspective, std::forward<Args>(args)...); | 199 return update(m_perspective, std::forward<Args>(args)...); |
| 210 } | 200 } |
| 211 template <typename... Args> | 201 template <typename... Args> |
| 212 bool updateSvgLocalToBorderBoxTransform(Args&&... args) { | 202 bool updateSvgLocalToBorderBoxTransform(Args&&... args) { |
| 213 DCHECK(!scrollTranslation()) << "SVG elements cannot scroll so there " | 203 DCHECK(!scrollTranslation()) << "SVG elements cannot scroll so there " |
| 214 "should never be both a scroll translation " | 204 "should never be both a scroll translation " |
| 215 "and an SVG local to border box transform."; | 205 "and an SVG local to border box transform."; |
| 216 return update(m_svgLocalToBorderBoxTransform, std::forward<Args>(args)...); | 206 return update(m_svgLocalToBorderBoxTransform, std::forward<Args>(args)...); |
| 217 } | 207 } |
| 218 template <typename... Args> | 208 template <typename... Args> |
| 219 bool updateScrollTranslation(Args&&... args) { | 209 bool updateScrollTranslation(Args&&... args) { |
| 220 DCHECK(!svgLocalToBorderBoxTransform()) | 210 DCHECK(!svgLocalToBorderBoxTransform()) |
| 221 << "SVG elements cannot scroll so there should never be both a scroll " | 211 << "SVG elements cannot scroll so there should never be both a scroll " |
| 222 "translation and an SVG local to border box transform."; | 212 "translation and an SVG local to border box transform."; |
| 223 return update(m_scrollTranslation, std::forward<Args>(args)...); | 213 if (m_scrollTranslation) { |
| 214 m_scrollTranslation->updateScrollTranslation(std::forward<Args>(args)...); |
| 215 return false; |
| 216 } |
| 217 m_scrollTranslation = TransformPaintPropertyNode::createScrollTranslation( |
| 218 std::forward<Args>(args)...); |
| 219 return true; |
| 224 } | 220 } |
| 225 template <typename... Args> | 221 template <typename... Args> |
| 226 bool updateScrollbarPaintOffset(Args&&... args) { | 222 bool updateScrollbarPaintOffset(Args&&... args) { |
| 227 return update(m_scrollbarPaintOffset, std::forward<Args>(args)...); | 223 return update(m_scrollbarPaintOffset, std::forward<Args>(args)...); |
| 228 } | 224 } |
| 229 template <typename... Args> | 225 template <typename... Args> |
| 230 bool updateScroll(Args&&... args) { | |
| 231 return update(m_scroll, std::forward<Args>(args)...); | |
| 232 } | |
| 233 template <typename... Args> | |
| 234 bool updateEffect(Args&&... args) { | 226 bool updateEffect(Args&&... args) { |
| 235 return update(m_effect, std::forward<Args>(args)...); | 227 return update(m_effect, std::forward<Args>(args)...); |
| 236 } | 228 } |
| 237 template <typename... Args> | 229 template <typename... Args> |
| 238 bool updateCssClip(Args&&... args) { | 230 bool updateCssClip(Args&&... args) { |
| 239 return update(m_cssClip, std::forward<Args>(args)...); | 231 return update(m_cssClip, std::forward<Args>(args)...); |
| 240 } | 232 } |
| 241 template <typename... Args> | 233 template <typename... Args> |
| 242 bool updateCssClipFixedPosition(Args&&... args) { | 234 bool updateCssClipFixedPosition(Args&&... args) { |
| 243 return update(m_cssClipFixedPosition, std::forward<Args>(args)...); | 235 return update(m_cssClipFixedPosition, std::forward<Args>(args)...); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 272 if (m_perspective) | 264 if (m_perspective) |
| 273 cloned->m_perspective = m_perspective->clone(); | 265 cloned->m_perspective = m_perspective->clone(); |
| 274 if (m_svgLocalToBorderBoxTransform) { | 266 if (m_svgLocalToBorderBoxTransform) { |
| 275 cloned->m_svgLocalToBorderBoxTransform = | 267 cloned->m_svgLocalToBorderBoxTransform = |
| 276 m_svgLocalToBorderBoxTransform->clone(); | 268 m_svgLocalToBorderBoxTransform->clone(); |
| 277 } | 269 } |
| 278 if (m_scrollTranslation) | 270 if (m_scrollTranslation) |
| 279 cloned->m_scrollTranslation = m_scrollTranslation->clone(); | 271 cloned->m_scrollTranslation = m_scrollTranslation->clone(); |
| 280 if (m_scrollbarPaintOffset) | 272 if (m_scrollbarPaintOffset) |
| 281 cloned->m_scrollbarPaintOffset = m_scrollbarPaintOffset->clone(); | 273 cloned->m_scrollbarPaintOffset = m_scrollbarPaintOffset->clone(); |
| 282 if (m_scroll) | |
| 283 cloned->m_scroll = m_scroll->clone(); | |
| 284 if (m_localBorderBoxProperties) { | 274 if (m_localBorderBoxProperties) { |
| 285 cloned->m_localBorderBoxProperties = | 275 cloned->m_localBorderBoxProperties = |
| 286 WTF::wrapUnique(new PropertyTreeState(*m_localBorderBoxProperties)); | 276 WTF::wrapUnique(new PropertyTreeState(*m_localBorderBoxProperties)); |
| 287 } | 277 } |
| 288 return cloned; | 278 return cloned; |
| 289 } | 279 } |
| 290 #endif | 280 #endif |
| 291 | 281 |
| 292 private: | 282 private: |
| 293 ObjectPaintProperties() {} | 283 ObjectPaintProperties() {} |
| (...skipping 30 matching lines...) Expand all Loading... |
| 324 RefPtr<EffectPaintPropertyNode> m_effect; | 314 RefPtr<EffectPaintPropertyNode> m_effect; |
| 325 RefPtr<ClipPaintPropertyNode> m_cssClip; | 315 RefPtr<ClipPaintPropertyNode> m_cssClip; |
| 326 RefPtr<ClipPaintPropertyNode> m_cssClipFixedPosition; | 316 RefPtr<ClipPaintPropertyNode> m_cssClipFixedPosition; |
| 327 RefPtr<ClipPaintPropertyNode> m_innerBorderRadiusClip; | 317 RefPtr<ClipPaintPropertyNode> m_innerBorderRadiusClip; |
| 328 RefPtr<ClipPaintPropertyNode> m_overflowClip; | 318 RefPtr<ClipPaintPropertyNode> m_overflowClip; |
| 329 RefPtr<TransformPaintPropertyNode> m_perspective; | 319 RefPtr<TransformPaintPropertyNode> m_perspective; |
| 330 // TODO(pdr): Only LayoutSVGRoot needs this and it should be moved there. | 320 // TODO(pdr): Only LayoutSVGRoot needs this and it should be moved there. |
| 331 RefPtr<TransformPaintPropertyNode> m_svgLocalToBorderBoxTransform; | 321 RefPtr<TransformPaintPropertyNode> m_svgLocalToBorderBoxTransform; |
| 332 RefPtr<TransformPaintPropertyNode> m_scrollTranslation; | 322 RefPtr<TransformPaintPropertyNode> m_scrollTranslation; |
| 333 RefPtr<TransformPaintPropertyNode> m_scrollbarPaintOffset; | 323 RefPtr<TransformPaintPropertyNode> m_scrollbarPaintOffset; |
| 334 RefPtr<ScrollPaintPropertyNode> m_scroll; | |
| 335 | 324 |
| 336 std::unique_ptr<PropertyTreeState> m_localBorderBoxProperties; | 325 std::unique_ptr<PropertyTreeState> m_localBorderBoxProperties; |
| 337 mutable std::unique_ptr<PropertyTreeState> m_contentsProperties; | 326 mutable std::unique_ptr<PropertyTreeState> m_contentsProperties; |
| 338 }; | 327 }; |
| 339 | 328 |
| 340 } // namespace blink | 329 } // namespace blink |
| 341 | 330 |
| 342 #endif // ObjectPaintProperties_h | 331 #endif // ObjectPaintProperties_h |
| OLD | NEW |