[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

andreas.kling at nokia.com andreas.kling at nokia.com
Wed Dec 22 12:11:50 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit d449741118db9fe80cca4a8befa2c236bca6e850
Author: andreas.kling at nokia.com <andreas.kling at nokia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Tue Aug 17 01:09:46 2010 +0000

    2010-08-16  Andreas Kling  <andreas.kling at nokia.com>
    
            Reviewed by Darin Adler.
    
            CSS: Add fast-path for rgba() color parsing
            https://bugs.webkit.org/show_bug.cgi?id=42965
    
            Test: fast/canvas/rgba-parsing.html
    
            * css/CSSParser.cpp:
            (WebCore::CSSParser::parseColor): Extended with support for rgba().
            (WebCore::parseAlphaValue): Added, parses an alpha value using
            WTF::strtod() (if necessary) and clamps between 0 and 1.
            (WebCore::isTenthAlpha):
    2010-08-16  Andreas Kling  <andreas.kling at nokia.com>
    
            Reviewed by Darin Adler.
    
            CSS: Add fast-path for rgba() color parsing
            https://bugs.webkit.org/show_bug.cgi?id=42965
    
            Add a test of rgba() color parsing.
    
            * fast/canvas/rgba-parsing-expected.txt: Added.
            * fast/canvas/rgba-parsing.html: Added.
            * fast/canvas/script-tests/rgba-parsing.js: Added.
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@65475 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 16abf88..c5d8dc7 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,5 +1,18 @@
 2010-08-16  Andreas Kling  <andreas.kling at nokia.com>
 
+        Reviewed by Darin Adler.
+
+        CSS: Add fast-path for rgba() color parsing
+        https://bugs.webkit.org/show_bug.cgi?id=42965
+
+        Add a test of rgba() color parsing.
+
+        * fast/canvas/rgba-parsing-expected.txt: Added.
+        * fast/canvas/rgba-parsing.html: Added.
+        * fast/canvas/script-tests/rgba-parsing.js: Added.
+
+2010-08-16  Andreas Kling  <andreas.kling at nokia.com>
+
         Reviewed by Ariya Hidayat.
 
         [Qt] Path::closeSubpath() should only close the last subpath if it has >1 point
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 308108b..367c8e7 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,18 @@
+2010-08-16  Andreas Kling  <andreas.kling at nokia.com>
+
+        Reviewed by Darin Adler.
+
+        CSS: Add fast-path for rgba() color parsing
+        https://bugs.webkit.org/show_bug.cgi?id=42965
+
+        Test: fast/canvas/rgba-parsing.html
+
+        * css/CSSParser.cpp:
+        (WebCore::CSSParser::parseColor): Extended with support for rgba().
+        (WebCore::parseAlphaValue): Added, parses an alpha value using
+        WTF::strtod() (if necessary) and clamps between 0 and 1.
+        (WebCore::isTenthAlpha):
+
 2010-08-16  Kinuko Yasuda  <kinuko at chromium.org>
 
         Reviewed by Dumitru Daniliuc.
diff --git a/WebCore/css/CSSParser.cpp b/WebCore/css/CSSParser.cpp
index d45b3ec..e5126a9 100644
--- a/WebCore/css/CSSParser.cpp
+++ b/WebCore/css/CSSParser.cpp
@@ -291,7 +291,7 @@ bool CSSParser::parseValue(CSSMutableStyleDeclaration* declaration, int id, cons
 // possible to set up a default color.
 bool CSSParser::parseColor(RGBA32& color, const String& string, bool strict)
 {
-    // First try creating a color specified by name, rgb() or "#" syntax.
+    // First try creating a color specified by name, rgba(), rgb() or "#" syntax.
     if (parseColor(string, color, strict))
         return true;
 
@@ -3739,6 +3739,63 @@ static inline bool parseColorInt(const UChar*& string, const UChar* end, UChar t
     return true;
 }
 
+static inline bool isTenthAlpha(const UChar* string, const int length)
+{
+    // "0.X"
+    if (length == 3 && string[0] == '0' && string[1] == '.' && isASCIIDigit(string[2]))
+        return true;
+
+    // ".X"
+    if (length == 2 && string[0] == '.' && isASCIIDigit(string[1]))
+        return true;
+
+    return false;
+}
+
+static inline bool parseAlphaValue(const UChar*& string, const UChar* end, UChar terminator, int& value)
+{
+    while (string != end && isCSSWhitespace(*string))
+        string++;
+
+    value = 0;
+
+    int length = end - string;
+    if (length < 2)
+        return false;
+
+    if (string[0] != '0' && string[0] != '1' && string[0] != '.')
+        return false;
+
+    if (string[length - 1] != terminator)
+        return false;
+
+    if (length == 2 && string[0] != '.') {
+        value = string[0] == '1' ? 255 : 0;
+        string = end;
+        return true;
+    }
+
+    if (isTenthAlpha(string, length - 1)) {
+        static const int tenthAlphaValues[] = { 0, 25, 51, 76, 102, 127, 153, 179, 204, 230 };
+        value = tenthAlphaValues[string[length - 2] - '0'];
+        string = end;
+        return true;
+    }
+
+    Vector<char, 8> bytes(length + 1);
+    for (int i = 0; i < length; ++i) {
+        if (!isASCIIDigit(string[i]) && string[i] != '.' && string[i] != terminator)
+            return false;
+        bytes[i] = string[i];
+    }
+    bytes[length] = '\0';
+    char* foundTerminator;
+    double d = WTF::strtod(bytes.data(), &foundTerminator);
+    value = static_cast<int>(d * nextafter(256.0, 0.0));
+    string += (foundTerminator - bytes.data()) + 1;
+    return *foundTerminator == terminator;
+}
+
 bool CSSParser::parseColor(const String &name, RGBA32& rgb, bool strict)
 {
     const UChar* characters = name.characters();
@@ -3754,6 +3811,28 @@ bool CSSParser::parseColor(const String &name, RGBA32& rgb, bool strict)
         }
     }
 
+    // Try rgba() syntax.
+    if (name.startsWith("rgba(")) {
+        const UChar* current = characters + 5;
+        const UChar* end = characters + length;
+        int red;
+        int green;
+        int blue;
+        int alpha;
+        if (!parseColorInt(current, end, ',', red))
+            return false;
+        if (!parseColorInt(current, end, ',', green))
+            return false;
+        if (!parseColorInt(current, end, ',', blue))
+            return false;
+        if (!parseAlphaValue(current, end, ')', alpha))
+            return false;
+        if (current != end)
+            return false;
+        rgb = makeRGBA(red, green, blue, alpha);
+        return true;
+    }
+
     // Try rgb() syntax.
     if (name.startsWith("rgb(")) {
         const UChar* current = characters + 4;
@@ -3772,6 +3851,7 @@ bool CSSParser::parseColor(const String &name, RGBA32& rgb, bool strict)
         rgb = makeRGB(red, green, blue);
         return true;
     }
+
     // Try named colors.
     Color tc;
     tc.setNamedColor(name);

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list