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

Side by Side Diff: tools/dom/src/html_native_DOMImplementation.dart

Issue 319283003: Refactor dart:_blink into classes to improve startup time (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rebase Created 6 years, 6 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 html; 5 part of html;
6 6
7 class _Property { 7 class _Property {
8 _Property(this.name) : 8 _Property(this.name) :
9 _hasValue = false, 9 _hasValue = false,
10 writable = false, 10 writable = false,
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 } 178 }
179 179
180 static Element getAndValidateNativeType(Type type, String tagName) { 180 static Element getAndValidateNativeType(Type type, String tagName) {
181 var element = new Element.tag(tagName); 181 var element = new Element.tag(tagName);
182 if (!isTypeSubclassOf(type, element.runtimeType)) { 182 if (!isTypeSubclassOf(type, element.runtimeType)) {
183 return null; 183 return null;
184 } 184 }
185 return element; 185 return element;
186 } 186 }
187 187
188 static window() => _blink.Native_Utils_window(); 188 static window() => _blink.Blink_Utils.window();
189 static forwardingPrint(String message) => _blink.Native_Utils_forwardingPrint( message); 189 static forwardingPrint(String message) => _blink.Blink_Utils.forwardingPrint(m essage);
190 // TODO(vsm): Make this API compatible with spawnUri. It should also 190 // TODO(vsm): Make this API compatible with spawnUri. It should also
191 // return a Future<Isolate>. 191 // return a Future<Isolate>.
192 static spawnDomUri(String uri) => _blink.Native_Utils_spawnDomUri(uri); 192 static spawnDomUri(String uri) => _blink.Blink_Utils.spawnDomUri(uri);
193 193
194 // The following methods were added for debugger integration to make working 194 // The following methods were added for debugger integration to make working
195 // with the Dart C mirrors API simpler. 195 // with the Dart C mirrors API simpler.
196 // TODO(jacobr): consider moving them to a separate library. 196 // TODO(jacobr): consider moving them to a separate library.
197 // If Dart supported dynamic code injection, we would only inject this code 197 // If Dart supported dynamic code injection, we would only inject this code
198 // when the debugger is invoked. 198 // when the debugger is invoked.
199 199
200 /** 200 /**
201 * Strips the private secret prefix from member names of the form 201 * Strips the private secret prefix from member names of the form
202 * someName@hash. 202 * someName@hash.
(...skipping 583 matching lines...) Expand 10 before | Expand all | Expand 10 after
786 if (nativeClass.reflectedType != HtmlElement) { 786 if (nativeClass.reflectedType != HtmlElement) {
787 throw new UnsupportedError('Class must provide extendsTag if base ' 787 throw new UnsupportedError('Class must provide extendsTag if base '
788 'native class is not HTMLElement'); 788 'native class is not HTMLElement');
789 } 789 }
790 } 790 }
791 791
792 _register(document, tag, type, extendsTagName); 792 _register(document, tag, type, extendsTagName);
793 } 793 }
794 794
795 static void _register(Document document, String tag, Type customType, 795 static void _register(Document document, String tag, Type customType,
796 String extendsTagName) => _blink.Native_Utils_register(document, tag, custom Type, extendsTagName); 796 String extendsTagName) => _blink.Blink_Utils.register(document, tag, customT ype, extendsTagName);
797 797
798 static Element createElement(Document document, String tagName) => 798 static Element createElement(Document document, String tagName) =>
799 _blink.Native_Utils_createElement(document, tagName); 799 _blink.Blink_Utils.createElement(document, tagName);
800 800
801 static void initializeCustomElement(HtmlElement element) => 801 static void initializeCustomElement(HtmlElement element) =>
802 _blink.Native_Utils_initializeCustomElement(element); 802 _blink.Blink_Utils.initializeCustomElement(element);
803 803
804 static Element changeElementWrapper(HtmlElement element, Type type) => 804 static Element changeElementWrapper(HtmlElement element, Type type) =>
805 _blink.Native_Utils_changeElementWrapper(element, type); 805 _blink.Blink_Utils.changeElementWrapper(element, type);
806 } 806 }
807 807
808 class _DOMWindowCrossFrame extends NativeFieldWrapperClass2 implements 808 class _DOMWindowCrossFrame extends NativeFieldWrapperClass2 implements
809 WindowBase { 809 WindowBase {
810 _DOMWindowCrossFrame.internal(); 810 _DOMWindowCrossFrame.internal();
811 811
812 // Fields. 812 // Fields.
813 HistoryBase get history => _blink.Native_DOMWindowCrossFrame_get_history(this) ; 813 HistoryBase get history => _blink.Blink_DOMWindowCrossFrame.get_history(this);
814 LocationBase get location => _blink.Native_DOMWindowCrossFrame_get_location(th is); 814 LocationBase get location => _blink.Blink_DOMWindowCrossFrame.get_location(thi s);
815 bool get closed => _blink.Native_DOMWindowCrossFrame_get_closed(this); 815 bool get closed => _blink.Blink_DOMWindowCrossFrame.get_closed(this);
816 WindowBase get opener => _blink.Native_DOMWindowCrossFrame_get_opener(this); 816 WindowBase get opener => _blink.Blink_DOMWindowCrossFrame.get_opener(this);
817 WindowBase get parent => _blink.Native_DOMWindowCrossFrame_get_parent(this); 817 WindowBase get parent => _blink.Blink_DOMWindowCrossFrame.get_parent(this);
818 WindowBase get top => _blink.Native_DOMWindowCrossFrame_get_top(this); 818 WindowBase get top => _blink.Blink_DOMWindowCrossFrame.get_top(this);
819 819
820 // Methods. 820 // Methods.
821 void close() => _blink.Native_DOMWindowCrossFrame_close(this); 821 void close() => _blink.Blink_DOMWindowCrossFrame.close(this);
822 void postMessage(/*SerializedScriptValue*/ message, String targetOrigin, [List messagePorts]) => 822 void postMessage(/*SerializedScriptValue*/ message, String targetOrigin, [List messagePorts]) =>
823 _blink.Native_DOMWindowCrossFrame_postMessage(this, message, targetOrigin, m essagePorts); 823 _blink.Blink_DOMWindowCrossFrame.postMessage(this, message, targetOrigin, me ssagePorts);
824 824
825 // Implementation support. 825 // Implementation support.
826 String get typeName => "Window"; 826 String get typeName => "Window";
827 827
828 // TODO(efortuna): Remove this method. dartbug.com/16814 828 // TODO(efortuna): Remove this method. dartbug.com/16814
829 Events get on => throw new UnsupportedError( 829 Events get on => throw new UnsupportedError(
830 'You can only attach EventListeners to your own window.'); 830 'You can only attach EventListeners to your own window.');
831 // TODO(efortuna): Remove this method. dartbug.com/16814 831 // TODO(efortuna): Remove this method. dartbug.com/16814
832 void addEventListener(String type, EventListener listener, [bool useCapture]) 832 void addEventListener(String type, EventListener listener, [bool useCapture])
833 => throw new UnsupportedError( 833 => throw new UnsupportedError(
834 'You can only attach EventListeners to your own window.'); 834 'You can only attach EventListeners to your own window.');
835 // TODO(efortuna): Remove this method. dartbug.com/16814 835 // TODO(efortuna): Remove this method. dartbug.com/16814
836 bool dispatchEvent(Event event) => throw new UnsupportedError( 836 bool dispatchEvent(Event event) => throw new UnsupportedError(
837 'You can only attach EventListeners to your own window.'); 837 'You can only attach EventListeners to your own window.');
838 // TODO(efortuna): Remove this method. dartbug.com/16814 838 // TODO(efortuna): Remove this method. dartbug.com/16814
839 void removeEventListener(String type, EventListener listener, 839 void removeEventListener(String type, EventListener listener,
840 [bool useCapture]) => throw new UnsupportedError( 840 [bool useCapture]) => throw new UnsupportedError(
841 'You can only attach EventListeners to your own window.'); 841 'You can only attach EventListeners to your own window.');
842 } 842 }
843 843
844 class _HistoryCrossFrame extends NativeFieldWrapperClass2 implements HistoryBase { 844 class _HistoryCrossFrame extends NativeFieldWrapperClass2 implements HistoryBase {
845 _HistoryCrossFrame.internal(); 845 _HistoryCrossFrame.internal();
846 846
847 // Methods. 847 // Methods.
848 void back() => _blink.Native_HistoryCrossFrame_back(this); 848 void back() => _blink.Blink_HistoryCrossFrame.back(this);
849 void forward() => _blink.Native_HistoryCrossFrame_forward(this); 849 void forward() => _blink.Blink_HistoryCrossFrame.forward(this);
850 void go(int distance) => _blink.Native_HistoryCrossFrame_go(this, distance); 850 void go(int distance) => _blink.Blink_HistoryCrossFrame.go(this, distance);
851 851
852 // Implementation support. 852 // Implementation support.
853 String get typeName => "History"; 853 String get typeName => "History";
854 } 854 }
855 855
856 class _LocationCrossFrame extends NativeFieldWrapperClass2 implements LocationBa se { 856 class _LocationCrossFrame extends NativeFieldWrapperClass2 implements LocationBa se {
857 _LocationCrossFrame.internal(); 857 _LocationCrossFrame.internal();
858 858
859 // Fields. 859 // Fields.
860 void set href(String h) => _blink.Native_LocationCrossFrame_set_href(this, h); 860 void set href(String h) => _blink.Blink_LocationCrossFrame.set_href(this, h);
861 861
862 // Implementation support. 862 // Implementation support.
863 String get typeName => "Location"; 863 String get typeName => "Location";
864 } 864 }
865 865
866 class _DOMStringMap extends NativeFieldWrapperClass2 implements Map<String, Stri ng> { 866 class _DOMStringMap extends NativeFieldWrapperClass2 implements Map<String, Stri ng> {
867 _DOMStringMap.internal(); 867 _DOMStringMap.internal();
868 868
869 bool containsValue(String value) => Maps.containsValue(this, value); 869 bool containsValue(String value) => Maps.containsValue(this, value);
870 bool containsKey(String key) => _blink.Native_DOMStringMap_containsKey(this, k ey); 870 bool containsKey(String key) => _blink.Blink_DOMStringMap.containsKey(this, ke y);
871 String operator [](String key) => _blink.Native_DOMStringMap_item(this, key); 871 String operator [](String key) => _blink.Blink_DOMStringMap.item(this, key);
872 void operator []=(String key, String value) => _blink.Native_DOMStringMap_setI tem(this, key, value); 872 void operator []=(String key, String value) => _blink.Blink_DOMStringMap.setIt em(this, key, value);
873 String putIfAbsent(String key, String ifAbsent()) => Maps.putIfAbsent(this, ke y, ifAbsent); 873 String putIfAbsent(String key, String ifAbsent()) => Maps.putIfAbsent(this, ke y, ifAbsent);
874 String remove(String key) => _blink.Native_DOMStringMap_remove(this, key); 874 String remove(String key) => _blink.Blink_DOMStringMap.remove(this, key);
875 void clear() => Maps.clear(this); 875 void clear() => Maps.clear(this);
876 void forEach(void f(String key, String value)) => Maps.forEach(this, f); 876 void forEach(void f(String key, String value)) => Maps.forEach(this, f);
877 Iterable<String> get keys => _blink.Native_DOMStringMap_get_keys(this); 877 Iterable<String> get keys => _blink.Blink_DOMStringMap.get_keys(this);
878 Iterable<String> get values => Maps.getValues(this); 878 Iterable<String> get values => Maps.getValues(this);
879 int get length => Maps.length(this); 879 int get length => Maps.length(this);
880 bool get isEmpty => Maps.isEmpty(this); 880 bool get isEmpty => Maps.isEmpty(this);
881 bool get isNotEmpty => Maps.isNotEmpty(this); 881 bool get isNotEmpty => Maps.isNotEmpty(this);
882 void addAll(Map<String, String> other) { 882 void addAll(Map<String, String> other) {
883 other.forEach((key, value) => this[key] = value); 883 other.forEach((key, value) => this[key] = value);
884 } 884 }
885 } 885 }
886 886
887 final _printClosure = (s) => window.console.log(s); 887 final _printClosure = (s) => window.console.log(s);
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
981 _scheduleImmediateHelper._schedule(callback); 981 _scheduleImmediateHelper._schedule(callback);
982 }; 982 };
983 983
984 get _pureIsolateScheduleImmediateClosure => ((void callback()) => 984 get _pureIsolateScheduleImmediateClosure => ((void callback()) =>
985 throw new UnimplementedError("scheduleMicrotask in background isolates " 985 throw new UnimplementedError("scheduleMicrotask in background isolates "
986 "are not supported in the browser")); 986 "are not supported in the browser"));
987 987
988 void _initializeCustomElement(Element e) { 988 void _initializeCustomElement(Element e) {
989 _Utils.initializeCustomElement(e); 989 _Utils.initializeCustomElement(e);
990 } 990 }
OLDNEW
« no previous file with comments | « tools/dom/src/blink_native_DOMImplementation.dart ('k') | tools/dom/templates/html/impl/impl_Element.darttemplate » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698