[webkit-changes] [WebKit/WebKit] 7a34ce: [web-animations] clean up the keyframe recomputati...

Antoine Quint noreply at github.com
Fri Feb 3 13:43:07 PST 2023


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 7a34ce6d991407d4952df999f0e65a8748486389
      https://github.com/WebKit/WebKit/commit/7a34ce6d991407d4952df999f0e65a8748486389
  Author: Antoine Quint <graouts at webkit.org>
  Date:   2023-02-03 (Fri, 03 Feb 2023)

  Changed paths:
    M Source/WebCore/animation/CSSPropertyAnimation.cpp
    M Source/WebCore/animation/KeyframeEffect.cpp
    M Source/WebCore/animation/KeyframeEffect.h
    M Source/WebCore/animation/KeyframeEffectStack.cpp
    M Source/WebCore/css/CSSKeyframeRule.cpp
    M Source/WebCore/css/CSSKeyframeRule.h
    M Source/WebCore/rendering/style/KeyframeList.cpp
    M Source/WebCore/rendering/style/KeyframeList.h
    M Source/WebCore/style/StyleResolver.cpp
    M Source/WebCore/style/StyleResolver.h

  Log Message:
  -----------
  [web-animations] clean up the keyframe recomputation code on style change
https://bugs.webkit.org/show_bug.cgi?id=251674

Reviewed by Antti Koivisto.

We landed a fair few changes recently to recompute keyframes when style changes while animations are
active. The ever-increasing list of parameters passed to Style::Resolver::keyframeStylesForAnimation()
as well as the ever-growing list of change checks made in KeyframeEffectStack::applyKeyframeEffects()
could do with some cleaning up.

We add a new KeyframeList::updatePropertiesMetadata() method which takes in a StyleProperties
and gathers information on the rule's StyleProperties relevant to keyframe recomputation: whether
"inherit" or "currentcolor" values are set, whether CSS variable values are used, whether a relative
font-weight value is set. This replaces duplicated logic found in Style::Resolver (in the CSS Animations
case) and KeyframeEffect (in the JS-originated case) when computing keyframes.

This method is called in Style::Resolver::keyframeStylesForAnimation() and KeyframeEffect::updateBlendingKeyframes().
This allows us to remove the matching information previously stored on KeyframeEffect.

We move all the logic from KeyframeEffectStack::applyKeyframeEffects() related to checking
whether some properties change to a new KeyframeEffect::recomputeKeyframesIfNecessary() which
will query the KeyframeList.

The code is now clearer and any future change to recompute keyframes will no longer require code
duplication.

Doing this refactor also uncovered a small error in the animation wrapper for text-indent which would
not check for the RenderStyle::textIndentLine() and RenderStyle::textIndentType() bits to determine
whether two text-indent were equal. This was likely due to change in the order of functions we use to check
whether a recomputation is required in the new KeyframeEffect::recomputeKeyframesIfNecessary().

* Source/WebCore/animation/CSSPropertyAnimation.cpp:
* Source/WebCore/animation/KeyframeEffect.cpp:
(WebCore::KeyframeEffect::updateBlendingKeyframes):
(WebCore::KeyframeEffect::computeCSSAnimationBlendingKeyframes):
(WebCore::KeyframeEffect::recomputeKeyframesIfNecessary):
(WebCore::KeyframeEffect::animatesDirectionAwareProperty const): Deleted.
(WebCore::KeyframeEffect::propertyAffectingKeyframeResolutionDidChange): Deleted.
(WebCore::KeyframeEffect::hasPropertySetToCurrentColor const): Deleted.
(WebCore::KeyframeEffect::hasColorSetToCurrentColor const): Deleted.
* Source/WebCore/animation/KeyframeEffect.h:
(WebCore::KeyframeEffect::inheritedProperties const): Deleted.
(WebCore::KeyframeEffect::containsCSSVariableReferences const): Deleted.
(WebCore::KeyframeEffect::hasExplicitlyInheritedKeyframeProperty const): Deleted.
(WebCore::KeyframeEffect::hasRelativeFontWeight const): Deleted.
* Source/WebCore/animation/KeyframeEffectStack.cpp:
(WebCore::KeyframeEffectStack::applyKeyframeEffects):
* Source/WebCore/css/CSSKeyframeRule.cpp:
(WebCore::StyleRuleKeyframe::containsCSSVariableReferences const): Deleted.
* Source/WebCore/css/CSSKeyframeRule.h:
* Source/WebCore/rendering/style/KeyframeList.cpp:
(WebCore::KeyframeList::clear):
(WebCore::KeyframeList::usesRelativeFontWeight const):
(WebCore::KeyframeList::hasCSSVariableReferences const):
(WebCore::KeyframeList::hasColorSetToCurrentColor const):
(WebCore::KeyframeList::hasPropertySetToCurrentColor const):
(WebCore::KeyframeList::propertiesSetToInherit const):
(WebCore::KeyframeList::updatePropertiesMetadata):
* Source/WebCore/rendering/style/KeyframeList.h:
* Source/WebCore/style/StyleResolver.cpp:
(WebCore::Style::Resolver::keyframeStylesForAnimation):
* Source/WebCore/style/StyleResolver.h:

Canonical link: https://commits.webkit.org/259838@main




More information about the webkit-changes mailing list