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

Side by Side Diff: tools/dom/src/CssClassSet.dart

Issue 11783009: Big merge from experimental to bleeding edge. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 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
« no previous file with comments | « tools/dom/src/AttributeMap.dart ('k') | tools/dom/src/Isolates.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, 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 part of html; 5 part of html;
6 6
7 abstract class CssClassSet implements Set<String> { 7 abstract class CssClassSet implements Set<String> {
8 8
9 String toString() { 9 String toString() {
10 return Strings.join(new List.from(readClasses()), ' '); 10 return Strings.join(new List.from(readClasses()), ' ');
(...skipping 16 matching lines...) Expand all
27 return result; 27 return result;
28 } 28 }
29 29
30 /** 30 /**
31 * Returns [:true:] if classes cannot be added or removed from this 31 * Returns [:true:] if classes cannot be added or removed from this
32 * [:CssClassSet:]. 32 * [:CssClassSet:].
33 */ 33 */
34 bool get frozen => false; 34 bool get frozen => false;
35 35
36 // interface Iterable - BEGIN 36 // interface Iterable - BEGIN
37 Iterator<String> iterator() => readClasses().iterator(); 37 Iterator<String> get iterator => readClasses().iterator;
38 // interface Iterable - END 38 // interface Iterable - END
39 39
40 // interface Collection - BEGIN 40 // interface Collection - BEGIN
41 void forEach(void f(String element)) { 41 void forEach(void f(String element)) {
42 readClasses().forEach(f); 42 readClasses().forEach(f);
43 } 43 }
44 44
45 Collection map(f(String element)) => readClasses().map(f); 45 String join([String separator]) => readClasses().join(separator);
46 46
47 Collection<String> filter(bool f(String element)) => readClasses().filter(f); 47 Iterable mappedBy(f(String element)) => readClasses().mappedBy(f);
48
49 Iterable<String> where(bool f(String element)) => readClasses().where(f);
48 50
49 bool every(bool f(String element)) => readClasses().every(f); 51 bool every(bool f(String element)) => readClasses().every(f);
50 52
51 bool some(bool f(String element)) => readClasses().some(f); 53 bool any(bool f(String element)) => readClasses().any(f);
52 54
53 bool get isEmpty => readClasses().isEmpty; 55 bool get isEmpty => readClasses().isEmpty;
54 56
55 int get length =>readClasses().length; 57 int get length =>readClasses().length;
56 58
57 dynamic reduce(dynamic initialValue, 59 dynamic reduce(dynamic initialValue,
58 dynamic combine(dynamic previousValue, String element)) { 60 dynamic combine(dynamic previousValue, String element)) {
59 return readClasses().reduce(initialValue, combine); 61 return readClasses().reduce(initialValue, combine);
60 } 62 }
61 // interface Collection - END 63 // interface Collection - END
62 64
63 // interface Set - BEGIN 65 // interface Set - BEGIN
64 bool contains(String value) => readClasses().contains(value); 66 bool contains(String value) => readClasses().contains(value);
65 67
66 void add(String value) { 68 void add(String value) {
67 // TODO - figure out if we need to do any validation here 69 // TODO - figure out if we need to do any validation here
68 // or if the browser natively does enough 70 // or if the browser natively does enough
69 _modify((s) => s.add(value)); 71 _modify((s) => s.add(value));
70 } 72 }
71 73
72 bool remove(String value) { 74 bool remove(String value) {
73 Set<String> s = readClasses(); 75 Set<String> s = readClasses();
74 bool result = s.remove(value); 76 bool result = s.remove(value);
75 writeClasses(s); 77 writeClasses(s);
76 return result; 78 return result;
77 } 79 }
78 80
79 void addAll(Collection<String> collection) { 81 void addAll(Iterable<String> iterable) {
80 // TODO - see comment above about validation 82 // TODO - see comment above about validation
81 _modify((s) => s.addAll(collection)); 83 _modify((s) => s.addAll(iterable));
82 } 84 }
83 85
84 void removeAll(Collection<String> collection) { 86 void removeAll(Iterable<String> iterable) {
85 _modify((s) => s.removeAll(collection)); 87 _modify((s) => s.removeAll(iterable));
86 } 88 }
87 89
88 bool isSubsetOf(Collection<String> collection) => 90 bool isSubsetOf(Collection<String> collection) =>
89 readClasses().isSubsetOf(collection); 91 readClasses().isSubsetOf(collection);
90 92
91 bool containsAll(Collection<String> collection) => 93 bool containsAll(Collection<String> collection) =>
92 readClasses().containsAll(collection); 94 readClasses().containsAll(collection);
93 95
94 Set<String> intersection(Collection<String> other) => 96 Set<String> intersection(Collection<String> other) =>
95 readClasses().intersection(other); 97 readClasses().intersection(other);
(...skipping 25 matching lines...) Expand all
121 */ 123 */
122 Set<String> readClasses(); 124 Set<String> readClasses();
123 125
124 /** 126 /**
125 * Join all the elements of a set into one string and write 127 * Join all the elements of a set into one string and write
126 * back to the element. 128 * back to the element.
127 * This is intended to be overridden by specific implementations. 129 * This is intended to be overridden by specific implementations.
128 */ 130 */
129 void writeClasses(Set<String> s); 131 void writeClasses(Set<String> s);
130 } 132 }
OLDNEW
« no previous file with comments | « tools/dom/src/AttributeMap.dart ('k') | tools/dom/src/Isolates.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698