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

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

Issue 12226129: Updating Element.scrollIntoView to be platform independent. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 10 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
« no previous file with comments | « tools/dom/scripts/htmlrenamer.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 // TODO(jacobr): use _Lists.dart to remove some of the duplicated 7 // TODO(jacobr): use _Lists.dart to remove some of the duplicated
8 // functionality. 8 // functionality.
9 class _ChildrenElementList implements List { 9 class _ChildrenElementList implements List {
10 // Raw Element. 10 // Raw Element.
(...skipping 751 matching lines...) Expand 10 before | Expand all | Expand 10 after
762 * deprecated and will simply return this [Element] object. 762 * deprecated and will simply return this [Element] object.
763 * 763 *
764 * [wc]: http://dvcs.w3.org/hg/webcomponents/raw-file/tip/explainer/index.html 764 * [wc]: http://dvcs.w3.org/hg/webcomponents/raw-file/tip/explainer/index.html
765 * [x-tags]: http://x-tags.org/ 765 * [x-tags]: http://x-tags.org/
766 */ 766 */
767 $if DART2JS 767 $if DART2JS
768 @Creates('Null') // Set from Dart code; does not instantiate a native type. 768 @Creates('Null') // Set from Dart code; does not instantiate a native type.
769 $endif 769 $endif
770 var xtag; 770 var xtag;
771 771
772 /**
773 * Scrolls this element into view.
774 *
775 * Only one of of the alignment options may be specified at a time.
776 *
777 * If no options are specified then this will attempt to scroll the minimum
778 * amount needed to bring the element into view.
779 *
780 * Note that alignCenter is currently only supported on WebKit platforms. If
781 * alignCenter is specified but not supported then this will fall back to
782 * alignTop.
783 *
784 * See also:
785 *
786 * * [scrollIntoView](http://docs.webplatform.org/wiki/dom/methods/scrollIntoV iew)
787 * * [scrollIntoViewIfNeeded](http://docs.webplatform.org/wiki/dom/methods/scr ollIntoViewIfNeeded)
788 */
789 void scrollIntoView({bool alignCenter, bool alignTop, bool alignBottom}) {
Jacob 2013/02/12 23:12:33 shouldn't this be an enum instead of 3 bools?
790 var paramCount = (alignCenter != null ? 1 : 0) +
791 (alignTop != null ? 1 : 0) + (alignBottom != null ? 1 : 0);
792 if (paramCount > 1) {
793 throw new ArgumentError(
794 'Can only specify one of alignCenter, alignTop, alignBottom');
795 }
796 var scrollIntoViewIfNeeded = false;
797 $if DART2JS
798 scrollIntoViewIfNeeded = JS('bool', '!!(#.scrollIntoViewIfNeeded)', this);
799 $endif
800 if (alignTop != null) {
801 this.$dom_scrollIntoView(alignTop);
802 } else if (alignBottom != null) {
803 this.$dom_scrollIntoView(alignBottom);
804 } else if (scrollIntoViewIfNeeded) {
805 if (alignCenter != null) {
806 this.$dom_scrollIntoViewIfNeeded(alignCenter);
807 } else {
808 this.$dom_scrollIntoViewIfNeeded();
809 }
810 } else {
811 this.$dom_scrollIntoView();
812 }
813 }
814
772 $if DART2JS 815 $if DART2JS
773 @DomName('Element.mouseWheelEvent') 816 @DomName('Element.mouseWheelEvent')
774 static const EventStreamProvider<WheelEvent> mouseWheelEvent = 817 static const EventStreamProvider<WheelEvent> mouseWheelEvent =
775 const _CustomEventStreamProvider<WheelEvent>( 818 const _CustomEventStreamProvider<WheelEvent>(
776 Element._determineMouseWheelEventType); 819 Element._determineMouseWheelEventType);
777 820
778 static String _determineMouseWheelEventType(EventTarget e) { 821 static String _determineMouseWheelEventType(EventTarget e) {
779 if (JS('bool', '#.onwheel !== undefined', e)) { 822 if (JS('bool', '#.onwheel !== undefined', e)) {
780 // W3C spec, and should be IE9+, but IE has a bug exposing onwheel. 823 // W3C spec, and should be IE9+, but IE has a bug exposing onwheel.
781 return 'wheel'; 824 return 'wheel';
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
1051 // Optimization to improve performance until the dart2js compiler inlines this 1094 // Optimization to improve performance until the dart2js compiler inlines this
1052 // method. 1095 // method.
1053 static dynamic createElement_tag(String tag) => 1096 static dynamic createElement_tag(String tag) =>
1054 // Firefox may return a JS function for some types (Embed, Object). 1097 // Firefox may return a JS function for some types (Embed, Object).
1055 JS('Element|=Object', 'document.createElement(#)', tag); 1098 JS('Element|=Object', 'document.createElement(#)', tag);
1056 $else 1099 $else
1057 static Element createElement_tag(String tag) => 1100 static Element createElement_tag(String tag) =>
1058 document.$dom_createElement(tag); 1101 document.$dom_createElement(tag);
1059 $endif 1102 $endif
1060 } 1103 }
OLDNEW
« no previous file with comments | « tools/dom/scripts/htmlrenamer.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698