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

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: Remove duplicated imports from html.dart 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
« no previous file with comments | « client/html/src/Document.dart ('k') | client/html/src/DocumentWrappingImplementation.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) 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 113 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 class EmptyClientRect implements ClientRect { 134 Future<CSSStyleDeclaration> _emptyStyleFuture() {
135 num get bottom() => 0; 135 return _createMeasurementFuture(() => new EmptyStyleDeclaration(),
136 num get top() => 0; 136 new Completer<CSSStyleDeclaration>());
137 num get left() => 0; 137 }
138 num get right() => 0; 138
139 num get height() => 0; 139 class EmptyElementRect implements ElementRect {
140 num get width() => 0; 140 final ClientRect client = const SimpleClientRect(0, 0, 0, 0);
141 final ClientRect offset = const SimpleClientRect(0, 0, 0, 0);
142 final ClientRect scroll = const SimpleClientRect(0, 0, 0, 0);
143 final ClientRect bounding = const SimpleClientRect(0, 0, 0, 0);
144 final List<ClientRect> clientRects = const <ClientRect>[];
145
146 const EmptyElementRect();
141 } 147 }
142 148
143 class DocumentFragmentWrappingImplementation extends NodeWrappingImplementation implements DocumentFragment { 149 class DocumentFragmentWrappingImplementation extends NodeWrappingImplementation implements DocumentFragment {
144 ElementList _elements; 150 ElementList _elements;
145 151
146 DocumentFragmentWrappingImplementation._wrap(ptr) : super._wrap(ptr) {} 152 DocumentFragmentWrappingImplementation._wrap(ptr) : super._wrap(ptr) {}
147 153
148 factory DocumentFragmentWrappingImplementation() { 154 factory DocumentFragmentWrappingImplementation() {
149 return new DocumentFragmentWrappingImplementation._wrap( 155 return new DocumentFragmentWrappingImplementation._wrap(
150 dom.document.createDocumentFragment()); 156 dom.document.createDocumentFragment());
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 position_OR_where, new DocumentFragment.html(text)); 225 position_OR_where, new DocumentFragment.html(text));
220 } 226 }
221 227
222 ElementEvents get on() { 228 ElementEvents get on() {
223 if (_on === null) { 229 if (_on === null) {
224 _on = new ElementEventsImplementation._wrap(_ptr); 230 _on = new ElementEventsImplementation._wrap(_ptr);
225 } 231 }
226 return _on; 232 return _on;
227 } 233 }
228 234
235 Future<ElementRect> get rect() {
236 return _createMeasurementFuture(() => const EmptyElementRect(),
237 new Completer<ElementRect>());
238 }
239
229 Element query(String selectors) => 240 Element query(String selectors) =>
230 LevelDom.wrapElement(_ptr.querySelector(selectors)); 241 LevelDom.wrapElement(_ptr.querySelector(selectors));
231 242
232 ElementList queryAll(String selectors) => 243 ElementList queryAll(String selectors) =>
233 LevelDom.wrapElementList(_ptr.querySelectorAll(selectors)); 244 LevelDom.wrapElementList(_ptr.querySelectorAll(selectors));
234 245
235 // If we can come up with a semi-reasonable default value for an Element 246 // If we can come up with a semi-reasonable default value for an Element
236 // getter, we'll use it. In general, these return the same values as an 247 // getter, we'll use it. In general, these return the same values as an
237 // element that has no parent. 248 // element that has no parent.
238 int get clientHeight() => 0;
239 int get clientWidth() => 0;
240 int get offsetHeight() => 0;
241 int get offsetWidth() => 0;
242 int get scrollHeight() => 0;
243 int get scrollWidth() => 0;
244 int get clientLeft() => 0;
245 int get clientTop() => 0;
246 int get offsetLeft() => 0;
247 int get offsetTop() => 0;
248 int get scrollLeft() => 0;
249 int get scrollTop() => 0;
250 String get contentEditable() => "false"; 249 String get contentEditable() => "false";
251 bool get isContentEditable() => false; 250 bool get isContentEditable() => false;
252 bool get draggable() => false; 251 bool get draggable() => false;
253 bool get hidden() => false; 252 bool get hidden() => false;
254 bool get spellcheck() => false; 253 bool get spellcheck() => false;
255 int get tabIndex() => -1; 254 int get tabIndex() => -1;
256 String get id() => ""; 255 String get id() => "";
257 String get title() => ""; 256 String get title() => "";
258 String get tagName() => ""; 257 String get tagName() => "";
259 String get webkitdropzone() => ""; 258 String get webkitdropzone() => "";
260 Element get firstElementChild() => elements.first(); 259 Element get firstElementChild() => elements.first();
261 Element get lastElementChild() => elements.last(); 260 Element get lastElementChild() => elements.last();
262 Element get nextElementSibling() => null; 261 Element get nextElementSibling() => null;
263 Element get previousElementSibling() => null; 262 Element get previousElementSibling() => null;
264 Element get offsetParent() => null; 263 Element get offsetParent() => null;
265 Element get parent() => null; 264 Element get parent() => null;
266 Map<String, String> get attributes() => const {}; 265 Map<String, String> get attributes() => const {};
267 // Issue 174: this should be a const set. 266 // Issue 174: this should be a const set.
268 Set<String> get classes() => new Set<String>(); 267 Set<String> get classes() => new Set<String>();
269 Map<String, String> get dataAttributes() => const {}; 268 Map<String, String> get dataAttributes() => const {};
270 CSSStyleDeclaration get style() => new EmptyStyleDeclaration(); 269 CSSStyleDeclaration get style() => new EmptyStyleDeclaration();
271 ClientRect getBoundingClientRect() => new EmptyClientRect(); 270 Future<CSSStyleDeclaration> get computedStyle() =>
272 List<ClientRect> getClientRects() => const []; 271 _emptyStyleFuture();
272 Future<CSSStyleDeclaration> getComputedStyle(String pseudoElement) =>
273 _emptyStyleFuture();
273 bool matchesSelector([String selectors]) => false; 274 bool matchesSelector([String selectors]) => false;
274 275
275 // Imperative Element methods are made into no-ops, as they are on parentless 276 // Imperative Element methods are made into no-ops, as they are on parentless
276 // elements. 277 // elements.
277 void blur() {} 278 void blur() {}
278 void focus() {} 279 void focus() {}
279 void scrollByLines([int lines]) {} 280 void scrollByLines([int lines]) {}
280 void scrollByPages([int pages]) {} 281 void scrollByPages([int pages]) {}
281 void scrollIntoView([bool centerIfNeeded]) {} 282 void scrollIntoView([bool centerIfNeeded]) {}
282 283
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 void set title(String value) { 361 void set title(String value) {
361 throw new UnsupportedOperationException( 362 throw new UnsupportedOperationException(
362 "Title can't be set for document fragments."); 363 "Title can't be set for document fragments.");
363 } 364 }
364 365
365 void set webkitdropzone(String value) { 366 void set webkitdropzone(String value) {
366 throw new UnsupportedOperationException( 367 throw new UnsupportedOperationException(
367 "WebKit drop zone can't be set for document fragments."); 368 "WebKit drop zone can't be set for document fragments.");
368 } 369 }
369 } 370 }
OLDNEW
« no previous file with comments | « client/html/src/Document.dart ('k') | client/html/src/DocumentWrappingImplementation.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698