Changeset 230595 in webkit


Ignore:
Timestamp:
Apr 12, 2018 2:25:56 PM (6 years ago)
Author:
graouts@webkit.org
Message:

[Web Animations] Fix a host of small CSS Animations and CSS Transitions issues
https://bugs.webkit.org/show_bug.cgi?id=184555

Reviewed by Dean Jackson.

Source/WebCore:

A series of small and intertwined issues were preventing a number of CSS Animations and CSS Trantions
tests to fail when expressed as Web Animations.

  • animation/AnimationTimeline.cpp:

(WebCore::AnimationTimeline::updateCSSAnimationsForElement): Pass the old and new RenderStyles to CSSAnimation::create()
since we're refactoring DeclarativeAnimation to create blending keyframes in initialize(), no longer requiring each subclass
to create them.
(WebCore::AnimationTimeline::cssAnimationForElementAndProperty): Return the animation, if any, for a property animated by
a CSS animation, so that we can determine if a property is already being animated when running a CSS Transition.
(WebCore::AnimationTimeline::updateCSSTransitionsForElement): Since a property can be specified twice in a "transition" property,
once via "all" and once explicitly, ensure we look at all currently running transitions for the currently-processed property to
see if we need to cancel this transition. Previously, we used to only see if it had been transitioned in the old style. We also
start transitions even if the duration is 0 provided the delay is a positive, non-zero value. Then, if there is a CSS Animation
for this property already running, use that animation's original unanimated style as the from value.

  • animation/AnimationTimeline.h:
  • animation/CSSAnimation.cpp:

(WebCore::CSSAnimation::create): The animation name is now set in the CSSAnimation constructor.
(WebCore::CSSAnimation::CSSAnimation): Set the animation name and keep a copy of the unanimated style such that we can
get it when a CSS Transition is created and takes precedence over this CSS Animation.
(WebCore::CSSAnimation::initialize): Deleted.

  • animation/CSSAnimation.h:
  • animation/CSSTransition.cpp:

(WebCore::CSSTransition::create):
(WebCore::CSSTransition::initialize):

  • animation/CSSTransition.h:
  • animation/DeclarativeAnimation.cpp:

(WebCore::DeclarativeAnimation::initialize): Call the new computeDeclarativeAnimationBlendingKeyframes() on the KeyframeEffect
directly in this method so that subclasses don't need to create it manually, but most important so that keyframes are created
before timing properties are set based on the backing animation.

  • animation/DeclarativeAnimation.h:
  • animation/KeyframeEffectReadOnly.cpp:

(WebCore::KeyframeEffectReadOnly::getKeyframes): Ensure we have a CSSValue before trying to serialize it.
(WebCore::KeyframeEffectReadOnly::computeDeclarativeAnimationBlendingKeyframes):
(WebCore::KeyframeEffectReadOnly::computeCSSAnimationBlendingKeyframes): Use the animation's unanimated style to compute keyframes,
instead of a default RenderStyle which would not use the right values for implicit keyframes.
(WebCore::KeyframeEffectReadOnly::stylesWouldYieldNewCSSTransitionsBlendingKeyframes const): Look at the property used to create
the transition rather than that specified on the backing Animation object since it can be CSSPropertyInvalid in the case of
"transition: all".
(WebCore::KeyframeEffectReadOnly::setAnimatedPropertiesInStyle): If we're dealing with a CSS animation, we consider the first and
last keyframes to always have the property listed since the underlying style was provided and should be captured.

  • animation/KeyframeEffectReadOnly.h:
  • style/StyleTreeResolver.cpp:

(WebCore::Style::TreeResolver::createAnimatedElementUpdate): Apply CSS Animations after CSS Trasitions since they take precedence.

LayoutTests:

