OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 part of html; | 5 part of html; |
6 | 6 |
7 /** | 7 /** |
8 * A set (union) of the CSS classes that are present in a set of elements. | 8 * A set (union) of the CSS classes that are present in a set of elements. |
9 * Implemented separately from _ElementCssClassSet for performance. | 9 * Implemented separately from _ElementCssClassSet for performance. |
10 */ | 10 */ |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 } | 133 } |
134 | 134 |
135 void retainWhere(bool test(String name)) { | 135 void retainWhere(bool test(String name)) { |
136 _removeWhere(_element, test, false); | 136 _removeWhere(_element, test, false); |
137 } | 137 } |
138 | 138 |
139 static bool _contains(Element _element, Object value) { | 139 static bool _contains(Element _element, Object value) { |
140 return value is String && _classListContains(_classListOf(_element), value); | 140 return value is String && _classListContains(_classListOf(_element), value); |
141 } | 141 } |
142 | 142 |
| 143 @ForceInline() |
143 static bool _add(Element _element, String value) { | 144 static bool _add(Element _element, String value) { |
144 DomTokenList list = _classListOf(_element); | 145 DomTokenList list = _classListOf(_element); |
145 // Compute returned result independently of action upon the set. | 146 // Compute returned result independently of action upon the set. |
146 bool added = !_classListContainsBeforeAddOrRemove(list, value); | 147 bool added = !_classListContainsBeforeAddOrRemove(list, value); |
147 _classListAdd(list, value); | 148 _classListAdd(list, value); |
148 return added; | 149 return added; |
149 } | 150 } |
150 | 151 |
| 152 @ForceInline() |
151 static bool _remove(Element _element, String value) { | 153 static bool _remove(Element _element, String value) { |
152 DomTokenList list = _classListOf(_element); | 154 DomTokenList list = _classListOf(_element); |
153 bool removed = _classListContainsBeforeAddOrRemove(list, value); | 155 bool removed = _classListContainsBeforeAddOrRemove(list, value); |
154 _classListRemove(list, value); | 156 _classListRemove(list, value); |
155 return removed; | 157 return removed; |
156 } | 158 } |
157 | 159 |
158 static bool _toggle(Element _element, String value, bool shouldAdd) { | 160 static bool _toggle(Element _element, String value, bool shouldAdd) { |
159 // There is no value that can be passed as the second argument of | 161 // There is no value that can be passed as the second argument of |
160 // DomTokenList.toggle that behaves the same as passing one argument. | 162 // DomTokenList.toggle that behaves the same as passing one argument. |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 | 251 |
250 static bool _classListToggle1(DomTokenList list, String value) { | 252 static bool _classListToggle1(DomTokenList list, String value) { |
251 return JS('bool', '#.toggle(#)', list, value); | 253 return JS('bool', '#.toggle(#)', list, value); |
252 } | 254 } |
253 | 255 |
254 static bool _classListToggle2( | 256 static bool _classListToggle2( |
255 DomTokenList list, String value, bool shouldAdd) { | 257 DomTokenList list, String value, bool shouldAdd) { |
256 return JS('bool', '#.toggle(#, #)', list, value, shouldAdd); | 258 return JS('bool', '#.toggle(#, #)', list, value, shouldAdd); |
257 } | 259 } |
258 } | 260 } |
OLD | NEW |