[SCM] WebKit Debian packaging branch, debian/unstable, updated. debian/1.1.15-1-40151-g37bb677

darin darin at 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Sat Sep 26 06:48:37 UTC 2009


The following commit has been merged in the debian/unstable branch:
commit c18398e9705a6825f2cdc688d79af9e16b04bf2e
Author: darin <darin at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Thu Oct 10 06:30:48 2002 +0000

    	- fixed 3047782 -- Alexander rejects some color strings that other browsers accept
    
            * khtml/misc/helper.cpp: (khtml::setNamedColor): Put some of the code from this
    	level that tries to accomodate bad colors in #if !APPLE_CHANGES, since we do most
    	of the smarts in KWQ.
    
            * kwq/KWQColor.mm:
            (hex2int): Tolerate non-hex digits, treating them as 0.
            (decodeColorFromHexColorString): Trim any number of leading # characters, and trailing
    	" and ' characters. Handle strings of 4, 5, 7, 8, 10, and 11 hex digits, along with
    	the existing 3, 6, 9, and 12.
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@2298 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog-2002-12-03 b/WebCore/ChangeLog-2002-12-03
index a778984..b25ec7d 100644
--- a/WebCore/ChangeLog-2002-12-03
+++ b/WebCore/ChangeLog-2002-12-03
@@ -1,3 +1,17 @@
+2002-10-10  Darin Adler  <darin at apple.com>
+
+	- fixed 3047782 -- Alexander rejects some color strings that other browsers accept
+
+        * khtml/misc/helper.cpp: (khtml::setNamedColor): Put some of the code from this
+	level that tries to accomodate bad colors in #if !APPLE_CHANGES, since we do most
+	of the smarts in KWQ.
+
+        * kwq/KWQColor.mm:
+        (hex2int): Tolerate non-hex digits, treating them as 0.
+        (decodeColorFromHexColorString): Trim any number of leading # characters, and trailing
+	" and ' characters. Handle strings of 4, 5, 7, 8, 10, and 11 hex digits, along with
+	the existing 3, 6, 9, and 12.
+
 2002-10-10  David Hyatt  <hyatt at apple.com>
 
 	Fix a subtle bug with layers.  When a parent is sorted with its
diff --git a/WebCore/ChangeLog-2003-10-25 b/WebCore/ChangeLog-2003-10-25
index a778984..b25ec7d 100644
--- a/WebCore/ChangeLog-2003-10-25
+++ b/WebCore/ChangeLog-2003-10-25
@@ -1,3 +1,17 @@
+2002-10-10  Darin Adler  <darin at apple.com>
+
+	- fixed 3047782 -- Alexander rejects some color strings that other browsers accept
+
+        * khtml/misc/helper.cpp: (khtml::setNamedColor): Put some of the code from this
+	level that tries to accomodate bad colors in #if !APPLE_CHANGES, since we do most
+	of the smarts in KWQ.
+
+        * kwq/KWQColor.mm:
+        (hex2int): Tolerate non-hex digits, treating them as 0.
+        (decodeColorFromHexColorString): Trim any number of leading # characters, and trailing
+	" and ' characters. Handle strings of 4, 5, 7, 8, 10, and 11 hex digits, along with
+	the existing 3, 6, 9, and 12.
+
 2002-10-10  David Hyatt  <hyatt at apple.com>
 
 	Fix a subtle bug with layers.  When a parent is sorted with its
diff --git a/WebCore/ChangeLog-2005-08-23 b/WebCore/ChangeLog-2005-08-23
index a778984..b25ec7d 100644
--- a/WebCore/ChangeLog-2005-08-23
+++ b/WebCore/ChangeLog-2005-08-23
@@ -1,3 +1,17 @@
+2002-10-10  Darin Adler  <darin at apple.com>
+
+	- fixed 3047782 -- Alexander rejects some color strings that other browsers accept
+
+        * khtml/misc/helper.cpp: (khtml::setNamedColor): Put some of the code from this
+	level that tries to accomodate bad colors in #if !APPLE_CHANGES, since we do most
+	of the smarts in KWQ.
+
+        * kwq/KWQColor.mm:
+        (hex2int): Tolerate non-hex digits, treating them as 0.
+        (decodeColorFromHexColorString): Trim any number of leading # characters, and trailing
+	" and ' characters. Handle strings of 4, 5, 7, 8, 10, and 11 hex digits, along with
+	the existing 3, 6, 9, and 12.
+
 2002-10-10  David Hyatt  <hyatt at apple.com>
 
 	Fix a subtle bug with layers.  When a parent is sorted with its
