Changeset 98773 in webkit


Ignore:
Timestamp:
Oct 28, 2011 3:55:37 PM (13 years ago)
Author:
cmarrin@apple.com
Message:

CSS grammar doesn't support functions with no parameters
https://bugs.webkit.org/show_bug.cgi?id=69110

Reviewed by Dean Jackson.

Source/WebCore:

Add rule to grammar to accept functions with 0 args and return
this case with a CSSParserValueList with 0 values. Also fixed
filter creation function to properly handle filters with 0
arguments.

  • css/CSSGrammar.y:
  • css/CSSStyleSelector.cpp:

(WebCore::CSSStyleSelector::createFilterOperations):

LayoutTests:

Updated tests to include tests for allowing 0 argument functions and for
disallowing functions with trailing commas (to pickup a couple of theses
cases not in the current tests). Also fixed one typo.

  • css3/filters/filter-property-computed-style-expected.txt:
  • css3/filters/filter-property-parsing-expected.txt:
  • css3/filters/filter-property-parsing-invalid-expected.txt:
  • css3/filters/script-tests/filter-property-computed-style.js:
  • css3/filters/script-tests/filter-property-parsing-invalid.js:
  • css3/filters/script-tests/filter-property-parsing.js:

(testFilterRule):

Location:
trunk
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r98768 r98773  
     12011-10-28  Chris Marrin  <cmarrin@apple.com>
     2
     3        CSS grammar doesn't support functions with no parameters
     4        https://bugs.webkit.org/show_bug.cgi?id=69110
     5
     6        Reviewed by Dean Jackson.
     7
     8        Updated tests to include tests for allowing 0 argument functions and for
     9        disallowing functions with trailing commas (to pickup a couple of theses
     10        cases not in the current tests). Also fixed one typo.
     11
     12        * css3/filters/filter-property-computed-style-expected.txt:
     13        * css3/filters/filter-property-parsing-expected.txt:
     14        * css3/filters/filter-property-parsing-invalid-expected.txt:
     15        * css3/filters/script-tests/filter-property-computed-style.js:
     16        * css3/filters/script-tests/filter-property-parsing-invalid.js:
     17        * css3/filters/script-tests/filter-property-parsing.js:
     18        (testFilterRule):
     19
    1202011-10-28  John Gregg  <johnnyg@google.com>
    221
  • trunk/LayoutTests/css3/filters/filter-property-computed-style-expected.txt

    r96775 r98773  
    4444PASS subRule.cssText is 'grayscale(0)'
    4545
     46No values : grayscale()
     47PASS filterStyle.length is 1
     48PASS subRule.operationType is WebKitCSSFilterValue.CSS_FILTER_GRAYSCALE
     49PASS subRule.cssText is 'grayscale(1)'
     50
    4651Multiple values : grayscale(0.5) grayscale(0.25)
    4752PASS filterStyle.length is 2
     
    6671PASS subRule.cssText is 'sepia(0)'
    6772
     73No values : sepia()
     74PASS filterStyle.length is 1
     75PASS subRule.operationType is WebKitCSSFilterValue.CSS_FILTER_SEPIA
     76PASS subRule.cssText is 'sepia(1)'
     77
    6878Multiple values : sepia(0.5) sepia(0.25)
    6979PASS filterStyle.length is 2
     
    95105PASS subRule.cssText is 'saturate(0)'
    96106
     107No values : saturate()
     108PASS filterStyle.length is 1
     109PASS subRule.operationType is WebKitCSSFilterValue.CSS_FILTER_SATURATE
     110PASS subRule.cssText is 'saturate(1)'
     111
    97112Multiple values : saturate(0.5) saturate(0.25)
    98113PASS filterStyle.length is 2
     
    139154PASS subRule.cssText is 'hue-rotate(0deg)'
    140155
     156No values : hue-rotate()
     157PASS filterStyle.length is 1
     158PASS subRule.operationType is WebKitCSSFilterValue.CSS_FILTER_HUE_ROTATE
     159PASS subRule.cssText is 'hue-rotate(0deg)'
     160
    141161Rule combinations : hue-rotate(10deg) grayscale(0.25)
    142162PASS filterStyle.length is 2
     
    161181PASS subRule.cssText is 'invert(0)'
    162182
     183No values : invert()
     184PASS filterStyle.length is 1
     185PASS subRule.operationType is WebKitCSSFilterValue.CSS_FILTER_INVERT
     186PASS subRule.cssText is 'invert(1)'
     187
    163188Multiple values : invert(0.5) invert(0.25)
    164189PASS filterStyle.length is 2
     
    190215PASS subRule.cssText is 'opacity(0)'
    191216
     217No values : opacity()
     218PASS filterStyle.length is 1
     219PASS subRule.operationType is WebKitCSSFilterValue.CSS_FILTER_OPACITY
     220PASS subRule.cssText is 'opacity(1)'
     221
    192222Multiple values : opacity(0.5) opacity(0.25)
    193223PASS filterStyle.length is 2
     
    219249PASS subRule.cssText is 'gamma(1 1 0)'
    220250
     251No values : gamma()
     252PASS filterStyle.length is 1
     253PASS subRule.operationType is WebKitCSSFilterValue.CSS_FILTER_GAMMA
     254PASS subRule.cssText is 'gamma(1 1 0)'
     255
    221256Float value : gamma(1.3)
    222257PASS filterStyle.length is 1
     
    249284PASS subRule.cssText is 'blur(5px 5px)'
    250285
     286No values : blur()
     287PASS filterStyle.length is 1
     288PASS subRule.operationType is WebKitCSSFilterValue.CSS_FILTER_BLUR
     289PASS subRule.cssText is 'blur(0px 0px)'
     290
    251291Three values : sharpen(1.0 10px 1)
    252292PASS filterStyle.length is 1
     
    268308PASS subRule.operationType is WebKitCSSFilterValue.CSS_FILTER_SHARPEN
    269309PASS subRule.cssText is 'sharpen(0.5 0px 1)'
     310
     311No values : sharpen()
     312PASS filterStyle.length is 1
     313PASS subRule.operationType is WebKitCSSFilterValue.CSS_FILTER_SHARPEN
     314PASS subRule.cssText is 'sharpen(0 0px 1)'
    270315
    271316Multiple operations : grayscale(0.5) sepia(0.25) saturate(0.75) hue-rotate(35deg) invert(0.2) opacity(0.9) gamma(2 1.1 1) blur(5px 2em) sharpen(0.5 3px 2)
  • trunk/LayoutTests/css3/filters/filter-property-parsing-expected.txt

    r96764 r98773  
    8686PASS subRule.cssText is 'grayscale(0)'
    8787
     88No values : grayscale()
     89PASS cssRule.type is 1
     90PASS declaration.length is 1
     91PASS declaration.getPropertyValue('-webkit-filter') is 'grayscale()'
     92PASS jsWrapperClass(filterRule) is 'CSSValueList'
     93PASS jsWrapperClass(filterRule.__proto__) is 'CSSValueListPrototype'
     94PASS jsWrapperClass(filterRule.constructor) is 'CSSValueListConstructor'
     95PASS filterRule.length is 1
     96PASS subRule.operationType is WebKitCSSFilterValue.CSS_FILTER_GRAYSCALE
     97PASS subRule.cssText is 'grayscale()'
     98
    8899Multiple values : grayscale(0.5) grayscale(0.25)
    89100PASS cssRule.type is 1
     
    132143PASS subRule.cssText is 'sepia(0)'
    133144
     145No values : sepia()
     146PASS cssRule.type is 1
     147PASS declaration.length is 1
     148PASS declaration.getPropertyValue('-webkit-filter') is 'sepia()'
     149PASS jsWrapperClass(filterRule) is 'CSSValueList'
     150PASS jsWrapperClass(filterRule.__proto__) is 'CSSValueListPrototype'
     151PASS jsWrapperClass(filterRule.constructor) is 'CSSValueListConstructor'
     152PASS filterRule.length is 1
     153PASS subRule.operationType is WebKitCSSFilterValue.CSS_FILTER_SEPIA
     154PASS subRule.cssText is 'sepia()'
     155
    134156Multiple values : sepia(0.5) sepia(0.25)
    135157PASS cssRule.type is 1
     
    191213PASS subRule.cssText is 'saturate(0)'
    192214
     215No values : saturate()
     216PASS cssRule.type is 1
     217PASS declaration.length is 1
     218PASS declaration.getPropertyValue('-webkit-filter') is 'saturate()'
     219PASS jsWrapperClass(filterRule) is 'CSSValueList'
     220PASS jsWrapperClass(filterRule.__proto__) is 'CSSValueListPrototype'
     221PASS jsWrapperClass(filterRule.constructor) is 'CSSValueListConstructor'
     222PASS filterRule.length is 1
     223PASS subRule.operationType is WebKitCSSFilterValue.CSS_FILTER_SATURATE
     224PASS subRule.cssText is 'saturate()'
     225
    193226Multiple values : saturate(0.5) saturate(0.25)
    194227PASS cssRule.type is 1
     
    283316PASS subRule.cssText is 'hue-rotate(0deg)'
    284317
     318No values : hue-rotate()
     319PASS cssRule.type is 1
     320PASS declaration.length is 1
     321PASS declaration.getPropertyValue('-webkit-filter') is 'hue-rotate()'
     322PASS jsWrapperClass(filterRule) is 'CSSValueList'
     323PASS jsWrapperClass(filterRule.__proto__) is 'CSSValueListPrototype'
     324PASS jsWrapperClass(filterRule.constructor) is 'CSSValueListConstructor'
     325PASS filterRule.length is 1
     326PASS subRule.operationType is WebKitCSSFilterValue.CSS_FILTER_HUE_ROTATE
     327PASS subRule.cssText is 'hue-rotate()'
     328
    285329Rule combinations : hue-rotate(10deg) grayscale(0.25)
    286330PASS cssRule.type is 1
     
    329373PASS subRule.cssText is 'invert(0)'
    330374
     375No values : invert()
     376PASS cssRule.type is 1
     377PASS declaration.length is 1
     378PASS declaration.getPropertyValue('-webkit-filter') is 'invert()'
     379PASS jsWrapperClass(filterRule) is 'CSSValueList'
     380PASS jsWrapperClass(filterRule.__proto__) is 'CSSValueListPrototype'
     381PASS jsWrapperClass(filterRule.constructor) is 'CSSValueListConstructor'
     382PASS filterRule.length is 1
     383PASS subRule.operationType is WebKitCSSFilterValue.CSS_FILTER_INVERT
     384PASS subRule.cssText is 'invert()'
     385
    331386Multiple values : invert(0.5) invert(0.25)
    332387PASS cssRule.type is 1
     
    387442PASS subRule.operationType is WebKitCSSFilterValue.CSS_FILTER_OPACITY
    388443PASS subRule.cssText is 'opacity(0)'
     444
     445No values : opacity()
     446PASS cssRule.type is 1
     447PASS declaration.length is 1
     448PASS declaration.getPropertyValue('-webkit-filter') is 'opacity()'
     449PASS jsWrapperClass(filterRule) is 'CSSValueList'
     450PASS jsWrapperClass(filterRule.__proto__) is 'CSSValueListPrototype'
     451PASS jsWrapperClass(filterRule.constructor) is 'CSSValueListConstructor'
     452PASS filterRule.length is 1
     453PASS subRule.operationType is WebKitCSSFilterValue.CSS_FILTER_OPACITY
     454PASS subRule.cssText is 'opacity()'
    389455
    390456Multiple values : opacity(0.5) opacity(0.25)
     
    458524PASS subRule.cssText is 'gamma(1.3)'
    459525
     526No values : gamma()
     527PASS cssRule.type is 1
     528PASS declaration.length is 1
     529PASS declaration.getPropertyValue('-webkit-filter') is 'gamma()'
     530PASS jsWrapperClass(filterRule) is 'CSSValueList'
     531PASS jsWrapperClass(filterRule.__proto__) is 'CSSValueListPrototype'
     532PASS jsWrapperClass(filterRule.constructor) is 'CSSValueListConstructor'
     533PASS filterRule.length is 1
     534PASS subRule.operationType is WebKitCSSFilterValue.CSS_FILTER_GAMMA
     535PASS subRule.cssText is 'gamma()'
     536
    460537Two zeros to px : blur(0 0)
    461538PASS cssRule.type is 1
     
    502579PASS subRule.cssText is 'blur(10%)'
    503580
     581No values : blur()
     582PASS cssRule.type is 1
     583PASS declaration.length is 1
     584PASS declaration.getPropertyValue('-webkit-filter') is 'blur()'
     585PASS jsWrapperClass(filterRule) is 'CSSValueList'
     586PASS jsWrapperClass(filterRule.__proto__) is 'CSSValueListPrototype'
     587PASS jsWrapperClass(filterRule.constructor) is 'CSSValueListConstructor'
     588PASS filterRule.length is 1
     589PASS subRule.operationType is WebKitCSSFilterValue.CSS_FILTER_BLUR
     590PASS subRule.cssText is 'blur()'
     591
    504592Three values : sharpen(1.0 10px 1)
    505593PASS cssRule.type is 1
     
    545633PASS subRule.operationType is WebKitCSSFilterValue.CSS_FILTER_SHARPEN
    546634PASS subRule.cssText is 'sharpen(0.25)'
     635
     636No values : sharpen()
     637PASS cssRule.type is 1
     638PASS declaration.length is 1
     639PASS declaration.getPropertyValue('-webkit-filter') is 'sharpen()'
     640PASS jsWrapperClass(filterRule) is 'CSSValueList'
     641PASS jsWrapperClass(filterRule.__proto__) is 'CSSValueListPrototype'
     642PASS jsWrapperClass(filterRule.constructor) is 'CSSValueListConstructor'
     643PASS filterRule.length is 1
     644PASS subRule.operationType is WebKitCSSFilterValue.CSS_FILTER_SHARPEN
     645PASS subRule.cssText is 'sharpen()'
    547646
    548647Multiple operations : grayscale(0.5) sepia(0.25) saturate(0.75) hue-rotate(35deg) invert(0.2) opacity(0.9) gamma(2 1.1 1) blur(5px 2em) sharpen(0.5 3px 2)
  • trunk/LayoutTests/css3/filters/filter-property-parsing-invalid-expected.txt

    r96764 r98773  
    215215PASS declaration.getPropertyValue('-webkit-filter') is null
    216216
    217 Commas : hue-rotate(1.0, 1.0, 1.0)
     217Commas : gamma(1.0, 1.0, 1.0)
     218PASS cssRule.type is 1
     219PASS declaration.length is 0
     220PASS declaration.getPropertyValue('-webkit-filter') is null
     221
     222Trailing comma : gamma(1.0, 1.0,)
    218223PASS cssRule.type is 1
    219224PASS declaration.length is 0
     
    255260PASS declaration.getPropertyValue('-webkit-filter') is null
    256261
     262Trailing comma : blur(1em,)
     263PASS cssRule.type is 1
     264PASS declaration.length is 0
     265PASS declaration.getPropertyValue('-webkit-filter') is null
     266
    257267Missing length : sharpen(1 1 1)
    258268PASS cssRule.type is 1
     
    279289PASS declaration.length is 0
    280290PASS declaration.getPropertyValue('-webkit-filter') is null
     291
     292Trailing comma : sharpen(1, 10px,)
     293PASS cssRule.type is 1
     294PASS declaration.length is 0
     295PASS declaration.getPropertyValue('-webkit-filter') is null
    281296PASS successfullyParsed is true
    282297
  • trunk/LayoutTests/css3/filters/script-tests/filter-property-computed-style.js

    r96775 r98773  
    5757                       ["grayscale(0)"]);
    5858
     59testComputedFilterRule("No values",
     60                       "grayscale()", 1,
     61                       ["WebKitCSSFilterValue.CSS_FILTER_GRAYSCALE"],
     62                       ["grayscale(1)"]);
     63
    5964testComputedFilterRule("Multiple values",
    6065                       "grayscale(0.5) grayscale(0.25)", 2,
     
    7782                       ["sepia(0)"]);
    7883
     84testComputedFilterRule("No values",
     85                       "sepia()", 1,
     86                       ["WebKitCSSFilterValue.CSS_FILTER_SEPIA"],
     87                       ["sepia(1)"]);
     88
    7989testComputedFilterRule("Multiple values",
    8090                       "sepia(0.5) sepia(0.25)", 2,
     
    102112                       ["saturate(0)"]);
    103113
     114testComputedFilterRule("No values",
     115                       "saturate()", 1,
     116                       ["WebKitCSSFilterValue.CSS_FILTER_SATURATE"],
     117                       ["saturate(1)"]);
     118
    104119testComputedFilterRule("Multiple values",
    105120                       "saturate(0.5) saturate(0.25)", 2,
     
    142157                       ["hue-rotate(0deg)"]);
    143158
     159testComputedFilterRule("No values",
     160                       "hue-rotate()", 1,
     161                       ["WebKitCSSFilterValue.CSS_FILTER_HUE_ROTATE"],
     162                       ["hue-rotate(0deg)"]);
     163
    144164testComputedFilterRule("Rule combinations",
    145165                       "hue-rotate(10deg) grayscale(0.25)", 2,
     
    162182                       ["invert(0)"]);
    163183
     184testComputedFilterRule("No values",
     185                       "invert()", 1,
     186                       ["WebKitCSSFilterValue.CSS_FILTER_INVERT"],
     187                       ["invert(1)"]);
     188
    164189testComputedFilterRule("Multiple values",
    165190                       "invert(0.5) invert(0.25)", 2,
     
    187212                       ["opacity(0)"]);
    188213
     214testComputedFilterRule("No values",
     215                       "opacity()", 1,
     216                       ["WebKitCSSFilterValue.CSS_FILTER_OPACITY"],
     217                       ["opacity(1)"]);
     218
    189219testComputedFilterRule("Multiple values",
    190220                       "opacity(0.5) opacity(0.25)", 2,
     
    212242                       ["gamma(1 1 0)"]);
    213243
     244testComputedFilterRule("No values",
     245                       "gamma()", 1,
     246                       ["WebKitCSSFilterValue.CSS_FILTER_GAMMA"],
     247                       ["gamma(1 1 0)"]);
     248
    214249testComputedFilterRule("Float value",
    215250                       "gamma(1.3)", 1,
     
    242277                       ["blur(5px 5px)"]);
    243278
     279testComputedFilterRule("No values",
     280                       "blur()", 1,
     281                       ["WebKitCSSFilterValue.CSS_FILTER_BLUR"],
     282                       ["blur(0px 0px)"]);
     283
    244284testComputedFilterRule("Three values",
    245285                       "sharpen(1.0 10px 1)", 1,
     
    261301                       ["WebKitCSSFilterValue.CSS_FILTER_SHARPEN"],
    262302                       ["sharpen(0.5 0px 1)"]);
     303
     304testComputedFilterRule("No values",
     305                       "sharpen()", 1,
     306                       ["WebKitCSSFilterValue.CSS_FILTER_SHARPEN"],
     307                       ["sharpen(0 0px 1)"]);
    263308
    264309testComputedFilterRule("Multiple operations",
  • trunk/LayoutTests/css3/filters/script-tests/filter-property-parsing-invalid.js

    r96764 r98773  
    6969testInvalidFilterRule("Negative number", "gamma(1.0 -0.1)");
    7070testInvalidFilterRule("Too many parameters", "gamma(1.0 1.0 1.0 1.0)");
    71 testInvalidFilterRule("Commas", "hue-rotate(1.0, 1.0, 1.0)");
     71testInvalidFilterRule("Commas", "gamma(1.0, 1.0, 1.0)");
     72testInvalidFilterRule("Trailing comma", "gamma(1.0, 1.0,)");
    7273
    7374testInvalidFilterRule("Bare number", "blur(1)");
     
    7879testInvalidFilterRule("Too many parameters and commas", "blur(1em, 1em, 2em)");
    7980testInvalidFilterRule("Commas", "blur(10px, 10px)");
     81testInvalidFilterRule("Trailing comma", "blur(1em,)");
    8082
    8183testInvalidFilterRule("Missing length", "sharpen(1 1 1)");
     
    8486testInvalidFilterRule("Too many parameters and commas", "sharpen(1, 1px, 1, 1)");
    8587testInvalidFilterRule("Commas", "sharpen(1, 10px, 1)");
     88testInvalidFilterRule("Trailing comma", "sharpen(1, 10px,)");
    8689
    8790successfullyParsed = true;
  • trunk/LayoutTests/css3/filters/script-tests/filter-property-parsing.js

    r96764 r98773  
    4343    shouldBe("filterRule.length", "" + expectedLength); // shouldBe expects string arguments
    4444 
    45     for (var i = 0; i < expectedLength; i++) {
    46         subRule = filterRule[i];
    47         shouldBe("subRule.operationType", expectedTypes[i]);
    48         shouldBe("subRule.cssText", "'" + expectedTexts[i] + "'");
     45    if (filterRule) {
     46        for (var i = 0; i < expectedLength; i++) {
     47            subRule = filterRule[i];
     48            shouldBe("subRule.operationType", expectedTypes[i]);
     49            shouldBe("subRule.cssText", "'" + expectedTexts[i] + "'");
     50        }
    4951    }
    5052}
     
    8587               ["grayscale(0)"]);
    8688
     89testFilterRule("No values",
     90               "grayscale()", 1, "grayscale()",
     91               ["WebKitCSSFilterValue.CSS_FILTER_GRAYSCALE"],
     92               ["grayscale()"]);
     93
    8794testFilterRule("Multiple values",
    8895               "grayscale(0.5) grayscale(0.25)", 2, "grayscale(0.5) grayscale(0.25)",
     
    105112               ["sepia(0)"]);
    106113
     114testFilterRule("No values",
     115               "sepia()", 1, "sepia()",
     116               ["WebKitCSSFilterValue.CSS_FILTER_SEPIA"],
     117               ["sepia()"]);
     118
    107119testFilterRule("Multiple values",
    108120               "sepia(0.5) sepia(0.25)", 2, "sepia(0.5) sepia(0.25)",
     
    130142               ["saturate(0)"]);
    131143
     144testFilterRule("No values",
     145               "saturate()", 1, "saturate()",
     146               ["WebKitCSSFilterValue.CSS_FILTER_SATURATE"],
     147               ["saturate()"]);
     148
    132149testFilterRule("Multiple values",
    133150               "saturate(0.5) saturate(0.25)", 2, "saturate(0.5) saturate(0.25)",
     
    170187               ["hue-rotate(0deg)"]);
    171188
     189testFilterRule("No values",
     190               "hue-rotate()", 1, "hue-rotate()",
     191               ["WebKitCSSFilterValue.CSS_FILTER_HUE_ROTATE"],
     192               ["hue-rotate()"]);
     193
    172194testFilterRule("Rule combinations",
    173195               "hue-rotate(10deg) grayscale(0.25)", 2, "hue-rotate(10deg) grayscale(0.25)",
     
    190212               ["invert(0)"]);
    191213
     214testFilterRule("No values",
     215               "invert()", 1, "invert()",
     216               ["WebKitCSSFilterValue.CSS_FILTER_INVERT"],
     217               ["invert()"]);
     218
    192219testFilterRule("Multiple values",
    193220               "invert(0.5) invert(0.25)", 2, "invert(0.5) invert(0.25)",
     
    215242               ["opacity(0)"]);
    216243
     244testFilterRule("No values",
     245               "opacity()", 1, "opacity()",
     246               ["WebKitCSSFilterValue.CSS_FILTER_OPACITY"],
     247               ["opacity()"]);
     248
    217249testFilterRule("Multiple values",
    218250               "opacity(0.5) opacity(0.25)", 2, "opacity(0.5) opacity(0.25)",
     
    245277               ["gamma(1.3)"]);
    246278
     279testFilterRule("No values",
     280               "gamma()", 1, "gamma()",
     281               ["WebKitCSSFilterValue.CSS_FILTER_GAMMA"],
     282               ["gamma()"]);
     283
    247284testFilterRule("Two zeros to px",
    248285               "blur(0 0)", 1, "blur(0px 0px)",
     
    265302               ["blur(10%)"]);
    266303
     304testFilterRule("No values",
     305               "blur()", 1, "blur()",
     306               ["WebKitCSSFilterValue.CSS_FILTER_BLUR"],
     307               ["blur()"]);
     308
    267309testFilterRule("Three values",
    268310               "sharpen(1.0 10px 1)", 1, "sharpen(1 10px 1)",
     
    284326               ["WebKitCSSFilterValue.CSS_FILTER_SHARPEN"],
    285327               ["sharpen(0.25)"]);
     328
     329testFilterRule("No values",
     330               "sharpen()", 1, "sharpen()",
     331               ["WebKitCSSFilterValue.CSS_FILTER_SHARPEN"],
     332               ["sharpen()"]);
    286333
    287334testFilterRule("Multiple operations",
  • trunk/Source/WebCore/ChangeLog

    r98771 r98773  
     12011-10-28  Chris Marrin  <cmarrin@apple.com>
     2
     3        CSS grammar doesn't support functions with no parameters
     4        https://bugs.webkit.org/show_bug.cgi?id=69110
     5
     6        Reviewed by Dean Jackson.
     7
     8        Add rule to grammar to accept functions with 0 args and return
     9        this case with a CSSParserValueList with 0 values. Also fixed
     10        filter creation function to properly handle filters with 0
     11        arguments.
     12
     13        * css/CSSGrammar.y:
     14        * css/CSSStyleSelector.cpp:
     15        (WebCore::CSSStyleSelector::createFilterOperations):
     16
    1172011-10-28  Sheriff Bot  <webkit.review.bot@gmail.com>
    218
  • trunk/Source/WebCore/css/CSSGrammar.y

    r97738 r98773  
    101101%}
    102102
    103 %expect 54
     103%expect 55
    104104
    105105%nonassoc LOWEST_PREC
     
    14791479        $$.function = f;
    14801480    } |
     1481    FUNCTION maybe_space ')' maybe_space {
     1482        CSSParser* p = static_cast<CSSParser*>(parser);
     1483        CSSParserFunction* f = p->createFloatingFunction();
     1484        f->name = $1;
     1485        CSSParserValueList* valueList = p->createFloatingValueList();
     1486        f->args = adoptPtr(p->sinkFloatingValueList(valueList));
     1487        $$.id = 0;
     1488        $$.unit = CSSParserValue::Function;
     1489        $$.function = f;
     1490    } |
    14811491    FUNCTION maybe_space error {
    14821492        CSSParser* p = static_cast<CSSParser*>(parser);
  • trunk/Source/WebCore/css/CSSStyleSelector.cpp

    r98748 r98773  
    53965396
    53975397        WebKitCSSFilterValue* filterValue = static_cast<WebKitCSSFilterValue*>(i.value());
    5398         if (!filterValue->length())
    5399             continue;
    5400 
    54015398        FilterOperation::OperationType operationType = filterOperationForType(filterValue->operationType());
    54025399
     
    54115408            continue;
    54125409
    5413         CSSPrimitiveValue* firstValue = static_cast<CSSPrimitiveValue*>(filterValue->itemWithoutBoundsCheck(0));
     5410        CSSPrimitiveValue* firstValue = filterValue->length() ? static_cast<CSSPrimitiveValue*>(filterValue->itemWithoutBoundsCheck(0)) : 0;
    54145411        switch (filterValue->operationType()) {
    54155412        case WebKitCSSFilterValue::ReferenceFilterOperation: {
    5416             operations.operations().append(ReferenceFilterOperation::create(firstValue->getStringValue(), operationType));
     5413            if (firstValue)
     5414                operations.operations().append(ReferenceFilterOperation::create(firstValue->getStringValue(), operationType));
    54175415            break;
    54185416        }
     
    54285426        }
    54295427        case WebKitCSSFilterValue::HueRotateFilterOperation: {
    5430             double angle = firstValue->getDoubleValue();
    5431             if (firstValue->primitiveType() == CSSPrimitiveValue::CSS_RAD)
    5432                 angle = rad2deg(angle);
    5433             else if (firstValue->primitiveType() == CSSPrimitiveValue::CSS_GRAD)
    5434                 angle = grad2deg(angle);
    5435             else if (firstValue->primitiveType() == CSSPrimitiveValue::CSS_TURN)
    5436                 angle = turn2deg(angle);
     5428            double angle = 0;
     5429            if (filterValue->length() == 1) {
     5430                angle = firstValue->getDoubleValue();
     5431                if (firstValue->primitiveType() == CSSPrimitiveValue::CSS_RAD)
     5432                    angle = rad2deg(angle);
     5433                else if (firstValue->primitiveType() == CSSPrimitiveValue::CSS_GRAD)
     5434                    angle = grad2deg(angle);
     5435                else if (firstValue->primitiveType() == CSSPrimitiveValue::CSS_TURN)
     5436                    angle = turn2deg(angle);
     5437            }
    54375438
    54385439            operations.operations().append(BasicColorMatrixFilterOperation::create(angle, operationType));
Note: See TracChangeset for help on using the changeset viewer.