Introduce SVGGeometryElement interface
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 20 Apr 2018 01:00:40 +0000 (01:00 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 20 Apr 2018 01:00:40 +0000 (01:00 +0000)
https://bugs.webkit.org/show_bug.cgi?id=184768

Source/WebCore:

Patch by Dirk Schulze <krit@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 <krit@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.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@230829 268f45cc-cd09-0410-ab3c-d52691b4dbfc

19 files changed:
LayoutTests/ChangeLog
LayoutTests/svg/dom/SVGPolygonElement-baseVal-list-removal-crash.html
LayoutTests/svg/dom/path-pointAtLength-expected.txt
LayoutTests/svg/dom/path-pointAtLength.html
LayoutTests/svg/dom/svg2-inheritance-expected.txt
Source/WebCore/CMakeLists.txt
Source/WebCore/ChangeLog
Source/WebCore/DerivedSources.make
Source/WebCore/Sources.txt
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/bindings/scripts/CodeGeneratorJS.pm
Source/WebCore/svg/SVGAllInOne.cpp
Source/WebCore/svg/SVGGeometryElement.cpp [new file with mode: 0644]
Source/WebCore/svg/SVGGeometryElement.h [new file with mode: 0644]
Source/WebCore/svg/SVGGeometryElement.idl [new file with mode: 0644]
Source/WebCore/svg/SVGGradientElement.cpp
Source/WebCore/svg/SVGPathElement.cpp
Source/WebCore/svg/SVGPathElement.h
Source/WebCore/svg/SVGPathElement.idl

index 4959962..76c9a91 100644 (file)
@@ -1,3 +1,17 @@
+2018-04-19  Dirk Schulze  <krit@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  <tzagallo@apple.com>
 
         REGRESSION(r227340): ArrayBuffers were not being serialized when sent via MessagePorts
index 6dbf900..91ef39b 100644 (file)
@@ -7,7 +7,7 @@ if (window.testRunner)
 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);
index a1eb3f1..274ae9b 100644 (file)
@@ -7,6 +7,10 @@ PASS pointAtLengthOfPath('M0,20 L400,20 L640,20') is '(640, 20)'
 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
index df0f1e1..58e14cd 100644 (file)
@@ -22,6 +22,10 @@ shouldBe("pointAtLengthOfPath('M0,20 L400,20 L640,20')", "'(640, 20)'");
 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>
index 3e20661..a41c2ac 100644 (file)
@@ -44,7 +44,7 @@ PASS SVGFontFaceSrcElement inherits SVGElement
 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 SVGMetadataElement inherits SVGElement
 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
