Title: [224934] trunk/Source/WebCore
Revision
224934
Author
[email protected]
Date
2017-11-16 12:38:25 -0800 (Thu, 16 Nov 2017)

Log Message

Clean up KeyframeEffect
https://bugs.webkit.org/show_bug.cgi?id=179777

Patch by Antoine Quint <[email protected]> on 2017-11-16
Reviewed by Daniel Bates.

A few review comments came in after https://bugs.webkit.org/show_bug.cgi?id=179707 landed,
addressing them with this follow-up patch.

* animation/KeyframeEffect.cpp:
(WebCore::KeyframeEffect::create): Use "keyframeEffect" instead of "result" for clarity.
(WebCore::KeyframeEffect::processKeyframes): Use consistent index and length types while iterating
over properties in PropertyNameArray and explicitly size the properties array since we already
know its final size.
* dom/Element.cpp:
(WebCore::Element::getAnimations):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (224933 => 224934)


--- trunk/Source/WebCore/ChangeLog	2017-11-16 20:26:37 UTC (rev 224933)
+++ trunk/Source/WebCore/ChangeLog	2017-11-16 20:38:25 UTC (rev 224934)
@@ -1,3 +1,21 @@
+2017-11-16  Antoine Quint  <[email protected]>
+
+        Clean up KeyframeEffect
+        https://bugs.webkit.org/show_bug.cgi?id=179777
+
+        Reviewed by Daniel Bates.
+
+        A few review comments came in after https://bugs.webkit.org/show_bug.cgi?id=179707 landed,
+        addressing them with this follow-up patch.
+
+        * animation/KeyframeEffect.cpp:
+        (WebCore::KeyframeEffect::create): Use "keyframeEffect" instead of "result" for clarity.
+        (WebCore::KeyframeEffect::processKeyframes): Use consistent index and length types while iterating
+        over properties in PropertyNameArray and explicitly size the properties array since we already
+        know its final size.
+        * dom/Element.cpp:
+        (WebCore::Element::getAnimations):
+
 2017-11-16  Zalan Bujtas  <[email protected]>
 
         Always invoke RenderObject::insertedIntoTree/willBeRemovedFromTree

Modified: trunk/Source/WebCore/animation/KeyframeEffect.cpp (224933 => 224934)


--- trunk/Source/WebCore/animation/KeyframeEffect.cpp	2017-11-16 20:26:37 UTC (rev 224933)
+++ trunk/Source/WebCore/animation/KeyframeEffect.cpp	2017-11-16 20:38:25 UTC (rev 224934)
@@ -37,13 +37,13 @@
 
 ExceptionOr<Ref<KeyframeEffect>> KeyframeEffect::create(ExecState& state, Element* target, Strong<JSObject>&& keyframes)
 {
-    auto result = adoptRef(*new KeyframeEffect(target));
+    auto keyframeEffect = adoptRef(*new KeyframeEffect(target));
 
-    auto setKeyframesResult = result->setKeyframes(state, WTFMove(keyframes));
+    auto setKeyframesResult = keyframeEffect->setKeyframes(state, WTFMove(keyframes));
     if (setKeyframesResult.hasException())
         return setKeyframesResult.releaseException();
 
-    return WTFMove(result);
+    return WTFMove(keyframeEffect);
 }
 
 KeyframeEffect::KeyframeEffect(Element* target)
@@ -79,7 +79,7 @@
     StyleResolver& styleResolver = m_target->styleResolver();
     auto parserContext = CSSParserContext(HTMLStandardMode);
 
-    const auto* array = jsCast<const JSArray*>(keyframes.get());
+    auto* array = jsCast<const JSArray*>(keyframes.get());
     auto length = array->length();
     if (length != 2)
         return Exception { TypeError };
@@ -94,7 +94,7 @@
         size_t numberOfProperties = ownPropertyNames.size();
 
         StringBuilder cssText;
-        for (unsigned j = 0; j < numberOfProperties; ++j) {
+        for (size_t j = 0; j < numberOfProperties; ++j) {
             cssText.append(ownPropertyNames[j].string());
             cssText.appendLiteral(": ");
             cssText.append(keyframe->get(&state, ownPropertyNames[j]).toWTFString(&state));
@@ -106,9 +106,9 @@
         styleProperties->parseDeclaration(cssText.toString(), parserContext);
         unsigned numberOfCSSProperties = styleProperties->propertyCount();
 
-        Vector<CSSPropertyID> properties;
+        Vector<CSSPropertyID> properties(numberOfCSSProperties);
         for (unsigned k = 0; k < numberOfCSSProperties; ++k) {
-            properties.append(styleProperties->propertyAt(k).id());
+            properties[k] = styleProperties->propertyAt(k).id();
             styleResolver.applyPropertyToStyle(styleProperties->propertyAt(k).id(), styleProperties->propertyAt(k).value(), WTFMove(renderStyle));
             renderStyle = styleResolver.state().takeStyle();
         }

Modified: trunk/Source/WebCore/dom/Element.cpp (224933 => 224934)


--- trunk/Source/WebCore/dom/Element.cpp	2017-11-16 20:26:37 UTC (rev 224933)
+++ trunk/Source/WebCore/dom/Element.cpp	2017-11-16 20:38:25 UTC (rev 224934)
@@ -3708,7 +3708,7 @@
     // FIXME: Filter and order the list as specified (webkit.org/b/179535).
     if (auto timeline = document().existingTimeline())
         return timeline->animationsForElement(*this);
-    return Vector<RefPtr<WebAnimation>> { };
+    return { };
 }
 
 AccessibleNode* Element::accessibleNode()
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to