Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 1072 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1083 * can be used to retrieve jQuery's | 1083 * can be used to retrieve jQuery's |
| 1084 * [outerHeight](http://api.jquery.com/outerHeight/) value for an element. | 1084 * [outerHeight](http://api.jquery.com/outerHeight/) value for an element. |
| 1085 * | 1085 * |
| 1086 * _Important_ _note_: use of this method will perform CSS calculations that | 1086 * _Important_ _note_: use of this method will perform CSS calculations that |
| 1087 * can trigger a browser reflow. Therefore, use of this property _during_ an | 1087 * can trigger a browser reflow. Therefore, use of this property _during_ an |
| 1088 * animation frame is discouraged. See also: | 1088 * animation frame is discouraged. See also: |
| 1089 * [Browser Reflow](https://developers.google.com/speed/articles/reflow) | 1089 * [Browser Reflow](https://developers.google.com/speed/articles/reflow) |
| 1090 */ | 1090 */ |
| 1091 @Experimental() | 1091 @Experimental() |
| 1092 CssRect get marginEdge => new _MarginCssRect(this); | 1092 CssRect get marginEdge => new _MarginCssRect(this); |
| 1093 | |
| 1094 /** | |
| 1095 * Provides the coordinates of the element relative to the top of the | |
| 1096 * document. | |
| 1097 * | |
| 1098 * This method is the Dart equivalent to jQuery's | |
| 1099 * [offset](http://api.jquery.com/offset/) method. | |
| 1100 */ | |
| 1101 Point get documentOffset => offsetTo(document.documentElement); | |
|
blois
2013/07/27 00:00:56
What's the difference between rolling the offsets
| |
| 1102 | |
| 1103 /** | |
| 1104 * Provides the offset of this element's [borderEdge] relative to the | |
| 1105 * specified [parent]. | |
| 1106 * | |
| 1107 * This is the Dart equivalent of jQuery's | |
| 1108 * [position](http://api.jquery.com/position/) method. Unlike jQuery's | |
| 1109 * position, however, [parent] can be any parent element of `this`, | |
| 1110 * rather than only `this`'s immediate [offsetParent]. If the specified | |
| 1111 * element is _not_ an offset parent or transitive offset parent to this | |
| 1112 * element, an [ArgumentError] is thrown. | |
| 1113 */ | |
| 1114 Point offsetTo(Element parent) { | |
| 1115 return Element._offsetToHelper(this, parent); | |
|
blois
2013/07/27 00:00:56
Why not just:
return new Point(documentOffset.x -
| |
| 1116 } | |
| 1117 | |
| 1118 static Point _offsetToHelper(Element current, Element parent) { | |
| 1119 // We're hopping from _offsetParent_ to offsetParent (not just parent), so | |
| 1120 // offsetParent, "tops out" at BODY. But people could conceivably pass in | |
| 1121 // the document.documentElement and I want it to return an absolute offset, | |
| 1122 // so we have the special case checking for HTML. | |
| 1123 bool foundAsParent = identical(current, parent) || parent.tagName == 'HTML'; | |
| 1124 if (current == null || identical(current, parent)) { | |
| 1125 if (foundAsParent) return new Point(0, 0); | |
| 1126 throw new ArgumentError("Specified element is not a transitive offset " | |
| 1127 "parent of this element."); | |
| 1128 } | |
| 1129 Element parentOffset = current.offsetParent; | |
| 1130 Point p = Element._offsetToHelper(parentOffset, parent); | |
| 1131 return new Point(p.x + current.offsetLeft, p.y + current.offsetTop); | |
| 1132 } | |
| 1093 $!MEMBERS | 1133 $!MEMBERS |
| 1094 } | 1134 } |
| 1095 | 1135 |
| 1096 | 1136 |
| 1097 final _START_TAG_REGEXP = new RegExp('<(\\w+)'); | 1137 final _START_TAG_REGEXP = new RegExp('<(\\w+)'); |
| 1098 class _ElementFactoryProvider { | 1138 class _ElementFactoryProvider { |
| 1099 static const _CUSTOM_PARENT_TAG_MAP = const { | 1139 static const _CUSTOM_PARENT_TAG_MAP = const { |
| 1100 'body' : 'html', | 1140 'body' : 'html', |
| 1101 'head' : 'html', | 1141 'head' : 'html', |
| 1102 'caption' : 'table', | 1142 'caption' : 'table', |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1230 const ScrollAlignment._internal(this._value); | 1270 const ScrollAlignment._internal(this._value); |
| 1231 toString() => 'ScrollAlignment.$_value'; | 1271 toString() => 'ScrollAlignment.$_value'; |
| 1232 | 1272 |
| 1233 /// Attempt to align the element to the top of the scrollable area. | 1273 /// Attempt to align the element to the top of the scrollable area. |
| 1234 static const TOP = const ScrollAlignment._internal('TOP'); | 1274 static const TOP = const ScrollAlignment._internal('TOP'); |
| 1235 /// Attempt to center the element in the scrollable area. | 1275 /// Attempt to center the element in the scrollable area. |
| 1236 static const CENTER = const ScrollAlignment._internal('CENTER'); | 1276 static const CENTER = const ScrollAlignment._internal('CENTER'); |
| 1237 /// Attempt to align the element to the bottom of the scrollable area. | 1277 /// Attempt to align the element to the bottom of the scrollable area. |
| 1238 static const BOTTOM = const ScrollAlignment._internal('BOTTOM'); | 1278 static const BOTTOM = const ScrollAlignment._internal('BOTTOM'); |
| 1239 } | 1279 } |
| OLD | NEW |