Title: [292690] trunk/Source/WebCore
Revision
292690
Author
[email protected]
Date
2022-04-10 15:51:52 -0700 (Sun, 10 Apr 2022)

Log Message

[LBSE] Activate SVG transform support through layers
https://bugs.webkit.org/show_bug.cgi?id=237711

Reviewed by Rob Buis.

Activate transforms for SVG layers.

Use the flag to keep track of the presence of SVG transformations
on a renderer. CSS/HTML renderers can rely only on the RenderStyle
to determine if transformations are applied, whereas SVG has to
consult additional sources, such as the SVG 'transform' attribute.

A SVG renderer with the 'HasSVGTransform' flag set should behave
like any SVG/HTML renderer that has CSS transformations applied.

With this patch applied SVG transform and CSS transforms can
be applied to <g> / <rect> elements in LBSE. However, the order
of the matrix multiplication is not correct yet for SVG -- that
will be adressed in a follow-up patch.

Covered by existing tests, no change in behaviour.

* platform/graphics/transforms/TransformationMatrix.cpp:
(WebCore::TransformationMatrix::multiplyAffineTransform):
* platform/graphics/transforms/TransformationMatrix.h:
* rendering/RenderBox.cpp:
(WebCore::RenderBox::updateLayerTransform): Deleted.
* rendering/RenderBox.h:
* rendering/RenderLayer.cpp:
(WebCore::canCreateStackingContext):
(WebCore::RenderLayer::currentTransform const):
* rendering/RenderLayerModelObject.cpp:
(WebCore::RenderLayerModelObject::updateLayerTransform):
(WebCore::RenderLayerModelObject::applySVGTransform const):
* rendering/RenderLayerModelObject.h:
* rendering/RenderObject.cpp:
(WebCore::RenderObject::setHasSVGTransform):
* rendering/RenderObject.h:
(WebCore::RenderObject::hasSVGTransform const):
(WebCore::RenderObject::hasTransform const):
* rendering/svg/RenderSVGContainer.cpp:
(WebCore::SVGLayerTransformUpdater::SVGLayerTransformUpdater):
(WebCore::SVGLayerTransformUpdater::~SVGLayerTransformUpdater):
(WebCore::RenderSVGContainer::layout):
* rendering/svg/RenderSVGContainer.h:
(WebCore::RenderSVGContainer::updateLayerInformation): Deleted.
* rendering/svg/RenderSVGModelObject.cpp:
(WebCore::RenderSVGModelObject::updateFromStyle):
* rendering/svg/RenderSVGRoot.cpp:
(WebCore::RenderSVGRoot::updateFromStyle):
* rendering/svg/RenderSVGShape.cpp:
(WebCore::RenderSVGShape::layout):
(WebCore::RenderSVGShape::applyTransform const):
* rendering/svg/RenderSVGShape.h:
* rendering/svg/RenderSVGTransformableContainer.cpp:
(WebCore::RenderSVGTransformableContainer::updateFromStyle):
(WebCore::RenderSVGTransformableContainer::applyTransform const):
* svg/SVGGraphicsElement.cpp:
(WebCore::SVGGraphicsElement::animatedLocalTransform const):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (292689 => 292690)


