source: trunk/WebCore/css/tokenizer.flex @ 30069

Revision 30069, 4.2 KB checked in by hyatt@apple.com, 7 years ago (diff)

Fix for bug 6248, implement the nth-* CSS3 selectors. Patch based on original KHTML work from Allan Jensen
and improved upon by Nick Shanks.

Reviewed by Eric

  • css/CSSGrammar.y:
  • css/CSSParser.cpp: (WebCore::CSSParser::lex):
  • css/CSSSelector.cpp: (WebCore::CSSSelector::extractPseudoType):
  • css/CSSSelector.h: (WebCore::CSSSelector::):
  • css/CSSStyleSelector.cpp: (WebCore::parseNth): (WebCore::matchNth): (WebCore::CSSStyleSelector::checkOneSelector):
  • css/tokenizer.flex:
  • rendering/RenderStyle.cpp: (WebCore::RenderStyle::RenderStyle):
  • rendering/RenderStyle.h: (WebCore::RenderStyle::childIndex): (WebCore::RenderStyle::setChildIndex):
  • Property svn:eol-style set to native
Line 
1%option case-insensitive
2%option noyywrap
3%option 8bit
4%option stack
5%s mediaquery
6
7h               [0-9a-fA-F]
8nonascii        [\200-\377]
9unicode         \\{h}{1,6}[ \t\r\n\f]?
10escape          {unicode}|\\[ -~\200-\377]
11nmstart         [_a-zA-Z]|{nonascii}|{escape}
12nmchar          [_a-zA-Z0-9-]|{nonascii}|{escape}
13string1         \"([\t !#$%&(-~]|\\{nl}|\'|{nonascii}|{escape})*\"
14string2         \'([\t !#$%&(-~]|\\{nl}|\"|{nonascii}|{escape})*\'
15hexcolor        {h}{3}|{h}{6}
16
17ident           -?{nmstart}{nmchar}*
18name            {nmchar}+
19num             [0-9]+|[0-9]*"."[0-9]+
20intnum          [0-9]+
21string          {string1}|{string2}
22url             ([!#$%&*-~]|{nonascii}|{escape})*
23w               [ \t\r\n\f]*
24nl              \n|\r\n|\r|\f
25range           \?{1,6}|{h}(\?{0,5}|{h}(\?{0,4}|{h}(\?{0,3}|{h}(\?{0,2}|{h}(\??|{h})))))
26nth             (-?[0-9]*n[\+-][0-9]+)|(-?[0-9]*n)
27
28%%
29
30\/\*[^*]*\*+([^/*][^*]*\*+)*\/  /* ignore comments */
31
32[ \t\r\n\f]+            {yyTok = WHITESPACE; return yyTok;}
33
34"<!--"                  {yyTok = SGML_CD; return yyTok;}
35"-->"                   {yyTok = SGML_CD; return yyTok;}
36"~="                    {yyTok = INCLUDES; return yyTok;}
37"|="                    {yyTok = DASHMATCH; return yyTok;}
38"^="                    {yyTok = BEGINSWITH; return yyTok;}
39"$="                    {yyTok = ENDSWITH; return yyTok;}
40"*="                    {yyTok = CONTAINS; return yyTok;}
41<mediaquery>"not"       {yyTok = MEDIA_NOT; return yyTok;}
42<mediaquery>"only"      {yyTok = MEDIA_ONLY; return yyTok;}
43<mediaquery>"and"       {yyTok = MEDIA_AND; return yyTok;}
44
45{string}                {yyTok = STRING; return yyTok;}
46{ident}                 {yyTok = IDENT; return yyTok;}
47{nth}                   {yyTok = NTH; return yyTok;}
48
49"#"{hexcolor}           {yyTok = HEX; return yyTok;}
50"#"{ident}              {yyTok = IDSEL; return yyTok;}
51
52"@import"               {BEGIN(mediaquery); yyTok = IMPORT_SYM; return yyTok;}
53"@page"                 {yyTok = PAGE_SYM; return yyTok;}
54"@media"                {BEGIN(mediaquery); yyTok = MEDIA_SYM; return yyTok;}
55"@font-face"            {yyTok = FONT_FACE_SYM; return yyTok;}
56"@charset"              {yyTok = CHARSET_SYM; return yyTok;}
57"@namespace"            {yyTok = NAMESPACE_SYM; return yyTok; }
58"@-webkit-rule"         {yyTok = WEBKIT_RULE_SYM; return yyTok; }
59"@-webkit-decls"        {yyTok = WEBKIT_DECLS_SYM; return yyTok; }
60"@-webkit-value"        {yyTok = WEBKIT_VALUE_SYM; return yyTok; }
61"@-webkit-mediaquery"   {BEGIN(mediaquery); yyTok = WEBKIT_MEDIAQUERY_SYM; return yyTok; }
62
63"!"{w}"important"       {yyTok = IMPORTANT_SYM; return yyTok;}
64
65{num}em                 {yyTok = EMS; return yyTok;}
66{num}__qem              {yyTok = QEMS; return yyTok;} /* quirky ems */
67{num}ex                 {yyTok = EXS; return yyTok;}
68{num}px                 {yyTok = PXS; return yyTok;}
69{num}cm                 {yyTok = CMS; return yyTok;}
70{num}mm                 {yyTok = MMS; return yyTok;}
71{num}in                 {yyTok = INS; return yyTok;}
72{num}pt                 {yyTok = PTS; return yyTok;}
73{num}pc                 {yyTok = PCS; return yyTok;}
74{num}deg                {yyTok = DEGS; return yyTok;}
75{num}rad                {yyTok = RADS; return yyTok;}
76{num}grad               {yyTok = GRADS; return yyTok;}
77{num}ms                 {yyTok = MSECS; return yyTok;}
78{num}s                  {yyTok = SECS; return yyTok;}
79{num}Hz                 {yyTok = HERZ; return yyTok;}
80{num}kHz                {yyTok = KHERZ; return yyTok;}
81{num}{ident}            {yyTok = DIMEN; return yyTok;}
82{num}%+                 {yyTok = PERCENTAGE; return yyTok;}
83{intnum}                {yyTok = INTEGER; return yyTok;}
84{num}                   {yyTok = FLOATTOKEN; return yyTok;}
85
86"not("                  {yyTok = NOTFUNCTION; return yyTok;}
87"url("{w}{string}{w}")" {yyTok = URI; return yyTok;}
88"url("{w}{url}{w}")"    {yyTok = URI; return yyTok;}
89{ident}"("              {yyTok = FUNCTION; return yyTok;}
90
91U\+{range}              {yyTok = UNICODERANGE; return yyTok;}
92U\+{h}{1,6}-{h}{1,6}    {yyTok = UNICODERANGE; return yyTok;}
93
94<mediaquery>"{"         |
95<mediaquery>";"         {BEGIN(INITIAL); yyTok = *yytext; return yyTok; }
96.                       {yyTok = *yytext; return yyTok;}
97
98%%
Note: See TracBrowser for help on using the repository browser.