Title: [228710] trunk/Source/WebCore
Revision
228710
Author
grao...@webkit.org
Date
2018-02-19 14:01:51 -0800 (Mon, 19 Feb 2018)

Log 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:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (228709 => 228710)


--- trunk/Source/WebCore/ChangeLog	2018-02-19 21:22:15 UTC (rev 228709)
+++ trunk/Source/WebCore/ChangeLog	2018-02-19 22:01:51 UTC (rev 228710)
@@ -1,3 +1,20 @@
+2018-02-19  Antoine Quint  <grao...@apple.com>
+
+        [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:
+
 2018-02-19  Jer Noble  <jer.no...@apple.com>
 
         [EME] Add mechanism for MediaKeySession to react to HDCP changes

Modified: trunk/Source/WebCore/animation/KeyframeEffectReadOnly.cpp (228709 => 228710)


--- trunk/Source/WebCore/animation/KeyframeEffectReadOnly.cpp	2018-02-19 21:22:15 UTC (rev 228709)
+++ trunk/Source/WebCore/animation/KeyframeEffectReadOnly.cpp	2018-02-19 22:01:51 UTC (rev 228710)
@@ -555,33 +555,11 @@
     // since they can be computed up-front.
     computeMissingKeyframeOffsets(parsedKeyframes);
 
-    KeyframeList keyframeList("keyframe-effect-" + createCanonicalUUIDString());
-    StyleResolver& styleResolver = m_target->styleResolver();
-
     // 8. For each frame in processed keyframes, perform the following steps:
     for (auto& keyframe : parsedKeyframes) {
-        // 1. For each property-value pair in frame, parse the property value using the syntax specified for that property.
-        //    If the property value is invalid according to the syntax for the property, discard the property-value pair.
-        //    User agents that provide support for diagnosing errors in content SHOULD produce an appropriate warning
-        //    highlighting the invalid property value.
-
-        KeyframeValue keyframeValue(keyframe.computedOffset, nullptr);
-        auto renderStyle = RenderStyle::createPtr();
-        auto& styleProperties = keyframe.style;
-        for (unsigned i = 0; i < styleProperties->propertyCount(); ++i) {
-            auto cssPropertyId = styleProperties->propertyAt(i).id();
-            keyframeValue.addProperty(cssPropertyId);
-            keyframeList.addProperty(cssPropertyId);
-            styleResolver.applyPropertyToStyle(cssPropertyId, styleProperties->propertyAt(i).value(), WTFMove(renderStyle));
-            renderStyle = styleResolver.state().takeStyle();
-        }
-
-        keyframeValue.setStyle(RenderStyle::clonePtr(*renderStyle));
-        keyframeList.insert(WTFMove(keyframeValue));
-
-        // 2. Let the timing function of frame be the result of parsing the “easing” property on frame using the CSS syntax
-        //    defined for the easing property of the AnimationEffectTimingReadOnly interface.
-        //    If parsing the “easing” property fails, throw a TypeError and abort this procedure.
+        // Let the timing function of frame be the result of parsing the “easing” property on frame using the CSS syntax
+        // defined for the easing property of the AnimationEffectTimingReadOnly interface.
+        // If parsing the “easing” property fails, throw a TypeError and abort this procedure.
         auto timingFunctionResult = TimingFunction::createFromCSSText(keyframe.easing);
         if (timingFunctionResult.hasException())
             return timingFunctionResult.releaseException();
@@ -597,14 +575,45 @@
             return timingFunctionResult.releaseException();
     }
 
-    m_blendingKeyframes = WTFMove(keyframeList);
     m_parsedKeyframes = WTFMove(parsedKeyframes);
 
-    computeStackingContextImpact();
+    updateBlendingKeyframes();
 
     return { };
 }
 
+void KeyframeEffectReadOnly::updateBlendingKeyframes()
+{
+    if (!m_target)
+        return;
+
+    KeyframeList keyframeList("keyframe-effect-" + createCanonicalUUIDString());
+    StyleResolver& styleResolver = m_target->styleResolver();
+
+    for (auto& keyframe : m_parsedKeyframes) {
+        KeyframeValue keyframeValue(keyframe.computedOffset, nullptr);
+        auto renderStyle = RenderStyle::createPtr();
+        // We need to call update() on the FontCascade or we'll hit an ASSERT when parsing font-related properties.
+        renderStyle->fontCascade().update(nullptr);
+
+        auto& styleProperties = keyframe.style;
+        for (unsigned i = 0; i < styleProperties->propertyCount(); ++i) {
+            auto cssPropertyId = styleProperties->propertyAt(i).id();
+            keyframeValue.addProperty(cssPropertyId);
+            keyframeList.addProperty(cssPropertyId);
+            styleResolver.applyPropertyToStyle(cssPropertyId, styleProperties->propertyAt(i).value(), WTFMove(renderStyle));
+            renderStyle = styleResolver.state().takeStyle();
+        }
+
+        keyframeValue.setStyle(RenderStyle::clonePtr(*renderStyle));
+        keyframeList.insert(WTFMove(keyframeValue));
+    }
+
+    m_blendingKeyframes = WTFMove(keyframeList);
+
+    computeStackingContextImpact();
+}
+
 void KeyframeEffectReadOnly::computeStackingContextImpact()
 {
     m_triggersStackingContext = false;

Modified: trunk/Source/WebCore/animation/KeyframeEffectReadOnly.h (228709 => 228710)


--- trunk/Source/WebCore/animation/KeyframeEffectReadOnly.h	2018-02-19 21:22:15 UTC (rev 228709)
+++ trunk/Source/WebCore/animation/KeyframeEffectReadOnly.h	2018-02-19 22:01:51 UTC (rev 228710)
@@ -119,6 +119,7 @@
 private:
     void setAnimatedPropertiesInStyle(RenderStyle&, double);
     void computeStackingContextImpact();
+    void updateBlendingKeyframes();
     bool shouldRunAccelerated();
 
     bool m_triggersStackingContext { false };
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to