--- trunk/Source/WebCore/ChangeLog	2022-04-10 21:56:21 UTC (rev 292689)
+++ trunk/Source/WebCore/ChangeLog	2022-04-10 22:51:52 UTC (rev 292690)
@@ -1,3 +1,65 @@
+2022-04-10  Nikolas Zimmermann  <[email protected]>
+
+        [LBSE] Activate SVG transform support through layers
+        https://bugs.webkit.org/show_bug.cgi?id=237711
+
+        Reviewed by Rob Buis.
+
+        Activate transforms for SVG layers.
+
+        Use the flag to keep track of the presence of SVG transformations
+        on a renderer. CSS/HTML renderers can rely only on the RenderStyle
+        to determine if transformations are applied, whereas SVG has to
+        consult additional sources, such as the SVG 'transform' attribute.
+
+        A SVG renderer with the 'HasSVGTransform' flag set should behave
+        like any SVG/HTML renderer that has CSS transformations applied.
+
+        With this patch applied SVG transform and CSS transforms can
+        be applied to <g> / <rect> elements in LBSE. However, the order
+        of the matrix multiplication is not correct yet for SVG -- that
+        will be adressed in a follow-up patch.
+
+        Covered by existing tests, no change in behaviour.
+
+        * platform/graphics/transforms/TransformationMatrix.cpp:
+        (WebCore::TransformationMatrix::multiplyAffineTransform):
+        * platform/graphics/transforms/TransformationMatrix.h:
+        * rendering/RenderBox.cpp:
+        (WebCore::RenderBox::updateLayerTransform): Deleted.
+        * rendering/RenderBox.h:
+        * rendering/RenderLayer.cpp:
+        (WebCore::canCreateStackingContext):
+        (WebCore::RenderLayer::currentTransform const):
+        * rendering/RenderLayerModelObject.cpp:
+        (WebCore::RenderLayerModelObject::updateLayerTransform):
+        (WebCore::RenderLayerModelObject::applySVGTransform const):
+        * rendering/RenderLayerModelObject.h:
+        * rendering/RenderObject.cpp:
+        (WebCore::RenderObject::setHasSVGTransform):
+        * rendering/RenderObject.h:
+        (WebCore::RenderObject::hasSVGTransform const):
+        (WebCore::RenderObject::hasTransform const):
+        * rendering/svg/RenderSVGContainer.cpp:
+        (WebCore::SVGLayerTransformUpdater::SVGLayerTransformUpdater):
+        (WebCore::SVGLayerTransformUpdater::~SVGLayerTransformUpdater):
+        (WebCore::RenderSVGContainer::layout):
+        * rendering/svg/RenderSVGContainer.h:
+        (WebCore::RenderSVGContainer::updateLayerInformation): Deleted.
+        * rendering/svg/RenderSVGModelObject.cpp:
+        (WebCore::RenderSVGModelObject::updateFromStyle):
+        * rendering/svg/RenderSVGRoot.cpp:
+        (WebCore::RenderSVGRoot::updateFromStyle):
+        * rendering/svg/RenderSVGShape.cpp:
+        (WebCore::RenderSVGShape::layout):
+        (WebCore::RenderSVGShape::applyTransform const):
+        * rendering/svg/RenderSVGShape.h:
+        * rendering/svg/RenderSVGTransformableContainer.cpp:
+        (WebCore::RenderSVGTransformableContainer::updateFromStyle):
+        (WebCore::RenderSVGTransformableContainer::applyTransform const):
+        * svg/SVGGraphicsElement.cpp:
+        (WebCore::SVGGraphicsElement::animatedLocalTransform const):
+
 2022-04-10  Alan Bujtas  <[email protected]>
 
         Line clamp specific line-count code should be in RenderDeprecatedFlexibleBox

Modified: trunk/Source/WebCore/platform/graphics/transforms/TransformationMatrix.cpp (292689 => 292690)


--- trunk/Source/WebCore/platform/graphics/transforms/TransformationMatrix.cpp	2022-04-10 21:56:21 UTC (rev 292689)
+++ trunk/Source/WebCore/platform/graphics/transforms/TransformationMatrix.cpp	2022-04-10 22:51:52 UTC (rev 292690)
@@ -1533,6 +1533,17 @@
     return *this;
 }
 
