Title: [106254] trunk/Source
Revision
106254
Author
msab...@apple.com
Date
2012-01-30 10:22:50 -0800 (Mon, 30 Jan 2012)

Log Message

Dromaeo tests call parseSimpleLengthValue() on 8 bit strings
https://bugs.webkit.org/show_bug.cgi?id=76649

Reviewed by Geoffrey Garen.

Source/_javascript_Core: 

* _javascript_Core.exp: Added export for charactersToDouble.

Source/WebCore: 

No functionality change, therefore no new tests.

Added 8 bit patch for parseSimpleLengthValue().

* css/CSSParser.cpp:
(WebCore::parseSimpleLengthValue):

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (106253 => 106254)


--- trunk/Source/_javascript_Core/ChangeLog	2012-01-30 18:10:43 UTC (rev 106253)
+++ trunk/Source/_javascript_Core/ChangeLog	2012-01-30 18:22:50 UTC (rev 106254)
@@ -1,5 +1,14 @@
 2012-01-30  Michael Saboff  <msab...@apple.com>
 
+        Dromaeo tests call parseSimpleLengthValue() on 8 bit strings
+        https://bugs.webkit.org/show_bug.cgi?id=76649
+
+        Reviewed by Geoffrey Garen.
+
+        * _javascript_Core.exp: Added export for charactersToDouble.
+
+2012-01-30  Michael Saboff  <msab...@apple.com>
+
         WebCore decodeEscapeSequences unnecessarily converts 8 bit strings to 16 bit when decoding.
         https://bugs.webkit.org/show_bug.cgi?id=76648
 

Modified: trunk/Source/_javascript_Core/_javascript_Core.exp (106253 => 106254)


--- trunk/Source/_javascript_Core/_javascript_Core.exp	2012-01-30 18:10:43 UTC (rev 106253)
+++ trunk/Source/_javascript_Core/_javascript_Core.exp	2012-01-30 18:22:50 UTC (rev 106254)
@@ -451,6 +451,7 @@
 __ZN3WTF17equalIgnoringCaseEPNS_10StringImplES1_
 __ZN3WTF18calculateDSTOffsetEdd
 __ZN3WTF18calculateUTCOffsetEv
+__ZN3WTF18charactersToDoubleEPKhmPbS2_
 __ZN3WTF18charactersToDoubleEPKtmPbS2_
 __ZN3WTF18dateToDaysFrom1970Eiii
 __ZN3WTF18monthFromDayInYearEib

Modified: trunk/Source/WebCore/ChangeLog (106253 => 106254)


--- trunk/Source/WebCore/ChangeLog	2012-01-30 18:10:43 UTC (rev 106253)
+++ trunk/Source/WebCore/ChangeLog	2012-01-30 18:22:50 UTC (rev 106254)
@@ -1,5 +1,19 @@
 2012-01-30  Michael Saboff  <msab...@apple.com>
 
+        Dromaeo tests call parseSimpleLengthValue() on 8 bit strings
+        https://bugs.webkit.org/show_bug.cgi?id=76649
+
+        Reviewed by Geoffrey Garen.
+
+        No functionality change, therefore no new tests.
+
+        Added 8 bit patch for parseSimpleLengthValue().
+
+        * css/CSSParser.cpp:
+        (WebCore::parseSimpleLengthValue):
+
+2012-01-30  Michael Saboff  <msab...@apple.com>
+
         WebCore decodeEscapeSequences unnecessarily converts 8 bit strings to 16 bit when decoding.
         https://bugs.webkit.org/show_bug.cgi?id=76648
 

Modified: trunk/Source/WebCore/css/CSSParser.cpp (106253 => 106254)


--- trunk/Source/WebCore/css/CSSParser.cpp	2012-01-30 18:10:43 UTC (rev 106253)
+++ trunk/Source/WebCore/css/CSSParser.cpp	2012-01-30 18:22:50 UTC (rev 106254)
@@ -411,28 +411,58 @@
 
 static bool parseSimpleLengthValue(CSSMutableStyleDeclaration* declaration, int propertyId, const String& string, bool important, bool strict, CSSStyleSheet* contextStyleSheet = 0)
 {
-    const UChar* characters = string.characters();
+    bool acceptsNegativeNumbers;
     unsigned length = string.length();
-    if (!characters || !length)
+
+    if (!length)
         return false;
-    bool acceptsNegativeNumbers;
-    if (!isSimpleLengthPropertyID(propertyId, acceptsNegativeNumbers))
-        return false;
 
+    double number;
+    bool ok;
     CSSPrimitiveValue::UnitTypes unit = CSSPrimitiveValue::CSS_NUMBER;
-    if (length > 2 && isASCIIAlphaCaselessEqual(characters[length - 2], 'p') && isASCIIAlphaCaselessEqual(characters[length - 1], 'x')) {
-        length -= 2;
-        unit = CSSPrimitiveValue::CSS_PX;
-    } else if (length > 1 && characters[length - 1] == '%') {
-        length -= 1;
-        unit = CSSPrimitiveValue::CSS_PERCENTAGE;
+
+    if (string.is8Bit()) {
+        const LChar* characters8 = string.characters8();
+        if (!characters8)
+            return false;
+
+        if (!isSimpleLengthPropertyID(propertyId, acceptsNegativeNumbers))
+            return false;
+
+        if (length > 2 && (characters8[length - 2] | 0x20) == 'p' && (characters8[length - 1] | 0x20) == 'x') {
+            length -= 2;
+            unit = CSSPrimitiveValue::CSS_PX;
+        } else if (length > 1 && characters8[length - 1] == '%') {
+            length -= 1;
+            unit = CSSPrimitiveValue::CSS_PERCENTAGE;
+        }
+
+        // We rely on charactersToDouble for validation as well. The function
+        // will set "ok" to "false" if the entire passed-in character range does
+        // not represent a double.
+        number = charactersToDouble(characters8, length, &ok);
+    } else {
+        const UChar* characters16 = string.characters16();
+        if (!characters16)
+            return false;
+
+        if (!isSimpleLengthPropertyID(propertyId, acceptsNegativeNumbers))
+            return false;
+
+        if (length > 2 && (characters16[length - 2] | 0x20) == 'p' && (characters16[length - 1] | 0x20) == 'x') {
+            length -= 2;
+            unit = CSSPrimitiveValue::CSS_PX;
+        } else if (length > 1 && characters16[length - 1] == '%') {
+            length -= 1;
+            unit = CSSPrimitiveValue::CSS_PERCENTAGE;
+        }
+
+        // We rely on charactersToDouble for validation as well. The function
+        // will set "ok" to "false" if the entire passed-in character range does
+        // not represent a double.
+        number = charactersToDouble(characters16, length, &ok);
     }
 
-    // We rely on charactersToDouble for validation as well. The function
-    // will set "ok" to "false" if the entire passed-in character range does
-    // not represent a double.
-    bool ok;
-    double number = charactersToDouble(characters, length, &ok);
     if (!ok)
         return false;
     if (unit == CSSPrimitiveValue::CSS_NUMBER) {
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to