Chromium Code Reviews| 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 d0860a4a188193eaaaebbc0685d0f58a21805700..2af3cc968385df730db5275dc9507f20a76aea94 100644 |
| --- a/third_party/WebKit/Source/core/paint/PaintPropertyTreeBuilder.cpp |
| +++ b/third_party/WebKit/Source/core/paint/PaintPropertyTreeBuilder.cpp |
| @@ -119,6 +119,7 @@ void PaintPropertyTreeBuilder::updateTransform(const LayoutObject& object, Paint |
| return; |
| // The origin is included in the local transform, so use an empty origin. |
| + // TODO(jbroman, pdr): Handle flattening in SVG? |
|
trchen
2016/07/13 04:39:44
SVG doesn't support 3D transforms.
jbroman
2016/07/13 21:47:13
Oh good; that simplifies things. I guess I should
|
| RefPtr<TransformPaintPropertyNode> svgTransform = TransformPaintPropertyNode::create( |
| transform, FloatPoint3D(0, 0, 0), context.currentTransform); |
| context.currentTransform = svgTransform.get(); |
| @@ -126,15 +127,42 @@ void PaintPropertyTreeBuilder::updateTransform(const LayoutObject& object, Paint |
| return; |
| } |
| + if (!object.isBox()) |
| + return; |
| const ComputedStyle& style = object.styleRef(); |
| - if (!object.isBox() || !style.hasTransform()) |
| + if (!style.hasTransform() && !style.preserves3D()) |
| return; |
| TransformationMatrix matrix; |
| style.applyTransform(matrix, toLayoutBox(object).size(), ComputedStyle::ExcludeTransformOrigin, |
| ComputedStyle::IncludeMotionPath, ComputedStyle::IncludeIndependentTransformProperties); |
| + |
| + DCHECK(context.currentTransform); |
| + const TransformPaintPropertyNode* renderingContextRoot = |
| + context.currentTransform->preserves3D() |
| + ? context.currentTransform->renderingContextRoot() : nullptr; |
| + |
| + // These variables must be initialized to make MSVC happy. |
| + TransformPaintPropertyNode::TransformStyle transformStyle = |
| + TransformPaintPropertyNode::FlattenTransform; |
| + TransformPaintPropertyNode::RenderingContextBehavior renderingContextBehavior = |
| + TransformPaintPropertyNode::DontEstablishNewRenderingContext; |
| + switch (style.transformStyle3D()) { |
| + case TransformStyle3DFlat: |
|
chrishtr
2016/07/13 20:30:50
Given the requirement to initialize for MSVC, migh
|
| + transformStyle = TransformPaintPropertyNode::FlattenTransform; |
| + break; |
| + case TransformStyle3DPreserve3D: |
| + transformStyle = TransformPaintPropertyNode::Preserve3D; |
| + // If a node with transform-style: preserve-3d does not exist in an |
| + // existing rendering context, it establishes a new one. |
| + if (!renderingContextRoot) |
| + renderingContextBehavior = TransformPaintPropertyNode::EstablishNewRenderingContext; |
| + break; |
| + } |
| + |
| RefPtr<TransformPaintPropertyNode> transformNode = TransformPaintPropertyNode::create( |
| - matrix, transformOrigin(toLayoutBox(object)), context.currentTransform); |
| + matrix, transformOrigin(toLayoutBox(object)), context.currentTransform, |
| + renderingContextBehavior, renderingContextRoot, transformStyle); |
| context.currentTransform = transformNode.get(); |
| object.getMutableForPainting().ensureObjectPaintProperties().setTransform(transformNode.release()); |
| } |
| @@ -249,10 +277,17 @@ void PaintPropertyTreeBuilder::updatePerspective(const LayoutObject& object, Pai |
| if (!object.isBox() || !style.hasPerspective()) |
| return; |
| + // The perspective node must not flatten (else nothing will get |
| + // perspective), but it should still extend the rendering context as most |
| + // transform nodes do. |
| + DCHECK(context.currentTransform); |
| RefPtr<TransformPaintPropertyNode> perspective = TransformPaintPropertyNode::create( |
| TransformationMatrix().applyPerspective(style.perspective()), |
| perspectiveOrigin(toLayoutBox(object)) + toLayoutSize(context.paintOffset), |
| - context.currentTransform); |
| + context.currentTransform, |
| + TransformPaintPropertyNode::DontEstablishNewRenderingContext, |
| + context.currentTransform->renderingContextRoot(), |
| + TransformPaintPropertyNode::Preserve3D); |
| context.currentTransform = perspective.get(); |
| object.getMutableForPainting().ensureObjectPaintProperties().setPerspective(perspective.release()); |
| } |