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

Side by Side Diff: tools/dom/scripts/css_code_generator.py

Issue 1173403004: Changed to use JSInterop (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Re-gen'd somehow diffs stopped showing up in CL Created 5 years, 5 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 | « sdk/lib/web_sql/dartium/web_sql_dartium.dart ('k') | tools/dom/scripts/dartdomgenerator.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/python 1 #!/usr/bin/python
2 # 2 #
3 # Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 3 # Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
4 # for details. All rights reserved. Use of this source code is governed by a 4 # for details. All rights reserved. Use of this source code is governed by a
5 # BSD-style license that can be found in the LICENSE file. 5 # BSD-style license that can be found in the LICENSE file.
6 6
7 """Generates CSSStyleDeclaration template file from css property definitions 7 """Generates CSSStyleDeclaration template file from css property definitions
8 defined in WebKit.""" 8 defined in WebKit."""
9 9
10 import tempfile, os, re 10 import tempfile, os, re
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 // The template file was generated by scripts/css_code_generator.py 95 // The template file was generated by scripts/css_code_generator.py
96 96
97 // Source of CSS properties: 97 // Source of CSS properties:
98 // %s 98 // %s
99 99
100 part of $LIBRARYNAME; 100 part of $LIBRARYNAME;
101 """ % SOURCE_PATH) 101 """ % SOURCE_PATH)
102 102
103 103
104 class_file.write(""" 104 class_file.write("""
105 $if DART2JS
105 $(ANNOTATIONS)$(NATIVESPEC)$(CLASS_MODIFIERS)class $CLASSNAME $EXTENDS with 106 $(ANNOTATIONS)$(NATIVESPEC)$(CLASS_MODIFIERS)class $CLASSNAME $EXTENDS with
106 $(CLASSNAME)Base $IMPLEMENTS { 107 $(CLASSNAME)Base $IMPLEMENTS {
108 $else
109 $if JSINTEROP
110 $(ANNOTATIONS)$(NATIVESPEC)$(CLASS_MODIFIERS) class $CLASSNAME extends
111 $(CLASSNAME)Base $IMPLEMENTS {
112 $else
113 $(ANNOTATIONS)$(NATIVESPEC)$(CLASS_MODIFIERS)class $CLASSNAME $EXTENDS with
114 $(CLASSNAME)Base $IMPLEMENTS {
115 $endif
116 $endif
107 factory $CLASSNAME() => new CssStyleDeclaration.css(''); 117 factory $CLASSNAME() => new CssStyleDeclaration.css('');
108 118
109 factory $CLASSNAME.css(String css) { 119 factory $CLASSNAME.css(String css) {
110 final style = new Element.tag('div').style; 120 final style = new Element.tag('div').style;
111 style.cssText = css; 121 style.cssText = css;
112 return style; 122 return style;
113 } 123 }
114 124
115 String getPropertyValue(String propertyName) { 125 String getPropertyValue(String propertyName) {
116 var propValue = _getPropertyValueHelper(propertyName); 126 var propValue = _getPropertyValueHelper(propertyName);
(...skipping 26 matching lines...) Expand all
143 return JS('bool', '# in #', propertyName, this); 153 return JS('bool', '# in #', propertyName, this);
144 $else 154 $else
145 // You can't just check the value of a property, because there is no way 155 // You can't just check the value of a property, because there is no way
146 // to distinguish between property not being present in the browser and 156 // to distinguish between property not being present in the browser and
147 // not having a value at all. (Ultimately we'll want the native method to 157 // not having a value at all. (Ultimately we'll want the native method to
148 // return null if the property doesn't exist and empty string if it's 158 // return null if the property doesn't exist and empty string if it's
149 // defined but just doesn't have a value. 159 // defined but just doesn't have a value.
150 return _hasProperty(propertyName); 160 return _hasProperty(propertyName);
151 $endif 161 $endif
152 } 162 }
163
153 $if DARTIUM 164 $if DARTIUM
154
155 bool _hasProperty(String propertyName) => 165 bool _hasProperty(String propertyName) =>
166 $if JSINTEROP
167 _blink.BlinkCSSStyleDeclaration.instance.$__propertyQuery___Callback_1_(un wrap_jso(this), propertyName) != null;
168 $else
156 _blink.BlinkCSSStyleDeclaration.$__propertyQuery___Callback_1(this, proper tyName); 169 _blink.BlinkCSSStyleDeclaration.$__propertyQuery___Callback_1(this, proper tyName);
170 $endif
157 $endif 171 $endif
158 172
159 @DomName('CSSStyleDeclaration.setProperty') 173 @DomName('CSSStyleDeclaration.setProperty')
160 void setProperty(String propertyName, String value, [String priority]) { 174 void setProperty(String propertyName, String value, [String priority]) {
161 return _setPropertyHelper(_browserPropertyName(propertyName), 175 return _setPropertyHelper(_browserPropertyName(propertyName),
162 value, priority); 176 value, priority);
163 } 177 }
164 178
165 String _browserPropertyName(String propertyName) { 179 String _browserPropertyName(String propertyName) {
166 String name = _readCache(propertyName); 180 String name = _readCache(propertyName);
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 @JSName('%s') 259 @JSName('%s')
246 String _%s; 260 String _%s;
247 """ % (property, camelName, camelName, 261 """ % (property, camelName, camelName,
248 property, camelName, camelName, 262 property, camelName, camelName,
249 camelName, camelName)) 263 camelName, camelName))
250 264
251 class_file.write(""" 265 class_file.write("""
252 $endif 266 $endif
253 } 267 }
254 268
269 $if DART2JS
255 class _CssStyleDeclarationSet extends Object with CssStyleDeclarationBase { 270 class _CssStyleDeclarationSet extends Object with CssStyleDeclarationBase {
271 $else
272 $if JSINTEROP
273 class _CssStyleDeclarationSet extends CssStyleDeclarationBase {
274 $else
275 class _CssStyleDeclarationSet extends Object with CssStyleDeclarationBase {
276 $endif
277 $endif
256 final Iterable<Element> _elementIterable; 278 final Iterable<Element> _elementIterable;
257 Iterable<CssStyleDeclaration> _elementCssStyleDeclarationSetIterable; 279 Iterable<CssStyleDeclaration> _elementCssStyleDeclarationSetIterable;
258 280
259 _CssStyleDeclarationSet(this._elementIterable) { 281 _CssStyleDeclarationSet(this._elementIterable) {
260 _elementCssStyleDeclarationSetIterable = new List.from( 282 _elementCssStyleDeclarationSetIterable = new List.from(
261 _elementIterable).map((e) => e.style); 283 _elementIterable).map((e) => e.style);
262 } 284 }
263 285
264 String getPropertyValue(String propertyName) => 286 String getPropertyValue(String propertyName) =>
265 _elementCssStyleDeclarationSetIterable.first.getPropertyValue( 287 _elementCssStyleDeclarationSetIterable.first.getPropertyValue(
(...skipping 29 matching lines...) Expand all
295 class_file.write(""" 317 class_file.write("""
296 $endif 318 $endif
297 319
298 // Important note: CssStyleDeclarationSet does NOT implement every method 320 // Important note: CssStyleDeclarationSet does NOT implement every method
299 // available in CssStyleDeclaration. Some of the methods don't make so much 321 // available in CssStyleDeclaration. Some of the methods don't make so much
300 // sense in terms of having a resonable value to return when you're 322 // sense in terms of having a resonable value to return when you're
301 // considering a list of Elements. You will need to manually add any of the 323 // considering a list of Elements. You will need to manually add any of the
302 // items in the MEMBERS set if you want that functionality. 324 // items in the MEMBERS set if you want that functionality.
303 } 325 }
304 326
327 $if DART2JS
305 abstract class CssStyleDeclarationBase { 328 abstract class CssStyleDeclarationBase {
306 String getPropertyValue(String propertyName); 329 String getPropertyValue(String propertyName);
307 void setProperty(String propertyName, String value, [String priority]); 330 void setProperty(String propertyName, String value, [String priority]);
331 $else
332 $if JSINTEROP
333 class CssStyleDeclarationBase {
334 String getPropertyValue(String propertyName) =>
335 throw new StateError('getProperty not overridden in dart:html');
336 void setProperty(String propertyName, String value, [String priority]) =>
337 throw new StateError('setProperty not overridden in dart:html');
338 $else
339 abstract class CssStyleDeclarationBase {
340 String getPropertyValue(String propertyName);
341 void setProperty(String propertyName, String value, [String priority]);
342 $endif
343 $endif
308 """) 344 """)
309 345
310 class_lines = []; 346 class_lines = [];
311 347
312 seen = set() 348 seen = set()
313 for prop in sorted(data, key=camelCaseName): 349 for prop in sorted(data, key=camelCaseName):
314 camel_case_name = camelCaseName(prop) 350 camel_case_name = camelCaseName(prop)
315 upper_camel_case_name = camel_case_name[0].upper() + camel_case_name[1:]; 351 upper_camel_case_name = camel_case_name[0].upper() + camel_case_name[1:];
316 css_name = prop.replace('-webkit-', '') 352 css_name = prop.replace('-webkit-', '')
317 base_css_name = prop.replace('-webkit-', '') 353 base_css_name = prop.replace('-webkit-', '')
(...skipping 18 matching lines...) Expand all
336 class_lines.append(annotated[base_css_name]) 372 class_lines.append(annotated[base_css_name])
337 class_lines.append(""" 373 class_lines.append("""
338 void set %s(String value) { 374 void set %s(String value) {
339 setProperty('%s', value, ''); 375 setProperty('%s', value, '');
340 } 376 }
341 """ % (camel_case_name, css_name)) 377 """ % (camel_case_name, css_name))
342 378
343 class_file.write(''.join(class_lines)); 379 class_file.write(''.join(class_lines));
344 class_file.write('}\n') 380 class_file.write('}\n')
345 class_file.close() 381 class_file.close()
OLDNEW
« no previous file with comments | « sdk/lib/web_sql/dartium/web_sql_dartium.dart ('k') | tools/dom/scripts/dartdomgenerator.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698