[SCM] WebKit Debian packaging branch, webkit-1.1, updated. upstream/1.1.15.1-1414-gc69ee75

eric at webkit.org eric at webkit.org
Thu Oct 29 20:44:16 UTC 2009


The following commit has been merged in the webkit-1.1 branch:
commit 27964f1cbb2ef966784c0a1ef4c2aa776086ce09
Author: eric at webkit.org <eric at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Wed Oct 14 04:09:02 2009 +0000

    2009-10-13  Evan Martin  <evan at chromium.org>
    
            Reviewed by Adam Barth.
    
            Float formatting changes affect three tests:
            - large-number-round-trip now passes
            - opacity-float now passes and has more test cases
            - compound-2d-transforms output tweaked slightly
    
            https://bugs.webkit.org/show_bug.cgi?id=18994
    
            * fast/css/large-number-round-trip-expected.txt:
            * fast/css/opacity-float-expected.txt:
            * fast/css/opacity-float.html:
            * platform/mac/fast/css/opacity-float-expected.txt: Removed.
            * transforms/2d/compound-2d-transforms-expected.txt:
            * transforms/2d/compound-2d-transforms.html:
    2009-10-13  Evan Martin  <evan at chromium.org>
    
            Reviewed by Adam Barth.
    
            Stringify CSS units manually (without printf) to make the formatting
            locale-insensitive and obey CSS spec with respect to large values.
    
            https://bugs.webkit.org/show_bug.cgi?id=18994
    
            * css/CSSPrimitiveValue.cpp:
            (WebCore::appendCSSDouble):
            (WebCore::formatWithUnits):
            (WebCore::CSSPrimitiveValue::cssText):
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@49554 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index d75cad5..fe890e6 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,21 @@
+2009-10-13  Evan Martin  <evan at chromium.org>
+
+        Reviewed by Adam Barth.
+
+        Float formatting changes affect three tests:
+        - large-number-round-trip now passes
+        - opacity-float now passes and has more test cases
+        - compound-2d-transforms output tweaked slightly
+        
+        https://bugs.webkit.org/show_bug.cgi?id=18994
+
+        * fast/css/large-number-round-trip-expected.txt:
+        * fast/css/opacity-float-expected.txt:
+        * fast/css/opacity-float.html:
+        * platform/mac/fast/css/opacity-float-expected.txt: Removed.
+        * transforms/2d/compound-2d-transforms-expected.txt:
+        * transforms/2d/compound-2d-transforms.html:
+
 2009-10-13  Zan Dobersek  <zandobersek at gmail.com>
 
         Reviewed by Holger Freyther.
diff --git a/LayoutTests/fast/css/large-number-round-trip-expected.txt b/LayoutTests/fast/css/large-number-round-trip-expected.txt
index c9c6dc1..4879544 100644
--- a/LayoutTests/fast/css/large-number-round-trip-expected.txt
+++ b/LayoutTests/fast/css/large-number-round-trip-expected.txt
@@ -1 +1 @@
-FAIL: read 90010000px back as 9.001e+07px, read again as 0px
+PASS: read 90010000px back as 90010000px, read again as 90010000px
diff --git a/LayoutTests/fast/css/opacity-float-expected.txt b/LayoutTests/fast/css/opacity-float-expected.txt
index f65ad1f..795a2c5 100644
--- a/LayoutTests/fast/css/opacity-float-expected.txt
+++ b/LayoutTests/fast/css/opacity-float-expected.txt
@@ -1,3 +1,17 @@
 This test verifies that reading a floating-point opacity from CSS attributes gets back a properly-formatted float. Improperly handling locales that cause decimals to be written as commas might break it.
 
 PASS
+PASS
+PASS
+PASS
+PASS
+PASS
+PASS
+PASS
+PASS
+PASS
+PASS
+PASS
+PASS
+PASS
+
diff --git a/LayoutTests/fast/css/opacity-float.html b/LayoutTests/fast/css/opacity-float.html
index 0ef0456..8405aeb 100644
--- a/LayoutTests/fast/css/opacity-float.html
+++ b/LayoutTests/fast/css/opacity-float.html
@@ -15,9 +15,34 @@ it.</p>
 <a id='test' style='opacity:.9'></a>
 
 <script>
