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 1d394cb7cd37438feba099574ccad966af718cfb..c643b6c4d462dcffc0244a145769c68e5f550fb8 100644 |
| --- a/third_party/WebKit/Source/core/paint/PaintPropertyTreeBuilder.cpp |
| +++ b/third_party/WebKit/Source/core/paint/PaintPropertyTreeBuilder.cpp |
| @@ -19,9 +19,27 @@ |
| namespace blink { |
| +namespace { |
| + |
| +// Creates a transform node which uses the current rendering context ID and |
| +// flattening behavior from the tree builder context. |
| +PassRefPtr<TransformPaintPropertyNode> createTransformNode( |
| + const PaintPropertyTreeBuilderContext& context, |
| + const TransformationMatrix& matrix, |
| + const FloatPoint3D& origin, |
| + PassRefPtr<TransformPaintPropertyNode> parent) |
| +{ |
| + return TransformPaintPropertyNode::create( |
| + matrix, origin, parent, |
| + context.current.shouldFlattenInheritedTransform, |
| + context.current.renderingContextID); |
| +} |
| + |
| +} // namespace |
| + |
| void PaintPropertyTreeBuilder::buildTreeRootNodes(FrameView& rootFrame, PaintPropertyTreeBuilderContext& context) |
| { |
| - RefPtr<TransformPaintPropertyNode> transformRoot = TransformPaintPropertyNode::create(TransformationMatrix(), FloatPoint3D(), nullptr); |
| + RefPtr<TransformPaintPropertyNode> transformRoot = TransformPaintPropertyNode::create(TransformationMatrix(), FloatPoint3D(), nullptr, true); |
| context.current.transform = context.absolutePosition.transform = context.fixedPosition.transform = transformRoot.get(); |
| rootFrame.setRootTransform(std::move(transformRoot)); |
| @@ -42,7 +60,7 @@ void PaintPropertyTreeBuilder::buildTreeNodes(FrameView& frameView, PaintPropert |
| TransformationMatrix frameTranslate; |
| frameTranslate.translate(frameView.x() + context.current.paintOffset.x(), frameView.y() + context.current.paintOffset.y()); |
| - RefPtr<TransformPaintPropertyNode> newTransformNodeForPreTranslation = TransformPaintPropertyNode::create(frameTranslate, FloatPoint3D(), context.current.transform); |
| + RefPtr<TransformPaintPropertyNode> newTransformNodeForPreTranslation = createTransformNode(context, frameTranslate, FloatPoint3D(), context.current.transform); |
| FloatRoundedRect contentClip(IntRect(IntPoint(), frameView.visibleContentSize())); |
| RefPtr<ClipPaintPropertyNode> newClipNodeForContentClip = ClipPaintPropertyNode::create(newTransformNodeForPreTranslation.get(), contentClip, context.current.clip); |
| @@ -58,6 +76,8 @@ void PaintPropertyTreeBuilder::buildTreeNodes(FrameView& frameView, PaintPropert |
| context.current.transform = newTransformNodeForScrollTranslation.get(); |
| context.current.paintOffset = LayoutPoint(); |
| context.current.clip = newClipNodeForContentClip.get(); |
| + context.current.renderingContextID = 0; |
| + context.current.shouldFlattenInheritedTransform = true; |
| context.absolutePosition = context.current; |
| context.containerForAbsolutePosition = nullptr; |
| context.fixedPosition = context.current; |
| @@ -88,11 +108,13 @@ void PaintPropertyTreeBuilder::updatePaintOffsetTranslation(const LayoutObject& |
| IntPoint roundedPaintOffset = roundedIntPoint(context.current.paintOffset); |
| LayoutPoint fractionalPaintOffset = LayoutPoint(context.current.paintOffset - roundedPaintOffset); |
| - RefPtr<TransformPaintPropertyNode> paintOffsetTranslation = TransformPaintPropertyNode::create( |
| + RefPtr<TransformPaintPropertyNode> paintOffsetTranslation = createTransformNode( |
| + context, |
| TransformationMatrix().translate(roundedPaintOffset.x(), roundedPaintOffset.y()), |
| FloatPoint3D(), context.current.transform); |
| context.current.transform = paintOffsetTranslation.get(); |
| context.current.paintOffset = fractionalPaintOffset; |
| + context.current.shouldFlattenInheritedTransform = false; |
| object.getMutableForPainting().ensureObjectPaintProperties().setPaintOffsetTranslation(paintOffsetTranslation.release()); |
| } |
| @@ -124,20 +146,42 @@ void PaintPropertyTreeBuilder::updateTransform(const LayoutObject& object, Paint |
| RefPtr<TransformPaintPropertyNode> svgTransform = TransformPaintPropertyNode::create( |
| transform, FloatPoint3D(0, 0, 0), context.current.transform); |
| context.current.transform = svgTransform.get(); |
| + context.current.renderingContextID = 0; |
| + context.current.shouldFlattenInheritedTransform = false; |
| object.getMutableForPainting().ensureObjectPaintProperties().setTransform(svgTransform.release()); |
| 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); |
| + |
| + unsigned renderingContextID = context.current.renderingContextID; |
| + unsigned renderingContextIDForChildren = 0; |
| + bool flattensInheritedTransform = context.current.shouldFlattenInheritedTransform; |
| + bool childrenFlattenInheritedTransform = true; |
| + |
| + if (style.preserves3D()) { |
| + // If a node with transform-style: preserve-3d does not exist in an |
| + // existing rendering context, it establishes a new one. |
| + if (!renderingContextID) |
| + renderingContextID = PtrHash<const LayoutObject>::hash(&object); |
| + renderingContextIDForChildren = renderingContextID; |
| + childrenFlattenInheritedTransform = false; |
|
trchen
2016/07/19 22:19:42
Note: transform-style should be respected if and o
jbroman
2016/07/20 15:30:56
Are you asking for a TODO, a bug, or would you lik
|
| + } |
| + |
| RefPtr<TransformPaintPropertyNode> transformNode = TransformPaintPropertyNode::create( |
| - matrix, transformOrigin(toLayoutBox(object)), context.current.transform); |
| + matrix, transformOrigin(toLayoutBox(object)), context.current.transform, |
| + flattensInheritedTransform, renderingContextID); |
| context.current.transform = transformNode.get(); |
| + context.current.renderingContextID = renderingContextIDForChildren; |
| + context.current.shouldFlattenInheritedTransform = childrenFlattenInheritedTransform; |
| object.getMutableForPainting().ensureObjectPaintProperties().setTransform(transformNode.release()); |
| } |
| @@ -251,11 +295,17 @@ void PaintPropertyTreeBuilder::updatePerspective(const LayoutObject& object, Pai |
| if (!object.isBox() || !style.hasPerspective()) |
| return; |
| - RefPtr<TransformPaintPropertyNode> perspective = TransformPaintPropertyNode::create( |
| + // The perspective node must not flatten (else nothing will get |
| + // perspective), but it should still extend the rendering context as most |
| + // transform nodes do. |
| + RefPtr<TransformPaintPropertyNode> perspective = createTransformNode( |
| + context, |
| TransformationMatrix().applyPerspective(style.perspective()), |
| perspectiveOrigin(toLayoutBox(object)) + toLayoutSize(context.current.paintOffset), |
| context.current.transform); |
| context.current.transform = perspective.get(); |
| + context.current.shouldFlattenInheritedTransform = false; |
| + |
| object.getMutableForPainting().ensureObjectPaintProperties().setPerspective(perspective.release()); |
| } |
| @@ -277,6 +327,8 @@ void PaintPropertyTreeBuilder::updateSvgLocalToBorderBoxTransform(const LayoutOb |
| transformToBorderBox, FloatPoint3D(0, 0, 0), context.current.transform); |
| context.current.transform = svgLocalToBorderBoxTransform.get(); |
| context.current.paintOffset = LayoutPoint(); |
| + context.current.renderingContextID = 0; |
| + context.current.shouldFlattenInheritedTransform = false; |
| object.getMutableForPainting().ensureObjectPaintProperties().setSvgLocalToBorderBoxTransform(svgLocalToBorderBoxTransform.release()); |
| } |
| @@ -291,11 +343,13 @@ void PaintPropertyTreeBuilder::updateScrollTranslation(const LayoutObject& objec |
| if (scrollOffset.isZero() && !layer->scrollsOverflow()) |
| return; |
| - RefPtr<TransformPaintPropertyNode> scrollTranslation = TransformPaintPropertyNode::create( |
| + RefPtr<TransformPaintPropertyNode> scrollTranslation = createTransformNode( |
| + context, |
| TransformationMatrix().translate(-scrollOffset.width(), -scrollOffset.height()), |
| FloatPoint3D(), |
| context.current.transform); |
| context.current.transform = scrollTranslation.get(); |
| + context.current.shouldFlattenInheritedTransform = false; |
| object.getMutableForPainting().ensureObjectPaintProperties().setScrollTranslation(scrollTranslation.release()); |
| } |
| @@ -399,8 +453,6 @@ void PaintPropertyTreeBuilder::buildTreeNodes(const LayoutObject& object, PaintP |
| updateLocalBorderBoxContext(object, context); |
| updateScrollbarPaintOffset(object, context); |
| updateOverflowClip(object, context); |
| - // TODO(trchen): Insert flattening transform here, as specified by |
| - // http://www.w3.org/TR/css3-transforms/#transform-style-property |
| updatePerspective(object, context); |
| updateSvgLocalToBorderBoxTransform(object, context); |
| updateScrollTranslation(object, context); |