| 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), | 70 if (_supportsProperty(_camelCase(propertyName))) { |
| 71 value, priority); | 71 return _setPropertyHelper(propertyName, value, priority); |
| 72 } else { |
| 73 return _setPropertyHelper(Device.cssPrefix + propertyName, value, |
| 74 priority); |
| 75 } |
| 72 } | 76 } |
| 73 | 77 |
| 74 String _browserPropertyName(String propertyName) { | |
| 75 String name = _readCache(propertyName); | |
| 76 if (name is String) return name; | |
| 77 if (_supportsProperty(_camelCase(propertyName))) { | |
| 78 name = propertyName; | |
| 79 } else { | |
| 80 name = Device.cssPrefix + propertyName; | |
| 81 } | |
| 82 _writeCache(propertyName, name); | |
| 83 return name; | |
| 84 } | |
| 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 | |
| 98 static String _camelCase(String hyphenated) { | 78 static String _camelCase(String hyphenated) { |
| 99 $if DART2JS | 79 $if DART2JS |
| 100 var replacedMs = JS('String', r'#.replace(/^-ms-/, "ms-")', hyphenated); | 80 var replacedMs = JS('String', r'#.replace(/^-ms-/, "ms-")', hyphenated); |
| 101 | 81 |
| 102 var fToUpper = const JS_CONST( | 82 var fToUpper = const JS_CONST( |
| 103 r'function(_, letter) { return letter.toUpperCase(); }'); | 83 r'function(_, letter) { return letter.toUpperCase(); }'); |
| 104 return JS('String', r'#.replace(/-([\da-z])/ig, #)', replacedMs, fToUpper); | 84 return JS('String', r'#.replace(/-([\da-z])/ig, #)', replacedMs, fToUpper); |
| 105 $else | 85 $else |
| 106 // The "ms" prefix is always lowercased. | 86 // The "ms" prefix is always lowercased. |
| 107 return hyphenated.replaceFirst(new RegExp('^-ms-'), 'ms-').replaceAllMapped( | 87 return hyphenated.replaceFirst(new RegExp('^-ms-'), 'ms-').replaceAllMapped( |
| 108 new RegExp('-([a-z]+)', caseSensitive: false), | 88 new RegExp('-([a-z]+)', caseSensitive: false), |
| 109 (match) => match[0][1].toUpperCase() + match[0].substring(2)); | 89 (match) => match[0][1].toUpperCase() + match[0].substring(2)); |
| 110 $endif | 90 $endif |
| 111 } | 91 } |
| 112 | 92 |
| 113 $if DART2JS | 93 $if DART2JS |
| 114 void _setPropertyHelper(String propertyName, String value, [String priority])
{ | 94 void _setPropertyHelper(String propertyName, String value, [String priority])
{ |
| 115 if (value == null) value = ''; | 95 // try/catch for IE9 which throws on unsupported values. |
| 116 if (priority == null) priority = ''; | 96 try { |
| 117 JS('void', '#.setProperty(#, #, #)', this, propertyName, value, priority); | 97 if (value == null) value = ''; |
| 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) {} |
| 118 } | 107 } |
| 119 | 108 |
| 120 /** | 109 /** |
| 121 * Checks to see if CSS Transitions are supported. | 110 * Checks to see if CSS Transitions are supported. |
| 122 */ | 111 */ |
| 123 static bool get supportsTransitions { | 112 static bool get supportsTransitions { |
| 124 return document.body.style.supportsProperty('transition'); | 113 return document.body.style.supportsProperty('transition'); |
| 125 } | 114 } |
| 126 $else | 115 $else |
| 127 void _setPropertyHelper(String propertyName, String value, [String priority])
{ | 116 void _setPropertyHelper(String propertyName, String value, [String priority])
{ |
| (...skipping 3116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3244 | 3233 |
| 3245 /** Gets the value of "zoom" */ | 3234 /** Gets the value of "zoom" */ |
| 3246 String get zoom => | 3235 String get zoom => |
| 3247 getPropertyValue('zoom'); | 3236 getPropertyValue('zoom'); |
| 3248 | 3237 |
| 3249 /** Sets the value of "zoom" */ | 3238 /** Sets the value of "zoom" */ |
| 3250 void set zoom(String value) { | 3239 void set zoom(String value) { |
| 3251 setProperty('zoom', value, ''); | 3240 setProperty('zoom', value, ''); |
| 3252 } | 3241 } |
| 3253 } | 3242 } |
| OLD | NEW |