| 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 // The hierarchy of the effect subtree created by a LayoutObject is as |
| 95 // follows: |
| 96 // [ effect ] |
| 97 // | Isolated group to apply various CSS effects, including opacity, |
| 98 // | mix-blend-mode, and for isolation if a mask needs to be applied or |
| 99 // | backdrop-dependent children are present. |
| 100 // +-[ filter ] |
| 101 // | Isolated group for CSS filter. |
| 102 // +-[ mask ] |
| 103 // Isolated group for painting the CSS mask. This node will have |
| 104 // SkBlendMode::kDstIn and shall paint last, i.e. after masked contents. |
| 94 const EffectPaintPropertyNode* effect() const { return m_effect.get(); } | 105 const EffectPaintPropertyNode* effect() const { return m_effect.get(); } |
| 106 const EffectPaintPropertyNode* filter() const { return m_filter.get(); } |
| 107 const EffectPaintPropertyNode* mask() const { return m_mask.get(); } |
| 95 | 108 |
| 96 // The hierarchy of the clip subtree created by a LayoutObject is as follows: | 109 // The hierarchy of the clip subtree created by a LayoutObject is as follows: |
| 97 // [ css clip ] | 110 // [ mask clip ] |
| 98 // [ css clip fixed position] | 111 // | Clip created by CSS mask. It serves two purposes: |
| 99 // [ inner border radius clip ] Clip created by a rounded border with overflow | 112 // | 1. Cull painting of the masked subtree. Because anything outside of |
| 100 // clip. This clip is not inset by scrollbars. | 113 // | the mask is never visible, it is pointless to paint them. |
| 101 // +--- [ overflow clip ] Clip created by overflow clip and is inset by | 114 // | 2. Raster clip of the masked subtree. Because the mask implemented |
| 102 // the scrollbars. | 115 // | as SkBlendMode::kDstIn, pixels outside of mask's bound will be |
| 116 // | intact when they shall be masked out. This clip ensures no pixels |
| 117 // | leak out. |
| 118 // +-[ css clip ] |
| 119 // | Clip created by CSS clip. CSS clip applies to all descendants, this |
| 120 // | node only applies to containing block descendants. For descendants |
| 121 // | not contained by this object, use [ css clip fixed position ]. |
| 122 // +-[ inner border radius clip] |
| 123 // | Clip created by a rounded border with overflow clip. This clip is |
| 124 // | not inset by scrollbars. |
| 125 // +-[ overflow clip ] |
| 126 // Clip created by overflow clip and is inset by the scrollbar. |
| 127 // [ css clip fixed position ] |
| 128 // Clip created by CSS clip. Only exists if the current clip includes |
| 129 // some clip that doesn't apply to our fixed position descendants. |
| 130 const ClipPaintPropertyNode* maskClip() const { return m_maskClip.get(); } |
| 103 const ClipPaintPropertyNode* cssClip() const { return m_cssClip.get(); } | 131 const ClipPaintPropertyNode* cssClip() const { return m_cssClip.get(); } |
| 104 const ClipPaintPropertyNode* cssClipFixedPosition() const { | 132 const ClipPaintPropertyNode* cssClipFixedPosition() const { |
| 105 return m_cssClipFixedPosition.get(); | 133 return m_cssClipFixedPosition.get(); |
| 106 } | 134 } |
| 107 const ClipPaintPropertyNode* innerBorderRadiusClip() const { | 135 const ClipPaintPropertyNode* innerBorderRadiusClip() const { |
| 108 return m_innerBorderRadiusClip.get(); | 136 return m_innerBorderRadiusClip.get(); |
| 109 } | 137 } |
| 110 const ClipPaintPropertyNode* overflowClip() const { | 138 const ClipPaintPropertyNode* overflowClip() const { |
| 111 return m_overflowClip.get(); | 139 return m_overflowClip.get(); |
| 112 } | 140 } |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 m_contentsProperties = nullptr; | 192 m_contentsProperties = nullptr; |
| 165 } | 193 } |
| 166 | 194 |
| 167 // The following clear* functions return true if the property tree structure | 195 // The following clear* functions return true if the property tree structure |
| 168 // changes (an existing node was deleted), and false otherwise. See the | 196 // changes (an existing node was deleted), and false otherwise. See the |
| 169 // class-level comment ("update & clear implementation note") for details | 197 // class-level comment ("update & clear implementation note") for details |
| 170 // about why this is needed for efficient updates. | 198 // about why this is needed for efficient updates. |
| 171 bool clearPaintOffsetTranslation() { return clear(m_paintOffsetTranslation); } | 199 bool clearPaintOffsetTranslation() { return clear(m_paintOffsetTranslation); } |
| 172 bool clearTransform() { return clear(m_transform); } | 200 bool clearTransform() { return clear(m_transform); } |
| 173 bool clearEffect() { return clear(m_effect); } | 201 bool clearEffect() { return clear(m_effect); } |
| 202 bool clearFilter() { return clear(m_filter); } |
| 203 bool clearMask() { return clear(m_mask); } |
| 204 bool clearMaskClip() { return clear(m_maskClip); } |
| 174 bool clearCssClip() { return clear(m_cssClip); } | 205 bool clearCssClip() { return clear(m_cssClip); } |
| 175 bool clearCssClipFixedPosition() { return clear(m_cssClipFixedPosition); } | 206 bool clearCssClipFixedPosition() { return clear(m_cssClipFixedPosition); } |
| 176 bool clearInnerBorderRadiusClip() { return clear(m_innerBorderRadiusClip); } | 207 bool clearInnerBorderRadiusClip() { return clear(m_innerBorderRadiusClip); } |
| 177 bool clearOverflowClip() { return clear(m_overflowClip); } | 208 bool clearOverflowClip() { return clear(m_overflowClip); } |
| 178 bool clearPerspective() { return clear(m_perspective); } | 209 bool clearPerspective() { return clear(m_perspective); } |
| 179 bool clearSvgLocalToBorderBoxTransform() { | 210 bool clearSvgLocalToBorderBoxTransform() { |
| 180 return clear(m_svgLocalToBorderBoxTransform); | 211 return clear(m_svgLocalToBorderBoxTransform); |
| 181 } | 212 } |
| 182 bool clearScrollTranslation() { return clear(m_scrollTranslation); } | 213 bool clearScrollTranslation() { return clear(m_scrollTranslation); } |
| 183 bool clearScrollbarPaintOffset() { return clear(m_scrollbarPaintOffset); } | 214 bool clearScrollbarPaintOffset() { return clear(m_scrollbarPaintOffset); } |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 } | 251 } |
| 221 template <typename... Args> | 252 template <typename... Args> |
| 222 bool updateScrollbarPaintOffset(Args&&... args) { | 253 bool updateScrollbarPaintOffset(Args&&... args) { |
| 223 return update(m_scrollbarPaintOffset, std::forward<Args>(args)...); | 254 return update(m_scrollbarPaintOffset, std::forward<Args>(args)...); |
| 224 } | 255 } |
| 225 template <typename... Args> | 256 template <typename... Args> |
| 226 bool updateEffect(Args&&... args) { | 257 bool updateEffect(Args&&... args) { |
| 227 return update(m_effect, std::forward<Args>(args)...); | 258 return update(m_effect, std::forward<Args>(args)...); |
| 228 } | 259 } |
| 229 template <typename... Args> | 260 template <typename... Args> |
| 261 bool updateFilter(Args&&... args) { |
| 262 return update(m_filter, std::forward<Args>(args)...); |
| 263 } |
| 264 template <typename... Args> |
| 265 bool updateMask(Args&&... args) { |
| 266 return update(m_mask, std::forward<Args>(args)...); |
| 267 } |
| 268 template <typename... Args> |
| 269 bool updateMaskClip(Args&&... args) { |
| 270 return update(m_maskClip, std::forward<Args>(args)...); |
| 271 } |
| 272 template <typename... Args> |
| 230 bool updateCssClip(Args&&... args) { | 273 bool updateCssClip(Args&&... args) { |
| 231 return update(m_cssClip, std::forward<Args>(args)...); | 274 return update(m_cssClip, std::forward<Args>(args)...); |
| 232 } | 275 } |
| 233 template <typename... Args> | 276 template <typename... Args> |
| 234 bool updateCssClipFixedPosition(Args&&... args) { | 277 bool updateCssClipFixedPosition(Args&&... args) { |
| 235 return update(m_cssClipFixedPosition, std::forward<Args>(args)...); | 278 return update(m_cssClipFixedPosition, std::forward<Args>(args)...); |
| 236 } | 279 } |
| 237 template <typename... Args> | 280 template <typename... Args> |
| 238 bool updateInnerBorderRadiusClip(Args&&... args) { | 281 bool updateInnerBorderRadiusClip(Args&&... args) { |
| 239 return update(m_innerBorderRadiusClip, std::forward<Args>(args)...); | 282 return update(m_innerBorderRadiusClip, std::forward<Args>(args)...); |
| 240 } | 283 } |
| 241 template <typename... Args> | 284 template <typename... Args> |
| 242 bool updateOverflowClip(Args&&... args) { | 285 bool updateOverflowClip(Args&&... args) { |
| 243 return update(m_overflowClip, std::forward<Args>(args)...); | 286 return update(m_overflowClip, std::forward<Args>(args)...); |
| 244 } | 287 } |
| 245 | 288 |
| 246 #if DCHECK_IS_ON() | 289 #if DCHECK_IS_ON() |
| 247 // Used by FindPropertiesNeedingUpdate.h for recording the current properties. | 290 // Used by FindPropertiesNeedingUpdate.h for recording the current properties. |
| 248 std::unique_ptr<ObjectPaintProperties> clone() const { | 291 std::unique_ptr<ObjectPaintProperties> clone() const { |
| 249 std::unique_ptr<ObjectPaintProperties> cloned = create(); | 292 std::unique_ptr<ObjectPaintProperties> cloned = create(); |
| 250 if (m_paintOffsetTranslation) | 293 if (m_paintOffsetTranslation) |
| 251 cloned->m_paintOffsetTranslation = m_paintOffsetTranslation->clone(); | 294 cloned->m_paintOffsetTranslation = m_paintOffsetTranslation->clone(); |
| 252 if (m_transform) | 295 if (m_transform) |
| 253 cloned->m_transform = m_transform->clone(); | 296 cloned->m_transform = m_transform->clone(); |
| 254 if (m_effect) | 297 if (m_effect) |
| 255 cloned->m_effect = m_effect->clone(); | 298 cloned->m_effect = m_effect->clone(); |
| 299 if (m_filter) |
| 300 cloned->m_filter = m_filter->clone(); |
| 301 if (m_mask) |
| 302 cloned->m_mask = m_mask->clone(); |
| 303 if (m_maskClip) |
| 304 cloned->m_maskClip = m_maskClip->clone(); |
| 256 if (m_cssClip) | 305 if (m_cssClip) |
| 257 cloned->m_cssClip = m_cssClip->clone(); | 306 cloned->m_cssClip = m_cssClip->clone(); |
| 258 if (m_cssClipFixedPosition) | 307 if (m_cssClipFixedPosition) |
| 259 cloned->m_cssClipFixedPosition = m_cssClipFixedPosition->clone(); | 308 cloned->m_cssClipFixedPosition = m_cssClipFixedPosition->clone(); |
| 260 if (m_innerBorderRadiusClip) | 309 if (m_innerBorderRadiusClip) |
| 261 cloned->m_innerBorderRadiusClip = m_innerBorderRadiusClip->clone(); | 310 cloned->m_innerBorderRadiusClip = m_innerBorderRadiusClip->clone(); |
| 262 if (m_overflowClip) | 311 if (m_overflowClip) |
| 263 cloned->m_overflowClip = m_overflowClip->clone(); | 312 cloned->m_overflowClip = m_overflowClip->clone(); |
| 264 if (m_perspective) | 313 if (m_perspective) |
| 265 cloned->m_perspective = m_perspective->clone(); | 314 cloned->m_perspective = m_perspective->clone(); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 305 } | 354 } |
| 306 field = PaintPropertyNode::create(std::forward<Args>(args)...); | 355 field = PaintPropertyNode::create(std::forward<Args>(args)...); |
| 307 return true; | 356 return true; |
| 308 } | 357 } |
| 309 | 358 |
| 310 void updateContentsProperties() const; | 359 void updateContentsProperties() const; |
| 311 | 360 |
| 312 RefPtr<TransformPaintPropertyNode> m_paintOffsetTranslation; | 361 RefPtr<TransformPaintPropertyNode> m_paintOffsetTranslation; |
| 313 RefPtr<TransformPaintPropertyNode> m_transform; | 362 RefPtr<TransformPaintPropertyNode> m_transform; |
| 314 RefPtr<EffectPaintPropertyNode> m_effect; | 363 RefPtr<EffectPaintPropertyNode> m_effect; |
| 364 RefPtr<EffectPaintPropertyNode> m_filter; |
| 365 RefPtr<EffectPaintPropertyNode> m_mask; |
| 366 RefPtr<ClipPaintPropertyNode> m_maskClip; |
| 315 RefPtr<ClipPaintPropertyNode> m_cssClip; | 367 RefPtr<ClipPaintPropertyNode> m_cssClip; |
| 316 RefPtr<ClipPaintPropertyNode> m_cssClipFixedPosition; | 368 RefPtr<ClipPaintPropertyNode> m_cssClipFixedPosition; |
| 317 RefPtr<ClipPaintPropertyNode> m_innerBorderRadiusClip; | 369 RefPtr<ClipPaintPropertyNode> m_innerBorderRadiusClip; |
| 318 RefPtr<ClipPaintPropertyNode> m_overflowClip; | 370 RefPtr<ClipPaintPropertyNode> m_overflowClip; |
| 319 RefPtr<TransformPaintPropertyNode> m_perspective; | 371 RefPtr<TransformPaintPropertyNode> m_perspective; |
| 320 // TODO(pdr): Only LayoutSVGRoot needs this and it should be moved there. | 372 // TODO(pdr): Only LayoutSVGRoot needs this and it should be moved there. |
| 321 RefPtr<TransformPaintPropertyNode> m_svgLocalToBorderBoxTransform; | 373 RefPtr<TransformPaintPropertyNode> m_svgLocalToBorderBoxTransform; |
| 322 RefPtr<TransformPaintPropertyNode> m_scrollTranslation; | 374 RefPtr<TransformPaintPropertyNode> m_scrollTranslation; |
| 323 RefPtr<TransformPaintPropertyNode> m_scrollbarPaintOffset; | 375 RefPtr<TransformPaintPropertyNode> m_scrollbarPaintOffset; |
| 324 | 376 |
| 325 std::unique_ptr<PropertyTreeState> m_localBorderBoxProperties; | 377 std::unique_ptr<PropertyTreeState> m_localBorderBoxProperties; |
| 326 mutable std::unique_ptr<PropertyTreeState> m_contentsProperties; | 378 mutable std::unique_ptr<PropertyTreeState> m_contentsProperties; |
| 327 }; | 379 }; |
| 328 | 380 |
| 329 } // namespace blink | 381 } // namespace blink |
| 330 | 382 |
| 331 #endif // ObjectPaintProperties_h | 383 #endif // ObjectPaintProperties_h |
| OLD | NEW |