Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1792)

Unified Diff: third_party/WebKit/Source/core/paint/PaintPropertyTreeBuilder.cpp

Issue 2604973002: Move computation of 3D descendants to the descendant-dependent flags walk. (Closed)
Patch Set: none Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/paint/PaintPropertyTreeBuilder.cpp
diff --git a/third_party/WebKit/Source/core/paint/PaintPropertyTreeBuilder.cpp b/third_party/WebKit/Source/core/paint/PaintPropertyTreeBuilder.cpp
index 6baebf02bfb5a7794626ffa4a5af5af5d5137593..6c95d439fddb3c4c5e7d85ae30d9995da879b2fd 100644
--- a/third_party/WebKit/Source/core/paint/PaintPropertyTreeBuilder.cpp
+++ b/third_party/WebKit/Source/core/paint/PaintPropertyTreeBuilder.cpp
@@ -305,30 +305,24 @@ void PaintPropertyTreeBuilder::updateTransformForNonRootSVG(
}
}
-static CompositingReasons compositingReasonsForTransform(
- const LayoutObject& object) {
+static CompositingReasons compositingReasonsForTransform(const LayoutBox& box) {
+ const ComputedStyle& style = box.styleRef();
CompositingReasons compositingReasons = CompositingReasonNone;
- if (CompositingReasonFinder::requiresCompositingForTransform(object))
+ if (CompositingReasonFinder::requiresCompositingForTransform(box))
compositingReasons |= CompositingReason3DTransform;
- if (CompositingReasonFinder::requiresCompositingForTransformAnimation(
- object.styleRef()))
+ if (CompositingReasonFinder::requiresCompositingForTransformAnimation(style))
compositingReasons |= CompositingReasonActiveAnimation;
- if (object.styleRef().hasWillChangeCompositingHint() &&
- !object.styleRef().subtreeWillChangeContents())
+ if (style.hasWillChangeCompositingHint() &&
+ !style.subtreeWillChangeContents())
compositingReasons |= CompositingReasonWillChangeCompositingHint;
- if (object.isBoxModelObject()) {
- const LayoutBoxModelObject* box = toLayoutBoxModelObject(&object);
- if (box->hasLayer()) {
- // TODO(chrishtr): move this to the descendant-dependent flags recursion
- // PaintLayer::updateDescendantDependentFlags.
- box->layer()->update3DTransformedDescendantStatus();
-
- if (box->layer()->has3DTransformedDescendant())
- compositingReasons |= CompositingReason3DTransform;
- }
+ if (box.hasLayer() && box.layer()->has3DTransformedDescendant()) {
+ if (style.hasPerspective())
+ compositingReasons |= CompositingReasonPerspectiveWith3DDescendants;
+ if (style.usedTransformStyle3D() == TransformStyle3DPreserve3D)
+ compositingReasons |= CompositingReasonPreserve3DWith3DDescendants;
}
return compositingReasons;
@@ -357,36 +351,44 @@ void PaintPropertyTreeBuilder::updateTransform(
if (object.needsPaintPropertyUpdate() || context.forceSubtreeUpdate) {
const ComputedStyle& style = object.styleRef();
- CompositingReasons compositingReasons =
- compositingReasonsForTransform(object);
-
// A transform node is allocated for transforms, preserves-3d and any
// direct compositing reason. The latter is required because this is the
// only way to represent compositing both an element and its stacking
// descendants.
- if (object.isBox() && (style.hasTransform() || style.preserves3D() ||
- compositingReasons != CompositingReasonNone)) {
+ bool hasTransform = false;
+ if (object.isBox()) {
auto& box = toLayoutBox(object);
- TransformationMatrix matrix;
- style.applyTransform(
- matrix, box.size(), ComputedStyle::ExcludeTransformOrigin,
- ComputedStyle::IncludeMotionPath,
- ComputedStyle::IncludeIndependentTransformProperties);
-
- // TODO(trchen): transform-style should only be respected if a PaintLayer
- // is created.
- // If a node with transform-style: preserve-3d does not exist in an
- // existing rendering context, it establishes a new one.
- unsigned renderingContextID = context.current.renderingContextID;
- if (style.preserves3D() && !renderingContextID)
- renderingContextID = PtrHash<const LayoutObject>::hash(&object);
- auto& properties = object.getMutableForPainting().ensurePaintProperties();
- context.forceSubtreeUpdate |= properties.updateTransform(
- context.current.transform, matrix, transformOrigin(box),
- context.current.shouldFlattenInheritedTransform, renderingContextID,
- compositingReasons);
- } else {
+ CompositingReasons compositingReasons =
+ compositingReasonsForTransform(box);
+
+ if (style.hasTransform() || style.preserves3D() ||
+ compositingReasons != CompositingReasonNone) {
+ TransformationMatrix matrix;
+ style.applyTransform(
+ matrix, box.size(), ComputedStyle::ExcludeTransformOrigin,
+ ComputedStyle::IncludeMotionPath,
+ ComputedStyle::IncludeIndependentTransformProperties);
+
+ // TODO(trchen): transform-style should only be respected if a
+ // PaintLayer
+ // is created.
+ // If a node with transform-style: preserve-3d does not exist in an
+ // existing rendering context, it establishes a new one.
+ unsigned renderingContextID = context.current.renderingContextID;
+ if (style.preserves3D() && !renderingContextID)
+ renderingContextID = PtrHash<const LayoutObject>::hash(&object);
+
+ auto& properties =
+ object.getMutableForPainting().ensurePaintProperties();
+ context.forceSubtreeUpdate |= properties.updateTransform(
+ context.current.transform, matrix, transformOrigin(box),
+ context.current.shouldFlattenInheritedTransform, renderingContextID,
+ compositingReasons);
+ hasTransform = true;
+ }
+ }
+ if (!hasTransform) {
if (auto* properties = object.getMutableForPainting().paintProperties())
context.forceSubtreeUpdate |= properties->clearTransform();
}

Powered by Google App Engine
This is Rietveld 408576698