| Differences between
and this patch
- a/Source/WebCore/ChangeLog +62 lines
Lines 1-3 a/Source/WebCore/ChangeLog_sec1
1
2022-03-21  Nikolas Zimmermann  <nzimmermann@igalia.com>
2
3
        [LBSE] Activate SVG transform support through layers
4
        https://bugs.webkit.org/show_bug.cgi?id=237711
5
6
        Reviewed by NOBODY (OOPS!).
7
8
        Activate transforms for SVG layers.
9
10
        Use the flag to keep track of the presence of SVG transformations
11
        on a renderer. CSS/HTML renderers can rely only on the RenderStyle
12
        to determine if transformations are applied, whereas SVG has to
13
        consult additional sources, such as the SVG 'transform' attribute.
14
15
        A SVG renderer with the 'HasSVGTransform' flag set should behave
16
        like any SVG/HTML renderer that has CSS transformations applied.
17
18
        With this patch applied SVG transform and CSS transforms can
19
        be applied to <g> / <rect> elements in LBSE, however transform-origin
20
        support is not yet correct, this will come up a follow-up patch.
21
22
        Covered by existing tests, no change in behaviour.
23
24
        * platform/graphics/transforms/TransformationMatrix.cpp:
25
        (WebCore::TransformationMatrix::multiplyAffineTransform):
26
        * platform/graphics/transforms/TransformationMatrix.h:
27
        * rendering/RenderBox.cpp:
28
        (WebCore::RenderBox::updateLayerTransform): Deleted.
29
        * rendering/RenderBox.h:
30
        * rendering/RenderLayer.cpp:
31
        (WebCore::canCreateStackingContext):
32
        (WebCore::updateTransformFromStyle):
33
        (WebCore::RenderLayer::currentTransform const):
34
        * rendering/RenderLayerModelObject.cpp:
35
        (WebCore::RenderLayerModelObject::updateLayerTransform):
36
        (WebCore::RenderLayerModelObject::applySVGTransform const):
37
        * rendering/RenderLayerModelObject.h:
38
        * rendering/RenderObject.cpp:
39
        (WebCore::RenderObject::setHasSVGTransform):
40
        * rendering/RenderObject.h:
41
        (WebCore::RenderObject::hasSVGTransform const):
42
        (WebCore::RenderObject::hasTransform const):
43
        * rendering/svg/RenderSVGContainer.cpp:
44
        (WebCore::SVGLayerTransformUpdater::SVGLayerTransformUpdater):
45
        (WebCore::SVGLayerTransformUpdater::~SVGLayerTransformUpdater):
46
        (WebCore::RenderSVGContainer::layout):
47
        * rendering/svg/RenderSVGContainer.h:
48
        (WebCore::RenderSVGContainer::updateLayerInformation): Deleted.
49
        * rendering/svg/RenderSVGModelObject.cpp:
50
        (WebCore::RenderSVGModelObject::updateFromStyle):
51
        * rendering/svg/RenderSVGRoot.cpp:
52
        (WebCore::RenderSVGRoot::updateFromStyle):
53
        * rendering/svg/RenderSVGShape.cpp:
54
        (WebCore::RenderSVGShape::layout):
55
        (WebCore::RenderSVGShape::applyTransform const):
56
        * rendering/svg/RenderSVGShape.h:
57
        * rendering/svg/RenderSVGTransformableContainer.cpp:
58
        (WebCore::RenderSVGTransformableContainer::updateFromStyle):
59
        (WebCore::RenderSVGTransformableContainer::applyTransform const):
60
        * svg/SVGGraphicsElement.cpp:
61
        (WebCore::SVGGraphicsElement::animatedLocalTransform const):
62
1
2022-03-21  Nikolas Zimmermann  <nzimmermann@igalia.com>
63
2022-03-21  Nikolas Zimmermann  <nzimmermann@igalia.com>
2
64
3
        Unify reference box / CTM computation in RenderLayer
65
        Unify reference box / CTM computation in RenderLayer
