⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 287762 in webkit


Ignore:
Timestamp:
Jan 7, 2022, 10:48:40 AM (5 years ago)
Author:
graouts@webkit.org
Message:

Expose iterators on AnimationList
https://bugs.webkit.org/show_bug.cgi?id=234957

Reviewed by Antti Koivisto.

  • animation/WebAnimationUtilities.cpp:

(WebCore::compareCSSAnimations):

  • css/CSSComputedStyleDeclaration.cpp:

(WebCore::valueListForAnimationOrTransitionProperty):
(WebCore::animationShorthandValue):

  • css/makeprop.pl:

(generateAnimationPropertyInitialValueSetter):

  • platform/animation/AnimationList.h:

(WebCore::AnimationList::begin const):
(WebCore::AnimationList::end const):
(WebCore::AnimationList::rbegin const):
(WebCore::AnimationList::rend const):

  • style/Styleable.cpp:

(WebCore::Styleable::updateCSSAnimations const):
(WebCore::compileTransitionPropertiesInStyle):
(WebCore::updateCSSTransitionsForStyleableAndProperty):

Location:
trunk/Source/WebCore
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r287761 r287762  
     12022-01-07  Antoine Quint  <graouts@webkit.org>
     2
     3        Expose iterators on AnimationList
     4        https://bugs.webkit.org/show_bug.cgi?id=234957
     5
     6        Reviewed by Antti Koivisto.
     7
     8        * animation/WebAnimationUtilities.cpp:
     9        (WebCore::compareCSSAnimations):
     10        * css/CSSComputedStyleDeclaration.cpp:
     11        (WebCore::valueListForAnimationOrTransitionProperty):
     12        (WebCore::animationShorthandValue):
     13        * css/makeprop.pl:
     14        (generateAnimationPropertyInitialValueSetter):
     15        * platform/animation/AnimationList.h:
     16        (WebCore::AnimationList::begin const):
     17        (WebCore::AnimationList::end const):
     18        (WebCore::AnimationList::rbegin const):
     19        (WebCore::AnimationList::rend const):
     20        * style/Styleable.cpp:
     21        (WebCore::Styleable::updateCSSAnimations const):
     22        (WebCore::compileTransitionPropertiesInStyle):
     23        (WebCore::updateCSSTransitionsForStyleableAndProperty):
     24
    1252022-01-07  Antoine Quint  <graouts@webkit.org>
    226
  • trunk/Source/WebCore/animation/WebAnimationUtilities.cpp

    r284312 r287762  
    133133    auto& aBackingAnimation = a.backingAnimation();
    134134    auto& bBackingAnimation = b.backingAnimation();
    135     for (size_t i = 0; i < cssAnimationList->size(); ++i) {
    136         auto& animation = cssAnimationList->animation(i);
    137         if (&animation == &aBackingAnimation)
     135    for (auto& animation : *cssAnimationList) {
     136        if (animation.ptr() == &aBackingAnimation)
    138137            return true;
    139         if (&animation == &bBackingAnimation)
     138        if (animation.ptr() == &bBackingAnimation)
    140139            return false;
    141140    }
  • trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp

    r287712 r287762  
    14751475    auto list = CSSValueList::createCommaSeparated();
    14761476    if (animationList) {
    1477         for (size_t i = 0; i < animationList->size(); ++i)
    1478             ComputedStyleExtractor::addValueForAnimationPropertyToList(list.get(), property, &animationList->animation(i));
     1477        for (const auto& animation : *animationList)
     1478            ComputedStyleExtractor::addValueForAnimationPropertyToList(list.get(), property, animation.ptr());
    14791479    } else
    14801480        ComputedStyleExtractor::addValueForAnimationPropertyToList(list.get(), property, nullptr);
     
    14861486    auto parentList = CSSValueList::createCommaSeparated();
    14871487    if (animationList) {
    1488         for (size_t i = 0; i < animationList->size(); ++i) {
    1489             const auto& animation = animationList->animation(i);
     1488        for (const auto& animation : *animationList) {
    14901489            auto childList = CSSValueList::createSpaceSeparated();
    14911490            for (auto longhand : shorthandForProperty(property))
    1492                 ComputedStyleExtractor::addValueForAnimationPropertyToList(childList.get(), longhand, &animation);
     1491                ComputedStyleExtractor::addValueForAnimationPropertyToList(childList.get(), longhand, animation.ptr());
    14931492            parentList->append(childList);
    14941493        }
  • trunk/Source/WebCore/css/makeprop.pl

    r284857 r287762  
    10681068  my $initial = $propertiesWithStyleBuilderOptions{$name}{"initial"};
    10691069  $setterContent .= $indent . "list.animation(0)." . $setter . "(Animation::" . $initial . "());\n";
    1070   $setterContent .= $indent . "for (size_t i = 1; i < list.size(); ++i)\n";
    1071   $setterContent .= $indent . "    list.animation(i)." . getClearFunction($name) . "();\n";
     1070  $setterContent .= $indent . "for (auto& animation : list)\n";
     1071  $setterContent .= $indent . "    animation->" . getClearFunction($name) . "();\n";
    10721072
    10731073  return $setterContent;
  • trunk/Source/WebCore/platform/animation/AnimationList.h

    r286532 r287762  
    5555    Animation& animation(size_t i) { return m_animations[i].get(); }
    5656    const Animation& animation(size_t i) const { return m_animations[i].get(); }
    57    
     57
     58    auto begin() const { return m_animations.begin(); }
     59    auto end() const { return m_animations.end(); }
     60
     61    using const_reverse_iterator = Vector<Ref<Animation>>::const_reverse_iterator;
     62    const_reverse_iterator rbegin() const { return m_animations.rbegin(); }
     63    const_reverse_iterator rend() const { return m_animations.rend(); }
     64
    5865private:
    5966    AnimationList();
  • trunk/Source/WebCore/style/Styleable.cpp

    r287707 r287762  
    247247    // first item in the list.
    248248    if (currentAnimationList) {
    249         for (size_t i = currentAnimationList->size(); i > 0; --i) {
    250             auto& currentAnimation = currentAnimationList->animation(i - 1);
    251             if (!shouldConsiderAnimation(this->element, currentAnimation))
     249        for (auto& currentAnimation : makeReversedRange(*currentAnimationList)) {
     250            if (!shouldConsiderAnimation(this->element, currentAnimation.get()))
    252251                continue;
    253252
    254253            bool foundMatchingAnimation = false;
    255254            for (auto& previousAnimation : previousAnimations) {
    256                 if (previousAnimation->animationName() == currentAnimation.name().string) {
     255                if (previousAnimation->animationName() == currentAnimation->name().string) {
    257256                    // Timing properties or play state may have changed so we need to update the backing animation with
    258257                    // the Animation found in the current style.
    259                     previousAnimation->setBackingAnimation(currentAnimation);
     258                    previousAnimation->setBackingAnimation(currentAnimation.get());
    260259                    // Keyframes may have been cleared if the @keyframes rules was changed since
    261260                    // the last style update, so we must ensure keyframes are picked up.
     
    270269
    271270            if (!foundMatchingAnimation)
    272                 newAnimations.add(CSSAnimation::create(*this, currentAnimation, currentStyle, newStyle, resolutionContext));
     271                newAnimations.add(CSSAnimation::create(*this, currentAnimation.get(), currentStyle, newStyle, resolutionContext));
    273272        }
    274273    }
     
    343342        return;
    344343
    345     for (size_t i = 0; i < transitions->size(); ++i) {
    346         const auto& animation = transitions->animation(i);
    347         auto mode = animation.property().mode;
     344    for (const auto& animation : *transitions) {
     345        auto mode = animation->property().mode;
    348346        if (mode == Animation::TransitionMode::SingleProperty) {
    349             auto property = animation.property().id;
     347            auto property = animation->property().id;
    350348            if (isShorthandCSSProperty(property)) {
    351349                for (auto longhand : shorthandForProperty(property))
     
    376374    const Animation* matchingBackingAnimation = nullptr;
    377375    if (auto* transitions = newStyle.transitions()) {
    378         for (size_t i = 0; i < transitions->size(); ++i) {
    379             auto& backingAnimation = transitions->animation(i);
    380             if (transitionMatchesProperty(backingAnimation, property))
    381                 matchingBackingAnimation = &backingAnimation;
     376        for (auto& backingAnimation : *transitions) {
     377            if (transitionMatchesProperty(backingAnimation.get(), property))
     378                matchingBackingAnimation = backingAnimation.ptr();
    382379        }
    383380    }
Note: See TracChangeset for help on using the changeset viewer.