Title: [88214] trunk
Revision
88214
Author
simon.fra...@apple.com
Date
2011-06-06 21:12:32 -0700 (Mon, 06 Jun 2011)

Log Message

2011-06-06  Simon Fraser  <simon.fra...@apple.com>

        Reviewed by Dan Bernstein.

        Incorrect rounding of color values during transitions
        https://bugs.webkit.org/show_bug.cgi?id=62141

        When blending integers, round to the nearest integer, instead of always rounding down.

        Test: transitions/color-transition-rounding.html

        * page/animation/AnimationBase.cpp:
        (WebCore::blendFunc):

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (88213 => 88214)


--- trunk/LayoutTests/ChangeLog	2011-06-07 04:06:51 UTC (rev 88213)
+++ trunk/LayoutTests/ChangeLog	2011-06-07 04:12:32 UTC (rev 88214)
@@ -1,3 +1,15 @@
+2011-06-06  Simon Fraser  <simon.fra...@apple.com>
+
+        Reviewed by Dan Bernstein.
+
+        Incorrect rounding of color values during transitions
+        https://bugs.webkit.org/show_bug.cgi?id=62141
+        
+        Test that interpolates colors, and checks the rounding.
+
+        * transitions/color-transition-rounding-expected.txt: Added.
+        * transitions/color-transition-rounding.html: Added.
+
 2011-06-06  Noel Gordon  <noel.gor...@gmail.com>
 
         Reviewed by Hajime Morita.

Added: trunk/LayoutTests/transitions/color-transition-rounding-expected.txt (0 => 88214)


--- trunk/LayoutTests/transitions/color-transition-rounding-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/transitions/color-transition-rounding-expected.txt	2011-06-07 04:12:32 UTC (rev 88214)
@@ -0,0 +1,5 @@
+This test will probably fail when run manually; it requires the pause API for accurate results.
+PASS - "color" property for "test" element at 0.4998s saw something close to: 127,0,128
+PASS - "color" property for "test" element at 0.5s saw something close to: 128,0,128
+PASS - "color" property for "test" element at 0.5002s saw something close to: 128,0,127
+

Added: trunk/LayoutTests/transitions/color-transition-rounding.html (0 => 88214)


--- trunk/LayoutTests/transitions/color-transition-rounding.html	                        (rev 0)
+++ trunk/LayoutTests/transitions/color-transition-rounding.html	2011-06-07 04:12:32 UTC (rev 88214)
@@ -0,0 +1,40 @@
+<!DOCTYPE>
+
+<html>
+<head>
+  <style>
+    #test {
+      color: #00F;
+      -webkit-transition: color 1s linear;
+    }
+    
+    #test.changed {
+      color: #F00;
+    }
+  </style>
+  <script src=""
+  <script type="text/_javascript_">
+    const expectedValues = [
+      // [time, element-id, property, expected-value, tolerance, post-completion callback, should-be-transitioning]
+      [0.4998, 'test', 'color', [127, 0, 128], 0],
+      [0.5000, 'test', 'color', [128, 0, 128], 0],
+      [0.5002, 'test', 'color', [128, 0, 127], 0],
+    ];
+
+    function setupTest()
+    {
+      document.getElementById('test').className = 'changed';
+    }
+
+    runTransitionTest(expectedValues, setupTest, usePauseAPI);
+  </script>
+</head>
+<body>
+
+  <div id="test">
+    This test will probably fail when run manually; it requires the pause API for accurate results.
+  </div>
+  
+  <div id="result"></div>
+</body>
+</html>
\ No newline at end of file

Modified: trunk/Source/WebCore/ChangeLog (88213 => 88214)


--- trunk/Source/WebCore/ChangeLog	2011-06-07 04:06:51 UTC (rev 88213)
+++ trunk/Source/WebCore/ChangeLog	2011-06-07 04:12:32 UTC (rev 88214)
@@ -1,3 +1,17 @@
+2011-06-06  Simon Fraser  <simon.fra...@apple.com>
+
+        Reviewed by Dan Bernstein.
+
+        Incorrect rounding of color values during transitions
+        https://bugs.webkit.org/show_bug.cgi?id=62141
+        
+        When blending integers, round to the nearest integer, instead of always rounding down.
+
+        Test: transitions/color-transition-rounding.html
+
+        * page/animation/AnimationBase.cpp:
+        (WebCore::blendFunc):
+
 2011-06-06  Sheriff Bot  <webkit.review....@gmail.com>
 
         Unreviewed, rolling out r88202.

Modified: trunk/Source/WebCore/page/animation/AnimationBase.cpp (88213 => 88214)


--- trunk/Source/WebCore/page/animation/AnimationBase.cpp	2011-06-07 04:06:51 UTC (rev 88213)
+++ trunk/Source/WebCore/page/animation/AnimationBase.cpp	2011-06-07 04:12:32 UTC (rev 88214)
@@ -79,7 +79,7 @@
 
 static inline int blendFunc(const AnimationBase*, int from, int to, double progress)
 {  
-    return int(from + (to - from) * progress);
+    return lround(from + (to - from) * progress);
 }
 
 static inline double blendFunc(const AnimationBase*, double from, double to, double progress)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to