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

Side by Side Diff: lib/parser.dart

Issue 13154004: import support (removed @include) (Closed) Base URL: https://github.com/dart-lang/csslib.git@master
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
« no previous file with comments | « no previous file | lib/src/css_printer.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library parser; 5 library parser;
6 6
7 import 'dart:math' as math; 7 import 'dart:math' as math;
8 8
9 import 'package:source_maps/span.dart' show File, Span, FileSpan; 9 import 'package:source_maps/span.dart' show File, Span, FileSpan;
10 10
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after
378 return null; 378 return null;
379 } 379 }
380 } 380 }
381 } 381 }
382 382
383 // Directive grammar: 383 // Directive grammar:
384 // 384 //
385 // import: '@import' [string | URI] media_list? 385 // import: '@import' [string | URI] media_list?
386 // media: '@media' media_query_list '{' ruleset '}' 386 // media: '@media' media_query_list '{' ruleset '}'
387 // page: '@page' [':' IDENT]? '{' declarations '}' 387 // page: '@page' [':' IDENT]? '{' declarations '}'
388 // include: '@include' [string | URI]
389 // stylet: '@stylet' IDENT '{' ruleset '}' 388 // stylet: '@stylet' IDENT '{' ruleset '}'
390 // media_query_list: IDENT [',' IDENT] 389 // media_query_list: IDENT [',' IDENT]
391 // keyframes: '@-webkit-keyframes ...' (see grammar below). 390 // keyframes: '@-webkit-keyframes ...' (see grammar below).
392 // font_face: '@font-face' '{' declarations '}' 391 // font_face: '@font-face' '{' declarations '}'
393 // namespace: '@namespace name url("xmlns") 392 // namespace: '@namespace name url("xmlns")
394 // 393 //
395 processDirective() { 394 processDirective() {
396 int start = _peekToken.start; 395 int start = _peekToken.start;
397 396
398 var tokId = _peek(); 397 var tokId = _peek();
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
553 _makeSpan(start))); 552 _makeSpan(start)));
554 553
555 } while (!_maybeEat(TokenKind.RBRACE)); 554 } while (!_maybeEat(TokenKind.RBRACE));
556 555
557 return kf; 556 return kf;
558 557
559 case TokenKind.DIRECTIVE_FONTFACE: 558 case TokenKind.DIRECTIVE_FONTFACE:
560 _next(); 559 _next();
561 return new FontFaceDirective(processDeclarations(), _makeSpan(start)); 560 return new FontFaceDirective(processDeclarations(), _makeSpan(start));
562 561
563 case TokenKind.DIRECTIVE_INCLUDE:
564 _next();
565 String relativeUrl = processQuotedString(false);
566 String url = '$_baseUrl/$relativeUrl';
567 // Does CSS file exist?
568 // TODO(sigmund,terry): this code seemed to be broken and unreachable
569 if (_otherFiles.containsKey(url)) {
570 var contents = _otherFiles[url];
571 Parser parser = new Parser(new File.text(url, contents), contents,
572 otherFiles: _otherFiles, start: 0, baseUrl: _baseUrl);
573 StyleSheet stylesheet = parser.parse();
574 return new IncludeDirective(
575 relativeUrl, stylesheet, _makeSpan(start));
576 }
577
578 _error('file doesn\'t exist $relativeUrl', _peekToken.span);
579
580 print("WARNING: @include doesn't work for uitest");
581 return new IncludeDirective(relativeUrl, null, _makeSpan(start));
582
583 case TokenKind.DIRECTIVE_STYLET: 562 case TokenKind.DIRECTIVE_STYLET:
584 /* Stylet grammar: 563 /* Stylet grammar:
585 * 564 *
586 * @stylet IDENT '{' 565 * @stylet IDENT '{'
587 * ruleset 566 * ruleset
588 * '}' 567 * '}'
589 */ 568 */
590 _next(); 569 _next();
591 570
592 var name; 571 var name;
(...skipping 1524 matching lines...) Expand 10 before | Expand all | Expand 10 after
2117 2096
2118 if (replace != null && result == null) { 2097 if (replace != null && result == null) {
2119 result = new StringBuffer(text.substring(0, i)); 2098 result = new StringBuffer(text.substring(0, i));
2120 } 2099 }
2121 2100
2122 if (result != null) result.write(replace != null ? replace : text[i]); 2101 if (result != null) result.write(replace != null ? replace : text[i]);
2123 } 2102 }
2124 2103
2125 return result == null ? text : result.toString(); 2104 return result == null ? text : result.toString();
2126 } 2105 }
OLDNEW
« no previous file with comments | « no previous file | lib/src/css_printer.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698