-var opacity = document.getElementById('test').style.opacity.toString();
-if (opacity == '0.9')
-    document.write('PASS');
-else
-    document.write('FAIL: ' + opacity);
+var test = document.getElementById('test');
+
+function doTest(expected, input) {
+    test.style.opacity = input;
+    var opacity = test.style.opacity.toString();
+    if (opacity == expected)
+        document.write('PASS');
+    else
+        document.write('FAIL: expected ' + expected + ', got ' + opacity);
+    document.write('<br>');
+}
+
+var tests = [['0.9', '0.9'],
+             ['98765432198', '98765432198'],
+             ['9870000', '9870000'],
+             ['0.000321', '0.000321'],
+             ['50.02', '50.02'],
+             // Check we clip precision to six decimals.
+             ['1234.567891', '1234.567891234']];
+for (var i = 0; i < tests.length; i++)
+    doTest(tests[i][0], tests[i][1]);
+
+// Test a too-small value.
+doTest('0', '0.0000001');
+// Test that a beyond-precision digit will be rounded in.
+doTest('0.000001', '0.0000009');
+
+// Run the test list again with negatives.
+for (var i = 0; i < tests.length; i++)
+    doTest('-' + tests[i][0], '-' + tests[i][1]);
 </script>
diff --git a/LayoutTests/platform/mac/fast/css/opacity-float-expected.txt b/LayoutTests/platform/mac/fast/css/opacity-float-expected.txt
deleted file mode 100644
index b81983d..0000000
--- a/LayoutTests/platform/mac/fast/css/opacity-float-expected.txt
+++ /dev/null
@@ -1,3 +0,0 @@
-This test verifies that reading a floating-point opacity from CSS attributes gets back a properly-formatted float. Improperly handling locales that cause decimals to be written as commas might break it.
-
-FAIL: 0,9
diff --git a/LayoutTests/transforms/2d/compound-2d-transforms-expected.txt b/LayoutTests/transforms/2d/compound-2d-transforms-expected.txt
index 5583bd0..0f52716 100644
--- a/LayoutTests/transforms/2d/compound-2d-transforms-expected.txt
+++ b/LayoutTests/transforms/2d/compound-2d-transforms-expected.txt
@@ -6,12 +6,12 @@ transform "scale(1.7)" expected "matrix(1.7, 0, 0, 1.7, 0, 0)" : PASS
 transform "skew(12deg)" expected "matrix(1, 0, 0.212557, 1, 0, 0)" : PASS
 transform "matrix(0.978148, 0.207912, -0.207912, 0.978148, 50, 20)" expected "matrix(0.978148, 0.207912, -0.207912, 0.978148, 50, 20)" : PASS
 transform "translate(50px, 20px) rotate(12deg)" expected "matrix(0.978148, 0.207912, -0.207912, 0.978148, 50, 20)" : PASS
