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

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

Powered by Google App Engine
This is Rietveld 408576698