+TransformationMatrix& TransformationMatrix::multiplyAffineTransform(const AffineTransform& matrix)
+{
+    if (matrix.isIdentity())
+        return *this;
+
+    if (matrix.isIdentityOrTranslation())
+        return translate(matrix.e(), matrix.f());
+
+    return multiply(matrix.toTransformationMatrix());
+}
+
 void TransformationMatrix::multVecMatrix(double x, double y, double& resultX, double& resultY) const
 {
     resultX = m_matrix[3][0] + x * m_matrix[0][0] + y * m_matrix[1][0];

Modified: trunk/Source/WebCore/platform/graphics/transforms/TransformationMatrix.h (292689 => 292690)


--- trunk/Source/WebCore/platform/graphics/transforms/TransformationMatrix.h	2022-04-10 21:56:21 UTC (rev 292689)
+++ trunk/Source/WebCore/platform/graphics/transforms/TransformationMatrix.h	2022-04-10 22:51:52 UTC (rev 292690)
@@ -249,6 +249,8 @@
 
     // this = mat * this.
     WEBCORE_EXPORT TransformationMatrix& multiply(const TransformationMatrix&);
+    // Identical to multiply(TransformationMatrix&), but saving a AffineTransform -> TransformationMatrix roundtrip for identity or translation matrices.
+    TransformationMatrix& multiplyAffineTransform(const AffineTransform&);
 
     WEBCORE_EXPORT TransformationMatrix& scale(double);
     WEBCORE_EXPORT TransformationMatrix& scaleNonUniform(double sx, double sy);

Modified: trunk/Source/WebCore/rendering/RenderBox.cpp (292689 => 292690)


--- trunk/Source/WebCore/rendering/RenderBox.cpp	2022-04-10 21:56:21 UTC (rev 292689)
+++ trunk/Source/WebCore/rendering/RenderBox.cpp	2022-04-10 22:51:52 UTC (rev 292690)
@@ -667,13 +667,6 @@
     quads.append(localToAbsoluteQuad(localRect, UseTransforms, wasFixed));
 }
 
