| 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/frame/LocalFrame.h" | 8 #include "core/frame/LocalFrame.h" |
| 9 #include "core/frame/Settings.h" | 9 #include "core/frame/Settings.h" |
| 10 #include "core/layout/LayoutInline.h" | 10 #include "core/layout/LayoutInline.h" |
| (...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 261 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled() && | 261 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled() && |
| 262 object.isLayoutView()) { | 262 object.isLayoutView()) { |
| 263 context.absolutePosition.transform = properties->paintOffsetTranslation(); | 263 context.absolutePosition.transform = properties->paintOffsetTranslation(); |
| 264 context.fixedPosition.transform = properties->paintOffsetTranslation(); | 264 context.fixedPosition.transform = properties->paintOffsetTranslation(); |
| 265 context.absolutePosition.paintOffset = LayoutPoint(); | 265 context.absolutePosition.paintOffset = LayoutPoint(); |
| 266 context.fixedPosition.paintOffset = LayoutPoint(); | 266 context.fixedPosition.paintOffset = LayoutPoint(); |
| 267 } | 267 } |
| 268 } | 268 } |
| 269 } | 269 } |
| 270 | 270 |
| 271 static FloatPoint3D transformOrigin(const LayoutBox& box) { | |
| 272 const ComputedStyle& style = box.styleRef(); | |
| 273 FloatSize borderBoxSize(box.size()); | |
| 274 return FloatPoint3D( | |
| 275 floatValueForLength(style.transformOriginX(), borderBoxSize.width()), | |
| 276 floatValueForLength(style.transformOriginY(), borderBoxSize.height()), | |
| 277 style.transformOriginZ()); | |
| 278 } | |
| 279 | |
| 280 // SVG does not use the general transform update of |updateTransform|, instead | 271 // SVG does not use the general transform update of |updateTransform|, instead |
| 281 // creating a transform node for SVG-specific transforms without 3D. | 272 // creating a transform node for SVG-specific transforms without 3D. |
| 282 void PaintPropertyTreeBuilder::updateTransformForNonRootSVG( | 273 void PaintPropertyTreeBuilder::updateTransformForNonRootSVG( |
| 283 const LayoutObject& object, | 274 const LayoutObject& object, |
| 284 PaintPropertyTreeBuilderContext& context) { | 275 PaintPropertyTreeBuilderContext& context) { |
| 285 DCHECK(object.isSVG() && !object.isSVGRoot()); | 276 DCHECK(object.isSVG() && !object.isSVGRoot()); |
| 286 // SVG does not use paint offset internally, except for SVGForeignObject which | 277 // SVG does not use paint offset internally, except for SVGForeignObject which |
| 287 // has different SVG and HTML coordinate spaces. | 278 // has different SVG and HTML coordinate spaces. |
| 288 DCHECK(object.isSVGForeignObject() || | 279 DCHECK(object.isSVGForeignObject() || |
| 289 context.current.paintOffset == LayoutPoint()); | 280 context.current.paintOffset == LayoutPoint()); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 323 object.styleRef())) | 314 object.styleRef())) |
| 324 compositingReasons |= CompositingReasonActiveAnimation; | 315 compositingReasons |= CompositingReasonActiveAnimation; |
| 325 | 316 |
| 326 if (object.styleRef().hasWillChangeCompositingHint() && | 317 if (object.styleRef().hasWillChangeCompositingHint() && |
| 327 !object.styleRef().subtreeWillChangeContents()) | 318 !object.styleRef().subtreeWillChangeContents()) |
| 328 compositingReasons |= CompositingReasonWillChangeCompositingHint; | 319 compositingReasons |= CompositingReasonWillChangeCompositingHint; |
| 329 | 320 |
| 330 return compositingReasons; | 321 return compositingReasons; |
| 331 } | 322 } |
| 332 | 323 |
| 324 static FloatPoint3D transformOrigin(const LayoutBox& box) { |
| 325 const ComputedStyle& style = box.styleRef(); |
| 326 // Transform origin has no effect without a transform or motion path. |
| 327 if (!style.hasTransform()) |
| 328 return FloatPoint3D(); |
| 329 FloatSize borderBoxSize(box.size()); |
| 330 return FloatPoint3D( |
| 331 floatValueForLength(style.transformOriginX(), borderBoxSize.width()), |
| 332 floatValueForLength(style.transformOriginY(), borderBoxSize.height()), |
| 333 style.transformOriginZ()); |
| 334 } |
| 335 |
| 333 void PaintPropertyTreeBuilder::updateTransform( | 336 void PaintPropertyTreeBuilder::updateTransform( |
| 334 const LayoutObject& object, | 337 const LayoutObject& object, |
| 335 PaintPropertyTreeBuilderContext& context) { | 338 PaintPropertyTreeBuilderContext& context) { |
| 336 if (object.isSVG() && !object.isSVGRoot()) { | 339 if (object.isSVG() && !object.isSVGRoot()) { |
| 337 updateTransformForNonRootSVG(object, context); | 340 updateTransformForNonRootSVG(object, context); |
| 338 return; | 341 return; |
| 339 } | 342 } |
| 340 | 343 |
| 341 if (object.needsPaintPropertyUpdate() || context.forceSubtreeUpdate) { | 344 if (object.needsPaintPropertyUpdate() || context.forceSubtreeUpdate) { |
| 342 const ComputedStyle& style = object.styleRef(); | 345 const ComputedStyle& style = object.styleRef(); |
| 343 | 346 |
| 344 CompositingReasons compositingReasons = | 347 CompositingReasons compositingReasons = |
| 345 compositingReasonsForTransform(object); | 348 compositingReasonsForTransform(object); |
| 346 | 349 |
| 347 // A transform node is allocated for transforms, preserves-3d and any | 350 // A transform node is allocated for transforms, preserves-3d and any |
| 348 // direct compositing reason. The latter is required because this is the | 351 // direct compositing reason. The latter is required because this is the |
| 349 // only way to represent compositing both an element and its stacking | 352 // only way to represent compositing both an element and its stacking |
| 350 // descendants. | 353 // descendants. |
| 351 if (object.isBox() && (style.hasTransform() || style.preserves3D() || | 354 if (object.isBox() && (style.hasTransform() || style.preserves3D() || |
| 352 compositingReasons != CompositingReasonNone)) { | 355 compositingReasons != CompositingReasonNone)) { |
| 356 auto& box = toLayoutBox(object); |
| 353 TransformationMatrix matrix; | 357 TransformationMatrix matrix; |
| 354 style.applyTransform( | 358 style.applyTransform( |
| 355 matrix, toLayoutBox(object).size(), | 359 matrix, box.size(), ComputedStyle::ExcludeTransformOrigin, |
| 356 ComputedStyle::ExcludeTransformOrigin, | |
| 357 ComputedStyle::IncludeMotionPath, | 360 ComputedStyle::IncludeMotionPath, |
| 358 ComputedStyle::IncludeIndependentTransformProperties); | 361 ComputedStyle::IncludeIndependentTransformProperties); |
| 359 | 362 |
| 360 // TODO(trchen): transform-style should only be respected if a PaintLayer | 363 // TODO(trchen): transform-style should only be respected if a PaintLayer |
| 361 // is created. | 364 // is created. |
| 362 // If a node with transform-style: preserve-3d does not exist in an | 365 // If a node with transform-style: preserve-3d does not exist in an |
| 363 // existing rendering context, it establishes a new one. | 366 // existing rendering context, it establishes a new one. |
| 364 unsigned renderingContextID = context.current.renderingContextID; | 367 unsigned renderingContextID = context.current.renderingContextID; |
| 365 if (style.preserves3D() && !renderingContextID) | 368 if (style.preserves3D() && !renderingContextID) |
| 366 renderingContextID = PtrHash<const LayoutObject>::hash(&object); | 369 renderingContextID = PtrHash<const LayoutObject>::hash(&object); |
| 367 | 370 |
| 368 auto& properties = object.getMutableForPainting().ensurePaintProperties(); | 371 auto& properties = object.getMutableForPainting().ensurePaintProperties(); |
| 369 context.forceSubtreeUpdate |= properties.updateTransform( | 372 context.forceSubtreeUpdate |= properties.updateTransform( |
| 370 context.current.transform, matrix, | 373 context.current.transform, matrix, transformOrigin(box), |
| 371 transformOrigin(toLayoutBox(object)), | |
| 372 context.current.shouldFlattenInheritedTransform, renderingContextID, | 374 context.current.shouldFlattenInheritedTransform, renderingContextID, |
| 373 compositingReasons); | 375 compositingReasons); |
| 374 } else { | 376 } else { |
| 375 if (auto* properties = object.getMutableForPainting().paintProperties()) | 377 if (auto* properties = object.getMutableForPainting().paintProperties()) |
| 376 context.forceSubtreeUpdate |= properties->clearTransform(); | 378 context.forceSubtreeUpdate |= properties->clearTransform(); |
| 377 } | 379 } |
| 378 } | 380 } |
| 379 | 381 |
| 380 const auto* properties = object.paintProperties(); | 382 const auto* properties = object.paintProperties(); |
| 381 if (properties && properties->transform()) { | 383 if (properties && properties->transform()) { |
| (...skipping 581 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 963 updateOverflowClip(object, context); | 965 updateOverflowClip(object, context); |
| 964 updatePerspective(object, context); | 966 updatePerspective(object, context); |
| 965 updateSvgLocalToBorderBoxTransform(object, context); | 967 updateSvgLocalToBorderBoxTransform(object, context); |
| 966 updateScrollAndScrollTranslation(object, context); | 968 updateScrollAndScrollTranslation(object, context); |
| 967 updateOutOfFlowContext(object, context); | 969 updateOutOfFlowContext(object, context); |
| 968 | 970 |
| 969 context.forceSubtreeUpdate |= object.subtreeNeedsPaintPropertyUpdate(); | 971 context.forceSubtreeUpdate |= object.subtreeNeedsPaintPropertyUpdate(); |
| 970 } | 972 } |
| 971 | 973 |
| 972 } // namespace blink | 974 } // namespace blink |
| OLD | NEW |