Changeset 233004 in webkit


Ignore:
Timestamp:
Jun 20, 2018 12:07:34 AM (6 years ago)
Author:
graouts@webkit.org
Message:

[Web Animations] Make imported/mozilla/css-animations/test_pseudoElement-get-animations.html pass reliably
https://bugs.webkit.org/show_bug.cgi?id=183818
<rdar://problem/40997015>

Reviewed by Dean Jackson.

LayoutTests/imported/mozilla:

Mark progressions in the Mozilla CSS Transitions and CSS Animations tests.

  • css-animations/test_pseudoElement-get-animations-expected.txt:
  • css-transitions/test_element-get-animations-expected.txt:

Source/WebCore:

We add a new opt-in flag to return sorted animations when calling AnimationTimeline::animationsForElement() so that
Element::getAnimations() can opt into returning animations sorted by the rules defined by the CSS Transitions spec.
The rule is that CSS Transitions must be sorted prior to CSS Animations and regular Web Animations, and then sorted
by the time they were generated and, if generated at the same time, sorted alphabetically based on the transitioned
property. To be able to accomodate this, we add a new generationTime() method to CSSTransition.

  • animation/AnimationTimeline.cpp:

(WebCore::AnimationTimeline::animationsForElement const):
(WebCore::AnimationTimeline::updateCSSTransitionsForElement):

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

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

  • animation/CSSTransition.h:
  • dom/Element.cpp:

(WebCore::Element::getAnimations):

LayoutTests:

This test now passes reliably.

