Title: [286843] trunk/Source/WebCore
Revision
286843
Author
zimmerm...@webkit.org
Date
2021-12-10 04:19:40 -0800 (Fri, 10 Dec 2021)

Log Message

[LBSE] Handle RenderSVGRoot in all places that handle LegacyRenderSVGRoot
https://bugs.webkit.org/show_bug.cgi?id=233872

Reviewed by Rob Buis.

Various places that handle LegacyRenderSVGRoot, also need to handle the
LBSE RenderSVGRoot renderer -- this patch plumbs in support for
RenderSVGRoot where necessary.

Covered by existing tests, no change in behaviour.

* accessibility/AccessibilityRenderObject.cpp:
(WebCore::AccessibilityRenderObject::elementPath const):
* page/FrameView.cpp:
(WebCore::FrameView::applyOverflowToViewport):
* rendering/RenderTreeAsText.cpp:
(WebCore::write):
* rendering/svg/RenderSVGResource.cpp:
(WebCore::RenderSVGResource::markForLayoutAndParentResourceInvalidation):
* rendering/svg/SVGRenderSupport.cpp:
(WebCore::layoutSizeOfNearestViewportChanged):
* rendering/svg/SVGRenderTreeAsText.cpp:
(WebCore::write):
* rendering/svg/SVGRenderTreeAsText.h:
* rendering/updating/RenderTreeBuilder.cpp:
(WebCore::RenderTreeBuilder::attachInternal):
(WebCore::RenderTreeBuilder::detach):
* rendering/updating/RenderTreeBuilderSVG.cpp:
(WebCore::RenderTreeBuilder::SVG::attach):
(WebCore::RenderTreeBuilder::SVG::detach):
* rendering/updating/RenderTreeBuilderSVG.h:
* svg/SVGElement.cpp:
(WebCore::SVGElement::childShouldCreateRenderer const):
* svg/SVGSVGElement.cpp:
(WebCore::SVGSVGElement::svgAttributeChanged):
(WebCore::SVGSVGElement::currentViewBoxRect const):
(WebCore::SVGSVGElement::currentViewportSize const):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (286842 => 286843)


--- trunk/Source/WebCore/ChangeLog	2021-12-10 11:24:56 UTC (rev 286842)
+++ trunk/Source/WebCore/ChangeLog	2021-12-10 12:19:40 UTC (rev 286843)
@@ -1,5 +1,45 @@
 2021-12-10  Nikolas Zimmermann  <nzimmerm...@igalia.com>
 
+        [LBSE] Handle RenderSVGRoot in all places that handle LegacyRenderSVGRoot
+        https://bugs.webkit.org/show_bug.cgi?id=233872
+
+        Reviewed by Rob Buis.
+
+        Various places that handle LegacyRenderSVGRoot, also need to handle the
+        LBSE RenderSVGRoot renderer -- this patch plumbs in support for
+        RenderSVGRoot where necessary.
+
+        Covered by existing tests, no change in behaviour.
+
+        * accessibility/AccessibilityRenderObject.cpp:
+        (WebCore::AccessibilityRenderObject::elementPath const):
+        * page/FrameView.cpp:
+        (WebCore::FrameView::applyOverflowToViewport):
+        * rendering/RenderTreeAsText.cpp:
+        (WebCore::write):
+        * rendering/svg/RenderSVGResource.cpp:
+        (WebCore::RenderSVGResource::markForLayoutAndParentResourceInvalidation):
+        * rendering/svg/SVGRenderSupport.cpp:
+        (WebCore::layoutSizeOfNearestViewportChanged):
+        * rendering/svg/SVGRenderTreeAsText.cpp:
+        (WebCore::write):
+        * rendering/svg/SVGRenderTreeAsText.h:
+        * rendering/updating/RenderTreeBuilder.cpp:
+        (WebCore::RenderTreeBuilder::attachInternal):
+        (WebCore::RenderTreeBuilder::detach):
+        * rendering/updating/RenderTreeBuilderSVG.cpp:
+        (WebCore::RenderTreeBuilder::SVG::attach):
+        (WebCore::RenderTreeBuilder::SVG::detach):
+        * rendering/updating/RenderTreeBuilderSVG.h:
+        * svg/SVGElement.cpp:
+        (WebCore::SVGElement::childShouldCreateRenderer const):
+        * svg/SVGSVGElement.cpp:
+        (WebCore::SVGSVGElement::svgAttributeChanged):
+        (WebCore::SVGSVGElement::currentViewBoxRect const):
+        (WebCore::SVGSVGElement::currentViewportSize const):
+
+2021-12-10  Nikolas Zimmermann  <nzimmerm...@igalia.com>
+
         [LBSE] Begin layer-aware RenderSVGRoot implementation
         https://bugs.webkit.org/show_bug.cgi?id=233863
 

