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

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

Issue 10871088: Revert "Implementing polyfills for insertAdjacent* to get them working on FF." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Merging.wq Created 8 years, 3 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 // TODO(jacobr): use _Lists.dart to remove some of the duplicated 5 // TODO(jacobr): use _Lists.dart to remove some of the duplicated
6 // functionality. 6 // functionality.
7 class _ChildrenElementList implements ElementList { 7 class _ChildrenElementList implements ElementList {
8 // Raw Element. 8 // Raw Element.
9 final _ElementImpl _element; 9 final _ElementImpl _element;
10 final _HTMLCollectionImpl _childElements; 10 final _HTMLCollectionImpl _childElements;
(...skipping 606 matching lines...) Expand 10 before | Expand all | Expand 10 after
617 * All your element measurement needs in one place 617 * All your element measurement needs in one place
618 * @domName none 618 * @domName none
619 */ 619 */
620 class _ElementRectImpl implements ElementRect { 620 class _ElementRectImpl implements ElementRect {
621 final ClientRect client; 621 final ClientRect client;
622 final ClientRect offset; 622 final ClientRect offset;
623 final ClientRect scroll; 623 final ClientRect scroll;
624 624
625 // TODO(jacobr): should we move these outside of ElementRect to avoid the 625 // TODO(jacobr): should we move these outside of ElementRect to avoid the
626 // overhead of computing them every time even though they are rarely used. 626 // overhead of computing them every time even though they are rarely used.
627 final _ClientRectImpl _boundingClientRect; 627 final _ClientRectImpl _boundingClientRect;
628 final _ClientRectListImpl _clientRects; 628 final _ClientRectListImpl _clientRects;
629 629
630 _ElementRectImpl(_ElementImpl element) : 630 _ElementRectImpl(_ElementImpl element) :
631 client = new _SimpleClientRect(element.$dom_clientLeft, 631 client = new _SimpleClientRect(element.$dom_clientLeft,
632 element.$dom_clientTop, 632 element.$dom_clientTop,
633 element.$dom_clientWidth, 633 element.$dom_clientWidth,
634 element.$dom_clientHeight), 634 element.$dom_clientHeight),
635 offset = new _SimpleClientRect(element.$dom_offsetLeft, 635 offset = new _SimpleClientRect(element.$dom_offsetLeft,
636 element.$dom_offsetTop, 636 element.$dom_offsetTop,
637 element.$dom_offsetWidth, 637 element.$dom_offsetWidth,
638 element.$dom_offsetHeight), 638 element.$dom_offsetHeight),
639 scroll = new _SimpleClientRect(element.$dom_scrollLeft, 639 scroll = new _SimpleClientRect(element.$dom_scrollLeft,
640 element.$dom_scrollTop, 640 element.$dom_scrollTop,
641 element.$dom_scrollWidth, 641 element.$dom_scrollWidth,
642 element.$dom_scrollHeight), 642 element.$dom_scrollHeight),
643 _boundingClientRect = element.$dom_getBoundingClientRect(), 643 _boundingClientRect = element.$dom_getBoundingClientRect(),
644 _clientRects = element.$dom_getClientRects(); 644 _clientRects = element.$dom_getClientRects();
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
713 // TODO(jacobr): last param should be null, see b/5045788 713 // TODO(jacobr): last param should be null, see b/5045788
714 return getComputedStyle(''); 714 return getComputedStyle('');
715 } 715 }
716 716
717 Future<CSSStyleDeclaration> getComputedStyle(String pseudoElement) { 717 Future<CSSStyleDeclaration> getComputedStyle(String pseudoElement) {
718 return _createMeasurementFuture( 718 return _createMeasurementFuture(
719 () => _window.$dom_getComputedStyle(this, pseudoElement), 719 () => _window.$dom_getComputedStyle(this, pseudoElement),
720 new Completer<CSSStyleDeclaration>()); 720 new Completer<CSSStyleDeclaration>());
721 } 721 }
722 722
723 void addText(String text) {
724 this.insertAdjacentText('beforeend', text);
725 }
726
727 void addHTML(String text) {
728 this.insertAdjacentHTML('beforeend', text);
729 }
730
731 // Hooks to support custom WebComponents. 723 // Hooks to support custom WebComponents.
732 var xtag; 724 var xtag;
733 725
734 $if DARTIUM 726 $if DARTIUM
735 noSuchMethod(String name, List args) { 727 noSuchMethod(String name, List args) {
736 if (dynamicUnknownElementDispatcher == null) { 728 if (dynamicUnknownElementDispatcher == null) {
737 throw new NoSuchMethodException(this, name, args); 729 throw new NoSuchMethodException(this, name, args);
738 } else { 730 } else {
739 return dynamicUnknownElementDispatcher(this, name, args); 731 return dynamicUnknownElementDispatcher(this, name, args);
740 } 732 }
741 } 733 }
742 $else 734 $else
743 // TODO(vsm): Implement noSuchMethod or similar for dart2js. 735 // TODO(vsm): Implement noSuchMethod or similar for dart2js.
744 $endif 736 $endif
745 737
746 $if DART2JS
747 /** @domName Element.insertAdjacentText */
748 void insertAdjacentText(String where, String text) {
749 if (JS('bool', '!!this.insertAdjacentText')) {
750 _insertAdjacentText(where, text);
751 } else {
752 _insertAdjacentNode(where, new Text(text));
753 }
754 }
755
756 void _insertAdjacentText(String where, String text)
757 native 'insertAdjacentText';
758
759 /** @domName Element.insertAdjacentHTML */
760 void insertAdjacentHTML(String where, String text) {
761 if (JS('bool', '!!this.insertAdjacentHTML')) {
762 _insertAdjacentHTML(where, text);
763 } else {
764 _insertAdjacentNode(where, new DocumentFragment.html(text));
765 }
766 }
767
768 void _insertAdjacentHTML(String where, String text)
769 native 'insertAdjacentHTML';
770
771 /** @domName Element.insertAdjacentHTML */
772 Element insertAdjacentElement(String where, Element element) {
773 if (JS('bool', '!!this.insertAdjacentElement')) {
774 _insertAdjacentElement(where, element);
775 } else {
776 _insertAdjacentNode(where, element);
777 }
778 return element;
779 }
780
781 void _insertAdjacentElement(String where, Element element)
782 native 'insertAdjacentElement';
783
784 void _insertAdjacentNode(String where, Node node) {
785 switch (where.toLowerCase()) {
786 case 'beforebegin':
787 this.parent.insertBefore(node, this);
788 break;
789 case 'afterbegin':
790 this.insertBefore(node, this.nodes.first);
791 break;
792 case 'beforeend':
793 this.nodes.add(node);
794 break;
795 case 'afterend':
796 this.parent.insertBefore(node, this.nextNode);
797 break;
798 default:
799 throw new IllegalArgumentException("Invalid position ${where}");
800 }
801 }
802 $else
803 $endif
804
805 $!MEMBERS 738 $!MEMBERS
806 } 739 }
807 740
808 // Temporary dispatch hook to support WebComponents. 741 // Temporary dispatch hook to support WebComponents.
809 Function dynamicUnknownElementDispatcher; 742 Function dynamicUnknownElementDispatcher;
810 743
811 final _START_TAG_REGEXP = const RegExp('<(\\w+)'); 744 final _START_TAG_REGEXP = const RegExp('<(\\w+)');
812 class _ElementFactoryProvider { 745 class _ElementFactoryProvider {
813 static final _CUSTOM_PARENT_TAG_MAP = const { 746 static final _CUSTOM_PARENT_TAG_MAP = const {
814 'body' : 'html', 747 'body' : 'html',
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
862 795
863 /** @domName Document.createElement */ 796 /** @domName Document.createElement */
864 $if DART2JS 797 $if DART2JS
865 // Optimization to improve performance until the dart2js compiler inlines this 798 // Optimization to improve performance until the dart2js compiler inlines this
866 // method. 799 // method.
867 factory Element.tag(String tag) native "return document.createElement(tag)"; 800 factory Element.tag(String tag) native "return document.createElement(tag)";
868 $else 801 $else
869 factory Element.tag(String tag) => _document.$dom_createElement(tag); 802 factory Element.tag(String tag) => _document.$dom_createElement(tag);
870 $endif 803 $endif
871 } 804 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698