Location:
trunk
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r232993 r233004  
     12018-06-19  Antoine Quint  <graouts@apple.com>
     2
     3        [Web Animations] Make imported/mozilla/css-animations/test_pseudoElement-get-animations.html pass reliably
     4        https://bugs.webkit.org/show_bug.cgi?id=183818
     5        <rdar://problem/40997015>
     6
     7        Reviewed by Dean Jackson.
     8
     9        This test now passes reliably.
     10
     11        * TestExpectations:
     12
    1132018-06-19  Per Arne Vollan  <pvollan@apple.com>
    214
  • trunk/LayoutTests/TestExpectations

    r232978 r233004  
    19271927webkit.org/b/181888 imported/w3c/web-platform-tests/web-animations/timing-model/animation-effects/current-iteration.html [ Pass Failure ]
    19281928
    1929 webkit.org/b/183818 imported/mozilla/css-animations/test_pseudoElement-get-animations.html [ Pass Failure Timeout ]
    19301929webkit.org/b/183826 imported/mozilla/css-animations/test_animation-pausing.html [ Pass Failure Timeout ]
    19311930webkit.org/b/183830 imported/mozilla/css-animations/test_animation-ready.html [ Pass Failure Timeout ]
  • trunk/LayoutTests/imported/mozilla/ChangeLog

    r232978 r233004  
     12018-06-19  Antoine Quint  <graouts@apple.com>
     2
     3        [Web Animations] Make imported/mozilla/css-animations/test_pseudoElement-get-animations.html pass reliably
     4        https://bugs.webkit.org/show_bug.cgi?id=183818
     5        <rdar://problem/40997015>
     6
     7        Reviewed by Dean Jackson.
     8
     9        Mark progressions in the Mozilla CSS Transitions and CSS Animations tests.
     10
     11        * css-animations/test_pseudoElement-get-animations-expected.txt:
     12        * css-transitions/test_element-get-animations-expected.txt:
     13
    1142018-06-19  Antoine Quint  <graouts@apple.com>
    215
  • trunk/LayoutTests/imported/mozilla/css-animations/test_pseudoElement-get-animations-expected.txt

    r229809 r233004  
    11
    22PASS getAnimations returns CSSAnimation objects
    3 FAIL getAnimations returns css transitions/animations, and script-generated animations in the expected order assert_equals: Got expected number of animations/trnasitions running on ::after pseudo element expected 5 but got 2
     3PASS getAnimations returns css transitions/animations, and script-generated animations in the expected order
    44
  • trunk/LayoutTests/imported/mozilla/css-transitions/test_element-get-animations-expected.txt

    r229888 r233004  
    55FAIL getAnimations for transition on non-animatable property assert_equals: getAnimations returns an empty sequence for a transition of a non-animatable property expected 0 but got 1
    66PASS getAnimations for transition on unsupported property
    7 FAIL getAnimations sorts simultaneous transitions by name assert_equals: expected "border-bottom-width" but got "border-left-width"
     7PASS getAnimations sorts simultaneous transitions by name
    88PASS getAnimations sorts transitions by when they were generated
    99
  • trunk/Source/WebCore/ChangeLog

    r233002 r233004  
     12018-06-19  Antoine Quint  <graouts@apple.com>
     2
     3        [Web Animations] Make imported/mozilla/css-animations/test_pseudoElement-get-animations.html pass reliably
     4        https://bugs.webkit.org/show_bug.cgi?id=183818
     5        <rdar://problem/40997015>
     6
     7        Reviewed by Dean Jackson.
     8
     9        We add a new opt-in flag to return sorted animations when calling AnimationTimeline::animationsForElement() so that
     10        Element::getAnimations() can opt into returning animations sorted by the rules defined by the CSS Transitions spec.
     11        The rule is that CSS Transitions must be sorted prior to CSS Animations and regular Web Animations, and then sorted
     12        by the time they were generated and, if generated at the same time, sorted alphabetically based on the transitioned
     13        property. To be able to accomodate this, we add a new generationTime() method to CSSTransition.
     14
     15        * animation/AnimationTimeline.cpp:
     16        (WebCore::AnimationTimeline::animationsForElement const):
     17        (WebCore::AnimationTimeline::updateCSSTransitionsForElement):
     18        * animation/AnimationTimeline.h:
     19        * animation/CSSTransition.cpp:
     20        (WebCore::CSSTransition::create):
     21        (WebCore::CSSTransition::CSSTransition):
     22        * animation/CSSTransition.h:
     23        * dom/Element.cpp:
     24        (WebCore::Element::getAnimations):
     25
    1262018-06-19  Basuke Suzuki  <Basuke.Suzuki@sony.com>
    227
  • trunk/Source/WebCore/animation/AnimationTimeline.cpp

    r232960 r233004  
    143143}
    144144
    145 Vector<RefPtr<WebAnimation>> AnimationTimeline::animationsForElement(Element& element) const
     145Vector<RefPtr<WebAnimation>> AnimationTimeline::animationsForElement(Element& element, Ordering ordering) const
    146146{
    147147    Vector<RefPtr<WebAnimation>> animations;
    148148    if (m_elementToCSSTransitionsMap.contains(&element)) {
    149149        const auto& cssTransitions = m_elementToCSSTransitionsMap.get(&element);
    150         animations.appendRange(cssTransitions.begin(), cssTransitions.end());
     150        if (ordering == Ordering::Sorted) {
     151            Vector<RefPtr<WebAnimation>> sortedCSSTransitions;
     152            sortedCSSTransitions.appendRange(cssTransitions.begin(), cssTransitions.end());
     153            std::sort(sortedCSSTransitions.begin(), sortedCSSTransitions.end(), [](auto& lhs, auto& rhs) {
     154                // Sort transitions first by their generation time, and then by transition-property.
     155                // https://drafts.csswg.org/css-transitions-2/#animation-composite-order
     156                auto* lhsTransition = downcast<CSSTransition>(lhs.get());
     157                auto* rhsTransition = downcast<CSSTransition>(rhs.get());
     158                if (lhsTransition->generationTime() != rhsTransition->generationTime())
     159                    return lhsTransition->generationTime() < rhsTransition->generationTime();
     160                return lhsTransition->transitionProperty().utf8() < rhsTransition->transitionProperty().utf8();
     161            });
     162            animations.appendVector(sortedCSSTransitions);
     163        } else
     164            animations.appendRange(cssTransitions.begin(), cssTransitions.end());
    151165    }
    152166    if (m_elementToCSSAnimationsMap.contains(&element)) {
     
    301315    }).iterator->value;
    302316
     317    auto generationTime = MonotonicTime::now();
     318
    303319    auto numberOfProperties = CSSPropertyAnimation::getNumProperties();
    304320    for (int propertyIndex = 0; propertyIndex < numberOfProperties; ++propertyIndex) {
     
    349365            auto& reversingAdjustedStartStyle = beforeChangeStyle;
    350366            auto reversingShorteningFactor = 1;
    351             runningTransitionsByProperty.set(property, CSSTransition::create(element, property, *matchingBackingAnimation, &beforeChangeStyle, afterChangeStyle, delay, duration, reversingAdjustedStartStyle, reversingShorteningFactor));
     367            runningTransitionsByProperty.set(property, CSSTransition::create(element, property, generationTime, *matchingBackingAnimation, &beforeChangeStyle, afterChangeStyle, delay, duration, reversingAdjustedStartStyle, reversingShorteningFactor));
    352368        } else if (completedTransitionsByProperty.contains(property) && !propertyInStyleMatchesValueForTransitionInMap(property, afterChangeStyle, completedTransitionsByProperty)) {
    353369            // 2. Otherwise, if the element has a completed transition for the property and the end value of the completed transition is different from
     
    402418                auto delay = matchingBackingAnimation->delay() < 0 ? Seconds(matchingBackingAnimation->delay()) * reversingShorteningFactor : Seconds(matchingBackingAnimation->delay());
    403419                auto duration = Seconds(matchingBackingAnimation->duration()) * reversingShorteningFactor;
    404                 runningTransitionsByProperty.set(property, CSSTransition::create(element, property, *matchingBackingAnimation, &previouslyRunningTransitionCurrentStyle, afterChangeStyle, delay, duration, reversingAdjustedStartStyle, reversingShorteningFactor));
     420                runningTransitionsByProperty.set(property, CSSTransition::create(element, property, generationTime, *matchingBackingAnimation, &previouslyRunningTransitionCurrentStyle, afterChangeStyle, delay, duration, reversingAdjustedStartStyle, reversingShorteningFactor));
    405421            } else {
    406422                // 4. Otherwise, implementations must cancel the running transition
     
    418434                auto& reversingAdjustedStartStyle = currentStyle;
    419435                auto reversingShorteningFactor = 1;
    420                 runningTransitionsByProperty.set(property, CSSTransition::create(element, property, *matchingBackingAnimation, &previouslyRunningTransitionCurrentStyle, afterChangeStyle, delay, duration, reversingAdjustedStartStyle, reversingShorteningFactor));
     436                runningTransitionsByProperty.set(property, CSSTransition::create(element, property, generationTime, *matchingBackingAnimation, &previouslyRunningTransitionCurrentStyle, afterChangeStyle, delay, duration, reversingAdjustedStartStyle, reversingShorteningFactor));
    421437            }
    422438        }
  • trunk/Source/WebCore/animation/AnimationTimeline.h

    r232960 r233004  
    5858    virtual void timingModelDidChange() { };
    5959
     60    enum class Ordering { Sorted, Unsorted };
    6061    const ListHashSet<RefPtr<WebAnimation>>& animations() const { return m_animations; }
    61     Vector<RefPtr<WebAnimation>> animationsForElement(Element&) const;
     62    Vector<RefPtr<WebAnimation>> animationsForElement(Element&, Ordering ordering = Ordering::Unsorted) const;
    6263    void removeAnimationsForElement(Element&);
    6364    void cancelDeclarativeAnimationsForElement(Element&);
  • trunk/Source/WebCore/animation/CSSTransition.cpp

    r232946 r233004  
    3333namespace WebCore {
    3434
    35 Ref<CSSTransition> CSSTransition::create(Element& target, CSSPropertyID property, const Animation& backingAnimation, const RenderStyle* oldStyle, const RenderStyle& newStyle, Seconds delay, Seconds duration, const RenderStyle& reversingAdjustedStartStyle, double reversingShorteningFactor)
     35Ref<CSSTransition> CSSTransition::create(Element& target, CSSPropertyID property, MonotonicTime generationTime, const Animation& backingAnimation, const RenderStyle* oldStyle, const RenderStyle& newStyle, Seconds delay, Seconds duration, const RenderStyle& reversingAdjustedStartStyle, double reversingShorteningFactor)
    3636{
    37     auto result = adoptRef(*new CSSTransition(target, property, backingAnimation, newStyle, reversingAdjustedStartStyle, reversingShorteningFactor));
     37    auto result = adoptRef(*new CSSTransition(target, property, generationTime, backingAnimation, newStyle, reversingAdjustedStartStyle, reversingShorteningFactor));
    3838    result->initialize(target, oldStyle, newStyle);
    3939    result->setTimingProperties(delay, duration);
     
    4141}
    4242
    43 CSSTransition::CSSTransition(Element& element, CSSPropertyID property, const Animation& backingAnimation, const RenderStyle& targetStyle, const RenderStyle& reversingAdjustedStartStyle, double reversingShorteningFactor)
     43CSSTransition::CSSTransition(Element& element, CSSPropertyID property, MonotonicTime generationTime, const Animation& backingAnimation, const RenderStyle& targetStyle, const RenderStyle& reversingAdjustedStartStyle, double reversingShorteningFactor)
    4444    : DeclarativeAnimation(element, backingAnimation)
    4545    , m_property(property)
     46    , m_generationTime(generationTime)
    4647    , m_targetStyle(RenderStyle::clonePtr(targetStyle))
    4748    , m_reversingAdjustedStartStyle(RenderStyle::clonePtr(reversingAdjustedStartStyle))
  • trunk/Source/WebCore/animation/CSSTransition.h

    r232946 r233004  
    3838class CSSTransition final : public DeclarativeAnimation {
    3939public:
    40     static Ref<CSSTransition> create(Element&, CSSPropertyID, const Animation&, const RenderStyle* oldStyle, const RenderStyle& newStyle, Seconds delay, Seconds duration, const RenderStyle& reversingAdjustedStartStyle, double);
     40    static Ref<CSSTransition> create(Element&, CSSPropertyID, MonotonicTime generationTime, const Animation&, const RenderStyle* oldStyle, const RenderStyle& newStyle, Seconds delay, Seconds duration, const RenderStyle& reversingAdjustedStartStyle, double);
    4141    ~CSSTransition() = default;
    4242
     
    4444    String transitionProperty() const { return getPropertyNameString(m_property); }
    4545    CSSPropertyID property() const { return m_property; }
     46    MonotonicTime generationTime() const { return m_generationTime; }
    4647    const RenderStyle& targetStyle() const { return *m_targetStyle; }
    4748    const RenderStyle& currentStyle() const { return *m_currentStyle; }
     
    5354
    5455private:
    55     CSSTransition(Element&, CSSPropertyID, const Animation&, const RenderStyle& targetStyle, const RenderStyle& reversingAdjustedStartStyle, double);
     56    CSSTransition(Element&, CSSPropertyID, MonotonicTime generationTime, const Animation&, const RenderStyle& targetStyle, const RenderStyle& reversingAdjustedStartStyle, double);
    5657    void setTimingProperties(Seconds delay, Seconds duration);
    5758
    5859    CSSPropertyID m_property;
     60    MonotonicTime m_generationTime;
    5961    std::unique_ptr<RenderStyle> m_targetStyle;
    6062    std::unique_ptr<RenderStyle> m_currentStyle;
  • trunk/Source/WebCore/dom/Element.cpp

    r232185 r233004  
    38343834    Vector<RefPtr<WebAnimation>> animations;
    38353835    if (auto timeline = document().existingTimeline()) {
    3836         for (auto& animation : timeline->animationsForElement(*this)) {
     3836        for (auto& animation : timeline->animationsForElement(*this, AnimationTimeline::Ordering::Sorted)) {
    38373837            if (animation->canBeListed())
    38383838                animations.append(animation);
Note: See TracChangeset for help on using the changeset viewer.