ASSERTion failure when SVG element is removed from document and readded

https://bugs.webkit.org/show_bug.cgi?id=95517
<rdar://problem/12175583>

Reviewed by Brady Eidson.

Previously, SVG animations would cease to animate when their parent
<svg> element was removed and re-added to the document.

Instead, to match Firefox and Opera, we should continue the animation
with the same beginTime (i.e. the animation continues as if it had never
been removed from the document).

Test: svg/animations/reinserting-svg-into-document.html

* svg/SVGSVGElement.cpp:
(WebCore::SVGSVGElement::insertedInto): Don't call begin() on an already-started SMILTimeContainer().
* svg/animation/SMILTimeContainer.cpp:
(WebCore::SMILTimeContainer::isStarted): Added.
* svg/animation/SMILTimeContainer.h: Add isStarted().
* svg/animation/SVGSMILElement.cpp:
(WebCore::SVGSMILElement::insertedInto): Always reschedule SVGSMILElements with
their parent SMILTimeContainer when they are inserted into the document, otherwise
they are lost (and never again update) when their subtree is removed and then
readded to the document.

Add a test that ensures that removing an SVG element from the document
and readding it continues SMIL animations.

* svg/animations/reinserting-svg-into-document.html: Added.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@127474 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 34be567b
2012-09-04 Tim Horton <timothy_horton@apple.com>
ASSERTion failure when SVG element is removed from document and readded
https://bugs.webkit.org/show_bug.cgi?id=95517
<rdar://problem/12175583>
Reviewed by Brady Eidson.
Add a test that ensures that removing an SVG element from the document
and readding it continues SMIL animations.
* svg/animations/reinserting-svg-into-document.html: Added.
2012-09-04 Vincent Scheib <scheib@chromium.org>
[Chromium] Allow asyncronous response of pointer lock requests in layout tests.
Reinserting SVG animation into document should continue the animation
PASS rect.x.animVal.value is 30
PASS rect.x.animVal.value is 60
<html>
<script src="../../fast/js/resources/js-test-pre.js"></script>
<script src="resources/SVGAnimationTestCase.js"></script>
<script>
function load() {
if (window.testRunner) {
testRunner.dumpAsText();
testRunner.waitUntilDone();
}
svg = document.getElementById("svg");
rect = document.getElementById("rect");
setTimeout(function () {
svg.setCurrentTime(1);
document.body.removeChild(svg);
document.body.appendChild(svg);
setTimeout(function () {
shouldBeCloseEnough("rect.x.animVal.value", "30", 1);
svg.setCurrentTime(2);
shouldBeCloseEnough("rect.x.animVal.value", "60", 1);
if (window.testRunner)
testRunner.notifyDone();
}, 0);
}, 0);
};
</script>
<body onload="load()">
<h1>Reinserting SVG animation into document should continue the animation</h1>
<p id="description"></p>
<div id="console"></div>
<svg id="svg" xmlns="http://www.w3.org/2000/svg">
<rect id="rect" x="0" y="0" width="20" height="20">
<animate attributeName="x" begin="0" from="0" to="90" dur="3s" fill="freeze" />
</rect>
</svg>
</body>
</html>
2012-09-04 Tim Horton <timothy_horton@apple.com>
ASSERTion failure when SVG element is removed from document and readded
https://bugs.webkit.org/show_bug.cgi?id=95517
<rdar://problem/12175583>
Reviewed by Brady Eidson.
Previously, SVG animations would cease to animate when their parent
<svg> element was removed and re-added to the document.
Instead, to match Firefox and Opera, we should continue the animation
with the same beginTime (i.e. the animation continues as if it had never
been removed from the document).
Test: svg/animations/reinserting-svg-into-document.html
* svg/SVGSVGElement.cpp:
(WebCore::SVGSVGElement::insertedInto): Don't call begin() on an already-started SMILTimeContainer().
* svg/animation/SMILTimeContainer.cpp:
(WebCore::SMILTimeContainer::isStarted): Added.
* svg/animation/SMILTimeContainer.h: Add isStarted().
* svg/animation/SVGSMILElement.cpp:
(WebCore::SVGSMILElement::insertedInto): Always reschedule SVGSMILElements with
their parent SMILTimeContainer when they are inserted into the document, otherwise
they are lost (and never again update) when their subtree is removed and then
readded to the document.
2012-09-04 Andrei Bucur <abucur@adobe.com>
[CSS Regions] Destroying a render named flow thread without unregistering left-over content nodes triggered an assertion.
......@@ -70,15 +70,22 @@ void ScrollingTreeNodeMac::update(ScrollingTreeState* state)
if (state->changedProperties() & (ScrollingTreeState::ScrollLayer | ScrollingTreeState::ContentsSize | ScrollingTreeState::ViewportRect))
updateMainFramePinState(scrollPosition());
if ((state->changedProperties() & ScrollingTreeState::ShouldUpdateScrollLayerPositionOnMainThread) && shouldUpdateScrollLayerPositionOnMainThread()) {
// We're transitioning to the slow "update scroll layer position on the main thread" mode.
// Initialize the probable main thread scroll position with the current scroll layer position.
if (state->changedProperties() & ScrollingTreeState::RequestedScrollPosition)
m_probableMainThreadScrollPosition = state->requestedScrollPosition();
else {
CGPoint scrollLayerPosition = m_scrollLayer.get().position;
m_probableMainThreadScrollPosition = IntPoint(-scrollLayerPosition.x, -scrollLayerPosition.y);
if ((state->changedProperties() & ScrollingTreeState::ShouldUpdateScrollLayerPositionOnMainThread)) {
bool updateScrollLayerPositionOnMainThread = shouldUpdateScrollLayerPositionOnMainThread();
if (updateScrollLayerPositionOnMainThread) {
// We're transitioning to the slow "update scroll layer position on the main thread" mode.
// Initialize the probable main thread scroll position with the current scroll layer position.
if (state->changedProperties() & ScrollingTreeState::RequestedScrollPosition)
m_probableMainThreadScrollPosition = state->requestedScrollPosition();
else {
CGPoint scrollLayerPosition = m_scrollLayer.get().position;
m_probableMainThreadScrollPosition = IntPoint(-scrollLayerPosition.x, -scrollLayerPosition.y);
}
}
if (scrollingTree()->scrollingPeformanceLoggingEnabled())
printf("SCROLLING: Switching to %s scrolling mode. Time: %f\n", updateScrollLayerPositionOnMainThread ? "slow" : "fast", WTF::monotonicallyIncreasingTime());
}
}
......
......@@ -480,7 +480,7 @@ Node::InsertionNotificationRequest SVGSVGElement::insertedInto(ContainerNode* ro
// 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())
if (!document()->parsing() && !document()->processingLoadEvent() && document()->loadEventFinished() && !timeContainer()->isStarted())
timeContainer()->begin();
}
return SVGStyledLocatableElement::insertedInto(rootParent);
......
......@@ -84,6 +84,11 @@ bool SMILTimeContainer::isPaused() const
return m_pauseTime;
}
bool SMILTimeContainer::isStarted() const
{
return m_beginTime;
}
void SMILTimeContainer::begin()
{
ASSERT(!m_beginTime);
......
......@@ -55,6 +55,7 @@ public:
bool isActive() const;
bool isPaused() const;
bool isStarted() const;
void begin();
void pause();
......
......@@ -212,10 +212,10 @@ Node::InsertionNotificationRequest SVGSMILElement::insertedInto(ContainerNode* r
if (!fastHasAttribute(SVGNames::beginAttr))
m_beginTimes.append(SMILTimeWithOrigin());
if (m_isWaitingForFirstInterval) {
if (m_isWaitingForFirstInterval)
resolveFirstInterval();
reschedule();
}
reschedule();
return InsertionDone;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment