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

Side by Side Diff: utils/css/uitest.dart

Issue 10887023: Use new try-catch syntax in runtime/, tools/, and utils/. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 3 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 | « utils/css/parser.dart ('k') | utils/pub/pub.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) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 #import('dart:html'); 5 #import('dart:html');
6 #import('css.dart'); 6 #import('css.dart');
7 #import('../lib/file_system_memory.dart'); 7 #import('../lib/file_system_memory.dart');
8 8
9 void runCss([bool debug = false, bool parseOnly = false]) { 9 void runCss([bool debug = false, bool parseOnly = false]) {
10 final Document doc = window.document; 10 final Document doc = window.document;
(...skipping 14 matching lines...) Expand all
25 } 25 }
26 26
27 CssWorld cssWorld = new CssWorld(knownClasses, knownIds); 27 CssWorld cssWorld = new CssWorld(knownClasses, knownIds);
28 bool templateValid = true; 28 bool templateValid = true;
29 String dumpTree = ""; 29 String dumpTree = "";
30 30
31 String cssExpr = expression.value; 31 String cssExpr = expression.value;
32 if (!debug) { 32 if (!debug) {
33 try { 33 try {
34 cssParseAndValidate(cssExpr, cssWorld); 34 cssParseAndValidate(cssExpr, cssWorld);
35 } catch (final cssException) { 35 } catch (cssException) {
36 templateValid = false; 36 templateValid = false;
37 dumpTree = cssException.toString(); 37 dumpTree = cssException.toString();
38 } 38 }
39 } else if (parseOnly) { 39 } else if (parseOnly) {
40 try { 40 try {
41 Parser parser = new Parser(new SourceFile( 41 Parser parser = new Parser(new SourceFile(
42 SourceFile.IN_MEMORY_FILE, cssExpr)); 42 SourceFile.IN_MEMORY_FILE, cssExpr));
43 Stylesheet stylesheet = parser.parse(); 43 Stylesheet stylesheet = parser.parse();
44 StringBuffer stylesheetTree = new StringBuffer(); 44 StringBuffer stylesheetTree = new StringBuffer();
45 String prettyStylesheet = stylesheet.toString(); 45 String prettyStylesheet = stylesheet.toString();
46 stylesheetTree.add("${prettyStylesheet}\n"); 46 stylesheetTree.add("${prettyStylesheet}\n");
47 stylesheetTree.add("\n============>Tree Dump<============\n"); 47 stylesheetTree.add("\n============>Tree Dump<============\n");
48 stylesheetTree.add(stylesheet.toDebugString()); 48 stylesheetTree.add(stylesheet.toDebugString());
49 dumpTree = stylesheetTree.toString(); 49 dumpTree = stylesheetTree.toString();
50 } catch (final cssParseException) { 50 } catch (cssParseException) {
51 templateValid = false; 51 templateValid = false;
52 dumpTree = cssParseException.toString(); 52 dumpTree = cssParseException.toString();
53 } 53 }
54 } else { 54 } else {
55 try { 55 try {
56 dumpTree = cssParseAndValidateDebug(cssExpr, cssWorld); 56 dumpTree = cssParseAndValidateDebug(cssExpr, cssWorld);
57 } catch (final cssException) { 57 } catch (cssException) {
58 templateValid = false; 58 templateValid = false;
59 dumpTree = cssException.toString(); 59 dumpTree = cssException.toString();
60 } 60 }
61 } 61 }
62 62
63 final bgcolor = templateValid ? "white" : "red"; 63 final bgcolor = templateValid ? "white" : "red";
64 final color = templateValid ? "black" : "white"; 64 final color = templateValid ? "black" : "white";
65 final valid = templateValid ? "VALID" : "NOT VALID"; 65 final valid = templateValid ? "VALID" : "NOT VALID";
66 String resultStyle = "resize:none; margin:0; height:100%; width:100%;" 66 String resultStyle = "resize:none; margin:0; height:100%; width:100%;"
67 "padding:5px 7px;"; 67 "padding:5px 7px;";
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 runCss(); 182 runCss();
183 }); 183 });
184 184
185 ButtonElement debugButton = window.document.query('#debug'); 185 ButtonElement debugButton = window.document.query('#debug');
186 debugButton.on.click.add((MouseEvent e) { 186 debugButton.on.click.add((MouseEvent e) {
187 runCss(true); 187 runCss(true);
188 }); 188 });
189 189
190 initCssWorld(false); 190 initCssWorld(false);
191 } 191 }
OLDNEW
« no previous file with comments | « utils/css/parser.dart ('k') | utils/pub/pub.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698