Modified: trunk/Source/WebCore/accessibility/AccessibilityRenderObject.cpp (286842 => 286843)


--- trunk/Source/WebCore/accessibility/AccessibilityRenderObject.cpp	2021-12-10 11:24:56 UTC (rev 286842)
+++ trunk/Source/WebCore/accessibility/AccessibilityRenderObject.cpp	2021-12-10 12:19:40 UTC (rev 286843)
@@ -94,6 +94,7 @@
 #include "RenderListMarker.h"
 #include "RenderMathMLBlock.h"
 #include "RenderMenuList.h"
+#include "RenderSVGRoot.h"
 #include "RenderSVGShape.h"
 #include "RenderTableCell.h"
 #include "RenderText.h"
@@ -954,6 +955,11 @@
         if (auto svgRoot = ancestorsOfType<LegacyRenderSVGRoot>(*m_renderer).first()) {
             LayoutPoint parentOffset = axObjectCache()->getOrCreate(&*svgRoot)->elementRect().location();
             path.transform(AffineTransform().translate(parentOffset.x(), parentOffset.y()));
+#if ENABLE(LAYER_BASED_SVG_ENGINE)
+        } else if (auto svgRoot = ancestorsOfType<RenderSVGRoot>(*m_renderer).first()) {
+            LayoutPoint parentOffset = axObjectCache()->getOrCreate(&*svgRoot)->elementRect().location();
+            path.transform(AffineTransform().translate(parentOffset.x(), parentOffset.y()));
+#endif
         }
 
         return path;

Modified: trunk/Source/WebCore/page/FrameView.cpp (286842 => 286843)


--- trunk/Source/WebCore/page/FrameView.cpp	2021-12-10 11:24:56 UTC (rev 286842)
+++ trunk/Source/WebCore/page/FrameView.cpp	2021-12-10 12:19:40 UTC (rev 286843)
@@ -87,6 +87,7 @@
 #include "RenderLayerBacking.h"
 #include "RenderLayerCompositor.h"
 #include "RenderLayerScrollableArea.h"
+#include "RenderSVGRoot.h"
 #include "RenderScrollbar.h"
 #include "RenderScrollbarPart.h"
 #include "RenderStyle.h"
@@ -647,6 +648,17 @@
     Overflow overflowX = renderer.effectiveOverflowX();
     Overflow overflowY = renderer.effectiveOverflowY();
 
+#if ENABLE(LAYER_BASED_SVG_ENGINE)
+    if (is<RenderSVGRoot>(renderer)) {
+        // FIXME: evaluate if we can allow overflow for these cases too.
+        // Overflow is always hidden when stand-alone SVG documents are embedded.
+        if (downcast<RenderSVGRoot>(renderer).isEmbeddedThroughFrameContainingSVGDocument()) {
+            overflowX = Overflow::Hidden;
+            overflowY = Overflow::Hidden;
+        }
+    }
+#endif
+
     if (is<LegacyRenderSVGRoot>(renderer)) {
         // FIXME: evaluate if we can allow overflow for these cases too.
         // Overflow is always hidden when stand-alone SVG documents are embedded.

Modified: trunk/Source/WebCore/rendering/RenderTreeAsText.cpp (286842 => 286843)


--- trunk/Source/WebCore/rendering/RenderTreeAsText.cpp	2021-12-10 11:24:56 UTC (rev 286842)
+++ trunk/Source/WebCore/rendering/RenderTreeAsText.cpp	2021-12-10 12:19:40 UTC (rev 286843)
@@ -63,6 +63,7 @@
 #include "RenderSVGInlineText.h"
 #include "RenderSVGPath.h"
 #include "RenderSVGResourceContainer.h"
+#include "RenderSVGRoot.h"
 #include "RenderSVGText.h"
 #include "RenderTableCell.h"
 #include "RenderView.h"
@@ -573,6 +574,12 @@
         writeSVGContainer(ts, downcast<RenderSVGContainer>(o), behavior);
         return;
     }
