| OLD | NEW |
| 1 | 1 |
| 2 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 2 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
| 3 // for details. All rights reserved. Use of this source code is governed by a | 3 // for details. All rights reserved. Use of this source code is governed by a |
| 4 // BSD-style license that can be found in the LICENSE file. | 4 // BSD-style license that can be found in the LICENSE file. |
| 5 | 5 |
| 6 // WARNING: DO NOT EDIT THIS TEMPLATE FILE. | 6 // WARNING: DO NOT EDIT THIS TEMPLATE FILE. |
| 7 // The template file was generated by scripts/css_code_generator.py | 7 // The template file was generated by scripts/css_code_generator.py |
| 8 | 8 |
| 9 // Source of CSS properties: | 9 // Source of CSS properties: |
| 10 // CSSPropertyNames.in | 10 // CSSPropertyNames.in |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 $endif | 60 $endif |
| 61 } | 61 } |
| 62 $if DARTIUM | 62 $if DARTIUM |
| 63 | 63 |
| 64 bool _hasProperty(String propertyName) => | 64 bool _hasProperty(String propertyName) => |
| 65 _blink.BlinkCSSStyleDeclaration.$__propertyQuery___Callback_1(this, proper
tyName); | 65 _blink.BlinkCSSStyleDeclaration.$__propertyQuery___Callback_1(this, proper
tyName); |
| 66 $endif | 66 $endif |
| 67 | 67 |
| 68 @DomName('CSSStyleDeclaration.setProperty') | 68 @DomName('CSSStyleDeclaration.setProperty') |
| 69 void setProperty(String propertyName, String value, [String priority]) { | 69 void setProperty(String propertyName, String value, [String priority]) { |
| 70 return _setPropertyHelper(_browserPropertyName(propertyName), |
| 71 value, priority); |
| 72 } |
| 73 |
| 74 String _browserPropertyName(String propertyName) { |
| 75 String name = _readCache(propertyName); |
| 76 if (name is String) return name; |
| 70 if (_supportsProperty(_camelCase(propertyName))) { | 77 if (_supportsProperty(_camelCase(propertyName))) { |
| 71 return _setPropertyHelper(propertyName, value, priority); | 78 name = propertyName; |
| 72 } else { | 79 } else { |
| 73 return _setPropertyHelper(Device.cssPrefix + propertyName, value, | 80 name = Device.cssPrefix + propertyName; |
| 74 priority); | |
| 75 } | 81 } |
| 82 _writeCache(propertyName, name); |
| 83 return name; |
| 76 } | 84 } |
| 77 | 85 |
| 86 $if DART2JS |
| 87 static final _propertyCache = JS('', '{}'); |
| 88 static String _readCache(String key) => |
| 89 JS('String|Null', '#[#]', _propertyCache, key); |
| 90 static void _writeCache(String key, String value) { |
| 91 JS('void', '#[#] = #', _propertyCache, key, value); |
| 92 } |
| 93 $else |
| 94 static String _readCache(String key) => null; |
| 95 static void _writeCache(String key, value) {} |
| 96 $endif |
| 97 |
| 78 static String _camelCase(String hyphenated) { | 98 static String _camelCase(String hyphenated) { |
| 79 $if DART2JS | 99 $if DART2JS |
| 80 var replacedMs = JS('String', r'#.replace(/^-ms-/, "ms-")', hyphenated); | 100 var replacedMs = JS('String', r'#.replace(/^-ms-/, "ms-")', hyphenated); |
| 81 | 101 |
| 82 var fToUpper = const JS_CONST( | 102 var fToUpper = const JS_CONST( |
| 83 r'function(_, letter) { return letter.toUpperCase(); }'); | 103 r'function(_, letter) { return letter.toUpperCase(); }'); |
| 84 return JS('String', r'#.replace(/-([\da-z])/ig, #)', replacedMs, fToUpper); | 104 return JS('String', r'#.replace(/-([\da-z])/ig, #)', replacedMs, fToUpper); |
| 85 $else | 105 $else |
| 86 // The "ms" prefix is always lowercased. | 106 // The "ms" prefix is always lowercased. |
| 87 return hyphenated.replaceFirst(new RegExp('^-ms-'), 'ms-').replaceAllMapped( | 107 return hyphenated.replaceFirst(new RegExp('^-ms-'), 'ms-').replaceAllMapped( |
| 88 new RegExp('-([a-z]+)', caseSensitive: false), | 108 new RegExp('-([a-z]+)', caseSensitive: false), |
| 89 (match) => match[0][1].toUpperCase() + match[0].substring(2)); | 109 (match) => match[0][1].toUpperCase() + match[0].substring(2)); |
| 90 $endif | 110 $endif |
| 91 } | 111 } |
| 92 | 112 |
| 93 $if DART2JS | 113 $if DART2JS |
| 94 void _setPropertyHelper(String propertyName, String value, [String priority])
{ | 114 void _setPropertyHelper(String propertyName, String value, [String priority])
{ |
| 95 // try/catch for IE9 which throws on unsupported values. | 115 if (value == null) value = ''; |
| 96 try { | 116 if (priority == null) priority = ''; |
| 97 if (value == null) value = ''; | 117 JS('void', '#.setProperty(#, #, #)', this, propertyName, value, priority); |
| 98 if (priority == null) { | |
| 99 priority = ''; | |
| 100 } | |
| 101 JS('void', '#.setProperty(#, #, #)', this, propertyName, value, priority); | |
| 102 // Bug #2772, IE9 requires a poke to actually apply the value. | |
| 103 if (JS('bool', '!!#.setAttribute', this)) { | |
| 104 JS('void', '#.setAttribute(#, #)', this, propertyName, value); | |
| 105 } | |
| 106 } catch (e) {} | |
| 107 } | 118 } |
| 108 | 119 |
| 109 /** | 120 /** |
| 110 * Checks to see if CSS Transitions are supported. | 121 * Checks to see if CSS Transitions are supported. |
| 111 */ | 122 */ |
| 112 static bool get supportsTransitions { | 123 static bool get supportsTransitions { |
| 113 return document.body.style.supportsProperty('transition'); | 124 return document.body.style.supportsProperty('transition'); |
| 114 } | 125 } |
| 115 $else | 126 $else |
| 116 void _setPropertyHelper(String propertyName, String value, [String priority])
{ | 127 void _setPropertyHelper(String propertyName, String value, [String priority])
{ |
| (...skipping 3116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3233 | 3244 |
| 3234 /** Gets the value of "zoom" */ | 3245 /** Gets the value of "zoom" */ |
| 3235 String get zoom => | 3246 String get zoom => |
| 3236 getPropertyValue('zoom'); | 3247 getPropertyValue('zoom'); |
| 3237 | 3248 |
| 3238 /** Sets the value of "zoom" */ | 3249 /** Sets the value of "zoom" */ |
| 3239 void set zoom(String value) { | 3250 void set zoom(String value) { |
| 3240 setProperty('zoom', value, ''); | 3251 setProperty('zoom', value, ''); |
| 3241 } | 3252 } |
| 3242 } | 3253 } |
| OLD | NEW |