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

Unified Diff: third_party/WebKit/Source/core/animation/Animation.cpp

Issue 1716673002: Web Animations: Throw exceptions for play/pause/reverse/finish with infinite end time (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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
Index: third_party/WebKit/Source/core/animation/Animation.cpp
diff --git a/third_party/WebKit/Source/core/animation/Animation.cpp b/third_party/WebKit/Source/core/animation/Animation.cpp
index 197b921791673d6c093b822a87659bf8fcd47621..7c57d020d976a148e99b0d887bf99508f3c24e80 100644
--- a/third_party/WebKit/Source/core/animation/Animation.cpp
+++ b/third_party/WebKit/Source/core/animation/Animation.cpp
@@ -500,7 +500,7 @@ Animation::AnimationPlayState Animation::calculatePlayState()
return Running;
}
-void Animation::pause()
+void Animation::pause(ExceptionState& exceptionState)
{
if (m_paused)
return;
@@ -509,6 +509,10 @@ void Animation::pause()
double newCurrentTime = currentTimeInternal();
if (calculatePlayState() == Idle) {
+ if (m_playbackRate < 0 && effectEnd() == std::numeric_limits<double>::infinity()) {
+ exceptionState.throwDOMException(InvalidStateError, "Cannot pause, Animation has infinite target effect end.");
+ return;
+ }
newCurrentTime = m_playbackRate < 0 ? effectEnd() : 0;
}
@@ -537,10 +541,16 @@ void Animation::unpauseInternal()
setCurrentTimeInternal(currentTimeInternal(), TimingUpdateOnDemand);
}
-void Animation::play()
+void Animation::play(ExceptionState& exceptionState)
{
PlayStateUpdateScope updateScope(*this, TimingUpdateOnDemand);
+ double currentTime = this->currentTimeInternal();
+ if (m_playbackRate < 0 && currentTime <= 0 && effectEnd() == std::numeric_limits<double>::infinity()) {
+ exceptionState.throwDOMException(InvalidStateError, "Cannot play reversed Animation with infinite target effect end.");
+ return;
+ }
+
if (!playing()) {
m_startTime = nullValue();
}
@@ -550,8 +560,6 @@ void Animation::play()
m_holdTime = 0;
}
- double currentTime = this->currentTimeInternal();
-
m_playState = Unset;
m_finished = false;
unpauseInternal();
@@ -565,14 +573,14 @@ void Animation::play()
}
}
-void Animation::reverse()
+void Animation::reverse(ExceptionState& exceptionState)
{
if (!m_playbackRate) {
return;
}
setPlaybackRateInternal(-m_playbackRate);
- play();
+ play(exceptionState);
}
void Animation::finish(ExceptionState& exceptionState)
« no previous file with comments | « third_party/WebKit/Source/core/animation/Animation.h ('k') | third_party/WebKit/Source/core/animation/Animation.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698