+#if ENABLE(LAYER_BASED_SVG_ENGINE)
+    if (is<RenderSVGRoot>(o)) {
+        write(ts, downcast<RenderSVGRoot>(o), behavior);
+        return;
+    }
+#endif
     if (is<LegacyRenderSVGRoot>(o)) {
         write(ts, downcast<LegacyRenderSVGRoot>(o), behavior);
         return;

Modified: trunk/Source/WebCore/rendering/svg/RenderSVGResource.cpp (286842 => 286843)


--- trunk/Source/WebCore/rendering/svg/RenderSVGResource.cpp	2021-12-10 11:24:56 UTC (rev 286842)
+++ trunk/Source/WebCore/rendering/svg/RenderSVGResource.cpp	2021-12-10 12:19:40 UTC (rev 286843)
@@ -30,6 +30,7 @@
 #include "RenderSVGResourceFilter.h"
 #include "RenderSVGResourceMasker.h"
 #include "RenderSVGResourceSolidColor.h"
+#include "RenderSVGRoot.h"
 #include "RenderView.h"
 #include "SVGResourceElementClient.h"
 #include "SVGResources.h"
@@ -202,6 +203,10 @@
         // invalidate the ancestor renderer because it may have finished its layout already.
         if (is<LegacyRenderSVGRoot>(object) && downcast<LegacyRenderSVGRoot>(object).isInLayout())
             object.setNeedsLayout(MarkOnlyThis);
+#if ENABLE(LAYER_BASED_SVG_ENGINE)
+        else if (is<RenderSVGRoot>(object) && downcast<RenderSVGRoot>(object).isInLayout())
+            object.setNeedsLayout(MarkOnlyThis);
+#endif
         else
             object.setNeedsLayout(MarkContainingBlockChain);
     }

Modified: trunk/Source/WebCore/rendering/svg/SVGRenderSupport.cpp (286842 => 286843)


--- trunk/Source/WebCore/rendering/svg/SVGRenderSupport.cpp	2021-12-10 11:24:56 UTC (rev 286842)
+++ trunk/Source/WebCore/rendering/svg/SVGRenderSupport.cpp	2021-12-10 12:19:40 UTC (rev 286843)
@@ -40,6 +40,7 @@
 #include "RenderSVGResourceFilter.h"
 #include "RenderSVGResourceMarker.h"
 #include "RenderSVGResourceMasker.h"
+#include "RenderSVGRoot.h"
 #include "RenderSVGText.h"
 #include "RenderSVGTransformableContainer.h"
 #include "RenderSVGViewportContainer.h"
@@ -211,6 +212,10 @@
     if (is<RenderSVGViewportContainer>(*start))
         return downcast<RenderSVGViewportContainer>(*start).isLayoutSizeChanged();
 
+#if ENABLE(LAYER_BASED_SVG_ENGINE)
+    if (is<RenderSVGRoot>(*start))
+        return downcast<RenderSVGRoot>(*start).isLayoutSizeChanged();
+#endif
     return downcast<LegacyRenderSVGRoot>(*start).isLayoutSizeChanged();
 }
 

Modified: trunk/Source/WebCore/rendering/svg/SVGRenderTreeAsText.cpp (286842 => 286843)


