Changeset 228710 in webkit


Ignore:
Timestamp:
Feb 19, 2018 2:01:51 PM (6 years ago)
Author:
graouts@webkit.org
Message:

[Web Animations] Decouple parsing JS keyframes and computing blending keyframes
https://bugs.webkit.org/show_bug.cgi?id=182939
<rdar://problem/37678364>

Reviewed by Dean Jackson.

Move all the code used to create the KeyframeList into a dedicated updateBlendingKeyframes() method.

No new tests since this code change has no user-visible impact.

  • animation/KeyframeEffectReadOnly.cpp:

(WebCore::KeyframeEffectReadOnly::processKeyframes):
(WebCore::KeyframeEffectReadOnly::updateBlendingKeyframes):

  • animation/KeyframeEffectReadOnly.h:
Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r228709 r228710  
     12018-02-19  Antoine Quint  <graouts@apple.com>
     2
     3        [Web Animations] Decouple parsing JS keyframes and computing blending keyframes
     4        https://bugs.webkit.org/show_bug.cgi?id=182939
     5        <rdar://problem/37678364>
     6
     7        Reviewed by Dean Jackson.
     8
     9        Move all the code used to create the KeyframeList into a dedicated updateBlendingKeyframes() method.
     10
     11        No new tests since this code change has no user-visible impact.
     12
     13        * animation/KeyframeEffectReadOnly.cpp:
     14        (WebCore::KeyframeEffectReadOnly::processKeyframes):
     15        (WebCore::KeyframeEffectReadOnly::updateBlendingKeyframes):
     16        * animation/KeyframeEffectReadOnly.h:
     17
    1182018-02-19  Jer Noble  <jer.noble@apple.com>
    219
  • trunk/Source/WebCore/animation/KeyframeEffectReadOnly.cpp

    r228702 r228710  
    556556    computeMissingKeyframeOffsets(parsedKeyframes);
    557557
     558    // 8. For each frame in processed keyframes, perform the following steps:
     559    for (auto& keyframe : parsedKeyframes) {
     560        // Let the timing function of frame be the result of parsing the “easing” property on frame using the CSS syntax
     561        // defined for the easing property of the AnimationEffectTimingReadOnly interface.
     562        // If parsing the “easing” property fails, throw a TypeError and abort this procedure.
     563        auto timingFunctionResult = TimingFunction::createFromCSSText(keyframe.easing);
     564        if (timingFunctionResult.hasException())
     565            return timingFunctionResult.releaseException();
     566        keyframe.timingFunction = timingFunctionResult.returnValue();
     567    }
     568
     569    // 9. Parse each of the values in unused easings using the CSS syntax defined for easing property of the
     570    //    AnimationEffectTimingReadOnly interface, and if any of the values fail to parse, throw a TypeError
     571    //    and abort this procedure.
     572    for (auto& easing : unusedEasings) {
     573        auto timingFunctionResult = TimingFunction::createFromCSSText(easing);
     574        if (timingFunctionResult.hasException())
     575            return timingFunctionResult.releaseException();
     576    }
     577
     578    m_parsedKeyframes = WTFMove(parsedKeyframes);
     579
     580    updateBlendingKeyframes();
     581
     582    return { };
     583}
     584
     585void KeyframeEffectReadOnly::updateBlendingKeyframes()
     586{
     587    if (!m_target)
     588        return;
     589
    558590    KeyframeList keyframeList("keyframe-effect-" + createCanonicalUUIDString());
    559591    StyleResolver& styleResolver = m_target->styleResolver();
    560592
    561     // 8. For each frame in processed keyframes, perform the following steps:
    562     for (auto& keyframe : parsedKeyframes) {
    563         // 1. For each property-value pair in frame, parse the property value using the syntax specified for that property.
    564         //    If the property value is invalid according to the syntax for the property, discard the property-value pair.
    565         //    User agents that provide support for diagnosing errors in content SHOULD produce an appropriate warning
    566         //    highlighting the invalid property value.
    567 
     593    for (auto& keyframe : m_parsedKeyframes) {
    568594        KeyframeValue keyframeValue(keyframe.computedOffset, nullptr);
    569595        auto renderStyle = RenderStyle::createPtr();
     596        // We need to call update() on the FontCascade or we'll hit an ASSERT when parsing font-related properties.
     597        renderStyle->fontCascade().update(nullptr);
     598
    570599        auto& styleProperties = keyframe.style;
    571600        for (unsigned i = 0; i < styleProperties->propertyCount(); ++i) {
     
    579608        keyframeValue.setStyle(RenderStyle::clonePtr(*renderStyle));
    580609        keyframeList.insert(WTFMove(keyframeValue));
    581 
    582         // 2. Let the timing function of frame be the result of parsing the “easing” property on frame using the CSS syntax
    583         //    defined for the easing property of the AnimationEffectTimingReadOnly interface.
    584         //    If parsing the “easing” property fails, throw a TypeError and abort this procedure.
    585         auto timingFunctionResult = TimingFunction::createFromCSSText(keyframe.easing);
    586         if (timingFunctionResult.hasException())
    587             return timingFunctionResult.releaseException();
    588         keyframe.timingFunction = timingFunctionResult.returnValue();
    589     }
    590 
    591     // 9. Parse each of the values in unused easings using the CSS syntax defined for easing property of the
    592     //    AnimationEffectTimingReadOnly interface, and if any of the values fail to parse, throw a TypeError
    593     //    and abort this procedure.
    594     for (auto& easing : unusedEasings) {
    595         auto timingFunctionResult = TimingFunction::createFromCSSText(easing);
    596         if (timingFunctionResult.hasException())
    597             return timingFunctionResult.releaseException();
    598610    }
    599611
    600612    m_blendingKeyframes = WTFMove(keyframeList);
    601     m_parsedKeyframes = WTFMove(parsedKeyframes);
    602613
    603614    computeStackingContextImpact();
    604 
    605     return { };
    606615}
    607616
  • trunk/Source/WebCore/animation/KeyframeEffectReadOnly.h

    r228702 r228710  
    120120    void setAnimatedPropertiesInStyle(RenderStyle&, double);
    121121    void computeStackingContextImpact();
     122    void updateBlendingKeyframes();
    122123    bool shouldRunAccelerated();
    123124
Note: See TracChangeset for help on using the changeset viewer.