| OLD | NEW |
| 1 #!/usr/bin/python2.6 | 1 #!/usr/bin/python2.6 |
| 2 # | 2 # |
| 3 # Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 3 # Copyright (c) 2011, 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 from css property definitions defined in WebKit
.""" | 7 """Generates CSSStyleDeclaration from css property definitions defined in WebKit
.""" |
| 8 | 8 |
| 9 import tempfile, os | 9 import tempfile, os |
| 10 | 10 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 // WARNING: Do not edit. | 56 // WARNING: Do not edit. |
| 57 // This file was generated by html/scripts/css_code_generator.py | 57 // This file was generated by html/scripts/css_code_generator.py |
| 58 | 58 |
| 59 // Source of CSS properties: | 59 // Source of CSS properties: |
| 60 // %s | 60 // %s |
| 61 | 61 |
| 62 // TODO(jacobr): add versions that take numeric values in px, miliseconds, etc. | 62 // TODO(jacobr): add versions that take numeric values in px, miliseconds, etc. |
| 63 | 63 |
| 64 interface CSSStyleDeclaration { | 64 interface CSSStyleDeclaration { |
| 65 | 65 |
| 66 String get cssText(); | 66 String get cssText; |
| 67 | 67 |
| 68 void set cssText(String value); | 68 void set cssText(String value); |
| 69 | 69 |
| 70 int get length(); | 70 int get length; |
| 71 | 71 |
| 72 CSSRule get parentRule(); | 72 CSSRule get parentRule; |
| 73 | 73 |
| 74 CSSValue getPropertyCSSValue(String propertyName); | 74 CSSValue getPropertyCSSValue(String propertyName); |
| 75 | 75 |
| 76 String getPropertyPriority(String propertyName); | 76 String getPropertyPriority(String propertyName); |
| 77 | 77 |
| 78 String getPropertyShorthand(String propertyName); | 78 String getPropertyShorthand(String propertyName); |
| 79 | 79 |
| 80 String getPropertyValue(String propertyName); | 80 String getPropertyValue(String propertyName); |
| 81 | 81 |
| 82 bool isPropertyImplicit(String propertyName); | 82 bool isPropertyImplicit(String propertyName); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 101 // Source of CSS properties: | 101 // Source of CSS properties: |
| 102 // %s | 102 // %s |
| 103 | 103 |
| 104 // TODO(jacobr): add versions that take numeric values in px, miliseconds, etc. | 104 // TODO(jacobr): add versions that take numeric values in px, miliseconds, etc. |
| 105 | 105 |
| 106 class CSSStyleDeclarationWrappingImplementation extends DOMWrapperBase implement
s CSSStyleDeclaration { | 106 class CSSStyleDeclarationWrappingImplementation extends DOMWrapperBase implement
s CSSStyleDeclaration { |
| 107 static String _cachedBrowserPrefix; | 107 static String _cachedBrowserPrefix; |
| 108 | 108 |
| 109 CSSStyleDeclarationWrappingImplementation._wrap(ptr) : super._wrap(ptr) {} | 109 CSSStyleDeclarationWrappingImplementation._wrap(ptr) : super._wrap(ptr) {} |
| 110 | 110 |
| 111 static String get _browserPrefix() { | 111 static String get _browserPrefix { |
| 112 if (_cachedBrowserPrefix === null) { | 112 if (_cachedBrowserPrefix === null) { |
| 113 if (_Device.isFirefox) { | 113 if (_Device.isFirefox) { |
| 114 _cachedBrowserPrefix = '-moz-'; | 114 _cachedBrowserPrefix = '-moz-'; |
| 115 } else { | 115 } else { |
| 116 _cachedBrowserPrefix = '-webkit-'; | 116 _cachedBrowserPrefix = '-webkit-'; |
| 117 } | 117 } |
| 118 // TODO(jacobr): support IE 9.0 and Opera as well. | 118 // TODO(jacobr): support IE 9.0 and Opera as well. |
| 119 } | 119 } |
| 120 return _cachedBrowserPrefix; | 120 return _cachedBrowserPrefix; |
| 121 } | 121 } |
| 122 | 122 |
| 123 String get cssText() { return _ptr.cssText; } | 123 String get cssText { return _ptr.cssText; } |
| 124 | 124 |
| 125 void set cssText(String value) { _ptr.cssText = value; } | 125 void set cssText(String value) { _ptr.cssText = value; } |
| 126 | 126 |
| 127 int get length() { return _ptr.length; } | 127 int get length { return _ptr.length; } |
| 128 | 128 |
| 129 CSSRule get parentRule() { return LevelDom.wrapCSSRule(_ptr.parentRule); } | 129 CSSRule get parentRule { return LevelDom.wrapCSSRule(_ptr.parentRule); } |
| 130 | 130 |
| 131 CSSValue getPropertyCSSValue(String propertyName) { | 131 CSSValue getPropertyCSSValue(String propertyName) { |
| 132 return LevelDom.wrapCSSValue(_ptr.getPropertyCSSValue(propertyName)); | 132 return LevelDom.wrapCSSValue(_ptr.getPropertyCSSValue(propertyName)); |
| 133 } | 133 } |
| 134 | 134 |
| 135 String getPropertyPriority(String propertyName) { | 135 String getPropertyPriority(String propertyName) { |
| 136 return _ptr.getPropertyPriority(propertyName); | 136 return _ptr.getPropertyPriority(propertyName); |
| 137 } | 137 } |
| 138 | 138 |
| 139 String getPropertyShorthand(String propertyName) { | 139 String getPropertyShorthand(String propertyName) { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 153 } | 153 } |
| 154 | 154 |
| 155 String removeProperty(String propertyName) { | 155 String removeProperty(String propertyName) { |
| 156 return _ptr.removeProperty(propertyName); | 156 return _ptr.removeProperty(propertyName); |
| 157 } | 157 } |
| 158 | 158 |
| 159 void setProperty(String propertyName, String value, [String priority = '']) { | 159 void setProperty(String propertyName, String value, [String priority = '']) { |
| 160 _ptr.setProperty(propertyName, value, priority); | 160 _ptr.setProperty(propertyName, value, priority); |
| 161 } | 161 } |
| 162 | 162 |
| 163 String get typeName() { return "CSSStyleDeclaration"; } | 163 String get typeName { return "CSSStyleDeclaration"; } |
| 164 | 164 |
| 165 """.lstrip() % SOURCE_PATH) | 165 """.lstrip() % SOURCE_PATH) |
| 166 | 166 |
| 167 interface_lines = []; | 167 interface_lines = []; |
| 168 class_lines = []; | 168 class_lines = []; |
| 169 | 169 |
| 170 seen = set() | 170 seen = set() |
| 171 for prop in sorted(data, key=lambda p: camelCaseName(p)): | 171 for prop in sorted(data, key=lambda p: camelCaseName(p)): |
| 172 camel_case_name = camelCaseName(prop) | 172 camel_case_name = camelCaseName(prop) |
| 173 upper_camel_case_name = camel_case_name[0].upper() + camel_case_name[1:]; | 173 upper_camel_case_name = camel_case_name[0].upper() + camel_case_name[1:]; |
| 174 css_name = prop.replace('-webkit-', '${_browserPrefix}') | 174 css_name = prop.replace('-webkit-', '${_browserPrefix}') |
| 175 base_css_name = prop.replace('-webkit-', '') | 175 base_css_name = prop.replace('-webkit-', '') |
| 176 | 176 |
| 177 if base_css_name in seen: | 177 if base_css_name in seen: |
| 178 continue | 178 continue |
| 179 seen.add(base_css_name) | 179 seen.add(base_css_name) |
| 180 | 180 |
| 181 comment = ' /** %s the value of "' + base_css_name + '" */' | 181 comment = ' /** %s the value of "' + base_css_name + '" */' |
| 182 | 182 |
| 183 interface_lines.append(comment % 'Gets') | 183 interface_lines.append(comment % 'Gets') |
| 184 interface_lines.append(""" | 184 interface_lines.append(""" |
| 185 String get %s(); | 185 String get %s; |
| 186 | 186 |
| 187 """ % camel_case_name) | 187 """ % camel_case_name) |
| 188 | 188 |
| 189 interface_lines.append(comment % 'Sets') | 189 interface_lines.append(comment % 'Sets') |
| 190 interface_lines.append(""" | 190 interface_lines.append(""" |
| 191 void set %s(String value); | 191 void set %s(String value); |
| 192 | 192 |
| 193 """ % camel_case_name) | 193 """ % camel_case_name) |
| 194 | 194 |
| 195 class_lines.append('\n'); | 195 class_lines.append('\n'); |
| 196 class_lines.append(comment % 'Gets') | 196 class_lines.append(comment % 'Gets') |
| 197 class_lines.append(""" | 197 class_lines.append(""" |
| 198 String get %s() => | 198 String get %s => |
| 199 getPropertyValue('%s'); | 199 getPropertyValue('%s'); |
| 200 | 200 |
| 201 """ % (camel_case_name, css_name)) | 201 """ % (camel_case_name, css_name)) |
| 202 | 202 |
| 203 class_lines.append(comment % 'Sets') | 203 class_lines.append(comment % 'Sets') |
| 204 class_lines.append(""" | 204 class_lines.append(""" |
| 205 void set %s(String value) { | 205 void set %s(String value) { |
| 206 setProperty('%s', value, ''); | 206 setProperty('%s', value, ''); |
| 207 } | 207 } |
| 208 """ % (camel_case_name, css_name)) | 208 """ % (camel_case_name, css_name)) |
| 209 | 209 |
| 210 interface_file.write(''.join(interface_lines)); | 210 interface_file.write(''.join(interface_lines)); |
| 211 interface_file.write('}\n') | 211 interface_file.write('}\n') |
| 212 interface_file.close() | 212 interface_file.close() |
| 213 | 213 |
| 214 class_file.write(''.join(class_lines)); | 214 class_file.write(''.join(class_lines)); |
| 215 class_file.write('}\n') | 215 class_file.write('}\n') |
| 216 class_file.close() | 216 class_file.close() |
| 217 | 217 |
| 218 if __name__ == '__main__': | 218 if __name__ == '__main__': |
| 219 main() | 219 main() |
| OLD | NEW |