--- trunk/Source/WebCore/rendering/svg/SVGRenderTreeAsText.cpp	2021-12-10 11:24:56 UTC (rev 286842)
+++ trunk/Source/WebCore/rendering/svg/SVGRenderTreeAsText.cpp	2021-12-10 12:19:40 UTC (rev 286843)
@@ -47,6 +47,7 @@
 #include "RenderSVGResourcePattern.h"
 #include "RenderSVGResourceRadialGradientInlines.h"
 #include "RenderSVGResourceSolidColor.h"
+#include "RenderSVGRoot.h"
 #include "RenderSVGShapeInlines.h"
 #include "RenderSVGText.h"
 #include "SVGCircleElement.h"
@@ -507,6 +508,16 @@
     writeChildren(ts, container, behavior);
 }
 
+#if ENABLE(LAYER_BASED_SVG_ENGINE)
+void write(TextStream& ts, const RenderSVGRoot& root, OptionSet<RenderAsTextFlag> behavior)
+{
+    writeStandardPrefix(ts, root, behavior);
+    writePositionAndStyle(ts, root, behavior);
+    ts << "\n";
+    writeChildren(ts, root, behavior);
+}
+#endif
+
 void write(TextStream& ts, const LegacyRenderSVGRoot& root, OptionSet<RenderAsTextFlag> behavior)
 {
     writeStandardPrefix(ts, root, behavior);

Modified: trunk/Source/WebCore/rendering/svg/SVGRenderTreeAsText.h (286842 => 286843)


--- trunk/Source/WebCore/rendering/svg/SVGRenderTreeAsText.h	2021-12-10 11:24:56 UTC (rev 286842)
+++ trunk/Source/WebCore/rendering/svg/SVGRenderTreeAsText.h	2021-12-10 12:19:40 UTC (rev 286843)
@@ -30,9 +30,11 @@
 
 namespace WebCore {
 
+class AffineTransform;
 class Color;
 class FloatRect;
 class FloatSize;
+class LegacyRenderSVGRoot;
 class Node;
 class RenderImage;
 class RenderObject;
@@ -41,15 +43,17 @@
 class RenderSVGImage;
 class RenderSVGInlineText;
 class RenderSVGResourceContainer;
+class RenderSVGRoot;
 class RenderSVGShape;
-class LegacyRenderSVGRoot;
 class RenderSVGText;
-class AffineTransform;
 class SVGUnitTypes;
 
 // functions used by the main RenderTreeAsText code
+void write(WTF::TextStream&, const LegacyRenderSVGRoot&, OptionSet<RenderAsTextFlag>);
+#if ENABLE(LAYER_BASED_SVG_ENGINE)
+void write(WTF::TextStream&, const RenderSVGRoot&, OptionSet<RenderAsTextFlag>);
+#endif
 void write(WTF::TextStream&, const RenderSVGShape&, OptionSet<RenderAsTextFlag>);
-void write(WTF::TextStream&, const LegacyRenderSVGRoot&, OptionSet<RenderAsTextFlag>);
 void writeSVGGradientStop(WTF::TextStream&, const RenderSVGGradientStop&, OptionSet<RenderAsTextFlag>);
 void writeSVGResourceContainer(WTF::TextStream&, const RenderSVGResourceContainer&, OptionSet<RenderAsTextFlag>);
 void writeSVGContainer(WTF::TextStream&, const RenderSVGContainer&, OptionSet<RenderAsTextFlag>);

Modified: trunk/Source/WebCore/rendering/updating/RenderTreeBuilder.cpp (286842 => 286843)


--- trunk/Source/WebCore/rendering/updating/RenderTreeBuilder.cpp	2021-12-10 11:24:56 UTC (rev 286842)
+++ trunk/Source/WebCore/rendering/updating/RenderTreeBuilder.cpp	2021-12-10 12:19:40 UTC (rev 286843)
@@ -50,6 +50,7 @@
 #include "RenderRubyRun.h"
 #include "RenderSVGContainer.h"
 #include "RenderSVGInline.h"
+#include "RenderSVGRoot.h"
 #include "RenderSVGText.h"
 #include "RenderTable.h"
 #include "RenderTableCell.h"
@@ -290,6 +291,13 @@
         return;
     }
 
+#if ENABLE(LAYER_BASED_SVG_ENGINE)
+    if (is<RenderSVGRoot>(parent)) {
+        svgBuilder().attach(downcast<RenderSVGRoot>(parent), WTFMove(child), beforeChild);
+        return;
+    }
+#endif
+
     if (is<LegacyRenderSVGRoot>(parent)) {
         svgBuilder().attach(downcast<LegacyRenderSVGRoot>(parent), WTFMove(child), beforeChild);
         return;
@@ -374,6 +382,11 @@
     if (is<RenderSVGContainer>(parent))
         return svgBuilder().detach(downcast<RenderSVGContainer>(parent), child);
 
+#if ENABLE(LAYER_BASED_SVG_ENGINE)
+    if (is<RenderSVGRoot>(parent))
+        return svgBuilder().detach(downcast<RenderSVGRoot>(parent), child);
+#endif
+
     if (is<LegacyRenderSVGRoot>(parent))
         return svgBuilder().detach(downcast<LegacyRenderSVGRoot>(parent), child);
 

Modified: trunk/Source/WebCore/rendering/updating/RenderTreeBuilderSVG.cpp (286842 => 286843)


--- trunk/Source/WebCore/rendering/updating/RenderTreeBuilderSVG.cpp	2021-12-10 11:24:56 UTC (rev 286842)
+++ trunk/Source/WebCore/rendering/updating/RenderTreeBuilderSVG.cpp	2021-12-10 12:19:40 UTC (rev 286843)
@@ -29,6 +29,7 @@
 #include "LegacyRenderSVGRoot.h"
 #include "RenderSVGContainer.h"
 #include "RenderSVGInline.h"
+#include "RenderSVGRoot.h"
 #include "RenderSVGText.h"
 #include "RenderTreeBuilderBlock.h"
 #include "RenderTreeBuilderBlockFlow.h"
@@ -42,6 +43,13 @@
 {
 }
 
+void RenderTreeBuilder::SVG::attach(LegacyRenderSVGRoot& parent, RenderPtr<RenderObject> child, RenderObject* beforeChild)
+{
+    auto& childToAdd = *child;
+    m_builder.attachToRenderElement(parent, WTFMove(child), beforeChild);
+    SVGResourcesCache::clientWasAddedToTree(childToAdd);
+}
+
 void RenderTreeBuilder::SVG::attach(RenderSVGContainer& parent, RenderPtr<RenderObject> child, RenderObject* beforeChild)
 {
     auto& childToAdd = *child;
@@ -59,12 +67,14 @@
         textAncestor->subtreeChildWasAdded(&childToAdd);
 }
 
-void RenderTreeBuilder::SVG::attach(LegacyRenderSVGRoot& parent, RenderPtr<RenderObject> child, RenderObject* beforeChild)
+#if ENABLE(LAYER_BASED_SVG_ENGINE)
+void RenderTreeBuilder::SVG::attach(RenderSVGRoot& parent, RenderPtr<RenderObject> child, RenderObject* beforeChild)
 {
     auto& childToAdd = *child;
     m_builder.attachToRenderElement(parent, WTFMove(child), beforeChild);
     SVGResourcesCache::clientWasAddedToTree(childToAdd);
 }
+#endif
 
 void RenderTreeBuilder::SVG::attach(RenderSVGText& parent, RenderPtr<RenderObject> child, RenderObject* beforeChild)
 {
@@ -75,6 +85,12 @@
     parent.subtreeChildWasAdded(&childToAdd);
 }
 
+RenderPtr<RenderObject> RenderTreeBuilder::SVG::detach(LegacyRenderSVGRoot& parent, RenderObject& child)
+{
+    SVGResourcesCache::clientWillBeRemovedFromTree(child);
+    return m_builder.detachFromRenderElement(parent, child);
+}
+
 RenderPtr<RenderObject> RenderTreeBuilder::SVG::detach(RenderSVGText& parent, RenderObject& child)
 {
     SVGResourcesCache::clientWillBeRemovedFromTree(child);
@@ -107,10 +123,12 @@
     return m_builder.detachFromRenderElement(parent, child);
 }
 
-RenderPtr<RenderObject> RenderTreeBuilder::SVG::detach(LegacyRenderSVGRoot& parent, RenderObject& child)
+#if ENABLE(LAYER_BASED_SVG_ENGINE)
+RenderPtr<RenderObject> RenderTreeBuilder::SVG::detach(RenderSVGRoot& parent, RenderObject& child)
 {
     SVGResourcesCache::clientWillBeRemovedFromTree(child);
     return m_builder.detachFromRenderElement(parent, child);
 }
+#endif
 
 }

Modified: trunk/Source/WebCore/rendering/updating/RenderTreeBuilderSVG.h (286842 => 286843)


--- trunk/Source/WebCore/rendering/updating/RenderTreeBuilderSVG.h	2021-12-10 11:24:56 UTC (rev 286842)
+++ trunk/Source/WebCore/rendering/updating/RenderTreeBuilderSVG.h	2021-12-10 12:19:40 UTC (rev 286843)
@@ -29,9 +29,10 @@
 
 namespace WebCore {
 
+class LegacyRenderSVGRoot;
 class RenderSVGContainer;
 class RenderSVGInline;
-class LegacyRenderSVGRoot;
+class RenderSVGRoot;
 class RenderSVGText;
 
 class RenderTreeBuilder::SVG {
@@ -39,15 +40,21 @@
 public:
     SVG(RenderTreeBuilder&);
 
+    void attach(LegacyRenderSVGRoot& parent, RenderPtr<RenderObject> child, RenderObject* beforeChild);
     void attach(RenderSVGContainer& parent, RenderPtr<RenderObject> child, RenderObject* beforeChild);
     void attach(RenderSVGInline& parent, RenderPtr<RenderObject> child, RenderObject* beforeChild);
-    void attach(LegacyRenderSVGRoot& parent, RenderPtr<RenderObject> child, RenderObject* beforeChild);
+#if ENABLE(LAYER_BASED_SVG_ENGINE)
+    void attach(RenderSVGRoot& parent, RenderPtr<RenderObject> child, RenderObject* beforeChild);
+#endif
     void attach(RenderSVGText& parent, RenderPtr<RenderObject> child, RenderObject* beforeChild);
 
+    RenderPtr<RenderObject> detach(LegacyRenderSVGRoot& parent, RenderObject& child) WARN_UNUSED_RETURN;
+    RenderPtr<RenderObject> detach(RenderSVGContainer& parent, RenderObject& child) WARN_UNUSED_RETURN;
+    RenderPtr<RenderObject> detach(RenderSVGInline& parent, RenderObject& child) WARN_UNUSED_RETURN;
+#if ENABLE(LAYER_BASED_SVG_ENGINE)
+    RenderPtr<RenderObject> detach(RenderSVGRoot& parent, RenderObject& child) WARN_UNUSED_RETURN;
+#endif
     RenderPtr<RenderObject> detach(RenderSVGText& parent, RenderObject& child) WARN_UNUSED_RETURN;
-    RenderPtr<RenderObject> detach(RenderSVGInline& parent, RenderObject& child) WARN_UNUSED_RETURN;
-    RenderPtr<RenderObject> detach(RenderSVGContainer& parent, RenderObject& child) WARN_UNUSED_RETURN;
-    RenderPtr<RenderObject> detach(LegacyRenderSVGRoot& parent, RenderObject& child) WARN_UNUSED_RETURN;
 
 private:
     RenderTreeBuilder& m_builder;

Modified: trunk/Source/WebCore/svg/SVGElement.cpp (286842 => 286843)


--- trunk/Source/WebCore/svg/SVGElement.cpp	2021-12-10 11:24:56 UTC (rev 286842)
+++ trunk/Source/WebCore/svg/SVGElement.cpp	2021-12-10 12:19:40 UTC (rev 286843)
@@ -530,6 +530,14 @@
         return false;
     auto& svgChild = downcast<SVGElement>(child);
 
+#if ENABLE(LAYER_BASED_SVG_ENGINE)
+    // If the layer based SVG engine is enabled, all renderers that do not support the
+    // RenderLayer aware layout / painting / hit-testing mode ('LBSE-mode') have to be skipped.
+    // Currently all renderers are skipped.
+    if (document().settings().layerBasedSVGEngineEnabled())
+        return false;
+#endif
+
     static const QualifiedName* const invalidTextContent[] {
         &SVGNames::altGlyphTag.get(),
         &SVGNames::textPathTag.get(),

Modified: trunk/Source/WebCore/svg/SVGSVGElement.cpp (286842 => 286843)


--- trunk/Source/WebCore/svg/SVGSVGElement.cpp	2021-12-10 11:24:56 UTC (rev 286842)
+++ trunk/Source/WebCore/svg/SVGSVGElement.cpp	2021-12-10 12:19:40 UTC (rev 286843)
@@ -32,6 +32,7 @@
 #include "FrameSelection.h"
 #include "LegacyRenderSVGRoot.h"
 #include "RenderSVGResource.h"
+#include "RenderSVGRoot.h"
 #include "RenderSVGViewportContainer.h"
 #include "RenderView.h"
 #include "SMILTimeContainer.h"
@@ -211,6 +212,10 @@
         invalidateSVGPresentationalHintStyle();
 
         if (auto renderer = this->renderer()) {
+#if ENABLE(LAYER_BASED_SVG_ENGINE)
+            if (is<RenderSVGRoot>(renderer) && downcast<RenderSVGRoot>(*renderer).isEmbeddedThroughFrameContainingSVGDocument())
+                RenderSVGResource::markForLayoutAndParentResourceInvalidation(*renderer);
+#endif
             if (is<LegacyRenderSVGRoot>(renderer) && downcast<LegacyRenderSVGRoot>(*renderer).isEmbeddedThroughFrameContainingSVGDocument())
                 RenderSVGResource::markForLayoutAndParentResourceInvalidation(*renderer);
         }
@@ -475,10 +480,16 @@
     if (!viewBox.isEmpty())
         return viewBox;
 
-    if (!is<LegacyRenderSVGRoot>(renderer()))
+    bool isEmbeddedThroughSVGImage = false;
+    if (is<LegacyRenderSVGRoot>(renderer()) && downcast<LegacyRenderSVGRoot>(*renderer()).isEmbeddedThroughSVGImage())
+        isEmbeddedThroughSVGImage = true;
+#if ENABLE(LAYER_BASED_SVG_ENGINE)
+    else if (is<RenderSVGRoot>(renderer()) && downcast<RenderSVGRoot>(*renderer()).isEmbeddedThroughSVGImage())
+        isEmbeddedThroughSVGImage = true;
+#endif
+
+    if (!isEmbeddedThroughSVGImage)
         return { };
-    if (!downcast<LegacyRenderSVGRoot>(*renderer()).isEmbeddedThroughSVGImage())
-        return { };
 
     Length intrinsicWidth = this->intrinsicWidth();
     Length intrinsicHeight = this->intrinsicHeight();
@@ -486,7 +497,7 @@
         return { };
 
     // If no viewBox is specified but non-relative width/height values, then we
-    // should always synthesize a viewBox if we're embedded through a SVGImage.    
+    // should always synthesize a viewBox if we're embedded through a SVGImage.
     return { 0, 0, floatValueForLength(intrinsicWidth, 0), floatValueForLength(intrinsicHeight, 0) };
 }
 
@@ -498,6 +509,11 @@
         if (is<LegacyRenderSVGRoot>(*renderer())) {
             auto& root = downcast<LegacyRenderSVGRoot>(*renderer());
             viewportSize = root.contentBoxRect().size() / root.style().effectiveZoom();
+#if ENABLE(LAYER_BASED_SVG_ENGINE)
+        } else if (is<RenderSVGRoot>(*renderer())) {
+            auto& root = downcast<RenderSVGRoot>(*renderer());
+            viewportSize = root.contentBoxRect().size() / root.style().effectiveZoom();
+#endif
         } else
             viewportSize = downcast<RenderSVGViewportContainer>(*renderer()).viewport().size();
     }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to