2011-05-26 Rob Buis <rbuis@rim.com>
authorrwlbuis@webkit.org <rwlbuis@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 26 May 2011 16:13:10 +0000 (16:13 +0000)
committerrwlbuis@webkit.org <rwlbuis@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 26 May 2011 16:13:10 +0000 (16:13 +0000)
        Reviewed by Dirk Schulze.

        Dynamically created <animate> elements do not animate upon document insertion as they should
        https://bugs.webkit.org/show_bug.cgi?id=20028

        Tests: svg/animations/animate-insert-begin.html
               svg/animations/animate-insert-no-begin.html

        Move animation initializing and rescheduling to insertedIntoDocument. This way animate elements
        dynamicaly inserted into the document using js start as well.

        * svg/animation/SVGSMILElement.cpp:
        (WebCore::SVGSMILElement::insertedIntoDocument):
        * svg/animation/SVGSMILElement.h:
2011-05-26  Rob Buis  <rbuis@rim.com>

        Reviewed by Dirk Schulze.

        Dynamically created <animate> elements do not animate upon document insertion as they should
        https://bugs.webkit.org/show_bug.cgi?id=20028

        Add tests for dynamically inserting <animate>.

        * svg/animations/animate-insert-begin-expected.txt: Added.
        * svg/animations/animate-insert-begin.html: Added.
        * svg/animations/animate-insert-no-begin-expected.txt: Added.
        * svg/animations/animate-insert-no-begin.html: Added.
        * svg/animations/script-tests/animate-insert-begin.js: Added.
        (sample1):
        (sample2):
        (executeTest):
        * svg/animations/script-tests/animate-insert-no-begin.js: Added.
        (sample1):
        (sample2):
        (executeTest):

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

