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