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

Side by Side Diff: tools/dom/templates/html/impl/impl_Element.darttemplate

Issue 19520019: Reverting 25196, 25195, 25192. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 5 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) 2012, 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 part of $LIBRARYNAME; 5 part of $LIBRARYNAME;
6 6
7 class _ChildrenElementList extends ListBase<Element> { 7 class _ChildrenElementList extends ListBase<Element> {
8 // Raw Element. 8 // Raw Element.
9 final Element _element; 9 final Element _element;
10 final HtmlCollection _childElements; 10 final HtmlCollection _childElements;
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 } 150 }
151 151
152 Element get single { 152 Element get single {
153 if (length > 1) throw new StateError("More than one element"); 153 if (length > 1) throw new StateError("More than one element");
154 return first; 154 return first;
155 } 155 }
156 } 156 }
157 157
158 /** 158 /**
159 * An immutable list containing HTML elements. This list contains some 159 * An immutable list containing HTML elements. This list contains some
160 * additional methods when compared to regular lists for ease of CSS 160 * additional methods for ease of CSS manipulation on a group of elements.
161 * manipulation on a group of elements.
162 */ 161 */
163 abstract class ElementList<T extends Element> extends ListBase<T> { 162 abstract class ElementList<T extends Element> extends ListBase<T> {
164 /** 163 /**
165 * The union of all CSS classes applied to the elements in this list. 164 * The union of all CSS classes applied to the elements in this list.
166 * 165 *
167 * This set makes it easy to add, remove or toggle (add if not present, remove 166 * This set makes it easy to add, remove or toggle (add if not present, remove
168 * if present) the classes applied to a collection of elements. 167 * if present) the classes applied to a collection of elements.
169 * 168 *
170 * htmlList.classes.add('selected'); 169 * htmlList.classes.add('selected');
171 * htmlList.classes.toggle('isOnline'); 170 * htmlList.classes.toggle('isOnline');
172 * htmlList.classes.remove('selected'); 171 * htmlList.classes.remove('selected');
173 */ 172 */
174 CssClassSet get classes; 173 CssClassSet get classes;
175 174
176 /** Replace the classes with `value` for every element in this list. */ 175 /** Replace the classes with `value` for every element in this list. */
177 set classes(Iterable<String> value); 176 set classes(Iterable<String> value);
178
179 /**
180 * Access dimensions and position of the Elements in this list.
181 *
182 * Setting the height or width properties will set the height or width
183 * property for all elements in the list. This returns a rectangle with the
184 * dimenions actually available for content
185 * in this element, in pixels, regardless of this element's box-sizing
186 * property. Getting the height or width returns the height or width of the
187 * first Element in this list.
188 *
189 * Unlike [getBoundingClientRect], the dimensions of this rectangle
190 * will return the same numerical height if the element is hidden or not.
191 */
192 @Experimental()
193 CssRect get contentEdge;
194
195 /**
196 * Access dimensions and position of the first Element's content + padding box
197 * in this list.
198 *
199 * This returns a rectangle with the dimenions actually available for content
200 * in this element, in pixels, regardless of this element's box-sizing
201 * property. Unlike [getBoundingClientRect], the dimensions of this rectangle
202 * will return the same numerical height if the element is hidden or not. This
203 * can be used to retrieve jQuery's `innerHeight` value for an element. This
204 * is also a rectangle equalling the dimensions of clientHeight and
205 * clientWidth.
206 */
207 @Experimental()
208 CssRect get paddingEdge;
209
210 /**
211 * Access dimensions and position of the first Element's content + padding +
212 * border box in this list.
213 *
214 * This returns a rectangle with the dimenions actually available for content
215 * in this element, in pixels, regardless of this element's box-sizing
216 * property. Unlike [getBoundingClientRect], the dimensions of this rectangle
217 * will return the same numerical height if the element is hidden or not. This
218 * can be used to retrieve jQuery's `outerHeight` value for an element.
219 */
220 @Experimental()
221 CssRect get borderEdge;
222
223 /**
224 * Access dimensions and position of the first Element's content + padding +
225 * border + margin box in this list.
226 *
227 * This returns a rectangle with the dimenions actually available for content
228 * in this element, in pixels, regardless of this element's box-sizing
229 * property. Unlike [getBoundingClientRect], the dimensions of this rectangle
230 * will return the same numerical height if the element is hidden or not. This
231 * can be used to retrieve jQuery's `outerHeight` value for an element.
232 */
233 @Experimental()
234 CssRect get marginEdge;
235 } 177 }
236 178
237 // TODO(jacobr): this is an inefficient implementation but it is hard to see 179 // TODO(jacobr): this is an inefficient implementation but it is hard to see
238 // a better option given that we cannot quite force NodeList to be an 180 // a better option given that we cannot quite force NodeList to be an
239 // ElementList as there are valid cases where a NodeList JavaScript object 181 // ElementList as there are valid cases where a NodeList JavaScript object
240 // contains Node objects that are not Elements. 182 // contains Node objects that are not Elements.
241 class _FrozenElementList<T extends Element> extends ListBase<T> implements Eleme ntList { 183 class _FrozenElementList<T extends Element> extends ListBase<T> implements Eleme ntList {
242 final List<Node> _nodeList; 184 final List<Node> _nodeList;
243 // The subset of _nodeList that are Elements.
244 List<Element> _elementList;
245 185
246 _FrozenElementList._wrap(this._nodeList) { 186 _FrozenElementList._wrap(this._nodeList);
247 _elementList = _nodeList.where((e) => e is Element).toList();
248 }
249 187
250 int get length => _nodeList.length; 188 int get length => _nodeList.length;
251 189
252 Element operator [](int index) => _nodeList[index]; 190 Element operator [](int index) => _nodeList[index];
253 191
254 void operator []=(int index, Element value) { 192 void operator []=(int index, Element value) {
255 throw new UnsupportedError('Cannot modify list'); 193 throw new UnsupportedError('Cannot modify list');
256 } 194 }
257 195
258 void set length(int newLength) { 196 void set length(int newLength) {
259 throw new UnsupportedError('Cannot modify list'); 197 throw new UnsupportedError('Cannot modify list');
260 } 198 }
261 199
262 void sort([Comparator<Element> compare]) { 200 void sort([Comparator<Element> compare]) {
263 throw new UnsupportedError('Cannot sort list'); 201 throw new UnsupportedError('Cannot sort list');
264 } 202 }
265 203
266 Element get first => _nodeList.first; 204 Element get first => _nodeList.first;
267 205
268 Element get last => _nodeList.last; 206 Element get last => _nodeList.last;
269 207
270 Element get single => _nodeList.single; 208 Element get single => _nodeList.single;
271 209
272 CssClassSet get classes => new _MultiElementCssClassSet(_elementList); 210 CssClassSet get classes => new _MultiElementCssClassSet(
211 _nodeList.where((e) => e is Element));
273 212
274 void set classes(Iterable<String> value) { 213 void set classes(Iterable<String> value) {
275 _elementList.forEach((e) => e.classes = value); 214 _nodeList.where((e) => e is Element).forEach((e) => e.classes = value);
276 } 215 }
277
278 CssRect get contentEdge => new _ContentCssListRect(_elementList);
279
280 CssRect get paddingEdge => _elementList.first.paddingEdge;
281
282 CssRect get borderEdge => _elementList.first.borderEdge;
283
284 CssRect get marginEdge => _elementList.first.marginEdge;
285 } 216 }
286 217
287 /** 218 /**
288 * An abstract class, which all HTML elements extend. 219 * An abstract class, which all HTML elements extend.
289 */ 220 */
290 $(ANNOTATIONS)abstract class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC { 221 $(ANNOTATIONS)abstract class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC {
291 222
292 /** 223 /**
293 * Creates an HTML element from a valid fragment of HTML. 224 * Creates an HTML element from a valid fragment of HTML.
294 * 225 *
(...skipping 691 matching lines...) Expand 10 before | Expand all | Expand 10 after
986 @Experimental() 917 @Experimental()
987 bool get isTemplate => tagName == 'TEMPLATE' || _isAttributeTemplate; 918 bool get isTemplate => tagName == 'TEMPLATE' || _isAttributeTemplate;
988 919
989 void _ensureTemplate() { 920 void _ensureTemplate() {
990 if (!isTemplate) { 921 if (!isTemplate) {
991 throw new UnsupportedError('$this is not a template.'); 922 throw new UnsupportedError('$this is not a template.');
992 } 923 }
993 TemplateElement.decorate(this); 924 TemplateElement.decorate(this);
994 } 925 }
995 926
996 /**
997 * Access this element's content position.
998 *
999 * This returns a rectangle with the dimenions actually available for content
1000 * in this element, in pixels, regardless of this element's box-sizing
1001 * property. Unlike [getBoundingClientRect], the dimensions of this rectangle
1002 * will return the same numerical height if the element is hidden or not.
1003 *
1004 * _Important_ _note_: use of this method _will_ perform CSS calculations that
1005 * can trigger a browser reflow. Therefore, use of this property _during_ an
1006 * animation frame is discouraged. See also:
1007 * [Browser Reflow](https://developers.google.com/speed/articles/reflow)
1008 */
1009 @Experimental()
1010 CssRect get contentEdge => new _ContentCssRect(this);
1011
1012 /**
1013 * Access the dimensions and position of this element's content + padding box.
1014 *
1015 * This returns a rectangle with the dimenions actually available for content
1016 * in this element, in pixels, regardless of this element's box-sizing
1017 * property. Unlike [getBoundingClientRect], the dimensions of this rectangle
1018 * will return the same numerical height if the element is hidden or not. This
1019 * can be used to retrieve jQuery's
1020 * [innerHeight](http://api.jquery.com/innerHeight/) value for an element.
1021 * This is also a rectangle equalling the dimensions of clientHeight and
1022 * clientWidth.
1023 *
1024 * _Important_ _note_: use of this method _will_ perform CSS calculations that
1025 * can trigger a browser reflow. Therefore, use of this property _during_ an
1026 * animation frame is discouraged. See also:
1027 * [Browser Reflow](https://developers.google.com/speed/articles/reflow)
1028 */
1029 @Experimental()
1030 CssRect get paddingEdge => new _PaddingCssRect(this);
1031
1032 /**
1033 * Access the dimensions and position of this element's content + padding +
1034 * border box.
1035 *
1036 * This returns a rectangle with the dimenions actually available for content
1037 * in this element, in pixels, regardless of this element's box-sizing
1038 * property. Unlike [getBoundingClientRect], the dimensions of this rectangle
1039 * will return the same numerical height if the element is hidden or not. This
1040 * can be used to retrieve jQuery's
1041 * [outerHeight](http://api.jquery.com/outerHeight/) value for an element.
1042 *
1043 * _Important_ _note_: use of this method _will_ perform CSS calculations that
1044 * can trigger a browser reflow. Therefore, use of this property _during_ an
1045 * animation frame is discouraged. See also:
1046 * [Browser Reflow](https://developers.google.com/speed/articles/reflow)
1047 */
1048 @Experimental()
1049 CssRect get borderEdge => new _BorderCssRect(this);
1050
1051 /**
1052 * Access the dimensions and position of this element's content + padding +
1053 * border + margin box.
1054 *
1055 * This returns a rectangle with the dimenions actually available for content
1056 * in this element, in pixels, regardless of this element's box-sizing
1057 * property. Unlike [getBoundingClientRect], the dimensions of this rectangle
1058 * will return the same numerical height if the element is hidden or not. This
1059 * can be used to retrieve jQuery's
1060 * [outerHeight](http://api.jquery.com/outerHeight/) value for an element.
1061 *
1062 * _Important_ _note_: use of this method will perform CSS calculations that
1063 * can trigger a browser reflow. Therefore, use of this property _during_ an
1064 * animation frame is discouraged. See also:
1065 * [Browser Reflow](https://developers.google.com/speed/articles/reflow)
1066 */
1067 @Experimental()
1068 CssRect get marginEdge => new _MarginCssRect(this);
1069 $!MEMBERS 927 $!MEMBERS
1070 } 928 }
1071 929
1072 930
1073 final _START_TAG_REGEXP = new RegExp('<(\\w+)'); 931 final _START_TAG_REGEXP = new RegExp('<(\\w+)');
1074 class _ElementFactoryProvider { 932 class _ElementFactoryProvider {
1075 static const _CUSTOM_PARENT_TAG_MAP = const { 933 static const _CUSTOM_PARENT_TAG_MAP = const {
1076 'body' : 'html', 934 'body' : 'html',
1077 'head' : 'html', 935 'head' : 'html',
1078 'caption' : 'table', 936 'caption' : 'table',
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
1206 const ScrollAlignment._internal(this._value); 1064 const ScrollAlignment._internal(this._value);
1207 toString() => 'ScrollAlignment.$_value'; 1065 toString() => 'ScrollAlignment.$_value';
1208 1066
1209 /// Attempt to align the element to the top of the scrollable area. 1067 /// Attempt to align the element to the top of the scrollable area.
1210 static const TOP = const ScrollAlignment._internal('TOP'); 1068 static const TOP = const ScrollAlignment._internal('TOP');
1211 /// Attempt to center the element in the scrollable area. 1069 /// Attempt to center the element in the scrollable area.
1212 static const CENTER = const ScrollAlignment._internal('CENTER'); 1070 static const CENTER = const ScrollAlignment._internal('CENTER');
1213 /// Attempt to align the element to the bottom of the scrollable area. 1071 /// Attempt to align the element to the bottom of the scrollable area.
1214 static const BOTTOM = const ScrollAlignment._internal('BOTTOM'); 1072 static const BOTTOM = const ScrollAlignment._internal('BOTTOM');
1215 } 1073 }
OLDNEW
« tools/dom/src/Rectangle.dart ('K') | « tools/dom/templates/html/dartium/html_dartium.darttemplate ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698