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

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

Issue 137013002: Removed obsolete code (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Removed libraries not used Created 6 years, 11 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/treebase.dart ('k') | utils/css/validate.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 import 'dart:html';
6 import 'css.dart';
7 import '../lib/file_system_memory.dart';
8
9 void runCss([bool debug = false, bool parseOnly = false]) {
10 final Document doc = window.document;
11 final TextAreaElement classes = doc.query("#classes");
12 final TextAreaElement expression = doc.query('#expression');
13 final TableCellElement validity = doc.query('#validity');
14 final TableCellElement result = doc.query('#result');
15
16 List<String> knownWorld = classes.value.split("\n");
17 List<String> knownClasses = [];
18 List<String> knownIds = [];
19 for (final name in knownWorld) {
20 if (name.startsWith('.')) {
21 knownClasses.add(name.substring(1));
22 } else if (name.startsWith('#')) {
23 knownIds.add(name.substring(1));
24 }
25 }
26
27 CssWorld cssWorld = new CssWorld(knownClasses, knownIds);
28 bool templateValid = true;
29 String dumpTree = "";
30
31 String cssExpr = expression.value;
32 if (!debug) {
33 try {
34 cssParseAndValidate(cssExpr, cssWorld);
35 } catch (cssException) {
36 templateValid = false;
37 dumpTree = cssException.toString();
38 }
39 } else if (parseOnly) {
40 try {
41 Parser parser = new Parser(new SourceFile(
42 SourceFile.IN_MEMORY_FILE, cssExpr));
43 Stylesheet stylesheet = parser.parse();
44 StringBuffer stylesheetTree = new StringBuffer();
45 String prettyStylesheet = stylesheet.toString();
46 stylesheetTree.write("${prettyStylesheet}\n");
47 stylesheetTree.write("\n============>Tree Dump<============\n");
48 stylesheetTree.write(stylesheet.toDebugString());
49 dumpTree = stylesheetTree.toString();
50 } catch (cssParseException) {
51 templateValid = false;
52 dumpTree = cssParseException.toString();
53 }
54 } else {
55 try {
56 dumpTree = cssParseAndValidateDebug(cssExpr, cssWorld);
57 } catch (cssException) {
58 templateValid = false;
59 dumpTree = cssException.toString();
60 }
61 }
62
63 final bgcolor = templateValid ? "white" : "red";
64 final color = templateValid ? "black" : "white";
65 final valid = templateValid ? "VALID" : "NOT VALID";
66 String resultStyle = "resize:none; margin:0; height:100%; width:100%;"
67 "padding:5px 7px;";
68 String validityStyle = "font-weight:bold; background-color:$bgcolor;"
69 "color:$color; border:1px solid black; border-bottom:0px solid white;";
70 validity.innerHTML = '''
71 <div style="$validityStyle">
72 Expression: $cssExpr is $valid
73 </div>
74 ''';
75 result.innerHTML = "<textarea style=\"$resultStyle\">$dumpTree</textarea>";
76 }
77
78 void main() {
79 final element = new Element.tag('div');
80 element.innerHTML = '''
81 <table style="width: 100%; height: 100%;">
82 <tbody>
83 <tr>
84 <td style="vertical-align: top; width: 200px;">
85 <table style="height: 100%;">
86 <tbody>
87 <tr style="vertical-align: top; height: 1em;">
88 <td>
89 <span style="font-weight:bold;">Classes</span>
90 </td>
91 </tr>
92 <tr style="vertical-align: top;">
93 <td>
94 <textarea id="classes" style="resize: none; width: 200px; he ight: 100%; padding: 5px 7px;">.foobar\n.xyzzy\n.test\n.dummy\n#myId\n#myStory</ textarea>
95 </td>
96 </tr>
97 </tbody>
98 </table>
99 </td>
100 <td>
101 <table style="width: 100%; height: 100%;" cellspacing=0 cellpadding= 0 border=0>
102 <tbody>
103 <tr style="vertical-align: top; height: 100px;">
104 <td>
105 <table style="width: 100%;">
106 <tbody>
107 <tr>
108 <td>
109 <span style="font-weight:bold;">Selector Expression< /span>
110 </td>
111 </tr>
112 <tr>
113 <td>
114 <textarea id="expression" style="resize: none; width : 100%; height: 100px; padding: 5px 7px;"></textarea>
115 </td>
116 </tr>
117 </tbody>
118 </table>
119 </td>
120 </tr>
121
122 <tr style="vertical-align: top; height: 50px;">
123 <td>
124 <table>
125 <tbody>
126 <tr>
127 <td>
128 <button id=parse>Parse</button>
129 </td>
130 <td>
131 <button id=check>Check</button>
132 </td>
133 <td>
134 <button id=debug>Debug</button>
135 </td>
136 </tr>
137 </tbody>
138 </table>
139 </td>
140 </tr>
141
142 <tr style="vertical-align: top;">
143 <td>
144 <table style="width: 100%; height: 100%;" border="0" cellpad ding="0" cellspacing="0">
145 <tbody>
146 <tr style="vertical-align: top; height: 1em;">
147 <td>
148 <span style="font-weight:bold;">Result</span>
149 </td>
150 </tr>
151 <tr style="vertical-align: top; height: 1em;">
152 <td id="validity">
153 </td>
154 </tr>
155 <tr style="vertical-align: top;">
156 <td id="result">
157 <textarea style="resize: none; width: 100%; height: 100%; border: black solid 1px; padding: 5px 7px;"></textarea>
158 </td>
159 </tr>
160 </tbody>
161 </table>
162 </td>
163 </tr>
164 </tbody>
165 </table>
166 </td>
167 </tr>
168 </tbody>
169 </table>
170 ''';
171
172 document.body.style.setProperty("background-color", "lightgray");
173 document.body.elements.add(element);
174
175 ButtonElement parseButton = window.document.query('#parse');
176 parseButton.on.click.add((MouseEvent e) {
177 runCss(true, true);
178 });
179
180 ButtonElement checkButton = window.document.query('#check');
181 checkButton.on.click.add((MouseEvent e) {
182 runCss();
183 });
184
185 ButtonElement debugButton = window.document.query('#debug');
186 debugButton.on.click.add((MouseEvent e) {
187 runCss(true);
188 });
189
190 initCssWorld(false);
191 }
OLDNEW
« no previous file with comments | « utils/css/treebase.dart ('k') | utils/css/validate.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698