index 0c532a4..23c95bf 100644 (file)
@@ -940,6 +940,7 @@ set(WebCore_SVG_IDL_FILES
     svg/SVGFontFaceUriElement.idl
     svg/SVGForeignObjectElement.idl
     svg/SVGGElement.idl
+    svg/SVGGeometryElement.idl
     svg/SVGGlyphElement.idl
     svg/SVGGlyphRefElement.idl
     svg/SVGGradientElement.idl
index 10c8fc3..7a03e30 100644 (file)
@@ -1,3 +1,45 @@
+2018-04-19  Dirk Schulze  <krit@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  <tzagallo@apple.com>
 
         REGRESSION(r227340): ArrayBuffers were not being serialized when sent via MessagePorts
index c84520e..b2cb9e6 100644 (file)
@@ -868,6 +868,7 @@ JS_BINDING_IDLS = \
     $(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 \
index 3f8f998..b18c2c1 100644 (file)
@@ -2147,6 +2147,7 @@ svg/SVGFontFaceSrcElement.cpp
 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 @@ JSSVGFontFaceSrcElement.cpp
 JSSVGFontFaceUriElement.cpp
 JSSVGForeignObjectElement.cpp
 JSSVGGElement.cpp
+JSSVGGeometryElement.cpp
 JSSVGGlyphElement.cpp
 JSSVGGlyphRefElement.cpp
 JSSVGGradientElement.cpp
index f85e14a..d1a45a6 100644 (file)
                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 */; };
                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>"; };
                                B2FA3CB10AB75A6E000E5AC4 /* JSSVGForeignObjectElement.h */,
                                B2FA3CB20AB75A6E000E5AC4 /* JSSVGGElement.cpp */,
                                B2FA3CB30AB75A6E000E5AC4 /* JSSVGGElement.h */,
+                               FB273E832086E73E00A54E87 /* JSSVGGeometryElement.cpp */,
+                               FB273E842086E73E00A54E87 /* JSSVGGeometryElement.h */,
                                B27B28210CEF0C0700D39D54 /* JSSVGGlyphElement.cpp */,
                                B27B28220CEF0C0700D39D54 /* JSSVGGlyphElement.h */,
                                24D9129713CA96DE00D21915 /* JSSVGGlyphRefElement.cpp */,
                                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 */,
                                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 */,
                                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 */,
index 0f5dcfe..a09c70e 100644 (file)
@@ -3560,6 +3560,7 @@ sub GetGnuVTableOffsetForType
         || $typename eq "SVGPolylineElement"
         || $typename eq "SVGRectElement"
         || $typename eq "SVGSVGElement"
+        || $typename eq "SVGGeometryElement"
         || $typename eq "SVGGraphicsElement"
         || $typename eq "SVGSwitchElement"
         || $typename eq "SVGTextElement"
index 01a8543..d33f45d 100644 (file)
 #include "SVGFontFaceUriElement.cpp"
 #include "SVGForeignObjectElement.cpp"
 #include "SVGGElement.cpp"
+#include "SVGGeometryElement.cpp"
 #include "SVGGlyphElement.cpp"
 #include "SVGGlyphRefElement.cpp"
 #include "SVGGradientElement.cpp"
diff --git a/Source/WebCore/svg/SVGGeometryElement.cpp b/Source/WebCore/svg/SVGGeometryElement.cpp
new file mode 100644 (file)
index 0000000..e2b62af
--- /dev/null
@@ -0,0 +1,95 @@
+/*
+ * Copyright (C) 2004, 2005, 2006, 2008 Nikolas Zimmermann <zimmermann@kde.org>
+ * Copyright (C) 2004, 2005, 2006, 2007 Rob Buis <buis@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));
+}
+
+}
diff --git a/Source/WebCore/svg/SVGGeometryElement.h b/Source/WebCore/svg/SVGGeometryElement.h
new file mode 100644 (file)
index 0000000..1939199
--- /dev/null
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2004, 2005, 2006, 2008 Nikolas Zimmermann <zimmermann@kde.org>
+ * Copyright (C) 2004, 2005, 2006, 2007 Rob Buis <buis@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
diff --git a/Source/WebCore/svg/SVGGeometryElement.idl b/Source/WebCore/svg/SVGGeometryElement.idl
new file mode 100644 (file)
index 0000000..1d98e23
--- /dev/null
@@ -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);
+};
index 292b645..bb2b0b6 100644 (file)
@@ -24,7 +24,6 @@
 
 #include "ElementIterator.h"
 #include "RenderSVGHiddenContainer.h"
-#include "RenderSVGPath.h"
 #include "RenderSVGResourceLinearGradient.h"
 #include "RenderSVGResourceRadialGradient.h"
 #include "SVGNames.h"
index 24dee83..1dac18c 100644 (file)
@@ -79,11 +79,11 @@ BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGPathElement)
     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,14 +240,14 @@ void SVGPathElement::parseAttribute(const QualifiedName& name, const AtomicStrin
         return;
     }
 
-    SVGGraphicsElement::parseAttribute(name, value);
+    SVGGeometryElement::parseAttribute(name, value);
     SVGExternalResourcesRequired::parseAttribute(name, value);
 }
 
 void SVGPathElement::svgAttributeChanged(const QualifiedName& attrName)
 {
     if (!isSupportedAttribute(attrName)) {
-        SVGGraphicsElement::svgAttributeChanged(attrName);
+        SVGGeometryElement::svgAttributeChanged(attrName);
         return;
     }
 
@@ -286,14 +286,14 @@ void SVGPathElement::invalidateMPathDependencies()
 
 Node::InsertedIntoAncestorResult SVGPathElement::insertedIntoAncestor(InsertionType insertionType, ContainerNode& parentOfInsertedTree)
 {
-    SVGGraphicsElement::insertedIntoAncestor(insertionType, parentOfInsertedTree);
+    SVGGeometryElement::insertedIntoAncestor(insertionType, parentOfInsertedTree);
     invalidateMPathDependencies();
     return InsertedIntoAncestorResult::Done;
 }
 
 void SVGPathElement::removedFromAncestor(RemovalType removalType, ContainerNode& oldParentOfRemovedTree)
 {
-    SVGGraphicsElement::removedFromAncestor(removalType, oldParentOfRemovedTree);
+    SVGGeometryElement::removedFromAncestor(removalType, oldParentOfRemovedTree);
     invalidateMPathDependencies();
 }
 
index a5a9b8d..bcdf148 100644 (file)
@@ -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 SVGPathSegCurvetoQuadraticSmoothRel;
 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);
index b4df563..ee6bec8 100644 (file)
  * 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();