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