Changeset 106254 in webkit


Ignore:
Timestamp:
Jan 30, 2012 10:22:50 AM (12 years ago)
Author:
msaboff@apple.com
Message:

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

Reviewed by Geoffrey Garen.

Source/JavaScriptCore:

Source/WebCore:

No functionality change, therefore no new tests.

Added 8 bit patch for parseSimpleLengthValue().

  • css/CSSParser.cpp:

(WebCore::parseSimpleLengthValue):

Location:
trunk/Source
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r106253 r106254  
     12012-01-30  Michael Saboff  <msaboff@apple.com>
     2
     3        Dromaeo tests call parseSimpleLengthValue() on 8 bit strings
     4        https://bugs.webkit.org/show_bug.cgi?id=76649
     5
     6        Reviewed by Geoffrey Garen.
     7
     8        * JavaScriptCore.exp: Added export for charactersToDouble.
     9
    1102012-01-30  Michael Saboff  <msaboff@apple.com>
    211
  • trunk/Source/JavaScriptCore/JavaScriptCore.exp

    r106197 r106254  
    452452__ZN3WTF18calculateDSTOffsetEdd
    453453__ZN3WTF18calculateUTCOffsetEv
     454__ZN3WTF18charactersToDoubleEPKhmPbS2_
    454455__ZN3WTF18charactersToDoubleEPKtmPbS2_
    455456__ZN3WTF18dateToDaysFrom1970Eiii
  • trunk/Source/WebCore/ChangeLog

    r106253 r106254  
     12012-01-30  Michael Saboff  <msaboff@apple.com>
     2
     3        Dromaeo tests call parseSimpleLengthValue() on 8 bit strings
     4        https://bugs.webkit.org/show_bug.cgi?id=76649
     5
     6        Reviewed by Geoffrey Garen.
     7
     8        No functionality change, therefore no new tests.
     9
     10        Added 8 bit patch for parseSimpleLengthValue().
     11
     12        * css/CSSParser.cpp:
     13        (WebCore::parseSimpleLengthValue):
     14
    1152012-01-30  Michael Saboff  <msaboff@apple.com>
    216
  • trunk/Source/WebCore/css/CSSParser.cpp

    r106227 r106254  
    412412static bool parseSimpleLengthValue(CSSMutableStyleDeclaration* declaration, int propertyId, const String& string, bool important, bool strict, CSSStyleSheet* contextStyleSheet = 0)
    413413{
    414     const UChar* characters = string.characters();
     414    bool acceptsNegativeNumbers;
    415415    unsigned length = string.length();
    416     if (!characters || !length)
    417         return false;
    418     bool acceptsNegativeNumbers;
    419     if (!isSimpleLengthPropertyID(propertyId, acceptsNegativeNumbers))
    420         return false;
    421 
     416
     417    if (!length)
     418        return false;
     419
     420    double number;
     421    bool ok;
    422422    CSSPrimitiveValue::UnitTypes unit = CSSPrimitiveValue::CSS_NUMBER;
    423     if (length > 2 && isASCIIAlphaCaselessEqual(characters[length - 2], 'p') && isASCIIAlphaCaselessEqual(characters[length - 1], 'x')) {
    424         length -= 2;
    425         unit = CSSPrimitiveValue::CSS_PX;
    426     } else if (length > 1 && characters[length - 1] == '%') {
    427         length -= 1;
    428         unit = CSSPrimitiveValue::CSS_PERCENTAGE;
    429     }
    430 
    431     // We rely on charactersToDouble for validation as well. The function
    432     // will set "ok" to "false" if the entire passed-in character range does
    433     // not represent a double.
    434     bool ok;
    435     double number = charactersToDouble(characters, length, &ok);
     423
     424    if (string.is8Bit()) {
     425        const LChar* characters8 = string.characters8();
     426        if (!characters8)
     427            return false;
     428
     429        if (!isSimpleLengthPropertyID(propertyId, acceptsNegativeNumbers))
     430            return false;
     431
     432        if (length > 2 && (characters8[length - 2] | 0x20) == 'p' && (characters8[length - 1] | 0x20) == 'x') {
     433            length -= 2;
     434            unit = CSSPrimitiveValue::CSS_PX;
     435        } else if (length > 1 && characters8[length - 1] == '%') {
     436            length -= 1;
     437            unit = CSSPrimitiveValue::CSS_PERCENTAGE;
     438        }
     439
     440        // We rely on charactersToDouble for validation as well. The function
     441        // will set "ok" to "false" if the entire passed-in character range does
     442        // not represent a double.
     443        number = charactersToDouble(characters8, length, &ok);
     444    } else {
     445        const UChar* characters16 = string.characters16();
     446        if (!characters16)
     447            return false;
     448
     449        if (!isSimpleLengthPropertyID(propertyId, acceptsNegativeNumbers))
     450            return false;
     451
     452        if (length > 2 && (characters16[length - 2] | 0x20) == 'p' && (characters16[length - 1] | 0x20) == 'x') {
     453            length -= 2;
     454            unit = CSSPrimitiveValue::CSS_PX;
     455        } else if (length > 1 && characters16[length - 1] == '%') {
     456            length -= 1;
     457            unit = CSSPrimitiveValue::CSS_PERCENTAGE;
     458        }
     459
     460        // We rely on charactersToDouble for validation as well. The function
     461        // will set "ok" to "false" if the entire passed-in character range does
     462        // not represent a double.
     463        number = charactersToDouble(characters16, length, &ok);
     464    }
     465
    436466    if (!ok)
    437467        return false;
Note: See TracChangeset for help on using the changeset viewer.