Changeset 172833 in webkit


Ignore:
Timestamp:
Aug 21, 2014 1:29:43 PM (10 years ago)
Author:
commit-queue@webkit.org
Message:

REGRESSION: CSS not() selector does not work when it appears after or within @supports
https://bugs.webkit.org/show_bug.cgi?id=136063

Patch by Yuki Sekiguchi <yuki.sekiguchi@access-company.com> on 2014-08-21
Reviewed by Darin Adler.

Source/WebCore:

CSSParser changes its m_parsingMode to SupportsMode when it finds
"@supports" token. However, the mode will be never changed to
NormalMode. This changes parsing algorithm for "not" token forever,
and it cannot parse not pseudo class selector.

When we finish parsing @supports rule, we should change to normal
mode.

@media does the same thing. This patch changed CharacterEndMediaQuery
to CharacterEndConditionQuery, and we change parsing mode from
SupportsMode to NormalMode when the parser finished to parse
@supports rule.

Like "@-webkit-mediaquery", we cannot use '{' to
"@-webkit-supports-condition". Changed "@-webkit-supports-condition"
parsing rule and parseSupportsCondition() not to use '{'.

Tests: css3/supports-not-selector-cssom.html

css3/supports-not-selector.html

  • css/CSSGrammar.y.in:
  • css/CSSParser.cpp:

(WebCore::CSSParser::parseSupportsCondition):
(WebCore::isCSSLetter):
(WebCore::CSSParser::realLex):

LayoutTests:

Test that @supports doesn't break "not" pseudo class selector.

  • css3/supports-not-selector-cssom-expected.txt: Added.
  • css3/supports-not-selector-cssom.html: Added.
  • css3/supports-not-selector-expected.html: Added.
  • css3/supports-not-selector.html: Added.
Location:
trunk
Files:
4 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r172832 r172833  
     12014-08-21  Yuki Sekiguchi  <yuki.sekiguchi@access-company.com>
     2
     3        REGRESSION: CSS not() selector does not work when it appears after or within @supports
     4        https://bugs.webkit.org/show_bug.cgi?id=136063
     5
     6        Reviewed by Darin Adler.
     7
     8        Test that @supports doesn't break "not" pseudo class selector.
     9
     10        * css3/supports-not-selector-cssom-expected.txt: Added.
     11        * css3/supports-not-selector-cssom.html: Added.
     12        * css3/supports-not-selector-expected.html: Added.
     13        * css3/supports-not-selector.html: Added.
     14
    1152014-08-21  Beth Dakin  <bdakin@apple.com>
    216
  • trunk/Source/WebCore/ChangeLog

    r172832 r172833  
     12014-08-21  Yuki Sekiguchi  <yuki.sekiguchi@access-company.com>
     2
     3        REGRESSION: CSS not() selector does not work when it appears after or within @supports
     4        https://bugs.webkit.org/show_bug.cgi?id=136063
     5
     6        Reviewed by Darin Adler.
     7
     8        CSSParser changes its m_parsingMode to SupportsMode when it finds
     9        "@supports" token. However, the mode will be never changed to
     10        NormalMode. This changes parsing algorithm for "not" token forever,
     11        and it cannot parse not pseudo class selector.
     12
     13        When we finish parsing @supports rule, we should change to normal
     14        mode.
     15
     16        @media does the same thing. This patch changed CharacterEndMediaQuery
     17        to CharacterEndConditionQuery, and we change parsing mode from
     18        SupportsMode to NormalMode when the parser finished to parse
     19        @supports rule.
     20
     21        Like "@-webkit-mediaquery", we cannot use '{' to
     22        "@-webkit-supports-condition". Changed "@-webkit-supports-condition"
     23        parsing rule and parseSupportsCondition() not to use '{'.
     24
     25        Tests: css3/supports-not-selector-cssom.html
     26               css3/supports-not-selector.html
     27
     28        * css/CSSGrammar.y.in:
     29        * css/CSSParser.cpp:
     30        (WebCore::CSSParser::parseSupportsCondition):
     31        (WebCore::isCSSLetter):
     32        (WebCore::CSSParser::realLex):
     33
    1342014-08-21  Beth Dakin  <bdakin@apple.com>
    235
  • trunk/Source/WebCore/css/CSSGrammar.y.in

    r171008 r172833  
    392392#if ENABLE_CSS3_CONDITIONAL_RULES
    393393
    394 webkit_supports_condition: WEBKIT_SUPPORTS_CONDITION_SYM '{' maybe_space supports_condition '}' { parser->m_supportsCondition = $4; } ;
     394webkit_supports_condition: WEBKIT_SUPPORTS_CONDITION_SYM WHITESPACE maybe_space supports_condition '}' { parser->m_supportsCondition = $4; } ;
    395395
    396396#endif
  • trunk/Source/WebCore/css/CSSParser.cpp

    r172642 r172833  
    472472{
    473473    m_supportsCondition = false;
    474     setupParser("@-webkit-supports-condition{ ", string, "} ");
     474    // can't use { because tokenizer state switches from supports to initial state when it sees { token.
     475    // instead insert one " " (which is WHITESPACE in CSSGrammar.y)
     476    setupParser("@-webkit-supports-condition ", string, "} ");
    475477    cssyyparse(this);
    476478    return m_supportsCondition;
     
    99829984    CharacterNull,
    99839985    CharacterWhiteSpace,
    9984     CharacterEndMediaQuery,
     9986    CharacterEndConditionQuery,
    99859987    CharacterEndNthChild,
    99869988    CharacterQuote,
     
    1006110063/*  57 - 9                  */ CharacterNumber,
    1006210064/*  58 - :                  */ CharacterOther,
    10063 /*  59 - ;                  */ CharacterEndMediaQuery,
     10065/*  59 - ;                  */ CharacterEndConditionQuery,
    1006410066/*  60 - <                  */ CharacterLess,
    1006510067/*  61 - =                  */ CharacterOther,
     
    1012510127/* 121 - y                  */ CharacterIdentifierStart,
    1012610128/* 122 - z                  */ CharacterIdentifierStart,
    10127 /* 123 - {                  */ CharacterEndMediaQuery,
     10129/* 123 - {                  */ CharacterEndConditionQuery,
    1012810130/* 124 - |                  */ CharacterVerticalBar,
    1012910131/* 125 - }                  */ CharacterOther,
     
    1134111343        break;
    1134211344
    11343     case CharacterEndMediaQuery:
    11344         if (m_parsingMode == MediaQueryMode)
     11345    case CharacterEndConditionQuery: {
     11346        bool isParsingCondition = m_parsingMode == MediaQueryMode;
     11347#if ENABLE(CSS3_CONDITIONAL_RULES)
     11348        isParsingCondition = isParsingCondition || m_parsingMode == SupportsMode;
     11349#endif
     11350        if (isParsingCondition)
    1134511351            m_parsingMode = NormalMode;
    1134611352        break;
     11353    }
    1134711354
    1134811355    case CharacterEndNthChild:
Note: See TracChangeset for help on using the changeset viewer.