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

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

Issue 18182010: Make html metadata follow the spec. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fixed DocsEditable, Experimental, Unstable Created 7 years, 5 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 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 564 matching lines...) Expand 10 before | Expand all | Expand 10 after
575 * The tag should be a valid HTML tag name. 575 * The tag should be a valid HTML tag name.
576 */ 576 */
577 static bool isTagSupported(String tag) { 577 static bool isTagSupported(String tag) {
578 var e = _ElementFactoryProvider.createElement_tag(tag); 578 var e = _ElementFactoryProvider.createElement_tag(tag);
579 return e is Element && !(e is UnknownElement); 579 return e is Element && !(e is UnknownElement);
580 } 580 }
581 581
582 /** 582 /**
583 * Called by the DOM when this element has been instantiated. 583 * Called by the DOM when this element has been instantiated.
584 */ 584 */
585 @Experimental 585 @Experimental()
586 void onCreated() {} 586 void onCreated() {}
587 587
588 // Hooks to support custom WebComponents. 588 // Hooks to support custom WebComponents.
589 589
590 $if DART2JS 590 $if DART2JS
591 @Creates('Null') // Set from Dart code; does not instantiate a native type. 591 @Creates('Null') // Set from Dart code; does not instantiate a native type.
592 $endif 592 $endif
593 Element _xtag; 593 Element _xtag;
594 594
595 /** 595 /**
(...skipping 10 matching lines...) Expand all
606 */ 606 */
607 // Note: return type is `dynamic` for convenience to suppress warnings when 607 // Note: return type is `dynamic` for convenience to suppress warnings when
608 // members of the component are used. The actual type is a subtype of Element. 608 // members of the component are used. The actual type is a subtype of Element.
609 get xtag => _xtag != null ? _xtag : this; 609 get xtag => _xtag != null ? _xtag : this;
610 610
611 void set xtag(Element value) { 611 void set xtag(Element value) {
612 _xtag = value; 612 _xtag = value;
613 } 613 }
614 614
615 @DomName('Element.localName') 615 @DomName('Element.localName')
616 @DocsEditable 616 @DocsEditable()
617 String get localName => $dom_localName; 617 String get localName => $dom_localName;
618 618
619 @DomName('Element.namespaceUri') 619 @DomName('Element.namespaceUri')
620 @DocsEditable 620 @DocsEditable()
621 String get namespaceUri => $dom_namespaceUri; 621 String get namespaceUri => $dom_namespaceUri;
622 622
623 String toString() => localName; 623 String toString() => localName;
624 624
625 /** 625 /**
626 * Scrolls this element into view. 626 * Scrolls this element into view.
627 * 627 *
628 * Only one of of the alignment options may be specified at a time. 628 * Only one of of the alignment options may be specified at a time.
629 * 629 *
630 * If no options are specified then this will attempt to scroll the minimum 630 * If no options are specified then this will attempt to scroll the minimum
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
785 this.parentNode.insertBefore(node, this.nextNode); 785 this.parentNode.insertBefore(node, this.nextNode);
786 break; 786 break;
787 default: 787 default:
788 throw new ArgumentError("Invalid position ${where}"); 788 throw new ArgumentError("Invalid position ${where}");
789 } 789 }
790 } 790 }
791 791
792 /** 792 /**
793 * Checks if this element matches the CSS selectors. 793 * Checks if this element matches the CSS selectors.
794 */ 794 */
795 @Experimental 795 @Experimental()
796 bool matches(String selectors) { 796 bool matches(String selectors) {
797 if (JS('bool', '!!#.matches', this)) { 797 if (JS('bool', '!!#.matches', this)) {
798 return JS('bool', '#.matches(#)', this, selectors); 798 return JS('bool', '#.matches(#)', this, selectors);
799 } else if (JS('bool', '!!#.webkitMatchesSelector', this)) { 799 } else if (JS('bool', '!!#.webkitMatchesSelector', this)) {
800 return JS('bool', '#.webkitMatchesSelector(#)', this, selectors); 800 return JS('bool', '#.webkitMatchesSelector(#)', this, selectors);
801 } else if (JS('bool', '!!#.mozMatchesSelector', this)) { 801 } else if (JS('bool', '!!#.mozMatchesSelector', this)) {
802 return JS('bool', '#.mozMatchesSelector(#)', this, selectors); 802 return JS('bool', '#.mozMatchesSelector(#)', this, selectors);
803 } else if (JS('bool', '!!#.msMatchesSelector', this)) { 803 } else if (JS('bool', '!!#.msMatchesSelector', this)) {
804 return JS('bool', '#.msMatchesSelector(#)', this, selectors); 804 return JS('bool', '#.msMatchesSelector(#)', this, selectors);
805 } 805 }
(...skipping 13 matching lines...) Expand all
819 $endif 819 $endif
820 DocumentFragment _templateContent; 820 DocumentFragment _templateContent;
821 821
822 bool _templateIsDecorated; 822 bool _templateIsDecorated;
823 823
824 824
825 /** 825 /**
826 * Gets the template this node refers to. 826 * Gets the template this node refers to.
827 * This is only supported if [isTemplate] is true. 827 * This is only supported if [isTemplate] is true.
828 */ 828 */
829 @Experimental 829 @Experimental()
830 Element get ref { 830 Element get ref {
831 _ensureTemplate(); 831 _ensureTemplate();
832 832
833 Element ref = null; 833 Element ref = null;
834 var refId = attributes['ref']; 834 var refId = attributes['ref'];
835 if (refId != null) { 835 if (refId != null) {
836 var treeScope = this; 836 var treeScope = this;
837 while (treeScope.parentNode != null) { 837 while (treeScope.parentNode != null) {
838 treeScope = treeScope.parentNode; 838 treeScope = treeScope.parentNode;
839 } 839 }
840 840
841 // Note: JS code tests that getElementById is present. We can't do that 841 // Note: JS code tests that getElementById is present. We can't do that
842 // easily, so instead check for the types known to implement it. 842 // easily, so instead check for the types known to implement it.
843 if (treeScope is Document || 843 if (treeScope is Document ||
844 treeScope is ShadowRoot || 844 treeScope is ShadowRoot ||
845 treeScope is svg.SvgSvgElement) { 845 treeScope is svg.SvgSvgElement) {
846 846
847 ref = treeScope.getElementById(refId); 847 ref = treeScope.getElementById(refId);
848 } 848 }
849 } 849 }
850 850
851 return ref != null ? ref : _templateInstanceRef; 851 return ref != null ? ref : _templateInstanceRef;
852 } 852 }
853 853
854 /** 854 /**
855 * Gets the content of this template. 855 * Gets the content of this template.
856 * This is only supported if [isTemplate] is true. 856 * This is only supported if [isTemplate] is true.
857 */ 857 */
858 @Experimental 858 @Experimental()
859 DocumentFragment get content { 859 DocumentFragment get content {
860 _ensureTemplate(); 860 _ensureTemplate();
861 return _templateContent; 861 return _templateContent;
862 } 862 }
863 863
864 /** 864 /**
865 * Creates an instance of the template. 865 * Creates an instance of the template.
866 * This is only supported if [isTemplate] is true. 866 * This is only supported if [isTemplate] is true.
867 */ 867 */
868 @Experimental 868 @Experimental()
869 DocumentFragment createInstance() { 869 DocumentFragment createInstance() {
870 _ensureTemplate(); 870 _ensureTemplate();
871 return TemplateElement.mdvPackage(this).createInstance(); 871 return TemplateElement.mdvPackage(this).createInstance();
872 } 872 }
873 873
874 /** 874 /**
875 * The data model which is inherited through the tree. 875 * The data model which is inherited through the tree.
876 * This is only supported if [isTemplate] is true. 876 * This is only supported if [isTemplate] is true.
877 */ 877 */
878 @Experimental 878 @Experimental()
879 get model => TemplateElement.mdvPackage(this).model; 879 get model => TemplateElement.mdvPackage(this).model;
880 880
881 @Experimental 881 @Experimental()
882 void set model(value) { 882 void set model(value) {
883 _ensureTemplate(); 883 _ensureTemplate();
884 TemplateElement.mdvPackage(this).model = value; 884 TemplateElement.mdvPackage(this).model = value;
885 } 885 }
886 886
887 // TODO(jmesserly): const set would be better 887 // TODO(jmesserly): const set would be better
888 static const _TABLE_TAGS = const { 888 static const _TABLE_TAGS = const {
889 'caption': null, 889 'caption': null,
890 'col': null, 890 'col': null,
891 'colgroup': null, 891 'colgroup': null,
(...skipping 15 matching lines...) Expand all
907 * A node is a template if [tagName] is TEMPLATE, or the node has the 907 * A node is a template if [tagName] is TEMPLATE, or the node has the
908 * 'template' attribute and this tag supports attribute form for backwards 908 * 'template' attribute and this tag supports attribute form for backwards
909 * compatibility with existing HTML parsers. The nodes that can use attribute 909 * compatibility with existing HTML parsers. The nodes that can use attribute
910 * form are table elments (THEAD, TBODY, TFOOT, TH, TR, TD, CAPTION, COLGROUP 910 * form are table elments (THEAD, TBODY, TFOOT, TH, TR, TD, CAPTION, COLGROUP
911 * and COL), OPTION, and OPTGROUP. 911 * and COL), OPTION, and OPTGROUP.
912 */ 912 */
913 // TODO(jmesserly): this is not a public MDV API, but it seems like a useful 913 // TODO(jmesserly): this is not a public MDV API, but it seems like a useful
914 // place to document which tags our polyfill considers to be templates. 914 // place to document which tags our polyfill considers to be templates.
915 // Otherwise I'd be repeating it in several other places. 915 // Otherwise I'd be repeating it in several other places.
916 // See if we can replace this with a TemplateMixin. 916 // See if we can replace this with a TemplateMixin.
917 @Experimental 917 @Experimental()
918 bool get isTemplate => tagName == 'TEMPLATE' || _isAttributeTemplate; 918 bool get isTemplate => tagName == 'TEMPLATE' || _isAttributeTemplate;
919 919
920 void _ensureTemplate() { 920 void _ensureTemplate() {
921 if (!isTemplate) { 921 if (!isTemplate) {
922 throw new UnsupportedError('$this is not a template.'); 922 throw new UnsupportedError('$this is not a template.');
923 } 923 }
924 TemplateElement.decorate(this); 924 TemplateElement.decorate(this);
925 } 925 }
926 926
927 $!MEMBERS 927 $!MEMBERS
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
1064 const ScrollAlignment._internal(this._value); 1064 const ScrollAlignment._internal(this._value);
1065 toString() => 'ScrollAlignment.$_value'; 1065 toString() => 'ScrollAlignment.$_value';
1066 1066
1067 /// Attempt to align the element to the top of the scrollable area. 1067 /// Attempt to align the element to the top of the scrollable area.
1068 static const TOP = const ScrollAlignment._internal('TOP'); 1068 static const TOP = const ScrollAlignment._internal('TOP');
1069 /// Attempt to center the element in the scrollable area. 1069 /// Attempt to center the element in the scrollable area.
1070 static const CENTER = const ScrollAlignment._internal('CENTER'); 1070 static const CENTER = const ScrollAlignment._internal('CENTER');
1071 /// Attempt to align the element to the bottom of the scrollable area. 1071 /// Attempt to align the element to the bottom of the scrollable area.
1072 static const BOTTOM = const ScrollAlignment._internal('BOTTOM'); 1072 static const BOTTOM = const ScrollAlignment._internal('BOTTOM');
1073 } 1073 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698