diff --git a/WebCore/khtml/misc/helper.cpp b/WebCore/khtml/misc/helper.cpp
index 5ff4aa9..97541e1 100644
--- a/WebCore/khtml/misc/helper.cpp
+++ b/WebCore/khtml/misc/helper.cpp
@@ -206,21 +206,11 @@ void khtml::setNamedColor(QColor &color, const QString &_name)
         return;
     }
 
+#if !APPLE_CHANGES
+
     // also recognize "color=ffffff"
     if (len == 6)
     {
-#ifdef APPLE_CHANGES
-        // recognize #12345 (duplicate the last character)
-        if(name[0] == '#') {
-            name += name.right(1);
-        }
-        else if ((!name[0].isLetter() && !name[0].isDigit())) {
-	    color = QColor();
-	    return;
-	}
-        color.setNamedColor(name);
-        return;
-#else /* APPLE_CHANGES not defined */
         bool ok;
         int val = name.toInt(&ok, 16);
         if(ok)
@@ -241,7 +231,6 @@ void khtml::setNamedColor(QColor &color, const QString &_name)
 	    color = QColor();
 	    return;
 	}
-#endif /* APPLE_CHANGES not defined */
     }
 
     // #fffffff as found on msdn.microsoft.com
@@ -250,6 +239,8 @@ void khtml::setNamedColor(QColor &color, const QString &_name)
         name = name.left(7);
     }
 
+#endif
+
     if ( len > 4 && name[0].lower() == 'r' && name[1].lower() == 'g' &&
          name[2].lower() == 'b' && name[3] == '(' &&
          name[len-1] == ')')
diff --git a/WebCore/kwq/KWQColor.mm b/WebCore/kwq/KWQColor.mm
index 9449b6f..fd2ca03 100644
--- a/WebCore/kwq/KWQColor.mm
+++ b/WebCore/kwq/KWQColor.mm
@@ -223,6 +223,7 @@ QString QColor::name() const
     return name;
 }
 
+// This tolerates bad hex digits, because that's what other web browsers do too.
 static int hex2int(QChar hexchar)
 {
     int v;
@@ -234,7 +235,7 @@ static int hex2int(QChar hexchar)
     else if (hexchar >= 'a' && hexchar <= 'f')
 	v = hexchar.cell() - 'a' + 10;
     else
-	v = -1;
+	v = 0;
     
     return v;
 }
@@ -244,34 +245,52 @@ static bool decodeColorFromHexColorString(const QString &string, int *r, int *g,
     int len = string.length();
     int offset = 0;
     
-    if (len == 0)
-        return false;
-
-    if (string[0] == '#') {
+    while (len) {
+        QChar c = string[offset];
+        if (!(c == '#' || c == '"' || c == '\'')) {
+            break;
+        }
         len -= 1;
         offset += 1;
     }
     
-    for (int i = 0; i < len; i++)
-        if (hex2int(string[i+offset]) == -1)
-            return false;
+    while (len) {
+        QChar c = string[offset + len - 1];
+        if (!(c == '"' || c == '\'')) {
+            break;
+        }
+        len -= 1;
+    }
     
+    if (len == 0)
+        return false;
+
     switch (len) {
     case 12:
         *r = (hex2int(string[0+offset]) << 4) + hex2int(string[1+offset]);
         *g = (hex2int(string[4+offset]) << 4) + hex2int(string[5+offset]);
         *b = (hex2int(string[8+offset]) << 4) + hex2int(string[9+offset]);
         return true;
+    case 11:
+    case 10:
     case 9:
         *r = (hex2int(string[0+offset]) << 4) + hex2int(string[1+offset]);
         *g = (hex2int(string[3+offset]) << 4) + hex2int(string[4+offset]);
         *b = (hex2int(string[6+offset]) << 4) + hex2int(string[7+offset]);
         return true;
+    case 8:
+    case 7:
     case 6:
         *r = (hex2int(string[0+offset]) << 4) + hex2int(string[1+offset]);
         *g = (hex2int(string[2+offset]) << 4) + hex2int(string[3+offset]);
         *b = (hex2int(string[4+offset]) << 4) + hex2int(string[5+offset]);
         return true;
+    case 5:
+        *r = (hex2int(string[0+offset]) << 4) + hex2int(string[1+offset]);
+        *g = (hex2int(string[2+offset]) << 4) + hex2int(string[3+offset]);
+        *b = hex2int(string[4+offset]) * 0x11;
+        return true;
+    case 4:
     case 3:
         // Convert 0 to F to 0 to 255.
         *r = hex2int(string[0+offset]) * 0x11;

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list