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