Changeset 287835 in webkit


Ignore:
Timestamp:
Jan 10, 2022 7:09:14 AM (6 months ago)
Author:
graouts@webkit.org
Message:

[Web Animations] getKeyframes() for a CSS Animation should not use computed style for keyframes (part 2)
https://bugs.webkit.org/show_bug.cgi?id=235028

Reviewed by Antti Koivisto.

LayoutTests/imported/w3c:

Mark WPT progressions.

  • web-platform-tests/css/css-animations/KeyframeEffect-getKeyframes.tentative-expected.txt:

Source/WebCore:

In bug 235008, we already improved the situtation by reading from the StyleProperties
associated with the StyleRuleKeyframe for CSS Animations. We're now taking the next
step by reading from the matching rules for the provided element.

There is one remaining case where we use the computed style: when the CSSValue uses
a CSS variable. To fix the css/css-animations/KeyframeEffect-getKeyframes.tentative.html
WPT entirely, we'll need to be able to substitute those in the output.

  • animation/KeyframeEffect.cpp:

(WebCore::KeyframeEffect::getKeyframes):

Location:
trunk
Files:
4 edited

Legend:

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

    r287830 r287835  
     12022-01-10  Antoine Quint  <graouts@webkit.org>
     2
     3        [Web Animations] getKeyframes() for a CSS Animation should not use computed style for keyframes (part 2)
     4        https://bugs.webkit.org/show_bug.cgi?id=235028
     5
     6        Reviewed by Antti Koivisto.
     7
     8        Mark WPT progressions.
     9
     10        * web-platform-tests/css/css-animations/KeyframeEffect-getKeyframes.tentative-expected.txt:
     11
    1122022-01-09  Antoine Quint  <graouts@webkit.org>
    213
  • trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-animations/KeyframeEffect-getKeyframes.tentative-expected.txt

    r287822 r287835  
    1818PASS KeyframeEffect.getKeyframes() returns expected values for animations with filter properties and missing keyframes
    1919PASS KeyframeEffect.getKeyframes() returns expected values for animation with drop-shadow of filter property
    20 FAIL KeyframeEffect.getKeyframes() returns expected values for animations with text-shadow properties and missing keyframes assert_equals: value for 'textShadow' on Keyframe #0 should match expected "rgb(0, 0, 0) 1px 1px 2px, rgb(0, 0, 255) 0px 0px 16px, rgb(0, 0, 255) 0px 0px 3.2px" but got "rgb(0, 0, 0) 1px 1px 2px, rgb(0, 0, 255) 0px 0px 16px, rgb(0, 0, 255) 0px 0px 3.200000047683716px"
    21 FAIL KeyframeEffect.getKeyframes() returns expected values for animations with background-size properties and missing keyframes assert_equals: value for 'backgroundSize' on ComputedKeyframe #0 after updating current style should match expected "30px, 40%, auto" but got "30px"
     20PASS KeyframeEffect.getKeyframes() returns expected values for animations with text-shadow properties and missing keyframes
     21PASS KeyframeEffect.getKeyframes() returns expected values for animations with background-size properties and missing keyframes
    2222FAIL KeyframeEffect.getKeyframes() returns expected values for animations with CSS variables as keyframe values assert_equals: value for 'transform' on Keyframe #1 should match expected "translate(100px)" but got "matrix(1, 0, 0, 1, 100, 0)"
    2323PASS KeyframeEffect.getKeyframes() returns expected values for animations with CSS variables as keyframe values in a shorthand property
  • trunk/Source/WebCore/ChangeLog

    r287834 r287835  
     12022-01-10  Antoine Quint  <graouts@webkit.org>
     2
     3        [Web Animations] getKeyframes() for a CSS Animation should not use computed style for keyframes (part 2)
     4        https://bugs.webkit.org/show_bug.cgi?id=235028
     5
     6        Reviewed by Antti Koivisto.
     7
     8        In bug 235008, we already improved the situtation by reading from the StyleProperties
     9        associated with the StyleRuleKeyframe for CSS Animations. We're now taking the next
     10        step by reading from the matching rules for the provided element.
     11
     12        There is one remaining case where we use the computed style: when the CSSValue uses
     13        a CSS variable. To fix the css/css-animations/KeyframeEffect-getKeyframes.tentative.html
     14        WPT entirely, we'll need to be able to substitute those in the output.
     15
     16        * animation/KeyframeEffect.cpp:
     17        (WebCore::KeyframeEffect::getKeyframes):
     18
    1192022-01-10  Nikolas Zimmermann  <nzimmermann@igalia.com>
    220
  • trunk/Source/WebCore/animation/KeyframeEffect.cpp

    r287827 r287835  
    666666        };
    667667
     668        auto styleProperties = MutableStyleProperties::create();
     669        if (m_blendingKeyframesSource == BlendingKeyframesSource::CSSAnimation) {
     670            auto matchingRules = m_target->styleResolver().pseudoStyleRulesForElement(target, m_pseudoId, Style::Resolver::AllCSSRules);
     671            for (auto& matchedRule : matchingRules)
     672                styleProperties->mergeAndOverrideOnConflict(matchedRule->properties());
     673            if (is<StyledElement>(m_target) && m_pseudoId == PseudoId::None) {
     674                if (auto* inlineProperties = downcast<StyledElement>(*m_target).inlineStyle())
     675                    styleProperties->mergeAndOverrideOnConflict(*inlineProperties);
     676            }
     677        }
     678
    668679        // We need to establish which properties are implicit for 0% and 100%.
    669680        HashSet<CSSPropertyID> zeroKeyframeProperties = computedKeyframes.properties();
     
    693704
    694705            auto& keyframe = computedKeyframes[i];
     706            auto& style = *keyframe.style();
     707            auto* keyframeRule = keyframeRuleForKey(keyframe.key());
    695708
    696709            // 2. Set offset, computedOffset, easing members of output keyframe to the respective values keyframe offset, computed keyframe offset,
     
    704717            auto outputKeyframe = convertDictionaryToJS(lexicalGlobalObject, *jsCast<JSDOMGlobalObject*>(&lexicalGlobalObject), computedKeyframe);
    705718
    706             auto addPropertyToKeyframe = [&](CSSPropertyID cssPropertyId, String idlValue) {
     719            auto addPropertyToKeyframe = [&](CSSPropertyID cssPropertyId) {
    707720                // 1. Let property name be the result of applying the animation property name to IDL attribute name algorithm to the property name of declaration.
    708721                auto propertyName = CSSPropertyIDToIDLAttributeName(cssPropertyId);
    709722                // 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.
    710                 // 3. Let value be the result of converting IDL value to an ECMAScript String value.
    711                 auto value = toJS<IDLDOMString>(lexicalGlobalObject, idlValue);
    712                 // 4. Call the [[DefineOwnProperty]] internal method on output keyframe with property name property name,
    713                 //    Property Descriptor { [[Writable]]: true, [[Enumerable]]: true, [[Configurable]]: true, [[Value]]: value } and Boolean flag false.
    714                 JSObject::defineOwnProperty(outputKeyframe, &lexicalGlobalObject, AtomString(propertyName).impl(), PropertyDescriptor(value, 0), false);
    715             };
    716 
    717             // 3. For each animation property-value pair specified on keyframe, declaration, perform the following steps:
    718             auto& style = *keyframe.style();
    719             auto* keyframeRule = keyframeRuleForKey(keyframe.key());
    720             for (auto cssPropertyId : keyframe.properties()) {
    721                 if (cssPropertyId == CSSPropertyCustom)
    722                     continue;
    723723                String idlValue = "";
    724724                if (keyframeRule) {
     
    729729                }
    730730                if (idlValue.isEmpty()) {
     731                    if (auto cssValue = styleProperties->getPropertyCSSValue(cssPropertyId)) {
     732                        if (!cssValue->hasVariableReferences())
     733                            idlValue = styleProperties->getPropertyValue(cssPropertyId);
     734                    }
     735                }
     736                if (idlValue.isEmpty()) {
    731737                    if (auto cssValue = computedStyleExtractor.valueForPropertyInStyle(style, cssPropertyId, renderer))
    732738                        idlValue = cssValue->cssText();
    733739                }
    734                 addPropertyToKeyframe(cssPropertyId, idlValue);
     740                // 3. Let value be the result of converting IDL value to an ECMAScript String value.
     741                auto value = toJS<IDLDOMString>(lexicalGlobalObject, idlValue);
     742                // 4. Call the [[DefineOwnProperty]] internal method on output keyframe with property name property name,
     743                //    Property Descriptor { [[Writable]]: true, [[Enumerable]]: true, [[Configurable]]: true, [[Value]]: value } and Boolean flag false.
     744                JSObject::defineOwnProperty(outputKeyframe, &lexicalGlobalObject, AtomString(propertyName).impl(), PropertyDescriptor(value, 0), false);
     745            };
     746
     747            // 3. For each animation property-value pair specified on keyframe, declaration, perform the following steps:
     748            for (auto cssPropertyId : keyframe.properties()) {
     749                if (cssPropertyId == CSSPropertyCustom)
     750                    continue;
     751                addPropertyToKeyframe(cssPropertyId);
    735752            }
    736753
     
    738755            if (lastStyleChangeEventStyle) {
    739756                if (!keyframe.key()) {
    740                     for (auto cssPropertyId : zeroKeyframeProperties) {
    741                         if (auto cssValue = computedStyleExtractor.valueForPropertyInStyle(*lastStyleChangeEventStyle, cssPropertyId, renderer))
    742                             addPropertyToKeyframe(cssPropertyId, cssValue->cssText());
    743                     }
     757                    for (auto cssPropertyId : zeroKeyframeProperties)
     758                        addPropertyToKeyframe(cssPropertyId);
    744759                    zeroKeyframeProperties.clear();
    745760                } else if (keyframe.key() == 1) {
    746                     for (auto cssPropertyId : oneKeyframeProperties) {
    747                         if (auto cssValue = computedStyleExtractor.valueForPropertyInStyle(*lastStyleChangeEventStyle, cssPropertyId, renderer))
    748                             addPropertyToKeyframe(cssPropertyId, cssValue->cssText());
    749                     }
     761                    for (auto cssPropertyId : oneKeyframeProperties)
     762                        addPropertyToKeyframe(cssPropertyId);
    750763                    oneKeyframeProperties.clear();
    751764                }
Note: See TracChangeset for help on using the changeset viewer.