Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(277)

Side by Side Diff: Source/core/css/CSSGrammar.y.in

Issue 13646013: Enable support for CSS Conditional Rules (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/bindings/v8/custom/V8CSSRuleCustom.cpp ('k') | Source/core/css/CSSParser.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2002-2003 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 2002-2003 Lars Knoll (knoll@kde.org)
3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 App le Inc. All rights reserved. 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 App le Inc. All rights reserved.
4 * Copyright (C) 2006 Alexey Proskuryakov (ap@nypop.com) 4 * Copyright (C) 2006 Alexey Proskuryakov (ap@nypop.com)
5 * Copyright (C) 2008 Eric Seidel <eric@webkit.org> 5 * Copyright (C) 2008 Eric Seidel <eric@webkit.org>
6 * Copyright (C) 2012 Intel Corporation. All rights reserved. 6 * Copyright (C) 2012 Intel Corporation. All rights reserved.
7 * 7 *
8 * This library is free software; you can redistribute it and/or 8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public 9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 %nonassoc ':' 111 %nonassoc ':'
112 %nonassoc '.' 112 %nonassoc '.'
113 %nonassoc '[' 113 %nonassoc '['
114 %nonassoc <string> '*' 114 %nonassoc <string> '*'
115 %nonassoc error 115 %nonassoc error
116 %left '|' 116 %left '|'
117 117
118 %token IMPORT_SYM 118 %token IMPORT_SYM
119 %token PAGE_SYM 119 %token PAGE_SYM
120 %token MEDIA_SYM 120 %token MEDIA_SYM
121 #if ENABLE_CSS3_CONDITIONAL_RULES
122 %token SUPPORTS_SYM 121 %token SUPPORTS_SYM
123 #endif
124 %token FONT_FACE_SYM 122 %token FONT_FACE_SYM
125 %token HOST_SYM 123 %token HOST_SYM
126 %token CHARSET_SYM 124 %token CHARSET_SYM
127 %token NAMESPACE_SYM 125 %token NAMESPACE_SYM
128 %token VARFUNCTION 126 %token VARFUNCTION
129 %token INTERNAL_DECLS_SYM 127 %token INTERNAL_DECLS_SYM
130 %token INTERNAL_RULE_SYM 128 %token INTERNAL_RULE_SYM
131 %token INTERNAL_SELECTOR_SYM 129 %token INTERNAL_SELECTOR_SYM
132 %token INTERNAL_VALUE_SYM 130 %token INTERNAL_VALUE_SYM
133 %token WEBKIT_KEYFRAME_RULE_SYM 131 %token WEBKIT_KEYFRAME_RULE_SYM
134 %token WEBKIT_KEYFRAMES_SYM 132 %token WEBKIT_KEYFRAMES_SYM
135 %token WEBKIT_MEDIAQUERY_SYM 133 %token WEBKIT_MEDIAQUERY_SYM
136 %token WEBKIT_REGION_RULE_SYM 134 %token WEBKIT_REGION_RULE_SYM
137 %token WEBKIT_VIEWPORT_RULE_SYM 135 %token WEBKIT_VIEWPORT_RULE_SYM
138 #if ENABLE_CSS3_CONDITIONAL_RULES
139 %token WEBKIT_SUPPORTS_CONDITION_SYM 136 %token WEBKIT_SUPPORTS_CONDITION_SYM
140 #endif
141 %token WEBKIT_FILTER_RULE_SYM 137 %token WEBKIT_FILTER_RULE_SYM
142 %token <marginBox> TOPLEFTCORNER_SYM 138 %token <marginBox> TOPLEFTCORNER_SYM
143 %token <marginBox> TOPLEFT_SYM 139 %token <marginBox> TOPLEFT_SYM
144 %token <marginBox> TOPCENTER_SYM 140 %token <marginBox> TOPCENTER_SYM
145 %token <marginBox> TOPRIGHT_SYM 141 %token <marginBox> TOPRIGHT_SYM
146 %token <marginBox> TOPRIGHTCORNER_SYM 142 %token <marginBox> TOPRIGHTCORNER_SYM
147 %token <marginBox> BOTTOMLEFTCORNER_SYM 143 %token <marginBox> BOTTOMLEFTCORNER_SYM
148 %token <marginBox> BOTTOMLEFT_SYM 144 %token <marginBox> BOTTOMLEFT_SYM
149 %token <marginBox> BOTTOMCENTER_SYM 145 %token <marginBox> BOTTOMCENTER_SYM
150 %token <marginBox> BOTTOMRIGHT_SYM 146 %token <marginBox> BOTTOMRIGHT_SYM
151 %token <marginBox> BOTTOMRIGHTCORNER_SYM 147 %token <marginBox> BOTTOMRIGHTCORNER_SYM
152 %token <marginBox> LEFTTOP_SYM 148 %token <marginBox> LEFTTOP_SYM
153 %token <marginBox> LEFTMIDDLE_SYM 149 %token <marginBox> LEFTMIDDLE_SYM
154 %token <marginBox> LEFTBOTTOM_SYM 150 %token <marginBox> LEFTBOTTOM_SYM
155 %token <marginBox> RIGHTTOP_SYM 151 %token <marginBox> RIGHTTOP_SYM
156 %token <marginBox> RIGHTMIDDLE_SYM 152 %token <marginBox> RIGHTMIDDLE_SYM
157 %token <marginBox> RIGHTBOTTOM_SYM 153 %token <marginBox> RIGHTBOTTOM_SYM
158 154
159 %token ATKEYWORD 155 %token ATKEYWORD
160 156
161 %token IMPORTANT_SYM 157 %token IMPORTANT_SYM
162 %token MEDIA_ONLY 158 %token MEDIA_ONLY
163 %token MEDIA_NOT 159 %token MEDIA_NOT
164 %token MEDIA_AND 160 %token MEDIA_AND
165 #if ENABLE_CSS3_CONDITIONAL_RULES 161
166 %token SUPPORTS_NOT 162 %token SUPPORTS_NOT
167 %token SUPPORTS_AND 163 %token SUPPORTS_AND
168 %token SUPPORTS_OR 164 %token SUPPORTS_OR
169 #endif
170 165
171 %token <number> REMS 166 %token <number> REMS
172 %token <number> CHS 167 %token <number> CHS
173 %token <number> QEMS 168 %token <number> QEMS
174 %token <number> EMS 169 %token <number> EMS
175 %token <number> EXS 170 %token <number> EXS
176 %token <number> PXS 171 %token <number> PXS
177 %token <number> CMS 172 %token <number> CMS
178 %token <number> MMS 173 %token <number> MMS
179 %token <number> INS 174 %token <number> INS
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 %type <rule> invalid_rule 224 %type <rule> invalid_rule
230 %type <rule> save_block 225 %type <rule> save_block
231 %type <rule> invalid_at 226 %type <rule> invalid_at
232 %type <rule> rule 227 %type <rule> rule
233 %type <rule> valid_rule 228 %type <rule> valid_rule
234 %type <ruleList> block_rule_list 229 %type <ruleList> block_rule_list
235 %type <ruleList> region_block_rule_list 230 %type <ruleList> region_block_rule_list
236 %type <rule> block_rule 231 %type <rule> block_rule
237 %type <rule> block_valid_rule 232 %type <rule> block_valid_rule
238 %type <rule> region 233 %type <rule> region
239 #if ENABLE_CSS3_CONDITIONAL_RULES
240 %type <rule> supports 234 %type <rule> supports
241 #endif
242 #if ENABLE_CSS_DEVICE_ADAPTATION 235 #if ENABLE_CSS_DEVICE_ADAPTATION
243 %type <rule> viewport 236 %type <rule> viewport
244 #endif 237 #endif
245 %type <rule> filter 238 %type <rule> filter
246 239
247 %type <string> maybe_ns_prefix 240 %type <string> maybe_ns_prefix
248 241
249 %type <string> namespace_selector 242 %type <string> namespace_selector
250 243
251 %type <string> string_or_uri 244 %type <string> string_or_uri
252 %type <string> ident_or_string 245 %type <string> ident_or_string
253 %type <string> medium 246 %type <string> medium
254 %type <marginBox> margin_sym 247 %type <marginBox> margin_sym
255 248
256 %type <string> media_feature 249 %type <string> media_feature
257 %type <mediaList> media_list 250 %type <mediaList> media_list
258 %type <mediaList> maybe_media_list 251 %type <mediaList> maybe_media_list
259 %type <mediaQuery> media_query 252 %type <mediaQuery> media_query
260 %type <mediaQueryRestrictor> maybe_media_restrictor 253 %type <mediaQueryRestrictor> maybe_media_restrictor
261 %type <valueList> maybe_media_value 254 %type <valueList> maybe_media_value
262 %type <mediaQueryExp> media_query_exp 255 %type <mediaQueryExp> media_query_exp
263 %type <mediaQueryExpList> media_query_exp_list 256 %type <mediaQueryExpList> media_query_exp_list
264 %type <mediaQueryExpList> maybe_and_media_query_exp_list 257 %type <mediaQueryExpList> maybe_and_media_query_exp_list
265 258
266 #if ENABLE_CSS3_CONDITIONAL_RULES
267 %type <boolean> supports_condition 259 %type <boolean> supports_condition
268 %type <boolean> supports_condition_in_parens 260 %type <boolean> supports_condition_in_parens
269 %type <boolean> supports_negation 261 %type <boolean> supports_negation
270 %type <boolean> supports_conjunction 262 %type <boolean> supports_conjunction
271 %type <boolean> supports_disjunction 263 %type <boolean> supports_disjunction
272 %type <boolean> supports_declaration_condition 264 %type <boolean> supports_declaration_condition
273 %type <boolean> supports_error 265 %type <boolean> supports_error
274 #endif
275 266
276 %type <string> keyframe_name 267 %type <string> keyframe_name
277 %type <keyframe> keyframe_rule 268 %type <keyframe> keyframe_rule
278 %type <keyframeRuleList> keyframes_rule 269 %type <keyframeRuleList> keyframes_rule
279 %type <valueList> key_list 270 %type <valueList> key_list
280 %type <value> key 271 %type <value> key
281 272
282 %type <id> property 273 %type <id> property
283 274
284 %type <selector> specifier 275 %type <selector> specifier
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 %% 320 %%
330 321
331 stylesheet: 322 stylesheet:
332 maybe_space maybe_charset maybe_sgml rule_list 323 maybe_space maybe_charset maybe_sgml rule_list
333 | internal_decls maybe_space 324 | internal_decls maybe_space
334 | internal_rule maybe_space 325 | internal_rule maybe_space
335 | internal_selector maybe_space 326 | internal_selector maybe_space
336 | internal_value maybe_space 327 | internal_value maybe_space
337 | webkit_mediaquery maybe_space 328 | webkit_mediaquery maybe_space
338 | webkit_keyframe_rule maybe_space 329 | webkit_keyframe_rule maybe_space
339 #if ENABLE_CSS3_CONDITIONAL_RULES
340 | webkit_supports_condition maybe_space 330 | webkit_supports_condition maybe_space
341 #endif
342 ; 331 ;
343 332
344 internal_rule: 333 internal_rule:
345 INTERNAL_RULE_SYM '{' maybe_space valid_rule maybe_space '}' { 334 INTERNAL_RULE_SYM '{' maybe_space valid_rule maybe_space '}' {
346 parser->m_rule = $4; 335 parser->m_rule = $4;
347 } 336 }
348 ; 337 ;
349 338
350 webkit_keyframe_rule: 339 webkit_keyframe_rule:
351 WEBKIT_KEYFRAME_RULE_SYM '{' maybe_space keyframe_rule maybe_space '}' { 340 WEBKIT_KEYFRAME_RULE_SYM '{' maybe_space keyframe_rule maybe_space '}' {
(...skipping 27 matching lines...) Expand all
379 368
380 internal_selector: 369 internal_selector:
381 INTERNAL_SELECTOR_SYM '{' maybe_space selector_list '}' { 370 INTERNAL_SELECTOR_SYM '{' maybe_space selector_list '}' {
382 if ($4) { 371 if ($4) {
383 if (parser->m_selectorListForParseSelector) 372 if (parser->m_selectorListForParseSelector)
384 parser->m_selectorListForParseSelector->adoptSelectorVector(*$4) ; 373 parser->m_selectorListForParseSelector->adoptSelectorVector(*$4) ;
385 } 374 }
386 } 375 }
387 ; 376 ;
388 377
389 #if ENABLE_CSS3_CONDITIONAL_RULES
390 webkit_supports_condition: 378 webkit_supports_condition:
391 WEBKIT_SUPPORTS_CONDITION_SYM '{' maybe_space supports_condition '}' { 379 WEBKIT_SUPPORTS_CONDITION_SYM '{' maybe_space supports_condition '}' {
392 parser->m_supportsCondition = $4; 380 parser->m_supportsCondition = $4;
393 } 381 }
394 ; 382 ;
395 #endif
396 383
397 maybe_space: 384 maybe_space:
398 /* empty */ %prec UNIMPORTANT_TOK 385 /* empty */ %prec UNIMPORTANT_TOK
399 | maybe_space WHITESPACE 386 | maybe_space WHITESPACE
400 ; 387 ;
401 388
402 maybe_sgml: 389 maybe_sgml:
403 /* empty */ 390 /* empty */
404 | maybe_sgml SGML_CD 391 | maybe_sgml SGML_CD
405 | maybe_sgml WHITESPACE 392 | maybe_sgml WHITESPACE
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
449 436
450 valid_rule: 437 valid_rule:
451 ruleset 438 ruleset
452 | media 439 | media
453 | page 440 | page
454 | font_face 441 | font_face
455 | keyframes 442 | keyframes
456 | namespace 443 | namespace
457 | import 444 | import
458 | region 445 | region
459 #if ENABLE_CSS3_CONDITIONAL_RULES
460 | supports 446 | supports
461 #endif
462 | host 447 | host
463 #if ENABLE_CSS_DEVICE_ADAPTATION 448 #if ENABLE_CSS_DEVICE_ADAPTATION
464 | viewport 449 | viewport
465 #endif 450 #endif
466 | filter 451 | filter
467 ; 452 ;
468 453
469 rule: 454 rule:
470 valid_rule { 455 valid_rule {
471 parser->m_hadSyntacticallyValidCSSRule = true; 456 parser->m_hadSyntacticallyValidCSSRule = true;
(...skipping 26 matching lines...) Expand all
498 } 483 }
499 } 484 }
500 ; 485 ;
501 486
502 block_valid_rule: 487 block_valid_rule:
503 ruleset 488 ruleset
504 | page 489 | page
505 | font_face 490 | font_face
506 | media 491 | media
507 | keyframes 492 | keyframes
508 #if ENABLE_CSS3_CONDITIONAL_RULES
509 | supports 493 | supports
510 #endif
511 #if ENABLE_CSS_DEVICE_ADAPTATION 494 #if ENABLE_CSS_DEVICE_ADAPTATION
512 | viewport 495 | viewport
513 #endif 496 #endif
514 | filter 497 | filter
515 ; 498 ;
516 499
517 block_rule: 500 block_rule:
518 block_valid_rule 501 block_valid_rule
519 | invalid_rule 502 | invalid_rule
520 | invalid_at 503 | invalid_at
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
709 parser->endRuleBody(true); 692 parser->endRuleBody(true);
710 } 693 }
711 ; 694 ;
712 695
713 medium: 696 medium:
714 IDENT maybe_space { 697 IDENT maybe_space {
715 $$ = $1; 698 $$ = $1;
716 } 699 }
717 ; 700 ;
718 701
719 #if ENABLE_CSS3_CONDITIONAL_RULES
720 supports: 702 supports:
721 before_supports_rule SUPPORTS_SYM maybe_space supports_condition at_supports _rule_header_end '{' at_rule_body_start maybe_space block_rule_list save_block { 703 before_supports_rule SUPPORTS_SYM maybe_space supports_condition at_supports _rule_header_end '{' at_rule_body_start maybe_space block_rule_list save_block {
722 $$ = parser->createSupportsRule($4, $9); 704 $$ = parser->createSupportsRule($4, $9);
723 } 705 }
724 | before_supports_rule SUPPORTS_SYM supports_error { 706 | before_supports_rule SUPPORTS_SYM supports_error {
725 parser->endRuleBody(true); 707 parser->endRuleBody(true);
726 parser->popSupportsRuleData(); 708 parser->popSupportsRuleData();
727 } 709 }
728 ; 710 ;
729 711
730 supports_error: 712 supports_error:
731 error ';' 713 error ';' {
732 | error invalid_block 714 }
715 | error invalid_block {
716 }
717 ;
733 718
734 before_supports_rule: 719 before_supports_rule:
735 /* empty */ { 720 /* empty */ {
736 parser->startRuleHeader(CSSRuleSourceData::SUPPORTS_RULE); 721 parser->startRuleHeader(CSSRuleSourceData::SUPPORTS_RULE);
737 parser->markSupportsRuleHeaderStart(); 722 parser->markSupportsRuleHeaderStart();
738 } 723 }
739 ; 724 ;
740 725
741 at_supports_rule_header_end: 726 at_supports_rule_header_end:
742 /* empty */ { 727 /* empty */ {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
774 | supports_disjunction SUPPORTS_OR maybe_space supports_condition_in_parens { 759 | supports_disjunction SUPPORTS_OR maybe_space supports_condition_in_parens {
775 $$ = $1 || $4; 760 $$ = $1 || $4;
776 } 761 }
777 ; 762 ;
778 763
779 supports_condition_in_parens: 764 supports_condition_in_parens:
780 '(' maybe_space supports_condition ')' maybe_space { 765 '(' maybe_space supports_condition ')' maybe_space {
781 $$ = $3; 766 $$ = $3;
782 } 767 }
783 | supports_declaration_condition 768 | supports_declaration_condition
784 | '(' error ')' 769 | '(' error ')' {
770 $$ = false;
771 }
785 ; 772 ;
786 773
787 supports_declaration_condition: 774 supports_declaration_condition:
788 '(' maybe_space property ':' maybe_space expr prio ')' maybe_space { 775 '(' maybe_space property ':' maybe_space expr prio ')' maybe_space {
789 $$ = false; 776 $$ = false;
790 CSSParser* p = static_cast<CSSParser*>(parser); 777 CSSParser* p = static_cast<CSSParser*>(parser);
791 if ($3 && $6) { 778 if ($3 && $6) {
792 p->m_valueList = p->sinkFloatingValueList($6); 779 p->m_valueList = p->sinkFloatingValueList($6);
793 int oldParsedProperties = p->m_parsedProperties.size(); 780 int oldParsedProperties = p->m_parsedProperties.size();
794 $$ = p->parseValue(static_cast<CSSPropertyID>($3), $7); 781 $$ = p->parseValue(static_cast<CSSPropertyID>($3), $7);
795 // We just need to know if the declaration is supported as it is wri tten. Rollback any additions. 782 // We just need to know if the declaration is supported as it is wri tten. Rollback any additions.
796 if ($$) 783 if ($$)
797 p->rollbackLastProperties(p->m_parsedProperties.size() - oldPars edProperties); 784 p->rollbackLastProperties(p->m_parsedProperties.size() - oldPars edProperties);
798 p->m_valueList = nullptr; 785 p->m_valueList = nullptr;
799 } 786 }
800 p->endProperty($7, false); 787 p->endProperty($7, false);
801 } 788 }
802 ; 789 ;
803 #endif
804 790
805 before_keyframes_rule: 791 before_keyframes_rule:
806 /* empty */ { 792 /* empty */ {
807 parser->startRuleHeader(CSSRuleSourceData::KEYFRAMES_RULE); 793 parser->startRuleHeader(CSSRuleSourceData::KEYFRAMES_RULE);
808 } 794 }
809 ; 795 ;
810 796
811 keyframes: 797 keyframes:
812 before_keyframes_rule WEBKIT_KEYFRAMES_SYM maybe_space keyframe_name at_rule _header_end_maybe_space '{' at_rule_body_start maybe_space keyframes_rule closin g_brace { 798 before_keyframes_rule WEBKIT_KEYFRAMES_SYM maybe_space keyframe_name at_rule _header_end_maybe_space '{' at_rule_body_start maybe_space keyframes_rule closin g_brace {
813 $$ = parser->createKeyframesRule($4, parser->sinkFloatingKeyframeVector( $9)); 799 $$ = parser->createKeyframesRule($4, parser->sinkFloatingKeyframeVector( $9));
(...skipping 1192 matching lines...) Expand 10 before | Expand all | Expand 10 after
2006 } 1992 }
2007 ; 1993 ;
2008 1994
2009 error_location: { 1995 error_location: {
2010 $$ = parser->currentLocation(); 1996 $$ = parser->currentLocation();
2011 } 1997 }
2012 ; 1998 ;
2013 1999
2014 %% 2000 %%
2015 2001
OLDNEW
« no previous file with comments | « Source/bindings/v8/custom/V8CSSRuleCustom.cpp ('k') | Source/core/css/CSSParser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698