OLD | NEW |
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 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 } | 188 } |
189 $else | 189 $else |
190 static String _readCache(String key) => null; | 190 static String _readCache(String key) => null; |
191 static void _writeCache(String key, value) {} | 191 static void _writeCache(String key, value) {} |
192 $endif | 192 $endif |
193 | 193 |
194 static String _camelCase(String hyphenated) { | 194 static String _camelCase(String hyphenated) { |
195 $if DART2JS | 195 $if DART2JS |
196 var replacedMs = JS('String', r'#.replace(/^-ms-/, "ms-")', hyphenated); | 196 var replacedMs = JS('String', r'#.replace(/^-ms-/, "ms-")', hyphenated); |
197 | 197 |
198 var fToUpper = const JS_CONST( | 198 var fToUpper = JS('', |
199 r'function(_, letter) { return letter.toUpperCase(); }'); | 199 r'function(_, letter) { return letter.toUpperCase(); }'); |
200 return JS('String', r'#.replace(/-([\da-z])/ig, #)', replacedMs, fToUpper); | 200 return JS('String', r'#.replace(/-([\da-z])/ig, #)', replacedMs, fToUpper); |
201 $else | 201 $else |
202 // The "ms" prefix is always lowercased. | 202 // The "ms" prefix is always lowercased. |
203 return hyphenated.replaceFirst(new RegExp('^-ms-'), 'ms-').replaceAllMapped( | 203 return hyphenated.replaceFirst(new RegExp('^-ms-'), 'ms-').replaceAllMapped( |
204 new RegExp('-([a-z]+)', caseSensitive: false), | 204 new RegExp('-([a-z]+)', caseSensitive: false), |
205 (match) => match[0][1].toUpperCase() + match[0].substring(2)); | 205 (match) => match[0][1].toUpperCase() + match[0].substring(2)); |
206 $endif | 206 $endif |
207 } | 207 } |
208 | 208 |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
355 class_lines.append(annotated[base_css_name]) | 355 class_lines.append(annotated[base_css_name]) |
356 class_lines.append(""" | 356 class_lines.append(""" |
357 set %s(String value) { | 357 set %s(String value) { |
358 setProperty('%s', value, ''); | 358 setProperty('%s', value, ''); |
359 } | 359 } |
360 """ % (camel_case_name, css_name)) | 360 """ % (camel_case_name, css_name)) |
361 | 361 |
362 class_file.write(''.join(class_lines)); | 362 class_file.write(''.join(class_lines)); |
363 class_file.write('}\n') | 363 class_file.write('}\n') |
364 class_file.close() | 364 class_file.close() |
OLD | NEW |