LayoutTests/ChangeLog
LayoutTests/svg/animations/animate-insert-begin-expected.txt [new file with mode: 0644]
LayoutTests/svg/animations/animate-insert-begin.html [new file with mode: 0644]
LayoutTests/svg/animations/animate-insert-no-begin-expected.txt [new file with mode: 0644]
LayoutTests/svg/animations/animate-insert-no-begin.html [new file with mode: 0644]
LayoutTests/svg/animations/script-tests/animate-insert-begin.js [new file with mode: 0644]
LayoutTests/svg/animations/script-tests/animate-insert-no-begin.js [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/svg/animation/SVGSMILElement.cpp
Source/WebCore/svg/animation/SVGSMILElement.h

index ae2c964..40b831c 100644 (file)
@@ -1,3 +1,25 @@
+2011-05-26  Rob Buis  <rbuis@rim.com>
+
+        Reviewed by Dirk Schulze.
+
+        Dynamically created <animate> elements do not animate upon document insertion as they should
+        https://bugs.webkit.org/show_bug.cgi?id=20028
+
+        Add tests for dynamically inserting <animate>.
+
+        * svg/animations/animate-insert-begin-expected.txt: Added.
+        * svg/animations/animate-insert-begin.html: Added.
+        * svg/animations/animate-insert-no-begin-expected.txt: Added.
+        * svg/animations/animate-insert-no-begin.html: Added.
+        * svg/animations/script-tests/animate-insert-begin.js: Added.
+        (sample1):
+        (sample2):
+        (executeTest):
+        * svg/animations/script-tests/animate-insert-no-begin.js: Added.
+        (sample1):
+        (sample2):
+        (executeTest):
+
 2011-05-26  Chang Shu  <cshu@webkit.org>
 
         Unreviewed.
diff --git a/LayoutTests/svg/animations/animate-insert-begin-expected.txt b/LayoutTests/svg/animations/animate-insert-begin-expected.txt
new file mode 100644 (file)
index 0000000..b7e79f4
--- /dev/null
@@ -0,0 +1,13 @@
+SVG 1.1 dynamic animation tests
+
+Test behavior of dynamically inserting animate with begin attribute
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS rect.x.baseVal.value is 0
+PASS rect.x.baseVal.value is 90
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/svg/animations/animate-insert-begin.html b/LayoutTests/svg/animations/animate-insert-begin.html
new file mode 100644 (file)
index 0000000..b5ff1e0
--- /dev/null
@@ -0,0 +1,15 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<link rel="stylesheet" href="../../fast/js/resources/js-test-style.css">
+<script src="../../fast/js/resources/js-test-pre.js"></script>
+<script src="../dynamic-updates/resources/SVGTestCase.js"></script>
+<script src="resources/SVGAnimationTestCase.js"></script>
+</head>
+<body>
+<h1>SVG 1.1 dynamic animation tests</h1>
+<p id="description"></p>
+<div id="console"></div>
+<script src="script-tests/animate-insert-begin.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/svg/animations/animate-insert-no-begin-expected.txt b/LayoutTests/svg/animations/animate-insert-no-begin-expected.txt
new file mode 100644 (file)
index 0000000..1c1553b
--- /dev/null
@@ -0,0 +1,13 @@
+SVG 1.1 dynamic animation tests
+
+Test behavior of dynamically inserting animate without begin attribute
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS rect.x.baseVal.value is 0
+PASS rect.x.baseVal.value is 90
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/svg/animations/animate-insert-no-begin.html b/LayoutTests/svg/animations/animate-insert-no-begin.html
new file mode 100644 (file)
index 0000000..7d6ae7f
--- /dev/null
@@ -0,0 +1,15 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<link rel="stylesheet" href="../../fast/js/resources/js-test-style.css">
+<script src="../../fast/js/resources/js-test-pre.js"></script>
+<script src="../dynamic-updates/resources/SVGTestCase.js"></script>
+<script src="resources/SVGAnimationTestCase.js"></script>
+</head>
+<body>
+<h1>SVG 1.1 dynamic animation tests</h1>
+<p id="description"></p>
+<div id="console"></div>
+<script src="script-tests/animate-insert-no-begin.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/svg/animations/script-tests/animate-insert-begin.js b/LayoutTests/svg/animations/script-tests/animate-insert-begin.js
new file mode 100644 (file)
index 0000000..ea23c63
--- /dev/null
@@ -0,0 +1,47 @@
+description("Test behavior of dynamically inserting animate with begin attribute");
+createSVGTestCase();
+
+
+// Setup test document
+var rect = createSVGElement("rect");
+rect.setAttribute("id", "rect");
+rect.setAttribute("x", "0");
+rect.setAttribute("y", "45");
+rect.setAttribute("width", "10");
+rect.setAttribute("height", "10");
+rect.setAttribute("fill", "green");
+rect.setAttribute("onclick", "executeTest()");
+
+var animate = createSVGElement("animate");
+animate.setAttribute("id", "animation");
+animate.setAttribute("attributeName", "x");
+animate.setAttribute("begin", "0");
+animate.setAttribute("from", "0");
+animate.setAttribute("to", "90");
+animate.setAttribute("dur", "3s");
+animate.setAttribute("fill", "freeze");
+rect.appendChild(animate);
+rootSVGElement.appendChild(rect);
+
+// Setup animation test
+function sample1() {
+    shouldBe("rect.x.baseVal.value", "0");
+}
+
+function sample2() {
+    shouldBe("rect.x.baseVal.value", "90");
+}
+
+function executeTest() {
+    const expectedValues = [
+        // [animationId, time, elementId, sampleCallback]
+        ["animation", 0.0,    "rect", sample1],
+        ["animation", 3.0,    "rect", sample2],
+    ];
+
+    runAnimationTest(expectedValues);
+}
+
+// Begin test async
+window.setTimeout("triggerUpdate(5, 50)", 0);
+var successfullyParsed = true;
diff --git a/LayoutTests/svg/animations/script-tests/animate-insert-no-begin.js b/LayoutTests/svg/animations/script-tests/animate-insert-no-begin.js
new file mode 100644 (file)
index 0000000..30393b4
--- /dev/null
@@ -0,0 +1,46 @@
+description("Test behavior of dynamically inserting animate without begin attribute");
+createSVGTestCase();
+
+
+// Setup test document
+var rect = createSVGElement("rect");
+rect.setAttribute("id", "rect");
+rect.setAttribute("x", "0");
+rect.setAttribute("y", "45");
+rect.setAttribute("width", "10");
+rect.setAttribute("height", "10");
+rect.setAttribute("fill", "green");
+rect.setAttribute("onclick", "executeTest()");
+
+var animate = createSVGElement("animate");
+animate.setAttribute("id", "animation");
+animate.setAttribute("attributeName", "x");
+animate.setAttribute("from", "0");
+animate.setAttribute("to", "90");
+animate.setAttribute("dur", "3s");
+animate.setAttribute("fill", "freeze");
+rect.appendChild(animate);
+rootSVGElement.appendChild(rect);
+
+// Setup animation test
+function sample1() {
+    shouldBe("rect.x.baseVal.value", "0");
+}
+
+function sample2() {
+    shouldBe("rect.x.baseVal.value", "90");
+}
+
+function executeTest() {
+    const expectedValues = [
+        // [animationId, time, elementId, sampleCallback]
+        ["animation", 0.0,    "rect", sample1],
+        ["animation", 3.0,    "rect", sample2],
+    ];
+
+    runAnimationTest(expectedValues);
+}
+
+// Begin test async
+window.setTimeout("triggerUpdate(5, 50)", 0);
+var successfullyParsed = true;
index 6b5f0d4..c274697 100644 (file)
@@ -1,3 +1,20 @@
+2011-05-26  Rob Buis  <rbuis@rim.com>
+
+        Reviewed by Dirk Schulze.
+
+        Dynamically created <animate> elements do not animate upon document insertion as they should
+        https://bugs.webkit.org/show_bug.cgi?id=20028
+
+        Tests: svg/animations/animate-insert-begin.html
+               svg/animations/animate-insert-no-begin.html
+
+        Move animation initializing and rescheduling to insertedIntoDocument. This way animate elements
+        dynamicaly inserted into the document using js start as well.
+
+        * svg/animation/SVGSMILElement.cpp:
+        (WebCore::SVGSMILElement::insertedIntoDocument):
+        * svg/animation/SVGSMILElement.h:
+
 2011-05-26  Andreas Kling  <kling@webkit.org>
 
         Reviewed by Benjamin Poulain.
index dca5064..bcc8bbb 100644 (file)
@@ -182,7 +182,15 @@ void SVGSMILElement::insertedIntoDocument()
     m_timeContainer = owner->timeContainer();
     ASSERT(m_timeContainer);
     m_timeContainer->setDocumentOrderIndexesDirty();
-    reschedule();
+
+    // "If no attribute is present, the default begin value (an offset-value of 0) must be evaluated."
+    if (!hasAttribute(SVGNames::beginAttr))
+        m_beginTimes.append(0);
+
+    if (m_isWaitingForFirstInterval) {
+        resolveFirstInterval();
+        reschedule();
+    }
 }
 
 void SVGSMILElement::removedFromDocument()
@@ -203,20 +211,6 @@ void SVGSMILElement::removedFromDocument()
     SVGElement::removedFromDocument();
 }
    
-void SVGSMILElement::finishParsingChildren()
-{
-    SVGElement::finishParsingChildren();
-
-    // "If no attribute is present, the default begin value (an offset-value of 0) must be evaluated."
-    if (!hasAttribute(SVGNames::beginAttr))
-        m_beginTimes.append(0);
-
-    if (m_isWaitingForFirstInterval) {
-        resolveFirstInterval();
-        reschedule();
-    }
-}
-
 SMILTime SVGSMILElement::parseOffsetValue(const String& data)
 {
     bool ok;
index af6dbff..3376c00 100644 (file)
@@ -48,7 +48,6 @@ public:
     virtual void attributeChanged(Attribute*, bool preserveDecls);
     virtual void insertedIntoDocument();
     virtual void removedFromDocument();
-    virtual void finishParsingChildren();
     
     virtual bool hasValidAttributeType() const = 0;