Title: [230829] trunk
Revision
230829
Author
commit-qu...@webkit.org
Date
2018-04-19 18:00:40 -0700 (Thu, 19 Apr 2018)

Log Message

Introduce SVGGeometryElement interface
https://bugs.webkit.org/show_bug.cgi?id=184768

Source/WebCore:

Patch by Dirk Schulze <k...@webbkit.org> on 2018-04-19
Reviewed by Antti Koivisto.

Start implementing SVGGeometryElement interface from SVG2.
https://svgwg.org/svg2-draft/types.html#InterfaceSVGGeometryElement

Start with SVGPathElement only for now. Also, just inferface gets implemented
by this patch. No new functionality like isPointInFill yet.
Fix getPointAtLength and make it more restrictive. This follows the spec and
all other implementations.

Added additional test scenarios to existing tests.

* CMakeLists.txt:
* DerivedSources.make:
* Sources.txt:
* WebCore.xcodeproj/project.pbxproj:
* bindings/scripts/CodeGeneratorJS.pm:
(GetGnuVTableOffsetForType):
* svg/SVGAllInOne.cpp:
* svg/SVGGeometryElement.cpp: Added.
(WebCore::SVGGeometryElement::SVGGeometryElement):
(WebCore::SVGGeometryElement::isSupportedAttribute):
(WebCore::SVGGeometryElement::parseAttribute):
(WebCore::SVGGeometryElement::svgAttributeChanged):
(WebCore::SVGGeometryElement::createElementRenderer):
* svg/SVGGeometryElement.h: Added.
* svg/SVGGeometryElement.idl: Added.
* svg/SVGGradientElement.cpp:
* svg/SVGPathElement.cpp:
(WebCore::SVGPathElement::SVGPathElement):
(WebCore::SVGPathElement::parseAttribute):
(WebCore::SVGPathElement::svgAttributeChanged):
(WebCore::SVGPathElement::insertedIntoAncestor):
(WebCore::SVGPathElement::removedFromAncestor):
* svg/SVGPathElement.h:
* svg/SVGPathElement.idl:

LayoutTests:

Patch by Dirk Schulze <k...@webkit.org> on 2018-04-19
Reviewed by Antti Koivisto.

Start implementing SVGGeometryElement interface from SVG2.

* svg/dom/SVGPolygonElement-baseVal-list-removal-crash.html: pointAtLength requires value now.
* svg/dom/path-pointAtLength-expected.txt:
* svg/dom/path-pointAtLength.html: Added throw tests for pointAtLength.
* svg/dom/svg2-inheritance-expected.txt: Inheritance fixed for SVGPathElement only for now.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (230828 => 230829)


--- trunk/LayoutTests/ChangeLog	2018-04-19 23:59:50 UTC (rev 230828)
+++ trunk/LayoutTests/ChangeLog	2018-04-20 01:00:40 UTC (rev 230829)
@@ -1,3 +1,17 @@
+2018-04-19  Dirk Schulze  <k...@webkit.org>
+
+        Introduce SVGGeometryElement interface
+        https://bugs.webkit.org/show_bug.cgi?id=184768
+
+        Reviewed by Antti Koivisto.
+
+        Start implementing SVGGeometryElement interface from SVG2.
+
+        * svg/dom/SVGPolygonElement-baseVal-list-removal-crash.html: pointAtLength requires value now.
+        * svg/dom/path-pointAtLength-expected.txt:
+        * svg/dom/path-pointAtLength.html: Added throw tests for pointAtLength.
+        * svg/dom/svg2-inheritance-expected.txt: Inheritance fixed for SVGPathElement only for now.
+
 2018-04-19  Tadeu Zagallo  <tzaga...@apple.com>
 
         REGRESSION(r227340): ArrayBuffers were not being serialized when sent via MessagePorts

Modified: trunk/LayoutTests/svg/dom/SVGPolygonElement-baseVal-list-removal-crash.html (230828 => 230829)


