Chromium Code Reviews| Index: sdk/lib/html/dartium/html_dartium.dart |
| diff --git a/sdk/lib/html/dartium/html_dartium.dart b/sdk/lib/html/dartium/html_dartium.dart |
| index c5cd9207bf85cc3fc9dfb8171fd8cc1fce776b33..f110817795f2feb0a581aace3fc0fc003e8e74b3 100644 |
| --- a/sdk/lib/html/dartium/html_dartium.dart |
| +++ b/sdk/lib/html/dartium/html_dartium.dart |
| @@ -9727,6 +9727,40 @@ abstract class Element extends Node implements ElementTraversal { |
| */ |
| var xtag; |
| + /** |
| + * Scrolls this element into view. |
| + * |
| + * Only one of of the alignment options may be specified at a time. |
| + * |
| + * If no options are specified then this will attempt to scroll the minimum |
| + * amount needed to bring the element into view. |
| + * |
| + * Note that alignCenter is currently only supported on WebKit platforms. If |
| + * alignCenter is specified but not supported then this will fall back to |
| + * alignTop. |
| + * |
| + * See also: |
| + * |
| + * * [scrollIntoView](http://docs.webplatform.org/wiki/dom/methods/scrollIntoView) |
| + * * [scrollIntoViewIfNeeded](http://docs.webplatform.org/wiki/dom/methods/scrollIntoViewIfNeeded) |
| + */ |
| + void scrollIntoView([ScrollIntoViewAlignment alignment]) { |
|
Jacob
2013/02/13 21:08:19
Why not call ScrollIntoViewAlignment
just
Anchor
|
| + var hasScrollIntoViewIfNeeded = false; |
| + if (alignment == ScrollIntoViewAlignment.TOP) { |
| + this.$dom_scrollIntoView(true); |
| + } else if (alignment == ScrollIntoViewAlignment.BOTTOM) { |
| + this.$dom_scrollIntoView(false); |
| + } else if (hasScrollIntoViewIfNeeded) { |
| + if (alignment == ScrollIntoViewAlignment.CENTER) { |
| + this.$dom_scrollIntoViewIfNeeded(true); |
| + } else { |
| + this.$dom_scrollIntoViewIfNeeded(); |
| + } |
| + } else { |
| + this.$dom_scrollIntoView(); |
| + } |
| + } |
| + |
| Element.internal() : super.internal(); |
| @@ -10166,7 +10200,24 @@ abstract class Element extends Node implements ElementTraversal { |
| @DocsEditable |
| void scrollByPages(int pages) native "Element_scrollByPages_Callback"; |
| - void scrollIntoView([bool centerIfNeeded]) { |
| + void $dom_scrollIntoView([bool alignWithTop]) { |
| + if (?alignWithTop) { |
| + _scrollIntoView_1(alignWithTop); |
| + return; |
| + } |
| + _scrollIntoView_2(); |
| + return; |
| + } |
| + |
| + @DomName('Element._scrollIntoView_1') |
| + @DocsEditable |
| + void _scrollIntoView_1(alignWithTop) native "Element__scrollIntoView_1_Callback"; |
| + |
| + @DomName('Element._scrollIntoView_2') |
| + @DocsEditable |
| + void _scrollIntoView_2() native "Element__scrollIntoView_2_Callback"; |
| + |
| + void $dom_scrollIntoViewIfNeeded([bool centerIfNeeded]) { |
| if (?centerIfNeeded) { |
| _scrollIntoViewIfNeeded_1(centerIfNeeded); |
| return; |
| @@ -10552,6 +10603,23 @@ class _ElementFactoryProvider { |
| document.$dom_createElement(tag); |
| } |
| + |
| +/** |
| + * Options for Element.scrollIntoView. |
| + */ |
| +class ScrollIntoViewAlignment { |
| + final _value; |
| + const ScrollIntoViewAlignment._internal(this._value); |
| + toString() => 'ScrollIntoViewAlignment.$_value'; |
| + |
| + /// Attempt to align the element to the top of the scrollable area. |
| + static const TOP = const ScrollIntoViewAlignment._internal('TOP'); |
| + /// Attempt to center the element in the scrollable area. |
| + static const CENTER = const ScrollIntoViewAlignment._internal('CENTER'); |
| + /// Attempt to align the element to the bottom of the scrollable area. |
| + static const BOTTOM = const ScrollIntoViewAlignment._internal('BOTTOM'); |
| +} |
| + |
| @DocsEditable |
| @deprecated |
| class ElementEvents extends Events { |