Changeset 47716 in webkit


Ignore:
Timestamp:
Aug 24, 2009 9:26:47 AM (15 years ago)
Author:
mitz@apple.com
Message:

WebCore:
background-size fails to parse if a single length/percentage/auto is followed by a comma
https://bugs.webkit.org/show_bug.cgi?id=28674

Reviewed by Simon Fraser.

  • css/CSSParser.cpp:

(WebCore::CSSParser::parseFillSize): Added an allowComma parameter,

which is set to false when this method consumes a comma. Moved
handling of 'contain' and 'cover' from parseFillProperty into this
method.

(WebCore::CSSParser::parseFillProperty): Set allowComma to true before

processing the next value, and pass allowComma to parseFillSize.

  • css/CSSParser.h:

LayoutTests:
background-size fails to parse if a single length/percentage/auto is followed by a comma
https://bugs.webkit.org/show_bug.cgi?id=28674

Reviewed by Simon Fraser.

  • fast/backgrounds/size/parsing-background-size-values-expected.txt:
  • fast/backgrounds/size/resources/parsing-background-size-values.js:
Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r47711 r47716  
     12009-08-24  Dan Bernstein  <mitz@apple.com>
     2
     3        Reviewed by Simon Fraser.
     4
     5        background-size fails to parse if a single length/percentage/auto is followed by a comma
     6        https://bugs.webkit.org/show_bug.cgi?id=28674
     7
     8        * fast/backgrounds/size/parsing-background-size-values-expected.txt:
     9        * fast/backgrounds/size/resources/parsing-background-size-values.js:
     10
    1112009-08-24  Kenneth Rohde Christiansen  <kenneth@webkit.org>
    212
  • trunk/LayoutTests/fast/backgrounds/size/parsing-background-size-values-expected.txt

    r47630 r47716  
    1616PASS test("background-size: 100 100 100;") is null
    1717PASS test("background-size: coconut;") is null
     18PASS test("background-size: 100px,;") is null
     19PASS test("background-size: 100px, 50%;") is "100px 100px, 50% 50%"
     20PASS test("background-size: 50% 100px, 2em, 100px 50%;") is "50% 100px, 2em 2em, 100px 50%"
    1821PASS successfullyParsed is true
    1922
  • trunk/LayoutTests/fast/backgrounds/size/resources/parsing-background-size-values.js

    r47630 r47716  
    2626shouldBe('test("background-size: coconut;")', 'null');
    2727
     28shouldBe('test("background-size: 100px,;")', 'null');
     29shouldBe('test("background-size: 100px, 50%;")', '"100px 100px, 50% 50%"');
     30shouldBe('test("background-size: 50% 100px, 2em, 100px 50%;")', '"50% 100px, 2em 2em, 100px 50%"');
     31
    2832var successfullyParsed = true;
  • trunk/WebCore/ChangeLog

    r47712 r47716  
     12009-08-24  Dan Bernstein  <mitz@apple.com>
     2
     3        Reviewed by Simon Fraser.
     4
     5        background-size fails to parse if a single length/percentage/auto is followed by a comma
     6        https://bugs.webkit.org/show_bug.cgi?id=28674
     7
     8        * css/CSSParser.cpp:
     9        (WebCore::CSSParser::parseFillSize): Added an allowComma parameter,
     10            which is set to false when this method consumes a comma. Moved
     11            handling of 'contain' and 'cover' from parseFillProperty into this
     12            method.
     13        (WebCore::CSSParser::parseFillProperty): Set allowComma to true before
     14            processing the next value, and pass allowComma to parseFillSize.
     15        * css/CSSParser.h:
     16
    1172009-08-17  Martin Robinson  <martin.james.robinson@gmail.com>
    218
  • trunk/WebCore/css/CSSParser.cpp

    r47648 r47716  
    22372237}
    22382238
    2239 PassRefPtr<CSSValue> CSSParser::parseFillSize()
    2240 {
     2239PassRefPtr<CSSValue> CSSParser::parseFillSize(bool& allowComma)
     2240{
     2241    allowComma = true;
    22412242    CSSParserValue* value = m_valueList->current();
     2243
     2244    if (value->id == CSSValueContain || value->id == CSSValueCover)
     2245        return CSSPrimitiveValue::createIdentifier(value->id);
     2246
    22422247    RefPtr<CSSPrimitiveValue> parsedValue1;
    22432248   
     
    22542259        if (value->id == CSSValueAuto)
    22552260            parsedValue2 = CSSPrimitiveValue::create(0, CSSPrimitiveValue::CSS_UNKNOWN);
     2261        else if (value->unit == CSSParserValue::Operator && value->iValue == ',')
     2262            allowComma = false;
    22562263        else {
    22572264            if (!validUnit(value, FLength|FPercent, m_strict))
     
    22962303            allowComma = false;
    22972304        } else {
     2305            allowComma = true;
    22982306            switch (propId) {
    22992307                case CSSPropertyBackgroundColor:
     
    23782386                case CSSPropertyBackgroundSize:
    23792387                case CSSPropertyWebkitMaskSize: {
    2380                     if (val->id == CSSValueContain || val->id == CSSValueCover) {
    2381                         currValue = CSSPrimitiveValue::createIdentifier(val->id);
     2388                    currValue = parseFillSize(allowComma);
     2389                    if (currValue)
    23822390                        m_valueList->next();
    2383                     } else {
    2384                         currValue = parseFillSize();
    2385                         if (currValue)
    2386                             m_valueList->next();
    2387                     }
    23882391                    break;
    23892392                }
     
    24122415                    value2 = currValue2.release();
    24132416            }
    2414             allowComma = true;
    24152417        }
    24162418       
  • trunk/WebCore/css/CSSParser.h

    r46547 r47716  
    8383        PassRefPtr<CSSValue> parseFillPositionXY(bool& xFound, bool& yFound);
    8484        void parseFillPosition(RefPtr<CSSValue>&, RefPtr<CSSValue>&);
    85         PassRefPtr<CSSValue> parseFillSize();
     85        PassRefPtr<CSSValue> parseFillSize(bool &allowComma);
    8686       
    8787        bool parseFillProperty(int propId, int& propId1, int& propId2, RefPtr<CSSValue>&, RefPtr<CSSValue>&);
Note: See TracChangeset for help on using the changeset viewer.