Changeset 221980 in webkit
- Timestamp:
- Sep 13, 2017 11:20:12 AM (7 years ago)
- Location:
- trunk/Source
- Files:
-
- 19 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r221978 r221980 1 2017-09-13 Antti Koivisto <antti@apple.com> 2 3 Make more of the CSS animation system internals element based 4 https://bugs.webkit.org/show_bug.cgi?id=176832 5 6 Reviewed by Zalan Bujtas. 7 8 CSS animations animate element style. Continue moving away from renderers in the animation code. 9 10 Also do some general modernization. 11 12 * css/CSSComputedStyleDeclaration.cpp: 13 (WebCore::computeRenderStyleForProperty): 14 * page/animation/AnimationBase.cpp: 15 (WebCore::AnimationBase::AnimationBase): 16 * page/animation/AnimationBase.h: 17 * page/animation/CSSAnimationController.cpp: 18 (WebCore::CSSAnimationControllerPrivate::ensureCompositeAnimation): 19 (WebCore::CSSAnimationControllerPrivate::clear): 20 (WebCore::CSSAnimationControllerPrivate::updateAnimations): 21 (WebCore::CSSAnimationControllerPrivate::updateAnimationTimerForElement): 22 (WebCore::CSSAnimationControllerPrivate::isRunningAnimationOnRenderer const): 23 (WebCore::CSSAnimationControllerPrivate::isRunningAcceleratedAnimationOnRenderer const): 24 (WebCore::CSSAnimationControllerPrivate::pauseAnimationAtTime): 25 (WebCore::CSSAnimationControllerPrivate::pauseTransitionAtTime): 26 (WebCore::CSSAnimationControllerPrivate::animatedStyleForElement): 27 (WebCore::CSSAnimationControllerPrivate::computeExtentOfAnimation const): 28 (WebCore::CSSAnimationController::cancelAnimations): 29 (WebCore::CSSAnimationController::updateAnimations): 30 (WebCore::CSSAnimationController::animatedStyleForRenderer): 31 (WebCore::CSSAnimationController::computeExtentOfAnimation const): 32 (WebCore::CSSAnimationController::pauseAnimationAtTime): 33 (WebCore::CSSAnimationController::pauseTransitionAtTime): 34 (WebCore::CSSAnimationControllerPrivate::updateAnimationTimerForRenderer): Deleted. 35 (WebCore::CSSAnimationControllerPrivate::getAnimatedStyleForRenderer): Deleted. 36 (WebCore::CSSAnimationController::getAnimatedStyleForRenderer): Deleted. 37 * page/animation/CSSAnimationController.h: 38 * page/animation/CSSAnimationControllerPrivate.h: 39 * page/animation/CompositeAnimation.cpp: 40 (WebCore::CompositeAnimation::~CompositeAnimation): 41 (WebCore::CompositeAnimation::clearElement): 42 (WebCore::CompositeAnimation::updateTransitions): 43 (WebCore::CompositeAnimation::updateKeyframeAnimations): 44 (WebCore::CompositeAnimation::animate): 45 (WebCore::CompositeAnimation::clearRenderer): Deleted. 46 * page/animation/CompositeAnimation.h: 47 * page/animation/ImplicitAnimation.cpp: 48 (WebCore::ImplicitAnimation::ImplicitAnimation): 49 (WebCore::ImplicitAnimation::animate): 50 * page/animation/ImplicitAnimation.h: 51 (WebCore::ImplicitAnimation::create): 52 * page/animation/KeyframeAnimation.cpp: 53 (WebCore::KeyframeAnimation::KeyframeAnimation): 54 (WebCore::KeyframeAnimation::animate): 55 * page/animation/KeyframeAnimation.h: 56 * rendering/RenderElement.cpp: 57 (WebCore::RenderElement::willBeDestroyed): 58 * rendering/RenderLayer.cpp: 59 (WebCore::RenderLayer::currentTransform const): 60 * style/RenderTreeUpdater.cpp: 61 (WebCore::RenderTreeUpdater::createRenderer): 62 * style/StyleTreeResolver.cpp: 63 (WebCore::Style::TreeResolver::createAnimatedElementUpdate): 64 * testing/Internals.cpp: 65 (WebCore::Internals::pauseAnimationAtTimeOnElement): 66 (WebCore::Internals::pauseAnimationAtTimeOnPseudoElement): 67 (WebCore::Internals::pauseTransitionAtTimeOnElement): 68 (WebCore::Internals::pauseTransitionAtTimeOnPseudoElement): 69 1 70 2017-09-13 Daniel Bates <dabates@apple.com> 2 71 -
trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp
r221501 r221980 2478 2478 2479 2479 if (renderer && renderer->isComposited() && CSSAnimationController::supportsAcceleratedAnimationOfProperty(propertyID)) { 2480 ownedStyle = renderer->animation(). getAnimatedStyleForRenderer(*renderer);2480 ownedStyle = renderer->animation().animatedStyleForRenderer(*renderer); 2481 2481 if (pseudoElementSpecifier && !element.isPseudoElement()) { 2482 2482 // FIXME: This cached pseudo style will only exist if the animation has been run at least once. -
trunk/Source/WebCore/page/animation/AnimationBase.cpp
r221941 r221980 77 77 } 78 78 79 AnimationBase::AnimationBase(const Animation& animation, RenderElement* renderer, CompositeAnimation*compositeAnimation)80 : m_element( renderer->element())81 , m_compositeAnimation( compositeAnimation)79 AnimationBase::AnimationBase(const Animation& animation, Element& element, CompositeAnimation& compositeAnimation) 80 : m_element(&element) 81 , m_compositeAnimation(&compositeAnimation) 82 82 , m_animation(const_cast<Animation&>(animation)) 83 83 { 84 ASSERT(m_element);85 84 // Compute the total duration 86 85 if (m_animation->iterationCount() > 0) -
trunk/Source/WebCore/page/animation/AnimationBase.h
r221941 r221980 49 49 WTF_MAKE_FAST_ALLOCATED; 50 50 public: 51 AnimationBase(const Animation& transition, RenderElement*, CompositeAnimation*);51 AnimationBase(const Animation& transition, Element&, CompositeAnimation&); 52 52 virtual ~AnimationBase() { } 53 53 … … 135 135 double progress(double scale = 1, double offset = 0, const TimingFunction* = nullptr) const; 136 136 137 // Returns true if the animation state changed.138 virtual bool animate(CompositeAnimation&, RenderElement*, const RenderStyle* /*currentStyle*/, const RenderStyle& /*targetStyle*/, std::unique_ptr<RenderStyle>& /*animatedStyle*/, bool& didBlendStyle) = 0;139 137 virtual void getAnimatedStyle(std::unique_ptr<RenderStyle>& /*animatedStyle*/) = 0; 140 138 -
trunk/Source/WebCore/page/animation/CSSAnimationController.cpp
r221916 r221980 84 84 } 85 85 86 CompositeAnimation& CSSAnimationControllerPrivate::ensureCompositeAnimation( RenderElement& renderer)87 { 88 auto result = m_compositeAnimations.ensure(& renderer, [&] {86 CompositeAnimation& CSSAnimationControllerPrivate::ensureCompositeAnimation(Element& element) 87 { 88 auto result = m_compositeAnimations.ensure(&element, [&] { 89 89 return CompositeAnimation::create(*this); 90 90 }); 91 91 92 if (animationsAreSuspendedForDocument(& renderer.document()))92 if (animationsAreSuspendedForDocument(&element.document())) 93 93 result.iterator->value->suspendAnimations(); 94 94 … … 96 96 } 97 97 98 bool CSSAnimationControllerPrivate::clear( RenderElement& renderer)99 { 100 auto it = m_compositeAnimations.find(& renderer);98 bool CSSAnimationControllerPrivate::clear(Element& element) 99 { 100 auto it = m_compositeAnimations.find(&element); 101 101 if (it == m_compositeAnimations.end()) 102 102 return false; 103 103 104 LOG(Animations, "CSSAnimationControllerPrivate %p clear: %p", this, &renderer); 105 106 Element* element = renderer.element(); 107 108 m_eventsToDispatch.removeAllMatching([element] (const EventToDispatch& info) { 109 return info.element.ptr() == element; 104 LOG(Animations, "CSSAnimationControllerPrivate %p clear: %p", this, &element); 105 106 m_eventsToDispatch.removeAllMatching([&] (const EventToDispatch& info) { 107 return info.element.ptr() == &element; 110 108 }); 111 109 112 m_elementChangesToDispatch.removeAllMatching([ element](auto& currentElement) {113 return currentElement.ptr() == element;110 m_elementChangesToDispatch.removeAllMatching([&](auto& currentElement) { 111 return currentElement.ptr() == &element; 114 112 }); 115 113 … … 119 117 auto& animation = *it->value; 120 118 bool result = animation.isSuspended(); 121 animation.clear Renderer();119 animation.clearElement(); 122 120 123 121 m_compositeAnimations.remove(it); … … 141 139 if (callSetChanged != CallSetChanged) 142 140 break; 143 Element* element = compositeAnimation.key->element(); 144 ASSERT(element); 145 ASSERT(element->document().pageCacheState() == Document::NotInPageCache); 146 element->invalidateStyleAndLayerComposition(); 141 Element& element = *compositeAnimation.key; 142 ASSERT(element.document().pageCacheState() == Document::NotInPageCache); 143 element.invalidateStyleAndLayerComposition(); 147 144 calledSetChanged = true; 148 145 } … … 156 153 } 157 154 158 void CSSAnimationControllerPrivate::updateAnimationTimerFor Renderer(RenderElement& renderer)155 void CSSAnimationControllerPrivate::updateAnimationTimerForElement(Element& element) 159 156 { 160 157 std::optional<Seconds> timeToNextService; 161 158 162 const CompositeAnimation* compositeAnimation = m_compositeAnimations.get(& renderer);159 const CompositeAnimation* compositeAnimation = m_compositeAnimations.get(&element); 163 160 if (!compositeAnimation->isSuspended() && compositeAnimation->hasAnimations()) 164 161 timeToNextService = compositeAnimation->timeToNextService(); … … 290 287 bool CSSAnimationControllerPrivate::isRunningAnimationOnRenderer(RenderElement& renderer, CSSPropertyID property, AnimationBase::RunningState runningState) const 291 288 { 292 auto* animation = m_compositeAnimations.get(&renderer); 289 if (!renderer.element()) 290 return false; 291 auto* animation = m_compositeAnimations.get(renderer.element()); 293 292 if (!animation) 294 293 return false; … … 298 297 bool CSSAnimationControllerPrivate::isRunningAcceleratedAnimationOnRenderer(RenderElement& renderer, CSSPropertyID property, AnimationBase::RunningState runningState) const 299 298 { 300 auto* animation = m_compositeAnimations.get(&renderer); 299 if (!renderer.element()) 300 return false; 301 auto* animation = m_compositeAnimations.get(renderer.element()); 301 302 if (!animation) 302 303 return false; … … 403 404 } 404 405 405 bool CSSAnimationControllerPrivate::pauseAnimationAtTime(RenderElement* renderer, const AtomicString& name, double t) 406 { 407 if (!renderer) 408 return false; 409 410 CompositeAnimation& compositeAnimation = ensureCompositeAnimation(*renderer); 406 bool CSSAnimationControllerPrivate::pauseAnimationAtTime(Element& element, const AtomicString& name, double t) 407 { 408 CompositeAnimation& compositeAnimation = ensureCompositeAnimation(element); 411 409 if (compositeAnimation.pauseAnimationAtTime(name, t)) { 412 renderer->element()->invalidateStyleAndLayerComposition();410 element.invalidateStyleAndLayerComposition(); 413 411 startUpdateStyleIfNeededDispatcher(); 414 412 return true; … … 418 416 } 419 417 420 bool CSSAnimationControllerPrivate::pauseTransitionAtTime(RenderElement* renderer, const String& property, double t) 421 { 422 if (!renderer) 423 return false; 424 425 CompositeAnimation& compositeAnimation = ensureCompositeAnimation(*renderer); 418 bool CSSAnimationControllerPrivate::pauseTransitionAtTime(Element& element, const String& property, double t) 419 { 420 CompositeAnimation& compositeAnimation = ensureCompositeAnimation(element); 426 421 if (compositeAnimation.pauseTransitionAtTime(cssPropertyID(property), t)) { 427 renderer->element()->invalidateStyleAndLayerComposition();422 element.invalidateStyleAndLayerComposition(); 428 423 startUpdateStyleIfNeededDispatcher(); 429 424 return true; … … 468 463 } 469 464 470 std::unique_ptr<RenderStyle> CSSAnimationControllerPrivate:: getAnimatedStyleForRenderer(RenderElement& renderer)471 { 472 auto* animation = m_compositeAnimations.get(& renderer);465 std::unique_ptr<RenderStyle> CSSAnimationControllerPrivate::animatedStyleForElement(Element& element) 466 { 467 auto* animation = m_compositeAnimations.get(&element); 473 468 if (!animation) 474 return RenderStyle::clonePtr(renderer.style());469 return nullptr; 475 470 476 471 AnimationPrivateUpdateBlock animationUpdateBlock(*this); 477 472 478 std::unique_ptr<RenderStyle>animatingStyle = animation->getAnimatedStyle();473 auto animatingStyle = animation->getAnimatedStyle(); 479 474 if (!animatingStyle) 480 animatingStyle = RenderStyle::clonePtr(renderer.style());475 return nullptr; 481 476 482 477 return animatingStyle; 483 478 } 484 479 485 bool CSSAnimationControllerPrivate::computeExtentOfAnimation( RenderElement& renderer, LayoutRect& bounds) const486 { 487 auto* animation = m_compositeAnimations.get(& renderer);480 bool CSSAnimationControllerPrivate::computeExtentOfAnimation(Element& element, LayoutRect& bounds) const 481 { 482 auto* animation = m_compositeAnimations.get(&element); 488 483 if (!animation) 489 484 return true; … … 632 627 } 633 628 634 void CSSAnimationController::cancelAnimations( RenderElement& renderer)635 { 636 if (!m_data->clear( renderer))637 return; 638 639 Element* element = renderer.element();640 if (!element || element->document().renderTreeBeingDestroyed())641 return;642 ASSERT(element->document().pageCacheState() == Document::NotInPageCache);643 element->invalidateStyleAndLayerComposition(); 644 } 645 646 bool CSSAnimationController::updateAnimations(RenderElement& renderer, const RenderStyle& newStyle, std::unique_ptr<RenderStyle>& animatedStyle) 647 { 648 auto* oldStyle = renderer.hasInitializedStyle() ? &renderer.style() : nullptr;629 void CSSAnimationController::cancelAnimations(Element& element) 630 { 631 if (!m_data->clear(element)) 632 return; 633 634 if (element.document().renderTreeBeingDestroyed()) 635 return; 636 ASSERT(element.document().pageCacheState() == Document::NotInPageCache); 637 element.invalidateStyleAndLayerComposition(); 638 } 639 640 bool CSSAnimationController::updateAnimations(Element& element, const RenderStyle& newStyle, std::unique_ptr<RenderStyle>& animatedStyle) 641 { 642 auto* renderer = element.renderer(); 643 auto* oldStyle = (renderer && renderer->hasInitializedStyle()) ? &renderer->style() : nullptr; 649 644 if ((!oldStyle || (!oldStyle->animations() && !oldStyle->transitions())) && (!newStyle.animations() && !newStyle.transitions())) 650 645 return false; 651 646 652 if ( renderer.document().pageCacheState() != Document::NotInPageCache)647 if (element.document().pageCacheState() != Document::NotInPageCache) 653 648 return false; 654 649 655 650 // Don't run transitions when printing. 656 if ( renderer.view().printing())651 if (element.document().renderView()->printing()) 657 652 return false; 658 653 … … 662 657 // a new style. 663 658 664 // We don't support anonymous pseudo elements like :first-line or :first-letter. 665 ASSERT(renderer.element()); 666 667 CompositeAnimation& rendererAnimations = m_data->ensureCompositeAnimation(renderer); 668 bool animationStateChanged = rendererAnimations.animate(renderer, oldStyle, newStyle, animatedStyle); 669 670 if (renderer.parent() || newStyle.animations() || (oldStyle && oldStyle->animations())) { 671 auto& frameView = renderer.view().frameView(); 672 if (rendererAnimations.hasAnimationThatDependsOnLayout()) 659 CompositeAnimation& compositeAnimation = m_data->ensureCompositeAnimation(element); 660 bool animationStateChanged = compositeAnimation.animate(element, oldStyle, newStyle, animatedStyle); 661 662 if ((renderer && renderer->parent()) || newStyle.animations() || (oldStyle && oldStyle->animations())) { 663 auto& frameView = *element.document().view(); 664 if (compositeAnimation.hasAnimationThatDependsOnLayout()) 673 665 m_data->setRequiresLayout(); 674 m_data->updateAnimationTimerFor Renderer(renderer);666 m_data->updateAnimationTimerForElement(element); 675 667 frameView.scheduleAnimation(); 676 668 } … … 679 671 } 680 672 681 std::unique_ptr<RenderStyle> CSSAnimationController::getAnimatedStyleForRenderer(RenderElement& renderer) 682 { 683 if (!renderer.style().hasAnimationsOrTransitions()) 684 return RenderStyle::clonePtr(renderer.style()); 685 686 return m_data->getAnimatedStyleForRenderer(renderer); 673 std::unique_ptr<RenderStyle> CSSAnimationController::animatedStyleForRenderer(RenderElement& renderer) 674 { 675 std::unique_ptr<RenderStyle> result; 676 677 if (renderer.style().hasAnimationsOrTransitions() && renderer.element()) 678 result = m_data->animatedStyleForElement(*renderer.element()); 679 680 if (!result) 681 result = RenderStyle::clonePtr(renderer.style()); 682 683 return result; 687 684 } 688 685 689 686 bool CSSAnimationController::computeExtentOfAnimation(RenderElement& renderer, LayoutRect& bounds) const 690 687 { 688 if (!renderer.element()) 689 return true; 691 690 if (!renderer.style().hasAnimationsOrTransitions()) 692 691 return true; 693 692 694 return m_data->computeExtentOfAnimation( renderer, bounds);693 return m_data->computeExtentOfAnimation(*renderer.element(), bounds); 695 694 } 696 695 … … 704 703 } 705 704 706 bool CSSAnimationController::pauseAnimationAtTime( RenderElement* renderer, const AtomicString& name, double t)705 bool CSSAnimationController::pauseAnimationAtTime(Element& element, const AtomicString& name, double t) 707 706 { 708 707 AnimationUpdateBlock animationUpdateBlock(this); 709 return m_data->pauseAnimationAtTime( renderer, name, t);708 return m_data->pauseAnimationAtTime(element, name, t); 710 709 } 711 710 … … 715 714 } 716 715 717 bool CSSAnimationController::pauseTransitionAtTime( RenderElement* renderer, const String& property, double t)716 bool CSSAnimationController::pauseTransitionAtTime(Element& element, const String& property, double t) 718 717 { 719 718 AnimationUpdateBlock animationUpdateBlock(this); 720 return m_data->pauseTransitionAtTime( renderer, property, t);719 return m_data->pauseTransitionAtTime(element, property, t); 721 720 } 722 721 -
trunk/Source/WebCore/page/animation/CSSAnimationController.h
r213473 r221980 49 49 ~CSSAnimationController(); 50 50 51 void cancelAnimations( RenderElement&);52 bool updateAnimations( RenderElement&, const RenderStyle& newStyle, std::unique_ptr<RenderStyle>& animatedStyle);53 std::unique_ptr<RenderStyle> getAnimatedStyleForRenderer(RenderElement&);51 void cancelAnimations(Element&); 52 bool updateAnimations(Element&, const RenderStyle& newStyle, std::unique_ptr<RenderStyle>& animatedStyle); 53 std::unique_ptr<RenderStyle> animatedStyleForRenderer(RenderElement&); 54 54 55 55 // If possible, compute the visual extent of any transform animation on the given renderer … … 61 61 void notifyAnimationStarted(RenderElement&, double startTime); 62 62 63 WEBCORE_EXPORT bool pauseAnimationAtTime( RenderElement*, const AtomicString& name, double t); // To be used only for testing64 WEBCORE_EXPORT bool pauseTransitionAtTime( RenderElement*, const String& property, double t); // To be used only for testing63 WEBCORE_EXPORT bool pauseAnimationAtTime(Element&, const AtomicString& name, double t); // To be used only for testing 64 WEBCORE_EXPORT bool pauseTransitionAtTime(Element&, const String& property, double t); // To be used only for testing 65 65 WEBCORE_EXPORT unsigned numberOfActiveAnimations(Document*) const; // To be used only for testing 66 66 -
trunk/Source/WebCore/page/animation/CSSAnimationControllerPrivate.h
r217075 r221980 53 53 void updateAnimationTimer(SetChanged callSetChanged = DoNotCallSetChanged); 54 54 55 CompositeAnimation& ensureCompositeAnimation( RenderElement&);56 bool clear( RenderElement&);55 CompositeAnimation& ensureCompositeAnimation(Element&); 56 bool clear(Element&); 57 57 58 58 void updateStyleIfNeededDispatcherFired(); … … 80 80 bool isRunningAcceleratedAnimationOnRenderer(RenderElement&, CSSPropertyID, AnimationBase::RunningState) const; 81 81 82 bool pauseAnimationAtTime( RenderElement*, const AtomicString& name, double t);83 bool pauseTransitionAtTime( RenderElement*, const String& property, double t);82 bool pauseAnimationAtTime(Element&, const AtomicString& name, double t); 83 bool pauseTransitionAtTime(Element&, const String& property, double t); 84 84 unsigned numberOfActiveAnimations(Document*) const; 85 85 86 std::unique_ptr<RenderStyle> getAnimatedStyleForRenderer(RenderElement&);86 std::unique_ptr<RenderStyle> animatedStyleForElement(Element&); 87 87 88 bool computeExtentOfAnimation( RenderElement&, LayoutRect&) const;88 bool computeExtentOfAnimation(Element&, LayoutRect&) const; 89 89 90 90 double beginAnimationUpdateTime(); … … 102 102 void animationWillBeRemoved(AnimationBase*); 103 103 104 void updateAnimationTimerFor Renderer(RenderElement&);104 void updateAnimationTimerForElement(Element&); 105 105 106 106 bool allowsNewAnimationsWhileSuspended() const { return m_allowsNewAnimationsWhileSuspended; } … … 125 125 void startTimeResponse(double t); 126 126 127 HashMap< RenderElement*, RefPtr<CompositeAnimation>> m_compositeAnimations;127 HashMap<Element*, RefPtr<CompositeAnimation>> m_compositeAnimations; 128 128 Timer m_animationTimer; 129 129 Timer m_updateStyleIfNeededDispatcher; -
trunk/Source/WebCore/page/animation/CompositeAnimation.cpp
r217997 r221980 54 54 // any waiting lists first. 55 55 56 clear Renderer();56 clearElement(); 57 57 m_transitions.clear(); 58 58 m_keyframeAnimations.clear(); 59 59 } 60 60 61 void CompositeAnimation::clear Renderer()61 void CompositeAnimation::clearElement() 62 62 { 63 63 if (!m_transitions.isEmpty()) { … … 78 78 } 79 79 80 void CompositeAnimation::updateTransitions( RenderElement* renderer, const RenderStyle* currentStyle, const RenderStyle*targetStyle)80 void CompositeAnimation::updateTransitions(Element& element, const RenderStyle* currentStyle, const RenderStyle& targetStyle) 81 81 { 82 82 // If currentStyle is null or there are no old or new transitions, just skip it 83 if (!currentStyle || (!targetStyle ->transitions() && m_transitions.isEmpty()))83 if (!currentStyle || (!targetStyle.transitions() && m_transitions.isEmpty())) 84 84 return; 85 85 … … 92 92 93 93 // Check to see if we need to update the active transitions 94 if (targetStyle ->transitions()) {95 for (size_t i = 0; i < targetStyle ->transitions()->size(); ++i) {96 auto& animation = targetStyle ->transitions()->animation(i);94 if (targetStyle.transitions()) { 95 for (size_t i = 0; i < targetStyle.transitions()->size(); ++i) { 96 auto& animation = targetStyle.transitions()->animation(i); 97 97 bool isActiveTransition = animation.duration() || animation.delay() > 0; 98 98 … … 144 144 // list. In this case, the latter one overrides the earlier one, so we 145 145 // behave as though this is a running animation being replaced. 146 if (!implAnim->isTargetPropertyEqual(prop, targetStyle)) {146 if (!implAnim->isTargetPropertyEqual(prop, &targetStyle)) { 147 147 // For accelerated animations we need to return a new RenderStyle with the _current_ value 148 148 // of the property, so that restarted transitions use the correct starting point. … … 160 160 } else { 161 161 // We need to start a transition if it is active and the properties don't match 162 equal = !isActiveTransition || CSSPropertyAnimation::propertiesEqual(prop, fromStyle, targetStyle);162 equal = !isActiveTransition || CSSPropertyAnimation::propertiesEqual(prop, fromStyle, &targetStyle); 163 163 } 164 164 … … 169 169 if (!equal && isActiveTransition) { 170 170 // Add the new transition 171 auto implicitAnimation = ImplicitAnimation::create(animation, prop, renderer, this, modifiedCurrentStyle ? modifiedCurrentStyle.get() :fromStyle);171 auto implicitAnimation = ImplicitAnimation::create(animation, prop, element, *this, modifiedCurrentStyle ? *modifiedCurrentStyle : *fromStyle); 172 172 if (m_suspended && implicitAnimation->hasStyle()) 173 173 implicitAnimation->updatePlayState(AnimPlayStatePaused); 174 174 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());175 LOG(Animations, "Created ImplicitAnimation %p on element %p for property %s duration %.2f delay %.2f", implicitAnimation.ptr(), &element, getPropertyName(prop), animation.duration(), animation.delay()); 176 176 m_transitions.set(prop, WTFMove(implicitAnimation)); 177 177 } … … 190 190 animationController().animationWillBeRemoved(transition.get()); 191 191 toBeRemoved.append(transition->animatingProperty()); 192 LOG(Animations, "Removing ImplicitAnimation %p from renderer %p for property %s", transition.get(), renderer, getPropertyName(transition->animatingProperty()));192 LOG(Animations, "Removing ImplicitAnimation %p from element %p for property %s", transition.get(), &element, getPropertyName(transition->animatingProperty())); 193 193 } 194 194 } … … 199 199 } 200 200 201 void CompositeAnimation::updateKeyframeAnimations( RenderElement* renderer, const RenderStyle* currentStyle, const RenderStyle*targetStyle)201 void CompositeAnimation::updateKeyframeAnimations(Element& element, const RenderStyle* currentStyle, const RenderStyle& targetStyle) 202 202 { 203 203 // Nothing to do if we don't have any animations, and didn't have any before 204 if (m_keyframeAnimations.isEmpty() && !targetStyle ->hasAnimations())204 if (m_keyframeAnimations.isEmpty() && !targetStyle.hasAnimations()) 205 205 return; 206 206 207 207 m_keyframeAnimations.checkConsistency(); 208 208 209 if (currentStyle && currentStyle->hasAnimations() && targetStyle ->hasAnimations() && *(currentStyle->animations()) == *(targetStyle->animations()))209 if (currentStyle && currentStyle->hasAnimations() && targetStyle.hasAnimations() && *(currentStyle->animations()) == *(targetStyle.animations())) 210 210 return; 211 211 … … 222 222 223 223 // Now mark any still active animations as active and add any new animations. 224 if (targetStyle ->animations()) {225 int numAnims = targetStyle ->animations()->size();224 if (targetStyle.animations()) { 225 int numAnims = targetStyle.animations()->size(); 226 226 for (int i = 0; i < numAnims; ++i) { 227 auto& animation = targetStyle ->animations()->animation(i);227 auto& animation = targetStyle.animations()->animation(i); 228 228 AtomicString animationName(animation.name()); 229 229 … … 250 250 keyframeAnim->setAnimation(animation); 251 251 } else if ((animation.duration() || animation.delay()) && animation.iterationCount() && animationName != none) { 252 keyframeAnim = KeyframeAnimation::create(animation, renderer,this, targetStyle);253 LOG(Animations, "Creating KeyframeAnimation %p on renderer %p with keyframes %s, duration %.2f, delay %.2f, iterations %.2f", keyframeAnim.get(), renderer, animation.name().utf8().data(), animation.duration(), animation.delay(), animation.iterationCount());252 keyframeAnim = KeyframeAnimation::create(animation, element, *this, targetStyle); 253 LOG(Animations, "Creating KeyframeAnimation %p on element %p with keyframes %s, duration %.2f, delay %.2f, iterations %.2f", keyframeAnim.get(), &element, animation.name().utf8().data(), animation.duration(), animation.delay(), animation.iterationCount()); 254 254 255 255 if (m_suspended) { … … 281 281 animationController().animationWillBeRemoved(animation.get()); 282 282 animation->clear(); 283 LOG(Animations, "Removing KeyframeAnimation %p from renderer %p", animation.get(), renderer);283 LOG(Animations, "Removing KeyframeAnimation %p from element %p", animation.get(), &element); 284 284 } 285 285 } … … 288 288 } 289 289 290 bool CompositeAnimation::animate( RenderElement& renderer, const RenderStyle* currentStyle, const RenderStyle& targetStyle, std::unique_ptr<RenderStyle>& blendedStyle)290 bool CompositeAnimation::animate(Element& element, const RenderStyle* currentStyle, const RenderStyle& targetStyle, std::unique_ptr<RenderStyle>& blendedStyle) 291 291 { 292 292 // We don't do any transitions if we don't have a currentStyle (on startup). 293 updateTransitions( &renderer, currentStyle, &targetStyle);294 updateKeyframeAnimations( &renderer, currentStyle, &targetStyle);293 updateTransitions(element, currentStyle, targetStyle); 294 updateKeyframeAnimations(element, currentStyle, targetStyle); 295 295 m_keyframeAnimations.checkConsistency(); 296 296 … … 304 304 for (auto& transition : m_transitions.values()) { 305 305 bool didBlendStyle = false; 306 if (transition->animate(*this, &renderer, currentStyle,targetStyle, blendedStyle, didBlendStyle))306 if (transition->animate(*this, targetStyle, blendedStyle, didBlendStyle)) 307 307 animationStateChanged = true; 308 308 … … 334 334 if (keyframeAnim) { 335 335 bool didBlendStyle = false; 336 if (keyframeAnim->animate(*this, &renderer, currentStyle,targetStyle, blendedStyle, didBlendStyle))336 if (keyframeAnim->animate(*this, targetStyle, blendedStyle, didBlendStyle)) 337 337 animationStateChanged = true; 338 338 -
trunk/Source/WebCore/page/animation/CompositeAnimation.h
r218748 r221980 53 53 ~CompositeAnimation(); 54 54 55 void clear Renderer();55 void clearElement(); 56 56 57 bool animate( RenderElement&, const RenderStyle* currentStyle, const RenderStyle& targetStyle, std::unique_ptr<RenderStyle>& blendedStyle);57 bool animate(Element&, const RenderStyle* currentStyle, const RenderStyle& targetStyle, std::unique_ptr<RenderStyle>& blendedStyle); 58 58 std::unique_ptr<RenderStyle> getAnimatedStyle() const; 59 59 bool computeExtentOfTransformAnimation(LayoutRect&) const; … … 89 89 CompositeAnimation(CSSAnimationControllerPrivate&); 90 90 91 void updateTransitions( RenderElement*, const RenderStyle* currentStyle, const RenderStyle*targetStyle);92 void updateKeyframeAnimations( RenderElement*, const RenderStyle* currentStyle, const RenderStyle*targetStyle);91 void updateTransitions(Element&, const RenderStyle* currentStyle, const RenderStyle& targetStyle); 92 void updateKeyframeAnimations(Element&, const RenderStyle* currentStyle, const RenderStyle& targetStyle); 93 93 94 94 typedef HashMap<int, RefPtr<ImplicitAnimation>> CSSPropertyTransitionsMap; -
trunk/Source/WebCore/page/animation/ImplicitAnimation.cpp
r221941 r221980 41 41 namespace WebCore { 42 42 43 ImplicitAnimation::ImplicitAnimation(const Animation& transition, CSSPropertyID animatingProperty, RenderElement* renderer, CompositeAnimation* compAnim, const RenderStyle*fromStyle)44 : AnimationBase(transition, renderer, compAnim)45 , m_fromStyle(RenderStyle::clonePtr( *fromStyle))43 ImplicitAnimation::ImplicitAnimation(const Animation& transition, CSSPropertyID animatingProperty, Element& element, CompositeAnimation& compositeAnimation, const RenderStyle& fromStyle) 44 : AnimationBase(transition, element, compositeAnimation) 45 , m_fromStyle(RenderStyle::clonePtr(fromStyle)) 46 46 , m_transitionProperty(transition.property()) 47 47 , m_animatingProperty(animatingProperty) … … 62 62 } 63 63 64 bool ImplicitAnimation::animate(CompositeAnimation& compositeAnimation, RenderElement*, const RenderStyle*,const RenderStyle& targetStyle, std::unique_ptr<RenderStyle>& animatedStyle, bool& didBlendStyle)64 bool ImplicitAnimation::animate(CompositeAnimation& compositeAnimation, 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. -
trunk/Source/WebCore/page/animation/ImplicitAnimation.h
r217997 r221980 41 41 class ImplicitAnimation : public AnimationBase { 42 42 public: 43 static Ref<ImplicitAnimation> create(const Animation& animation, CSSPropertyID animatingProperty, RenderElement* renderer, CompositeAnimation* compositeAnimation, const RenderStyle*fromStyle)43 static Ref<ImplicitAnimation> create(const Animation& animation, CSSPropertyID animatingProperty, Element& element, CompositeAnimation& compositeAnimation, const RenderStyle& fromStyle) 44 44 { 45 return adoptRef(*new ImplicitAnimation(animation, animatingProperty, renderer, compositeAnimation, fromStyle));45 return adoptRef(*new ImplicitAnimation(animation, animatingProperty, element, compositeAnimation, fromStyle)); 46 46 }; 47 47 … … 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&, const RenderStyle& targetStyle, std::unique_ptr<RenderStyle>& animatedStyle, bool& didBlendStyle); 57 57 void getAnimatedStyle(std::unique_ptr<RenderStyle>& animatedStyle) override; 58 58 void reset(const RenderStyle& to, CompositeAnimation&); … … 87 87 88 88 private: 89 ImplicitAnimation(const Animation&, CSSPropertyID, RenderElement*, CompositeAnimation*, const RenderStyle*);89 ImplicitAnimation(const Animation&, CSSPropertyID, Element&, CompositeAnimation&, const RenderStyle&); 90 90 virtual ~ImplicitAnimation(); 91 91 -
trunk/Source/WebCore/page/animation/KeyframeAnimation.cpp
r221941 r221980 46 46 namespace WebCore { 47 47 48 KeyframeAnimation::KeyframeAnimation(const Animation& animation, RenderElement* renderer, CompositeAnimation* compositeAnimation, const RenderStyle*unanimatedStyle)49 : AnimationBase(animation, renderer, compositeAnimation)48 KeyframeAnimation::KeyframeAnimation(const Animation& animation, Element& element, CompositeAnimation& compositeAnimation, const RenderStyle& unanimatedStyle) 49 : AnimationBase(animation, element, compositeAnimation) 50 50 , m_keyframes(animation.name()) 51 , m_unanimatedStyle(RenderStyle::clonePtr( *unanimatedStyle))51 , m_unanimatedStyle(RenderStyle::clonePtr(unanimatedStyle)) 52 52 { 53 53 resolveKeyframeStyles(); … … 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, const RenderStyle& targetStyle, std::unique_ptr<RenderStyle>& animatedStyle, bool& didBlendStyle) 158 158 { 159 159 // Fire the start timeout if needed -
trunk/Source/WebCore/page/animation/KeyframeAnimation.h
r217997 r221980 40 40 class KeyframeAnimation final : public AnimationBase { 41 41 public: 42 static Ref<KeyframeAnimation> create(const Animation& animation, RenderElement* renderer, CompositeAnimation* compositeAnimation, const RenderStyle*unanimatedStyle)42 static Ref<KeyframeAnimation> create(const Animation& animation, Element& element, CompositeAnimation& compositeAnimation, const RenderStyle& unanimatedStyle) 43 43 { 44 return adoptRef(*new KeyframeAnimation(animation, renderer, compositeAnimation, unanimatedStyle));44 return adoptRef(*new KeyframeAnimation(animation, element, compositeAnimation, unanimatedStyle)); 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&, const RenderStyle& targetStyle, std::unique_ptr<RenderStyle>& animatedStyle, bool& didBlendStyle); 48 48 void getAnimatedStyle(std::unique_ptr<RenderStyle>&) override; 49 49 … … 94 94 95 95 private: 96 KeyframeAnimation(const Animation&, RenderElement*, CompositeAnimation*, const RenderStyle*unanimatedStyle);96 KeyframeAnimation(const Animation&, Element&, CompositeAnimation&, const RenderStyle& unanimatedStyle); 97 97 virtual ~KeyframeAnimation(); 98 98 -
trunk/Source/WebCore/rendering/RenderElement.cpp
r221916 r221980 1105 1105 view().frameView().removeSlowRepaintObject(this); 1106 1106 1107 animation().cancelAnimations(*this); 1107 if (element()) 1108 animation().cancelAnimations(*element()); 1108 1109 1109 1110 destroyLeftoverChildren(); -
trunk/Source/WebCore/rendering/RenderLayer.cpp
r221958 r221980 1006 1006 TransformationMatrix currTransform; 1007 1007 FloatRect pixelSnappedBorderRect = snapRectToDevicePixels(box->borderBoxRect(), box->document().deviceScaleFactor()); 1008 std::unique_ptr<RenderStyle> style = renderer().animation(). getAnimatedStyleForRenderer(renderer());1008 std::unique_ptr<RenderStyle> style = renderer().animation().animatedStyleForRenderer(renderer()); 1009 1009 style->applyTransform(currTransform, pixelSnappedBorderRect, applyOrigin); 1010 1010 makeMatrixRenderable(currTransform, canRender3DTransforms()); -
trunk/Source/WebCore/style/RenderTreeUpdater.cpp
r221409 r221980 399 399 auto& initialStyle = newRenderer->style(); 400 400 std::unique_ptr<RenderStyle> animatedStyle; 401 newRenderer->animation().updateAnimations( *newRenderer, initialStyle, animatedStyle);401 newRenderer->animation().updateAnimations(element, initialStyle, animatedStyle); 402 402 if (animatedStyle) { 403 403 newRenderer->setStyleInternal(WTFMove(*animatedStyle)); -
trunk/Source/WebCore/style/StyleTreeResolver.cpp
r220523 r221980 267 267 268 268 std::unique_ptr<RenderStyle> animatedStyle; 269 if (element.document().frame()->animation().updateAnimations( *renderer, *newStyle, animatedStyle))269 if (element.document().frame()->animation().updateAnimations(element, *newStyle, animatedStyle)) 270 270 recompositeLayer = true; 271 271 -
trunk/Source/WebCore/testing/Internals.cpp
r221976 r221980 908 908 if (pauseTime < 0) 909 909 return Exception { InvalidAccessError }; 910 return frame()->animation().pauseAnimationAtTime(element .renderer(), AtomicString(animationName), pauseTime);910 return frame()->animation().pauseAnimationAtTime(element, AtomicString(animationName), pauseTime); 911 911 } 912 912 … … 923 923 return Exception { InvalidAccessError }; 924 924 925 return frame()->animation().pauseAnimationAtTime( pseudoElement->renderer(), AtomicString(animationName), pauseTime);925 return frame()->animation().pauseAnimationAtTime(*pseudoElement, AtomicString(animationName), pauseTime); 926 926 } 927 927 … … 930 930 if (pauseTime < 0) 931 931 return Exception { InvalidAccessError }; 932 return frame()->animation().pauseTransitionAtTime(element .renderer(), propertyName, pauseTime);932 return frame()->animation().pauseTransitionAtTime(element, propertyName, pauseTime); 933 933 } 934 934 … … 945 945 return Exception { InvalidAccessError }; 946 946 947 return frame()->animation().pauseTransitionAtTime( pseudoElement->renderer(), property, pauseTime);947 return frame()->animation().pauseTransitionAtTime(*pseudoElement, property, pauseTime); 948 948 } 949 949 -
trunk/Source/WebKitLegacy/win/WebFrame.cpp
r218611 r221980 1172 1172 return E_FAIL; 1173 1173 1174 *animationWasRunning = frame->animation().pauseAnimationAtTime(downcast< RenderElement>(domNode->node()->renderer()), String(animationName, SysStringLen(animationName)), secondsFromNow);1174 *animationWasRunning = frame->animation().pauseAnimationAtTime(downcast<Element>(*domNode->node()), String(animationName, SysStringLen(animationName)), secondsFromNow); 1175 1175 return S_OK; 1176 1176 } … … 1191 1191 return E_FAIL; 1192 1192 1193 *transitionWasRunning = frame->animation().pauseTransitionAtTime(downcast< RenderElement>(domNode->node()->renderer()), String(propertyName, SysStringLen(propertyName)), secondsFromNow);1193 *transitionWasRunning = frame->animation().pauseTransitionAtTime(downcast<Element>(*domNode->node()), String(propertyName, SysStringLen(propertyName)), secondsFromNow); 1194 1194 return S_OK; 1195 1195 }
Note: See TracChangeset
for help on using the changeset viewer.