Title: [102608] trunk/Source/WebCore
Revision
102608
Author
simon.fra...@apple.com
Date
2011-12-12 11:16:20 -0800 (Mon, 12 Dec 2011)

Log Message

Share code that checks for matching sets of transform operations
https://bugs.webkit.org/show_bug.cgi?id=74265

Reviewed by Dan Bernstein.

Add TransformOperations::operationsMatch() and call it from the
three places that used this same code.

Tested by existing tests.

* page/animation/ImplicitAnimation.cpp:
(WebCore::ImplicitAnimation::validateTransformFunctionList):
* page/animation/KeyframeAnimation.cpp:
(WebCore::KeyframeAnimation::validateTransformFunctionList):
* platform/graphics/GraphicsLayer.cpp:
(WebCore::GraphicsLayer::fetchTransformOperationList):
* platform/graphics/transforms/TransformOperations.cpp:
(WebCore::TransformOperations::operationsMatch):
* platform/graphics/transforms/TransformOperations.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (102607 => 102608)


--- trunk/Source/WebCore/ChangeLog	2011-12-12 19:11:28 UTC (rev 102607)
+++ trunk/Source/WebCore/ChangeLog	2011-12-12 19:16:20 UTC (rev 102608)
@@ -1,3 +1,25 @@
+2011-12-12  Simon Fraser  <simon.fra...@apple.com>
+
+        Share code that checks for matching sets of transform operations
+        https://bugs.webkit.org/show_bug.cgi?id=74265
+
+        Reviewed by Dan Bernstein.
+        
+        Add TransformOperations::operationsMatch() and call it from the
+        three places that used this same code.
+        
+        Tested by existing tests.
+
+        * page/animation/ImplicitAnimation.cpp:
+        (WebCore::ImplicitAnimation::validateTransformFunctionList):
+        * page/animation/KeyframeAnimation.cpp:
+        (WebCore::KeyframeAnimation::validateTransformFunctionList):
+        * platform/graphics/GraphicsLayer.cpp:
+        (WebCore::GraphicsLayer::fetchTransformOperationList):
+        * platform/graphics/transforms/TransformOperations.cpp:
+        (WebCore::TransformOperations::operationsMatch):
+        * platform/graphics/transforms/TransformOperations.h:
+
 2011-12-12  Antti Koivisto  <an...@apple.com>
 
         Cache visited link hash

Modified: trunk/Source/WebCore/page/animation/ImplicitAnimation.cpp (102607 => 102608)


--- trunk/Source/WebCore/page/animation/ImplicitAnimation.cpp	2011-12-12 19:11:28 UTC (rev 102607)
+++ trunk/Source/WebCore/page/animation/ImplicitAnimation.cpp	2011-12-12 19:16:20 UTC (rev 102608)
@@ -263,21 +263,9 @@
     if (val->operations().isEmpty())
         return;
         
-    // See if the keyframes are valid
-    if (val != toVal) {
-        // A list of length 0 matches anything
-        if (!toVal->operations().isEmpty()) {
-            // If the sizes of the function lists don't match, the lists don't match
-            if (val->operations().size() != toVal->operations().size())
-                return;
-        
-            // If the types of each function are not the same, the lists don't match
-            for (size_t j = 0; j < val->operations().size(); ++j) {
-                if (!val->operations()[j]->isSameType(*toVal->operations()[j]))
-                    return;
-            }
-        }
-    }
+    // An emtpy transform list matches anything.
+    if (val != toVal && !toVal->operations().isEmpty() && !val->operationsMatch(*toVal))
+        return;
 
     // Keyframes are valid
     m_transformFunctionListValid = true;

Modified: trunk/Source/WebCore/page/animation/KeyframeAnimation.cpp (102607 => 102608)


--- trunk/Source/WebCore/page/animation/KeyframeAnimation.cpp	2011-12-12 19:11:28 UTC (rev 102607)
+++ trunk/Source/WebCore/page/animation/KeyframeAnimation.cpp	2011-12-12 19:16:20 UTC (rev 102608)
@@ -423,19 +423,12 @@
         const KeyframeValue& currentKeyframe = m_keyframes[i];
         const TransformOperations* val = &currentKeyframe.style()->transform();
         
-        // A null transform matches anything
+        // An emtpy transform list matches anything.
         if (val->operations().isEmpty())
             continue;
         
-        // If the sizes of the function lists don't match, the lists don't match
-        if (firstVal->operations().size() != val->operations().size())
+        if (!firstVal->operationsMatch(*val))
             return;
-        
-        // If the types of each function are not the same, the lists don't match
-        for (size_t j = 0; j < firstVal->operations().size(); ++j) {
-            if (!firstVal->operations()[j]->isSameType(*val->operations()[j]))
-                return;
-        }
     }
 
     // Keyframes are valid

Modified: trunk/Source/WebCore/platform/graphics/GraphicsLayer.cpp (102607 => 102608)


--- trunk/Source/WebCore/platform/graphics/GraphicsLayer.cpp	2011-12-12 19:11:28 UTC (rev 102607)
+++ trunk/Source/WebCore/platform/graphics/GraphicsLayer.cpp	2011-12-12 19:16:20 UTC (rev 102608)
@@ -392,17 +392,12 @@
     for (size_t i = firstIndex + 1; i < valueList.size(); ++i) {
         const TransformOperations* val = operationsAt(valueList, i);
         
-        // a null transform matches anything
+        // An emtpy transform list matches anything.
         if (val->operations().isEmpty())
             continue;
             
-        if (firstVal->operations().size() != val->operations().size())
+        if (!firstVal->operationsMatch(*val))
             return;
-            
-        for (size_t j = 0; j < firstVal->operations().size(); ++j) {
-            if (!firstVal->operations().at(j)->isSameType(*val->operations().at(j)))
-                return;
-        }
     }
 
     // Keyframes are valid, fill in the list.

Modified: trunk/Source/WebCore/platform/graphics/transforms/TransformOperations.cpp (102607 => 102608)


--- trunk/Source/WebCore/platform/graphics/transforms/TransformOperations.cpp	2011-12-12 19:11:28 UTC (rev 102607)
+++ trunk/Source/WebCore/platform/graphics/transforms/TransformOperations.cpp	2011-12-12 19:16:20 UTC (rev 102608)
@@ -46,4 +46,19 @@
     return true;
 }
 
+bool TransformOperations::operationsMatch(const TransformOperations& other) const
+{
+    size_t numOperations = operations().size();
+    // If the sizes of the function lists don't match, the lists don't match
+    if (numOperations != other.operations().size())
+        return false;
+    
+    // If the types of each function are not the same, the lists don't match
+    for (size_t i = 0; i < numOperations; ++i) {
+        if (!operations()[i]->isSameType(*other.operations()[i]))
+            return false;
+    }
+    return true;
+}
+
 } // namespace WebCore

Modified: trunk/Source/WebCore/platform/graphics/transforms/TransformOperations.h (102607 => 102608)


--- trunk/Source/WebCore/platform/graphics/transforms/TransformOperations.h	2011-12-12 19:11:28 UTC (rev 102607)
+++ trunk/Source/WebCore/platform/graphics/transforms/TransformOperations.h	2011-12-12 19:16:20 UTC (rev 102608)
@@ -58,6 +58,8 @@
         return false;
     }
     
+    bool operationsMatch(const TransformOperations&) const;
+    
     void clear()
     {
         m_operations.clear();
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to