Changeset 221916 in webkit
- Timestamp:
- Sep 12, 2017 8:31:41 AM (7 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r221915 r221916 1 2017-09-12 Antti Koivisto <antti@apple.com> 2 3 Remove RenderElement::isCSSAnimating boolean 4 https://bugs.webkit.org/show_bug.cgi?id=176779 5 6 Reviewed by Andreas Kling. 7 8 This optimization can be replaced with a simple style test that doesn't require keeping 9 two sources of truth in sync. 10 11 * page/animation/CSSAnimationController.cpp: 12 (WebCore::CSSAnimationControllerPrivate::ensureCompositeAnimation): 13 (WebCore::CSSAnimationControllerPrivate::clear): 14 15 Can't test here as style might have become non-animating and we don't clear animation when that happens. 16 This is only called on renderer destruction so it is not an important optimization. 17 18 (WebCore::CSSAnimationControllerPrivate::isRunningAnimationOnRenderer const): 19 (WebCore::CSSAnimationControllerPrivate::isRunningAcceleratedAnimationOnRenderer const): 20 (WebCore::CSSAnimationControllerPrivate::getAnimatedStyleForRenderer): 21 (WebCore::CSSAnimationControllerPrivate::computeExtentOfAnimation const): 22 (WebCore::CSSAnimationController::cancelAnimations): 23 (WebCore::CSSAnimationController::getAnimatedStyleForRenderer): 24 (WebCore::CSSAnimationController::computeExtentOfAnimation const): 25 (WebCore::CSSAnimationController::isRunningAnimationOnRenderer const): 26 (WebCore::CSSAnimationController::isRunningAcceleratedAnimationOnRenderer const): 27 28 Test if the style has any animations. This is roughly equivalent of the old test. 29 (it is actually somewhat better as the boolean was never cleared on style changes) 30 31 * rendering/RenderElement.cpp: 32 (WebCore::RenderElement::RenderElement): 33 * rendering/RenderElement.h: 34 (WebCore::RenderElement::isCSSAnimating const): Deleted. 35 (WebCore::RenderElement::setIsCSSAnimating): Deleted. 36 * rendering/style/RenderStyle.h: 37 (WebCore::RenderStyle::hasAnimationsOrTransitions const): 38 1 39 2017-09-12 Ms2ger <Ms2ger@igalia.com> 2 40 -
trunk/Source/WebCore/page/animation/CSSAnimationController.cpp
r217075 r221916 86 86 CompositeAnimation& CSSAnimationControllerPrivate::ensureCompositeAnimation(RenderElement& renderer) 87 87 { 88 auto result = m_compositeAnimations.add(&renderer, nullptr); 89 if (result.isNewEntry) { 90 result.iterator->value = CompositeAnimation::create(*this); 91 renderer.setIsCSSAnimating(true); 92 } 88 auto result = m_compositeAnimations.ensure(&renderer, [&] { 89 return CompositeAnimation::create(*this); 90 }); 93 91 94 92 if (animationsAreSuspendedForDocument(&renderer.document())) … … 100 98 bool CSSAnimationControllerPrivate::clear(RenderElement& renderer) 101 99 { 100 auto it = m_compositeAnimations.find(&renderer); 101 if (it == m_compositeAnimations.end()) 102 return false; 103 102 104 LOG(Animations, "CSSAnimationControllerPrivate %p clear: %p", this, &renderer); 103 104 ASSERT(renderer.isCSSAnimating());105 ASSERT(m_compositeAnimations.contains(&renderer));106 105 107 106 Element* element = renderer.element(); … … 117 116 // Return false if we didn't do anything OR we are suspended (so we don't try to 118 117 // do a invalidateStyleForSubtree() when suspended). 119 RefPtr<CompositeAnimation> animation = m_compositeAnimations.take(&renderer); 120 ASSERT(animation); 121 renderer.setIsCSSAnimating(false); 122 animation->clearRenderer(); 123 return animation->isSuspended(); 118 // FIXME: The code below does the opposite of what the comment above says regarding suspended state. 119 auto& animation = *it->value; 120 bool result = animation.isSuspended(); 121 animation.clearRenderer(); 122 123 m_compositeAnimations.remove(it); 124 125 return result; 124 126 } 125 127 … … 288 290 bool CSSAnimationControllerPrivate::isRunningAnimationOnRenderer(RenderElement& renderer, CSSPropertyID property, AnimationBase::RunningState runningState) const 289 291 { 290 ASSERT(renderer.isCSSAnimating());291 ASSERT(m_compositeAnimations.contains(&renderer));292 const CompositeAnimation& animation = *m_compositeAnimations.get(&renderer);293 return animation .isAnimatingProperty(property, false, runningState);292 auto* animation = m_compositeAnimations.get(&renderer); 293 if (!animation) 294 return false; 295 return animation->isAnimatingProperty(property, false, runningState); 294 296 } 295 297 296 298 bool CSSAnimationControllerPrivate::isRunningAcceleratedAnimationOnRenderer(RenderElement& renderer, CSSPropertyID property, AnimationBase::RunningState runningState) const 297 299 { 298 ASSERT(renderer.isCSSAnimating());299 ASSERT(m_compositeAnimations.contains(&renderer));300 const CompositeAnimation& animation = *m_compositeAnimations.get(&renderer);301 return animation .isAnimatingProperty(property, true, runningState);300 auto* animation = m_compositeAnimations.get(&renderer); 301 if (!animation) 302 return false; 303 return animation->isAnimatingProperty(property, true, runningState); 302 304 } 303 305 … … 468 470 std::unique_ptr<RenderStyle> CSSAnimationControllerPrivate::getAnimatedStyleForRenderer(RenderElement& renderer) 469 471 { 472 auto* animation = m_compositeAnimations.get(&renderer); 473 if (!animation) 474 return RenderStyle::clonePtr(renderer.style()); 475 470 476 AnimationPrivateUpdateBlock animationUpdateBlock(*this); 471 477 472 ASSERT(renderer.isCSSAnimating()); 473 ASSERT(m_compositeAnimations.contains(&renderer)); 474 const CompositeAnimation& rendererAnimations = *m_compositeAnimations.get(&renderer); 475 std::unique_ptr<RenderStyle> animatingStyle = rendererAnimations.getAnimatedStyle(); 478 std::unique_ptr<RenderStyle> animatingStyle = animation->getAnimatedStyle(); 476 479 if (!animatingStyle) 477 480 animatingStyle = RenderStyle::clonePtr(renderer.style()); … … 482 485 bool CSSAnimationControllerPrivate::computeExtentOfAnimation(RenderElement& renderer, LayoutRect& bounds) const 483 486 { 484 ASSERT(renderer.isCSSAnimating()); 485 ASSERT(m_compositeAnimations.contains(&renderer)); 486 487 const CompositeAnimation& rendererAnimations = *m_compositeAnimations.get(&renderer); 488 if (!rendererAnimations.isAnimatingProperty(CSSPropertyTransform, false, AnimationBase::Running | AnimationBase::Paused)) 487 auto* animation = m_compositeAnimations.get(&renderer); 488 if (!animation) 489 489 return true; 490 490 491 return rendererAnimations.computeExtentOfTransformAnimation(bounds); 491 if (!animation->isAnimatingProperty(CSSPropertyTransform, false, AnimationBase::Running | AnimationBase::Paused)) 492 return true; 493 494 return animation->computeExtentOfTransformAnimation(bounds); 492 495 } 493 496 … … 631 634 void CSSAnimationController::cancelAnimations(RenderElement& renderer) 632 635 { 633 if (!renderer.isCSSAnimating())634 return;635 636 636 if (!m_data->clear(renderer)) 637 637 return; … … 681 681 std::unique_ptr<RenderStyle> CSSAnimationController::getAnimatedStyleForRenderer(RenderElement& renderer) 682 682 { 683 if (!renderer. isCSSAnimating())683 if (!renderer.style().hasAnimationsOrTransitions()) 684 684 return RenderStyle::clonePtr(renderer.style()); 685 685 686 return m_data->getAnimatedStyleForRenderer(renderer); 686 687 } … … 688 689 bool CSSAnimationController::computeExtentOfAnimation(RenderElement& renderer, LayoutRect& bounds) const 689 690 { 690 if (!renderer. isCSSAnimating())691 if (!renderer.style().hasAnimationsOrTransitions()) 691 692 return true; 692 693 … … 722 723 bool CSSAnimationController::isRunningAnimationOnRenderer(RenderElement& renderer, CSSPropertyID property, AnimationBase::RunningState runningState) const 723 724 { 724 return renderer.isCSSAnimating() && m_data->isRunningAnimationOnRenderer(renderer, property, runningState); 725 if (!renderer.style().hasAnimationsOrTransitions()) 726 return false; 727 return m_data->isRunningAnimationOnRenderer(renderer, property, runningState); 725 728 } 726 729 727 730 bool CSSAnimationController::isRunningAcceleratedAnimationOnRenderer(RenderElement& renderer, CSSPropertyID property, AnimationBase::RunningState runningState) const 728 731 { 729 return renderer.isCSSAnimating() && m_data->isRunningAcceleratedAnimationOnRenderer(renderer, property, runningState); 732 if (!renderer.style().hasAnimationsOrTransitions()) 733 return false; 734 return m_data->isRunningAcceleratedAnimationOnRenderer(renderer, property, runningState); 730 735 } 731 736 -
trunk/Source/WebCore/rendering/RenderElement.cpp
r221147 r221916 108 108 , m_hasPausedImageAnimations(false) 109 109 , m_hasCounterNodeMap(false) 110 , m_isCSSAnimating(false)111 110 , m_hasContinuation(false) 112 111 , m_hasValidCachedFirstLineStyle(false) -
trunk/Source/WebCore/rendering/RenderElement.h
r219876 r221916 204 204 void setHasCounterNodeMap(bool f) { m_hasCounterNodeMap = f; } 205 205 206 bool isCSSAnimating() const { return m_isCSSAnimating; }207 void setIsCSSAnimating(bool b) { m_isCSSAnimating = b; }208 209 206 const RenderElement* enclosingRendererWithTextDecoration(TextDecoration, bool firstLine) const; 210 207 void drawLineForBoxSide(GraphicsContext&, const FloatRect&, BoxSide, Color, EBorderStyle, float adjacentWidth1, float adjacentWidth2, bool antialias = false) const; … … 339 336 unsigned m_hasPausedImageAnimations : 1; 340 337 unsigned m_hasCounterNodeMap : 1; 341 unsigned m_isCSSAnimating : 1;342 338 unsigned m_hasContinuation : 1; 343 339 mutable unsigned m_hasValidCachedFirstLineStyle : 1; -
trunk/Source/WebCore/rendering/style/RenderStyle.h
r221467 r221916 663 663 AnimationList* transitions() { return m_rareNonInheritedData->transitions.get(); } 664 664 665 bool hasAnimationsOrTransitions() const { return m_rareNonInheritedData->hasAnimationsOrTransitions(); }665 bool hasAnimationsOrTransitions() const { return hasAnimations() || hasTransitions(); } 666 666 667 667 AnimationList& ensureAnimations(); -
trunk/Source/WebCore/rendering/style/StyleRareNonInheritedData.h
r218793 r221916 93 93 bool hasOpacity() const { return opacity < 1; } 94 94 95 bool hasAnimationsOrTransitions() const { return animations || transitions; }96 97 95 float opacity; 98 96
Note: See TracChangeset
for help on using the changeset viewer.