Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1553)

Unified Diff: Source/core/svg/animation/SMILTimeContainer.cpp

Issue 195233003: Prevent destruction of self in SMILTimeContainer with 'discard' (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « LayoutTests/svg/animations/discard-on-svg-crash-2-expected.txt ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/svg/animation/SMILTimeContainer.cpp
diff --git a/Source/core/svg/animation/SMILTimeContainer.cpp b/Source/core/svg/animation/SMILTimeContainer.cpp
index 598d6f6af80e153a288f4fdc2cc29e3f8508b1e7..ee0886e8938f8a73bc0c31d6dd4c67dfac4344e0 100644
--- a/Source/core/svg/animation/SMILTimeContainer.cpp
+++ b/Source/core/svg/animation/SMILTimeContainer.cpp
@@ -37,6 +37,16 @@ using namespace std;
namespace WebCore {
+// Every entry-point that calls updateAnimations() should instantiate a
+// DiscardScope to prevent deletion of the ownerElement (and hence itself.)
+class DiscardScope {
+public:
+ explicit DiscardScope(SVGSVGElement& timeContainerOwner) : m_discardScopeElement(&timeContainerOwner) { }
+
+private:
+ RefPtr<SVGSVGElement> m_discardScopeElement;
+};
+
SMILTimeContainer::SMILTimeContainer(SVGSVGElement& owner)
: m_beginTime(0)
, m_pauseTime(0)
@@ -147,6 +157,7 @@ void SMILTimeContainer::begin()
// If 'm_presetStartTime' is set, the timeline was modified via setElapsed() before the document began.
// In this case pass on 'seekToTime=true' to updateAnimations().
m_beginTime = now - m_presetStartTime;
+ DiscardScope discardScope(m_ownerSVGElement);
SMILTime earliestFireTime = updateAnimations(SMILTime(m_presetStartTime), m_presetStartTime ? true : false);
m_presetStartTime = 0;
@@ -219,6 +230,7 @@ void SMILTimeContainer::setElapsed(SMILTime time)
m_preventScheduledAnimationsChanges = false;
#endif
+ DiscardScope discardScope(m_ownerSVGElement);
updateAnimationsAndScheduleFrameIfNeeded(time, true);
}
@@ -261,6 +273,7 @@ void SMILTimeContainer::wakeupTimerFired(Timer<SMILTimeContainer>*)
} else {
ASSERT(m_frameSchedulingState == SynchronizeAnimations);
m_frameSchedulingState = Idle;
+ DiscardScope discardScope(m_ownerSVGElement);
updateAnimationsAndScheduleFrameIfNeeded(elapsed());
}
}
@@ -321,6 +334,7 @@ void SMILTimeContainer::serviceAnimations(double monotonicAnimationStartTime)
m_frameSchedulingState = Idle;
animationClock().updateTime(monotonicAnimationStartTime);
+ DiscardScope discardScope(m_ownerSVGElement);
kouhei (in TOK) 2014/03/12 00:30:30 Can we put this inside updateAnimationsAndSchedule
fs 2014/03/12 07:32:14 No (unfortunately), because on the next line follo
updateAnimationsAndScheduleFrameIfNeeded(elapsed());
animationClock().unfreeze();
}
« no previous file with comments | « LayoutTests/svg/animations/discard-on-svg-crash-2-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698