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

Unified Diff: client/dom/templates/html/frog/html_frog.darttemplate

Issue 9537001: Generate dart:html bindings for Dartium as well as Frog. All unittests now pass (or are disabled fo… (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 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 side-by-side diff with in-line comments
Download patch
Index: client/dom/templates/html/frog/html_frog.darttemplate
diff --git a/client/dom/templates/html/frog/html_frog.darttemplate b/client/dom/templates/html/frog/html_frog.darttemplate
index 65bafde89a17b5177d86bb12261cf0b509413c77..80aa6b287ccd27ca0388f92f0eb6234825c3c683 100644
--- a/client/dom/templates/html/frog/html_frog.darttemplate
+++ b/client/dom/templates/html/frog/html_frog.darttemplate
@@ -15,15 +15,50 @@ $!GENERATED_DART_FILES
#source('../dom/src/ReadyState.dart');
#source('../dom/src/TimeoutHandler.dart');
#source('../dom/src/_Collections.dart');
+#source('../html/src/Measurement.dart');
+#source('../html/src/shared_FactoryProviders.dart');
#source('../html/src/frog_FactoryProviders.dart');
+#source('../html/src/_Testing.dart');
#source('../html/src/Device.dart');
#source('../dom/src/_ListIterators.dart');
#source('../dom/src/_Lists.dart');
-// TODO(sra): What 'window' do we get in a worker? Perhaps this
-// should return the interface type.
-Window get window() native "return window;";
-_WindowJs get _window() native "return window;";
+_WindowImpl _cachedWindow;
+_DocumentImpl _cachedDocument;
-Document get document() native "return window.document.documentElement;";
-_DocumentJs get _document() native "return window.document.documentElement;";
+void _init() {
+ _cachedDocument = _document;
+ _cachedWindow = _window;
+ // Feature detect that dart:dom and dart:html are not both loaded by
+ // checking for the presence of a bug that manifests itself when both
+ // libraries are loaded.
+ // TODO(jacobr): remove this code once b/1911 is fixed and the frog compiler
+ // is changed to generate compile time errors if two libraries that define
+ // the same native types in conflicting ways are imported.
+ var element = new Element.tag('body');
+ element.innerHTML = 'f';
+ if (element.text == '') {
+ _cachedWindow.console.error(
+ 'Cannot import dart:html and dart:dom within the same application.');
+ throw new UnsupportedOperationException(
+ 'Cannot import dart:html and dart:dom within the same application.');
+ }
+}
+
+Window get window() {
+ if (_cachedWindow == null) {
+ _init();
+ }
+ return _cachedWindow;
+}
+
+_WindowImpl get _window() native "return window;";
+
+Document get document() {
+ if (_cachedDocument == null) {
+ _init();
+ }
+ return _cachedDocument;
+}
+
+_DocumentImpl get _document() native "return window.document.documentElement;";

Powered by Google App Engine
This is Rietveld 408576698