Chromium Code Reviews| Index: frog/css/csstemplate.dart |
| diff --git a/frog/css/csstemplate.dart b/frog/css/csstemplate.dart |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..0aebea93075fdba60b892f3b3d0a3025a9c9a8c6 |
| --- /dev/null |
| +++ b/frog/css/csstemplate.dart |
| @@ -0,0 +1,45 @@ |
| +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
| +// for details. All rights reserved. Use of this source code is governed by a |
| +// BSD-style license that can be found in the LICENSE file. |
| + |
| +#import('css.dart'); |
| + |
| +class CssTemplate { |
| + // TODO(terry): Add obfuscation mapping file. |
| + static void xlate(String cssExpression, CssWorld world) { |
|
jimhug
2011/11/09 16:04:03
Speaking for Bob <smile>. Any reason not to just
terry
2011/11/09 21:56:06
Good point Bob (Jim?) I'll do that.
Done.
|
| + Parser parser = new Parser(new SourceFile(SourceFile.IN_MEMORY_FILE, |
| + cssExpression)); |
| + try { |
| + var tree = parser.template(true); |
| + if (tree != null) { |
| + parser.validateTemplate(tree.selectors, world); |
| + } |
| + } catch (var cssException) { |
| + print(cssException.toString()); |
| + throw cssException; |
| + } |
| + } |
| + |
| + // Returns pretty printed tree of the expression. |
| + static String xlateDebug(String cssExpression, CssWorld world) { |
| + Parser parser = new Parser(new SourceFile(SourceFile.IN_MEMORY_FILE, |
| + cssExpression)); |
| + String output = ""; |
| + String prettyTree = ""; |
| + try { |
| + var tree = parser.template(true); |
| + if (tree != null) { |
| + prettyTree = tree.toDebugString(); |
| + parser.validateTemplate(tree.selectors, world); |
| + output = prettyTree; |
| + } |
| + } catch (var cssException) { |
| + String error = cssException.toString(); |
| + output = "$error\n$prettyTree"; |
| + throw cssException; |
| + } |
| + |
| + return output; |
| + } |
| + |
| +} |