| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 493 return Paused; | 493 return Paused; |
| 494 if (m_playState == Idle) | 494 if (m_playState == Idle) |
| 495 return Idle; | 495 return Idle; |
| 496 if (m_currentTimePending || (isNull(m_startTime) && m_playbackRate != 0)) | 496 if (m_currentTimePending || (isNull(m_startTime) && m_playbackRate != 0)) |
| 497 return Pending; | 497 return Pending; |
| 498 if (limited()) | 498 if (limited()) |
| 499 return Finished; | 499 return Finished; |
| 500 return Running; | 500 return Running; |
| 501 } | 501 } |
| 502 | 502 |
| 503 void Animation::pause() | 503 void Animation::pause(ExceptionState& exceptionState) |
| 504 { | 504 { |
| 505 if (m_paused) | 505 if (m_paused) |
| 506 return; | 506 return; |
| 507 | 507 |
| 508 PlayStateUpdateScope updateScope(*this, TimingUpdateOnDemand); | 508 PlayStateUpdateScope updateScope(*this, TimingUpdateOnDemand); |
| 509 | 509 |
| 510 double newCurrentTime = currentTimeInternal(); | 510 double newCurrentTime = currentTimeInternal(); |
| 511 if (calculatePlayState() == Idle) { | 511 if (calculatePlayState() == Idle) { |
| 512 if (m_playbackRate < 0 && effectEnd() == std::numeric_limits<double>::in
finity()) { |
| 513 exceptionState.throwDOMException(InvalidStateError, "Cannot pause, A
nimation has infinite target effect end."); |
| 514 return; |
| 515 } |
| 512 newCurrentTime = m_playbackRate < 0 ? effectEnd() : 0; | 516 newCurrentTime = m_playbackRate < 0 ? effectEnd() : 0; |
| 513 } | 517 } |
| 514 | 518 |
| 515 m_playState = Unset; | 519 m_playState = Unset; |
| 516 m_paused = true; | 520 m_paused = true; |
| 517 m_currentTimePending = true; | 521 m_currentTimePending = true; |
| 518 setCurrentTimeInternal(newCurrentTime, TimingUpdateOnDemand); | 522 setCurrentTimeInternal(newCurrentTime, TimingUpdateOnDemand); |
| 519 } | 523 } |
| 520 | 524 |
| 521 void Animation::unpause() | 525 void Animation::unpause() |
| 522 { | 526 { |
| 523 if (!m_paused) | 527 if (!m_paused) |
| 524 return; | 528 return; |
| 525 | 529 |
| 526 PlayStateUpdateScope updateScope(*this, TimingUpdateOnDemand); | 530 PlayStateUpdateScope updateScope(*this, TimingUpdateOnDemand); |
| 527 | 531 |
| 528 m_currentTimePending = true; | 532 m_currentTimePending = true; |
| 529 unpauseInternal(); | 533 unpauseInternal(); |
| 530 } | 534 } |
| 531 | 535 |
| 532 void Animation::unpauseInternal() | 536 void Animation::unpauseInternal() |
| 533 { | 537 { |
| 534 if (!m_paused) | 538 if (!m_paused) |
| 535 return; | 539 return; |
| 536 m_paused = false; | 540 m_paused = false; |
| 537 setCurrentTimeInternal(currentTimeInternal(), TimingUpdateOnDemand); | 541 setCurrentTimeInternal(currentTimeInternal(), TimingUpdateOnDemand); |
| 538 } | 542 } |
| 539 | 543 |
| 540 void Animation::play() | 544 void Animation::play(ExceptionState& exceptionState) |
| 541 { | 545 { |
| 542 PlayStateUpdateScope updateScope(*this, TimingUpdateOnDemand); | 546 PlayStateUpdateScope updateScope(*this, TimingUpdateOnDemand); |
| 543 | 547 |
| 548 double currentTime = this->currentTimeInternal(); |
| 549 if (m_playbackRate < 0 && currentTime <= 0 && effectEnd() == std::numeric_li
mits<double>::infinity()) { |
| 550 exceptionState.throwDOMException(InvalidStateError, "Cannot play reverse
d Animation with infinite target effect end."); |
| 551 return; |
| 552 } |
| 553 |
| 544 if (!playing()) { | 554 if (!playing()) { |
| 545 m_startTime = nullValue(); | 555 m_startTime = nullValue(); |
| 546 } | 556 } |
| 547 | 557 |
| 548 if (playStateInternal() == Idle) { | 558 if (playStateInternal() == Idle) { |
| 549 m_held = true; | 559 m_held = true; |
| 550 m_holdTime = 0; | 560 m_holdTime = 0; |
| 551 } | 561 } |
| 552 | 562 |
| 553 double currentTime = this->currentTimeInternal(); | |
| 554 | |
| 555 m_playState = Unset; | 563 m_playState = Unset; |
| 556 m_finished = false; | 564 m_finished = false; |
| 557 unpauseInternal(); | 565 unpauseInternal(); |
| 558 | 566 |
| 559 if (m_playbackRate > 0 && (currentTime < 0 || currentTime >= effectEnd())) { | 567 if (m_playbackRate > 0 && (currentTime < 0 || currentTime >= effectEnd())) { |
| 560 m_startTime = nullValue(); | 568 m_startTime = nullValue(); |
| 561 setCurrentTimeInternal(0, TimingUpdateOnDemand); | 569 setCurrentTimeInternal(0, TimingUpdateOnDemand); |
| 562 } else if (m_playbackRate < 0 && (currentTime <= 0 || currentTime > effectEn
d())) { | 570 } else if (m_playbackRate < 0 && (currentTime <= 0 || currentTime > effectEn
d())) { |
| 563 m_startTime = nullValue(); | 571 m_startTime = nullValue(); |
| 564 setCurrentTimeInternal(effectEnd(), TimingUpdateOnDemand); | 572 setCurrentTimeInternal(effectEnd(), TimingUpdateOnDemand); |
| 565 } | 573 } |
| 566 } | 574 } |
| 567 | 575 |
| 568 void Animation::reverse() | 576 void Animation::reverse(ExceptionState& exceptionState) |
| 569 { | 577 { |
| 570 if (!m_playbackRate) { | 578 if (!m_playbackRate) { |
| 571 return; | 579 return; |
| 572 } | 580 } |
| 573 | 581 |
| 574 setPlaybackRateInternal(-m_playbackRate); | 582 setPlaybackRateInternal(-m_playbackRate); |
| 575 play(); | 583 play(exceptionState); |
| 576 } | 584 } |
| 577 | 585 |
| 578 void Animation::finish(ExceptionState& exceptionState) | 586 void Animation::finish(ExceptionState& exceptionState) |
| 579 { | 587 { |
| 580 PlayStateUpdateScope updateScope(*this, TimingUpdateOnDemand); | 588 PlayStateUpdateScope updateScope(*this, TimingUpdateOnDemand); |
| 581 | 589 |
| 582 if (!m_playbackRate) { | 590 if (!m_playbackRate) { |
| 583 exceptionState.throwDOMException(InvalidStateError, "Cannot finish Anima
tion with a playbackRate of 0."); | 591 exceptionState.throwDOMException(InvalidStateError, "Cannot finish Anima
tion with a playbackRate of 0."); |
| 584 return; | 592 return; |
| 585 } | 593 } |
| (...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1069 visitor->trace(m_timeline); | 1077 visitor->trace(m_timeline); |
| 1070 visitor->trace(m_pendingFinishedEvent); | 1078 visitor->trace(m_pendingFinishedEvent); |
| 1071 visitor->trace(m_pendingCancelledEvent); | 1079 visitor->trace(m_pendingCancelledEvent); |
| 1072 visitor->trace(m_finishedPromise); | 1080 visitor->trace(m_finishedPromise); |
| 1073 visitor->trace(m_readyPromise); | 1081 visitor->trace(m_readyPromise); |
| 1074 RefCountedGarbageCollectedEventTargetWithInlineData<Animation>::trace(visito
r); | 1082 RefCountedGarbageCollectedEventTargetWithInlineData<Animation>::trace(visito
r); |
| 1075 ActiveDOMObject::trace(visitor); | 1083 ActiveDOMObject::trace(visitor); |
| 1076 } | 1084 } |
| 1077 | 1085 |
| 1078 } // namespace blink | 1086 } // namespace blink |
| OLD | NEW |