Revision: 10156
Author: gwt.mirror...@gmail.com
Date: Fri May 6 11:12:40 2011
Log: Add an option that helps teams that rely on the body being loaded
in onModuleLoade
Review by: zun...@google.com
http://code.google.com/p/google-web-toolkit/source/detail?r=10156
Added:
/trunk/dev/core/src/com/google/gwt/core/ext/linker/impl/isBodyLoaded.js
/trunk/dev/core/src/com/google/gwt/core/ext/linker/impl/isBodyLoadedFF35Fix.js
Modified:
/trunk/dev/core/src/com/google/gwt/core/ext/linker/impl/waitForBodyLoaded.js
/trunk/dev/core/src/com/google/gwt/core/linker/CrossSiteIframeLinker.java
/trunk/dev/core/src/com/google/gwt/core/linker/CrossSiteIframeTemplate.js
=======================================
--- /dev/null
+++ /trunk/dev/core/src/com/google/gwt/core/ext/linker/impl/isBodyLoaded.js
Fri May 6 11:12:40 2011
@@ -0,0 +1,12 @@
+function isBodyLoaded() {
+ if (typeof $doc.readyState == "undefined") {
+ // FF 3.5 and below does not have readyState, but it does allow us to
+ // append to the body before it has finished loading, so we return
whether
+ // the body element exists. Note that for very few apps, this may cause
+ // problems because they do something in onModuleLoad that assumes the
body
+ // is loaded. For those apps, we provide an alternative implementation
+ // in isBodyLoadedFf35Fix.js
+ return (typeof $doc.body != "undefined" && $doc.body != null);
+ }
+ return (/loaded|complete/.test($doc.readyState));
+}
=======================================
--- /dev/null
+++
/trunk/dev/core/src/com/google/gwt/core/ext/linker/impl/isBodyLoadedFF35Fix.js
Fri May 6 11:12:40 2011
@@ -0,0 +1,16 @@
+function isBodyLoaded() {
+ if (typeof $doc.readyState == "undefined") {
+ // FF 3.5 and below does not have readyState, so this implementation
takes
+ // a conservative approach and returns false, forcing us to wait for
the
+ // DOMContentLoaded event. Note that this will not work for Late
Loading
+ // apps (since that event has already fired at GWT bootstrap time, so
we
+ // will wait/hang forever). However, this approach is an option for
non
+ // Late Loaded apps that are seeing problems in FF3.5 because they
need the
+ // body to be loaded before onModuleLoad() is called. Note that GWT
+ // bootstrap works fine with the standard apporoach in
waitForBodyLoaded.js
+ // this is just a fix for apps that do things in onModuleLoad that
assume
+ // the body is loaded.
+ return false;
+ }
+ return (/loaded|complete/.test($doc.readyState));
+}
=======================================
---
/trunk/dev/core/src/com/google/gwt/core/ext/linker/impl/waitForBodyLoaded.js
Wed Oct 27 13:37:45 2010
+++
/trunk/dev/core/src/com/google/gwt/core/ext/linker/impl/waitForBodyLoaded.js
Fri May 6 08:06:47 2011
@@ -1,6 +1,9 @@
// Setup code which waits for the body to be loaded and then calls the
// callback function
function setupWaitForBodyLoad(callback) {
+ // Provides the isBodyLoaded() function
+ __IS_BODY_LOADED__
+
var bodyDone = false;
if (isBodyLoaded()) {
=======================================
---
/trunk/dev/core/src/com/google/gwt/core/linker/CrossSiteIframeLinker.java
Tue Apr 26 08:02:24 2011
+++
/trunk/dev/core/src/com/google/gwt/core/linker/CrossSiteIframeLinker.java
Fri May 6 08:06:47 2011
@@ -69,7 +69,10 @@
// Must do installScript before installLocation and waitForBodyLoaded
includeJs(ss, logger,
getJsInstallScript(context), "__INSTALL_SCRIPT__");
includeJs(ss, logger,
getJsInstallLocation(context), "__INSTALL_LOCATION__");
+
+ // Must do waitForBodyLoaded before isBodyLoaded
includeJs(ss, logger,
getJsWaitForBodyLoaded(context), "__WAIT_FOR_BODY_LOADED__");
+ includeJs(ss, logger,
getJsIsBodyLoaded(context), "__IS_BODY_LOADED__");
// Must do permutations before providers
includeJs(ss, logger, getJsPermutations(context), "__PERMUTATIONS__");
@@ -187,6 +190,16 @@
protected String getJsInstallScript(LinkerContext context) {
return "com/google/gwt/core/ext/linker/impl/installScriptEarlyDownload.js";
}
+
+ /**
+ * Returns the name of the {@code JsIsBodyLoaded} script. By default,
+ * returns {@code "com/google/gwt/core/ext/linker/impl/isBodyLoaded.js"}.
+ *
+ * @param context a LinkerContext
+ */
+ protected String getJsIsBodyLoaded(LinkerContext context) {
+ return "com/google/gwt/core/ext/linker/impl/isBodyLoaded.js";
+ }
/**
* Returns the name of the {@code JsLoadExternalStylesheets} script. By
default,
=======================================
---
/trunk/dev/core/src/com/google/gwt/core/linker/CrossSiteIframeTemplate.js
Mon Apr 11 11:56:17 2011
+++
/trunk/dev/core/src/com/google/gwt/core/linker/CrossSiteIframeTemplate.js
Fri May 6 08:06:47 2011
@@ -22,16 +22,6 @@
* Internal Helper Functions
***************************************************************************/
- function isBodyLoaded() {
- if (typeof $doc.readyState == "undefined") {
- // FF 3.5 and below does not have readyState, but it does allow us to
- // append to the body before it has finished loading, so we return
whether
- // the body element exists.
- return (typeof $doc.body != "undefined" && $doc.body != null);
- }
- return (/loaded|complete/.test($doc.readyState));
- }
-
function isHostedMode() {
var query = $wnd.location.search;
return ((query.indexOf('gwt.codesvr.__MODULE_NAME__=') != -1) ||
--
http://groups.google.com/group/Google-Web-Toolkit-Contributors