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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 * Please note the property name camelCase, not-hyphens. This | 42 * Please note the property name camelCase, not-hyphens. This |
43 * method returns true if the property is accessible via an unprefixed _or_ | 43 * method returns true if the property is accessible via an unprefixed _or_ |
44 * prefixed property. | 44 * prefixed property. |
45 */ | 45 */ |
46 bool supportsProperty(String propertyName) { | 46 bool supportsProperty(String propertyName) { |
47 return _supportsProperty(propertyName) || | 47 return _supportsProperty(propertyName) || |
48 _supportsProperty(_camelCase("${Device.cssPrefix}$propertyName")); | 48 _supportsProperty(_camelCase("${Device.cssPrefix}$propertyName")); |
49 } | 49 } |
50 | 50 |
51 bool _supportsProperty(String propertyName) { | 51 bool _supportsProperty(String propertyName) { |
52 $if DART2JS | |
53 return JS('bool', '# in #', propertyName, this); | 52 return JS('bool', '# in #', propertyName, this); |
54 $else | |
55 // You can't just check the value of a property, because there is no way | |
56 // to distinguish between property not being present in the browser and | |
57 // not having a value at all. (Ultimately we'll want the native method to | |
58 // return null if the property doesn't exist and empty string if it's | |
59 // defined but just doesn't have a value. | |
60 return _hasProperty(propertyName); | |
61 $endif | |
62 } | 53 } |
63 | 54 |
64 $if DARTIUM | |
65 bool _hasProperty(String propertyName) => | |
66 _blink.BlinkCSSStyleDeclaration.instance.$__get___propertyIsEnumerable_Cal
lback_1_(this, propertyName); | |
67 $endif | |
68 | 55 |
69 @DomName('CSSStyleDeclaration.setProperty') | 56 @DomName('CSSStyleDeclaration.setProperty') |
70 void setProperty(String propertyName, String value, [String priority]) { | 57 void setProperty(String propertyName, String value, [String priority]) { |
71 return _setPropertyHelper(_browserPropertyName(propertyName), | 58 return _setPropertyHelper(_browserPropertyName(propertyName), |
72 value, priority); | 59 value, priority); |
73 } | 60 } |
74 | 61 |
75 String _browserPropertyName(String propertyName) { | 62 String _browserPropertyName(String propertyName) { |
76 String name = _readCache(propertyName); | 63 String name = _readCache(propertyName); |
77 if (name is String) return name; | 64 if (name is String) return name; |
78 name = _supportedBrowserPropertyName(propertyName); | 65 name = _supportedBrowserPropertyName(propertyName); |
79 _writeCache(propertyName, name); | 66 _writeCache(propertyName, name); |
80 return name; | 67 return name; |
81 } | 68 } |
82 | 69 |
83 String _supportedBrowserPropertyName(String propertyName) { | 70 String _supportedBrowserPropertyName(String propertyName) { |
84 if (_supportsProperty(_camelCase(propertyName))) { | 71 if (_supportsProperty(_camelCase(propertyName))) { |
85 return propertyName; | 72 return propertyName; |
86 } | 73 } |
87 var prefixed = "${Device.cssPrefix}$propertyName"; | 74 var prefixed = "${Device.cssPrefix}$propertyName"; |
88 if (_supportsProperty(prefixed)) { | 75 if (_supportsProperty(prefixed)) { |
89 return prefixed; | 76 return prefixed; |
90 } | 77 } |
91 // May be a CSS variable, just use it as provided. | 78 // May be a CSS variable, just use it as provided. |
92 return propertyName; | 79 return propertyName; |
93 } | 80 } |
94 | 81 |
95 $if DART2JS | |
96 static final _propertyCache = JS('', '{}'); | 82 static final _propertyCache = JS('', '{}'); |
97 static String _readCache(String key) => | 83 static String _readCache(String key) => |
98 JS('String|Null', '#[#]', _propertyCache, key); | 84 JS('String|Null', '#[#]', _propertyCache, key); |
99 static void _writeCache(String key, String value) { | 85 static void _writeCache(String key, String value) { |
100 JS('void', '#[#] = #', _propertyCache, key, value); | 86 JS('void', '#[#] = #', _propertyCache, key, value); |
101 } | 87 } |
102 $else | |
103 static String _readCache(String key) => null; | |
104 static void _writeCache(String key, value) {} | |
105 $endif | |
106 | 88 |
107 static String _camelCase(String hyphenated) { | 89 static String _camelCase(String hyphenated) { |
108 $if DART2JS | |
109 var replacedMs = JS('String', r'#.replace(/^-ms-/, "ms-")', hyphenated); | 90 var replacedMs = JS('String', r'#.replace(/^-ms-/, "ms-")', hyphenated); |
110 return JS( | 91 return JS( |
111 'String', | 92 'String', |
112 r'#.replace(/-([\da-z])/ig,' | 93 r'#.replace(/-([\da-z])/ig,' |
113 r'function(_, letter) { return letter.toUpperCase();})', | 94 r'function(_, letter) { return letter.toUpperCase();})', |
114 replacedMs); | 95 replacedMs); |
115 $else | |
116 // The "ms" prefix is always lowercased. | |
117 return hyphenated.replaceFirst(new RegExp('^-ms-'), 'ms-').replaceAllMapped( | |
118 new RegExp('-([a-z]+)', caseSensitive: false), | |
119 (match) => match[0][1].toUpperCase() + match[0].substring(2)); | |
120 $endif | |
121 } | 96 } |
122 | 97 |
123 $if DART2JS | |
124 void _setPropertyHelper(String propertyName, String value, [String priority])
{ | 98 void _setPropertyHelper(String propertyName, String value, [String priority])
{ |
125 if (value == null) value = ''; | 99 if (value == null) value = ''; |
126 if (priority == null) priority = ''; | 100 if (priority == null) priority = ''; |
127 JS('void', '#.setProperty(#, #, #)', this, propertyName, value, priority); | 101 JS('void', '#.setProperty(#, #, #)', this, propertyName, value, priority); |
128 } | 102 } |
129 | 103 |
130 /** | 104 /** |
131 * Checks to see if CSS Transitions are supported. | 105 * Checks to see if CSS Transitions are supported. |
132 */ | 106 */ |
133 static bool get supportsTransitions { | 107 static bool get supportsTransitions { |
134 return document.body.style.supportsProperty('transition'); | 108 return document.body.style.supportsProperty('transition'); |
135 } | 109 } |
136 $else | |
137 void _setPropertyHelper(String propertyName, String value, [String priority])
{ | |
138 if (priority == null) { | |
139 priority = ''; | |
140 } | |
141 _setProperty(propertyName, value, priority); | |
142 } | |
143 | |
144 /** | |
145 * Checks to see if CSS Transitions are supported. | |
146 */ | |
147 static bool get supportsTransitions => true; | |
148 $endif | |
149 $!MEMBERS | 110 $!MEMBERS |
150 $if DART2JS | |
151 | 111 |
152 /** Gets the value of "background" */ | 112 /** Gets the value of "background" */ |
153 String get background => this._background; | 113 String get background => this._background; |
154 | 114 |
155 /** Sets the value of "background" */ | 115 /** Sets the value of "background" */ |
156 set background(String value) { | 116 set background(String value) { |
157 _background = value == null ? '' : value; | 117 _background = value == null ? '' : value; |
158 } | 118 } |
159 @Returns('String') | 119 @Returns('String') |
160 @JSName('background') | 120 @JSName('background') |
(...skipping 971 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1132 String get zIndex => this._zIndex; | 1092 String get zIndex => this._zIndex; |
1133 | 1093 |
1134 /** Sets the value of "z-index" */ | 1094 /** Sets the value of "z-index" */ |
1135 set zIndex(String value) { | 1095 set zIndex(String value) { |
1136 _zIndex = value == null ? '' : value; | 1096 _zIndex = value == null ? '' : value; |
1137 } | 1097 } |
1138 @Returns('String') | 1098 @Returns('String') |
1139 @JSName('zIndex') | 1099 @JSName('zIndex') |
1140 String _zIndex; | 1100 String _zIndex; |
1141 | 1101 |
1142 $endif | |
1143 } | 1102 } |
1144 | 1103 |
1145 class _CssStyleDeclarationSet extends Object with CssStyleDeclarationBase { | 1104 class _CssStyleDeclarationSet extends Object with CssStyleDeclarationBase { |
1146 final Iterable<Element> _elementIterable; | 1105 final Iterable<Element> _elementIterable; |
1147 Iterable<CssStyleDeclaration> _elementCssStyleDeclarationSetIterable; | 1106 Iterable<CssStyleDeclaration> _elementCssStyleDeclarationSetIterable; |
1148 | 1107 |
1149 _CssStyleDeclarationSet(this._elementIterable) { | 1108 _CssStyleDeclarationSet(this._elementIterable) { |
1150 _elementCssStyleDeclarationSetIterable = new List.from( | 1109 _elementCssStyleDeclarationSetIterable = new List.from( |
1151 _elementIterable).map((e) => e.style); | 1110 _elementIterable).map((e) => e.style); |
1152 } | 1111 } |
1153 | 1112 |
1154 String getPropertyValue(String propertyName) => | 1113 String getPropertyValue(String propertyName) => |
1155 _elementCssStyleDeclarationSetIterable.first.getPropertyValue( | 1114 _elementCssStyleDeclarationSetIterable.first.getPropertyValue( |
1156 propertyName); | 1115 propertyName); |
1157 | 1116 |
1158 void setProperty(String propertyName, String value, [String priority]) { | 1117 void setProperty(String propertyName, String value, [String priority]) { |
1159 _elementCssStyleDeclarationSetIterable.forEach((e) => | 1118 _elementCssStyleDeclarationSetIterable.forEach((e) => |
1160 e.setProperty(propertyName, value, priority)); | 1119 e.setProperty(propertyName, value, priority)); |
1161 } | 1120 } |
1162 | 1121 |
1163 | 1122 |
1164 $if DART2JS | |
1165 void _setAll(String propertyName, String value) { | 1123 void _setAll(String propertyName, String value) { |
1166 value = value == null ? '' : value; | 1124 value = value == null ? '' : value; |
1167 for (Element element in _elementIterable) { | 1125 for (Element element in _elementIterable) { |
1168 JS('void', '#.style[#] = #', element, propertyName, value); | 1126 JS('void', '#.style[#] = #', element, propertyName, value); |
1169 } | 1127 } |
1170 } | 1128 } |
1171 | 1129 |
1172 /** Sets the value of "background" */ | 1130 /** Sets the value of "background" */ |
1173 set background(String value) { | 1131 set background(String value) { |
1174 _setAll('background', value); | 1132 _setAll('background', value); |
(...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1612 /** Sets the value of "word-spacing" */ | 1570 /** Sets the value of "word-spacing" */ |
1613 set wordSpacing(String value) { | 1571 set wordSpacing(String value) { |
1614 _setAll('wordSpacing', value); | 1572 _setAll('wordSpacing', value); |
1615 } | 1573 } |
1616 | 1574 |
1617 /** Sets the value of "z-index" */ | 1575 /** Sets the value of "z-index" */ |
1618 set zIndex(String value) { | 1576 set zIndex(String value) { |
1619 _setAll('zIndex', value); | 1577 _setAll('zIndex', value); |
1620 } | 1578 } |
1621 | 1579 |
1622 $endif | |
1623 | 1580 |
1624 // Important note: CssStyleDeclarationSet does NOT implement every method | 1581 // Important note: CssStyleDeclarationSet does NOT implement every method |
1625 // available in CssStyleDeclaration. Some of the methods don't make so much | 1582 // available in CssStyleDeclaration. Some of the methods don't make so much |
1626 // sense in terms of having a resonable value to return when you're | 1583 // sense in terms of having a resonable value to return when you're |
1627 // considering a list of Elements. You will need to manually add any of the | 1584 // considering a list of Elements. You will need to manually add any of the |
1628 // items in the MEMBERS set if you want that functionality. | 1585 // items in the MEMBERS set if you want that functionality. |
1629 } | 1586 } |
1630 | 1587 |
1631 $if DART2JS | |
1632 abstract class CssStyleDeclarationBase { | 1588 abstract class CssStyleDeclarationBase { |
1633 String getPropertyValue(String propertyName); | 1589 String getPropertyValue(String propertyName); |
1634 void setProperty(String propertyName, String value, [String priority]); | 1590 void setProperty(String propertyName, String value, [String priority]); |
1635 $else | |
1636 $if JSINTEROP | |
1637 class CssStyleDeclarationBase { | |
1638 String getPropertyValue(String propertyName) => | |
1639 throw new StateError('getProperty not overridden in dart:html'); | |
1640 void setProperty(String propertyName, String value, [String priority]) => | |
1641 throw new StateError('setProperty not overridden in dart:html'); | |
1642 $else | |
1643 abstract class CssStyleDeclarationBase { | |
1644 String getPropertyValue(String propertyName); | |
1645 void setProperty(String propertyName, String value, [String priority]); | |
1646 $endif | |
1647 $endif | |
1648 | 1591 |
1649 /** Gets the value of "align-content" */ | 1592 /** Gets the value of "align-content" */ |
1650 String get alignContent => | 1593 String get alignContent => |
1651 getPropertyValue('align-content'); | 1594 getPropertyValue('align-content'); |
1652 | 1595 |
1653 /** Sets the value of "align-content" */ | 1596 /** Sets the value of "align-content" */ |
1654 set alignContent(String value) { | 1597 set alignContent(String value) { |
1655 setProperty('align-content', value, ''); | 1598 setProperty('align-content', value, ''); |
1656 } | 1599 } |
1657 | 1600 |
(...skipping 3065 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4723 | 4666 |
4724 /** Gets the value of "zoom" */ | 4667 /** Gets the value of "zoom" */ |
4725 String get zoom => | 4668 String get zoom => |
4726 getPropertyValue('zoom'); | 4669 getPropertyValue('zoom'); |
4727 | 4670 |
4728 /** Sets the value of "zoom" */ | 4671 /** Sets the value of "zoom" */ |
4729 set zoom(String value) { | 4672 set zoom(String value) { |
4730 setProperty('zoom', value, ''); | 4673 setProperty('zoom', value, ''); |
4731 } | 4674 } |
4732 } | 4675 } |
OLD | NEW |