Changeset 221980 in webkit


Ignore:
Timestamp:
Sep 13, 2017 11:20:12 AM (7 years ago)
Author:
Antti Koivisto
Message:

Make more of the CSS animation system internals element based
https://bugs.webkit.org/show_bug.cgi?id=176832

Reviewed by Zalan Bujtas.

CSS animations animate element style. Continue moving away from renderers in the animation code.

Also do some general modernization.

  • css/CSSComputedStyleDeclaration.cpp:

(WebCore::computeRenderStyleForProperty):

  • page/animation/AnimationBase.cpp:

(WebCore::AnimationBase::AnimationBase):

  • page/animation/AnimationBase.h:
  • page/animation/CSSAnimationController.cpp:

(WebCore::CSSAnimationControllerPrivate::ensureCompositeAnimation):
(WebCore::CSSAnimationControllerPrivate::clear):
(WebCore::CSSAnimationControllerPrivate::updateAnimations):
(WebCore::CSSAnimationControllerPrivate::updateAnimationTimerForElement):
(WebCore::CSSAnimationControllerPrivate::isRunningAnimationOnRenderer const):
(WebCore::CSSAnimationControllerPrivate::isRunningAcceleratedAnimationOnRenderer const):
(WebCore::CSSAnimationControllerPrivate::pauseAnimationAtTime):
(WebCore::CSSAnimationControllerPrivate::pauseTransitionAtTime):
(WebCore::CSSAnimationControllerPrivate::animatedStyleForElement):
(WebCore::CSSAnimationControllerPrivate::computeExtentOfAnimation const):
(WebCore::CSSAnimationController::cancelAnimations):
(WebCore::CSSAnimationController::updateAnimations):
(WebCore::CSSAnimationController::animatedStyleForRenderer):
(WebCore::CSSAnimationController::computeExtentOfAnimation const):
(WebCore::CSSAnimationController::pauseAnimationAtTime):
(WebCore::CSSAnimationController::pauseTransitionAtTime):
(WebCore::CSSAnimationControllerPrivate::updateAnimationTimerForRenderer): Deleted.
(WebCore::CSSAnimationControllerPrivate::getAnimatedStyleForRenderer): Deleted.
(WebCore::CSSAnimationController::getAnimatedStyleForRenderer): Deleted.

  • page/animation/CSSAnimationController.h:
  • page/animation/CSSAnimationControllerPrivate.h:
  • page/animation/CompositeAnimation.cpp:

(WebCore::CompositeAnimation::~CompositeAnimation):
(WebCore::CompositeAnimation::clearElement):
(WebCore::CompositeAnimation::updateTransitions):
(WebCore::CompositeAnimation::updateKeyframeAnimations):
(WebCore::CompositeAnimation::animate):
(WebCore::CompositeAnimation::clearRenderer): Deleted.

  • page/animation/CompositeAnimation.h:
  • page/animation/ImplicitAnimation.cpp:

(WebCore::ImplicitAnimation::ImplicitAnimation):
(WebCore::ImplicitAnimation::animate):

  • page/animation/ImplicitAnimation.h:

(WebCore::ImplicitAnimation::create):

  • page/animation/KeyframeAnimation.cpp:

(WebCore::KeyframeAnimation::KeyframeAnimation):
(WebCore::KeyframeAnimation::animate):

  • page/animation/KeyframeAnimation.h:
  • rendering/RenderElement.cpp:

(WebCore::RenderElement::willBeDestroyed):

  • rendering/RenderLayer.cpp:

(WebCore::RenderLayer::currentTransform const):

  • style/RenderTreeUpdater.cpp:

(WebCore::RenderTreeUpdater::createRenderer):

  • style/StyleTreeResolver.cpp:

(WebCore::Style::TreeResolver::createAnimatedElementUpdate):

  • testing/Internals.cpp:

(WebCore::Internals::pauseAnimationAtTimeOnElement):
(WebCore::Internals::pauseAnimationAtTimeOnPseudoElement):
(WebCore::Internals::pauseTransitionAtTimeOnElement):
(WebCore::Internals::pauseTransitionAtTimeOnPseudoElement):