-transform "rotate(12deg) translate(50px, 20px)" expected "matrix(0.978148, 0.207912, -0.207912, 0.978148, 44.7491, 29.9585)" : PASS
-transform "rotate(12deg) translate(50px, 20px) scale(1.4)" expected "matrix(1.36941, 0.291076, -0.291076, 1.36941, 44.7491, 29.9585)" : PASS
-transform "scale(1.4) rotate(12deg) translate(50px, 20px) " expected "matrix(1.36941, 0.291076, -0.291076, 1.36941, 62.6488, 41.942)" : PASS
-transform "scale(1.4) translate(50px, 20px) rotate(12deg)" expected "matrix(1.36941, 0.291076, -0.291076, 1.36941, 70, 28)" : PASS
-transform "translate(50px, 20px) rotate(12deg) translateY(50px) scale(1.4)" expected "matrix(1.36941, 0.291076, -0.291076, 1.36941, 39.6044, 68.9074)" : PASS
-transform "rotate(12deg) translate(50px, 20px) scale(1.4) translate(-80px, 40px) skew(34deg) translate(10px, 10px) scale(0.7) skewY(-25deg) rotate(21deg) translateX(50px) scale(1.4, 1.8)" expected "matrix(1.20517, 0.148207, 0.258987, 2.04004, -13.3847, 85.31)" : PASS
+transform "rotate(12deg) translate(50px, 20px)" expected "matrix(0.978148, 0.207912, -0.207912, 0.978148, 44.749146, 29.958537)" : PASS
+transform "rotate(12deg) translate(50px, 20px) scale(1.4)" expected "matrix(1.369407, 0.291076, -0.291076, 1.369407, 44.749146, 29.958537)" : PASS
+transform "scale(1.4) rotate(12deg) translate(50px, 20px) " expected "matrix(1.369407, 0.291076, -0.291076, 1.369407, 62.648805, 41.941951)" : PASS
+transform "scale(1.4) translate(50px, 20px) rotate(12deg)" expected "matrix(1.369407, 0.291076, -0.291076, 1.369407, 70, 28)" : PASS
+transform "translate(50px, 20px) rotate(12deg) translateY(50px) scale(1.4)" expected "matrix(1.369407, 0.291076, -0.291076, 1.369407, 39.604415, 68.90738)" : PASS
+transform "rotate(12deg) translate(50px, 20px) scale(1.4) translate(-80px, 40px) skew(34deg) translate(10px, 10px) scale(0.7) skewY(-25deg) rotate(21deg) translateX(50px) scale(1.4, 1.8)" expected "matrix(1.205166, 0.148207, 0.258987, 2.040044, -13.384723, 85.309967)" : PASS
 transform ",rotate(12deg) translate(50px, 20px)" expected "none" : PASS
 transform "rotate(12deg), translate(50px, 20px)" expected "none" : PASS
 transform "rotate(12deg) + translate(50px, 20px)" expected "none" : PASS
diff --git a/LayoutTests/transforms/2d/compound-2d-transforms.html b/LayoutTests/transforms/2d/compound-2d-transforms.html
index 16003c3..7aa6691 100644
--- a/LayoutTests/transforms/2d/compound-2d-transforms.html
+++ b/LayoutTests/transforms/2d/compound-2d-transforms.html
@@ -43,17 +43,17 @@
       
       // two functions
       { 'transform' : 'translate(50px, 20px) rotate(12deg)',          'result' : 'matrix(0.978148, 0.207912, -0.207912, 0.978148, 50, 20)' },
-      { 'transform' : 'rotate(12deg) translate(50px, 20px)',          'result' : 'matrix(0.978148, 0.207912, -0.207912, 0.978148, 44.7491, 29.9585)' },
+      { 'transform' : 'rotate(12deg) translate(50px, 20px)',          'result' : 'matrix(0.978148, 0.207912, -0.207912, 0.978148, 44.749146, 29.958537)' },
 
       // three functions
