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

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

Issue 9148015: Example showing alternate async measurement solution (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Ready for review 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 class FilteredElementList implements ElementList { 5 class FilteredElementList implements ElementList {
6 final Node _node; 6 final Node _node;
7 final NodeList _childNodes; 7 final NodeList _childNodes;
8 8
9 FilteredElementList(Node node): _childNodes = node.nodes, _node = node; 9 FilteredElementList(Node node): _childNodes = node.nodes, _node = node;
10 10
11 // We can't memoize this, since it's possible that children will be messed 11 // We can't memoize this, since it's possible that children will be messed
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 throw new UnsupportedOperationException( 124 throw new UnsupportedOperationException(
125 "Can't modify a frozen style declaration."); 125 "Can't modify a frozen style declaration.");
126 } 126 }
127 127
128 void setProperty(String propertyName, String value, [String priority]) { 128 void setProperty(String propertyName, String value, [String priority]) {
129 throw new UnsupportedOperationException( 129 throw new UnsupportedOperationException(
130 "Can't modify a frozen style declaration."); 130 "Can't modify a frozen style declaration.");
131 } 131 }
132 } 132 }
133 133
134 Future<CSSStyleDeclaration> _emptyStyleFuture() {
135 return _createMeasurementFuture(() => new EmptyStyleDeclaration(),
136 new Completer<CSSStyleDeclaration>());
137 }
138
139 class EmptyElementRect implements ElementRect { 134 class EmptyElementRect implements ElementRect {
140 final ClientRect client = const SimpleClientRect(0, 0, 0, 0); 135 final ClientRect client = const SimpleClientRect(0, 0, 0, 0);
141 final ClientRect offset = const SimpleClientRect(0, 0, 0, 0); 136 final ClientRect offset = const SimpleClientRect(0, 0, 0, 0);
142 final ClientRect scroll = const SimpleClientRect(0, 0, 0, 0); 137 final ClientRect scroll = const SimpleClientRect(0, 0, 0, 0);
143 final ClientRect bounding = const SimpleClientRect(0, 0, 0, 0); 138 final ClientRect bounding = const SimpleClientRect(0, 0, 0, 0);
144 final List<ClientRect> clientRects = const <ClientRect>[]; 139 final List<ClientRect> clientRects = const <ClientRect>[];
145 140
146 const EmptyElementRect(); 141 const EmptyElementRect();
147 } 142 }
148 143
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 position_OR_where, new DocumentFragment.html(text)); 221 position_OR_where, new DocumentFragment.html(text));
227 } 222 }
228 223
229 ElementEvents get on() { 224 ElementEvents get on() {
230 if (_on === null) { 225 if (_on === null) {
231 _on = new ElementEventsImplementation._wrap(_ptr); 226 _on = new ElementEventsImplementation._wrap(_ptr);
232 } 227 }
233 return _on; 228 return _on;
234 } 229 }
235 230
236 Future<ElementRect> get rect() { 231 ElementRect get rect() {
237 return _createMeasurementFuture(() => const EmptyElementRect(), 232 // A document fragment can never be attached to a Document so it always
238 new Completer<ElementRect>()); 233 // safe to measure.
234 return const EmptyElementRect();
239 } 235 }
240 236
241 Element query(String selectors) => 237 Element query(String selectors) =>
242 LevelDom.wrapElement(_ptr.querySelector(selectors)); 238 LevelDom.wrapElement(_ptr.querySelector(selectors));
243 239
244 ElementList queryAll(String selectors) => 240 ElementList queryAll(String selectors) =>
245 LevelDom.wrapElementList(_ptr.querySelectorAll(selectors)); 241 LevelDom.wrapElementList(_ptr.querySelectorAll(selectors));
246 242
247 // If we can come up with a semi-reasonable default value for an Element 243 // If we can come up with a semi-reasonable default value for an Element
248 // getter, we'll use it. In general, these return the same values as an 244 // getter, we'll use it. In general, these return the same values as an
(...skipping 12 matching lines...) Expand all
261 Element get lastElementChild() => elements.last(); 257 Element get lastElementChild() => elements.last();
262 Element get nextElementSibling() => null; 258 Element get nextElementSibling() => null;
263 Element get previousElementSibling() => null; 259 Element get previousElementSibling() => null;
264 Element get offsetParent() => null; 260 Element get offsetParent() => null;
265 Element get parent() => null; 261 Element get parent() => null;
266 Map<String, String> get attributes() => const {}; 262 Map<String, String> get attributes() => const {};
267 // Issue 174: this should be a const set. 263 // Issue 174: this should be a const set.
268 Set<String> get classes() => new Set<String>(); 264 Set<String> get classes() => new Set<String>();
269 Map<String, String> get dataAttributes() => const {}; 265 Map<String, String> get dataAttributes() => const {};
270 CSSStyleDeclaration get style() => new EmptyStyleDeclaration(); 266 CSSStyleDeclaration get style() => new EmptyStyleDeclaration();
271 Future<CSSStyleDeclaration> get computedStyle() => 267 CSSStyleDeclaration get computedStyle() => new EmptyStyleDeclaration();
272 _emptyStyleFuture(); 268 CSSStyleDeclaration getComputedStyle(String pseudoElement) =>
273 Future<CSSStyleDeclaration> getComputedStyle(String pseudoElement) => 269 new EmptyStyleDeclaration();
274 _emptyStyleFuture();
275 bool matchesSelector([String selectors]) => false; 270 bool matchesSelector([String selectors]) => false;
276 271
277 // Imperative Element methods are made into no-ops, as they are on parentless 272 // Imperative Element methods are made into no-ops, as they are on parentless
278 // elements. 273 // elements.
279 void blur() {} 274 void blur() {}
280 void focus() {} 275 void focus() {}
281 void scrollByLines([int lines]) {} 276 void scrollByLines([int lines]) {}
282 void scrollByPages([int pages]) {} 277 void scrollByPages([int pages]) {}
283 void scrollIntoView([bool centerIfNeeded]) {} 278 void scrollIntoView([bool centerIfNeeded]) {}
284 279
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 "Title can't be set for document fragments."); 359 "Title can't be set for document fragments.");
365 } 360 }
366 361
367 void set webkitdropzone(String value) { 362 void set webkitdropzone(String value) {
368 throw new UnsupportedOperationException( 363 throw new UnsupportedOperationException(
369 "WebKit drop zone can't be set for document fragments."); 364 "WebKit drop zone can't be set for document fragments.");
370 } 365 }
371 366
372 DocumentFragment clone(bool deep) => super.clone(deep); 367 DocumentFragment clone(bool deep) => super.clone(deep);
373 } 368 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698