Changeset 51600 in webkit


Ignore:
Timestamp:
Dec 2, 2009 7:33:31 AM (14 years ago)
Author:
hyatt@apple.com
Message:

https://bugs.webkit.org/show_bug.cgi?id=32045, make sure escape sequences work with
all the @-rules we support. When escape sequences are present, the lexical scanner
just returns a generic token name: ATKEYWORD. We have to process the escape sequences
and then recheck against the rules we support with the final processed name. If we
find a match, we mutate the token value to the appropriate rule name token, e.g.,
NAMESPACE_SYM.

Reviewed by Dan Bernstein.

Added fast/css/namespaces/namespaces-escapes.xml

  • css/CSSParser.cpp:

(WebCore::CSSParser::lex):
(WebCore::CSSParser::recheckAtKeyword):
(WebCore::CSSParser::text):

  • css/CSSParser.h:
Location:
trunk
Files:
4 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r51599 r51600  
     12009-12-01  Dave Hyatt  <hyatt@apple.com>
     2
     3        Reviewed by Dan Bernstein.
     4
     5        https://bugs.webkit.org/show_bug.cgi?id=32045, make sure escape sequences work with
     6        all the @-rules we support.  When escape sequences are present, the lexical scanner
     7        just returns a generic token name: ATKEYWORD.  We have to process the escape sequences
     8        and then recheck against the rules we support with the final processed name.  If we
     9        find a match, we mutate the token value to the appropriate rule name token, e.g.,
     10        NAMESPACE_SYM.
     11
     12        Added fast/css/namespaces/namespaces-escapes.xml
     13
     14        * css/CSSParser.cpp:
     15        (WebCore::CSSParser::lex):
     16        (WebCore::CSSParser::recheckAtKeyword):
     17        (WebCore::CSSParser::text):
     18        * css/CSSParser.h:
     19
    1202009-12-02  Anton Muhin  <antonm@chromium.org>
    221
  • trunk/WebCore/css/CSSParser.cpp

    r50998 r51600  
    46194619{
    46204620    YYSTYPE* yylval = static_cast<YYSTYPE*>(yylvalWithoutType);
    4621     int token = lex();
    46224621    int length;
     4622   
     4623    lex();
     4624
    46234625    UChar* t = text(&length);
    46244626
    4625     switch (token) {
     4627    switch (token()) {
    46264628    case WHITESPACE:
    46274629    case SGML_CD:
     
    46894691    }
    46904692
    4691     return token;
     4693    return token();
    46924694}
    46934695
     
    46954697{
    46964698    return c == ' ' || c == '\t' || c == '\r' || c == '\n' || c == '\f';
     4699}
     4700
     4701void CSSParser::recheckAtKeyword(const UChar* str, int len)
     4702{
     4703    String ruleName(str, len);
     4704    if (equalIgnoringCase(ruleName, "@import"))
     4705        yyTok = IMPORT_SYM;
     4706    else if (equalIgnoringCase(ruleName, "@page"))
     4707        yyTok = PAGE_SYM;
     4708    else if (equalIgnoringCase(ruleName, "@media"))
     4709        yyTok = MEDIA_SYM;
     4710    else if (equalIgnoringCase(ruleName, "@font-face"))
     4711        yyTok = FONT_FACE_SYM;
     4712    else if (equalIgnoringCase(ruleName, "@charset"))
     4713        yyTok = CHARSET_SYM;
     4714    else if (equalIgnoringCase(ruleName, "@namespace"))
     4715        yyTok = NAMESPACE_SYM;
     4716    else if (equalIgnoringCase(ruleName, "@-webkit-keyframes"))
     4717        yyTok = WEBKIT_KEYFRAMES_SYM;
     4718    else if (equalIgnoringCase(ruleName, "@-webkit-mediaquery"))
     4719        yyTok = WEBKIT_MEDIAQUERY_SYM;
     4720    // FIXME: Add CSS Variables if we ever decide to turn it back on.
    46974721}
    46984722
     
    47494773    UChar* out = start;
    47504774    UChar* escape = 0;
     4775
     4776    bool sawEscape = false;
    47514777
    47524778    for (int i = 0; i < l; i++) {
     
    47944820        if (!escape && *current == '\\') {
    47954821            escape = current;
     4822            sawEscape = true;
    47964823            continue;
    47974824        }
     
    48144841   
    48154842    *length = out - start;
     4843   
     4844    // If we have an unrecognized @-keyword, and if we handled any escapes at all, then
     4845    // we should attempt to adjust yyTok to the correct type.
     4846    if (yyTok == ATKEYWORD && sawEscape)
     4847        recheckAtKeyword(start, *length);
     4848
    48164849    return start;
    48174850}
  • trunk/WebCore/css/CSSParser.h

    r50273 r51600  
    226226       
    227227    private:
     228        void recheckAtKeyword(const UChar* str, int len);
     229   
    228230        void clearProperties();
    229231
Note: See TracChangeset for help on using the changeset viewer.