-void RenderBox::updateLayerTransform()
-{
-    // Transform-origin depends on box size, so we need to update the layer transform after layout.
-    if (hasLayer())
-        layer()->updateTransform();
-}
-
 void RenderBox::applyTransform(TransformationMatrix& t, const RenderStyle& style, const FloatRect& boundingBox, OptionSet<RenderStyle::TransformOperationOption> options) const
 {
     style.applyTransform(t, boundingBox, options);

Modified: trunk/Source/WebCore/rendering/RenderBox.h (292689 => 292690)


--- trunk/Source/WebCore/rendering/RenderBox.h	2022-04-10 21:56:21 UTC (rev 292689)
+++ trunk/Source/WebCore/rendering/RenderBox.h	2022-04-10 22:51:52 UTC (rev 292690)
@@ -218,7 +218,6 @@
     void addOverflowFromChild(const RenderBox* child) { addOverflowFromChild(child, child->locationOffset()); }
     void addOverflowFromChild(const RenderBox* child, const LayoutSize& delta);
 
-    void updateLayerTransform();
     void applyTransform(TransformationMatrix&, const RenderStyle&, const FloatRect& boundingBox, OptionSet<RenderStyle::TransformOperationOption> = RenderStyle::allTransformOperations) const override;
 
     LayoutSize contentSize() const { return { contentWidth(), contentHeight() }; }

Modified: trunk/Source/WebCore/rendering/RenderLayer.cpp (292689 => 292690)


--- trunk/Source/WebCore/rendering/RenderLayer.cpp	2022-04-10 21:56:21 UTC (rev 292689)
+++ trunk/Source/WebCore/rendering/RenderLayer.cpp	2022-04-10 22:51:52 UTC (rev 292690)
@@ -552,6 +552,9 @@
 {
     auto& renderer = layer.renderer();
     return renderer.hasTransformRelatedProperty()
+#if ENABLE(LAYER_BASED_SVG_ENGINE)
+        || renderer.hasSVGTransform()
+#endif
         || renderer.hasClipPath()
         || renderer.hasFilter()
         || renderer.hasMask()
@@ -1357,19 +1360,13 @@
     if (!m_transform)
         return { };
 
-    // FIXME: [LBSE] Upstream transform support for RenderSVGModelObject derived renderers
-    if (!is<RenderBox>(renderer()))
-        return { };
-
-    auto& renderBox = downcast<RenderBox>(renderer());
-
     // m_transform includes transform-origin and is affected by the choice of the transform-box.
     // Therefore we can only use the cached m_transform, if the animation doesn't alter transform-box or excludes transform-origin.
 
     // Query the animatedStyle() to obtain the current transformation, when accelerated transform animations are running.
-    auto styleable = Styleable::fromRenderer(renderBox);
+    auto styleable = Styleable::fromRenderer(renderer());
     if ((styleable && styleable->isRunningAcceleratedTransformAnimation()) || !options.contains(RenderStyle::TransformOperationOption::TransformOrigin)) {
-        std::unique_ptr<RenderStyle> animatedStyle = renderBox.animatedStyle();
+        std::unique_ptr<RenderStyle> animatedStyle = renderer().animatedStyle();
 
         TransformationMatrix transform;
         updateTransformFromStyle(transform, *animatedStyle, options);

Modified: trunk/Source/WebCore/rendering/RenderLayerModelObject.cpp (292689 => 292690)


--- trunk/Source/WebCore/rendering/RenderLayerModelObject.cpp	2022-04-10 21:56:21 UTC (rev 292689)
+++ trunk/Source/WebCore/rendering/RenderLayerModelObject.cpp	2022-04-10 22:51:52 UTC (rev 292690)
@@ -31,6 +31,7 @@
 #include "RenderLayerScrollableArea.h"
 #include "RenderSVGModelObject.h"
 #include "RenderView.h"
+#include "SVGGraphicsElement.h"
 #include "Settings.h"
 #include "StyleScrollSnapPoints.h"
 #include "TransformState.h"
@@ -231,6 +232,13 @@
     layer()->backing()->suspendAnimations(time);
 }
 
+void RenderLayerModelObject::updateLayerTransform()
+{
+    // Transform-origin depends on box size, so we need to update the layer transform after layout.
+    if (hasLayer())
+        layer()->updateTransform();
+}
+
 #if ENABLE(LAYER_BASED_SVG_ENGINE)
 std::optional<LayoutRect> RenderLayerModelObject::computeVisibleRectInSVGContainer(const LayoutRect& rect, const RenderLayerModelObject* container, RenderObject::VisibleRectContext context) const
 {
@@ -316,6 +324,38 @@
 
     container->mapLocalToContainer(ancestorContainer, transformState, mode, wasFixed);
 }
+
+void RenderLayerModelObject::applySVGTransform(TransformationMatrix& transform, SVGGraphicsElement& graphicsElement, const RenderStyle& style, const FloatRect& boundingBox, OptionSet<RenderStyle::TransformOperationOption> options) const
+{
+    // This check does not use style.hasTransformRelatedProperty() on purpose -- we only want to know if either the 'transform' property, an
+    // offset path, or the individual transform operations are set (perspective / transform-style: preserve-3d are not relevant here).
+    bool hasCSSTransform = style.hasTransform() || style.rotate() || style.translate() || style.scale();
+
+    bool affectedByTransformOrigin = false;
+    std::optional<AffineTransform> svgTransform;
+
+    if (hasCSSTransform)
+        affectedByTransformOrigin = style.affectedByTransformOrigin();
+    else if (auto affineTransform = graphicsElement.animatedLocalTransform(); !affineTransform.isIdentity()) {
+        svgTransform = affineTransform;
+        affectedByTransformOrigin = affineTransform.a() != 1 || affineTransform.b() || affineTransform.c() || affineTransform.d() != 1;
+    }
+
+    if (!hasCSSTransform && !svgTransform.has_value())
+        return;
+
+    FloatPoint3D originTranslate;
+    if (options.contains(RenderStyle::TransformOperationOption::TransformOrigin) && affectedByTransformOrigin)
+        originTranslate = style.applyTransformOrigin(transform, boundingBox);
+
+    // CSS transforms take precedence over SVG transforms.
+    if (hasCSSTransform)
+        style.applyCSSTransform(transform, boundingBox, options);
+    else
+        transform.multiplyAffineTransform(svgTransform.value());
+
+    style.unapplyTransformOrigin(transform, originTranslate);
+}
 #endif
 
 bool rendererNeedsPixelSnapping(const RenderLayerModelObject& renderer)

Modified: trunk/Source/WebCore/rendering/RenderLayerModelObject.h (292689 => 292690)


--- trunk/Source/WebCore/rendering/RenderLayerModelObject.h	2022-04-10 21:56:21 UTC (rev 292689)
+++ trunk/Source/WebCore/rendering/RenderLayerModelObject.h	2022-04-10 22:51:52 UTC (rev 292690)
@@ -28,6 +28,7 @@
 
 class KeyframeList;
 class RenderLayer;
+class SVGGraphicsElement;
 
 struct LayerRepaintRects {
     LayoutRect clippedOverflowRect;
@@ -75,8 +76,12 @@
     // Provides the SVG implementation for mapLocalToContainer().
     // This lives in RenderLayerModelObject, which is the common base-class for all SVG renderers.
     void mapLocalToSVGContainer(const RenderLayerModelObject* ancestorContainer, TransformState&, OptionSet<MapCoordinatesMode>, bool* wasFixed) const;
+
+    void applySVGTransform(TransformationMatrix&, SVGGraphicsElement&, const RenderStyle&, const FloatRect& boundingBox, OptionSet<RenderStyle::TransformOperationOption>) const;
 #endif
 
+    void updateLayerTransform();
+
     virtual void applyTransform(TransformationMatrix&, const RenderStyle&, const FloatRect& boundingBox, OptionSet<RenderStyle::TransformOperationOption> = RenderStyle::allTransformOperations) const = 0;
 
 protected:

Modified: trunk/Source/WebCore/rendering/RenderObject.cpp (292689 => 292690)


--- trunk/Source/WebCore/rendering/RenderObject.cpp	2022-04-10 21:56:21 UTC (rev 292689)
+++ trunk/Source/WebCore/rendering/RenderObject.cpp	2022-04-10 22:51:52 UTC (rev 292690)
@@ -1987,6 +1987,14 @@
         ensureRareData().setHasOutlineAutoAncestor(hasOutlineAutoAncestor);
 }
 
+#if ENABLE(LAYER_BASED_SVG_ENGINE)
+void RenderObject::setHasSVGTransform(bool hasSVGTransform)
+{
+    if (hasSVGTransform || hasRareData())
+        ensureRareData().setHasSVGTransform(hasSVGTransform);
+}
+#endif
+
 void RenderObject::setPaintContainmentApplies(bool paintContainmentApplies)
 {
     if (paintContainmentApplies || hasRareData())

Modified: trunk/Source/WebCore/rendering/RenderObject.h (292689 => 292690)


--- trunk/Source/WebCore/rendering/RenderObject.h	2022-04-10 21:56:21 UTC (rev 292689)
+++ trunk/Source/WebCore/rendering/RenderObject.h	2022-04-10 22:51:52 UTC (rev 292690)
@@ -416,6 +416,12 @@
     bool hasOutlineAutoAncestor() const { return m_bitfields.hasRareData() && rareData().hasOutlineAutoAncestor(); }
     bool paintContainmentApplies() const { return m_bitfields.hasRareData() && rareData().paintContainmentApplies(); }
 
+#if ENABLE(LAYER_BASED_SVG_ENGINE)
+    bool hasSVGTransform() const { return m_bitfields.hasRareData() && rareData().hasSVGTransform(); }
+#else
+    bool hasSVGTransform() const { return false; }
+#endif
+
     bool isExcludedFromNormalLayout() const { return m_bitfields.isExcludedFromNormalLayout(); }
     void setIsExcludedFromNormalLayout(bool excluded) { m_bitfields.setIsExcludedFromNormalLayout(excluded); }
     bool isExcludedAndPlacedInBorder() const { return isExcludedFromNormalLayout() && isLegend(); }
@@ -450,7 +456,7 @@
     bool hasPotentiallyScrollableOverflow() const;
 
     bool hasTransformRelatedProperty() const { return m_bitfields.hasTransformRelatedProperty(); } // Transform, perspective or transform-style: preserve-3d.
-    bool hasTransform() const { return hasTransformRelatedProperty() && (style().hasTransform() || style().translate() || style().scale() || style().rotate()); }
+    bool hasTransform() const { return hasTransformRelatedProperty() && (style().hasTransform() || style().translate() || style().scale() || style().rotate() || hasSVGTransform()); }
     bool hasTransformOrPespective() const { return hasTransformRelatedProperty() && (hasTransform() || style().hasPerspective()); }
 
     inline bool preservesNewline() const;
@@ -515,6 +521,9 @@
     void setIsRenderFragmentedFlow(bool = true);
     void setHasOutlineAutoAncestor(bool = true);
     void setPaintContainmentApplies(bool = true);
+#if ENABLE(LAYER_BASED_SVG_ENGINE)
+    void setHasSVGTransform(bool = true);
+#endif
 
     // Hook so that RenderTextControl can return the line height of its inner renderer.
     // For other renderers, the value is the same as lineHeight(false).
@@ -944,6 +953,9 @@
         ADD_BOOLEAN_BITFIELD(isRenderFragmentedFlow, IsRenderFragmentedFlow);
         ADD_BOOLEAN_BITFIELD(hasOutlineAutoAncestor, HasOutlineAutoAncestor);
         ADD_BOOLEAN_BITFIELD(paintContainmentApplies, PaintContainmentApplies);
+#if ENABLE(LAYER_BASED_SVG_ENGINE)
+        ADD_BOOLEAN_BITFIELD(hasSVGTransform, HasSVGTransform);
+#endif
 
         // From RenderElement
         std::unique_ptr<ReferencedSVGResources> referencedSVGResources;

Modified: trunk/Source/WebCore/rendering/svg/RenderSVGContainer.cpp (292689 => 292690)


--- trunk/Source/WebCore/rendering/svg/RenderSVGContainer.cpp	2022-04-10 21:56:21 UTC (rev 292689)
+++ trunk/Source/WebCore/rendering/svg/RenderSVGContainer.cpp	2022-04-10 22:51:52 UTC (rev 292690)
@@ -52,6 +52,36 @@
 
 RenderSVGContainer::~RenderSVGContainer() = default;
 
+// Helper class, move to its own file once utilized in more than one place.
+class SVGLayerTransformUpdater {
+    WTF_MAKE_NONCOPYABLE(SVGLayerTransformUpdater);
+public:
+    SVGLayerTransformUpdater(RenderLayerModelObject& renderer)
+        : m_renderer(renderer)
+    {
+        if (!m_renderer.hasLayer())
+            return;
+
+        m_transformReferenceBox = m_renderer.transformReferenceBoxRect();
+        m_renderer.updateLayerTransform();
+    }
+
+
+    ~SVGLayerTransformUpdater()
+    {
+        if (!m_renderer.hasLayer())
+            return;
+        if (m_renderer.transformReferenceBoxRect() == m_transformReferenceBox)
+            return;
+
+        m_renderer.updateLayerTransform();
+    }
+
+private:
+    RenderLayerModelObject& m_renderer;
+    FloatRect m_transformReferenceBox;
+};
+
 void RenderSVGContainer::layout()
 {
     StackStats::LayoutCheckPoint layoutCheckPoint;
@@ -64,13 +94,10 @@
     // Update layer transform before laying out children (SVG needs access to the transform matrices during layout for on-screen text font-size calculations).
     // Eventually re-update if the transform reference box, relevant for transform-origin, has changed during layout.
     {
-        // FIXME: [LBSE] Upstream SVGLayerTransformUpdater
-        // SVGLayerTransformUpdater transformUpdater(*this);
+        SVGLayerTransformUpdater updateTransform(*this);
         layoutChildren();
     }
 
-    updateLayerInformation();
-
     // Invalidate all resources of this client if our layout changed.
     if (everHadLayout() && needsLayout())
         SVGResourcesCache::clientLayoutChanged(*this);

Modified: trunk/Source/WebCore/rendering/svg/RenderSVGContainer.h (292689 => 292690)


--- trunk/Source/WebCore/rendering/svg/RenderSVGContainer.h	2022-04-10 21:56:21 UTC (rev 292689)
+++ trunk/Source/WebCore/rendering/svg/RenderSVGContainer.h	2022-04-10 22:51:52 UTC (rev 292690)
@@ -55,7 +55,6 @@
     virtual void layoutChildren();
     bool nodeAtPoint(const HitTestRequest&, HitTestResult&, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, HitTestAction) override;
 
-    virtual void updateLayerInformation() { }
     virtual void calculateViewport();
     virtual bool pointIsInsideViewportClip(const FloatPoint&) { return true; }
 

Modified: trunk/Source/WebCore/rendering/svg/RenderSVGModelObject.cpp (292689 => 292690)


--- trunk/Source/WebCore/rendering/svg/RenderSVGModelObject.cpp	2022-04-10 21:56:21 UTC (rev 292689)
+++ trunk/Source/WebCore/rendering/svg/RenderSVGModelObject.cpp	2022-04-10 22:51:52 UTC (rev 292690)
@@ -36,6 +36,7 @@
 #include "RenderGeometryMap.h"
 #include "RenderLayer.h"
 #include "RenderLayerModelObject.h"
+#include "RenderSVGModelObjectInlines.h"
 #include "RenderSVGResource.h"
 #include "RenderView.h"
 #include "SVGElementInlines.h"
@@ -59,15 +60,13 @@
 void RenderSVGModelObject::updateFromStyle()
 {
     RenderLayerModelObject::updateFromStyle();
-    setHasTransformRelatedProperty(style().hasTransformRelatedProperty());
 
-    AffineTransform transform;
-    if (is<SVGGraphicsElement>(nodeForNonAnonymous()))
-        transform = downcast<SVGGraphicsElement>(nodeForNonAnonymous()).animatedLocalTransform();
+    bool hasSVGTransform = false;
+    if (is<SVGGraphicsElement>(element()))
+        hasSVGTransform = !downcast<SVGGraphicsElement>(element()).animatedLocalTransform().isIdentity();
 
-    // FIXME: [LBSE] Upstream RenderObject changes
-    // if (!transform.isIdentity())
-    //     setHasSVGTransform();
+    setHasTransformRelatedProperty(style().hasTransformRelatedProperty() || hasSVGTransform);
+    setHasSVGTransform(hasSVGTransform);
 }
 
 FloatRect RenderSVGModelObject::borderBoxRectInFragmentEquivalent(RenderFragmentContainer*, RenderBox::RenderBoxFragmentInfoFlags) const

Modified: trunk/Source/WebCore/rendering/svg/RenderSVGRoot.cpp (292689 => 292690)


--- trunk/Source/WebCore/rendering/svg/RenderSVGRoot.cpp	2022-04-10 21:56:21 UTC (rev 292689)
+++ trunk/Source/WebCore/rendering/svg/RenderSVGRoot.cpp	2022-04-10 22:51:52 UTC (rev 292690)
@@ -396,8 +396,7 @@
 {
     RenderReplaced::updateFromStyle();
 
-    // FIXME: [LBSE] Upstream RenderObject changes
-    // setHasSVGTransform();
+    setHasSVGTransform();
 
     if (shouldApplyViewportClip())
         setHasNonVisibleOverflow();

Modified: trunk/Source/WebCore/rendering/svg/RenderSVGShape.cpp (292689 => 292690)


--- trunk/Source/WebCore/rendering/svg/RenderSVGShape.cpp	2022-04-10 21:56:21 UTC (rev 292689)
+++ trunk/Source/WebCore/rendering/svg/RenderSVGShape.cpp	2022-04-10 22:51:52 UTC (rev 292690)
@@ -154,8 +154,7 @@
         setLayoutRect(enclosingLayoutRect(m_fillBoundingBox));
     }
 
-    // FIXME: [LBSE] Upstream SVGLayerTransformUpdater
-    // SVGRenderSupport::updateLayerTransform(*this);
+    updateLayerTransform();
 
     // Invalidate all resources of this client if our layout changed.
     if (everHadLayout() && selfNeedsLayout())
@@ -536,8 +535,7 @@
 
 void RenderSVGShape::applyTransform(TransformationMatrix& transform, const RenderStyle& style, const FloatRect& boundingBox, OptionSet<RenderStyle::TransformOperationOption> options) const
 {
-    // FIXME: [LBSE] Upstream CSS/SVG transform support
-    style.applyTransform(transform, boundingBox, options);
+    applySVGTransform(transform, graphicsElement(), style, boundingBox, options);
 }
 
 }

Modified: trunk/Source/WebCore/rendering/svg/RenderSVGShape.h (292689 => 292690)


--- trunk/Source/WebCore/rendering/svg/RenderSVGShape.h	2022-04-10 21:56:21 UTC (rev 292689)
+++ trunk/Source/WebCore/rendering/svg/RenderSVGShape.h	2022-04-10 22:51:52 UTC (rev 292690)
@@ -82,7 +82,7 @@
 
     FloatRect computeMarkerBoundingBox(const SVGBoundingBoxComputation::DecorationOptions&) const;
 
-    void applyTransform(TransformationMatrix&, const RenderStyle&, const FloatRect& boundingBox, OptionSet<RenderStyle::TransformOperationOption> = RenderStyle::allTransformOperations) const override;
+    void applyTransform(TransformationMatrix&, const RenderStyle&, const FloatRect& boundingBox, OptionSet<RenderStyle::TransformOperationOption> = RenderStyle::allTransformOperations) const final;
 
 protected:
     void element() const = delete;

Modified: trunk/Source/WebCore/rendering/svg/RenderSVGTransformableContainer.cpp (292689 => 292690)


--- trunk/Source/WebCore/rendering/svg/RenderSVGTransformableContainer.cpp	2022-04-10 21:56:21 UTC (rev 292689)
+++ trunk/Source/WebCore/rendering/svg/RenderSVGTransformableContainer.cpp	2022-04-10 22:51:52 UTC (rev 292690)
@@ -97,15 +97,13 @@
 {
     RenderSVGContainer::updateFromStyle();
 
-    // FIXME: [LBSE] Upstream CSS/SVG transform support
-    // if (associatedUseElement(graphicsElement()))
-    //    setHasSVGTransform();
+    if (associatedUseElement(graphicsElement()))
+        setHasSVGTransform();
 }
 
 void RenderSVGTransformableContainer::applyTransform(TransformationMatrix& transform, const RenderStyle& style, const FloatRect& boundingBox, OptionSet<RenderStyle::TransformOperationOption> options) const
 {
-    // FIXME: [LBSE] Upstream CSS/SVG transform support
-    style.applyTransform(transform, boundingBox, options);
+    applySVGTransform(transform, graphicsElement(), style, boundingBox, options);
 }
 
 void RenderSVGTransformableContainer::styleWillChange(StyleDifference diff, const RenderStyle& newStyle)

Modified: trunk/Source/WebCore/svg/SVGGraphicsElement.cpp (292689 => 292690)


--- trunk/Source/WebCore/svg/SVGGraphicsElement.cpp	2022-04-10 21:56:21 UTC (rev 292689)
+++ trunk/Source/WebCore/svg/SVGGraphicsElement.cpp	2022-04-10 22:51:52 UTC (rev 292690)
@@ -73,6 +73,15 @@
 
 AffineTransform SVGGraphicsElement::animatedLocalTransform() const
 {
+#if ENABLE(LAYER_BASED_SVG_ENGINE)
+    // LBSE handles transforms via RenderLayer, no need to handle CSS transforms here.
+    if (document().settings().layerBasedSVGEngineEnabled()) {
+        if (m_supplementalTransform)
+            return *m_supplementalTransform * transform().concatenate();
+        return transform().concatenate();
+    }
+#endif
+
     AffineTransform matrix;
 
     auto* style = renderer() ? &renderer()->style() : nullptr;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to