- a/Source/WebCore/platform/graphics/transforms/TransformationMatrix.cpp +11 lines
Lines 1533-1538 TransformationMatrix& TransformationMatrix::multiply(const TransformationMatrix& a/Source/WebCore/platform/graphics/transforms/TransformationMatrix.cpp_sec1
1533
    return *this;
1533
    return *this;
1534
}
1534
}
1535
1535
1536
TransformationMatrix& TransformationMatrix::multiplyAffineTransform(const AffineTransform& matrix)
1537
{
1538
    if (matrix.isIdentity())
1539
        return *this;
1540
1541
    if (matrix.isIdentityOrTranslation())
1542
        return translate(matrix.e(), matrix.f());
1543
1544
    return multiply(matrix.toTransformationMatrix());
1545
}
1546
1536
void TransformationMatrix::multVecMatrix(double x, double y, double& resultX, double& resultY) const
1547
void TransformationMatrix::multVecMatrix(double x, double y, double& resultX, double& resultY) const
1537
{
1548
{
1538
    resultX = m_matrix[3][0] + x * m_matrix[0][0] + y * m_matrix[1][0];
1549
    resultX = m_matrix[3][0] + x * m_matrix[0][0] + y * m_matrix[1][0];
- a/Source/WebCore/platform/graphics/transforms/TransformationMatrix.h +2 lines
Lines 249-254 public: a/Source/WebCore/platform/graphics/transforms/TransformationMatrix.h_sec1
249
249
250
    // this = mat * this.
250
    // this = mat * this.
251
    WEBCORE_EXPORT TransformationMatrix& multiply(const TransformationMatrix&);
251
    WEBCORE_EXPORT TransformationMatrix& multiply(const TransformationMatrix&);
252
    // Identical to multiply(TransformationMatrix&), but saving a AffineTransform -> TransformationMatrix roundtrip for identity or translation matrices.
253
    TransformationMatrix& multiplyAffineTransform(const AffineTransform&);
252
254
253
    WEBCORE_EXPORT TransformationMatrix& scale(double);
255
    WEBCORE_EXPORT TransformationMatrix& scale(double);
254
    WEBCORE_EXPORT TransformationMatrix& scaleNonUniform(double sx, double sy);
256
    WEBCORE_EXPORT TransformationMatrix& scaleNonUniform(double sx, double sy);
- a/Source/WebCore/rendering/RenderBox.cpp -7 lines
Lines 662-674 void RenderBox::absoluteQuads(Vector<FloatQuad>& quads, bool* wasFixed) const a/Source/WebCore/rendering/RenderBox.cpp_sec1
662
    quads.append(localToAbsoluteQuad(localRect, UseTransforms, wasFixed));
662
    quads.append(localToAbsoluteQuad(localRect, UseTransforms, wasFixed));
663
}
663
}
664
664
665
void RenderBox::updateLayerTransform()
666
{
667
    // Transform-origin depends on box size, so we need to update the layer transform after layout.
668
    if (hasLayer())
669
        layer()->updateTransform();
670
}
671
672
void RenderBox::applyTransform(TransformationMatrix& t, const RenderStyle& style, const FloatRect& boundingBox, OptionSet<RenderStyle::TransformOperationOption> options) const
665
void RenderBox::applyTransform(TransformationMatrix& t, const RenderStyle& style, const FloatRect& boundingBox, OptionSet<RenderStyle::TransformOperationOption> options) const
673
{
666
{
674
    style.applyTransform(t, boundingBox, options);
667
    style.applyTransform(t, boundingBox, options);
- a/Source/WebCore/rendering/RenderBox.h -1 lines
Lines 218-224 public: a/Source/WebCore/rendering/RenderBox.h_sec1
218
    void addOverflowFromChild(const RenderBox* child) { addOverflowFromChild(child, child->locationOffset()); }
218
    void addOverflowFromChild(const RenderBox* child) { addOverflowFromChild(child, child->locationOffset()); }
219
    void addOverflowFromChild(const RenderBox* child, const LayoutSize& delta);
219
    void addOverflowFromChild(const RenderBox* child, const LayoutSize& delta);
220
220
221
    void updateLayerTransform();
222
    void applyTransform(TransformationMatrix&, const RenderStyle&, const FloatRect& boundingBox, OptionSet<RenderStyle::TransformOperationOption> = RenderStyle::allTransformOperations) const override;
221
    void applyTransform(TransformationMatrix&, const RenderStyle&, const FloatRect& boundingBox, OptionSet<RenderStyle::TransformOperationOption> = RenderStyle::allTransformOperations) const override;
223
222
224
    LayoutSize contentSize() const { return { contentWidth(), contentHeight() }; }
223
    LayoutSize contentSize() const { return { contentWidth(), contentHeight() }; }
- a/Source/WebCore/rendering/RenderLayer.cpp -8 / +5 lines
Lines 552-557 static bool canCreateStackingContext(const RenderLayer& layer) a/Source/WebCore/rendering/RenderLayer.cpp_sec1
552
{
552
{
553
    auto& renderer = layer.renderer();
553
    auto& renderer = layer.renderer();
554
    return renderer.hasTransformRelatedProperty()
554
    return renderer.hasTransformRelatedProperty()
555
#if ENABLE(LAYER_BASED_SVG_ENGINE)
556
        || renderer.hasSVGTransform()
557
#endif
555
        || renderer.hasClipPath()
558
        || renderer.hasClipPath()
556
        || renderer.hasFilter()
559
        || renderer.hasFilter()
557
        || renderer.hasMask()
560
        || renderer.hasMask()
Lines 1366-1384 TransformationMatrix RenderLayer::currentTransform(OptionSet<RenderStyle::Transf a/Source/WebCore/rendering/RenderLayer.cpp_sec2
1366
    if (!m_transform)
1369
    if (!m_transform)
1367
        return { };
1370
        return { };
1368
1371
1369
    // FIXME: [LBSE] Upstream transform support for RenderSVGModelObject derived renderers
1370
    if (!is<RenderBox>(renderer()))
1371
        return { };
1372
1373
    auto& renderBox = downcast<RenderBox>(renderer());
1374
1375
    // m_transform includes transform-origin and is affected by the choice of the transform-box.
1372
    // m_transform includes transform-origin and is affected by the choice of the transform-box.
1376
    // Therefore we can only use the cached m_transform, if the animation doesn't alter transform-box or excludes transform-origin.
1373
    // Therefore we can only use the cached m_transform, if the animation doesn't alter transform-box or excludes transform-origin.
1377
1374
1378
    // Query the animatedStyle() to obtain the current transformation, when accelerated transform animations are running.
1375
    // Query the animatedStyle() to obtain the current transformation, when accelerated transform animations are running.
1379
    auto styleable = Styleable::fromRenderer(renderBox);
1376
    auto styleable = Styleable::fromRenderer(renderer());
1380
    if ((styleable && styleable->isRunningAcceleratedTransformAnimation()) || !options.contains(RenderStyle::TransformOperationOption::TransformOrigin)) {
1377
    if ((styleable && styleable->isRunningAcceleratedTransformAnimation()) || !options.contains(RenderStyle::TransformOperationOption::TransformOrigin)) {
1381
        std::unique_ptr<RenderStyle> animatedStyle = renderBox.animatedStyle();
1378
        std::unique_ptr<RenderStyle> animatedStyle = renderer().animatedStyle();
1382
1379
1383
        TransformationMatrix transform;
1380
        TransformationMatrix transform;
1384
        updateTransformFromStyle(transform, *animatedStyle, options);
1381
        updateTransformFromStyle(transform, *animatedStyle, options);
- a/Source/WebCore/rendering/RenderLayerModelObject.cpp +40 lines
Lines 31-36 a/Source/WebCore/rendering/RenderLayerModelObject.cpp_sec1
31
#include "RenderLayerScrollableArea.h"
31
#include "RenderLayerScrollableArea.h"
32
#include "RenderSVGModelObject.h"
32
#include "RenderSVGModelObject.h"
33
#include "RenderView.h"
33
#include "RenderView.h"
34
#include "SVGGraphicsElement.h"
34
#include "Settings.h"
35
#include "Settings.h"
35
#include "StyleScrollSnapPoints.h"
36
#include "StyleScrollSnapPoints.h"
36
#include "TransformState.h"
37
#include "TransformState.h"
Lines 231-236 void RenderLayerModelObject::suspendAnimations(MonotonicTime time) a/Source/WebCore/rendering/RenderLayerModelObject.cpp_sec2
231
    layer()->backing()->suspendAnimations(time);
232
    layer()->backing()->suspendAnimations(time);
232
}
233
}
233
234
235
void RenderLayerModelObject::updateLayerTransform()
236
{
237
    // Transform-origin depends on box size, so we need to update the layer transform after layout.
238
    if (hasLayer())
239
        layer()->updateTransform();
240
}
241
234
#if ENABLE(LAYER_BASED_SVG_ENGINE)
242
#if ENABLE(LAYER_BASED_SVG_ENGINE)
235
std::optional<LayoutRect> RenderLayerModelObject::computeVisibleRectInSVGContainer(const LayoutRect& rect, const RenderLayerModelObject* container, RenderObject::VisibleRectContext context) const
243
std::optional<LayoutRect> RenderLayerModelObject::computeVisibleRectInSVGContainer(const LayoutRect& rect, const RenderLayerModelObject* container, RenderObject::VisibleRectContext context) const
236
{
244
{
Lines 316-321 void RenderLayerModelObject::mapLocalToSVGContainer(const RenderLayerModelObject a/Source/WebCore/rendering/RenderLayerModelObject.cpp_sec3
316
324
317
    container->mapLocalToContainer(ancestorContainer, transformState, mode, wasFixed);
325
    container->mapLocalToContainer(ancestorContainer, transformState, mode, wasFixed);
318
}
326
}
327
328
void RenderLayerModelObject::applySVGTransform(TransformationMatrix& transform, SVGGraphicsElement& graphicsElement, const RenderStyle& style, const FloatRect& boundingBox, OptionSet<RenderStyle::TransformOperationOption> options) const
329
{
330
    // This check does not use style.hasTransformRelatedProperty() on purpose -- we only want to know if either the 'transform' property, an
331
    // offset path, or the individual transform operations are set (perspective / transform-style: preserve-3d are not relevant here).
332
    bool hasCSSTransform = style.hasTransform() || style.rotate() || style.translate() || style.scale();
333
334
    bool affectedByTransformOrigin = false;
335
    std::optional<AffineTransform> svgTransform;
336
337
    if (hasCSSTransform)
338
        affectedByTransformOrigin = style.affectedByTransformOrigin();
339
    else if (auto affineTransform = graphicsElement.animatedLocalTransform(); !affineTransform.isIdentity()) {
340
        svgTransform = affineTransform;
341
        affectedByTransformOrigin = affineTransform.a() != 1 || affineTransform.b() || affineTransform.c() || affineTransform.d() != 1;
342
    }
343
344
    if (!hasCSSTransform && !svgTransform.has_value())
345
        return;
346
347
    FloatPoint3D originTranslate;
348
    if (options.contains(RenderStyle::TransformOperationOption::TransformOrigin) && affectedByTransformOrigin)
349
        originTranslate = style.applyTransformOrigin(transform, boundingBox);
350
351
    // CSS transforms take precedence over SVG transforms.
352
    if (hasCSSTransform)
353
        style.applyCSSTransform(transform, boundingBox, options);
354
    else
355
        transform.multiplyAffineTransform(svgTransform.value());
356
357
    style.unapplyTransformOrigin(transform, originTranslate);
358
}
319
#endif
359
#endif
320
360
321
} // namespace WebCore
361
} // namespace WebCore
- a/Source/WebCore/rendering/RenderLayerModelObject.h +5 lines
Lines 28-33 namespace WebCore { a/Source/WebCore/rendering/RenderLayerModelObject.h_sec1
28
28
29
class KeyframeList;
29
class KeyframeList;
30
class RenderLayer;
30
class RenderLayer;
31
class SVGGraphicsElement;
31
32
32
struct LayerRepaintRects {
33
struct LayerRepaintRects {
33
    LayoutRect clippedOverflowRect;
34
    LayoutRect clippedOverflowRect;
Lines 75-82 public: a/Source/WebCore/rendering/RenderLayerModelObject.h_sec2
75
    // Provides the SVG implementation for mapLocalToContainer().
76
    // Provides the SVG implementation for mapLocalToContainer().
76
    // This lives in RenderLayerModelObject, which is the common base-class for all SVG renderers.
77
    // This lives in RenderLayerModelObject, which is the common base-class for all SVG renderers.
77
    void mapLocalToSVGContainer(const RenderLayerModelObject* ancestorContainer, TransformState&, OptionSet<MapCoordinatesMode>, bool* wasFixed) const;
78
    void mapLocalToSVGContainer(const RenderLayerModelObject* ancestorContainer, TransformState&, OptionSet<MapCoordinatesMode>, bool* wasFixed) const;
79
80
    void applySVGTransform(TransformationMatrix&, SVGGraphicsElement&, const RenderStyle&, const FloatRect& boundingBox, OptionSet<RenderStyle::TransformOperationOption>) const;
78
#endif
81
#endif
79
82
83
    void updateLayerTransform();
84
80
    virtual void applyTransform(TransformationMatrix&, const RenderStyle&, const FloatRect& boundingBox, OptionSet<RenderStyle::TransformOperationOption> = RenderStyle::allTransformOperations) const = 0;
85
    virtual void applyTransform(TransformationMatrix&, const RenderStyle&, const FloatRect& boundingBox, OptionSet<RenderStyle::TransformOperationOption> = RenderStyle::allTransformOperations) const = 0;
81
86
82
protected:
87
protected:
- a/Source/WebCore/rendering/RenderObject.cpp +8 lines
Lines 1975-1980 void RenderObject::setHasOutlineAutoAncestor(bool hasOutlineAutoAncestor) a/Source/WebCore/rendering/RenderObject.cpp_sec1
1975
        ensureRareData().setHasOutlineAutoAncestor(hasOutlineAutoAncestor);
1975
        ensureRareData().setHasOutlineAutoAncestor(hasOutlineAutoAncestor);
1976
}
1976
}
1977
1977
1978
#if ENABLE(LAYER_BASED_SVG_ENGINE)
1979
void RenderObject::setHasSVGTransform(bool hasSVGTransform)
1980
{
1981
    if (hasSVGTransform || hasRareData())
1982
        ensureRareData().setHasSVGTransform(hasSVGTransform);
1983
}
1984
#endif
1985
1978
void RenderObject::setPaintContainmentApplies(bool paintContainmentApplies)
1986
void RenderObject::setPaintContainmentApplies(bool paintContainmentApplies)
1979
{
1987
{
1980
    if (paintContainmentApplies || hasRareData())
1988
    if (paintContainmentApplies || hasRareData())
- a/Source/WebCore/rendering/RenderObject.h -1 / +13 lines
Lines 415-420 public: a/Source/WebCore/rendering/RenderObject.h_sec1
415
    bool hasOutlineAutoAncestor() const { return m_bitfields.hasRareData() && rareData().hasOutlineAutoAncestor(); }
415
    bool hasOutlineAutoAncestor() const { return m_bitfields.hasRareData() && rareData().hasOutlineAutoAncestor(); }
416
    bool paintContainmentApplies() const { return m_bitfields.hasRareData() && rareData().paintContainmentApplies(); }
416
    bool paintContainmentApplies() const { return m_bitfields.hasRareData() && rareData().paintContainmentApplies(); }
417
417
418
#if ENABLE(LAYER_BASED_SVG_ENGINE)
419
    bool hasSVGTransform() const { return m_bitfields.hasRareData() && rareData().hasSVGTransform(); }
420
#else
421
    bool hasSVGTransform() const { return false; }
422
#endif
423
418
    bool isExcludedFromNormalLayout() const { return m_bitfields.isExcludedFromNormalLayout(); }
424
    bool isExcludedFromNormalLayout() const { return m_bitfields.isExcludedFromNormalLayout(); }
419
    void setIsExcludedFromNormalLayout(bool excluded) { m_bitfields.setIsExcludedFromNormalLayout(excluded); }
425
    void setIsExcludedFromNormalLayout(bool excluded) { m_bitfields.setIsExcludedFromNormalLayout(excluded); }
420
    bool isExcludedAndPlacedInBorder() const { return isExcludedFromNormalLayout() && isLegend(); }
426
    bool isExcludedAndPlacedInBorder() const { return isExcludedFromNormalLayout() && isLegend(); }
Lines 449-455 public: a/Source/WebCore/rendering/RenderObject.h_sec2
449
    bool hasPotentiallyScrollableOverflow() const;
455
    bool hasPotentiallyScrollableOverflow() const;
450
456
451
    bool hasTransformRelatedProperty() const { return m_bitfields.hasTransformRelatedProperty(); } // Transform, perspective or transform-style: preserve-3d.
457
    bool hasTransformRelatedProperty() const { return m_bitfields.hasTransformRelatedProperty(); } // Transform, perspective or transform-style: preserve-3d.
452
    bool hasTransform() const { return hasTransformRelatedProperty() && (style().hasTransform() || style().translate() || style().scale() || style().rotate()); }
458
    bool hasTransform() const { return hasTransformRelatedProperty() && (style().hasTransform() || style().translate() || style().scale() || style().rotate() || hasSVGTransform()); }
453
    bool hasTransformOrPespective() const { return hasTransformRelatedProperty() && (hasTransform() || style().hasPerspective()); }
459
    bool hasTransformOrPespective() const { return hasTransformRelatedProperty() && (hasTransform() || style().hasPerspective()); }
454
460
455
    inline bool preservesNewline() const;
461
    inline bool preservesNewline() const;
Lines 514-519 public: a/Source/WebCore/rendering/RenderObject.h_sec3
514
    void setIsRenderFragmentedFlow(bool = true);
520
    void setIsRenderFragmentedFlow(bool = true);
515
    void setHasOutlineAutoAncestor(bool = true);
521
    void setHasOutlineAutoAncestor(bool = true);
516
    void setPaintContainmentApplies(bool = true);
522
    void setPaintContainmentApplies(bool = true);
523
#if ENABLE(LAYER_BASED_SVG_ENGINE)
524
    void setHasSVGTransform(bool = true);
525
#endif
517
526
518
    // Hook so that RenderTextControl can return the line height of its inner renderer.
527
    // Hook so that RenderTextControl can return the line height of its inner renderer.
519
    // For other renderers, the value is the same as lineHeight(false).
528
    // For other renderers, the value is the same as lineHeight(false).
Lines 943-948 private: a/Source/WebCore/rendering/RenderObject.h_sec4
943
        ADD_BOOLEAN_BITFIELD(isRenderFragmentedFlow, IsRenderFragmentedFlow);
952
        ADD_BOOLEAN_BITFIELD(isRenderFragmentedFlow, IsRenderFragmentedFlow);
944
        ADD_BOOLEAN_BITFIELD(hasOutlineAutoAncestor, HasOutlineAutoAncestor);
953
        ADD_BOOLEAN_BITFIELD(hasOutlineAutoAncestor, HasOutlineAutoAncestor);
945
        ADD_BOOLEAN_BITFIELD(paintContainmentApplies, PaintContainmentApplies);
954
        ADD_BOOLEAN_BITFIELD(paintContainmentApplies, PaintContainmentApplies);
955
#if ENABLE(LAYER_BASED_SVG_ENGINE)
956
        ADD_BOOLEAN_BITFIELD(hasSVGTransform, HasSVGTransform);
957
#endif
946
958
947
        // From RenderElement
959
        // From RenderElement
948
        std::unique_ptr<ReferencedSVGResources> referencedSVGResources;
960
        std::unique_ptr<ReferencedSVGResources> referencedSVGResources;
- a/Source/WebCore/rendering/svg/RenderSVGContainer.cpp -4 / +31 lines
Lines 52-57 RenderSVGContainer::RenderSVGContainer(SVGElement& element, RenderStyle&& style) a/Source/WebCore/rendering/svg/RenderSVGContainer.cpp_sec1
52
52
53
RenderSVGContainer::~RenderSVGContainer() = default;
53
RenderSVGContainer::~RenderSVGContainer() = default;
54
54
55
// Helper class, move to its own file once utilized in more than one place.
56
class SVGLayerTransformUpdater {
57
    WTF_MAKE_NONCOPYABLE(SVGLayerTransformUpdater);
58
public:
59
    SVGLayerTransformUpdater(RenderLayerModelObject& renderer)
60
        : m_renderer(renderer)
61
    {
62
        if (!m_renderer.hasLayer())
63
            return;
64
65
        m_transformReferenceBox = m_renderer.transformReferenceBoxRect();
66
        m_renderer.updateLayerTransform();
67
    }
68
69
70
    ~SVGLayerTransformUpdater()
71
    {
72
        if (!m_renderer.hasLayer())
73
            return;
74
        if (m_renderer.transformReferenceBoxRect() == m_transformReferenceBox)
75
            return;
76
77
        m_renderer.updateLayerTransform();
78
    }
79
80
private:
81
    RenderLayerModelObject& m_renderer;
82
    FloatRect m_transformReferenceBox;
83
};
84
55
void RenderSVGContainer::layout()
85
void RenderSVGContainer::layout()
56
{
86
{
57
    StackStats::LayoutCheckPoint layoutCheckPoint;
87
    StackStats::LayoutCheckPoint layoutCheckPoint;
Lines 64-76 void RenderSVGContainer::layout() a/Source/WebCore/rendering/svg/RenderSVGContainer.cpp_sec2
64
    // Update layer transform before laying out children (SVG needs access to the transform matrices during layout for on-screen text font-size calculations).
94
    // Update layer transform before laying out children (SVG needs access to the transform matrices during layout for on-screen text font-size calculations).
65
    // Eventually re-update if the transform reference box, relevant for transform-origin, has changed during layout.
95
    // Eventually re-update if the transform reference box, relevant for transform-origin, has changed during layout.
66
    {
96
    {
67
        // FIXME: [LBSE] Upstream SVGLayerTransformUpdater
97
        SVGLayerTransformUpdater updateTransform(*this);
68
        // SVGLayerTransformUpdater transformUpdater(*this);
69
        layoutChildren();
98
        layoutChildren();
70
    }
99
    }
71
100
72
    updateLayerInformation();
73
74
    // Invalidate all resources of this client if our layout changed.
101
    // Invalidate all resources of this client if our layout changed.
75
    if (everHadLayout() && needsLayout())
102
    if (everHadLayout() && needsLayout())
76
        SVGResourcesCache::clientLayoutChanged(*this);
103
        SVGResourcesCache::clientLayoutChanged(*this);
- a/Source/WebCore/rendering/svg/RenderSVGContainer.h -1 lines
Lines 55-61 protected: a/Source/WebCore/rendering/svg/RenderSVGContainer.h_sec1
55
    virtual void layoutChildren();
55
    virtual void layoutChildren();
56
    bool nodeAtPoint(const HitTestRequest&, HitTestResult&, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, HitTestAction) override;
56
    bool nodeAtPoint(const HitTestRequest&, HitTestResult&, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, HitTestAction) override;
57
57
58
    virtual void updateLayerInformation() { }
59
    virtual void calculateViewport();
58
    virtual void calculateViewport();
60
    virtual bool pointIsInsideViewportClip(const FloatPoint&) { return true; }
59
    virtual bool pointIsInsideViewportClip(const FloatPoint&) { return true; }
61
60
- a/Source/WebCore/rendering/svg/RenderSVGModelObject.cpp -7 / +6 lines
Lines 36-41 a/Source/WebCore/rendering/svg/RenderSVGModelObject.cpp_sec1
36
#include "RenderGeometryMap.h"
36
#include "RenderGeometryMap.h"
37
#include "RenderLayer.h"
37
#include "RenderLayer.h"
38
#include "RenderLayerModelObject.h"
38
#include "RenderLayerModelObject.h"
39
#include "RenderSVGModelObjectInlines.h"
39
#include "RenderSVGResource.h"
40
#include "RenderSVGResource.h"
40
#include "RenderView.h"
41
#include "RenderView.h"
41
#include "SVGElementInlines.h"
42
#include "SVGElementInlines.h"
Lines 59-73 RenderSVGModelObject::RenderSVGModelObject(SVGElement& element, RenderStyle&& st a/Source/WebCore/rendering/svg/RenderSVGModelObject.cpp_sec2
59
void RenderSVGModelObject::updateFromStyle()
60
void RenderSVGModelObject::updateFromStyle()
60
{
61
{
61
    RenderLayerModelObject::updateFromStyle();
62
    RenderLayerModelObject::updateFromStyle();
62
    setHasTransformRelatedProperty(style().hasTransformRelatedProperty());
63
63
64
    AffineTransform transform;
64
    bool hasSVGTransform = false;
65
    if (is<SVGGraphicsElement>(nodeForNonAnonymous()))
65
    if (is<SVGGraphicsElement>(element()))
66
        transform = downcast<SVGGraphicsElement>(nodeForNonAnonymous()).animatedLocalTransform();
66
        hasSVGTransform = !downcast<SVGGraphicsElement>(element()).animatedLocalTransform().isIdentity();
67
67
68
    // FIXME: [LBSE] Upstream RenderObject changes
68
    setHasTransformRelatedProperty(style().hasTransformRelatedProperty() || hasSVGTransform);
69
    // if (!transform.isIdentity())
69
    setHasSVGTransform(hasSVGTransform);
70
    //     setHasSVGTransform();
71
}
70
}
72
71
73
FloatRect RenderSVGModelObject::borderBoxRectInFragmentEquivalent(RenderFragmentContainer*, RenderBox::RenderBoxFragmentInfoFlags) const
72
FloatRect RenderSVGModelObject::borderBoxRectInFragmentEquivalent(RenderFragmentContainer*, RenderBox::RenderBoxFragmentInfoFlags) const
- a/Source/WebCore/rendering/svg/RenderSVGRoot.cpp -2 / +1 lines
Lines 396-403 void RenderSVGRoot::updateFromStyle() a/Source/WebCore/rendering/svg/RenderSVGRoot.cpp_sec1
396
{
396
{
397
    RenderReplaced::updateFromStyle();
397
    RenderReplaced::updateFromStyle();
398
398
399
    // FIXME: [LBSE] Upstream RenderObject changes
399
    setHasSVGTransform();
400
    // setHasSVGTransform();
401
400
402
    if (shouldApplyViewportClip())
401
    if (shouldApplyViewportClip())
403
        setHasNonVisibleOverflow();
402
        setHasNonVisibleOverflow();
- a/Source/WebCore/rendering/svg/RenderSVGShape.cpp -4 / +2 lines
Lines 154-161 void RenderSVGShape::layout() a/Source/WebCore/rendering/svg/RenderSVGShape.cpp_sec1
154
        setLayoutRect(enclosingLayoutRect(m_fillBoundingBox));
154
        setLayoutRect(enclosingLayoutRect(m_fillBoundingBox));
155
    }
155
    }
156
156
157
    // FIXME: [LBSE] Upstream SVGLayerTransformUpdater
157
    updateLayerTransform();
158
    // SVGRenderSupport::updateLayerTransform(*this);
159
158
160
    // Invalidate all resources of this client if our layout changed.
159
    // Invalidate all resources of this client if our layout changed.
161
    if (everHadLayout() && selfNeedsLayout())
160
    if (everHadLayout() && selfNeedsLayout())
Lines 536-543 void RenderSVGShape::styleWillChange(StyleDifference diff, const RenderStyle& ne a/Source/WebCore/rendering/svg/RenderSVGShape.cpp_sec2
536
535
537
void RenderSVGShape::applyTransform(TransformationMatrix& transform, const RenderStyle& style, const FloatRect& boundingBox, OptionSet<RenderStyle::TransformOperationOption> options) const
536
void RenderSVGShape::applyTransform(TransformationMatrix& transform, const RenderStyle& style, const FloatRect& boundingBox, OptionSet<RenderStyle::TransformOperationOption> options) const
538
{
537
{
539
    // FIXME: [LBSE] Upstream CSS/SVG transform support
538
    applySVGTransform(transform, graphicsElement(), style, boundingBox, options);
540
    style.applyTransform(transform, boundingBox, options);
541
}
539
}
542
540
543
}
541
}
- a/Source/WebCore/rendering/svg/RenderSVGShape.h -1 / +1 lines
Lines 82-88 public: a/Source/WebCore/rendering/svg/RenderSVGShape.h_sec1
82
82
83
    FloatRect computeMarkerBoundingBox(const SVGBoundingBoxComputation::DecorationOptions&) const;
83
    FloatRect computeMarkerBoundingBox(const SVGBoundingBoxComputation::DecorationOptions&) const;
84
84
85
    void applyTransform(TransformationMatrix&, const RenderStyle&, const FloatRect& boundingBox, OptionSet<RenderStyle::TransformOperationOption> = RenderStyle::allTransformOperations) const override;
85
    void applyTransform(TransformationMatrix&, const RenderStyle&, const FloatRect& boundingBox, OptionSet<RenderStyle::TransformOperationOption> = RenderStyle::allTransformOperations) const final;
86
86
87
protected:
87
protected:
88
    void element() const = delete;
88
    void element() const = delete;
- a/Source/WebCore/rendering/svg/RenderSVGTransformableContainer.cpp -5 / +3 lines
Lines 97-111 void RenderSVGTransformableContainer::updateFromStyle() a/Source/WebCore/rendering/svg/RenderSVGTransformableContainer.cpp_sec1
97
{
97
{
98
    RenderSVGContainer::updateFromStyle();
98
    RenderSVGContainer::updateFromStyle();
99
99
100
    // FIXME: [LBSE] Upstream CSS/SVG transform support
100
    if (associatedUseElement(graphicsElement()))
101
    // if (associatedUseElement(graphicsElement()))
101
        setHasSVGTransform();
102
    //    setHasSVGTransform();
103
}
102
}
104
103
105
void RenderSVGTransformableContainer::applyTransform(TransformationMatrix& transform, const RenderStyle& style, const FloatRect& boundingBox, OptionSet<RenderStyle::TransformOperationOption> options) const
104
void RenderSVGTransformableContainer::applyTransform(TransformationMatrix& transform, const RenderStyle& style, const FloatRect& boundingBox, OptionSet<RenderStyle::TransformOperationOption> options) const
106
{
105
{
107
    // FIXME: [LBSE] Upstream CSS/SVG transform support
106
    applySVGTransform(transform, graphicsElement(), style, boundingBox, options);
108
    style.applyTransform(transform, boundingBox, options);
109
}
107
}
110
108
111
void RenderSVGTransformableContainer::styleWillChange(StyleDifference diff, const RenderStyle& newStyle)
109
void RenderSVGTransformableContainer::styleWillChange(StyleDifference diff, const RenderStyle& newStyle)
- a/Source/WebCore/svg/SVGGraphicsElement.cpp +9 lines
Lines 73-78 AffineTransform SVGGraphicsElement::getScreenCTM(StyleUpdateStrategy styleUpdate a/Source/WebCore/svg/SVGGraphicsElement.cpp_sec1
73
73
74
AffineTransform SVGGraphicsElement::animatedLocalTransform() const
74
AffineTransform SVGGraphicsElement::animatedLocalTransform() const
75
{
75
{
76
#if ENABLE(LAYER_BASED_SVG_ENGINE)
77
    // LBSE handles transforms via RenderLayer, no need to handle CSS transforms here.
78
    if (document().settings().layerBasedSVGEngineEnabled()) {
79
        if (m_supplementalTransform)
80
            return *m_supplementalTransform * transform().concatenate();
81
        return transform().concatenate();
82
    }
83
#endif
84
76
    AffineTransform matrix;
85
    AffineTransform matrix;
77
86
78
    auto* style = renderer() ? &renderer()->style() : nullptr;
87
    auto* style = renderer() ? &renderer()->style() : nullptr;

Return to Bug 237711