| 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 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 298 if (m_currentTimePending) { | 298 if (m_currentTimePending) { |
| 299 m_startTime = 0; | 299 m_startTime = 0; |
| 300 m_currentTimePending = false; | 300 m_currentTimePending = false; |
| 301 } | 301 } |
| 302 | 302 |
| 303 setCurrentTimeInternal(newCurrentTime / 1000, TimingUpdateOnDemand); | 303 setCurrentTimeInternal(newCurrentTime / 1000, TimingUpdateOnDemand); |
| 304 } | 304 } |
| 305 | 305 |
| 306 void AnimationPlayer::setStartTime(double startTime) | 306 void AnimationPlayer::setStartTime(double startTime) |
| 307 { | 307 { |
| 308 if (m_paused) // FIXME: Should this throw an exception? | 308 if (m_paused || m_idle) |
| 309 return; | 309 return; |
| 310 if (!std::isfinite(startTime)) | 310 if (!std::isfinite(startTime)) |
| 311 return; | 311 return; |
| 312 if (startTime == m_startTime) | 312 if (startTime == m_startTime) |
| 313 return; | 313 return; |
| 314 | 314 |
| 315 setCompositorPending(); | 315 setCompositorPending(); |
| 316 m_currentTimePending = false; | 316 m_currentTimePending = false; |
| 317 setStartTimeInternal(startTime / 1000); | 317 setStartTimeInternal(startTime / 1000); |
| 318 } | 318 } |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 451 m_finished = false; | 451 m_finished = false; |
| 452 } | 452 } |
| 453 | 453 |
| 454 void AnimationPlayer::reverse() | 454 void AnimationPlayer::reverse() |
| 455 { | 455 { |
| 456 if (!m_playbackRate) { | 456 if (!m_playbackRate) { |
| 457 return; | 457 return; |
| 458 } | 458 } |
| 459 | 459 |
| 460 uncancel(); | 460 uncancel(); |
| 461 | |
| 462 if (m_content) { | |
| 463 if (m_playbackRate > 0 && currentTimeInternal() > sourceEnd()) { | |
| 464 setCurrentTimeInternal(sourceEnd(), TimingUpdateOnDemand); | |
| 465 ASSERT(finished()); | |
| 466 } else if (m_playbackRate < 0 && currentTimeInternal() < 0) { | |
| 467 setCurrentTimeInternal(0, TimingUpdateOnDemand); | |
| 468 ASSERT(finished()); | |
| 469 } | |
| 470 } | |
| 471 setPlaybackRate(-m_playbackRate); | 461 setPlaybackRate(-m_playbackRate); |
| 472 unpauseInternal(); | 462 play(); |
| 473 } | 463 } |
| 474 | 464 |
| 475 void AnimationPlayer::finish(ExceptionState& exceptionState) | 465 void AnimationPlayer::finish(ExceptionState& exceptionState) |
| 476 { | 466 { |
| 477 if (!m_playbackRate) { | 467 if (!m_playbackRate) { |
| 478 return; | 468 return; |
| 479 } | 469 } |
| 480 if (m_playbackRate > 0 && sourceEnd() == std::numeric_limits<double>::infini
ty()) { | 470 if (m_playbackRate > 0 && sourceEnd() == std::numeric_limits<double>::infini
ty()) { |
| 481 exceptionState.throwDOMException(InvalidStateError, "AnimationPlayer has
source content whose end time is infinity."); | 471 exceptionState.throwDOMException(InvalidStateError, "AnimationPlayer has
source content whose end time is infinity."); |
| 482 return; | 472 return; |
| 483 } | 473 } |
| 484 if (playing()) { | 474 if (playing()) { |
| 485 setCompositorPending(); | 475 setCompositorPending(); |
| 486 } | 476 } |
| 487 | 477 |
| 488 uncancel(); | 478 uncancel(); |
| 489 m_startTime = 0; | |
| 490 | 479 |
| 491 if (m_playbackRate < 0) { | 480 double newCurrentTime = m_playbackRate < 0 ? 0 : sourceEnd(); |
| 492 setCurrentTimeInternal(0, TimingUpdateOnDemand); | 481 setCurrentTimeInternal(newCurrentTime, TimingUpdateOnDemand); |
| 493 } else { | 482 if (!paused()) { |
| 494 setCurrentTimeInternal(sourceEnd(), TimingUpdateOnDemand); | 483 m_startTime = calculateStartTime(newCurrentTime); |
| 495 } | 484 } |
| 485 |
| 486 m_currentTimePending = false; |
| 496 ASSERT(finished()); | 487 ASSERT(finished()); |
| 497 } | 488 } |
| 498 | 489 |
| 499 const AtomicString& AnimationPlayer::interfaceName() const | 490 const AtomicString& AnimationPlayer::interfaceName() const |
| 500 { | 491 { |
| 501 return EventTargetNames::AnimationPlayer; | 492 return EventTargetNames::AnimationPlayer; |
| 502 } | 493 } |
| 503 | 494 |
| 504 ExecutionContext* AnimationPlayer::executionContext() const | 495 ExecutionContext* AnimationPlayer::executionContext() const |
| 505 { | 496 { |
| (...skipping 19 matching lines...) Expand all Loading... |
| 525 } | 516 } |
| 526 | 517 |
| 527 void AnimationPlayer::setPlaybackRate(double playbackRate) | 518 void AnimationPlayer::setPlaybackRate(double playbackRate) |
| 528 { | 519 { |
| 529 if (!std::isfinite(playbackRate)) | 520 if (!std::isfinite(playbackRate)) |
| 530 return; | 521 return; |
| 531 if (playbackRate == m_playbackRate) | 522 if (playbackRate == m_playbackRate) |
| 532 return; | 523 return; |
| 533 | 524 |
| 534 setCompositorPending(); | 525 setCompositorPending(); |
| 535 if (!finished() && !paused()) | 526 if (!finished() && !paused() && hasStartTime()) |
| 536 m_currentTimePending = true; | 527 m_currentTimePending = true; |
| 537 | 528 |
| 538 double storedCurrentTime = currentTimeInternal(); | 529 double storedCurrentTime = currentTimeInternal(); |
| 539 if ((m_playbackRate < 0 && playbackRate >= 0) || (m_playbackRate > 0 && play
backRate <= 0)) | 530 if ((m_playbackRate < 0 && playbackRate >= 0) || (m_playbackRate > 0 && play
backRate <= 0)) |
| 540 m_finished = false; | 531 m_finished = false; |
| 541 | 532 |
| 542 m_playbackRate = playbackRate; | 533 m_playbackRate = playbackRate; |
| 543 m_startTime = std::numeric_limits<double>::quiet_NaN(); | 534 m_startTime = std::numeric_limits<double>::quiet_NaN(); |
| 544 setCurrentTimeInternal(storedCurrentTime, TimingUpdateOnDemand); | 535 setCurrentTimeInternal(storedCurrentTime, TimingUpdateOnDemand); |
| 545 } | 536 } |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 642 return m_content->timeToForwardsEffectChange() / m_playbackRate; | 633 return m_content->timeToForwardsEffectChange() / m_playbackRate; |
| 643 return m_content->timeToReverseEffectChange() / -m_playbackRate; | 634 return m_content->timeToReverseEffectChange() / -m_playbackRate; |
| 644 } | 635 } |
| 645 | 636 |
| 646 void AnimationPlayer::cancel() | 637 void AnimationPlayer::cancel() |
| 647 { | 638 { |
| 648 m_holdTime = currentTimeInternal(); | 639 m_holdTime = currentTimeInternal(); |
| 649 m_held = true; | 640 m_held = true; |
| 650 m_idle = true; | 641 m_idle = true; |
| 651 m_startTime = nullValue(); | 642 m_startTime = nullValue(); |
| 643 m_currentTimePending = false; |
| 652 setCompositorPending(); | 644 setCompositorPending(); |
| 653 } | 645 } |
| 654 | 646 |
| 655 #if !ENABLE(OILPAN) | 647 #if !ENABLE(OILPAN) |
| 656 bool AnimationPlayer::canFree() const | 648 bool AnimationPlayer::canFree() const |
| 657 { | 649 { |
| 658 ASSERT(m_content); | 650 ASSERT(m_content); |
| 659 return hasOneRef() && m_content->isAnimation() && m_content->hasOneRef(); | 651 return hasOneRef() && m_content->isAnimation() && m_content->hasOneRef(); |
| 660 } | 652 } |
| 661 #endif | 653 #endif |
| (...skipping 17 matching lines...) Expand all Loading... |
| 679 | 671 |
| 680 void AnimationPlayer::trace(Visitor* visitor) | 672 void AnimationPlayer::trace(Visitor* visitor) |
| 681 { | 673 { |
| 682 visitor->trace(m_content); | 674 visitor->trace(m_content); |
| 683 visitor->trace(m_timeline); | 675 visitor->trace(m_timeline); |
| 684 visitor->trace(m_pendingFinishedEvent); | 676 visitor->trace(m_pendingFinishedEvent); |
| 685 EventTargetWithInlineData::trace(visitor); | 677 EventTargetWithInlineData::trace(visitor); |
| 686 } | 678 } |
| 687 | 679 |
| 688 } // namespace | 680 } // namespace |
| OLD | NEW |