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: sky/engine/core/css/parser/CSSGrammar.y

Issue 807703003: Remove @media rules. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years 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
OLDNEW
1 %{ 1 %{
2 2
3 /* 3 /*
4 * Copyright (C) 2002-2003 Lars Knoll (knoll@kde.org) 4 * Copyright (C) 2002-2003 Lars Knoll (knoll@kde.org)
5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 App le Inc. All rights reserved. 5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 App le Inc. All rights reserved.
6 * Copyright (C) 2006 Alexey Proskuryakov (ap@nypop.com) 6 * Copyright (C) 2006 Alexey Proskuryakov (ap@nypop.com)
7 * Copyright (C) 2008 Eric Seidel <eric@webkit.org> 7 * Copyright (C) 2008 Eric Seidel <eric@webkit.org>
8 * Copyright (C) 2012 Intel Corporation. All rights reserved. 8 * Copyright (C) 2012 Intel Corporation. All rights reserved.
9 * 9 *
10 * This library is free software; you can redistribute it and/or 10 * This library is free software; you can redistribute it and/or
(...skipping 11 matching lines...) Expand all
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 U SA 22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 U SA
23 * 23 *
24 */ 24 */
25 25
26 #include "config.h" 26 #include "config.h"
27 27
28 #include "CSSPropertyNames.h" 28 #include "CSSPropertyNames.h"
29 #include "core/css/CSSPrimitiveValue.h" 29 #include "core/css/CSSPrimitiveValue.h"
30 #include "core/css/CSSSelector.h" 30 #include "core/css/CSSSelector.h"
31 #include "core/css/CSSSelectorList.h" 31 #include "core/css/CSSSelectorList.h"
32 #include "core/css/MediaList.h"
33 #include "core/css/MediaQueryExp.h"
34 #include "core/css/StyleKeyframe.h" 32 #include "core/css/StyleKeyframe.h"
35 #include "core/css/StyleRule.h" 33 #include "core/css/StyleRule.h"
36 #include "core/css/StyleRuleKeyframes.h" 34 #include "core/css/StyleRuleKeyframes.h"
37 #include "core/css/StyleSheetContents.h" 35 #include "core/css/StyleSheetContents.h"
38 #include "core/css/parser/BisonCSSParser.h" 36 #include "core/css/parser/BisonCSSParser.h"
39 #include "core/css/parser/CSSParserMode.h" 37 #include "core/css/parser/CSSParserMode.h"
40 #include "core/dom/Document.h" 38 #include "core/dom/Document.h"
41 #include "sky/engine/core/css/MediaList.h"
42 #include "wtf/FastMalloc.h" 39 #include "wtf/FastMalloc.h"
43 #include <stdlib.h> 40 #include <stdlib.h>
44 #include <string.h> 41 #include <string.h>
45 42
46 using namespace blink; 43 using namespace blink;
47 44
48 #define YYMALLOC fastMalloc 45 #define YYMALLOC fastMalloc
49 #define YYFREE fastFree 46 #define YYFREE fastFree
50 47
51 #define YYENABLE_NLS 0 48 #define YYENABLE_NLS 0
(...skipping 14 matching lines...) Expand all
66 63
67 %union { 64 %union {
68 bool boolean; 65 bool boolean;
69 char character; 66 char character;
70 int integer; 67 int integer;
71 double number; 68 double number;
72 CSSParserString string; 69 CSSParserString string;
73 70
74 StyleRuleBase* rule; 71 StyleRuleBase* rule;
75 // The content of the three below HeapVectors are guaranteed to be kept aliv e by 72 // The content of the three below HeapVectors are guaranteed to be kept aliv e by
76 // the corresponding m_parsedRules, m_floatingMediaQueryExpList, and m_parse dKeyFrames 73 // the corresponding m_parsedRules, and m_parsedKeyFrames
77 // lists in BisonCSSParser.h. 74 // lists in BisonCSSParser.h.
78 Vector<RefPtr<StyleRuleBase> >* ruleList; 75 Vector<RefPtr<StyleRuleBase> >* ruleList;
79 Vector<OwnPtr<MediaQueryExp> >* mediaQueryExpList;
80 Vector<RefPtr<StyleKeyframe> >* keyframeRuleList; 76 Vector<RefPtr<StyleKeyframe> >* keyframeRuleList;
81 CSSParserSelector* selector; 77 CSSParserSelector* selector;
82 Vector<OwnPtr<CSSParserSelector> >* selectorList; 78 Vector<OwnPtr<CSSParserSelector> >* selectorList;
83 CSSSelector::AttributeMatchType attributeMatchType; 79 CSSSelector::AttributeMatchType attributeMatchType;
84 MediaQuerySet* mediaList;
85 MediaQuery* mediaQuery;
86 MediaQuery::Restrictor mediaQueryRestrictor;
87 MediaQueryExp* mediaQueryExp;
88 CSSParserValue value; 80 CSSParserValue value;
89 CSSParserValueList* valueList; 81 CSSParserValueList* valueList;
90 StyleKeyframe* keyframe; 82 StyleKeyframe* keyframe;
91 float val; 83 float val;
92 CSSPropertyID id; 84 CSSPropertyID id;
93 CSSParserLocation location; 85 CSSParserLocation location;
94 } 86 }
95 87
96 %{ 88 %{
97 89
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 159
168 %nonassoc <string> HEX 160 %nonassoc <string> HEX
169 %nonassoc <string> IDSEL 161 %nonassoc <string> IDSEL
170 %nonassoc ':' 162 %nonassoc ':'
171 %nonassoc '.' 163 %nonassoc '.'
172 %nonassoc '[' 164 %nonassoc '['
173 %nonassoc <string> '*' 165 %nonassoc <string> '*'
174 %nonassoc error 166 %nonassoc error
175 %left '|' 167 %left '|'
176 168
177 %token MEDIA_SYM
178 %token SUPPORTS_SYM 169 %token SUPPORTS_SYM
179 %token FONT_FACE_SYM 170 %token FONT_FACE_SYM
180 %token CHARSET_SYM 171 %token CHARSET_SYM
181 %token INTERNAL_DECLS_SYM 172 %token INTERNAL_DECLS_SYM
182 %token INTERNAL_MEDIALIST_SYM
183 %token INTERNAL_RULE_SYM 173 %token INTERNAL_RULE_SYM
184 %token INTERNAL_SELECTOR_SYM 174 %token INTERNAL_SELECTOR_SYM
185 %token INTERNAL_VALUE_SYM 175 %token INTERNAL_VALUE_SYM
186 %token INTERNAL_KEYFRAME_RULE_SYM 176 %token INTERNAL_KEYFRAME_RULE_SYM
187 %token INTERNAL_KEYFRAME_KEY_LIST_SYM 177 %token INTERNAL_KEYFRAME_KEY_LIST_SYM
188 %token INTERNAL_SUPPORTS_CONDITION_SYM 178 %token INTERNAL_SUPPORTS_CONDITION_SYM
189 %token KEYFRAMES_SYM 179 %token KEYFRAMES_SYM
190 180
191 %token ATKEYWORD 181 %token ATKEYWORD
192 182
193 %token IMPORTANT_SYM 183 %token IMPORTANT_SYM
194 %token MEDIA_ONLY
195 %token MEDIA_NOT
196 %token MEDIA_AND
197 %token MEDIA_OR
198 184
199 %token SUPPORTS_NOT 185 %token SUPPORTS_NOT
200 %token SUPPORTS_AND 186 %token SUPPORTS_AND
201 %token SUPPORTS_OR 187 %token SUPPORTS_OR
202 188
203 %token <number> CHS 189 %token <number> CHS
204 %token <number> EMS 190 %token <number> EMS
205 %token <number> EXS 191 %token <number> EXS
206 %token <number> PXS 192 %token <number> PXS
207 %token <number> CMS 193 %token <number> CMS
(...skipping 25 matching lines...) Expand all
233 219
234 %token <string> URI 220 %token <string> URI
235 %token <string> FUNCTION 221 %token <string> FUNCTION
236 %token <string> NOTFUNCTION 222 %token <string> NOTFUNCTION
237 %token <string> CALCFUNCTION 223 %token <string> CALCFUNCTION
238 %token <string> HOSTFUNCTION 224 %token <string> HOSTFUNCTION
239 225
240 %token <string> UNICODERANGE 226 %token <string> UNICODERANGE
241 227
242 %type <rule> ruleset 228 %type <rule> ruleset
243 %type <rule> media
244 %type <rule> font_face 229 %type <rule> font_face
245 %type <rule> keyframes 230 %type <rule> keyframes
246 %type <rule> rule 231 %type <rule> rule
247 %type <rule> valid_rule 232 %type <rule> valid_rule
248 %type <ruleList> block_rule_body 233 %type <ruleList> block_rule_body
249 %type <ruleList> block_rule_list 234 %type <ruleList> block_rule_list
250 %type <rule> block_rule 235 %type <rule> block_rule
251 %type <rule> block_valid_rule 236 %type <rule> block_valid_rule
252 %type <rule> supports 237 %type <rule> supports
253 %type <boolean> keyframes_rule_start 238 %type <boolean> keyframes_rule_start
254 239
255 %type <string> ident_or_string 240 %type <string> ident_or_string
256 %type <string> medium
257
258 %type <mediaList> media_list
259 %type <mediaList> maybe_media_list
260 %type <mediaList> mq_list
261 %type <mediaQuery> media_query
262 %type <mediaQuery> valid_media_query
263 %type <mediaQueryRestrictor> maybe_media_restrictor
264 %type <valueList> maybe_media_value
265 %type <mediaQueryExp> media_query_exp
266 %type <mediaQueryExpList> media_query_exp_list
267 %type <mediaQueryExpList> maybe_and_media_query_exp_list
268 241
269 %type <boolean> supports_condition 242 %type <boolean> supports_condition
270 %type <boolean> supports_condition_in_parens 243 %type <boolean> supports_condition_in_parens
271 %type <boolean> supports_negation 244 %type <boolean> supports_negation
272 %type <boolean> supports_conjunction 245 %type <boolean> supports_conjunction
273 %type <boolean> supports_disjunction 246 %type <boolean> supports_disjunction
274 %type <boolean> supports_declaration_condition 247 %type <boolean> supports_declaration_condition
275 248
276 %type <string> keyframe_name 249 %type <string> keyframe_name
277 %type <keyframe> keyframe_rule 250 %type <keyframe> keyframe_rule
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 %type <value> track_names_list 298 %type <value> track_names_list
326 299
327 %% 300 %%
328 301
329 stylesheet: 302 stylesheet:
330 maybe_charset maybe_sgml rule_list 303 maybe_charset maybe_sgml rule_list
331 | internal_decls 304 | internal_decls
332 | internal_rule 305 | internal_rule
333 | internal_selector 306 | internal_selector
334 | internal_value 307 | internal_value
335 | internal_medialist
336 | internal_keyframe_rule 308 | internal_keyframe_rule
337 | internal_keyframe_key_list 309 | internal_keyframe_key_list
338 | internal_supports_condition 310 | internal_supports_condition
339 ; 311 ;
340 312
341 internal_rule: 313 internal_rule:
342 INTERNAL_RULE_SYM maybe_space valid_rule maybe_space TOKEN_EOF { 314 INTERNAL_RULE_SYM maybe_space valid_rule maybe_space TOKEN_EOF {
343 parser->m_rule = $3; 315 parser->m_rule = $3;
344 } 316 }
345 ; 317 ;
(...skipping 19 matching lines...) Expand all
365 internal_value: 337 internal_value:
366 INTERNAL_VALUE_SYM maybe_space expr TOKEN_EOF { 338 INTERNAL_VALUE_SYM maybe_space expr TOKEN_EOF {
367 parser->m_valueList = parser->sinkFloatingValueList($3); 339 parser->m_valueList = parser->sinkFloatingValueList($3);
368 int oldParsedProperties = parser->m_parsedProperties.size(); 340 int oldParsedProperties = parser->m_parsedProperties.size();
369 if (!parser->parseValue(parser->m_id, parser->m_important)) 341 if (!parser->parseValue(parser->m_id, parser->m_important))
370 parser->rollbackLastProperties(parser->m_parsedProperties.size() - o ldParsedProperties); 342 parser->rollbackLastProperties(parser->m_parsedProperties.size() - o ldParsedProperties);
371 parser->m_valueList = nullptr; 343 parser->m_valueList = nullptr;
372 } 344 }
373 ; 345 ;
374 346
375 internal_medialist:
376 INTERNAL_MEDIALIST_SYM maybe_space location_label maybe_media_list TOKEN_EOF {
377 parser->m_mediaList = $4;
378 }
379 ;
380
381 internal_selector: 347 internal_selector:
382 INTERNAL_SELECTOR_SYM maybe_space selector_list TOKEN_EOF { 348 INTERNAL_SELECTOR_SYM maybe_space selector_list TOKEN_EOF {
383 if (parser->m_selectorListForParseSelector) 349 if (parser->m_selectorListForParseSelector)
384 parser->m_selectorListForParseSelector->adoptSelectorVector(*$3); 350 parser->m_selectorListForParseSelector->adoptSelectorVector(*$3);
385 } 351 }
386 ; 352 ;
387 353
388 internal_supports_condition: 354 internal_supports_condition:
389 INTERNAL_SUPPORTS_CONDITION_SYM maybe_space supports_condition TOKEN_EOF { 355 INTERNAL_SUPPORTS_CONDITION_SYM maybe_space supports_condition TOKEN_EOF {
390 parser->m_supportsCondition = $3; 356 parser->m_supportsCondition = $3;
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
439 rule_list: 405 rule_list:
440 /* empty */ 406 /* empty */
441 | rule_list rule maybe_sgml { 407 | rule_list rule maybe_sgml {
442 if ($2 && parser->m_styleSheet) 408 if ($2 && parser->m_styleSheet)
443 parser->m_styleSheet->parserAppendRule($2); 409 parser->m_styleSheet->parserAppendRule($2);
444 } 410 }
445 ; 411 ;
446 412
447 valid_rule: 413 valid_rule:
448 ruleset 414 ruleset
449 | media
450 | font_face 415 | font_face
451 | keyframes 416 | keyframes
452 | supports 417 | supports
453 ; 418 ;
454 419
455 before_rule: 420 before_rule:
456 /* empty */ { 421 /* empty */ {
457 parser->startRule(); 422 parser->startRule();
458 } 423 }
459 ; 424 ;
(...skipping 24 matching lines...) Expand all
484 449
485 block_rule_recovery: 450 block_rule_recovery:
486 before_rule invalid_rule_header { 451 before_rule invalid_rule_header {
487 parser->endRule(false); 452 parser->endRule(false);
488 } 453 }
489 ; 454 ;
490 455
491 block_valid_rule: 456 block_valid_rule:
492 ruleset 457 ruleset
493 | font_face 458 | font_face
494 | media
495 | keyframes 459 | keyframes
496 | supports 460 | supports
497 ; 461 ;
498 462
499 block_rule: 463 block_rule:
500 before_rule block_valid_rule { 464 before_rule block_valid_rule {
501 $$ = $2; 465 $$ = $2;
502 parser->endRule(!!$$); 466 parser->endRule(!!$$);
503 } 467 }
504 | before_rule invalid_rule { 468 | before_rule invalid_rule {
505 $$ = 0; 469 $$ = 0;
506 parser->endRule(false); 470 parser->endRule(false);
507 } 471 }
508 ; 472 ;
509 473
510 maybe_media_value:
511 /*empty*/ {
512 $$ = 0;
513 }
514 | ':' maybe_space expr {
515 $$ = $3;
516 }
517 ;
518
519 media_query_exp:
520 '(' maybe_space IDENT maybe_space maybe_media_value closing_parenthesis {
521 parser->tokenToLowerCase($3);
522 $$ = parser->createFloatingMediaQueryExp($3, $5);
523 if (!$$)
524 YYERROR;
525 }
526 | '(' error error_recovery closing_parenthesis {
527 YYERROR;
528 }
529 ;
530
531 media_query_exp_list:
532 media_query_exp {
533 $$ = parser->createFloatingMediaQueryExpList();
534 $$->append(parser->sinkFloatingMediaQueryExp($1));
535 }
536 | media_query_exp_list maybe_space MEDIA_AND maybe_space media_query_exp {
537 $$ = $1;
538 $$->append(parser->sinkFloatingMediaQueryExp($5));
539 }
540 ;
541
542 maybe_and_media_query_exp_list:
543 maybe_space {
544 $$ = parser->createFloatingMediaQueryExpList();
545 }
546 | maybe_space MEDIA_AND maybe_space media_query_exp_list maybe_space {
547 $$ = $4;
548 }
549 ;
550
551 maybe_media_restrictor:
552 /*empty*/ {
553 $$ = MediaQuery::None;
554 }
555 | MEDIA_ONLY maybe_space {
556 $$ = MediaQuery::Only;
557 }
558 | MEDIA_NOT maybe_space {
559 $$ = MediaQuery::Not;
560 }
561 ;
562
563 valid_media_query:
564 media_query_exp_list maybe_space {
565 $$ = parser->createFloatingMediaQuery(parser->sinkFloatingMediaQueryExpL ist($1));
566 }
567 | maybe_media_restrictor medium maybe_and_media_query_exp_list {
568 parser->tokenToLowerCase($2);
569 $$ = parser->createFloatingMediaQuery($1, $2, parser->sinkFloatingMediaQ ueryExpList($3));
570 }
571 ;
572
573 media_query:
574 valid_media_query
575 | valid_media_query error error_location rule_error_recovery {
576 parser->reportError(parser->lastLocationLabel(), InvalidMediaQueryCSSErr or);
577 $$ = parser->createFloatingNotAllQuery();
578 }
579 | error error_location rule_error_recovery {
580 parser->reportError(parser->lastLocationLabel(), InvalidMediaQueryCSSErr or);
581 $$ = parser->createFloatingNotAllQuery();
582 }
583 ;
584
585 maybe_media_list:
586 /* empty */ {
587 $$ = parser->createMediaQuerySet();
588 }
589 | media_list
590 ;
591
592 media_list:
593 media_query {
594 $$ = parser->createMediaQuerySet();
595 $$->addMediaQuery(parser->sinkFloatingMediaQuery($1));
596 }
597 | mq_list media_query {
598 $$ = $1;
599 $$->addMediaQuery(parser->sinkFloatingMediaQuery($2));
600 }
601 | mq_list {
602 $$ = $1;
603 $$->addMediaQuery(parser->sinkFloatingMediaQuery(parser->createFloatingN otAllQuery()));
604 }
605 ;
606
607 mq_list:
608 media_query ',' maybe_space location_label {
609 $$ = parser->createMediaQuerySet();
610 $$->addMediaQuery(parser->sinkFloatingMediaQuery($1));
611 }
612 | mq_list media_query ',' maybe_space location_label {
613 $$ = $1;
614 $$->addMediaQuery(parser->sinkFloatingMediaQuery($2));
615 }
616 ;
617
618 at_rule_body_start: 474 at_rule_body_start:
619 /* empty */ { 475 /* empty */ {
620 parser->startRuleBody(); 476 parser->startRuleBody();
621 } 477 }
622 ; 478 ;
623 479
624 before_media_rule:
625 /* empty */ {
626 parser->startRuleHeader(CSSRuleSourceData::MEDIA_RULE);
627 }
628 ;
629
630 at_rule_header_end_maybe_space: 480 at_rule_header_end_maybe_space:
631 maybe_space { 481 maybe_space {
632 parser->endRuleHeader(); 482 parser->endRuleHeader();
633 } 483 }
634 ; 484 ;
635 485
636 media_rule_start:
637 before_media_rule MEDIA_SYM maybe_space;
638
639 media:
640 media_rule_start maybe_media_list '{' at_rule_header_end at_rule_body_start maybe_space block_rule_body closing_brace {
641 $$ = parser->createMediaRule($2, $7);
642 }
643 ;
644
645 medium:
646 IDENT
647 ;
648
649 supports: 486 supports:
650 before_supports_rule SUPPORTS_SYM maybe_space supports_condition at_supports _rule_header_end '{' at_rule_body_start maybe_space block_rule_body closing_brac e { 487 before_supports_rule SUPPORTS_SYM maybe_space supports_condition at_supports _rule_header_end '{' at_rule_body_start maybe_space block_rule_body closing_brac e {
651 $$ = parser->createSupportsRule($4, $9); 488 $$ = parser->createSupportsRule($4, $9);
652 } 489 }
653 ; 490 ;
654 491
655 before_supports_rule: 492 before_supports_rule:
656 /* empty */ { 493 /* empty */ {
657 parser->startRuleHeader(CSSRuleSourceData::SUPPORTS_RULE); 494 parser->startRuleHeader(CSSRuleSourceData::SUPPORTS_RULE);
658 parser->markSupportsRuleHeaderStart(); 495 parser->markSupportsRuleHeaderStart();
(...skipping 759 matching lines...) Expand 10 before | Expand all | Expand 10 after
1418 parser->reportError($1, InvalidRuleCSSError); 1255 parser->reportError($1, InvalidRuleCSSError);
1419 } 1256 }
1420 ; 1257 ;
1421 1258
1422 invalid_rule: 1259 invalid_rule:
1423 error error_location rule_error_recovery at_invalid_rule_header_end invalid_ block { 1260 error error_location rule_error_recovery at_invalid_rule_header_end invalid_ block {
1424 parser->reportError($2, InvalidRuleCSSError); 1261 parser->reportError($2, InvalidRuleCSSError);
1425 } 1262 }
1426 | regular_invalid_at_rule_header at_invalid_rule_header_end ';' 1263 | regular_invalid_at_rule_header at_invalid_rule_header_end ';'
1427 | regular_invalid_at_rule_header at_invalid_rule_header_end invalid_block 1264 | regular_invalid_at_rule_header at_invalid_rule_header_end invalid_block
1428 | media_rule_start maybe_media_list ';'
1429 ; 1265 ;
1430 1266
1431 invalid_rule_header: 1267 invalid_rule_header:
1432 error error_location rule_error_recovery at_invalid_rule_header_end { 1268 error error_location rule_error_recovery at_invalid_rule_header_end {
1433 parser->reportError($2, InvalidRuleCSSError); 1269 parser->reportError($2, InvalidRuleCSSError);
1434 } 1270 }
1435 | regular_invalid_at_rule_header at_invalid_rule_header_end 1271 | regular_invalid_at_rule_header at_invalid_rule_header_end
1436 | media_rule_start maybe_media_list
1437 ; 1272 ;
1438 1273
1439 at_invalid_rule_header_end: 1274 at_invalid_rule_header_end:
1440 /* empty */ { 1275 /* empty */ {
1441 parser->endInvalidRuleHeader(); 1276 parser->endInvalidRuleHeader();
1442 } 1277 }
1443 ; 1278 ;
1444 1279
1445 invalid_block: 1280 invalid_block:
1446 '{' error_recovery closing_brace { 1281 '{' error_recovery closing_brace {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1478 ; 1313 ;
1479 1314
1480 rule_error_recovery: 1315 rule_error_recovery:
1481 /* empty */ 1316 /* empty */
1482 | rule_error_recovery error 1317 | rule_error_recovery error
1483 | rule_error_recovery invalid_square_brackets_block 1318 | rule_error_recovery invalid_square_brackets_block
1484 | rule_error_recovery invalid_parentheses_block 1319 | rule_error_recovery invalid_parentheses_block
1485 ; 1320 ;
1486 1321
1487 %% 1322 %%
OLDNEW
« no previous file with comments | « sky/engine/core/css/parser/BisonCSSParserTest.cpp ('k') | sky/engine/core/css/parser/CSSTokenizer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698