Mark more tests as passing when the CSS Animations and CSS Transitions as Web Animations flag is on.

  • animations/animation-border-overflow.html:
  • animations/lineheight-animation.html:
  • animations/missing-from-to-transforms.html:
  • animations/missing-values-first-keyframe.html:
  • animations/missing-values-last-keyframe.html:
  • animations/transition-and-animation-1.html:
  • animations/transition-and-animation-2.html:
  • animations/transition-and-animation-3.html:
  • animations/width-using-ems.html:
  • compositing/layer-creation/mismatched-rotated-transform-animation-overlap.html:
  • compositing/layer-creation/multiple-keyframes-animation-overlap.html:
  • compositing/layer-creation/scale-rotation-animation-overlap.html:
  • compositing/layer-creation/translate-scale-animation-overlap.html:
  • css3/filters/filter-animation-from-none-hw.html:
  • css3/filters/filter-animation-from-none-multi-hw.html:
  • css3/filters/filter-animation-from-none-multi.html:
  • css3/filters/filter-animation-from-none.html:
  • imported/blink/transitions/unprefixed-transform.html:
  • transitions/interrupted-all-transition.html:
Location:
trunk
Files:
32 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r230590 r230595  
     12018-04-12  Antoine Quint  <graouts@apple.com>
     2
     3        [Web Animations] Fix a host of small CSS Animations and CSS Transitions issues
     4        https://bugs.webkit.org/show_bug.cgi?id=184555
     5
     6        Reviewed by Dean Jackson.
     7
     8        Mark more tests as passing when the CSS Animations and CSS Transitions as Web Animations flag is on.
     9
     10        * animations/animation-border-overflow.html:
     11        * animations/lineheight-animation.html:
     12        * animations/missing-from-to-transforms.html:
     13        * animations/missing-values-first-keyframe.html:
     14        * animations/missing-values-last-keyframe.html:
     15        * animations/transition-and-animation-1.html:
     16        * animations/transition-and-animation-2.html:
     17        * animations/transition-and-animation-3.html:
     18        * animations/width-using-ems.html:
     19        * compositing/layer-creation/mismatched-rotated-transform-animation-overlap.html:
     20        * compositing/layer-creation/multiple-keyframes-animation-overlap.html:
     21        * compositing/layer-creation/scale-rotation-animation-overlap.html:
     22        * compositing/layer-creation/translate-scale-animation-overlap.html:
     23        * css3/filters/filter-animation-from-none-hw.html:
     24        * css3/filters/filter-animation-from-none-multi-hw.html:
     25        * css3/filters/filter-animation-from-none-multi.html:
     26        * css3/filters/filter-animation-from-none.html:
     27        * imported/blink/transitions/unprefixed-transform.html:
     28        * transitions/interrupted-all-transition.html:
     29
    1302018-04-12  Keith Rollin  <krollin@apple.com>
    231
  • trunk/LayoutTests/animations/animation-border-overflow.html

    r119985 r230595  
     1<!DOCTYPE html><!-- webkit-test-runner [ enableCSSAnimationsAndCSSTransitionsBackedByWebAnimations=true ] -->
    12<html>
    23<head>
  • trunk/LayoutTests/animations/lineheight-animation.html

    r84872 r230595  
    1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    2    "http://www.w3.org/TR/html4/loose.dtd">
     1<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><!-- webkit-test-runner [ enableCSSAnimationsAndCSSTransitionsBackedByWebAnimations=true ] -->
    32
    43<html lang="en">
  • trunk/LayoutTests/animations/missing-from-to-transforms.html

    r180441 r230595  
    1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    2    "http://www.w3.org/TR/html4/loose.dtd">
     1<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><!-- webkit-test-runner [ enableCSSAnimationsAndCSSTransitionsBackedByWebAnimations=true ] -->
    32
    43<html lang="en">
  • trunk/LayoutTests/animations/missing-values-first-keyframe.html

    r230574 r230595  
    1 <!DOCTYPE html>
     1<!DOCTYPE html><!-- webkit-test-runner [ enableCSSAnimationsAndCSSTransitionsBackedByWebAnimations=true ] -->
    22<html>
    33<head>
  • trunk/LayoutTests/animations/missing-values-last-keyframe.html

    r230574 r230595  
    1 <!DOCTYPE html>
     1<!DOCTYPE html><!-- webkit-test-runner [ enableCSSAnimationsAndCSSTransitionsBackedByWebAnimations=true ] -->
    22<html>
    33<head>
  • trunk/LayoutTests/animations/transition-and-animation-1.html

    r84872 r230595  
    1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    2    "http://www.w3.org/TR/html4/loose.dtd">
     1<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><!-- webkit-test-runner [ enableCSSAnimationsAndCSSTransitionsBackedByWebAnimations=true ] -->
    32
    43<html lang="en">
  • trunk/LayoutTests/animations/transition-and-animation-2.html

    r84872 r230595  
    1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    2    "http://www.w3.org/TR/html4/loose.dtd">
     1<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><!-- webkit-test-runner [ enableCSSAnimationsAndCSSTransitionsBackedByWebAnimations=true ] -->
    32
    43<html lang="en">
  • trunk/LayoutTests/animations/transition-and-animation-3.html

    r211573 r230595  
    1 <!DOCTYPE html>
     1<!DOCTYPE html><!-- webkit-test-runner [ enableCSSAnimationsAndCSSTransitionsBackedByWebAnimations=true ] -->
    22
    33<html>
  • trunk/LayoutTests/animations/width-using-ems.html

    r84872 r230595  
    1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    2    "http://www.w3.org/TR/html4/loose.dtd">
     1<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><!-- webkit-test-runner [ enableCSSAnimationsAndCSSTransitionsBackedByWebAnimations=true ] -->
    32
    43<html lang="en">
  • trunk/LayoutTests/compositing/layer-creation/mismatched-rotated-transform-animation-overlap.html

    r181515 r230595  
    1 <!DOCTYPE html>
     1<!DOCTYPE html><!-- webkit-test-runner [ enableCSSAnimationsAndCSSTransitionsBackedByWebAnimations=true ] -->
    22
    33<html>
  • trunk/LayoutTests/compositing/layer-creation/multiple-keyframes-animation-overlap.html

    r181515 r230595  
    1 <!DOCTYPE html>
     1<!DOCTYPE html><!-- webkit-test-runner [ enableCSSAnimationsAndCSSTransitionsBackedByWebAnimations=true ] -->
    22
    33<html>
  • trunk/LayoutTests/compositing/layer-creation/scale-rotation-animation-overlap.html

    r181515 r230595  
    1 <!DOCTYPE html>
     1<!DOCTYPE html><!-- webkit-test-runner [ enableCSSAnimationsAndCSSTransitionsBackedByWebAnimations=true ] -->
    22
    33<html>
  • trunk/LayoutTests/compositing/layer-creation/translate-scale-animation-overlap.html

    r181515 r230595  
    1 <!DOCTYPE html>
     1<!DOCTYPE html><!-- webkit-test-runner [ enableCSSAnimationsAndCSSTransitionsBackedByWebAnimations=true ] -->
    22
    33<html>
  • trunk/LayoutTests/css3/filters/filter-animation-from-none-hw.html

    r230574 r230595  
    1 <!DOCTYPE html>
     1<!DOCTYPE html><!-- webkit-test-runner [ enableCSSAnimationsAndCSSTransitionsBackedByWebAnimations=true ] -->
    22
    33<html>
  • trunk/LayoutTests/css3/filters/filter-animation-from-none-multi-hw.html

    r230574 r230595  
    1 <!DOCTYPE html>
     1<!DOCTYPE html><!-- webkit-test-runner [ enableCSSAnimationsAndCSSTransitionsBackedByWebAnimations=true ] -->
    22
    33<html>
  • trunk/LayoutTests/css3/filters/filter-animation-from-none-multi.html

    r230574 r230595  
    1 <!DOCTYPE html>
     1<!DOCTYPE html><!-- webkit-test-runner [ enableCSSAnimationsAndCSSTransitionsBackedByWebAnimations=true ] -->
    22
    33<html>
  • trunk/LayoutTests/css3/filters/filter-animation-from-none.html

    r230574 r230595  
    1 <!DOCTYPE html>
     1<!DOCTYPE html><!-- webkit-test-runner [ enableCSSAnimationsAndCSSTransitionsBackedByWebAnimations=true ] -->
    22
    33<html>
  • trunk/LayoutTests/imported/blink/transitions/unprefixed-transform.html

    r190629 r230595  
    1 <!DOCTYPE html>
     1<!DOCTYPE html><!-- webkit-test-runner [ enableCSSAnimationsAndCSSTransitionsBackedByWebAnimations=true ] -->
    22<div class="target">-webkit-transform 10ms</div><br>
    33<div class="target">transform 10ms</div><br>
  • trunk/LayoutTests/transitions/interrupted-all-transition.html

    r200360 r230595  
    1 <!DOCTYPE html>
     1<!DOCTYPE html><!-- webkit-test-runner [ enableCSSAnimationsAndCSSTransitionsBackedByWebAnimations=true ] -->
    22
    33<html>
  • trunk/Source/WebCore/ChangeLog

    r230594 r230595  
     12018-04-12  Antoine Quint  <graouts@apple.com>
     2
     3        [Web Animations] Fix a host of small CSS Animations and CSS Transitions issues
     4        https://bugs.webkit.org/show_bug.cgi?id=184555
     5
     6        Reviewed by Dean Jackson.
     7
     8        A series of small and intertwined issues were preventing a number of CSS Animations and CSS Trantions
     9        tests to fail when expressed as Web Animations.
     10
     11        * animation/AnimationTimeline.cpp:
     12        (WebCore::AnimationTimeline::updateCSSAnimationsForElement): Pass the old and new RenderStyles to CSSAnimation::create()
     13        since we're refactoring DeclarativeAnimation to create blending keyframes in initialize(), no longer requiring each subclass
     14        to create them.
     15        (WebCore::AnimationTimeline::cssAnimationForElementAndProperty): Return the animation, if any, for a property animated by
     16        a CSS animation, so that we can determine if a property is already being animated when running a CSS Transition.
     17        (WebCore::AnimationTimeline::updateCSSTransitionsForElement): Since a property can be specified twice in a "transition" property,
     18        once via "all" and once explicitly, ensure we look at all currently running transitions for the currently-processed property to
     19        see if we need to cancel this transition. Previously, we used to only see if it had been transitioned in the old style. We also
     20        start transitions even if the duration is 0 provided the delay is a positive, non-zero value. Then, if there is a CSS Animation
     21        for this property already running, use that animation's original unanimated style as the from value.
     22        * animation/AnimationTimeline.h:
     23        * animation/CSSAnimation.cpp:
     24        (WebCore::CSSAnimation::create): The animation name is now set in the CSSAnimation constructor.
     25        (WebCore::CSSAnimation::CSSAnimation): Set the animation name and keep a copy of the unanimated style such that we can
     26        get it when a CSS Transition is created and takes precedence over this CSS Animation.
     27        (WebCore::CSSAnimation::initialize): Deleted.
     28        * animation/CSSAnimation.h:
     29        * animation/CSSTransition.cpp:
     30        (WebCore::CSSTransition::create):
     31        (WebCore::CSSTransition::initialize):
     32        * animation/CSSTransition.h:
     33        * animation/DeclarativeAnimation.cpp:
     34        (WebCore::DeclarativeAnimation::initialize): Call the new computeDeclarativeAnimationBlendingKeyframes() on the KeyframeEffect
     35        directly in this method so that subclasses don't need to create it manually, but most important so that keyframes are created
     36        before timing properties are set based on the backing animation.
     37        * animation/DeclarativeAnimation.h:
     38        * animation/KeyframeEffectReadOnly.cpp:
     39        (WebCore::KeyframeEffectReadOnly::getKeyframes): Ensure we have a CSSValue before trying to serialize it.
     40        (WebCore::KeyframeEffectReadOnly::computeDeclarativeAnimationBlendingKeyframes):
     41        (WebCore::KeyframeEffectReadOnly::computeCSSAnimationBlendingKeyframes): Use the animation's unanimated style to compute keyframes,
     42        instead of a default RenderStyle which would not use the right values for implicit keyframes.
     43        (WebCore::KeyframeEffectReadOnly::stylesWouldYieldNewCSSTransitionsBlendingKeyframes const): Look at the property used to create
     44        the transition rather than that specified on the backing Animation object since it can be CSSPropertyInvalid in the case of
     45        "transition: all".
     46        (WebCore::KeyframeEffectReadOnly::setAnimatedPropertiesInStyle): If we're dealing with a CSS animation, we consider the first and
     47        last keyframes to always have the property listed since the underlying style was provided and should be captured.
     48        * animation/KeyframeEffectReadOnly.h:
     49        * style/StyleTreeResolver.cpp:
     50        (WebCore::Style::TreeResolver::createAnimatedElementUpdate): Apply CSS Animations after CSS Trasitions since they take precedence.
     51
    1522018-04-12  Antoine Quint  <graouts@apple.com>
    253
  • trunk/Source/WebCore/animation/AnimationTimeline.cpp

    r230594 r230595  
    183183            } else if (currentAnimation.isValidAnimation()) {
    184184                // Otherwise we are dealing with a new animation name and must create a CSSAnimation for it.
    185                 cssAnimationsByName.set(name, CSSAnimation::create(element, currentAnimation));
     185                cssAnimationsByName.set(name, CSSAnimation::create(element, currentAnimation, oldStyle, newStyle));
    186186            }
    187187            // Remove the name of this animation from our list since it's now known to be current.
     
    198198    if (cssAnimationsByName.isEmpty())
    199199        m_elementToCSSAnimationByName.remove(&element);
     200}
     201
     202RefPtr<WebAnimation> AnimationTimeline::cssAnimationForElementAndProperty(Element& element, CSSPropertyID property)
     203{
     204    RefPtr<WebAnimation> matchingAnimation;
     205    for (const auto& animation : m_elementToCSSAnimationsMap.get(&element)) {
     206        auto* effect = animation->effect();
     207        if (is<KeyframeEffectReadOnly>(effect) && downcast<KeyframeEffectReadOnly>(effect)->animatedProperties().contains(property))
     208            matchingAnimation = animation;
     209    }
     210    return matchingAnimation;
    200211}
    201212
     
    270281                }
    271282
    272                 bool hadProperty = previousProperties.removeFirst(property);
     283                previousProperties.removeFirst(property);
    273284                // We've found a backing animation that we didn't know about for a valid property.
    274285                if (!previousBackingAnimations.contains(&backingAnimation)) {
     
    276287                    // animation's properties and whether its blending keyframes match the old and new styles. If they do, move on to the
    277288                    // next transition, otherwise delete the previous CSSTransition object, and create a new one.
    278                     if (hadProperty) {
     289                    if (cssTransitionsByProperty.contains(property)) {
    279290                        if (cssTransitionsByProperty.get(property)->matchesBackingAnimationAndStyles(backingAnimation, oldStyle, newStyle))
    280291                            continue;
     
    283294                    // Now we can create a new CSSTransition with the new backing animation provided it has a valid
    284295                    // duration and the from and to values are distinct.
    285                     if (backingAnimation.duration() > 0 && oldStyle && !CSSPropertyAnimation::propertiesEqual(property, oldStyle, &newStyle))
    286                         cssTransitionsByProperty.set(property, CSSTransition::create(element, property, backingAnimation, oldStyle, newStyle));
     296                    if ((backingAnimation.duration() || backingAnimation.delay() > 0) && oldStyle) {
     297                        auto existingAnimation = cssAnimationForElementAndProperty(element, property);
     298                        const auto* fromStyle = existingAnimation ? &downcast<CSSAnimation>(existingAnimation.get())->unanimatedStyle() : oldStyle;
     299                        if (!CSSPropertyAnimation::propertiesEqual(property, fromStyle, &newStyle))
     300                            cssTransitionsByProperty.set(property, CSSTransition::create(element, property, backingAnimation, fromStyle, newStyle));
     301                    }
    287302                }
    288303            }
  • trunk/Source/WebCore/animation/AnimationTimeline.h

    r230594 r230595  
    8888    HashMap<Element*, Vector<RefPtr<WebAnimation>>>& relevantMapForAnimation(WebAnimation&);
    8989    void cancelOrRemoveDeclarativeAnimation(RefPtr<DeclarativeAnimation>);
     90    RefPtr<WebAnimation> cssAnimationForElementAndProperty(Element&, CSSPropertyID);
    9091
    9192    ClassType m_classType;
  • trunk/Source/WebCore/animation/CSSAnimation.cpp

    r229983 r230595  
    3232namespace WebCore {
    3333
    34 Ref<CSSAnimation> CSSAnimation::create(Element& target, const Animation& backingAnimation)
     34Ref<CSSAnimation> CSSAnimation::create(Element& target, const Animation& backingAnimation, const RenderStyle* oldStyle, const RenderStyle& newStyle)
    3535{
    36     auto result = adoptRef(*new CSSAnimation(target, backingAnimation));
    37     result->m_animationName = backingAnimation.name();
    38     result->initialize(target);
     36    auto result = adoptRef(*new CSSAnimation(target, backingAnimation, newStyle));
     37    result->initialize(target, oldStyle, newStyle);
    3938    return result;
    4039}
    4140
    42 CSSAnimation::CSSAnimation(Element& element, const Animation& backingAnimation)
     41CSSAnimation::CSSAnimation(Element& element, const Animation& backingAnimation, const RenderStyle& unanimatedStyle)
    4342    : DeclarativeAnimation(element, backingAnimation)
     43    , m_animationName(backingAnimation.name())
     44    , m_unanimatedStyle(RenderStyle::clonePtr(unanimatedStyle))
    4445{
    45 }
    46 
    47 void CSSAnimation::initialize(const Element& target)
    48 {
    49     DeclarativeAnimation::initialize(target);
    50 
    51     downcast<KeyframeEffectReadOnly>(effect())->computeCSSAnimationBlendingKeyframes();
    5246}
    5347
  • trunk/Source/WebCore/animation/CSSAnimation.h

    r229983 r230595  
    3333class Animation;
    3434class Element;
     35class RenderStyle;
    3536
    3637class CSSAnimation final : public DeclarativeAnimation {
    3738public:
    38     static Ref<CSSAnimation> create(Element&, const Animation&);
     39    static Ref<CSSAnimation> create(Element&, const Animation&, const RenderStyle* oldStyle, const RenderStyle& newStyle);
    3940    ~CSSAnimation() = default;
    4041
    4142    bool isCSSAnimation() const override { return true; }
    4243    const String& animationName() const { return m_animationName; }
     44    const RenderStyle& unanimatedStyle() const { return *m_unanimatedStyle; }
    4345
    4446    std::optional<double> bindingsCurrentTime() const final;
    4547
    4648protected:
    47     void initialize(const Element&) final;
    4849    void syncPropertiesWithBackingAnimation() final;
    4950
    5051private:
    51     CSSAnimation(Element&, const Animation&);
     52    CSSAnimation(Element&, const Animation&, const RenderStyle&);
    5253
    5354    String m_animationName;
    54 
     55    std::unique_ptr<RenderStyle> m_unanimatedStyle;
    5556};
    5657
  • trunk/Source/WebCore/animation/CSSTransition.cpp

    r230112 r230595  
    3636{
    3737    auto result = adoptRef(*new CSSTransition(target, property, backingAnimation));
    38     result->initialize(target);
    39     downcast<KeyframeEffectReadOnly>(result->effect())->computeCSSTransitionBlendingKeyframes(oldStyle, newStyle);
     38    result->initialize(target, oldStyle, newStyle);
    4039    return result;
    4140}
     
    4746}
    4847
    49 void CSSTransition::initialize(const Element& target)
     48void CSSTransition::initialize(const Element& target, const RenderStyle* oldStyle, const RenderStyle& newStyle)
    5049{
    51     DeclarativeAnimation::initialize(target);
     50    DeclarativeAnimation::initialize(target, oldStyle, newStyle);
    5251
    5352    suspendEffectInvalidation();
  • trunk/Source/WebCore/animation/CSSTransition.h

    r230112 r230595  
    4949
    5050protected:
    51     void initialize(const Element&) final;
     51    void initialize(const Element&, const RenderStyle* oldStyle, const RenderStyle& newStyle) final;
    5252
    5353private:
  • trunk/Source/WebCore/animation/DeclarativeAnimation.cpp

    r229981 r230595  
    5757}
    5858
    59 void DeclarativeAnimation::initialize(const Element& target)
     59void DeclarativeAnimation::initialize(const Element& target, const RenderStyle* oldStyle, const RenderStyle& newStyle)
    6060{
    6161    // We need to suspend invalidation of the animation's keyframe effect during its creation
     
    6666    setEffect(KeyframeEffectReadOnly::create(target));
    6767    setTimeline(&target.document().timeline());
     68    downcast<KeyframeEffectReadOnly>(effect())->computeDeclarativeAnimationBlendingKeyframes(oldStyle, newStyle);
    6869    syncPropertiesWithBackingAnimation();
    6970    if (backingAnimation().playState() == AnimPlayStatePlaying)
  • trunk/Source/WebCore/animation/DeclarativeAnimation.h

    r229829 r230595  
    3535class Animation;
    3636class Element;
     37class RenderStyle;
    3738
    3839class DeclarativeAnimation : public WebAnimation {
     
    5253    DeclarativeAnimation(Element&, const Animation&);
    5354
    54     virtual void initialize(const Element&);
     55    virtual void initialize(const Element&, const RenderStyle* oldStyle, const RenderStyle& newStyle);
    5556    virtual void syncPropertiesWithBackingAnimation();
    5657
  • trunk/Source/WebCore/animation/KeyframeEffectReadOnly.cpp

    r230578 r230595  
    538538                auto propertyName = CSSPropertyIDToIDLAttributeName(cssPropertyId);
    539539                // 2. Let IDL value be the result of serializing the property value of declaration by passing declaration to the algorithm to serialize a CSS value.
    540                 auto idlValue = computedStyleExtractor.valueForPropertyinStyle(style, cssPropertyId)->cssText();
     540                String idlValue = "";
     541                if (auto cssValue = computedStyleExtractor.valueForPropertyinStyle(style, cssPropertyId))
     542                    idlValue = cssValue->cssText();
    541543                // 3. Let value be the result of converting IDL value to an ECMAScript String value.
    542544                auto value = toJS<IDLDOMString>(state, idlValue);
     
    818820#endif
    819821
     822void KeyframeEffectReadOnly::computeDeclarativeAnimationBlendingKeyframes(const RenderStyle* oldStyle, const RenderStyle& newStyle)
     823{
     824    ASSERT(is<DeclarativeAnimation>(animation()));
     825    if (is<CSSAnimation>(animation()))
     826        computeCSSAnimationBlendingKeyframes();
     827    else if (is<CSSTransition>(animation()))
     828        computeCSSTransitionBlendingKeyframes(oldStyle, newStyle);
     829}
     830
    820831void KeyframeEffectReadOnly::computeCSSAnimationBlendingKeyframes()
    821832{
    822833    ASSERT(is<CSSAnimation>(animation()));
    823834
    824     auto& backingAnimation = downcast<CSSAnimation>(animation())->backingAnimation();
     835    auto cssAnimation = downcast<CSSAnimation>(animation());
     836    auto& backingAnimation = cssAnimation->backingAnimation();
    825837    if (backingAnimation.name().isEmpty())
    826838        return;
    827 
    828     auto renderStyle = RenderStyle::createPtr();
    829     // We need to call update() on the FontCascade or we'll hit an ASSERT when parsing font-related properties.
    830     renderStyle->fontCascade().update(nullptr);
    831839
    832840    KeyframeList keyframeList(backingAnimation.name());
    833841    if (auto* styleScope = Style::Scope::forOrdinal(*m_target, backingAnimation.nameStyleScopeOrdinal()))
    834         styleScope->resolver().keyframeStylesForAnimation(*m_target, renderStyle.get(), keyframeList);
     842        styleScope->resolver().keyframeStylesForAnimation(*m_target, &cssAnimation->unanimatedStyle(), keyframeList);
    835843
    836844    // Ensure resource loads for all the frames.
     
    878886        return false;
    879887
    880     auto property = downcast<CSSTransition>(animation())->backingAnimation().property();
     888    auto property = downcast<CSSTransition>(animation())->property();
    881889
    882890    // There cannot be new keyframes if the start and to values are the same.
     
    991999    // The effect value of a single property referenced by a keyframe effect as one of its target properties,
    9921000    // for a given iteration progress, current iteration and underlying value is calculated as follows.
     1001
     1002    bool isCSSAnimation = is<CSSAnimation>(animation());
    9931003
    9941004    for (auto cssPropertyId : m_blendingKeyframes.properties()) {
     
    10061016        for (size_t i = 0; i < m_blendingKeyframes.size(); ++i) {
    10071017            auto& keyframe = m_blendingKeyframes[i];
    1008             if (!keyframe.containsProperty(cssPropertyId))
    1009                 continue;
    10101018            auto offset = keyframe.key();
     1019            if (!keyframe.containsProperty(cssPropertyId)) {
     1020                // If we're dealing with a CSS animation, we consider the first and last keyframes to always have the property listed
     1021                // since the underlying style was provided and should be captured.
     1022                if (!isCSSAnimation || (offset && offset < 1))
     1023                    continue;
     1024            }
    10111025            if (!offset)
    10121026                numberOfKeyframesWithZeroOffset++;
  • trunk/Source/WebCore/animation/KeyframeEffectReadOnly.h

    r230578 r230595  
    113113#endif
    114114
    115     void computeCSSAnimationBlendingKeyframes();
    116     void computeCSSTransitionBlendingKeyframes(const RenderStyle* oldStyle, const RenderStyle& newStyle);
     115    void computeDeclarativeAnimationBlendingKeyframes(const RenderStyle* oldStyle, const RenderStyle& newStyle);
    117116    bool stylesWouldYieldNewCSSTransitionsBlendingKeyframes(const RenderStyle& oldStyle, const RenderStyle& newStyle) const;
    118117    bool hasBlendingKeyframes() const { return m_blendingKeyframes.size(); }
     
    140139    void computeStackingContextImpact();
    141140    void updateBlendingKeyframes();
     141    void computeCSSAnimationBlendingKeyframes();
     142    void computeCSSTransitionBlendingKeyframes(const RenderStyle* oldStyle, const RenderStyle& newStyle);
    142143    void computeShouldRunAccelerated();
    143144    void setBlendingKeyframes(KeyframeList&);
  • trunk/Source/WebCore/style/StyleTreeResolver.cpp

    r230211 r230595  
    293293        // on the document timeline. Note that we get timeline() on the Document here because we need a timeline created
    294294        // in case no Web Animations have been created through the JS API.
     295        if ((oldStyle && oldStyle->hasTransitions()) || newStyle->hasTransitions())
     296            m_document.timeline().updateCSSTransitionsForElement(element, *newStyle, oldStyle);
     297
    295298        if ((oldStyle && oldStyle->hasAnimations()) || newStyle->hasAnimations())
    296299            m_document.timeline().updateCSSAnimationsForElement(element, *newStyle, oldStyle);
    297 
    298         if ((oldStyle && oldStyle->hasTransitions()) || newStyle->hasTransitions())
    299             m_document.timeline().updateCSSTransitionsForElement(element, *newStyle, oldStyle);
    300300    }
    301301
Note: See TracChangeset for help on using the changeset viewer.