| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 html_css_fixup; | 5 library html_css_fixup; |
| 6 | 6 |
| 7 import 'dart:json' as json; | 7 import 'dart:json' as json; |
| 8 | 8 |
| 9 import 'package:csslib/parser.dart' as css; | 9 import 'package:csslib/parser.dart' as css; |
| 10 import 'package:csslib/visitor.dart'; | 10 import 'package:csslib/visitor.dart'; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 | 29 |
| 30 /** Emit CSS selectors scoped to the "is" attribute of the component. */ | 30 /** Emit CSS selectors scoped to the "is" attribute of the component. */ |
| 31 static const SCOPED_POLYFILL = const CssPolyfillKind(1); | 31 static const SCOPED_POLYFILL = const CssPolyfillKind(1); |
| 32 | 32 |
| 33 /** Emit CSS selectors mangled. */ | 33 /** Emit CSS selectors mangled. */ |
| 34 static const MANGLED_POLYFILL = const CssPolyfillKind(2); | 34 static const MANGLED_POLYFILL = const CssPolyfillKind(2); |
| 35 | 35 |
| 36 static CssPolyfillKind of(CompilerOptions options, ComponentInfo component) { | 36 static CssPolyfillKind of(CompilerOptions options, ComponentInfo component) { |
| 37 if (!options.processCss || !component.scoped) return NO_POLYFILL; | 37 if (!options.processCss || !component.scoped) return NO_POLYFILL; |
| 38 if (options.mangleCss) return MANGLED_POLYFILL; | 38 if (options.mangleCss) return MANGLED_POLYFILL; |
| 39 if (!component.hasAuthorStyles && !hasCssReset) return MANGLED_POLYFILL; | 39 if (!component.hasAuthorStyles && options.resetCssFile == null) { |
| 40 return MANGLED_POLYFILL; |
| 41 } |
| 40 return SCOPED_POLYFILL; | 42 return SCOPED_POLYFILL; |
| 41 } | 43 } |
| 42 } | 44 } |
| 43 | 45 |
| 44 | 46 |
| 45 /** | 47 /** |
| 46 * If processCss is enabled, prefix any component's HTML attributes for id or | 48 * If processCss is enabled, prefix any component's HTML attributes for id or |
| 47 * class to reference the mangled CSS class name or id. | 49 * class to reference the mangled CSS class name or id. |
| 48 */ | 50 */ |
| 49 void fixupHtmlCss(FileInfo fileInfo, CompilerOptions options) { | 51 void fixupHtmlCss(FileInfo fileInfo, CompilerOptions options) { |
| (...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 579 | 581 |
| 580 // Find all imports return list of @imports in this style tag. | 582 // Find all imports return list of @imports in this style tag. |
| 581 var urlInfos = findImportsInStyleSheet(styleSheet, _packageRoot, | 583 var urlInfos = findImportsInStyleSheet(styleSheet, _packageRoot, |
| 582 _inputUrl, _messages); | 584 _inputUrl, _messages); |
| 583 imports.addAll(urlInfos); | 585 imports.addAll(urlInfos); |
| 584 } | 586 } |
| 585 } | 587 } |
| 586 super.visitElement(node); | 588 super.visitElement(node); |
| 587 } | 589 } |
| 588 } | 590 } |
| OLD | NEW |