--- trunk/LayoutTests/svg/dom/SVGPolygonElement-baseVal-list-removal-crash.html	2018-04-19 23:59:50 UTC (rev 230828)
+++ trunk/LayoutTests/svg/dom/SVGPolygonElement-baseVal-list-removal-crash.html	2018-04-20 01:00:40 UTC (rev 230829)
@@ -7,7 +7,7 @@
 function go() {
     var oSVGPolygon = document.createElementNS("http://www.w3.org/2000/svg", "polygon");
     var oSVGPath = document.createElementNS("http://www.w3.org/2000/svg", "path");
-    var oSVGPoint1 = oSVGPath.getPointAtLength();
+    var oSVGPoint1 = oSVGPath.getPointAtLength(0);
     oSVGPolygon.points.initialize(oSVGPoint1);
     oSVGPolygon.points.removeItem(-9223372036854775802);
     alert("Accessing old oSVGPoint1.x: " + oSVGPoint1.x);

Modified: trunk/LayoutTests/svg/dom/path-pointAtLength-expected.txt (230828 => 230829)


--- trunk/LayoutTests/svg/dom/path-pointAtLength-expected.txt	2018-04-19 23:59:50 UTC (rev 230828)
+++ trunk/LayoutTests/svg/dom/path-pointAtLength-expected.txt	2018-04-20 01:00:40 UTC (rev 230829)
@@ -7,6 +7,10 @@
 PASS pointAtLengthOfPath('M0,20 L400,20 L640,20 z') is '(580, 20)'
 PASS pointAtLengthOfPath('M0,20 L400,20 z M 320,20 L640,20') is '(100, 20)'
 PASS pointAtLengthOfPath('M0,20 L20,40') is '(20, 40)'
+PASS pathElement.getPointAtLength(Math.NaN) threw exception TypeError: The provided value is non-finite.
+PASS pathElement.getPointAtLength() threw exception TypeError: Not enough arguments.
+PASS pathElement.getPointAtLength(Math.Infinity) threw exception TypeError: The provided value is non-finite.
+PASS pathElement.getPointAtLength('abc') threw exception TypeError: The provided value is non-finite.
 PASS successfullyParsed is true
 
 TEST COMPLETE

Modified: trunk/LayoutTests/svg/dom/path-pointAtLength.html (230828 => 230829)


--- trunk/LayoutTests/svg/dom/path-pointAtLength.html	2018-04-19 23:59:50 UTC (rev 230828)
+++ trunk/LayoutTests/svg/dom/path-pointAtLength.html	2018-04-20 01:00:40 UTC (rev 230829)
@@ -22,6 +22,10 @@
 shouldBe("pointAtLengthOfPath('M0,20 L400,20 L640,20 z')", "'(580, 20)'");
 shouldBe("pointAtLengthOfPath('M0,20 L400,20 z M 320,20 L640,20')", "'(100, 20)'");
 shouldBe("pointAtLengthOfPath('M0,20 L20,40')", "'(20, 40)'");
+shouldThrow("pathElement.getPointAtLength(Math.NaN)");
+shouldThrow("pathElement.getPointAtLength()");
+shouldThrow("pathElement.getPointAtLength(Math.Infinity)");
+shouldThrow("pathElement.getPointAtLength('abc')");
 
 var successfullyParsed = true;
 </script>

Modified: trunk/LayoutTests/svg/dom/svg2-inheritance-expected.txt (230828 => 230829)


--- trunk/LayoutTests/svg/dom/svg2-inheritance-expected.txt	2018-04-19 23:59:50 UTC (rev 230828)
+++ trunk/LayoutTests/svg/dom/svg2-inheritance-expected.txt	2018-04-20 01:00:40 UTC (rev 230829)
@@ -44,7 +44,7 @@
 PASS SVGFontFaceUriElement inherits SVGElement
 PASS SVGForeignObjectElement inherits SVGGraphicsElement
 PASS SVGGElement inherits SVGGraphicsElement
-FAIL SVGGeometryElement is not defined
+PASS SVGGeometryElement inherits SVGGraphicsElement
 PASS SVGGlyphElement inherits SVGElement
 PASS SVGGlyphRefElement inherits SVGElement
 PASS SVGGradientElement inherits SVGElement
@@ -68,7 +68,7 @@
 PASS SVGMissingGlyphElement inherits SVGElement
 PASS SVGNumber inherits Object
 PASS SVGNumberList inherits Object
-FAIL SVGPathElement should inherit SVGGeometryElement but got SVGGraphicsElement instead
+PASS SVGPathElement inherits SVGGeometryElement
 PASS SVGPathSeg inherits Object
 PASS SVGPathSegArcAbs inherits SVGPathSeg
 PASS SVGPathSegArcRel inherits SVGPathSeg

Modified: trunk/Source/WebCore/CMakeLists.txt (230828 => 230829)


--- trunk/Source/WebCore/CMakeLists.txt	2018-04-19 23:59:50 UTC (rev 230828)
+++ trunk/Source/WebCore/CMakeLists.txt	2018-04-20 01:00:40 UTC (rev 230829)
@@ -940,6 +940,7 @@
     svg/SVGFontFaceUriElement.idl
     svg/SVGForeignObjectElement.idl
     svg/SVGGElement.idl
+    svg/SVGGeometryElement.idl
     svg/SVGGlyphElement.idl
     svg/SVGGlyphRefElement.idl
     svg/SVGGradientElement.idl

Modified: trunk/Source/WebCore/ChangeLog (230828 => 230829)


--- trunk/Source/WebCore/ChangeLog	2018-04-19 23:59:50 UTC (rev 230828)
+++ trunk/Source/WebCore/ChangeLog	2018-04-20 01:00:40 UTC (rev 230829)
@@ -1,3 +1,45 @@
+2018-04-19  Dirk Schulze  <k...@webbkit.org>
+
+        Introduce SVGGeometryElement interface
+        https://bugs.webkit.org/show_bug.cgi?id=184768
+
+        Reviewed by Antti Koivisto.
+
+        Start implementing SVGGeometryElement interface from SVG2.
+        https://svgwg.org/svg2-draft/types.html#InterfaceSVGGeometryElement
+
+        Start with SVGPathElement only for now. Also, just inferface gets implemented
+        by this patch. No new functionality like isPointInFill yet.
+        Fix getPointAtLength and make it more restrictive. This follows the spec and
+        all other implementations.
+
+        Added additional test scenarios to existing tests.
+
+        * CMakeLists.txt:
+        * DerivedSources.make:
+        * Sources.txt:
+        * WebCore.xcodeproj/project.pbxproj:
+        * bindings/scripts/CodeGeneratorJS.pm:
+        (GetGnuVTableOffsetForType):
+        * svg/SVGAllInOne.cpp:
+        * svg/SVGGeometryElement.cpp: Added.
+        (WebCore::SVGGeometryElement::SVGGeometryElement):
+        (WebCore::SVGGeometryElement::isSupportedAttribute):
+        (WebCore::SVGGeometryElement::parseAttribute):
+        (WebCore::SVGGeometryElement::svgAttributeChanged):
+        (WebCore::SVGGeometryElement::createElementRenderer):
+        * svg/SVGGeometryElement.h: Added.
+        * svg/SVGGeometryElement.idl: Added.
+        * svg/SVGGradientElement.cpp:
+        * svg/SVGPathElement.cpp:
+        (WebCore::SVGPathElement::SVGPathElement):
+        (WebCore::SVGPathElement::parseAttribute):
+        (WebCore::SVGPathElement::svgAttributeChanged):
+        (WebCore::SVGPathElement::insertedIntoAncestor):
+        (WebCore::SVGPathElement::removedFromAncestor):
+        * svg/SVGPathElement.h:
+        * svg/SVGPathElement.idl:
+
 2018-04-19  Tadeu Zagallo  <tzaga...@apple.com>
 
         REGRESSION(r227340): ArrayBuffers were not being serialized when sent via MessagePorts

Modified: trunk/Source/WebCore/DerivedSources.make (230828 => 230829)


--- trunk/Source/WebCore/DerivedSources.make	2018-04-19 23:59:50 UTC (rev 230828)
+++ trunk/Source/WebCore/DerivedSources.make	2018-04-20 01:00:40 UTC (rev 230829)
@@ -868,6 +868,7 @@
     $(WebCore)/svg/SVGFontFaceUriElement.idl \
     $(WebCore)/svg/SVGForeignObjectElement.idl \
     $(WebCore)/svg/SVGGElement.idl \
+    $(WebCore)/svg/SVGGeometryElement.idl \
     $(WebCore)/svg/SVGGlyphElement.idl \
     $(WebCore)/svg/SVGGlyphRefElement.idl \
     $(WebCore)/svg/SVGGradientElement.idl \

Modified: trunk/Source/WebCore/Sources.txt (230828 => 230829)


--- trunk/Source/WebCore/Sources.txt	2018-04-19 23:59:50 UTC (rev 230828)
+++ trunk/Source/WebCore/Sources.txt	2018-04-20 01:00:40 UTC (rev 230829)
@@ -2147,6 +2147,7 @@
 svg/SVGFontFaceUriElement.cpp
 svg/SVGForeignObjectElement.cpp
 svg/SVGGElement.cpp
+svg/SVGGeometryElement.cpp
 svg/SVGGlyphElement.cpp
 svg/SVGGlyphRefElement.cpp
 svg/SVGGradientElement.cpp
@@ -2921,6 +2922,7 @@
 JSSVGFontFaceUriElement.cpp
 JSSVGForeignObjectElement.cpp
 JSSVGGElement.cpp
+JSSVGGeometryElement.cpp
 JSSVGGlyphElement.cpp
 JSSVGGlyphRefElement.cpp
 JSSVGGradientElement.cpp

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (230828 => 230829)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2018-04-19 23:59:50 UTC (rev 230828)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2018-04-20 01:00:40 UTC (rev 230829)
@@ -4815,6 +4815,8 @@
 		FABE72F71059C1EB00D999DD /* MathMLPresentationElement.h in Headers */ = {isa = PBXBuildFile; fileRef = FABE72F01059C1EB00D999DD /* MathMLPresentationElement.h */; };
 		FABE72F91059C1EB00D999DD /* MathMLMathElement.h in Headers */ = {isa = PBXBuildFile; fileRef = FABE72F21059C1EB00D999DD /* MathMLMathElement.h */; };
 		FABE72FE1059C21100D999DD /* MathMLNames.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FABE72FC1059C21100D999DD /* MathMLNames.cpp */; };
