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

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

Issue 2045253005: Re-implement SVG transform paint property nodes [spv2] (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address reviewer comments Created 4 years, 6 months 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 14aa29a03b460b5fe4b0900391879a882f030e7a..3c9c9a3194da0f30c38ec4a4772fc0a62c6fc744 100644
--- a/third_party/WebKit/Source/core/paint/PaintPropertyTreeBuilder.cpp
+++ b/third_party/WebKit/Source/core/paint/PaintPropertyTreeBuilder.cpp
@@ -9,6 +9,7 @@
#include "core/frame/Settings.h"
#include "core/layout/LayoutInline.h"
#include "core/layout/LayoutPart.h"
+#include "core/layout/svg/LayoutSVGRoot.h"
#include "core/paint/ObjectPaintProperties.h"
#include "core/paint/PaintLayer.h"
#include "platform/transforms/TransformationMatrix.h"
@@ -64,17 +65,14 @@ void PaintPropertyTreeBuilder::buildTreeNodes(FrameView& frameView, PaintPropert
void PaintPropertyTreeBuilder::updatePaintOffsetTranslation(const LayoutObject& object, PaintPropertyTreeBuilderContext& context)
{
- bool shouldCreatePaintOffsetTranslationNode = false;
- if (object.isSVGRoot()) {
- // SVG doesn't use paint offset internally so emit a paint offset at the html->svg boundary.
- shouldCreatePaintOffsetTranslationNode = true;
- } else if (object.isBoxModelObject()) {
+ if (object.isBoxModelObject()) {
// TODO(trchen): Eliminate PaintLayer dependency.
PaintLayer* layer = toLayoutBoxModelObject(object).layer();
- shouldCreatePaintOffsetTranslationNode = layer && layer->paintsWithTransform(GlobalPaintNormalPhase);
+ if (!layer || !layer->paintsWithTransform(GlobalPaintNormalPhase))
+ return;
}
- if (context.paintOffset == LayoutPoint() || !shouldCreatePaintOffsetTranslationNode)
+ if (context.paintOffset == LayoutPoint())
return;
RefPtr<TransformPaintPropertyNode> paintOffsetTranslation = TransformPaintPropertyNode::create(
@@ -97,6 +95,26 @@ static FloatPoint3D transformOrigin(const LayoutBox& box)
void PaintPropertyTreeBuilder::updateTransform(const LayoutObject& object, PaintPropertyTreeBuilderContext& context)
{
+ if (object.isSVG() && !object.isSVGRoot()) {
+ // SVG does not use paint offset internally and the root should have already accounted for
+ // any paint offset in the root's svgLocalToBorderBox transform.
+ DCHECK(context.paintOffset == LayoutPoint());
+
+ // TODO(pdr): Check for the presence of a transform instead of the value. Checking for an
+ // identity matrix will cause the property tree structure to change during animations if
+ // the animation passes through the identity matrix.
+ const AffineTransform& transform = object.localToSVGParentTransform();
+ if (transform.isIdentity())
+ return;
+
+ // The origin is included in the local transform, so use an empty origin.
+ RefPtr<TransformPaintPropertyNode> svgTransform = TransformPaintPropertyNode::create(
+ transform, FloatPoint3D(0, 0, 0), context.currentTransform);
+ context.currentTransform = svgTransform.get();
+ object.getMutableForPainting().ensureObjectPaintProperties().setTransform(svgTransform.release());
+ return;
+ }
+
const ComputedStyle& style = object.styleRef();
if (!object.isBox() || !style.hasTransform())
return;
@@ -232,20 +250,21 @@ void PaintPropertyTreeBuilder::updatePerspective(const LayoutObject& object, Pai
object.getMutableForPainting().ensureObjectPaintProperties().setPerspective(perspective.release());
}
-void PaintPropertyTreeBuilder::updateSvgLocalTransform(const LayoutObject& object, PaintPropertyTreeBuilderContext& context)
+void PaintPropertyTreeBuilder::updateSvgLocalToBorderBoxTransform(const LayoutObject& object, PaintPropertyTreeBuilderContext& context)
{
- if (!object.isSVG())
+ if (!object.isSVGRoot())
return;
- const AffineTransform& transform = object.localToSVGParentTransform();
+ AffineTransform transform = AffineTransform::translation(context.paintOffset.x().toFloat(), context.paintOffset.y().toFloat());
+ transform *= toLayoutSVGRoot(object).localToBorderBoxTransform();
if (transform.isIdentity())
return;
- // The origin is included in the local transform, so use an empty origin.
- RefPtr<TransformPaintPropertyNode> svgLocalTransform = TransformPaintPropertyNode::create(
+ RefPtr<TransformPaintPropertyNode> svgLocalToBorderBoxTransform = TransformPaintPropertyNode::create(
transform, FloatPoint3D(0, 0, 0), context.currentTransform);
- context.currentTransform = svgLocalTransform.get();
- object.getMutableForPainting().ensureObjectPaintProperties().setSvgLocalTransform(svgLocalTransform.release());
+ context.currentTransform = svgLocalToBorderBoxTransform.get();
+ context.paintOffset = LayoutPoint();
+ object.getMutableForPainting().ensureObjectPaintProperties().setSvgLocalToBorderBoxTransform(svgLocalToBorderBoxTransform.release());
}
void PaintPropertyTreeBuilder::updateScrollTranslation(const LayoutObject& object, PaintPropertyTreeBuilderContext& context)
@@ -344,7 +363,7 @@ static void deriveBorderBoxFromContainerContext(const LayoutObject& object, Pain
default:
ASSERT_NOT_REACHED();
}
- if (boxModelObject.isBox()) {
+ if (boxModelObject.isBox() && (!boxModelObject.isSVG() || boxModelObject.isSVGRoot())) {
// TODO(pdr): Several calls in this function walk back up the tree to calculate containers
// (e.g., topLeftLocation, offsetForInFlowPosition*). The containing block and other
// containers can be stored on PaintPropertyTreeBuilderContext instead of recomputing them.
@@ -379,7 +398,7 @@ void PaintPropertyTreeBuilder::buildTreeNodes(const LayoutObject& object, PaintP
// TODO(trchen): Insert flattening transform here, as specified by
// http://www.w3.org/TR/css3-transforms/#transform-style-property
updatePerspective(object, context);
- updateSvgLocalTransform(object, context);
+ updateSvgLocalToBorderBoxTransform(object, context);
updateScrollTranslation(object, context);
updateOutOfFlowContext(object, context);
}

Powered by Google App Engine
This is Rietveld 408576698