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

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

Issue 8416010: Further code review changes for issue 8341027. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Add DOMWrapperBase._empty. 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 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 _filtered.getRange(start, length); 101 _filtered.getRange(start, length);
102 int indexOf(Element element, int startIndex) => 102 int indexOf(Element element, int startIndex) =>
103 _filtered.indexOf(element, startIndex); 103 _filtered.indexOf(element, startIndex);
104 int lastIndexOf(Element element, int startIndex) => 104 int lastIndexOf(Element element, int startIndex) =>
105 _filtered.lastIndexOf(element, startIndex); 105 _filtered.lastIndexOf(element, startIndex);
106 Element last() => _filtered.last(); 106 Element last() => _filtered.last();
107 } 107 }
108 108
109 class EmptyStyleDeclaration extends CSSStyleDeclarationWrappingImplementation { 109 class EmptyStyleDeclaration extends CSSStyleDeclarationWrappingImplementation {
110 // This can't call super(), since that's a factory constructor 110 // This can't call super(), since that's a factory constructor
111 EmptyStyleDeclaration() 111 const EmptyStyleDeclaration() : super._empty();
112 : super._wrap(dom.document.createElement('div').style); 112
113 String get cssText() => "";
114 int get length() => 0;
115 CSSRule get parentRule() => null;
116 CSSValue getPropertyCSSValue(String propertyName) => null;»
117 String getPropertyPriority(String propertyName) => "";»
118 String getPropertyShorthand(String propertyName) => null;»
119 String getPropertyValue(String propertyName) => null;»
120 bool isPropertyImplicit(String propertyName) => false;»
121 String item(int index) => "";
113 122
114 void set cssText(String value) { 123 void set cssText(String value) {
115 throw new UnsupportedOperationException( 124 throw new UnsupportedOperationException(
116 "Can't modify a frozen style declaration."); 125 "Can't modify a frozen style declaration.");
117 } 126 }
118 127
119 String removeProperty(String propertyName) { 128 String removeProperty(String propertyName) {
120 throw new UnsupportedOperationException( 129 throw new UnsupportedOperationException(
121 "Can't modify a frozen style declaration."); 130 "Can't modify a frozen style declaration.");
122 } 131 }
123 132
124 void setProperty(String propertyName, String value, [String priority]) { 133 void setProperty(String propertyName, String value, [String priority]) {
125 throw new UnsupportedOperationException( 134 throw new UnsupportedOperationException(
126 "Can't modify a frozen style declaration."); 135 "Can't modify a frozen style declaration.");
127 } 136 }
128 } 137 }
129 138
130 class EmptyClientRect implements ClientRect { 139 class EmptyClientRect implements ClientRect {
131 num get bottom() => 0; 140 num get bottom() => 0;
132 num get top() => 0; 141 num get top() => 0;
133 num get left() => 0; 142 num get left() => 0;
134 num get right() => 0; 143 num get right() => 0;
135 num get height() => 0; 144 num get height() => 0;
136 num get width() => 0; 145 num get width() => 0;
137 } 146 }
138 147
139 class DocumentFragmentWrappingImplementation extends NodeWrappingImplementation implements DocumentFragment { 148 class DocumentFragmentWrappingImplementation extends NodeWrappingImplementation implements DocumentFragment {
140 ElementList _elements; 149 ElementList _elements;
150 CSSStyleDeclaration _style;
151 ClientRect _clientRect;
141 152
142 DocumentFragmentWrappingImplementation._wrap(ptr) : super._wrap(ptr) {} 153 DocumentFragmentWrappingImplementation._wrap(ptr) : super._wrap(ptr) {}
143 154
144 factory DocumentFragmentWrappingImplementation() { 155 factory DocumentFragmentWrappingImplementation() {
145 return new DocumentFragmentWrappingImplementation._wrap( 156 return new DocumentFragmentWrappingImplementation._wrap(
146 dom.document.createDocumentFragment()); 157 dom.document.createDocumentFragment());
147 } 158 }
148 159
149 factory DocumentFragmentWrappingImplementation.html(String html) { 160 factory DocumentFragmentWrappingImplementation.html(String html) {
150 var fragment = new DocumentFragment(); 161 var fragment = new DocumentFragment();
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 } 232 }
222 return _on; 233 return _on;
223 } 234 }
224 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
242 CSSStyleDeclaration get style() {
243 if (_style == null) _style = const EmptyStyleDeclaration();
244 return _style;
245 }
246
247 ClientRect getBoundingClientRect() {
248 if (_clientRect == null) _clientRect = new EmptyClientRect();
249 return _clientRect;
250 }
251
231 // If we can come up with a semi-reasonable default value for an Element 252 // 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 253 // getter, we'll use it. In general, these return the same values as an
233 // element that has no parent. 254 // element that has no parent.
234 int get clientHeight() => 0; 255 int get clientHeight() => 0;
235 int get clientWidth() => 0; 256 int get clientWidth() => 0;
236 int get offsetHeight() => 0; 257 int get offsetHeight() => 0;
237 int get offsetWidth() => 0; 258 int get offsetWidth() => 0;
238 int get scrollHeight() => 0; 259 int get scrollHeight() => 0;
239 int get scrollWidth() => 0; 260 int get scrollWidth() => 0;
240 int get clientLeft() => 0; 261 int get clientLeft() => 0;
(...skipping 15 matching lines...) Expand all
256 Element get firstElementChild() => elements.first(); 277 Element get firstElementChild() => elements.first();
257 Element get lastElementChild() => elements.last(); 278 Element get lastElementChild() => elements.last();
258 Element get nextElementSibling() => null; 279 Element get nextElementSibling() => null;
259 Element get previousElementSibling() => null; 280 Element get previousElementSibling() => null;
260 Element get offsetParent() => null; 281 Element get offsetParent() => null;
261 Element get parent() => null; 282 Element get parent() => null;
262 Map<String, String> get attributes() => const {}; 283 Map<String, String> get attributes() => const {};
263 // Issue 174: this should be a const set. 284 // Issue 174: this should be a const set.
264 Set<String> get classes() => new Set<String>(); 285 Set<String> get classes() => new Set<String>();
265 Map<String, String> get dataAttributes() => const {}; 286 Map<String, String> get dataAttributes() => const {};
266 CSSStyleDeclaration get style() => new EmptyStyleDeclaration();
267 ClientRect getBoundingClientRect() => new EmptyClientRect();
268 List<ClientRect> getClientRects() => const []; 287 List<ClientRect> getClientRects() => const [];
269 bool matchesSelector([String selectors]) => false; 288 bool matchesSelector([String selectors]) => false;
270 289
271 // Imperative Element methods are made into no-ops, as they are on parentless 290 // Imperative Element methods are made into no-ops, as they are on parentless
272 // elements. 291 // elements.
273 void blur() {} 292 void blur() {}
274 void focus() {} 293 void focus() {}
275 void scrollByLines([int lines]) {} 294 void scrollByLines([int lines]) {}
276 void scrollByPages([int pages]) {} 295 void scrollByPages([int pages]) {}
277 void scrollIntoView([bool centerIfNeeded]) {} 296 void scrollIntoView([bool centerIfNeeded]) {}
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 void set title(String value) { 375 void set title(String value) {
357 throw new UnsupportedOperationException( 376 throw new UnsupportedOperationException(
358 "Title can't be set for document fragments."); 377 "Title can't be set for document fragments.");
359 } 378 }
360 379
361 void set webkitdropzone(String value) { 380 void set webkitdropzone(String value) {
362 throw new UnsupportedOperationException( 381 throw new UnsupportedOperationException(
363 "WebKit drop zone can't be set for document fragments."); 382 "WebKit drop zone can't be set for document fragments.");
364 } 383 }
365 } 384 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698