+		FB273E822086E6C700A54E87 /* SVGGeometryElement.h in Headers */ = {isa = PBXBuildFile; fileRef = FB273E7F2086E6A300A54E87 /* SVGGeometryElement.h */; };
+		FB273E852086E74D00A54E87 /* JSSVGGeometryElement.h in Headers */ = {isa = PBXBuildFile; fileRef = FB273E842086E73E00A54E87 /* JSSVGGeometryElement.h */; };
 		FB2C15C3165D649D0039C9F8 /* CachedSVGDocumentReference.h in Headers */ = {isa = PBXBuildFile; fileRef = FB2C15C2165D64900039C9F8 /* CachedSVGDocumentReference.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		FB3056C2169E5DAC0096A232 /* CSSGroupingRule.h in Headers */ = {isa = PBXBuildFile; fileRef = FB3056C1169E5DAC0096A232 /* CSSGroupingRule.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		FB484F4D171F821E00040755 /* TransformFunctions.h in Headers */ = {isa = PBXBuildFile; fileRef = FB484F4B171F821E00040755 /* TransformFunctions.h */; };
@@ -14515,6 +14517,11 @@
 		FABE72F31059C1EB00D999DD /* mathtags.in */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = mathtags.in; sourceTree = "<group>"; };
 		FABE72FB1059C21100D999DD /* MathMLElementFactory.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MathMLElementFactory.cpp; sourceTree = "<group>"; };
 		FABE72FC1059C21100D999DD /* MathMLNames.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MathMLNames.cpp; sourceTree = "<group>"; };
+		FB273E7E2086E6A300A54E87 /* SVGGeometryElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SVGGeometryElement.cpp; sourceTree = "<group>"; };
+		FB273E7F2086E6A300A54E87 /* SVGGeometryElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGGeometryElement.h; sourceTree = "<group>"; };
+		FB273E802086E6A300A54E87 /* SVGGeometryElement.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = SVGGeometryElement.idl; sourceTree = "<group>"; };
+		FB273E832086E73E00A54E87 /* JSSVGGeometryElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSSVGGeometryElement.cpp; sourceTree = SOURCE_ROOT; };
+		FB273E842086E73E00A54E87 /* JSSVGGeometryElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSSVGGeometryElement.h; sourceTree = SOURCE_ROOT; };
 		FB2C15C2165D64900039C9F8 /* CachedSVGDocumentReference.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CachedSVGDocumentReference.h; sourceTree = "<group>"; };
 		FB3056C1169E5DAC0096A232 /* CSSGroupingRule.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSSGroupingRule.h; sourceTree = "<group>"; };
 		FB484F4A171F821E00040755 /* TransformFunctions.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TransformFunctions.cpp; sourceTree = "<group>"; };
@@ -21924,6 +21931,8 @@
 				B2FA3CB10AB75A6E000E5AC4 /* JSSVGForeignObjectElement.h */,
 				B2FA3CB20AB75A6E000E5AC4 /* JSSVGGElement.cpp */,
 				B2FA3CB30AB75A6E000E5AC4 /* JSSVGGElement.h */,
+				FB273E832086E73E00A54E87 /* JSSVGGeometryElement.cpp */,
+				FB273E842086E73E00A54E87 /* JSSVGGeometryElement.h */,
 				B27B28210CEF0C0700D39D54 /* JSSVGGlyphElement.cpp */,
 				B27B28220CEF0C0700D39D54 /* JSSVGGlyphElement.h */,
 				24D9129713CA96DE00D21915 /* JSSVGGlyphRefElement.cpp */,
@@ -22876,6 +22885,9 @@
 				B22278900D00BF200071B782 /* SVGGElement.cpp */,
 				B22278910D00BF200071B782 /* SVGGElement.h */,
 				B22278920D00BF200071B782 /* SVGGElement.idl */,
+				FB273E7E2086E6A300A54E87 /* SVGGeometryElement.cpp */,
+				FB273E7F2086E6A300A54E87 /* SVGGeometryElement.h */,
+				FB273E802086E6A300A54E87 /* SVGGeometryElement.idl */,
 				B2A1F2A40CEF0ABF00442F6A /* SVGGlyphElement.cpp */,
 				B2A1F2A50CEF0ABF00442F6A /* SVGGlyphElement.h */,
 				B2A1F2A60CEF0ABF00442F6A /* SVGGlyphElement.idl */,
@@ -28739,6 +28751,7 @@
 				A83B78FC0CCAFF15000B0825 /* JSSVGFontFaceUriElement.h in Headers */,
 				B2FA3D990AB75A6F000E5AC4 /* JSSVGForeignObjectElement.h in Headers */,
 				B2FA3D9B0AB75A6F000E5AC4 /* JSSVGGElement.h in Headers */,
+				FB273E852086E74D00A54E87 /* JSSVGGeometryElement.h in Headers */,
 				B27B28280CEF0C0700D39D54 /* JSSVGGlyphElement.h in Headers */,
 				24D9129A13CA971400D21915 /* JSSVGGlyphRefElement.h in Headers */,
 				B2FA3D9D0AB75A6F000E5AC4 /* JSSVGGradientElement.h in Headers */,
@@ -30140,6 +30153,7 @@
 				B2227A210D00BF220071B782 /* SVGFontFaceUriElement.h in Headers */,
 				B2227A240D00BF220071B782 /* SVGForeignObjectElement.h in Headers */,
 				B2227A270D00BF220071B782 /* SVGGElement.h in Headers */,
+				FB273E822086E6C700A54E87 /* SVGGeometryElement.h in Headers */,
 				B2A1F2AE0CEF0ABF00442F6A /* SVGGlyphElement.h in Headers */,
 				24D912BE13CA9A9700D21915 /* SVGGlyphRefElement.h in Headers */,
 				B2227A2A0D00BF220071B782 /* SVGGradientElement.h in Headers */,

Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm (230828 => 230829)


--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm	2018-04-19 23:59:50 UTC (rev 230828)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm	2018-04-20 01:00:40 UTC (rev 230829)
@@ -3560,6 +3560,7 @@
         || $typename eq "SVGPolylineElement"
         || $typename eq "SVGRectElement"
         || $typename eq "SVGSVGElement"
+        || $typename eq "SVGGeometryElement"
         || $typename eq "SVGGraphicsElement"
         || $typename eq "SVGSwitchElement"
         || $typename eq "SVGTextElement"

Modified: trunk/Source/WebCore/svg/SVGAllInOne.cpp (230828 => 230829)


--- trunk/Source/WebCore/svg/SVGAllInOne.cpp	2018-04-19 23:59:50 UTC (rev 230828)
+++ trunk/Source/WebCore/svg/SVGAllInOne.cpp	2018-04-20 01:00:40 UTC (rev 230829)
@@ -102,6 +102,7 @@
 #include "SVGFontFaceUriElement.cpp"
 #include "SVGForeignObjectElement.cpp"
 #include "SVGGElement.cpp"
+#include "SVGGeometryElement.cpp"
 #include "SVGGlyphElement.cpp"
 #include "SVGGlyphRefElement.cpp"
 #include "SVGGradientElement.cpp"

Added: trunk/Source/WebCore/svg/SVGGeometryElement.cpp (0 => 230829)


--- trunk/Source/WebCore/svg/SVGGeometryElement.cpp	                        (rev 0)
+++ trunk/Source/WebCore/svg/SVGGeometryElement.cpp	2018-04-20 01:00:40 UTC (rev 230829)
@@ -0,0 +1,95 @@
+/*
+ * Copyright (C) 2004, 2005, 2006, 2008 Nikolas Zimmermann <zimmerm...@kde.org>
+ * Copyright (C) 2004, 2005, 2006, 2007 Rob Buis <b...@kde.org>
+ * Copyright (C) 2018 Apple Inc. All rights reserved.
+ * Copyright (C) 2018 Adobe Systems Incorporated. All rights reserved.
+ *
+ * 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 "SVGGeometryElement.h"
+
+#include "RenderSVGPath.h"
+#include "RenderSVGResource.h"
+#include "SVGDocumentExtensions.h"
+#include "SVGMPathElement.h"
+#include "SVGNames.h"
+#include "SVGPathUtilities.h"
+#include "SVGPoint.h"
+#include <wtf/IsoMallocInlines.h>
+#include <wtf/NeverDestroyed.h>
+
+namespace WebCore {
+
+WTF_MAKE_ISO_ALLOCATED_IMPL(SVGGeometryElement);
+
+// Animated property definitions
+DEFINE_ANIMATED_NUMBER(SVGGeometryElement, SVGNames::pathLengthAttr, PathLength, pathLength)
+
+BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGGeometryElement)
+    REGISTER_LOCAL_ANIMATED_PROPERTY(pathLength)
+    REGISTER_PARENT_ANIMATED_PROPERTIES(SVGGraphicsElement)
+END_REGISTER_ANIMATED_PROPERTIES
+
+SVGGeometryElement::SVGGeometryElement(const QualifiedName& tagName, Document& document)
+    : SVGGraphicsElement(tagName, document)
+{
+    registerAnimatedPropertiesForSVGGeometryElement();
+}
+
+bool SVGGeometryElement::isSupportedAttribute(const QualifiedName& attrName)
+{
+    static const auto supportedAttributes = makeNeverDestroyed([] {
+        HashSet<QualifiedName> set;
+        SVGLangSpace::addSupportedAttributes(set);
+        SVGExternalResourcesRequired::addSupportedAttributes(set);
+        set.add({ SVGNames::pathLengthAttr.get() });
+        return set;
+    }());
+    return supportedAttributes.get().contains<SVGAttributeHashTranslator>(attrName);
+}
+
+void SVGGeometryElement::parseAttribute(const QualifiedName& name, const AtomicString& value)
+{
+    if (name == SVGNames::pathLengthAttr) {
+        setPathLengthBaseValue(value.toFloat());
+        if (pathLengthBaseValue() < 0)
+            document().accessSVGExtensions().reportError("A negative value for path attribute <pathLength> is not allowed");
+        return;
+    }
+
+    SVGGraphicsElement::parseAttribute(name, value);
+}
+
+void SVGGeometryElement::svgAttributeChanged(const QualifiedName& attrName)
+{
+    if (!isSupportedAttribute(attrName)) {
+        SVGGraphicsElement::svgAttributeChanged(attrName);
+        return;
+    }
+
+    InstanceInvalidationGuard guard(*this);
+
+    ASSERT_NOT_REACHED();
+}
+
+RenderPtr<RenderElement> SVGGeometryElement::createElementRenderer(RenderStyle&& style, const RenderTreePosition&)
+{
+    return createRenderer<RenderSVGPath>(*this, WTFMove(style));
+}
+
+}

Added: trunk/Source/WebCore/svg/SVGGeometryElement.h (0 => 230829)


--- trunk/Source/WebCore/svg/SVGGeometryElement.h	                        (rev 0)
+++ trunk/Source/WebCore/svg/SVGGeometryElement.h	2018-04-20 01:00:40 UTC (rev 230829)
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2004, 2005, 2006, 2008 Nikolas Zimmermann <zimmerm...@kde.org>
+ * Copyright (C) 2004, 2005, 2006, 2007 Rob Buis <b...@kde.org>
+ * Copyright (C) 2018 Adobe Systems Incorporated. All rights reserved.
+ *
+ * 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
+
+#include "Path.h"
+#include "SVGAnimatedBoolean.h"
+#include "SVGAnimatedNumber.h"
+#include "SVGExternalResourcesRequired.h"
+#include "SVGGraphicsElement.h"
+#include "SVGNames.h"
+
+namespace WebCore {
+
+class SVGPoint;
+
+class SVGGeometryElement : public SVGGraphicsElement {
+    WTF_MAKE_ISO_ALLOCATED(SVGGeometryElement);
+public:
+    
+    virtual float getTotalLength() const = 0;
+    virtual Ref<SVGPoint> getPointAtLength(float distance) const = 0;
+
+protected:
+    SVGGeometryElement(const QualifiedName&, Document&);
+
+    static bool isSupportedAttribute(const QualifiedName&);
+    void parseAttribute(const QualifiedName&, const AtomicString&) override;
+    void svgAttributeChanged(const QualifiedName&) override;
+
+    BEGIN_DECLARE_ANIMATED_PROPERTIES(SVGGeometryElement)
+        DECLARE_ANIMATED_NUMBER(PathLength, pathLength)
+    END_DECLARE_ANIMATED_PROPERTIES
+
+    RenderPtr<RenderElement> createElementRenderer(RenderStyle&&, const RenderTreePosition&) override;
+};
+
+} // namespace WebCore

Added: trunk/Source/WebCore/svg/SVGGeometryElement.idl (0 => 230829)


--- trunk/Source/WebCore/svg/SVGGeometryElement.idl	                        (rev 0)
+++ trunk/Source/WebCore/svg/SVGGeometryElement.idl	2018-04-20 01:00:40 UTC (rev 230829)
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2018 Adobe Systems Incorporated. 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 APPLE INC. ``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 APPLE INC. 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. 
+ */
+
+// [Exposed=Window]
+interface SVGGeometryElement : SVGGraphicsElement {
+    readonly attribute SVGAnimatedNumber pathLength; // FIXME: Should be [SameObject].
+
+    // boolean isPointInFill(DOMPointInit point);
+    // boolean isPointInStroke(DOMPointInit point);
+    unrestricted float getTotalLength();
+    [NewObject] SVGPoint getPointAtLength(float distance);
+};

Modified: trunk/Source/WebCore/svg/SVGGradientElement.cpp (230828 => 230829)


--- trunk/Source/WebCore/svg/SVGGradientElement.cpp	2018-04-19 23:59:50 UTC (rev 230828)
+++ trunk/Source/WebCore/svg/SVGGradientElement.cpp	2018-04-20 01:00:40 UTC (rev 230829)
@@ -24,7 +24,6 @@
 
 #include "ElementIterator.h"
 #include "RenderSVGHiddenContainer.h"
-#include "RenderSVGPath.h"
 #include "RenderSVGResourceLinearGradient.h"
 #include "RenderSVGResourceRadialGradient.h"
 #include "SVGNames.h"

Modified: trunk/Source/WebCore/svg/SVGPathElement.cpp (230828 => 230829)


--- trunk/Source/WebCore/svg/SVGPathElement.cpp	2018-04-19 23:59:50 UTC (rev 230828)
+++ trunk/Source/WebCore/svg/SVGPathElement.cpp	2018-04-20 01:00:40 UTC (rev 230829)
@@ -79,11 +79,11 @@
     REGISTER_LOCAL_ANIMATED_PROPERTY(d)
     REGISTER_LOCAL_ANIMATED_PROPERTY(pathLength)
     REGISTER_LOCAL_ANIMATED_PROPERTY(externalResourcesRequired)
-    REGISTER_PARENT_ANIMATED_PROPERTIES(SVGGraphicsElement)
+    REGISTER_PARENT_ANIMATED_PROPERTIES(SVGGeometryElement)
 END_REGISTER_ANIMATED_PROPERTIES
 
 inline SVGPathElement::SVGPathElement(const QualifiedName& tagName, Document& document)
-    : SVGGraphicsElement(tagName, document)
+    : SVGGeometryElement(tagName, document)
     , m_pathSegList(PathSegUnalteredRole)
     , m_isAnimValObserved(false)
 {
@@ -240,7 +240,7 @@
         return;
     }
 
-    SVGGraphicsElement::parseAttribute(name, value);
+    SVGGeometryElement::parseAttribute(name, value);
     SVGExternalResourcesRequired::parseAttribute(name, value);
 }
 
