Changeset 217997 in webkit
- Timestamp:
- Jun 9, 2017 10:52:42 AM (7 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r217985 r217997 1 2017-06-09 Chris Dumez <cdumez@apple.com> 2 3 CSS transitions added while page is not visible do not start when the page becomes visible 4 https://bugs.webkit.org/show_bug.cgi?id=173166 5 <rdar://problem/32250351> 6 7 Reviewed by Darin Adler. 8 9 Add layout test coverage. 10 11 * fast/animation/css-animation-resuming-when-visible-expected.txt: Added. 12 * fast/animation/css-animation-resuming-when-visible.html: Added. 13 1 14 2017-06-09 Eric Carlson <eric.carlson@apple.com> 2 15 -
trunk/Source/WebCore/ChangeLog
r217994 r217997 1 2017-06-09 Chris Dumez <cdumez@apple.com> 2 3 CSS transitions added while page is not visible do not start when the page becomes visible 4 https://bugs.webkit.org/show_bug.cgi?id=173166 5 <rdar://problem/32250351> 6 7 Reviewed by Darin Adler. 8 9 CSS transitions added while page is not visible would not start when the page becomes 10 visible. The issue was that when CompositeAnimation::updateTransitions() was called 11 while the page is hidden (and animations are therefore suspended), it would not 12 populate m_transations with ImplicitAnimation objects. We would therefore have later 13 no transitions to resume when the page becomes visible later on. This patch updates 14 CompositeAnimation::updateTransitions() to properly populate m_transitions and instead 15 pause the ImplicitAnimation it creates if animations are currently suspended. This 16 behavior is more consistent with the one of CompositeAnimation::updateKeyframeAnimations(). 17 18 I also needed to update ImplicitAnimation::animate() to not restart a paused animation 19 if the animation is currently paused. This is similar to what is done in 20 KeyframeAnimation::animate(). Without this, the paused ImplicitAnimation we add to 21 m_transition would incorrectly get unpaused while the page is still hidden and the 22 animations are still supposed to be suspended. This issue was showing when running the 23 test I am adding in this patch. 24 25 Test: fast/animation/css-animation-resuming-when-visible.html 26 27 * page/animation/CompositeAnimation.cpp: 28 (WebCore::CompositeAnimation::updateTransitions): 29 * page/animation/ImplicitAnimation.cpp: 30 (WebCore::ImplicitAnimation::animate): 31 (WebCore::ImplicitAnimation::reset): 32 * page/animation/ImplicitAnimation.h: 33 1 34 2017-06-09 Yusuke Suzuki <utatane.tea@gmail.com> 2 35 -
trunk/Source/WebCore/page/animation/AnimationBase.h
r215352 r217997 135 135 136 136 // Returns true if the animation state changed. 137 virtual bool animate(CompositeAnimation *, RenderElement*, const RenderStyle* /*currentStyle*/, const RenderStyle*/*targetStyle*/, std::unique_ptr<RenderStyle>& /*animatedStyle*/, bool& didBlendStyle) = 0;137 virtual bool animate(CompositeAnimation&, RenderElement*, const RenderStyle* /*currentStyle*/, const RenderStyle& /*targetStyle*/, std::unique_ptr<RenderStyle>& /*animatedStyle*/, bool& didBlendStyle) = 0; 138 138 virtual void getAnimatedStyle(std::unique_ptr<RenderStyle>& /*animatedStyle*/) = 0; 139 139 -
trunk/Source/WebCore/page/animation/CompositeAnimation.cpp
r217075 r217997 95 95 for (size_t i = 0; i < targetStyle->transitions()->size(); ++i) { 96 96 auto& animation = targetStyle->transitions()->animation(i); 97 bool isActiveTransition = !m_suspended && (animation.duration() || animation.delay() > 0);97 bool isActiveTransition = animation.duration() || animation.delay() > 0; 98 98 99 99 Animation::AnimationMode mode = animation.animationMode(); … … 170 170 // Add the new transition 171 171 auto implicitAnimation = ImplicitAnimation::create(animation, prop, renderer, this, modifiedCurrentStyle ? modifiedCurrentStyle.get() : fromStyle); 172 if (m_suspended && implicitAnimation->hasStyle()) 173 implicitAnimation->updatePlayState(AnimPlayStatePaused); 174 172 175 LOG(Animations, "Created ImplicitAnimation %p on renderer %p for property %s duration %.2f delay %.2f", implicitAnimation.ptr(), renderer, getPropertyName(prop), animation.duration(), animation.delay()); 173 176 m_transitions.set(prop, WTFMove(implicitAnimation)); … … 301 304 for (auto& transition : m_transitions.values()) { 302 305 bool didBlendStyle = false; 303 if (transition->animate( this, &renderer, currentStyle, &targetStyle, blendedStyle, didBlendStyle))306 if (transition->animate(*this, &renderer, currentStyle, targetStyle, blendedStyle, didBlendStyle)) 304 307 animationStateChanged = true; 305 308 … … 331 334 if (keyframeAnim) { 332 335 bool didBlendStyle = false; 333 if (keyframeAnim->animate( this, &renderer, currentStyle, &targetStyle, blendedStyle, didBlendStyle))336 if (keyframeAnim->animate(*this, &renderer, currentStyle, targetStyle, blendedStyle, didBlendStyle)) 334 337 animationStateChanged = true; 335 338 -
trunk/Source/WebCore/page/animation/ImplicitAnimation.cpp
r215143 r217997 62 62 } 63 63 64 bool ImplicitAnimation::animate(CompositeAnimation *, RenderElement*, const RenderStyle*, const RenderStyle*targetStyle, std::unique_ptr<RenderStyle>& animatedStyle, bool& didBlendStyle)64 bool ImplicitAnimation::animate(CompositeAnimation& compositeAnimation, RenderElement*, const RenderStyle*, const RenderStyle& targetStyle, std::unique_ptr<RenderStyle>& animatedStyle, bool& didBlendStyle) 65 65 { 66 66 // If we get this far and the animation is done, it means we are cleaning up a just finished animation. … … 73 73 // Reset to start the transition if we are new 74 74 if (isNew()) 75 reset(targetStyle );75 reset(targetStyle, compositeAnimation); 76 76 77 77 // Run a cycle of animation. 78 78 // We know we will need a new render style, so make one if needed 79 79 if (!animatedStyle) 80 animatedStyle = RenderStyle::clonePtr( *targetStyle);80 animatedStyle = RenderStyle::clonePtr(targetStyle); 81 81 82 82 CSSPropertyAnimation::blendProperties(this, m_animatingProperty, animatedStyle.get(), m_fromStyle.get(), m_toStyle.get(), progress()); … … 200 200 } 201 201 202 void ImplicitAnimation::reset(const RenderStyle* to) 203 { 204 ASSERT(to); 202 void ImplicitAnimation::reset(const RenderStyle& to, CompositeAnimation& compositeAnimation) 203 { 205 204 ASSERT(m_fromStyle); 206 205 207 m_toStyle = RenderStyle::clonePtr( *to);206 m_toStyle = RenderStyle::clonePtr(to); 208 207 209 208 if (m_object && m_object->element()) … … 212 211 // Restart the transition 213 212 if (m_fromStyle && m_toStyle) 214 updateStateMachine( AnimationStateInput::RestartAnimation, -1);213 updateStateMachine(compositeAnimation.isSuspended() ? AnimationStateInput::PlayStatePaused : AnimationStateInput::RestartAnimation, -1); 215 214 216 215 // set the transform animation list -
trunk/Source/WebCore/page/animation/ImplicitAnimation.h
r215143 r217997 54 54 void endAnimation() override; 55 55 56 bool animate(CompositeAnimation *, RenderElement*, const RenderStyle* currentStyle, const RenderStyle*targetStyle, std::unique_ptr<RenderStyle>& animatedStyle, bool& didBlendStyle) override;56 bool animate(CompositeAnimation&, RenderElement*, const RenderStyle* currentStyle, const RenderStyle& targetStyle, std::unique_ptr<RenderStyle>& animatedStyle, bool& didBlendStyle) override; 57 57 void getAnimatedStyle(std::unique_ptr<RenderStyle>& animatedStyle) override; 58 void reset(const RenderStyle * to);58 void reset(const RenderStyle& to, CompositeAnimation&); 59 59 60 60 bool computeExtentOfTransformAnimation(LayoutRect&) const override; -
trunk/Source/WebCore/page/animation/KeyframeAnimation.cpp
r217075 r217997 155 155 } 156 156 157 bool KeyframeAnimation::animate(CompositeAnimation * compositeAnimation, RenderElement*, const RenderStyle*, const RenderStyle*targetStyle, std::unique_ptr<RenderStyle>& animatedStyle, bool& didBlendStyle)157 bool KeyframeAnimation::animate(CompositeAnimation& compositeAnimation, RenderElement*, const RenderStyle*, const RenderStyle& targetStyle, std::unique_ptr<RenderStyle>& animatedStyle, bool& didBlendStyle) 158 158 { 159 159 // Fire the start timeout if needed … … 162 162 // If we have not yet started, we will not have a valid start time, so just start the animation if needed. 163 163 if (isNew()) { 164 if (m_animation->playState() == AnimPlayStatePlaying && !compositeAnimation ->isSuspended())164 if (m_animation->playState() == AnimPlayStatePlaying && !compositeAnimation.isSuspended()) 165 165 updateStateMachine(AnimationStateInput::StartAnimation, -1); 166 166 else if (m_animation->playState() == AnimPlayStatePaused) … … 172 172 if (postActive()) { 173 173 if (!animatedStyle) 174 animatedStyle = RenderStyle::clonePtr( *targetStyle);174 animatedStyle = RenderStyle::clonePtr(targetStyle); 175 175 return false; 176 176 } … … 196 196 // We know we will need a new render style, so make one if needed. 197 197 if (!animatedStyle) 198 animatedStyle = RenderStyle::clonePtr( *targetStyle);198 animatedStyle = RenderStyle::clonePtr(targetStyle); 199 199 200 200 // FIXME: we need to be more efficient about determining which keyframes we are animating between. -
trunk/Source/WebCore/page/animation/KeyframeAnimation.h
r217075 r217997 45 45 } 46 46 47 bool animate(CompositeAnimation *, RenderElement*, const RenderStyle* currentStyle, const RenderStyle*targetStyle, std::unique_ptr<RenderStyle>& animatedStyle, bool& didBlendStyle) override;47 bool animate(CompositeAnimation&, RenderElement*, const RenderStyle* currentStyle, const RenderStyle& targetStyle, std::unique_ptr<RenderStyle>& animatedStyle, bool& didBlendStyle) override; 48 48 void getAnimatedStyle(std::unique_ptr<RenderStyle>&) override; 49 49
Note: See TracChangeset
for help on using the changeset viewer.