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

darin at apple.com darin at apple.com
Thu Oct 29 20:44:43 UTC 2009


The following commit has been merged in the webkit-1.1 branch:
commit 418fa48ed61cc7beb3be6495de969c3775076249
Author: darin at apple.com <darin at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Wed Oct 14 21:45:27 2009 +0000

    JavaScriptCore: Additions so fix for https://bugs.webkit.org/show_bug.cgi?id=18994
    can build on Windows.
    
    Patch by Darin Adler <darin at apple.com> on 2009-10-14
    * wtf/MathExtras.h: Added llround and llroundf for Windows.
    
    WebCore: Stringify CSS units manually (without printf) to make the formatting
    locale-insensitive and obey CSS spec with respect to large values.
    
    Patch by Evan Martin <evan at chromium.org> on 2009-10-14
    Reviewed by Darin Adler.
    
    https://bugs.webkit.org/show_bug.cgi?id=18994
    
    * css/CSSPrimitiveValue.cpp:
    (WebCore::appendCSSDouble):
    (WebCore::formatWithUnits):
    (WebCore::CSSPrimitiveValue::cssText):
    
    LayoutTests: 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
    
    Patch by Evan Martin <evan at chromium.org> on 2009-10-14
    Reviewed by Darin Adler.
    
    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:
    
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@49585 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/JavaScriptCore/ChangeLog b/JavaScriptCore/ChangeLog
index e3f3cd9..9bfc973 100644
--- a/JavaScriptCore/ChangeLog
+++ b/JavaScriptCore/ChangeLog
@@ -1,3 +1,10 @@
+2009-10-14  Darin Adler  <darin at apple.com>
+
+        Additions so fix for https://bugs.webkit.org/show_bug.cgi?id=18994
+        can build on Windows.
+
+        * wtf/MathExtras.h: Added llround and llroundf for Windows.
+
 2009-10-14  Kevin Ollivier  <kevino at theolliviers.com>
 
         wx build fix. Set ENABLE_PLUGIN_PACKAGE_SIMPLE_HASH for plugins while we're still building stubs.
diff --git a/JavaScriptCore/wtf/MathExtras.h b/JavaScriptCore/wtf/MathExtras.h
index 324300d..556230e 100644
--- a/JavaScriptCore/wtf/MathExtras.h
+++ b/JavaScriptCore/wtf/MathExtras.h
@@ -102,6 +102,8 @@ inline bool signbit(double x) { struct ieee_double *p = (struct ieee_double *)&x
 
 #if COMPILER(MSVC) || COMPILER(RVCT)
 
+inline long long llround(double num) { return static_cast<long long>(num > 0 ? num + 0.5 : ceil(num - 0.5)); }
+inline long long llroundf(float num) { return static_cast<long long>(num > 0 ? num + 0.5f : ceil(num - 0.5f)); }
 inline long lround(double num) { return static_cast<long>(num > 0 ? num + 0.5 : ceil(num - 0.5)); }
 inline long lroundf(float num) { return static_cast<long>(num > 0 ? num + 0.5f : ceilf(num - 0.5f)); }
 inline double round(double num) { return num > 0 ? floor(num + 0.5) : ceil(num - 0.5); }
diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 8a44d50..31e105c 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,21 @@
+2009-10-14  Evan Martin  <evan at chromium.org>
+
+        Reviewed by Darin Adler.
+
+        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-14  Dirk Schulze  <krit at webkit.org>
 
         Reviewed by Nikolas Zimmermann.
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/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 2b77825..188693e 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,17 @@
+2009-10-14  Evan Martin  <evan at chromium.org>
+
+        Reviewed by Darin Adler.
+
+        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-14  Mark Seaborn  <mseaborn at google.com>
 
         Reviewed by Darin Adler.
diff --git a/WebCore/css/CSSPrimitiveValue.cpp b/WebCore/css/CSSPrimitiveValue.cpp
index 1f2c9ca..d2286bb 100644
--- a/WebCore/css/CSSPrimitiveValue.cpp
+++ b/WebCore/css/CSSPrimitiveValue.cpp
@@ -34,6 +34,8 @@
 #include "Rect.h"
 #include "RenderStyle.h"
 #include <wtf/ASCIICType.h>
+#include <wtf/MathExtras.h>
+#include <wtf/StringExtras.h>
 #include <wtf/StdLibExtras.h>
 
 #if ENABLE(DASHBOARD_SUPPORT)
@@ -684,6 +686,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 +762,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