| 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::LocalBorderBoxProperties> recordTreeContextIfN
eeded(LayoutObject& object, const PaintPropertyTreeBuilderContext& context) |
| 314 { |
| 315 // Note: Currently only layer painter makes use of the pre-computed context. |
| 316 // This condition may be loosened with no adverse effects beside memory use. |
| 317 if (!object.hasLayer()) |
| 318 return nullptr; |
| 319 |
| 320 OwnPtr<ObjectPaintProperties::LocalBorderBoxProperties> recordedContext = ad
optPtr(new ObjectPaintProperties::LocalBorderBoxProperties); |
| 321 recordedContext->paintOffset = context.paintOffset; |
| 322 recordedContext->properties.transform = context.currentTransform; |
| 323 recordedContext->properties.clip = context.currentClip; |
| 324 recordedContext->properties.effect = context.currentEffect; |
| 325 return recordedContext.release(); |
| 326 } |
| 327 |
| 313 void PaintPropertyTreeBuilder::walk(LayoutObject& object, const PaintPropertyTre
eBuilderContext& context) | 328 void PaintPropertyTreeBuilder::walk(LayoutObject& object, const PaintPropertyTre
eBuilderContext& context) |
| 314 { | 329 { |
| 315 PaintPropertyTreeBuilderContext localContext(context); | 330 PaintPropertyTreeBuilderContext localContext(context); |
| 316 | 331 |
| 317 deriveBorderBoxFromContainerContext(object, localContext); | 332 deriveBorderBoxFromContainerContext(object, localContext); |
| 318 RefPtr<TransformPaintPropertyNode> newTransformNodeForPaintOffsetTranslation
= createPaintOffsetTranslationIfNeeded(object, localContext); | 333 RefPtr<TransformPaintPropertyNode> newTransformNodeForPaintOffsetTranslation
= createPaintOffsetTranslationIfNeeded(object, localContext); |
| 319 RefPtr<TransformPaintPropertyNode> newTransformNodeForTransform = createTran
sformIfNeeded(object, localContext); | 334 RefPtr<TransformPaintPropertyNode> newTransformNodeForTransform = createTran
sformIfNeeded(object, localContext); |
| 320 RefPtr<EffectPaintPropertyNode> newEffectNode = createEffectIfNeeded(object,
localContext); | 335 RefPtr<EffectPaintPropertyNode> newEffectNode = createEffectIfNeeded(object,
localContext); |
| 336 OwnPtr<ObjectPaintProperties::LocalBorderBoxProperties> newRecordedContext =
recordTreeContextIfNeeded(object, localContext); |
| 321 RefPtr<ClipPaintPropertyNode> newClipNodeForOverflowClip = createOverflowCli
pIfNeeded(object, localContext); | 337 RefPtr<ClipPaintPropertyNode> newClipNodeForOverflowClip = createOverflowCli
pIfNeeded(object, localContext); |
| 322 // TODO(trchen): Insert flattening transform here, as specified by | 338 // TODO(trchen): Insert flattening transform here, as specified by |
| 323 // http://www.w3.org/TR/css3-transforms/#transform-style-property | 339 // http://www.w3.org/TR/css3-transforms/#transform-style-property |
| 324 RefPtr<TransformPaintPropertyNode> newTransformNodeForPerspective = createPe
rspectiveIfNeeded(object, localContext); | 340 RefPtr<TransformPaintPropertyNode> newTransformNodeForPerspective = createPe
rspectiveIfNeeded(object, localContext); |
| 325 RefPtr<TransformPaintPropertyNode> newTransformNodeForScrollTranslation = cr
eateScrollTranslationIfNeeded(object, localContext); | 341 RefPtr<TransformPaintPropertyNode> newTransformNodeForScrollTranslation = cr
eateScrollTranslationIfNeeded(object, localContext); |
| 326 updateOutOfFlowContext(object, newTransformNodeForTransform, localContext); | 342 updateOutOfFlowContext(object, newTransformNodeForTransform, localContext); |
| 327 | 343 |
| 328 if (newTransformNodeForPaintOffsetTranslation || newTransformNodeForTransfor
m || newEffectNode || newClipNodeForOverflowClip || newTransformNodeForPerspecti
ve || newTransformNodeForScrollTranslation) { | 344 if (newTransformNodeForPaintOffsetTranslation || newTransformNodeForTransfor
m || newEffectNode || newClipNodeForOverflowClip || newTransformNodeForPerspecti
ve || newTransformNodeForScrollTranslation || newRecordedContext) { |
| 329 OwnPtr<ObjectPaintProperties> updatedPaintProperties = ObjectPaintProper
ties::create( | 345 OwnPtr<ObjectPaintProperties> updatedPaintProperties = ObjectPaintProper
ties::create( |
| 330 newTransformNodeForPaintOffsetTranslation.release(), | 346 newTransformNodeForPaintOffsetTranslation.release(), |
| 331 newTransformNodeForTransform.release(), | 347 newTransformNodeForTransform.release(), |
| 332 newEffectNode.release(), | 348 newEffectNode.release(), |
| 333 newClipNodeForOverflowClip.release(), | 349 newClipNodeForOverflowClip.release(), |
| 334 newTransformNodeForPerspective.release(), | 350 newTransformNodeForPerspective.release(), |
| 335 newTransformNodeForScrollTranslation.release()); | 351 newTransformNodeForScrollTranslation.release(), |
| 352 newRecordedContext.release()); |
| 336 object.setObjectPaintProperties(updatedPaintProperties.release()); | 353 object.setObjectPaintProperties(updatedPaintProperties.release()); |
| 337 } else { | 354 } else { |
| 338 object.clearObjectPaintProperties(); | 355 object.clearObjectPaintProperties(); |
| 339 } | 356 } |
| 340 | 357 |
| 341 for (LayoutObject* child = object.slowFirstChild(); child; child = child->ne
xtSibling()) { | 358 for (LayoutObject* child = object.slowFirstChild(); child; child = child->ne
xtSibling()) { |
| 342 if (child->isBoxModelObject() || child->isSVG()) | 359 if (child->isBoxModelObject() || child->isSVG()) |
| 343 walk(*child, localContext); | 360 walk(*child, localContext); |
| 344 } | 361 } |
| 345 } | 362 } |
| 346 | 363 |
| 347 } // namespace blink | 364 } // namespace blink |
| OLD | NEW |