-      { 'transform' : 'rotate(12deg) translate(50px, 20px) scale(1.4)',   'result' : 'matrix(1.36941, 0.291076, -0.291076, 1.36941, 44.7491, 29.9585)' },
-      { 'transform' : 'scale(1.4) rotate(12deg) translate(50px, 20px) ',  'result' : 'matrix(1.36941, 0.291076, -0.291076, 1.36941, 62.6488, 41.942)' },
-      { 'transform' : 'scale(1.4) translate(50px, 20px) rotate(12deg)',   'result' : 'matrix(1.36941, 0.291076, -0.291076, 1.36941, 70, 28)' },
-      { 'transform' : 'translate(50px, 20px) rotate(12deg) translateY(50px) scale(1.4)',   'result' : 'matrix(1.36941, 0.291076, -0.291076, 1.36941, 39.6044, 68.9074)' },
+      { 'transform' : 'rotate(12deg) translate(50px, 20px) scale(1.4)',   'result' : 'matrix(1.369407, 0.291076, -0.291076, 1.369407, 44.749146, 29.958537)' },
+      { 'transform' : 'scale(1.4) rotate(12deg) translate(50px, 20px) ',  'result' : 'matrix(1.369407, 0.291076, -0.291076, 1.369407, 62.648805, 41.941951)' },
+      { 'transform' : 'scale(1.4) translate(50px, 20px) rotate(12deg)',   'result' : 'matrix(1.369407, 0.291076, -0.291076, 1.369407, 70, 28)' },
+      { 'transform' : 'translate(50px, 20px) rotate(12deg) translateY(50px) scale(1.4)',   'result' : 'matrix(1.369407, 0.291076, -0.291076, 1.369407, 39.604415, 68.90738)' },
 
       // lots of functions
       { 'transform' : 'rotate(12deg) translate(50px, 20px) scale(1.4) translate(-80px, 40px) skew(34deg) translate(10px, 10px) scale(0.7) skewY(-25deg) rotate(21deg) translateX(50px) scale(1.4, 1.8)', 
-        'result' : 'matrix(1.20517, 0.148207, 0.258987, 2.04004, -13.3847, 85.31)' },
+        'result' : 'matrix(1.205166, 0.148207, 0.258987, 2.040044, -13.384723, 85.309967)' },
         
       // invalid compound functions
       { 'transform' : ',rotate(12deg) translate(50px, 20px)', 'result' : 'none' }, // has comma
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 7a389d7..5ff9f71 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,5 +1,19 @@
 2009-10-13  Evan Martin  <evan at chromium.org>
 
+        Reviewed by Adam Barth.
+
+        Stringify CSS units manually (without printf) to make the formatting
+        locale-insensitive and obey CSS spec with respect to large values.
+        
+        https://bugs.webkit.org/show_bug.cgi?id=18994
+
+        * css/CSSPrimitiveValue.cpp:
+        (WebCore::appendCSSDouble):
+        (WebCore::formatWithUnits):
+        (WebCore::CSSPrimitiveValue::cssText):
+
+2009-10-13  Evan Martin  <evan at chromium.org>
+
         Reviewed by David Levin.
 
         Make grippy lines vertical on horizontal scrollbars in Linux Chrome.
diff --git a/WebCore/css/CSSPrimitiveValue.cpp b/WebCore/css/CSSPrimitiveValue.cpp
index 1f2c9ca..bf377e5 100644
--- a/WebCore/css/CSSPrimitiveValue.cpp
+++ b/WebCore/css/CSSPrimitiveValue.cpp
@@ -684,6 +684,71 @@ int CSSPrimitiveValue::getIdent()
     return m_value.ident;
 }
 