Location:
trunk/Source
Files:
19 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r221978 r221980  
     12017-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
    1702017-09-13  Daniel Bates  <dabates@apple.com>
    271
  • trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp

    r221501 r221980  
    24782478
    24792479    if (renderer && renderer->isComposited() && CSSAnimationController::supportsAcceleratedAnimationOfProperty(propertyID)) {
    2480         ownedStyle = renderer->animation().getAnimatedStyleForRenderer(*renderer);
     2480        ownedStyle = renderer->animation().animatedStyleForRenderer(*renderer);
    24812481        if (pseudoElementSpecifier && !element.isPseudoElement()) {
    24822482            // 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  
    7777}
    7878
    79 AnimationBase::AnimationBase(const Animation& animation, RenderElement* renderer, CompositeAnimation* compositeAnimation)
    80     : m_element(renderer->element())
    81     , m_compositeAnimation(compositeAnimation)
     79AnimationBase::AnimationBase(const Animation& animation, Element& element, CompositeAnimation& compositeAnimation)
     80    : m_element(&element)
     81    , m_compositeAnimation(&compositeAnimation)
    8282    , m_animation(const_cast<Animation&>(animation))
    8383{
    84     ASSERT(m_element);
    8584    // Compute the total duration
    8685    if (m_animation->iterationCount() > 0)
  • trunk/Source/WebCore/page/animation/AnimationBase.h

    r221941 r221980  
    4949    WTF_MAKE_FAST_ALLOCATED;
    5050public:
    51     AnimationBase(const Animation& transition, RenderElement*, CompositeAnimation*);
     51    AnimationBase(const Animation& transition, Element&, CompositeAnimation&);
    5252    virtual ~AnimationBase() { }
    5353
     
    135135    double progress(double scale = 1, double offset = 0, const TimingFunction* = nullptr) const;
    136136
    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;
    139137    virtual void getAnimatedStyle(std::unique_ptr<RenderStyle>& /*animatedStyle*/) = 0;
    140138
  • trunk/Source/WebCore/page/animation/CSSAnimationController.cpp

    r221916 r221980  
    8484}
    8585
    86 CompositeAnimation& CSSAnimationControllerPrivate::ensureCompositeAnimation(RenderElement& renderer)
    87 {
    88     auto result = m_compositeAnimations.ensure(&renderer, [&] {
     86CompositeAnimation& CSSAnimationControllerPrivate::ensureCompositeAnimation(Element& element)
     87{
     88    auto result = m_compositeAnimations.ensure(&element, [&] {
    8989        return CompositeAnimation::create(*this);
    9090    });
    9191
    92     if (animationsAreSuspendedForDocument(&renderer.document()))
     92    if (animationsAreSuspendedForDocument(&element.document()))
    9393        result.iterator->value->suspendAnimations();
    9494
     
    9696}
    9797
    98 bool CSSAnimationControllerPrivate::clear(RenderElement& renderer)
    99 {
    100     auto it = m_compositeAnimations.find(&renderer);
     98bool CSSAnimationControllerPrivate::clear(Element& element)
     99{
     100    auto it = m_compositeAnimations.find(&element);
    101101    if (it == m_compositeAnimations.end())
    102102        return false;
    103103
    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;
    110108    });
    111109
    112     m_elementChangesToDispatch.removeAllMatching([element](auto& currentElement) {
    113         return currentElement.ptr() == element;
     110    m_elementChangesToDispatch.removeAllMatching([&](auto& currentElement) {
     111        return currentElement.ptr() == &element;
    114112    });
    115113   
     
    119117    auto& animation = *it->value;
    120118    bool result = animation.isSuspended();
    121     animation.clearRenderer();
     119    animation.clearElement();
    122120
    123121    m_compositeAnimations.remove(it);
     
    141139                if (callSetChanged != CallSetChanged)
    142140                    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();
    147144                calledSetChanged = true;
    148145            }
     
    156153}
    157154
    158 void CSSAnimationControllerPrivate::updateAnimationTimerForRenderer(RenderElement& renderer)
     155void CSSAnimationControllerPrivate::updateAnimationTimerForElement(Element& element)
    159156{
    160157    std::optional<Seconds> timeToNextService;
    161158
    162     const CompositeAnimation* compositeAnimation = m_compositeAnimations.get(&renderer);
     159    const CompositeAnimation* compositeAnimation = m_compositeAnimations.get(&element);
    163160    if (!compositeAnimation->isSuspended() && compositeAnimation->hasAnimations())
    164161        timeToNextService = compositeAnimation->timeToNextService();
     
    290287bool CSSAnimationControllerPrivate::isRunningAnimationOnRenderer(RenderElement& renderer, CSSPropertyID property, AnimationBase::RunningState runningState) const
    291288{
    292     auto* animation = m_compositeAnimations.get(&renderer);
     289    if (!renderer.element())
     290        return false;
     291    auto* animation = m_compositeAnimations.get(renderer.element());
    293292    if (!animation)
    294293        return false;
     
    298297bool CSSAnimationControllerPrivate::isRunningAcceleratedAnimationOnRenderer(RenderElement& renderer, CSSPropertyID property, AnimationBase::RunningState runningState) const
    299298{
    300     auto* animation = m_compositeAnimations.get(&renderer);
     299    if (!renderer.element())
     300        return false;
     301    auto* animation = m_compositeAnimations.get(renderer.element());
    301302    if (!animation)
    302303        return false;
     
    403404}
    404405
    405 bool CSSAnimationControllerPrivate::pauseAnimationAtTime(RenderElement* renderer, const AtomicString& name, double t)
    406 {
    407     if (!renderer)
    408         return false;
    409 
    410     CompositeAnimation& compositeAnimation = ensureCompositeAnimation(*renderer);
     406bool CSSAnimationControllerPrivate::pauseAnimationAtTime(Element& element, const AtomicString& name, double t)
     407{
     408    CompositeAnimation& compositeAnimation = ensureCompositeAnimation(element);
    411409    if (compositeAnimation.pauseAnimationAtTime(name, t)) {
    412         renderer->element()->invalidateStyleAndLayerComposition();
     410        element.invalidateStyleAndLayerComposition();
    413411        startUpdateStyleIfNeededDispatcher();
    414412        return true;
     
    418416}
    419417
    420 bool CSSAnimationControllerPrivate::pauseTransitionAtTime(RenderElement* renderer, const String& property, double t)
    421 {
    422     if (!renderer)
    423         return false;
    424 
    425     CompositeAnimation& compositeAnimation = ensureCompositeAnimation(*renderer);
     418bool CSSAnimationControllerPrivate::pauseTransitionAtTime(Element& element, const String& property, double t)
     419{
     420    CompositeAnimation& compositeAnimation = ensureCompositeAnimation(element);
    426421    if (compositeAnimation.pauseTransitionAtTime(cssPropertyID(property), t)) {
    427         renderer->element()->invalidateStyleAndLayerComposition();
     422        element.invalidateStyleAndLayerComposition();
    428423        startUpdateStyleIfNeededDispatcher();
    429424        return true;
     
    468463}
    469464
    470 std::unique_ptr<RenderStyle> CSSAnimationControllerPrivate::getAnimatedStyleForRenderer(RenderElement& renderer)
    471 {
    472     auto* animation = m_compositeAnimations.get(&renderer);
     465std::unique_ptr<RenderStyle> CSSAnimationControllerPrivate::animatedStyleForElement(Element& element)
     466{
     467    auto* animation = m_compositeAnimations.get(&element);
    473468    if (!animation)
    474         return RenderStyle::clonePtr(renderer.style());
     469        return nullptr;
    475470
    476471    AnimationPrivateUpdateBlock animationUpdateBlock(*this);
    477472
    478     std::unique_ptr<RenderStyle> animatingStyle = animation->getAnimatedStyle();
     473    auto animatingStyle = animation->getAnimatedStyle();
    479474    if (!animatingStyle)
    480         animatingStyle = RenderStyle::clonePtr(renderer.style());
     475        return nullptr;
    481476   
    482477    return animatingStyle;
    483478}
    484479
    485 bool CSSAnimationControllerPrivate::computeExtentOfAnimation(RenderElement& renderer, LayoutRect& bounds) const
    486 {
    487     auto* animation = m_compositeAnimations.get(&renderer);
     480bool CSSAnimationControllerPrivate::computeExtentOfAnimation(Element& element, LayoutRect& bounds) const
     481{
     482    auto* animation = m_compositeAnimations.get(&element);
    488483    if (!animation)
    489484        return true;
     
    632627}
    633628
    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;
     629void 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
     640bool 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;
    649644    if ((!oldStyle || (!oldStyle->animations() && !oldStyle->transitions())) && (!newStyle.animations() && !newStyle.transitions()))
    650645        return false;
    651646
    652     if (renderer.document().pageCacheState() != Document::NotInPageCache)
     647    if (element.document().pageCacheState() != Document::NotInPageCache)
    653648        return false;
    654649
    655650    // Don't run transitions when printing.
    656     if (renderer.view().printing())
     651    if (element.document().renderView()->printing())
    657652        return false;
    658653
     
    662657    // a new style.
    663658
    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())
    673665            m_data->setRequiresLayout();
    674         m_data->updateAnimationTimerForRenderer(renderer);
     666        m_data->updateAnimationTimerForElement(element);
    675667        frameView.scheduleAnimation();
    676668    }
     
    679671}
    680672
    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);
     673std::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;
    687684}
    688685
    689686bool CSSAnimationController::computeExtentOfAnimation(RenderElement& renderer, LayoutRect& bounds) const
    690687{
     688    if (!renderer.element())
     689        return true;
    691690    if (!renderer.style().hasAnimationsOrTransitions())
    692691        return true;
    693692
    694     return m_data->computeExtentOfAnimation(renderer, bounds);
     693    return m_data->computeExtentOfAnimation(*renderer.element(), bounds);
    695694}
    696695
     
    704703}
    705704
    706 bool CSSAnimationController::pauseAnimationAtTime(RenderElement* renderer, const AtomicString& name, double t)
     705bool CSSAnimationController::pauseAnimationAtTime(Element& element, const AtomicString& name, double t)
    707706{
    708707    AnimationUpdateBlock animationUpdateBlock(this);
    709     return m_data->pauseAnimationAtTime(renderer, name, t);
     708    return m_data->pauseAnimationAtTime(element, name, t);
    710709}
    711710
     
    715714}
    716715
    717 bool CSSAnimationController::pauseTransitionAtTime(RenderElement* renderer, const String& property, double t)
     716bool CSSAnimationController::pauseTransitionAtTime(Element& element, const String& property, double t)
    718717{
    719718    AnimationUpdateBlock animationUpdateBlock(this);
    720     return m_data->pauseTransitionAtTime(renderer, property, t);
     719    return m_data->pauseTransitionAtTime(element, property, t);
    721720}
    722721
  • trunk/Source/WebCore/page/animation/CSSAnimationController.h

    r213473 r221980  
    4949    ~CSSAnimationController();
    5050
    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&);
    5454
    5555    // If possible, compute the visual extent of any transform animation on the given renderer
     
    6161    void notifyAnimationStarted(RenderElement&, double startTime);
    6262
    63     WEBCORE_EXPORT bool pauseAnimationAtTime(RenderElement*, const AtomicString& name, double t); // To be used only for testing
    64     WEBCORE_EXPORT bool pauseTransitionAtTime(RenderElement*, const String& property, double t); // To be used only for testing
     63    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
    6565    WEBCORE_EXPORT unsigned numberOfActiveAnimations(Document*) const; // To be used only for testing
    6666   
  • trunk/Source/WebCore/page/animation/CSSAnimationControllerPrivate.h

    r217075 r221980  
    5353    void updateAnimationTimer(SetChanged callSetChanged = DoNotCallSetChanged);
    5454
    55     CompositeAnimation& ensureCompositeAnimation(RenderElement&);
    56     bool clear(RenderElement&);
     55    CompositeAnimation& ensureCompositeAnimation(Element&);
     56    bool clear(Element&);
    5757
    5858    void updateStyleIfNeededDispatcherFired();
     
    8080    bool isRunningAcceleratedAnimationOnRenderer(RenderElement&, CSSPropertyID, AnimationBase::RunningState) const;
    8181
    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);
    8484    unsigned numberOfActiveAnimations(Document*) const;
    8585
    86     std::unique_ptr<RenderStyle> getAnimatedStyleForRenderer(RenderElement&);
     86    std::unique_ptr<RenderStyle> animatedStyleForElement(Element&);
    8787
    88     bool computeExtentOfAnimation(RenderElement&, LayoutRect&) const;
     88    bool computeExtentOfAnimation(Element&, LayoutRect&) const;
    8989
    9090    double beginAnimationUpdateTime();
     
    102102    void animationWillBeRemoved(AnimationBase*);
    103103
    104     void updateAnimationTimerForRenderer(RenderElement&);
     104    void updateAnimationTimerForElement(Element&);
    105105
    106106    bool allowsNewAnimationsWhileSuspended() const { return m_allowsNewAnimationsWhileSuspended; }
     
    125125    void startTimeResponse(double t);
    126126
    127     HashMap<RenderElement*, RefPtr<CompositeAnimation>> m_compositeAnimations;
     127    HashMap<Element*, RefPtr<CompositeAnimation>> m_compositeAnimations;
    128128    Timer m_animationTimer;
    129129    Timer m_updateStyleIfNeededDispatcher;
  • trunk/Source/WebCore/page/animation/CompositeAnimation.cpp

    r217997 r221980  
    5454    // any waiting lists first.
    5555
    56     clearRenderer();
     56    clearElement();
    5757    m_transitions.clear();
    5858    m_keyframeAnimations.clear();
    5959}
    6060
    61 void CompositeAnimation::clearRenderer()
     61void CompositeAnimation::clearElement()
    6262{
    6363    if (!m_transitions.isEmpty()) {
     
    7878}
    7979
    80 void CompositeAnimation::updateTransitions(RenderElement* renderer, const RenderStyle* currentStyle, const RenderStyle* targetStyle)
     80void CompositeAnimation::updateTransitions(Element& element, const RenderStyle* currentStyle, const RenderStyle& targetStyle)
    8181{
    8282    // 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()))
    8484        return;
    8585
     
    9292   
    9393    // 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);
    9797            bool isActiveTransition = animation.duration() || animation.delay() > 0;
    9898
     
    144144                    // list. In this case, the latter one overrides the earlier one, so we
    145145                    // behave as though this is a running animation being replaced.
    146                     if (!implAnim->isTargetPropertyEqual(prop, targetStyle)) {
     146                    if (!implAnim->isTargetPropertyEqual(prop, &targetStyle)) {
    147147                        // For accelerated animations we need to return a new RenderStyle with the _current_ value
    148148                        // of the property, so that restarted transitions use the correct starting point.
     
    160160                } else {
    161161                    // 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);
    163163                }
    164164
     
    169169                if (!equal && isActiveTransition) {
    170170                    // 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);
    172172                    if (m_suspended && implicitAnimation->hasStyle())
    173173                        implicitAnimation->updatePlayState(AnimPlayStatePaused);
    174174
    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());
    176176                    m_transitions.set(prop, WTFMove(implicitAnimation));
    177177                }
     
    190190            animationController().animationWillBeRemoved(transition.get());
    191191            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()));
    193193        }
    194194    }
     
    199199}
    200200
    201 void CompositeAnimation::updateKeyframeAnimations(RenderElement* renderer, const RenderStyle* currentStyle, const RenderStyle* targetStyle)
     201void CompositeAnimation::updateKeyframeAnimations(Element& element, const RenderStyle* currentStyle, const RenderStyle& targetStyle)
    202202{
    203203    // 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())
    205205        return;
    206206
    207207    m_keyframeAnimations.checkConsistency();
    208208   
    209     if (currentStyle && currentStyle->hasAnimations() && targetStyle->hasAnimations() && *(currentStyle->animations()) == *(targetStyle->animations()))
     209    if (currentStyle && currentStyle->hasAnimations() && targetStyle.hasAnimations() && *(currentStyle->animations()) == *(targetStyle.animations()))
    210210        return;
    211211
     
    222222   
    223223    // 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();
    226226        for (int i = 0; i < numAnims; ++i) {
    227             auto& animation = targetStyle->animations()->animation(i);
     227            auto& animation = targetStyle.animations()->animation(i);
    228228            AtomicString animationName(animation.name());
    229229
     
    250250                keyframeAnim->setAnimation(animation);
    251251            } 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());
    254254
    255255                if (m_suspended) {
     
    281281            animationController().animationWillBeRemoved(animation.get());
    282282            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);
    284284        }
    285285    }
     
    288288}
    289289
    290 bool CompositeAnimation::animate(RenderElement& renderer, const RenderStyle* currentStyle, const RenderStyle& targetStyle, std::unique_ptr<RenderStyle>& blendedStyle)
     290bool CompositeAnimation::animate(Element& element, const RenderStyle* currentStyle, const RenderStyle& targetStyle, std::unique_ptr<RenderStyle>& blendedStyle)
    291291{
    292292    // 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);
    295295    m_keyframeAnimations.checkConsistency();
    296296
     
    304304        for (auto& transition : m_transitions.values()) {
    305305            bool didBlendStyle = false;
    306             if (transition->animate(*this, &renderer, currentStyle, targetStyle, blendedStyle, didBlendStyle))
     306            if (transition->animate(*this, targetStyle, blendedStyle, didBlendStyle))
    307307                animationStateChanged = true;
    308308
     
    334334        if (keyframeAnim) {
    335335            bool didBlendStyle = false;
    336             if (keyframeAnim->animate(*this, &renderer, currentStyle, targetStyle, blendedStyle, didBlendStyle))
     336            if (keyframeAnim->animate(*this, targetStyle, blendedStyle, didBlendStyle))
    337337                animationStateChanged = true;
    338338
  • trunk/Source/WebCore/page/animation/CompositeAnimation.h

    r218748 r221980  
    5353    ~CompositeAnimation();
    5454   
    55     void clearRenderer();
     55    void clearElement();
    5656
    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);
    5858    std::unique_ptr<RenderStyle> getAnimatedStyle() const;
    5959    bool computeExtentOfTransformAnimation(LayoutRect&) const;
     
    8989    CompositeAnimation(CSSAnimationControllerPrivate&);
    9090
    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);
    9393   
    9494    typedef HashMap<int, RefPtr<ImplicitAnimation>> CSSPropertyTransitionsMap;
  • trunk/Source/WebCore/page/animation/ImplicitAnimation.cpp

    r221941 r221980  
    4141namespace WebCore {
    4242
    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))
     43ImplicitAnimation::ImplicitAnimation(const Animation& transition, CSSPropertyID animatingProperty, Element& element, CompositeAnimation& compositeAnimation, const RenderStyle& fromStyle)
     44    : AnimationBase(transition, element, compositeAnimation)
     45    , m_fromStyle(RenderStyle::clonePtr(fromStyle))
    4646    , m_transitionProperty(transition.property())
    4747    , m_animatingProperty(animatingProperty)
     
    6262}
    6363
    64 bool ImplicitAnimation::animate(CompositeAnimation& compositeAnimation, RenderElement*, const RenderStyle*, const RenderStyle& targetStyle, std::unique_ptr<RenderStyle>& animatedStyle, bool& didBlendStyle)
     64bool ImplicitAnimation::animate(CompositeAnimation& compositeAnimation, const RenderStyle& targetStyle, std::unique_ptr<RenderStyle>& animatedStyle, bool& didBlendStyle)
    6565{
    6666    // 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  
    4141class ImplicitAnimation : public AnimationBase {
    4242public:
    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)
    4444    {
    45         return adoptRef(*new ImplicitAnimation(animation, animatingProperty, renderer, compositeAnimation, fromStyle));
     45        return adoptRef(*new ImplicitAnimation(animation, animatingProperty, element, compositeAnimation, fromStyle));
    4646    };
    4747   
     
    5454    void endAnimation() override;
    5555
    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);
    5757    void getAnimatedStyle(std::unique_ptr<RenderStyle>& animatedStyle) override;
    5858    void reset(const RenderStyle& to, CompositeAnimation&);
     
    8787
    8888private:
    89     ImplicitAnimation(const Animation&, CSSPropertyID, RenderElement*, CompositeAnimation*, const RenderStyle*);
     89    ImplicitAnimation(const Animation&, CSSPropertyID, Element&, CompositeAnimation&, const RenderStyle&);
    9090    virtual ~ImplicitAnimation();
    9191
  • trunk/Source/WebCore/page/animation/KeyframeAnimation.cpp

    r221941 r221980  
    4646namespace WebCore {
    4747
    48 KeyframeAnimation::KeyframeAnimation(const Animation& animation, RenderElement* renderer, CompositeAnimation* compositeAnimation, const RenderStyle* unanimatedStyle)
    49     : AnimationBase(animation, renderer, compositeAnimation)
     48KeyframeAnimation::KeyframeAnimation(const Animation& animation, Element& element, CompositeAnimation& compositeAnimation, const RenderStyle& unanimatedStyle)
     49    : AnimationBase(animation, element, compositeAnimation)
    5050    , m_keyframes(animation.name())
    51     , m_unanimatedStyle(RenderStyle::clonePtr(*unanimatedStyle))
     51    , m_unanimatedStyle(RenderStyle::clonePtr(unanimatedStyle))
    5252{
    5353    resolveKeyframeStyles();
     
    155155}
    156156
    157 bool KeyframeAnimation::animate(CompositeAnimation& compositeAnimation, RenderElement*, const RenderStyle*, const RenderStyle& targetStyle, std::unique_ptr<RenderStyle>& animatedStyle, bool& didBlendStyle)
     157bool KeyframeAnimation::animate(CompositeAnimation& compositeAnimation, const RenderStyle& targetStyle, std::unique_ptr<RenderStyle>& animatedStyle, bool& didBlendStyle)
    158158{
    159159    // Fire the start timeout if needed
  • trunk/Source/WebCore/page/animation/KeyframeAnimation.h

    r217997 r221980  
    4040class KeyframeAnimation final : public AnimationBase {
    4141public:
    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)
    4343    {
    44         return adoptRef(*new KeyframeAnimation(animation, renderer, compositeAnimation, unanimatedStyle));
     44        return adoptRef(*new KeyframeAnimation(animation, element, compositeAnimation, unanimatedStyle));
    4545    }
    4646
    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);
    4848    void getAnimatedStyle(std::unique_ptr<RenderStyle>&) override;
    4949
     
    9494
    9595private:
    96     KeyframeAnimation(const Animation&, RenderElement*, CompositeAnimation*, const RenderStyle* unanimatedStyle);
     96    KeyframeAnimation(const Animation&, Element&, CompositeAnimation&, const RenderStyle& unanimatedStyle);
    9797    virtual ~KeyframeAnimation();
    9898   
  • trunk/Source/WebCore/rendering/RenderElement.cpp

    r221916 r221980  
    11051105        view().frameView().removeSlowRepaintObject(this);
    11061106
    1107     animation().cancelAnimations(*this);
     1107    if (element())
     1108        animation().cancelAnimations(*element());
    11081109
    11091110    destroyLeftoverChildren();
  • trunk/Source/WebCore/rendering/RenderLayer.cpp

    r221958 r221980  
    10061006        TransformationMatrix currTransform;
    10071007        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());
    10091009        style->applyTransform(currTransform, pixelSnappedBorderRect, applyOrigin);
    10101010        makeMatrixRenderable(currTransform, canRender3DTransforms());
  • trunk/Source/WebCore/style/RenderTreeUpdater.cpp

    r221409 r221980  
    399399    auto& initialStyle = newRenderer->style();
    400400    std::unique_ptr<RenderStyle> animatedStyle;
    401     newRenderer->animation().updateAnimations(*newRenderer, initialStyle, animatedStyle);
     401    newRenderer->animation().updateAnimations(element, initialStyle, animatedStyle);
    402402    if (animatedStyle) {
    403403        newRenderer->setStyleInternal(WTFMove(*animatedStyle));
  • trunk/Source/WebCore/style/StyleTreeResolver.cpp

    r220523 r221980  
    267267
    268268    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))
    270270        recompositeLayer = true;
    271271
  • trunk/Source/WebCore/testing/Internals.cpp

    r221976 r221980  
    908908    if (pauseTime < 0)
    909909        return Exception { InvalidAccessError };
    910     return frame()->animation().pauseAnimationAtTime(element.renderer(), AtomicString(animationName), pauseTime);
     910    return frame()->animation().pauseAnimationAtTime(element, AtomicString(animationName), pauseTime);
    911911}
    912912
     
    923923        return Exception { InvalidAccessError };
    924924
    925     return frame()->animation().pauseAnimationAtTime(pseudoElement->renderer(), AtomicString(animationName), pauseTime);
     925    return frame()->animation().pauseAnimationAtTime(*pseudoElement, AtomicString(animationName), pauseTime);
    926926}
    927927
     
    930930    if (pauseTime < 0)
    931931        return Exception { InvalidAccessError };
    932     return frame()->animation().pauseTransitionAtTime(element.renderer(), propertyName, pauseTime);
     932    return frame()->animation().pauseTransitionAtTime(element, propertyName, pauseTime);
    933933}
    934934
     
    945945        return Exception { InvalidAccessError };
    946946
    947     return frame()->animation().pauseTransitionAtTime(pseudoElement->renderer(), property, pauseTime);
     947    return frame()->animation().pauseTransitionAtTime(*pseudoElement, property, pauseTime);
    948948}
    949949
  • trunk/Source/WebKitLegacy/win/WebFrame.cpp

    r218611 r221980  
    11721172        return E_FAIL;
    11731173
    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);
    11751175    return S_OK;
    11761176}
     
    11911191        return E_FAIL;
    11921192
    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);
    11941194    return S_OK;
    11951195}
Note: See TracChangeset for help on using the changeset viewer.