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

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

Issue 8363040: Implement measurement using futures (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: take2 Created 9 years, 1 month 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) 2011, 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
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 throw new UnsupportedOperationException( 120 throw new UnsupportedOperationException(
121 "Can't modify a frozen style declaration."); 121 "Can't modify a frozen style declaration.");
122 } 122 }
123 123
124 void setProperty(String propertyName, String value, [String priority]) { 124 void setProperty(String propertyName, String value, [String priority]) {
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 129
130 class EmptyClientRect implements ClientRect { 130 Future<CSSStyleDeclaration> _emptyStyleFuture() {
131 num get bottom() => 0; 131 final completer = new Completer<CSSStyleDeclaration>();
132 num get top() => 0; 132 completer.complete(new EmptyStyleDeclaration());
133 num get left() => 0; 133 return completer.future;
134 num get right() => 0; 134 }
135 num get height() => 0; 135
136 num get width() => 0; 136 class EmptyElementRect implements ElementRect {
137 ClientRect get client() => new SimpleClientRect(0, 0, 0, 0);
arv (Not doing code reviews) 2011/10/27 03:16:13 Does this still work? const SimpleClientRect(0, 0
Jacob 2011/10/27 20:59:25 Done. Switched these all to fields and took advan
138 ClientRect get offset() => new SimpleClientRect(0, 0, 0, 0);
139 ClientRect get scroll() => new SimpleClientRect(0, 0, 0, 0);
140 ClientRect get bounding() => new SimpleClientRect(0, 0, 0, 0);
141 List<ClientRect> get clientRects() => const <SimpleClientRect>[];
137 } 142 }
138 143
139 class DocumentFragmentWrappingImplementation extends NodeWrappingImplementation implements DocumentFragment { 144 class DocumentFragmentWrappingImplementation extends NodeWrappingImplementation implements DocumentFragment {
140 ElementList _elements; 145 ElementList _elements;
141 146
142 DocumentFragmentWrappingImplementation._wrap(ptr) : super._wrap(ptr) {} 147 DocumentFragmentWrappingImplementation._wrap(ptr) : super._wrap(ptr) {}
143 148
144 factory DocumentFragmentWrappingImplementation() { 149 factory DocumentFragmentWrappingImplementation() {
145 return new DocumentFragmentWrappingImplementation._wrap( 150 return new DocumentFragmentWrappingImplementation._wrap(
146 dom.document.createDocumentFragment()); 151 dom.document.createDocumentFragment());
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 position_OR_where, new DocumentFragment.html(text)); 220 position_OR_where, new DocumentFragment.html(text));
216 } 221 }
217 222
218 ElementEvents get on() { 223 ElementEvents get on() {
219 if (_on === null) { 224 if (_on === null) {
220 _on = new ElementEventsImplementation._wrap(_ptr); 225 _on = new ElementEventsImplementation._wrap(_ptr);
221 } 226 }
222 return _on; 227 return _on;
223 } 228 }
224 229
230 Future<ElementRect> get rect() {
231 final completer = new Completer<ElementRect>();
232 completer.complete(new EmptyElementRect());
233 return completer.future;
234 }
235
225 Element query(String selectors) => 236 Element query(String selectors) =>
226 LevelDom.wrapElement(_ptr.querySelector(selectors)); 237 LevelDom.wrapElement(_ptr.querySelector(selectors));
227 238
228 ElementList queryAll(String selectors) => 239 ElementList queryAll(String selectors) =>
229 LevelDom.wrapElementList(_ptr.querySelectorAll(selectors)); 240 LevelDom.wrapElementList(_ptr.querySelectorAll(selectors));
230 241
231 // If we can come up with a semi-reasonable default value for an Element 242 // If we can come up with a semi-reasonable default value for an Element
232 // getter, we'll use it. In general, these return the same values as an 243 // getter, we'll use it. In general, these return the same values as an
233 // element that has no parent. 244 // element that has no parent.
234 int get clientHeight() => 0;
235 int get clientWidth() => 0;
236 int get offsetHeight() => 0;
237 int get offsetWidth() => 0;
238 int get scrollHeight() => 0;
239 int get scrollWidth() => 0;
240 int get clientLeft() => 0;
241 int get clientTop() => 0;
242 int get offsetLeft() => 0;
243 int get offsetTop() => 0;
244 int get scrollLeft() => 0;
245 int get scrollTop() => 0;
246 String get contentEditable() => "false"; 245 String get contentEditable() => "false";
247 bool get isContentEditable() => false; 246 bool get isContentEditable() => false;
248 bool get draggable() => false; 247 bool get draggable() => false;
249 bool get hidden() => false; 248 bool get hidden() => false;
250 bool get spellcheck() => false; 249 bool get spellcheck() => false;
251 int get tabIndex() => -1; 250 int get tabIndex() => -1;
252 String get id() => ""; 251 String get id() => "";
253 String get title() => ""; 252 String get title() => "";
254 String get tagName() => ""; 253 String get tagName() => "";
255 String get webkitdropzone() => ""; 254 String get webkitdropzone() => "";
256 Element get firstElementChild() => elements.first(); 255 Element get firstElementChild() => elements.first();
257 Element get lastElementChild() => elements.last(); 256 Element get lastElementChild() => elements.last();
258 Element get nextElementSibling() => null; 257 Element get nextElementSibling() => null;
259 Element get previousElementSibling() => null; 258 Element get previousElementSibling() => null;
260 Element get offsetParent() => null; 259 Element get offsetParent() => null;
261 Element get parent() => null; 260 Element get parent() => null;
262 Map<String, String> get attributes() => const {}; 261 Map<String, String> get attributes() => const {};
263 // Issue 174: this should be a const set. 262 // Issue 174: this should be a const set.
264 Set<String> get classes() => new Set<String>(); 263 Set<String> get classes() => new Set<String>();
265 Map<String, String> get dataAttributes() => const {}; 264 Map<String, String> get dataAttributes() => const {};
266 CSSStyleDeclaration get style() => new EmptyStyleDeclaration(); 265 CSSStyleDeclaration get style() => new EmptyStyleDeclaration();
267 ClientRect getBoundingClientRect() => new EmptyClientRect(); 266 Future<CSSStyleDeclaration> get computedStyle() =>
268 List<ClientRect> getClientRects() => const []; 267 _emptyStyleFuture();
268 Future<CSSStyleDeclaration> getComputedStyle(String pseudoElement) =>
269 _emptyStyleFuture();
269 bool matchesSelector([String selectors]) => false; 270 bool matchesSelector([String selectors]) => false;
270 271
271 // 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
272 // elements. 273 // elements.
273 void blur() {} 274 void blur() {}
274 void focus() {} 275 void focus() {}
275 void scrollByLines([int lines]) {} 276 void scrollByLines([int lines]) {}
276 void scrollByPages([int pages]) {} 277 void scrollByPages([int pages]) {}
277 void scrollIntoView([bool centerIfNeeded]) {} 278 void scrollIntoView([bool centerIfNeeded]) {}
278 279
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 356
356 void set title(String value) { 357 void set title(String value) {
357 throw new UnsupportedOperationException( 358 throw new UnsupportedOperationException(
358 "Title can't be set for document fragments."); 359 "Title can't be set for document fragments.");
359 } 360 }
360 361
361 void set webkitdropzone(String value) { 362 void set webkitdropzone(String value) {
362 throw new UnsupportedOperationException( 363 throw new UnsupportedOperationException(
363 "WebKit drop zone can't be set for document fragments."); 364 "WebKit drop zone can't be set for document fragments.");
364 } 365 }
365 } 366 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698