Changeset 181655 in webkit
- Timestamp:
- Mar 17, 2015, 12:01:46 PM (11 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 11 edited
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/animations/trigger-container-scroll-simple-expected.txt (added)
-
LayoutTests/animations/trigger-container-scroll-simple.html (added)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/css/CSSComputedStyleDeclaration.cpp (modified) (1 diff)
-
Source/WebCore/page/FrameView.cpp (modified) (1 diff)
-
Source/WebCore/page/animation/AnimationBase.cpp (modified) (6 diffs)
-
Source/WebCore/page/animation/AnimationController.cpp (modified) (3 diffs)
-
Source/WebCore/page/animation/AnimationController.h (modified) (1 diff)
-
Source/WebCore/page/animation/AnimationControllerPrivate.h (modified) (1 diff)
-
Source/WebCore/page/animation/CompositeAnimation.cpp (modified) (4 diffs)
-
Source/WebCore/page/animation/CompositeAnimation.h (modified) (3 diffs)
-
Source/WebCore/platform/animation/Animation.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r181652 r181655 1 2015-03-17 Dean Jackson <dino@apple.com> 2 3 Implement Scroll Container Animation Triggers 4 https://bugs.webkit.org/show_bug.cgi?id=142732 5 6 Reviewed by Simon Fraser. 7 8 Test that checks if an animation only triggers when the page 9 is scrolled. 10 11 * animations/trigger-container-scroll-simple-expected.txt: Added. 12 * animations/trigger-container-scroll-simple.html: Added. 13 1 14 2015-03-17 Brent Fulgham <bfulgham@apple.com> 2 15 -
trunk/Source/WebCore/ChangeLog
r181654 r181655 1 2015-03-17 Dean Jackson <dino@apple.com> 2 3 Implement Scroll Container Animation Triggers 4 https://bugs.webkit.org/show_bug.cgi?id=142732 5 6 Reviewed by Simon Fraser. 7 8 Test: animations/trigger-container-scroll-simple.html 9 10 Basic implementation of container-scroll. It only checks 11 the page scroll position for trigger values (not the scrolling 12 container in an overflow). 13 14 * css/CSSComputedStyleDeclaration.cpp: Add CSSPropertyWebkitAnimationTrigger 15 so that this property will appear in the inspector. 16 17 * page/FrameView.cpp: 18 (WebCore::FrameView::sendScrollEvent): If the page has scrolled, let the animation 19 controller know about it. 20 21 * page/animation/AnimationBase.cpp: 22 (WebCore::AnimationBase::updateStateMachine): Whitespace fix. 23 (WebCore::AnimationBase::fireAnimationEventsIfNeeded): If there is a trigger, 24 and the scroll position is past it, then tell the state machine that 25 we should start. 26 (WebCore::AnimationBase::timeToNextService): Use the scroll position as 27 an input to the update timer if a trigger is involved. 28 29 * page/animation/AnimationController.cpp: 30 (WebCore::AnimationControllerPrivate::ensureCompositeAnimation): Add whitespace. 31 (WebCore::AnimationControllerPrivate::scrollWasUpdated): Call updateAnimations. 32 (WebCore::AnimationController::scrollWasUpdated): Call into AnimationControllerPrivate. 33 * page/animation/AnimationController.h: 34 * page/animation/AnimationControllerPrivate.h: 35 36 * page/animation/CompositeAnimation.cpp: Keep a record of whether we have a scroll 37 triggered animation. 38 (WebCore::CompositeAnimation::CompositeAnimation): 39 (WebCore::CompositeAnimation::updateKeyframeAnimations): 40 * page/animation/CompositeAnimation.h: 41 (WebCore::CompositeAnimation::hasScrollTriggeredAnimation): 42 * platform/animation/Animation.cpp: 43 (WebCore::Animation::operator=): 44 1 45 2015-03-17 Simon Fraser <simon.fraser@apple.com> 2 46 -
trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp
r181602 r181655 246 246 CSSPropertyWebkitAnimationPlayState, 247 247 CSSPropertyWebkitAnimationTimingFunction, 248 CSSPropertyWebkitAnimationTrigger, 248 249 CSSPropertyWebkitAppearance, 249 250 CSSPropertyWebkitBackfaceVisibility, -
trunk/Source/WebCore/page/FrameView.cpp
r181617 r181655 4375 4375 frame().eventHandler().sendScrollEvent(); 4376 4376 frame().eventHandler().dispatchFakeMouseMoveEventSoon(); 4377 #if ENABLE(CSS_ANIMATIONS_LEVEL_2) 4378 frame().animation().scrollWasUpdated(); 4379 #endif 4377 4380 } 4378 4381 -
trunk/Source/WebCore/page/animation/AnimationBase.cpp
r181515 r181655 41 41 #include "RenderBox.h" 42 42 #include "RenderStyle.h" 43 #include "RenderView.h" 43 44 #include "UnitBezier.h" 44 45 #include <algorithm> … … 199 200 case AnimationState::New: 200 201 ASSERT(input == AnimationStateInput::StartAnimation || input == AnimationStateInput::PlayStateRunning || input == AnimationStateInput::PlayStatePaused); 202 201 203 if (input == AnimationStateInput::StartAnimation || input == AnimationStateInput::PlayStateRunning) { 202 204 m_requestedStartTime = beginAnimationUpdateTime(); … … 458 460 // Check for start timeout 459 461 if (m_animationState == AnimationState::StartWaitTimer) { 462 #if ENABLE(CSS_ANIMATIONS_LEVEL_2) 463 if (m_animation->trigger() && m_animation->trigger()->isScrollAnimationTrigger()) { 464 if (m_object) { 465 LayoutSize offset = m_object->view().frameView().scrollOffsetForFixedPosition(); 466 ScrollAnimationTrigger* scrollTrigger = static_cast<ScrollAnimationTrigger*>(m_animation->trigger().get()); 467 if (offset.height().toFloat() > scrollTrigger->startValue().value()) 468 updateStateMachine(AnimationStateInput::StartTimerFired, 0); 469 } 470 471 return; 472 } 473 #endif 460 474 if (beginAnimationUpdateTime() - m_requestedStartTime >= m_animation->delay()) 461 475 updateStateMachine(AnimationStateInput::StartTimerFired, 0); … … 464 478 465 479 double elapsedDuration = beginAnimationUpdateTime() - m_startTime; 480 #if ENABLE(CSS_ANIMATIONS_LEVEL_2) 481 if (m_animation->trigger() && m_animation->trigger()->isScrollAnimationTrigger()) 482 elapsedDuration = getElapsedTime(); 483 #endif 484 466 485 // FIXME: we need to ensure that elapsedDuration is never < 0. If it is, this suggests that 467 486 // we had a recalcStyle() outside of beginAnimationUpdate()/endAnimationUpdate(). … … 522 541 523 542 if (m_animationState == AnimationState::StartWaitTimer) { 543 #if ENABLE(CSS_ANIMATIONS_LEVEL_2) 544 if (m_animation->trigger()->isScrollAnimationTrigger()) { 545 if (m_object) { 546 float currentScrollOffset = m_object->view().frameView().scrollOffsetForFixedPosition().height().toFloat(); 547 ScrollAnimationTrigger* scrollTrigger = static_cast<ScrollAnimationTrigger*>(m_animation->trigger().get()); 548 if (currentScrollOffset >= scrollTrigger->startValue().value() && (!scrollTrigger->hasEndValue() || currentScrollOffset <= scrollTrigger->endValue().value())) 549 return 0; 550 } 551 return -1; 552 } 553 #endif 524 554 double timeFromNow = m_animation->delay() - (beginAnimationUpdateTime() - m_requestedStartTime); 525 555 return std::max(timeFromNow, 0.0); … … 673 703 double AnimationBase::getElapsedTime() const 674 704 { 675 if (paused()) 705 if (paused()) 676 706 return m_pauseTime - m_startTime; 677 707 if (m_startTime <= 0) -
trunk/Source/WebCore/page/animation/AnimationController.cpp
r181515 r181655 93 93 renderer.setIsCSSAnimating(true); 94 94 } 95 95 96 return *result.iterator->value; 96 97 } … … 515 516 } 516 517 518 #if ENABLE(CSS_ANIMATIONS_LEVEL_2) 519 void AnimationControllerPrivate::scrollWasUpdated() 520 { 521 updateAnimations(CallSetChanged); 522 } 523 #endif 524 517 525 AnimationController::AnimationController(Frame& frame) 518 526 : m_data(std::make_unique<AnimationControllerPrivate>(frame)) … … 701 709 } 702 710 711 #if ENABLE(CSS_ANIMATIONS_LEVEL_2) 712 void AnimationController::scrollWasUpdated() 713 { 714 m_data->scrollWasUpdated(); 715 } 716 #endif 717 703 718 } // namespace WebCore -
trunk/Source/WebCore/page/animation/AnimationController.h
r181515 r181655 87 87 static bool supportsAcceleratedAnimationOfProperty(CSSPropertyID); 88 88 89 #if ENABLE(CSS_ANIMATIONS_LEVEL_2) 90 void scrollWasUpdated(); 91 #endif 92 89 93 private: 90 94 const std::unique_ptr<AnimationControllerPrivate> m_data; -
trunk/Source/WebCore/page/animation/AnimationControllerPrivate.h
r181515 r181655 118 118 void setAllowsNewAnimationsWhileSuspended(bool); 119 119 120 #if ENABLE(CSS_ANIMATIONS_LEVEL_2) 121 void scrollWasUpdated(); 122 #endif 123 120 124 private: 121 125 void animationTimerFired(); -
trunk/Source/WebCore/page/animation/CompositeAnimation.cpp
r181515 r181655 44 44 CompositeAnimation::CompositeAnimation(AnimationControllerPrivate* animationController) 45 45 : m_animationController(animationController) 46 #if ENABLE(CSS_ANIMATIONS_LEVEL_2) 47 , m_hasScrollTriggeredAnimation(false) 48 #endif 46 49 { 47 50 m_suspended = animationController->isSuspended() && !animationController->allowsNewAnimationsWhileSuspended(); … … 223 226 for (AnimationNameMap::const_iterator it = m_keyframeAnimations.begin(); it != kfend; ++it) 224 227 it->value->setIndex(-1); 225 228 229 #if ENABLE(CSS_ANIMATIONS_LEVEL_2) 230 m_hasScrollTriggeredAnimation = false; 231 #endif 232 226 233 // Toss the animation order map. 227 234 m_keyframeAnimationOrderMap.clear(); … … 246 253 if (keyframeAnim->postActive()) 247 254 continue; 248 255 256 #if ENABLE(CSS_ANIMATIONS_LEVEL_2) 257 if (animation.trigger()->isScrollAnimationTrigger()) 258 m_hasScrollTriggeredAnimation = true; 259 #endif 260 249 261 // This one is still active. 250 262 … … 266 278 LOG(Animations, " property %s", getPropertyName(*it)); 267 279 #endif 280 281 #if ENABLE(CSS_ANIMATIONS_LEVEL_2) 282 if (animation.trigger()->isScrollAnimationTrigger()) 283 m_hasScrollTriggeredAnimation = true; 284 #endif 285 268 286 m_keyframeAnimations.set(keyframeAnim->name().impl(), keyframeAnim); 269 287 } -
trunk/Source/WebCore/page/animation/CompositeAnimation.h
r181515 r181655 81 81 unsigned numberOfActiveAnimations() const; 82 82 83 #if ENABLE(CSS_ANIMATIONS_LEVEL_2) 84 bool hasScrollTriggeredAnimation() const { return m_hasScrollTriggeredAnimation; } 85 #endif 86 83 87 private: 84 88 CompositeAnimation(AnimationControllerPrivate*); … … 88 92 89 93 typedef HashMap<int, RefPtr<ImplicitAnimation>> CSSPropertyTransitionsMap; 90 typedef HashMap<AtomicStringImpl*, RefPtr<KeyframeAnimation>> AnimationNameMap;94 typedef HashMap<AtomicStringImpl*, RefPtr<KeyframeAnimation>> AnimationNameMap; 91 95 92 96 AnimationControllerPrivate* m_animationController; … … 95 99 Vector<AtomicStringImpl*> m_keyframeAnimationOrderMap; 96 100 bool m_suspended; 101 #if ENABLE(CSS_ANIMATIONS_LEVEL_2) 102 bool m_hasScrollTriggeredAnimation; 103 #endif 97 104 }; 98 105 -
trunk/Source/WebCore/platform/animation/Animation.cpp
r181602 r181655 95 95 m_duration = o.m_duration; 96 96 m_timingFunction = o.m_timingFunction; 97 #if ENABLE(CSS_ANIMATIONS_LEVEL_2) 98 m_trigger = o.m_trigger; 99 #endif 97 100 m_direction = o.m_direction; 98 101 m_fillMode = o.m_fillMode;
Note:
See TracChangeset
for help on using the changeset viewer.