Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(626)

Side by Side Diff: client/html/src/CssClassSet.dart

Issue 9148015: Example showing alternate async measurement solution (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Final version Created 8 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 // TODO - figure out whether classList exists, and if so use that 5 // TODO - figure out whether classList exists, and if so use that
6 // rather than the className property that is being used here. 6 // rather than the className property that is being used here.
7 7
8 class _CssClassSet implements Set<String> { 8 class _CssClassSet implements Set<String> {
9 9
10 final _element; 10 final _element;
11 11
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 /** 98 /**
99 * Helper method used to modify the set of css classes on this element. 99 * Helper method used to modify the set of css classes on this element.
100 * 100 *
101 * f - callback with: 101 * f - callback with:
102 * s - a Set of all the css class name currently on this element. 102 * s - a Set of all the css class name currently on this element.
103 * 103 *
104 * After f returns, the modified set is written to the 104 * After f returns, the modified set is written to the
105 * className property of this element. 105 * className property of this element.
106 */ 106 */
107 void _modify( f(Set<String> s)) { 107 void _modify( f(Set<String> s)) {
108 assert(!_inMeasurementFrame || !_nodeInDocument(_element));
108 Set<String> s = _read(); 109 Set<String> s = _read();
109 f(s); 110 f(s);
110 _write(s); 111 _write(s);
111 } 112 }
112 113
113 /** 114 /**
114 * Read the class names from the HTMLElement class property, 115 * Read the class names from the HTMLElement class property,
115 * and put them into a set (duplicates are discarded). 116 * and put them into a set (duplicates are discarded).
116 */ 117 */
117 Set<String> _read() { 118 Set<String> _read() {
(...skipping 12 matching lines...) Expand all
130 * Read the class names as a space-separated string. This is meant to be 131 * Read the class names as a space-separated string. This is meant to be
131 * overridden by subclasses. 132 * overridden by subclasses.
132 */ 133 */
133 String _className() => _element.className; 134 String _className() => _element.className;
134 135
135 /** 136 /**
136 * Join all the elements of a set into one string and write 137 * Join all the elements of a set into one string and write
137 * back to the element. 138 * back to the element.
138 */ 139 */
139 void _write(Set s) { 140 void _write(Set s) {
141 assert(!_inMeasurementFrame || !_nodeInDocument(_element));
140 _element.className = _formatSet(s); 142 _element.className = _formatSet(s);
141 } 143 }
142 144
143 String _formatSet(Set<String> s) { 145 String _formatSet(Set<String> s) {
144 // TODO(mattsh) should be able to pass Set to String.joins http:/b/5398605 146 // TODO(mattsh) should be able to pass Set to String.joins http:/b/5398605
145 List list = new List.from(s); 147 List list = new List.from(s);
146 return Strings.join(list, ' '); 148 return Strings.join(list, ' ');
147 } 149 }
148 150
149 } 151 }
150 152
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698