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 docOffset => offsetTo(document.documentElement); | |
|
Jennifer Messerly
2013/07/24 23:26:23
personally, I would call this "documentOffset". Th
Emily Fortuna
2013/07/25 00:20:07
Done.
| |
| 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 element | |
| 1111 * is _not_ an offset parent or transitive offset parent to this element, | |
| 1112 * an ArgumentError is thrown. | |
|
Jennifer Messerly
2013/07/24 23:26:23
could use code links for [ArgumentError] and [offs
Emily Fortuna
2013/07/25 00:20:07
Done.
| |
| 1113 */ | |
| 1114 Point offsetTo(Element parent) { | |
| 1115 return _offsetToHelper(this, | |
| 1116 parent, parent == this || parent.tagName == 'HTML'); | |
|
Jennifer Messerly
2013/07/24 23:26:23
can we remove this extra arg? suggestion below.
Jennifer Messerly
2013/07/24 23:26:23
use "identical(parent, this)"? one thing to watch
| |
| 1117 } | |
| 1118 | |
| 1119 Point _offsetToHelper(Element current, Element parent, bool foundAsParent) { | |
|
Jennifer Messerly
2013/07/24 23:26:23
can this be static?
Emily Fortuna
2013/07/25 00:20:07
Done.
| |
| 1120 if (current == null || current == parent) { | |
|
Jennifer Messerly
2013/07/24 23:26:23
can we remove "foundAsParent"? it seems to duplica
Emily Fortuna
2013/07/25 00:20:07
HTML discussed offline and added comment. and refa
| |
| 1121 return foundAsParent? new Point(0, 0) : throw new ArgumentError( | |
|
Jennifer Messerly
2013/07/24 23:26:23
this might be cleaner as:
if (foundAsParent) retu
Emily Fortuna
2013/07/25 00:20:07
Done.
| |
| 1122 "Specified element is not a transitive offset parent of this " | |
| 1123 "element."); | |
| 1124 } | |
| 1125 Element parentOffset = current.offsetParent; | |
| 1126 Point p = _offsetToHelper( | |
| 1127 parentOffset, parent, foundAsParent || parentOffset == parent); | |
| 1128 return new Point(p.x + current.offsetLeft, p.y + current.offsetTop); | |
| 1129 } | |
| 1093 $!MEMBERS | 1130 $!MEMBERS |
| 1094 } | 1131 } |
| 1095 | 1132 |
| 1096 | 1133 |
| 1097 final _START_TAG_REGEXP = new RegExp('<(\\w+)'); | 1134 final _START_TAG_REGEXP = new RegExp('<(\\w+)'); |
| 1098 class _ElementFactoryProvider { | 1135 class _ElementFactoryProvider { |
| 1099 static const _CUSTOM_PARENT_TAG_MAP = const { | 1136 static const _CUSTOM_PARENT_TAG_MAP = const { |
| 1100 'body' : 'html', | 1137 'body' : 'html', |
| 1101 'head' : 'html', | 1138 'head' : 'html', |
| 1102 'caption' : 'table', | 1139 'caption' : 'table', |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1230 const ScrollAlignment._internal(this._value); | 1267 const ScrollAlignment._internal(this._value); |
| 1231 toString() => 'ScrollAlignment.$_value'; | 1268 toString() => 'ScrollAlignment.$_value'; |
| 1232 | 1269 |
| 1233 /// Attempt to align the element to the top of the scrollable area. | 1270 /// Attempt to align the element to the top of the scrollable area. |
| 1234 static const TOP = const ScrollAlignment._internal('TOP'); | 1271 static const TOP = const ScrollAlignment._internal('TOP'); |
| 1235 /// Attempt to center the element in the scrollable area. | 1272 /// Attempt to center the element in the scrollable area. |
| 1236 static const CENTER = const ScrollAlignment._internal('CENTER'); | 1273 static const CENTER = const ScrollAlignment._internal('CENTER'); |
| 1237 /// Attempt to align the element to the bottom of the scrollable area. | 1274 /// Attempt to align the element to the bottom of the scrollable area. |
| 1238 static const BOTTOM = const ScrollAlignment._internal('BOTTOM'); | 1275 static const BOTTOM = const ScrollAlignment._internal('BOTTOM'); |
| 1239 } | 1276 } |
| OLD | NEW |