Modified: trunk/LayoutTests/ChangeLog (124368 => 124369)
--- trunk/LayoutTests/ChangeLog 2012-08-01 21:21:55 UTC (rev 124368)
+++ trunk/LayoutTests/ChangeLog 2012-08-01 21:24:28 UTC (rev 124369)
@@ -1,3 +1,13 @@
+2012-08-01 Florin Malita <[email protected]>
+
+ SVG animation not working for elements inserted after parsing is finished
+ https://bugs.webkit.org/show_bug.cgi?id=92025
+
+ Reviewed by Nikolas Zimmermann.
+
+ * svg/animations/deferred-insertion-expected.txt: Added.
+ * svg/animations/deferred-insertion.html: Added.
+
2012-08-01 Vincent Scheib <[email protected]>
Block pointer lock for sandboxed iframes.
Added: trunk/LayoutTests/svg/animations/deferred-insertion-expected.txt (0 => 124369)
--- trunk/LayoutTests/svg/animations/deferred-insertion-expected.txt (rev 0)
+++ trunk/LayoutTests/svg/animations/deferred-insertion-expected.txt 2012-08-01 21:24:28 UTC (rev 124369)
@@ -0,0 +1,19 @@
+SVG 1.1 dynamic animation tests
+
+Test for animation on elements inserted programmatically. Should result in a 200x200 rect and only PASS messages
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS rect.width.animVal.value is 200
+PASS rect.width.baseVal.value is 200
+PASS rect.width.animVal.value is 150
+PASS rect.width.baseVal.value is 200
+PASS rect.width.animVal.value is 100
+PASS rect.width.baseVal.value is 200
+PASS rect.width.animVal.value is 200
+PASS rect.width.baseVal.value is 200
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/svg/animations/deferred-insertion.html (0 => 124369)
--- trunk/LayoutTests/svg/animations/deferred-insertion.html (rev 0)
+++ trunk/LayoutTests/svg/animations/deferred-insertion.html 2012-08-01 21:24:28 UTC (rev 124369)
@@ -0,0 +1,79 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src=""
+<script src=""
+<script src=""
+</head>
+<body _onload_="scheduleTest()">
+<h1>SVG 1.1 dynamic animation tests</h1>
+<p id="description"></p>
+<div id="console"></div>
+<script>
+
+function scheduleTest() {
+ if (window.testRunner)
+ testRunner.waitUntilDone();
+
+ setTimeout(startTest, 0);
+}
+
+function startTest() {
+ description("Test for animation on elements inserted programmatically. Should result in a 200x200 rect and only PASS messages");
+ createSVGTestCase();
+
+ // Setup test document
+ var rect = createSVGElement("rect");
+ rect.setAttribute("id", "rect");
+ rect.setAttribute("width", "200");
+ rect.setAttribute("height", "200");
+ rect.setAttribute("fill", "green");
+ rect.setAttribute("onclick", "executeTest()");
+
+ var animate = createSVGElement("animate");
+ animate.setAttribute("id", "animation");
+ animate.setAttribute("attributeName", "width");
+ animate.setAttribute("from", "200");
+ animate.setAttribute("to", "100");
+ animate.setAttribute("begin", "click");
+ animate.setAttribute("dur", "4s");
+ rect.appendChild(animate);
+ rootSVGElement.appendChild(rect);
+
+ runSMILTest();
+}
+
+function sample1() {
+ // Check initial/end conditions
+ shouldBeCloseEnough("rect.width.animVal.value", "200");
+ shouldBe("rect.width.baseVal.value", "200");
+}
+
+function sample2() {
+ // Check half-time conditions
+ shouldBeCloseEnough("rect.width.animVal.value", "150");
+ shouldBe("rect.width.baseVal.value", "200");
+}
+
+function sample3() {
+ // Check just before-end conditions
+ shouldBeCloseEnough("rect.width.animVal.value", "100");
+ shouldBe("rect.width.baseVal.value", "200");
+}
+
+function executeTest() {
+ const expectedValues = [
+ // [animationId, time, sampleCallback]
+ ["animation", 0.0, sample1],
+ ["animation", 2.0, sample2],
+ ["animation", 3.999, sample3],
+ ["animation", 4.001, sample1]
+ ];
+
+ runAnimationTest(expectedValues);
+}
+
+var successfullyParsed = true;
+</script>
+</body>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (124368 => 124369)
--- trunk/Source/WebCore/ChangeLog 2012-08-01 21:21:55 UTC (rev 124368)
+++ trunk/Source/WebCore/ChangeLog 2012-08-01 21:24:28 UTC (rev 124369)
@@ -1,3 +1,19 @@
+2012-08-01 Florin Malita <[email protected]>
+
+ SVG animation not working for elements inserted after parsing is finished
+ https://bugs.webkit.org/show_bug.cgi?id=92025
+
+ Reviewed by Nikolas Zimmermann.
+
+ Time containers for SVG elements inserted after document parsing is finished need to be
+ initialized on insertion (since they've missed the Document::implicitClose() initialization
+ point).
+
+ Test: svg/animations/deferred-insertion.html
+
+ * svg/SVGSVGElement.cpp:
+ (WebCore::SVGSVGElement::insertedInto):
+
2012-08-01 Vincent Scheib <[email protected]>
Block pointer lock for sandboxed iframes.
Modified: trunk/Source/WebCore/svg/SVGSVGElement.cpp (124368 => 124369)
--- trunk/Source/WebCore/svg/SVGSVGElement.cpp 2012-08-01 21:21:55 UTC (rev 124368)
+++ trunk/Source/WebCore/svg/SVGSVGElement.cpp 2012-08-01 21:24:28 UTC (rev 124369)
@@ -474,8 +474,15 @@
Node::InsertionNotificationRequest SVGSVGElement::insertedInto(ContainerNode* rootParent)
{
- if (rootParent->inDocument())
+ if (rootParent->inDocument()) {
document()->accessSVGExtensions()->addTimeContainer(this);
+
+ // Animations are started at the end of document parsing and after firing the load event,
+ // but if we miss that train (deferred programmatic element insertion for example) we need
+ // to initialize the time container here.
+ if (!document()->parsing() && !document()->processingLoadEvent() && document()->loadEventFinished())
+ timeContainer()->begin();
+ }
return SVGStyledLocatableElement::insertedInto(rootParent);
}