+static void appendCSSDouble(Vector<UChar>& vector, double value)
+{
+    // From the CSS specification section titled "Integers and real numbers",
+    // real numbers are only formatted as [sign] [digits] "." [digits].
+    // This differs from printf-style formatting in that exponents (e.g. 1.3e06)
+    // are not allowed.  Since NaN/inf are also not valid CSS values this
+    // function doesn't handle them.
+
+    // For compatibility with what was returned by older versions of
+    // WebKit, we target 6 digits of precision.
+    const int digitsAfterDecimalPoint = 6;
+    long long rounded = llround(fabs(value) * 1000000.0);
+    if (rounded == 0) {
+        vector.append('0');
+        return;
+    }
+
+    char buf[24];
+    int length = snprintf(buf, sizeof(buf), "%lld", rounded);
+    int decimalPoint = length - digitsAfterDecimalPoint;
+
+    // We are matching printf("%g")'s behavior and must trim trailing zeros,
+    // regardless of whether they're significant.
+    while (length > 0 && length > decimalPoint && buf[length - 1] == '0')
+        length--;
+
+    // Reserve an estimate of space for the number of digits we anticipate
+    // along with a minus sign/initial zero/decimal point.
+    vector.reserveCapacity(vector.size() + 3 + length);
+
+    if (value < 0)
+        vector.append('-');
+
+    if (decimalPoint <= 0) {
+        // Only digits after the decimal point.
+        vector.append('0');
+        vector.append('.');
+        for (int i = decimalPoint; i < 0; i++)
+            vector.append('0');
+        for (int i = 0; i < length; i++)
+            vector.append(buf[i]);
+    } else if (length <= decimalPoint) {
+        // Only digits before the decimal point.
+        for (int i = 0; i < length; i++)
+            vector.append(buf[i]);
+    } else {
+        // Digits before and after the decimal point.
+        for (int i = 0; i < decimalPoint; i++)
+            vector.append(buf[i]);
+        vector.append('.');
+        for (int i = decimalPoint; i < length; i++)
+            vector.append(buf[i]);
+    }
+}
+
+static String formatWithUnits(double value, const char* units)
+{
+    Vector<UChar> result;
+    appendCSSDouble(result, value);
+    result.reserveCapacity(result.size() + strlen(units));
+    for (int i = 0; units[i]; i++)
+        result.append(units[i]);
+    return String::adopt(result);
+}
+
 String CSSPrimitiveValue::cssText() const
 {
     // FIXME: return the original value instead of a generated one (e.g. color
@@ -695,61 +760,61 @@ String CSSPrimitiveValue::cssText() const
             break;
         case CSS_NUMBER:
         case CSS_PARSER_INTEGER:
-            text = String::number(m_value.num);
+            text = formatWithUnits(m_value.num, "");
             break;
         case CSS_PERCENTAGE:
-            text = String::format("%.6lg%%", m_value.num);
+            text = formatWithUnits(m_value.num, "%");
             break;
         case CSS_EMS:
-            text = String::format("%.6lgem", m_value.num);
+            text = formatWithUnits(m_value.num, "em");
             break;
         case CSS_EXS:
-            text = String::format("%.6lgex", m_value.num);
+            text = formatWithUnits(m_value.num, "ex");
             break;
         case CSS_REMS:
-            text = String::format("%.6lgrem", m_value.num);
+            text = formatWithUnits(m_value.num, "rem");
             break;
         case CSS_PX:
-            text = String::format("%.6lgpx", m_value.num);
+            text = formatWithUnits(m_value.num, "px");
             break;
         case CSS_CM:
-            text = String::format("%.6lgcm", m_value.num);
+            text = formatWithUnits(m_value.num, "cm");
             break;
         case CSS_MM:
-            text = String::format("%.6lgmm", m_value.num);
+            text = formatWithUnits(m_value.num, "mm");
             break;
         case CSS_IN:
-            text = String::format("%.6lgin", m_value.num);
+            text = formatWithUnits(m_value.num, "in");
             break;
         case CSS_PT:
-            text = String::format("%.6lgpt", m_value.num);
+            text = formatWithUnits(m_value.num, "pt");
             break;
         case CSS_PC:
-            text = String::format("%.6lgpc", m_value.num);
+            text = formatWithUnits(m_value.num, "pc");
             break;
         case CSS_DEG:
-            text = String::format("%.6lgdeg", m_value.num);
+            text = formatWithUnits(m_value.num, "deg");
             break;
         case CSS_RAD:
-            text = String::format("%.6lgrad", m_value.num);
+            text = formatWithUnits(m_value.num, "rad");
             break;
         case CSS_GRAD:
-            text = String::format("%.6lggrad", m_value.num);
+            text = formatWithUnits(m_value.num, "grad");
             break;
         case CSS_MS:
-            text = String::format("%.6lgms", m_value.num);
+            text = formatWithUnits(m_value.num, "ms");
             break;
         case CSS_S:
-            text = String::format("%.6lgs", m_value.num);
+            text = formatWithUnits(m_value.num, "s");
             break;
         case CSS_HZ:
-            text = String::format("%.6lghz", m_value.num);
+            text = formatWithUnits(m_value.num, "hz");
             break;
         case CSS_KHZ:
-            text = String::format("%.6lgkhz", m_value.num);
+            text = formatWithUnits(m_value.num, "khz");
             break;
         case CSS_TURN:
-            text = String::format("%.6lgturn", m_value.num);
+            text = formatWithUnits(m_value.num, "turn");
             break;
         case CSS_DIMENSION:
             // FIXME

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list