Changeset 291090 in webkit


Ignore:
Timestamp:
Mar 9, 2022 10:12:17 PM (4 months ago)
Author:
graouts@webkit.org
Message:

[web-animations] counter-increment should support discrete animation
https://bugs.webkit.org/show_bug.cgi?id=237640

Reviewed by Antti Koivisto.

LayoutTests/imported/w3c:

  • web-platform-tests/web-animations/animation-model/animation-types/accumulation-per-property-001-expected.txt:
  • web-platform-tests/web-animations/animation-model/animation-types/addition-per-property-001-expected.txt:
  • web-platform-tests/web-animations/animation-model/animation-types/interpolation-per-property-001-expected.txt:

Source/WebCore:

The counter-increment and counter-reset properties are represented via a single data structure
held by RenderStyle. This lays up the groundwork for animation support of counter-reset as well
but right now we only handle counter-increment to keep this patch focused.

  • animation/CSSPropertyAnimation.cpp:

(WebCore::CSSPropertyAnimationWrapperMap::CSSPropertyAnimationWrapperMap):

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r291068 r291090  
     12022-03-09  Antoine Quint  <graouts@webkit.org>
     2
     3        [web-animations] counter-increment should support discrete animation
     4        https://bugs.webkit.org/show_bug.cgi?id=237640
     5
     6        Reviewed by Antti Koivisto.
     7
     8        * web-platform-tests/web-animations/animation-model/animation-types/accumulation-per-property-001-expected.txt:
     9        * web-platform-tests/web-animations/animation-model/animation-types/addition-per-property-001-expected.txt:
     10        * web-platform-tests/web-animations/animation-model/animation-types/interpolation-per-property-001-expected.txt:
     11
    1122022-03-09  Antoine Quint  <graouts@webkit.org>
    213
  • trunk/LayoutTests/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/accumulation-per-property-001-expected.txt

    r291068 r291090  
    176176PASS column-width: "1px" onto "auto"
    177177PASS column-width: "auto" onto "1px"
     178PASS counter-increment (type: discrete) has testAccumulation function
     179PASS counter-increment: "ident-2 2" onto "ident-1 1"
     180PASS counter-increment: "ident-1 1" onto "ident-2 2"
    178181PASS cursor (type: discrete) has testAccumulation function
    179182PASS cursor: "wait" onto "pointer"
  • trunk/LayoutTests/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/addition-per-property-001-expected.txt

    r291068 r291090  
    176176PASS column-width: "1px" onto "auto"
    177177PASS column-width: "auto" onto "1px"
     178PASS counter-increment (type: discrete) has testAddition function
     179PASS counter-increment: "ident-2 2" onto "ident-1 1"
     180PASS counter-increment: "ident-1 1" onto "ident-2 2"
    178181PASS cursor (type: discrete) has testAddition function
    179182PASS cursor: "wait" onto "pointer"
  • trunk/LayoutTests/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/interpolation-per-property-001-expected.txt

    r291068 r291090  
    212212PASS column-width uses discrete animation when animating between "auto" and "1px" with effect easing
    213213PASS column-width uses discrete animation when animating between "auto" and "1px" with keyframe easing
     214PASS counter-increment (type: discrete) has testInterpolation function
     215PASS counter-increment uses discrete animation when animating between "ident-1 1" and "ident-2 2" with linear easing
     216PASS counter-increment uses discrete animation when animating between "ident-1 1" and "ident-2 2" with effect easing
     217PASS counter-increment uses discrete animation when animating between "ident-1 1" and "ident-2 2" with keyframe easing
    214218PASS cursor (type: discrete) has testInterpolation function
    215219PASS cursor uses discrete animation when animating between "pointer" and "wait" with linear easing
  • trunk/Source/WebCore/ChangeLog

    r291085 r291090  
     12022-03-09  Antoine Quint  <graouts@webkit.org>
     2
     3        [web-animations] counter-increment should support discrete animation
     4        https://bugs.webkit.org/show_bug.cgi?id=237640
     5
     6        Reviewed by Antti Koivisto.
     7
     8        The counter-increment and counter-reset properties are represented via a single data structure
     9        held by RenderStyle. This lays up the groundwork for animation support of counter-reset as well
     10        but right now we only handle counter-increment to keep this patch focused.
     11
     12        * animation/CSSPropertyAnimation.cpp:
     13        (WebCore::CSSPropertyAnimationWrapperMap::CSSPropertyAnimationWrapperMap):
     14
    1152022-03-09  Andres Gonzalez  <andresg_22@apple.com>
    216
  • trunk/Source/WebCore/animation/CSSPropertyAnimation.cpp

    r291068 r291090  
    4444#include "ColorBlending.h"
    4545#include "ContentData.h"
     46#include "CounterDirectives.h"
    4647#include "FloatConversion.h"
    4748#include "FontCascade.h"
     
    25122513    }
    25132514#endif
     2515};
     2516
     2517class CounterIncrementWrapper final : public AnimationPropertyWrapperBase {
     2518    WTF_MAKE_FAST_ALLOCATED;
     2519public:
     2520    CounterIncrementWrapper()
     2521        : AnimationPropertyWrapperBase(CSSPropertyCounterIncrement)
     2522    {
     2523    }
     2524
     2525    bool canInterpolate(const RenderStyle&, const RenderStyle&, CompositeOperation) const override { return false; }
     2526
     2527    bool equals(const RenderStyle& a, const RenderStyle& b) const final
     2528    {
     2529        auto* aCounterDirectives = a.counterDirectives();
     2530        auto* bCounterDirectives = b.counterDirectives();
     2531
     2532        if (!aCounterDirectives && !bCounterDirectives)
     2533            return true;
     2534        if (aCounterDirectives && bCounterDirectives) {
     2535            if (aCounterDirectives->size() != bCounterDirectives->size())
     2536                return false;
     2537            for (auto& [key, aDirective] : *aCounterDirectives) {
     2538                auto it = bCounterDirectives->find(key);
     2539                if (it == bCounterDirectives->end())
     2540                    return false;
     2541                auto& bDirective = it->value;
     2542                if (aDirective.incrementValue != bDirective.incrementValue)
     2543                    return false;
     2544            }
     2545            return true;
     2546        }
     2547        return false;
     2548    }
     2549
     2550#if !LOG_DISABLED
     2551    void logBlend(const RenderStyle&, const RenderStyle&, const RenderStyle&, double progress) const final
     2552    {
     2553        LOG_WITH_STREAM(Animations, stream << " blending counter-increment at " << TextStream::FormatNumberRespectingIntegers(progress) << ".");
     2554    }
     2555#endif
     2556
     2557    void blend(RenderStyle& destination, const RenderStyle& from, const RenderStyle& to, const CSSPropertyBlendingContext& context) const final
     2558    {
     2559        ASSERT(context.isDiscrete);
     2560        ASSERT(!context.progress || context.progress == 1);
     2561
     2562        // Clear all existing values in the existing set of directives.
     2563        if (destination.counterDirectives()) {
     2564            for (auto& [key, directive] : destination.accessCounterDirectives())
     2565                directive.incrementValue = std::nullopt;
     2566        }
     2567
     2568        auto& style = context.progress ? to : from;
     2569        if (!style.counterDirectives())
     2570            return;
     2571
     2572        auto& targetDirectives = destination.accessCounterDirectives();
     2573        for (auto& [key, directive] : *style.counterDirectives()) {
     2574            auto updateDirective = [](CounterDirectives& target, const CounterDirectives& source) {
     2575                target.incrementValue = source.incrementValue;
     2576            };
     2577            auto it = targetDirectives.find(key);
     2578            if (it == targetDirectives.end())
     2579                updateDirective(targetDirectives.add(key, CounterDirectives { }).iterator->value, directive);
     2580            else
     2581                updateDirective(it->value, directive);
     2582        }
     2583    }
    25142584};
    25152585
     
    28452915        new DiscretePropertyWrapper<WindRule>(CSSPropertyClipRule, &RenderStyle::clipRule, &RenderStyle::setClipRule),
    28462916        new DiscretePropertyWrapper<ColorInterpolation>(CSSPropertyColorInterpolationFilters, &RenderStyle::colorInterpolationFilters, &RenderStyle::setColorInterpolationFilters),
    2847         new DiscretePropertyWrapper<DominantBaseline>(CSSPropertyDominantBaseline, &RenderStyle::dominantBaseline, &RenderStyle::setDominantBaseline)
     2917        new DiscretePropertyWrapper<DominantBaseline>(CSSPropertyDominantBaseline, &RenderStyle::dominantBaseline, &RenderStyle::setDominantBaseline),
     2918        new CounterIncrementWrapper
    28482919    };
    28492920    const unsigned animatableLonghandPropertiesCount = WTF_ARRAY_LENGTH(animatableLonghandPropertyWrappers);
Note: See TracChangeset for help on using the changeset viewer.