Diff
Modified: trunk/Source/WebCore/ChangeLog (287742 => 287743)
--- trunk/Source/WebCore/ChangeLog 2022-01-07 08:45:30 UTC (rev 287742)
+++ trunk/Source/WebCore/ChangeLog 2022-01-07 13:02:32 UTC (rev 287743)
@@ -1,3 +1,31 @@
+2022-01-06 Nikolas Zimmermann <nzimmerm...@igalia.com>
+
+ [LBSE] Rename RenderSVGRect -> LegacyRenderSVGRect
+ https://bugs.webkit.org/show_bug.cgi?id=234878
+
+ Reviewed by Rob Buis.
+
+ Following the established procedure: rename RenderSVGRect -> LegacyRenderSVGRect.
+ In a follow-up patch RenderSVGRect will be reintroduced for LBSE, inheriting from
+ RenderSVGShape instead of LegacyRenderSVGShape.
+
+ Covered by existing tests, no change in behaviour.
+
+ * Sources.txt:
+ * WebCore.xcodeproj/project.pbxproj:
+ * rendering/svg/LegacyRenderSVGRect.cpp: Renamed from Source/WebCore/rendering/svg/RenderSVGRect.cpp.
+ (WebCore::LegacyRenderSVGRect::LegacyRenderSVGRect):
+ (WebCore::LegacyRenderSVGRect::rectElement const):
+ (WebCore::LegacyRenderSVGRect::updateShapeFromElement):
+ (WebCore::LegacyRenderSVGRect::fillShape const):
+ (WebCore::LegacyRenderSVGRect::strokeShape const):
+ (WebCore::LegacyRenderSVGRect::shapeDependentStrokeContains):
+ (WebCore::LegacyRenderSVGRect::shapeDependentFillContains const):
+ (WebCore::LegacyRenderSVGRect::isRenderingDisabled const):
+ * rendering/svg/LegacyRenderSVGRect.h: Renamed from Source/WebCore/rendering/svg/RenderSVGRect.h.
+ * svg/SVGRectElement.cpp:
+ (WebCore::SVGRectElement::createElementRenderer):
+
2022-01-07 Martin Robinson <mrobin...@webkit.org>
When transform-style: preserve-3d is used with a grouping property it should still create a containing block
Modified: trunk/Source/WebCore/Sources.txt (287742 => 287743)
--- trunk/Source/WebCore/Sources.txt 2022-01-07 08:45:30 UTC (rev 287742)
+++ trunk/Source/WebCore/Sources.txt 2022-01-07 13:02:32 UTC (rev 287743)
@@ -2467,6 +2467,7 @@
rendering/style/TextSizeAdjustment.cpp
rendering/style/WillChangeData.cpp
rendering/svg/LegacyRenderSVGModelObject.cpp
+rendering/svg/LegacyRenderSVGRect.cpp
rendering/svg/LegacyRenderSVGRoot.cpp
rendering/svg/LegacyRenderSVGShape.cpp
rendering/svg/RenderSVGBlock.cpp
@@ -2480,7 +2481,6 @@
rendering/svg/RenderSVGInlineText.cpp
rendering/svg/RenderSVGModelObject.cpp
rendering/svg/RenderSVGPath.cpp
-rendering/svg/RenderSVGRect.cpp
rendering/svg/RenderSVGResource.cpp
rendering/svg/RenderSVGResourceClipper.cpp
rendering/svg/RenderSVGResourceContainer.cpp
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (287742 => 287743)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2022-01-07 08:45:30 UTC (rev 287742)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2022-01-07 13:02:32 UTC (rev 287743)
@@ -3270,7 +3270,7 @@
A104EC5D220A3E4B00CBF67A /* JSMockPaymentContactFields.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A104EC5B220A3E4300CBF67A /* JSMockPaymentContactFields.cpp */; };
A104EC5E220A3E4E00CBF67A /* JSMockPaymentContactFields.h in Headers */ = {isa = PBXBuildFile; fileRef = A104EC5C220A3E4400CBF67A /* JSMockPaymentContactFields.h */; };
A104F24414C71F7A009E2C23 /* CachedSVGDocument.h in Headers */ = {isa = PBXBuildFile; fileRef = A104F24214C71F7A009E2C23 /* CachedSVGDocument.h */; settings = {ATTRIBUTES = (Private, ); }; };
- A10BB5851484E3A700B2E87A /* RenderSVGRect.h in Headers */ = {isa = PBXBuildFile; fileRef = A10BB5831484E3A700B2E87A /* RenderSVGRect.h */; };
+ A10BB5851484E3A700B2E87A /* LegacyRenderSVGRect.h in Headers */ = {isa = PBXBuildFile; fileRef = A10BB5831484E3A700B2E87A /* LegacyRenderSVGRect.h */; };
A10BB58B1484E3B300B2E87A /* LegacyRenderSVGShape.h in Headers */ = {isa = PBXBuildFile; fileRef = A10BB5891484E3B300B2E87A /* LegacyRenderSVGShape.h */; };
A10DBF4718F92317000D70C6 /* LegacyPreviewLoaderClient.h in Headers */ = {isa = PBXBuildFile; fileRef = A10DBF4618F92317000D70C6 /* LegacyPreviewLoaderClient.h */; settings = {ATTRIBUTES = (Private, ); }; };
A10DC76B14747BAB005E2471 /* StyleGridData.h in Headers */ = {isa = PBXBuildFile; fileRef = A10DC76914747BAB005E2471 /* StyleGridData.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -13374,8 +13374,8 @@
A104EC5C220A3E4400CBF67A /* JSMockPaymentContactFields.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = JSMockPaymentContactFields.h; sourceTree = "<group>"; };
A104F24114C71F7A009E2C23 /* CachedSVGDocument.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CachedSVGDocument.cpp; sourceTree = "<group>"; };
A104F24214C71F7A009E2C23 /* CachedSVGDocument.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CachedSVGDocument.h; sourceTree = "<group>"; };
- A10BB5821484E3A700B2E87A /* RenderSVGRect.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderSVGRect.cpp; sourceTree = "<group>"; };
- A10BB5831484E3A700B2E87A /* RenderSVGRect.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderSVGRect.h; sourceTree = "<group>"; };
+ A10BB5821484E3A700B2E87A /* LegacyRenderSVGRect.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LegacyRenderSVGRect.cpp; sourceTree = "<group>"; };
+ A10BB5831484E3A700B2E87A /* LegacyRenderSVGRect.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LegacyRenderSVGRect.h; sourceTree = "<group>"; };
A10BB5881484E3B300B2E87A /* LegacyRenderSVGShape.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LegacyRenderSVGShape.cpp; sourceTree = "<group>"; };
A10BB5891484E3B300B2E87A /* LegacyRenderSVGShape.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LegacyRenderSVGShape.h; sourceTree = "<group>"; };
A10D6E942144C99800FDD14D /* JSPaymentResponseCustom.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = JSPaymentResponseCustom.cpp; sourceTree = "<group>"; };
@@ -18906,6 +18906,8 @@
children = (
4367088B12D9CA4A00044234 /* LegacyRenderSVGModelObject.cpp */,
4367088C12D9CA4A00044234 /* LegacyRenderSVGModelObject.h */,
+ A10BB5821484E3A700B2E87A /* LegacyRenderSVGRect.cpp */,
+ A10BB5831484E3A700B2E87A /* LegacyRenderSVGRect.h */,
436708A512D9CA4B00044234 /* LegacyRenderSVGRoot.cpp */,
436708A612D9CA4B00044234 /* LegacyRenderSVGRoot.h */,
A10BB5881484E3B300B2E87A /* LegacyRenderSVGShape.cpp */,
@@ -18936,8 +18938,6 @@
436708FD12D9CA4A00032114 /* RenderSVGModelObject.h */,
ADDF1AD41257CD9A0003A759 /* RenderSVGPath.cpp */,
ADDF1AD51257CD9A0003A759 /* RenderSVGPath.h */,
- A10BB5821484E3A700B2E87A /* RenderSVGRect.cpp */,
- A10BB5831484E3A700B2E87A /* RenderSVGRect.h */,
4367088D12D9CA4A00044234 /* RenderSVGResource.cpp */,
4367088E12D9CA4A00044234 /* RenderSVGResource.h */,
4367088F12D9CA4A00044234 /* RenderSVGResourceClipper.cpp */,
@@ -35909,6 +35909,7 @@
A185B42A1E8211A100DC9118 /* LegacyPreviewLoader.h in Headers */,
A10DBF4718F92317000D70C6 /* LegacyPreviewLoaderClient.h in Headers */,
436708CB12D9CA4B00044234 /* LegacyRenderSVGModelObject.h in Headers */,
+ A10BB5851484E3A700B2E87A /* LegacyRenderSVGRect.h in Headers */,
436708E512D9CA4B00044234 /* LegacyRenderSVGRoot.h in Headers */,
A10BB58B1484E3B300B2E87A /* LegacyRenderSVGShape.h in Headers */,
CDF747F7270F86A4008FEEEC /* LegacyRenderSVGShapeInlines.h in Headers */,
@@ -36726,7 +36727,6 @@
0854B0171255E4E600B9CDD0 /* RenderSVGInlineText.h in Headers */,
43670C9342D9BC4B00044234 /* RenderSVGModelObject.h in Headers */,
ADDF1AD71257CD9A0003A759 /* RenderSVGPath.h in Headers */,
- A10BB5851484E3A700B2E87A /* RenderSVGRect.h in Headers */,
436708CD12D9CA4B00044234 /* RenderSVGResource.h in Headers */,
436708CF12D9CA4B00044234 /* RenderSVGResourceClipper.h in Headers */,
CDF747EF270F6F8D008FEEEC /* RenderSVGResourceClipperInlines.h in Headers */,
Copied: trunk/Source/WebCore/rendering/svg/LegacyRenderSVGRect.cpp (from rev 287742, trunk/Source/WebCore/rendering/svg/RenderSVGRect.cpp) (0 => 287743)
--- trunk/Source/WebCore/rendering/svg/LegacyRenderSVGRect.cpp (rev 0)
+++ trunk/Source/WebCore/rendering/svg/LegacyRenderSVGRect.cpp 2022-01-07 13:02:32 UTC (rev 287743)
@@ -0,0 +1,162 @@
+/*
+ * Copyright (C) 2011 University of Szeged
+ * Copyright (C) 2011 Renata Hodovan <r...@webkit.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY UNIVERSITY OF SZEGED ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL UNIVERSITY OF SZEGED OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "LegacyRenderSVGRect.h"
+
+#include "LegacyRenderSVGShapeInlines.h"
+#include "SVGElementTypeHelpers.h"
+#include <wtf/IsoMallocInlines.h>
+
+namespace WebCore {
+
+WTF_MAKE_ISO_ALLOCATED_IMPL(LegacyRenderSVGRect);
+
+LegacyRenderSVGRect::LegacyRenderSVGRect(SVGRectElement& element, RenderStyle&& style)
+ : LegacyRenderSVGShape(element, WTFMove(style))
+ , m_usePathFallback(false)
+{
+}
+
+LegacyRenderSVGRect::~LegacyRenderSVGRect() = default;
+
+SVGRectElement& LegacyRenderSVGRect::rectElement() const
+{
+ return downcast<SVGRectElement>(LegacyRenderSVGShape::graphicsElement());
+}
+
+void LegacyRenderSVGRect::updateShapeFromElement()
+{
+ // Before creating a new object we need to clear the cached bounding box
+ // to avoid using garbage.
+ m_fillBoundingBox = FloatRect();
+ m_innerStrokeRect = FloatRect();
+ m_outerStrokeRect = FloatRect();
+ clearPath();
+ m_usePathFallback = false;
+
+ SVGLengthContext lengthContext(&rectElement());
+ FloatSize boundingBoxSize(lengthContext.valueForLength(style().width(), SVGLengthMode::Width), lengthContext.valueForLength(style().height(), SVGLengthMode::Height));
+
+ // Spec: "A negative value is illegal. A value of zero disables rendering of the element."
+ if (boundingBoxSize.isEmpty())
+ return;
+
+ if (rectElement().rx().value(lengthContext) > 0 || rectElement().ry().value(lengthContext) > 0 || hasNonScalingStroke()) {
+ // Fall back to LegacyRenderSVGShape
+ LegacyRenderSVGShape::updateShapeFromElement();
+ m_usePathFallback = true;
+ return;
+ }
+
+ m_fillBoundingBox = FloatRect(FloatPoint(lengthContext.valueForLength(style().svgStyle().x(), SVGLengthMode::Width),
+ lengthContext.valueForLength(style().svgStyle().y(), SVGLengthMode::Height)),
+ boundingBoxSize);
+
+ // To decide if the stroke contains a point we create two rects which represent the inner and
+ // the outer stroke borders. A stroke contains the point, if the point is between them.
+ m_innerStrokeRect = m_fillBoundingBox;
+ m_outerStrokeRect = m_fillBoundingBox;
+
+ if (style().svgStyle().hasStroke()) {
+ float strokeWidth = this->strokeWidth();
+ m_innerStrokeRect.inflate(-strokeWidth / 2);
+ m_outerStrokeRect.inflate(strokeWidth / 2);
+ }
+
+ m_strokeBoundingBox = m_outerStrokeRect;
+
+#if USE(CG)
+ // CoreGraphics can inflate the stroke by 1px when drawing a rectangle with antialiasing disabled at non-integer coordinates, we need to compensate.
+ if (style().svgStyle().shapeRendering() == ShapeRendering::CrispEdges)
+ m_strokeBoundingBox.inflate(1);
+#endif
+}
+
+void LegacyRenderSVGRect::fillShape(GraphicsContext& context) const
+{
+ if (m_usePathFallback) {
+ LegacyRenderSVGShape::fillShape(context);
+ return;
+ }
+
+#if USE(CG)
+ // FIXME: CG implementation of GraphicsContextCG::fillRect has an own
+ // shadow drawing method, which draws an extra shadow.
+ // This is a workaround for switching off the extra shadow.
+ // https://bugs.webkit.org/show_bug.cgi?id=68899
+ if (context.hasShadow()) {
+ GraphicsContextStateSaver stateSaver(context);
+ context.clearShadow();
+ context.fillRect(m_fillBoundingBox);
+ return;
+ }
+#endif
+
+ context.fillRect(m_fillBoundingBox);
+}
+
+void LegacyRenderSVGRect::strokeShape(GraphicsContext& context) const
+{
+ if (!style().hasVisibleStroke())
+ return;
+
+ if (m_usePathFallback) {
+ LegacyRenderSVGShape::strokeShape(context);
+ return;
+ }
+
+ context.strokeRect(m_fillBoundingBox, strokeWidth());
+}
+
+bool LegacyRenderSVGRect::shapeDependentStrokeContains(const FloatPoint& point, PointCoordinateSpace pointCoordinateSpace)
+{
+ // The optimized contains code below does not support non-smooth strokes so we need
+ // to fall back to LegacyRenderSVGShape::shapeDependentStrokeContains in these cases.
+ if (m_usePathFallback || !hasSmoothStroke()) {
+ if (!hasPath())
+ LegacyRenderSVGShape::updateShapeFromElement();
+ return LegacyRenderSVGShape::shapeDependentStrokeContains(point, pointCoordinateSpace);
+ }
+
+ return m_outerStrokeRect.contains(point, FloatRect::InsideOrOnStroke) && !m_innerStrokeRect.contains(point, FloatRect::InsideButNotOnStroke);
+}
+
+bool LegacyRenderSVGRect::shapeDependentFillContains(const FloatPoint& point, const WindRule fillRule) const
+{
+ if (m_usePathFallback)
+ return LegacyRenderSVGShape::shapeDependentFillContains(point, fillRule);
+ return m_fillBoundingBox.contains(point.x(), point.y());
+}
+
+bool LegacyRenderSVGRect::isRenderingDisabled() const
+{
+ // A width or height of zero disables rendering for the element, and results in an empty bounding box.
+ return m_fillBoundingBox.isEmpty();
+}
+
+}
Copied: trunk/Source/WebCore/rendering/svg/LegacyRenderSVGRect.h (from rev 287742, trunk/Source/WebCore/rendering/svg/RenderSVGRect.h) (0 => 287743)
--- trunk/Source/WebCore/rendering/svg/LegacyRenderSVGRect.h (rev 0)
+++ trunk/Source/WebCore/rendering/svg/LegacyRenderSVGRect.h 2022-01-07 13:02:32 UTC (rev 287743)
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2011 University of Szeged
+ * Copyright (C) 2011 Renata Hodovan <r...@webkit.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY UNIVERSITY OF SZEGED ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL UNIVERSITY OF SZEGED OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include "LegacyRenderSVGShape.h"
+#include "SVGRectElement.h"
+
+namespace WebCore {
+
+class LegacyRenderSVGRect final : public LegacyRenderSVGShape {
+ WTF_MAKE_ISO_ALLOCATED(LegacyRenderSVGRect);
+public:
+ LegacyRenderSVGRect(SVGRectElement&, RenderStyle&&);
+ virtual ~LegacyRenderSVGRect();
+
+ SVGRectElement& rectElement() const;
+
+private:
+ void graphicsElement() const = delete;
+
+ const char* renderName() const override { return "RenderSVGRect"; }
+
+ void updateShapeFromElement() override;
+ bool isEmpty() const override { return m_usePathFallback ? LegacyRenderSVGShape::isEmpty() : m_fillBoundingBox.isEmpty(); }
+ bool isRenderingDisabled() const override;
+ void fillShape(GraphicsContext&) const override;
+ void strokeShape(GraphicsContext&) const override;
+ bool shapeDependentStrokeContains(const FloatPoint&, PointCoordinateSpace = GlobalCoordinateSpace) override;
+ bool shapeDependentFillContains(const FloatPoint&, const WindRule) const override;
+
+private:
+ FloatRect m_innerStrokeRect;
+ FloatRect m_outerStrokeRect;
+ bool m_usePathFallback;
+};
+
+} // namespace WebCore
Deleted: trunk/Source/WebCore/rendering/svg/RenderSVGRect.cpp (287742 => 287743)
--- trunk/Source/WebCore/rendering/svg/RenderSVGRect.cpp 2022-01-07 08:45:30 UTC (rev 287742)
+++ trunk/Source/WebCore/rendering/svg/RenderSVGRect.cpp 2022-01-07 13:02:32 UTC (rev 287743)
@@ -1,162 +0,0 @@
-/*
- * Copyright (C) 2011 University of Szeged
- * Copyright (C) 2011 Renata Hodovan <r...@webkit.org>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY UNIVERSITY OF SZEGED ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL UNIVERSITY OF SZEGED OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "RenderSVGRect.h"
-
-#include "LegacyRenderSVGShapeInlines.h"
-#include "SVGElementTypeHelpers.h"
-#include <wtf/IsoMallocInlines.h>
-
-namespace WebCore {
-
-WTF_MAKE_ISO_ALLOCATED_IMPL(RenderSVGRect);
-
-RenderSVGRect::RenderSVGRect(SVGRectElement& element, RenderStyle&& style)
- : LegacyRenderSVGShape(element, WTFMove(style))
- , m_usePathFallback(false)
-{
-}
-
-RenderSVGRect::~RenderSVGRect() = default;
-
-SVGRectElement& RenderSVGRect::rectElement() const
-{
- return downcast<SVGRectElement>(LegacyRenderSVGShape::graphicsElement());
-}
-
-void RenderSVGRect::updateShapeFromElement()
-{
- // Before creating a new object we need to clear the cached bounding box
- // to avoid using garbage.
- m_fillBoundingBox = FloatRect();
- m_innerStrokeRect = FloatRect();
- m_outerStrokeRect = FloatRect();
- clearPath();
- m_usePathFallback = false;
-
- SVGLengthContext lengthContext(&rectElement());
- FloatSize boundingBoxSize(lengthContext.valueForLength(style().width(), SVGLengthMode::Width), lengthContext.valueForLength(style().height(), SVGLengthMode::Height));
-
- // Spec: "A negative value is illegal. A value of zero disables rendering of the element."
- if (boundingBoxSize.isEmpty())
- return;
-
- if (rectElement().rx().value(lengthContext) > 0 || rectElement().ry().value(lengthContext) > 0 || hasNonScalingStroke()) {
- // Fall back to LegacyRenderSVGShape
- LegacyRenderSVGShape::updateShapeFromElement();
- m_usePathFallback = true;
- return;
- }
-
- m_fillBoundingBox = FloatRect(FloatPoint(lengthContext.valueForLength(style().svgStyle().x(), SVGLengthMode::Width),
- lengthContext.valueForLength(style().svgStyle().y(), SVGLengthMode::Height)),
- boundingBoxSize);
-
- // To decide if the stroke contains a point we create two rects which represent the inner and
- // the outer stroke borders. A stroke contains the point, if the point is between them.
- m_innerStrokeRect = m_fillBoundingBox;
- m_outerStrokeRect = m_fillBoundingBox;
-
- if (style().svgStyle().hasStroke()) {
- float strokeWidth = this->strokeWidth();
- m_innerStrokeRect.inflate(-strokeWidth / 2);
- m_outerStrokeRect.inflate(strokeWidth / 2);
- }
-
- m_strokeBoundingBox = m_outerStrokeRect;
-
-#if USE(CG)
- // CoreGraphics can inflate the stroke by 1px when drawing a rectangle with antialiasing disabled at non-integer coordinates, we need to compensate.
- if (style().svgStyle().shapeRendering() == ShapeRendering::CrispEdges)
- m_strokeBoundingBox.inflate(1);
-#endif
-}
-
-void RenderSVGRect::fillShape(GraphicsContext& context) const
-{
- if (m_usePathFallback) {
- LegacyRenderSVGShape::fillShape(context);
- return;
- }
-
-#if USE(CG)
- // FIXME: CG implementation of GraphicsContextCG::fillRect has an own
- // shadow drawing method, which draws an extra shadow.
- // This is a workaround for switching off the extra shadow.
- // https://bugs.webkit.org/show_bug.cgi?id=68899
- if (context.hasShadow()) {
- GraphicsContextStateSaver stateSaver(context);
- context.clearShadow();
- context.fillRect(m_fillBoundingBox);
- return;
- }
-#endif
-
- context.fillRect(m_fillBoundingBox);
-}
-
-void RenderSVGRect::strokeShape(GraphicsContext& context) const
-{
- if (!style().hasVisibleStroke())
- return;
-
- if (m_usePathFallback) {
- LegacyRenderSVGShape::strokeShape(context);
- return;
- }
-
- context.strokeRect(m_fillBoundingBox, strokeWidth());
-}
-
-bool RenderSVGRect::shapeDependentStrokeContains(const FloatPoint& point, PointCoordinateSpace pointCoordinateSpace)
-{
- // The optimized contains code below does not support non-smooth strokes so we need
- // to fall back to LegacyRenderSVGShape::shapeDependentStrokeContains in these cases.
- if (m_usePathFallback || !hasSmoothStroke()) {
- if (!hasPath())
- LegacyRenderSVGShape::updateShapeFromElement();
- return LegacyRenderSVGShape::shapeDependentStrokeContains(point, pointCoordinateSpace);
- }
-
- return m_outerStrokeRect.contains(point, FloatRect::InsideOrOnStroke) && !m_innerStrokeRect.contains(point, FloatRect::InsideButNotOnStroke);
-}
-
-bool RenderSVGRect::shapeDependentFillContains(const FloatPoint& point, const WindRule fillRule) const
-{
- if (m_usePathFallback)
- return LegacyRenderSVGShape::shapeDependentFillContains(point, fillRule);
- return m_fillBoundingBox.contains(point.x(), point.y());
-}
-
-bool RenderSVGRect::isRenderingDisabled() const
-{
- // A width or height of zero disables rendering for the element, and results in an empty bounding box.
- return m_fillBoundingBox.isEmpty();
-}
-
-}
Deleted: trunk/Source/WebCore/rendering/svg/RenderSVGRect.h (287742 => 287743)
--- trunk/Source/WebCore/rendering/svg/RenderSVGRect.h 2022-01-07 08:45:30 UTC (rev 287742)
+++ trunk/Source/WebCore/rendering/svg/RenderSVGRect.h 2022-01-07 13:02:32 UTC (rev 287743)
@@ -1,62 +0,0 @@
-/*
- * Copyright (C) 2011 University of Szeged
- * Copyright (C) 2011 Renata Hodovan <r...@webkit.org>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY UNIVERSITY OF SZEGED ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL UNIVERSITY OF SZEGED OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#pragma once
-
-#include "LegacyRenderSVGShape.h"
-#include "SVGRectElement.h"
-
-namespace WebCore {
-
-class RenderSVGRect final : public LegacyRenderSVGShape {
- WTF_MAKE_ISO_ALLOCATED(RenderSVGRect);
-public:
- RenderSVGRect(SVGRectElement&, RenderStyle&&);
- virtual ~RenderSVGRect();
-
- SVGRectElement& rectElement() const;
-
-private:
- void graphicsElement() const = delete;
-
- const char* renderName() const override { return "RenderSVGRect"; }
-
- void updateShapeFromElement() override;
- bool isEmpty() const override { return m_usePathFallback ? LegacyRenderSVGShape::isEmpty() : m_fillBoundingBox.isEmpty(); }
- bool isRenderingDisabled() const override;
- void fillShape(GraphicsContext&) const override;
- void strokeShape(GraphicsContext&) const override;
- bool shapeDependentStrokeContains(const FloatPoint&, PointCoordinateSpace = GlobalCoordinateSpace) override;
- bool shapeDependentFillContains(const FloatPoint&, const WindRule) const override;
-
-private:
- FloatRect m_innerStrokeRect;
- FloatRect m_outerStrokeRect;
- bool m_usePathFallback;
-};
-
-} // namespace WebCore
Modified: trunk/Source/WebCore/svg/SVGRectElement.cpp (287742 => 287743)
--- trunk/Source/WebCore/svg/SVGRectElement.cpp 2022-01-07 08:45:30 UTC (rev 287742)
+++ trunk/Source/WebCore/svg/SVGRectElement.cpp 2022-01-07 13:02:32 UTC (rev 287743)
@@ -23,7 +23,7 @@
#include "config.h"
#include "SVGRectElement.h"
-#include "RenderSVGRect.h"
+#include "LegacyRenderSVGRect.h"
#include "RenderSVGResource.h"
#include "SVGElementInlines.h"
#include <wtf/IsoMallocInlines.h>
@@ -88,7 +88,7 @@
RenderPtr<RenderElement> SVGRectElement::createElementRenderer(RenderStyle&& style, const RenderTreePosition&)
{
- return createRenderer<RenderSVGRect>(*this, WTFMove(style));
+ return createRenderer<LegacyRenderSVGRect>(*this, WTFMove(style));
}
}