@@ -247,7 +247,7 @@
 void SVGPathElement::svgAttributeChanged(const QualifiedName& attrName)
 {
     if (!isSupportedAttribute(attrName)) {
-        SVGGraphicsElement::svgAttributeChanged(attrName);
+        SVGGeometryElement::svgAttributeChanged(attrName);
         return;
     }
 
@@ -286,7 +286,7 @@
 
 Node::InsertedIntoAncestorResult SVGPathElement::insertedIntoAncestor(InsertionType insertionType, ContainerNode& parentOfInsertedTree)
 {
-    SVGGraphicsElement::insertedIntoAncestor(insertionType, parentOfInsertedTree);
+    SVGGeometryElement::insertedIntoAncestor(insertionType, parentOfInsertedTree);
     invalidateMPathDependencies();
     return InsertedIntoAncestorResult::Done;
 }
@@ -293,7 +293,7 @@
 
 void SVGPathElement::removedFromAncestor(RemovalType removalType, ContainerNode& oldParentOfRemovedTree)
 {
-    SVGGraphicsElement::removedFromAncestor(removalType, oldParentOfRemovedTree);
+    SVGGeometryElement::removedFromAncestor(removalType, oldParentOfRemovedTree);
     invalidateMPathDependencies();
 }
 

Modified: trunk/Source/WebCore/svg/SVGPathElement.h (230828 => 230829)


--- trunk/Source/WebCore/svg/SVGPathElement.h	2018-04-19 23:59:50 UTC (rev 230828)
+++ trunk/Source/WebCore/svg/SVGPathElement.h	2018-04-20 01:00:40 UTC (rev 230829)
@@ -24,7 +24,7 @@
 #include "SVGAnimatedBoolean.h"
 #include "SVGAnimatedNumber.h"
 #include "SVGExternalResourcesRequired.h"
-#include "SVGGraphicsElement.h"
+#include "SVGGeometryElement.h"
 #include "SVGNames.h"
 #include "SVGPathByteStream.h"
 #include "SVGPathSegListValues.h"
@@ -53,13 +53,13 @@
 class SVGPathSegList;
 class SVGPoint;
 
-class SVGPathElement final : public SVGGraphicsElement, public SVGExternalResourcesRequired {
+class SVGPathElement final : public SVGGeometryElement, public SVGExternalResourcesRequired {
     WTF_MAKE_ISO_ALLOCATED(SVGPathElement);
 public:
     static Ref<SVGPathElement> create(const QualifiedName&, Document&);
     
-    float getTotalLength() const;
-    Ref<SVGPoint> getPointAtLength(float distance) const;
+    float getTotalLength() const final;
+    Ref<SVGPoint> getPointAtLength(float distance) const final;
     unsigned getPathSegAtLength(float distance) const;
 
     Ref<SVGPathSegClosePath> createSVGPathSegClosePath(SVGPathSegRole = PathSegUndefinedRole);

Modified: trunk/Source/WebCore/svg/SVGPathElement.idl (230828 => 230829)


--- trunk/Source/WebCore/svg/SVGPathElement.idl	2018-04-19 23:59:50 UTC (rev 230828)
+++ trunk/Source/WebCore/svg/SVGPathElement.idl	2018-04-20 01:00:40 UTC (rev 230829)
@@ -24,11 +24,7 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
  */
 
-interface SVGPathElement : SVGGraphicsElement {
-    readonly attribute SVGAnimatedNumber pathLength;
-
-    unrestricted float getTotalLength();
-    [NewObject] SVGPoint getPointAtLength(optional unrestricted float distance = NaN);
+interface SVGPathElement : SVGGeometryElement {
     unsigned long getPathSegAtLength(optional unrestricted float distance = NaN);
 
     SVGPathSegClosePath createSVGPathSegClosePath();
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to