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 #include "core/paint/PaintPropertyTreeBuilder.h" | 5 #include "core/paint/PaintPropertyTreeBuilder.h" |
| 6 | 6 |
| 7 #include "core/frame/FrameView.h" | 7 #include "core/frame/FrameView.h" |
| 8 #include "core/layout/LayoutView.h" | 8 #include "core/layout/LayoutView.h" |
| 9 #include "core/paint/ObjectPaintProperties.h" | 9 #include "core/paint/ObjectPaintProperties.h" |
| 10 #include "core/paint/PaintLayer.h" | 10 #include "core/paint/PaintLayer.h" |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 303 context.clipForOutOfFlowPositioned = context.currentClip; | 303 context.clipForOutOfFlowPositioned = context.currentClip; |
| 304 } | 304 } |
| 305 | 305 |
| 306 if (createdNewTransform || object.isSVGRoot()) { | 306 if (createdNewTransform || object.isSVGRoot()) { |
| 307 context.transformForFixedPositioned = context.currentTransform; | 307 context.transformForFixedPositioned = context.currentTransform; |
| 308 context.paintOffsetForFixedPositioned = context.paintOffset; | 308 context.paintOffsetForFixedPositioned = context.paintOffset; |
| 309 context.clipForFixedPositioned = context.currentClip; | 309 context.clipForFixedPositioned = context.currentClip; |
| 310 } | 310 } |
| 311 } | 311 } |
| 312 | 312 |
| 313 PassOwnPtr<ObjectPaintProperties::PropertyTreeContext> cacheTreeContextIfNeeded( LayoutObject& object, const PaintPropertyTreeBuilderContext& context) | |
|
pdr.
2016/02/04 00:06:45
I still don't really view this as a cache any more
trchen
2016/02/04 00:51:29
recordTreeContextIfNeeded that is.
| |
| 314 { | |
| 315 // Note: Currently only layer painter makes use of the cache. This condition can be changed. | |
| 316 if (!object.hasLayer()) | |
| 317 return nullptr; | |
| 318 | |
| 319 OwnPtr<ObjectPaintProperties::PropertyTreeContext> contextCache = adoptPtr(n ew ObjectPaintProperties::PropertyTreeContext); | |
| 320 contextCache->paintOffset = context.paintOffset; | |
| 321 contextCache->properties.transform = context.currentTransform; | |
| 322 contextCache->properties.clip = context.currentClip; | |
| 323 contextCache->properties.effect = context.currentEffect; | |
| 324 return contextCache.release(); | |
| 325 } | |
| 326 | |
| 313 void PaintPropertyTreeBuilder::walk(LayoutObject& object, const PaintPropertyTre eBuilderContext& context) | 327 void PaintPropertyTreeBuilder::walk(LayoutObject& object, const PaintPropertyTre eBuilderContext& context) |
| 314 { | 328 { |
| 315 PaintPropertyTreeBuilderContext localContext(context); | 329 PaintPropertyTreeBuilderContext localContext(context); |
| 316 | 330 |
| 317 deriveBorderBoxFromContainerContext(object, localContext); | 331 deriveBorderBoxFromContainerContext(object, localContext); |
| 318 RefPtr<TransformPaintPropertyNode> newTransformNodeForPaintOffsetTranslation = createPaintOffsetTranslationIfNeeded(object, localContext); | 332 RefPtr<TransformPaintPropertyNode> newTransformNodeForPaintOffsetTranslation = createPaintOffsetTranslationIfNeeded(object, localContext); |
| 319 RefPtr<TransformPaintPropertyNode> newTransformNodeForTransform = createTran sformIfNeeded(object, localContext); | 333 RefPtr<TransformPaintPropertyNode> newTransformNodeForTransform = createTran sformIfNeeded(object, localContext); |
| 320 RefPtr<EffectPaintPropertyNode> newEffectNode = createEffectIfNeeded(object, localContext); | 334 RefPtr<EffectPaintPropertyNode> newEffectNode = createEffectIfNeeded(object, localContext); |
| 335 OwnPtr<ObjectPaintProperties::PropertyTreeContext> newContextCache = cacheTr eeContextIfNeeded(object, localContext); | |
| 321 RefPtr<ClipPaintPropertyNode> newClipNodeForOverflowClip = createOverflowCli pIfNeeded(object, localContext); | 336 RefPtr<ClipPaintPropertyNode> newClipNodeForOverflowClip = createOverflowCli pIfNeeded(object, localContext); |
| 322 // TODO(trchen): Insert flattening transform here, as specified by | 337 // TODO(trchen): Insert flattening transform here, as specified by |
| 323 // http://www.w3.org/TR/css3-transforms/#transform-style-property | 338 // http://www.w3.org/TR/css3-transforms/#transform-style-property |
| 324 RefPtr<TransformPaintPropertyNode> newTransformNodeForPerspective = createPe rspectiveIfNeeded(object, localContext); | 339 RefPtr<TransformPaintPropertyNode> newTransformNodeForPerspective = createPe rspectiveIfNeeded(object, localContext); |
| 325 RefPtr<TransformPaintPropertyNode> newTransformNodeForScrollTranslation = cr eateScrollTranslationIfNeeded(object, localContext); | 340 RefPtr<TransformPaintPropertyNode> newTransformNodeForScrollTranslation = cr eateScrollTranslationIfNeeded(object, localContext); |
| 326 updateOutOfFlowContext(object, newTransformNodeForTransform, localContext); | 341 updateOutOfFlowContext(object, newTransformNodeForTransform, localContext); |
| 327 | 342 |
| 328 if (newTransformNodeForPaintOffsetTranslation || newTransformNodeForTransfor m || newEffectNode || newClipNodeForOverflowClip || newTransformNodeForPerspecti ve || newTransformNodeForScrollTranslation) { | 343 if (newTransformNodeForPaintOffsetTranslation || newTransformNodeForTransfor m || newEffectNode || newClipNodeForOverflowClip || newTransformNodeForPerspecti ve || newTransformNodeForScrollTranslation || newContextCache) { |
| 329 OwnPtr<ObjectPaintProperties> updatedPaintProperties = ObjectPaintProper ties::create( | 344 OwnPtr<ObjectPaintProperties> updatedPaintProperties = ObjectPaintProper ties::create( |
| 330 newTransformNodeForPaintOffsetTranslation.release(), | 345 newTransformNodeForPaintOffsetTranslation.release(), |
| 331 newTransformNodeForTransform.release(), | 346 newTransformNodeForTransform.release(), |
| 332 newEffectNode.release(), | 347 newEffectNode.release(), |
| 333 newClipNodeForOverflowClip.release(), | 348 newClipNodeForOverflowClip.release(), |
| 334 newTransformNodeForPerspective.release(), | 349 newTransformNodeForPerspective.release(), |
| 335 newTransformNodeForScrollTranslation.release()); | 350 newTransformNodeForScrollTranslation.release(), |
| 351 newContextCache.release()); | |
| 336 object.setObjectPaintProperties(updatedPaintProperties.release()); | 352 object.setObjectPaintProperties(updatedPaintProperties.release()); |
| 337 } else { | 353 } else { |
| 338 object.clearObjectPaintProperties(); | 354 object.clearObjectPaintProperties(); |
| 339 } | 355 } |
| 340 | 356 |
| 341 for (LayoutObject* child = object.slowFirstChild(); child; child = child->ne xtSibling()) { | 357 for (LayoutObject* child = object.slowFirstChild(); child; child = child->ne xtSibling()) { |
| 342 if (child->isBoxModelObject() || child->isSVG()) | 358 if (child->isBoxModelObject() || child->isSVG()) |
| 343 walk(*child, localContext); | 359 walk(*child, localContext); |
| 344 } | 360 } |
| 345 } | 361 } |
| 346 | 362 |
| 347 } // namespace blink | 363 } // namespace blink |
| OLD | NEW |