Diff
Modified: trunk/Source/WebCore/ChangeLog (290879 => 290880)
--- trunk/Source/WebCore/ChangeLog 2022-03-07 10:19:52 UTC (rev 290879)
+++ trunk/Source/WebCore/ChangeLog 2022-03-07 11:16:26 UTC (rev 290880)
@@ -1,3 +1,41 @@
+2022-03-07 Nikolas Zimmermann <[email protected]>
+
+ [LBSE] Begin layer-aware RenderSVGTransformableContainer implementation
+ https://bugs.webkit.org/show_bug.cgi?id=237024
+
+ Reviewed by Rob Buis.
+
+ Create RenderSVGContainer based on the downstream LBSE implementation.
+
+ This patch does not yet enable the creation of RenderSVGContainer
+ renderers if LBSE is enabled, since the derived classes, such as
+ RenderSVGHiddenContainer / RenderSVGViewportContainer / ..., are still
+ missing in LBSE.
+
+ Covered by existing tests, no change in behaviour.
+
+ * Sources.txt: Add RenderSVGTransformableContainer.* to build.
+ * WebCore.xcodeproj/project.pbxproj: Ditto.
+ * rendering/RenderObject.h:
+ (WebCore::RenderObject::isSVGTransformableContainer const):
+ * rendering/svg/RenderSVGTransformableContainer.cpp: Added.
+ (WebCore::RenderSVGTransformableContainer::RenderSVGTransformableContainer):
+ (WebCore::associatedUseElement):
+ (WebCore::RenderSVGTransformableContainer::additionalContainerTranslation const):
+ (WebCore::RenderSVGTransformableContainer::calculateViewport):
+ (WebCore::RenderSVGTransformableContainer::layoutChildren):
+ (WebCore::RenderSVGTransformableContainer::updateFromStyle):
+ (WebCore::RenderSVGTransformableContainer::applyTransform const):
+ (WebCore::RenderSVGTransformableContainer::styleWillChange):
+ (WebCore::RenderSVGTransformableContainer::graphicsElement const):
+ * rendering/svg/RenderSVGTransformableContainer.h: Added.
+ * rendering/svg/SVGContainerLayout.cpp:
+ (WebCore::SVGContainerLayout::transformToRootChanged):
+ * svg/SVGElement.cpp: Create renderer for <g> elements in LBSE mode.
+ (WebCore::createSVGLayerAwareElementSet):
+ * svg/SVGGElement.cpp: Ditto.
+ (WebCore::SVGGElement::createElementRenderer):
+
2022-03-07 Matt Woodrow <[email protected]>
Compute correct containing block override size for items that are subgridden in one dimension only.
Modified: trunk/Source/WebCore/Sources.txt (290879 => 290880)
--- trunk/Source/WebCore/Sources.txt 2022-03-07 10:19:52 UTC (rev 290879)
+++ trunk/Source/WebCore/Sources.txt 2022-03-07 11:16:26 UTC (rev 290880)
@@ -2511,6 +2511,7 @@
rendering/svg/RenderSVGTSpan.cpp
rendering/svg/RenderSVGText.cpp
rendering/svg/RenderSVGTextPath.cpp
+rendering/svg/RenderSVGTransformableContainer.cpp
rendering/svg/RenderSVGViewportContainer.cpp
rendering/svg/SVGBoundingBoxComputation.cpp
rendering/svg/SVGContainerLayout.cpp
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (290879 => 290880)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2022-03-07 10:19:52 UTC (rev 290879)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2022-03-07 11:16:26 UTC (rev 290880)
@@ -1263,6 +1263,7 @@
436708E312D9CA4B00044234 /* RenderSVGResourceSolidColor.h in Headers */ = {isa = PBXBuildFile; fileRef = 436708A412D9CA4B00044234 /* RenderSVGResourceSolidColor.h */; };
436708E512D9CA4B00044234 /* LegacyRenderSVGRoot.h in Headers */ = {isa = PBXBuildFile; fileRef = 436708A612D9CA4B00044234 /* LegacyRenderSVGRoot.h */; };
436708E512D9DB4B00044234 /* RenderSVGRoot.h in Headers */ = {isa = PBXBuildFile; fileRef = 436708A612D9DB4B00044234 /* RenderSVGRoot.h */; };
+ 436707E724C9CA4B10044234 /* RenderSVGTransformableContainer.h in Headers */ = {isa = PBXBuildFile; fileRef = 436718BB12D9CA4B00042234 /* RenderSVGTransformableContainer.h */; };
436708E912D9CA4B00044234 /* LegacyRenderSVGTransformableContainer.h in Headers */ = {isa = PBXBuildFile; fileRef = 436708AA12D9CA4B00044234 /* LegacyRenderSVGTransformableContainer.h */; };
436708EB12D9CA4B00044234 /* RenderSVGViewportContainer.h in Headers */ = {isa = PBXBuildFile; fileRef = 436708AC12D9CA4B00044234 /* RenderSVGViewportContainer.h */; };
436708EE12D9CA4B00044234 /* SVGMarkerData.h in Headers */ = {isa = PBXBuildFile; fileRef = 436708AF12D9CA4B00044234 /* SVGMarkerData.h */; };
@@ -9095,7 +9096,9 @@
436708A512D9CA5C00044234 /* RenderSVGRoot.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderSVGRoot.cpp; sourceTree = "<group>"; };
436708A612D9CA4B00044234 /* LegacyRenderSVGRoot.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LegacyRenderSVGRoot.h; sourceTree = "<group>"; };
436708A612D9DB4B00044234 /* RenderSVGRoot.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderSVGRoot.h; sourceTree = "<group>"; };
+ 436708B812C9CA4C00011434 /* RenderSVGTransformableContainer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderSVGTransformableContainer.cpp; sourceTree = "<group>"; };
436708A912D9CA4B00044234 /* LegacyRenderSVGTransformableContainer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LegacyRenderSVGTransformableContainer.cpp; sourceTree = "<group>"; };
+ 436718BB12D9CA4B00042234 /* RenderSVGTransformableContainer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderSVGTransformableContainer.h; sourceTree = "<group>"; };
436708AA12D9CA4B00044234 /* LegacyRenderSVGTransformableContainer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LegacyRenderSVGTransformableContainer.h; sourceTree = "<group>"; };
436708AB12D9CA4B00044234 /* RenderSVGViewportContainer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderSVGViewportContainer.cpp; sourceTree = "<group>"; };
436708AC12D9CA4B00044234 /* RenderSVGViewportContainer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderSVGViewportContainer.h; sourceTree = "<group>"; };
@@ -19148,6 +19151,8 @@
0854B0071255E4E600B9CDD0 /* RenderSVGText.h */,
0854B0081255E4E600B9CDD0 /* RenderSVGTextPath.cpp */,
0854B0091255E4E600B9CDD0 /* RenderSVGTextPath.h */,
+ 436708B812C9CA4C00011434 /* RenderSVGTransformableContainer.cpp */,
+ 436718BB12D9CA4B00042234 /* RenderSVGTransformableContainer.h */,
0854B00B1255E4E600B9CDD0 /* RenderSVGTSpan.h */,
436708AB12D9CA4B00044234 /* RenderSVGViewportContainer.cpp */,
436708AC12D9CA4B00044234 /* RenderSVGViewportContainer.h */,
@@ -37005,6 +37010,7 @@
CDF747F7270F83B4107DEEEC /* RenderSVGShapeInlines.h in Headers */,
0854B0191255E4E600B9CDD0 /* RenderSVGText.h in Headers */,
0854B01B1255E4E600B9CDD0 /* RenderSVGTextPath.h in Headers */,
+ 436707E724C9CA4B10044234 /* RenderSVGTransformableContainer.h in Headers */,
0854B01D1255E4E600B9CDD0 /* RenderSVGTSpan.h in Headers */,
436708EB12D9CA4B00044234 /* RenderSVGViewportContainer.h in Headers */,
A8DF4AEB0980C42C0052981B /* RenderTable.h in Headers */,
Modified: trunk/Source/WebCore/rendering/RenderObject.h (290879 => 290880)
--- trunk/Source/WebCore/rendering/RenderObject.h 2022-03-07 10:19:52 UTC (rev 290879)
+++ trunk/Source/WebCore/rendering/RenderObject.h 2022-03-07 11:16:26 UTC (rev 290880)
@@ -327,6 +327,7 @@
virtual bool isSVGRoot() const { return false; }
virtual bool isSVGContainer() const { return false; }
virtual bool isLegacySVGContainer() const { return false; }
+ virtual bool isSVGTransformableContainer() const { return false; }
virtual bool isLegacySVGTransformableContainer() const { return false; }
virtual bool isSVGViewportContainer() const { return false; }
virtual bool isSVGGradientStop() const { return false; }
Added: trunk/Source/WebCore/rendering/svg/RenderSVGTransformableContainer.cpp (0 => 290880)
--- trunk/Source/WebCore/rendering/svg/RenderSVGTransformableContainer.cpp (rev 0)
+++ trunk/Source/WebCore/rendering/svg/RenderSVGTransformableContainer.cpp 2022-03-07 11:16:26 UTC (rev 290880)
@@ -0,0 +1,126 @@
+/*
+ * Copyright (C) 2004, 2005 Nikolas Zimmermann <[email protected]>
+ * Copyright (C) 2004, 2005, 2006 Rob Buis <[email protected]>
+ * Copyright (C) 2009 Google, Inc.
+ * Copyright (c) 2020, 2021, 2022 Igalia S.L.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "config.h"
+#include "RenderSVGTransformableContainer.h"
+
+#if ENABLE(LAYER_BASED_SVG_ENGINE)
+#include "RenderSVGModelObjectInlines.h"
+#include "SVGContainerLayout.h"
+#include "SVGElementTypeHelpers.h"
+#include "SVGGElement.h"
+#include "SVGGraphicsElement.h"
+#include "SVGPathData.h"
+#include "SVGUseElement.h"
+#include <wtf/IsoMallocInlines.h>
+
+namespace WebCore {
+
+WTF_MAKE_ISO_ALLOCATED_IMPL(RenderSVGTransformableContainer);
+
+RenderSVGTransformableContainer::RenderSVGTransformableContainer(SVGGraphicsElement& element, RenderStyle&& style)
+ : RenderSVGContainer(element, WTFMove(style))
+{
+}
+
+inline SVGUseElement* associatedUseElement(SVGGraphicsElement& element)
+{
+ // If we're either the renderer for a <use> element, or for any <g> element inside the shadow
+ // tree, that was created during the use/symbol/svg expansion in SVGUseElement. These containers
+ // need to respect the translations induced by their corresponding use elements x/y attributes.
+ if (is<SVGUseElement>(element))
+ return &downcast<SVGUseElement>(element);
+
+ if (element.isInShadowTree() && is<SVGGElement>(element)) {
+ SVGElement* correspondingElement = element.correspondingElement();
+ if (is<SVGUseElement>(correspondingElement))
+ return downcast<SVGUseElement>(correspondingElement);
+ }
+
+ return nullptr;
+}
+
+FloatPoint RenderSVGTransformableContainer::additionalContainerTranslation() const
+{
+ if (auto* useElement = associatedUseElement(graphicsElement())) {
+ // FIXME: [LBSE] Upstream SVGLengthContext changes
+ // const auto& lengthContext = useElement->lengthContext();
+ SVGLengthContext lengthContext(useElement);
+ return { useElement->x().value(lengthContext), useElement->y().value(lengthContext) };
+ }
+
+ return { };
+}
+
+void RenderSVGTransformableContainer::calculateViewport()
+{
+ RenderSVGContainer::calculateViewport();
+
+ // FIXME: [LBSE] Upstream SVGLengthContext changes
+ // if (auto* useElement = associatedUseElement(graphicsElement()))
+ // useElement->updateLengthContext();
+
+ m_supplementalLocalToParentTransform.makeIdentity();
+
+ auto translation = additionalContainerTranslation();
+ m_supplementalLocalToParentTransform.translate(translation.x(), translation.y());
+
+ m_didTransformToRootUpdate = m_hadTransformUpdate || SVGContainerLayout::transformToRootChanged(parent());
+}
+
+void RenderSVGTransformableContainer::layoutChildren()
+{
+ RenderSVGContainer::layoutChildren();
+ m_didTransformToRootUpdate = false;
+}
+
+void RenderSVGTransformableContainer::updateFromStyle()
+{
+ RenderSVGContainer::updateFromStyle();
+
+ // FIXME: [LBSE] Upstream CSS/SVG transform support
+ // if (associatedUseElement(graphicsElement()))
+ // setHasSVGTransform();
+}
+
+void RenderSVGTransformableContainer::applyTransform(TransformationMatrix& transform, const FloatRect& boundingBox, OptionSet<RenderStyle::TransformOperationOption> options) const
+{
+ // FIXME: [LBSE] Upstream CSS/SVG transform support
+ RenderSVGContainer::applyTransform(transform, boundingBox, options);
+}
+
+void RenderSVGTransformableContainer::styleWillChange(StyleDifference diff, const RenderStyle& newStyle)
+{
+ const RenderStyle* oldStyle = hasInitializedStyle() ? &style() : nullptr;
+ if (oldStyle && oldStyle->transform() != newStyle.transform())
+ setHadTransformUpdate();
+ RenderSVGContainer::styleWillChange(diff, newStyle);
+}
+
+SVGGraphicsElement& RenderSVGTransformableContainer::graphicsElement() const
+{
+ return downcast<SVGGraphicsElement>(RenderSVGContainer::element());
+}
+
+}
+
+#endif // ENABLE(LAYER_BASED_SVG_ENGINE)
Added: trunk/Source/WebCore/rendering/svg/RenderSVGTransformableContainer.h (0 => 290880)
--- trunk/Source/WebCore/rendering/svg/RenderSVGTransformableContainer.h (rev 0)
+++ trunk/Source/WebCore/rendering/svg/RenderSVGTransformableContainer.h 2022-03-07 11:16:26 UTC (rev 290880)
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2007 Eric Seidel <[email protected]>
+ * Copyright (C) 2009 Google, Inc.
+ * Copyright (c) 2020, 2021, 2022 Igalia S.L.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#pragma once
+
+#if ENABLE(LAYER_BASED_SVG_ENGINE)
+#include "RenderSVGContainer.h"
+
+namespace WebCore {
+
+class SVGGraphicsElement;
+
+class RenderSVGTransformableContainer final : public RenderSVGContainer {
+ WTF_MAKE_ISO_ALLOCATED(RenderSVGTransformableContainer);
+public:
+ RenderSVGTransformableContainer(SVGGraphicsElement&, RenderStyle&&);
+
+ bool isSVGTransformableContainer() const final { return true; }
+ void setHadTransformUpdate(bool value = true) { m_hadTransformUpdate = value; }
+ bool didTransformToRootUpdate() const { return m_didTransformToRootUpdate; }
+
+private:
+ SVGGraphicsElement& graphicsElement() const;
+
+ void element() const = delete;
+
+ void layoutChildren() final;
+ void calculateViewport() final;
+ FloatPoint additionalContainerTranslation() const;
+ void applyTransform(TransformationMatrix&, const FloatRect& boundingBox, OptionSet<RenderStyle::TransformOperationOption> = RenderStyle::allTransformOperations) const final;
+ void styleWillChange(StyleDifference, const RenderStyle& newStyle) final;
+ void updateFromStyle() final;
+
+ AffineTransform m_supplementalLocalToParentTransform;
+ bool m_didTransformToRootUpdate { false };
+ bool m_hadTransformUpdate { false };
+};
+
+} // namespace WebCore
+
+SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderSVGTransformableContainer, isSVGTransformableContainer())
+
+#endif // ENABLE(LAYER_BASED_SVG_ENGINE)
Modified: trunk/Source/WebCore/rendering/svg/SVGContainerLayout.cpp (290879 => 290880)
--- trunk/Source/WebCore/rendering/svg/SVGContainerLayout.cpp 2022-03-07 10:19:52 UTC (rev 290879)
+++ trunk/Source/WebCore/rendering/svg/SVGContainerLayout.cpp 2022-03-07 11:16:26 UTC (rev 290880)
@@ -39,6 +39,7 @@
#include "RenderSVGRoot.h"
#include "RenderSVGShape.h"
#include "RenderSVGText.h"
+#include "RenderSVGTransformableContainer.h"
#include "RenderSVGViewportContainer.h"
#include "SVGRenderSupport.h"
#include "SVGRenderingContext.h"
@@ -271,11 +272,10 @@
bool SVGContainerLayout::transformToRootChanged(const RenderObject* ancestor)
{
while (ancestor) {
- // FIXME: [LBSE] Upstream RenderSVGTransformableContainer changes
- // if (is<RenderSVGTransformableContainer>(*ancestor))
- // return downcast<const RenderSVGTransformableContainer>(*ancestor).didTransformToRootUpdate();
+ if (is<RenderSVGTransformableContainer>(*ancestor))
+ return downcast<const RenderSVGTransformableContainer>(*ancestor).didTransformToRootUpdate();
- // FIXME: [LBSE] Upstream RenderSVGTransformableContainer changes
+ // FIXME: [LBSE] Upstream RenderSVGViewportContainer changes
// if (is<RenderSVGViewportContainer>(*ancestor))
// return downcast<const RenderSVGViewportContainer>(*ancestor).didTransformToRootUpdate();
Modified: trunk/Source/WebCore/svg/SVGElement.cpp (290879 => 290880)
--- trunk/Source/WebCore/svg/SVGElement.cpp 2022-03-07 10:19:52 UTC (rev 290879)
+++ trunk/Source/WebCore/svg/SVGElement.cpp 2022-03-07 11:16:26 UTC (rev 290880)
@@ -531,7 +531,7 @@
// List of all SVG elements whose renderers support the layer aware layout / painting / hit-testing mode ('LBSE-mode').
using namespace SVGNames;
MemoryCompactLookupOnlyRobinHoodHashSet<AtomString> set;
- for (auto& tag : { rectTag.get() })
+ for (auto& tag : { gTag.get(), rectTag.get() })
set.add(tag.localName());
return set;
}
Modified: trunk/Source/WebCore/svg/SVGGElement.cpp (290879 => 290880)
--- trunk/Source/WebCore/svg/SVGGElement.cpp 2022-03-07 10:19:52 UTC (rev 290879)
+++ trunk/Source/WebCore/svg/SVGGElement.cpp 2022-03-07 11:16:26 UTC (rev 290880)
@@ -25,6 +25,7 @@
#include "LegacyRenderSVGTransformableContainer.h"
#include "RenderSVGHiddenContainer.h"
#include "RenderSVGResource.h"
+#include "RenderSVGTransformableContainer.h"
#include "SVGNames.h"
#include <wtf/IsoMallocInlines.h>
#include <wtf/NeverDestroyed.h>
@@ -51,6 +52,12 @@
RenderPtr<RenderElement> SVGGElement::createElementRenderer(RenderStyle&& style, const RenderTreePosition&)
{
+#if ENABLE(LAYER_BASED_SVG_ENGINE)
+ // FIXME: [LBSE] Support hidden containers
+ if (document().settings().layerBasedSVGEngineEnabled())
+ return createRenderer<RenderSVGTransformableContainer>(*this, WTFMove(style));
+#endif
+
// SVG 1.1 testsuite explicitly uses constructs like <g display="none"><linearGradient>
// We still have to create renderers for the <g> & <linearGradient> element, though the
// subtree may be hidden - we only want the resource renderers to exist so they can be