Title: [242515] trunk
Revision
242515
Author
s...@apple.com
Date
2019-03-05 15:12:51 -0800 (Tue, 05 Mar 2019)

Log Message

SVGPathSegList.insertItemBefore() should fail if the newItem belongs to an animating animPathSegList
https://bugs.webkit.org/show_bug.cgi?id=195333
<rdar://problem/48475802>

Reviewed by Simon Fraser.

Source/WebCore:

Because the SVG1.1 specs states that the newItem should be removed from
its original list before adding it to another list,
SVGPathSegList.insertItemBefore() should fail if the new item belongs to
an animating animPathSegList since it is read-only.

Test: svg/dom/SVGPathSegList-insert-from-animating-animPathSegList.svg

* svg/SVGPathSegList.cpp:
(WebCore::SVGPathSegList::processIncomingListItemValue):

LayoutTests:

* svg/dom/SVGPathSegList-insert-from-animating-animPathSegList-expected.txt: Added.
* svg/dom/SVGPathSegList-insert-from-animating-animPathSegList.svg: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (242514 => 242515)


--- trunk/LayoutTests/ChangeLog	2019-03-05 22:19:59 UTC (rev 242514)
+++ trunk/LayoutTests/ChangeLog	2019-03-05 23:12:51 UTC (rev 242515)
@@ -1,3 +1,14 @@
+2019-03-05  Said Abou-Hallawa  <sabouhall...@apple.com>
+
+        SVGPathSegList.insertItemBefore() should fail if the newItem belongs to an animating animPathSegList
+        https://bugs.webkit.org/show_bug.cgi?id=195333
+        <rdar://problem/48475802>
+
+        Reviewed by Simon Fraser.
+
+        * svg/dom/SVGPathSegList-insert-from-animating-animPathSegList-expected.txt: Added.
+        * svg/dom/SVGPathSegList-insert-from-animating-animPathSegList.svg: Added.
+
 2019-03-05  Ryan Haddad  <ryanhad...@apple.com>
 
         Unreviewed, rolling out r242403.

Added: trunk/LayoutTests/svg/dom/SVGPathSegList-insert-from-animating-animPathSegList-expected.txt (0 => 242515)


--- trunk/LayoutTests/svg/dom/SVGPathSegList-insert-from-animating-animPathSegList-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/svg/dom/SVGPathSegList-insert-from-animating-animPathSegList-expected.txt	2019-03-05 23:12:51 UTC (rev 242515)
@@ -0,0 +1 @@
+PASS: did not assert in debug.

Added: trunk/LayoutTests/svg/dom/SVGPathSegList-insert-from-animating-animPathSegList.svg (0 => 242515)


--- trunk/LayoutTests/svg/dom/SVGPathSegList-insert-from-animating-animPathSegList.svg	                        (rev 0)
+++ trunk/LayoutTests/svg/dom/SVGPathSegList-insert-from-animating-animPathSegList.svg	2019-03-05 23:12:51 UTC (rev 242515)
@@ -0,0 +1,29 @@
+<svg id="svg" xmlns="http://www.w3.org/2000/svg">
+    <path id="path1"></path>
+    <path id="path2" d="M 1 1 S 2,2 3,3">
+        <animate id="animate" attributeName="d" values="M 1 1" min="1s" max="2s"/>
+    </path>
+    <text>PASS: did not assert in debug.</text>
+    <script>
+        if (window.testRunner) {
+            testRunner.dumpAsText();
+            testRunner.waitUntilDone();
+        }
+
+        var animate = document.getElementById("animate");
+        animate.addEventListener('beginEvent' , function () {
+            var path1 = document.getElementById("path1");
+            var path2 = document.getElementById("path2");
+
+            var path1_pathSegList = path1.pathSegList;
+            var path2_animPathSegList = path2.animatedPathSegList;  
+
+            document.documentElement.setCurrentTime(1);
+
+            var pathseg = path2_animPathSegList.getItem(0); 
+            path1_pathSegList.insertItemBefore(pathseg, 0);
+            if (window.testRunner)
+                testRunner.notifyDone();
+        }, { once: true});
+    </script>
+</svg>

Modified: trunk/Source/WebCore/ChangeLog (242514 => 242515)


--- trunk/Source/WebCore/ChangeLog	2019-03-05 22:19:59 UTC (rev 242514)
+++ trunk/Source/WebCore/ChangeLog	2019-03-05 23:12:51 UTC (rev 242515)
@@ -1,3 +1,21 @@
+2019-03-05  Said Abou-Hallawa  <sabouhall...@apple.com>
+
+        SVGPathSegList.insertItemBefore() should fail if the newItem belongs to an animating animPathSegList
+        https://bugs.webkit.org/show_bug.cgi?id=195333
+        <rdar://problem/48475802>
+
+        Reviewed by Simon Fraser.
+
+        Because the SVG1.1 specs states that the newItem should be removed from
+        its original list before adding it to another list,
+        SVGPathSegList.insertItemBefore() should fail if the new item belongs to
+        an animating animPathSegList since it is read-only.
+
+        Test: svg/dom/SVGPathSegList-insert-from-animating-animPathSegList.svg
+
+        * svg/SVGPathSegList.cpp:
+        (WebCore::SVGPathSegList::processIncomingListItemValue):
+
 2019-03-05  Zalan Bujtas  <za...@apple.com>
 
         [ContentChangeObserver] Send content change notification through adjustObservedState

Modified: trunk/Source/WebCore/svg/SVGPathSegList.cpp (242514 => 242515)


--- trunk/Source/WebCore/svg/SVGPathSegList.cpp	2019-03-05 22:19:59 UTC (rev 242514)
+++ trunk/Source/WebCore/svg/SVGPathSegList.cpp	2019-03-05 23:12:51 UTC (rev 242515)
@@ -85,8 +85,15 @@
     bool livesInOtherList = animatedPropertyOfItem != m_animatedProperty;
     RefPtr<SVGAnimatedPathSegListPropertyTearOff> propertyTearOff = static_pointer_cast<SVGAnimatedPathSegListPropertyTearOff>(animatedPropertyOfItem);
     int indexToRemove = propertyTearOff->findItem(newItem.get());
-    ASSERT(indexToRemove != -1);
 
+    // If newItem does not exist in the propertyTearOff baseVal() list, it has to be
+    // in its animVal() list and it has to be animating.
+    if (indexToRemove == -1) {
+        ASSERT(propertyTearOff->isAnimating());
+        ASSERT(propertyTearOff->animVal()->findItem(newItem.get()) != -1);
+        return false;
+    }
+
     // Do not remove newItem if already in this list at the target index.
     if (!livesInOtherList && indexToModify && static_cast<unsigned>(indexToRemove) == *indexToModify)
         return false;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to