Author: [email protected]
Date: Tue May 26 11:40:15 2009
New Revision: 5471
Modified:
branches/snapshot-2009.05.12-r5406/branch-info.txt
branches/snapshot-2009.05.12-r5406/dev/core/src/com/google/gwt/core/ext/linker/impl/hosted.html
branches/snapshot-2009.05.12-r5406/dev/core/src/com/google/gwt/core/linker/IFrameTemplate.js
Log:
Rolling tr...@5393 out of this branch. The IFRAME XHR change is broken on
IE6 hosted and Safari 3.
Modified: branches/snapshot-2009.05.12-r5406/branch-info.txt
==============================================================================
--- branches/snapshot-2009.05.12-r5406/branch-info.txt (original)
+++ branches/snapshot-2009.05.12-r5406/branch-info.txt Tue May 26 11:40:15
2009
@@ -12,4 +12,4 @@
svn merge -c5450 https://google-web-toolkit.googlecode.com/svn/trunk .
/trunk c5466,5467 were merged (r5468) into this branch
svn merge -c5466,5467 http://google-web-toolkit.googlecode.com/svn/trunk/
-
+/trunk c5393 was ROLLED BACK in this branch
Modified:
branches/snapshot-2009.05.12-r5406/dev/core/src/com/google/gwt/core/ext/linker/impl/hosted.html
==============================================================================
---
branches/snapshot-2009.05.12-r5406/dev/core/src/com/google/gwt/core/ext/linker/impl/hosted.html
(original)
+++
branches/snapshot-2009.05.12-r5406/dev/core/src/com/google/gwt/core/ext/linker/impl/hosted.html
Tue May 26 11:40:15 2009
@@ -241,13 +241,6 @@
}
}
-// The module to be loaded can be specified either through the url query
-// parameter (as done by the legacy HostedModeTemplate.js), or by
specifying
-// window.__gwt_module (as done by IFrameTemplate.js). When the former
approach
-// is removed, we can drop the 'query' part of this logic.
query = window.location.search.substring(1);
if (query && $wnd[query]) setTimeout($wnd[query].onScriptLoad, 1);
-
-var module = window.__gwt_module;
-if (module && $wnd[module]) setTimeout($wnd[module].onScriptLoad, 1);
--></script></body></html>
Modified:
branches/snapshot-2009.05.12-r5406/dev/core/src/com/google/gwt/core/linker/IFrameTemplate.js
==============================================================================
---
branches/snapshot-2009.05.12-r5406/dev/core/src/com/google/gwt/core/linker/IFrameTemplate.js
(original)
+++
branches/snapshot-2009.05.12-r5406/dev/core/src/com/google/gwt/core/linker/IFrameTemplate.js
Tue May 26 11:40:15 2009
@@ -41,13 +41,9 @@
// the strong name of the cache.js file to load.
,answers = []
- // Error functions. Default unset in compiled mode, may be set by meta
props
+ // Error functions. Default unset in compiled mode, may be set by meta
props.
,onLoadErrorFunc, propertyErrorFunc
- // The frame that will contain the compiled script (created in
- // fetchCompiledScript())
- ,scriptFrame
-
; // end of global vars
$stats && $stats({
@@ -86,13 +82,10 @@
// Called by onScriptLoad(), onInjectionDone(), and onload(). It causes
// the specified module to be cranked up.
//
- var moduleStarted = false;
function maybeStartModule() {
- if (bodyDone && scriptsDone && loadDone && !moduleStarted) {
- moduleStarted = true;
-
- var frameWnd = scriptFrame.contentWindow;
-
+ if (scriptsDone && loadDone) {
+ var iframe = $doc.getElementById('__MODULE_NAME__');
+ var frameWnd = iframe.contentWindow;
// inject hosted mode property evaluation function
if (isHostedMode()) {
frameWnd.__gwt_getProperty = function(name) {
@@ -281,71 +274,35 @@
throw null;
}
- // Creates a new XMLHttpRequest object. Used by fetchCompiledScript().
- //
- function newXhr() {
- // This is the same logic as in GWT's XMLHttpRequest wrapper.
The 'else'
- // case is needed primarily for old IEs.
- if (window.XMLHttpRequest) {
- return new XMLHttpRequest();
- } else {
- try {
- return new ActiveXObject('MSXML2.XMLHTTP.3.0');
- } catch (e) {
- return new ActiveXObject("Microsoft.XMLHTTP");
- }
+ var frameInjected;
+ function maybeInjectFrame() {
+ if (!frameInjected) {
+ frameInjected = true;
+ var iframe = $doc.createElement('iframe');
+ // Prevents mixed mode security in IE6/7.
+ iframe.src = "javascript:''";
+ iframe.id = "__MODULE_NAME__";
+ iframe.style.cssText
= "position:absolute;width:0;height:0;border:none";
+ iframe.tabIndex = -1;
+ // Due to an IE6/7 refresh quirk, this must be an appendChild.
+ $doc.body.appendChild(iframe);
+
+ /*
+ * The src has to be set after the iframe is attached to the DOM to
avoid
+ * refresh quirks in Safari. We have to use the location.replace
trick to
+ * avoid FF2 refresh quirks.
+ */
+ $stats && $stats({
+ moduleName:'__MODULE_NAME__',
+ subSystem:'startup',
+ evtGroup: 'moduleStartup',
+ millis:(new Date()).getTime(),
+ type: 'moduleRequested'
+ });
+ iframe.contentWindow.location.replace(base + initialHtml);
}
}
- // Fetches the compiled script via XHR, dropping it into 'scriptFrame'
via
- // document.write().
- //
- function fetchCompiledScript() {
- $stats && $stats({
- moduleName:'__MODULE_NAME__',
- subSystem:'startup',
- evtGroup: 'moduleStartup',
- millis:(new Date()).getTime(),
- type: 'moduleRequested'
- });
-
- // Fetch the contents via XHR.
- var xhr = newXhr();
- xhr.open('GET', base + initialHtml);
- xhr.onreadystatechange = function() {
- // 4 == DONE
- if (xhr.readyState == 4) {
- // Create the script frame, making sure it's invisible, but not
- // "display:none", which keeps some browsers from running code in
it.
- scriptFrame = document.createElement('iframe');
- scriptFrame.src = 'javascript:""';
- scriptFrame.id = '__MODULE_NAME__';
- scriptFrame.style.cssText = 'position:absolute; width:0; height:0;
border:none';
- scriptFrame.tabIndex = -1;
- document.body.appendChild(scriptFrame);
-
- // Expose the module function via an expando on the iframe's
window.
- // (this is needed for the compiled script to call back into
- // onScriptLoad()).
- var win = scriptFrame.contentWindow;
- if (isHostedMode()) {
- win.__gwt_module = '__MODULE_FUNC__';
- }
-
- // Inject the fetched script into the script frame.
- // (this script will call onScriptLoad())
- var doc = win.document;
- doc.open();
- doc.write(xhr.responseText);
- doc.close();
-
- // Make sure we don't leak the xhr object.
- xhr = null;
- }
- };
- xhr.send(null);
- }
-
// --------------- PROPERTY PROVIDERS ---------------
// __PROPERTIES_BEGIN__
@@ -356,10 +313,14 @@
// Called when the compiled script identified by moduleName is done
loading.
//
__MODULE_FUNC__.onScriptLoad = function() {
- // Mark this module's script as done loading and (possibly) start the
- // module.
- loadDone = true;
- maybeStartModule();
+ // IE7 bookmark bug. A phantom (presumably cached) version of our
compiled iframe
+ // can call onScriptLoad before we even properly inject the iframe. So
if this is
+ // called before the frame was injected ... it is completely bogus.
+ if (frameInjected) {
+ // Mark this module's script as done loading and (possibly) start
the module.
+ loadDone = true;
+ maybeStartModule();
+ }
}
// Called when the script injection is complete.
@@ -390,14 +351,13 @@
$wnd.location.reload();
return;
}
-
- initialHtml = "hosted.html";
+ initialHtml = "hosted.html?__MODULE_FUNC__";
strongName = "";
}
processMetas();
- // ------- SELECT PERMUTATION AND FETCH SCRIPT -------
+ // --------------- WINDOW ONLOAD HOOK ---------------
$stats && $stats({
moduleName:'__MODULE_NAME__',
@@ -419,11 +379,6 @@
}
}
- // Start the request for the compiled script.
- fetchCompiledScript();
-
- // --------------- WINDOW ONLOAD HOOK ---------------
-
var onBodyDoneTimerId;
function onBodyDone() {
if (!bodyDone) {
@@ -445,6 +400,7 @@
// For everyone that supports DOMContentLoaded.
if ($doc.addEventListener) {
$doc.addEventListener("DOMContentLoaded", function() {
+ maybeInjectFrame();
onBodyDone();
}, false);
}
@@ -452,6 +408,7 @@
// Fallback. If onBodyDone() gets fired twice, it's not a big deal.
var onBodyDoneTimerId = setInterval(function() {
if (/loaded|complete/.test($doc.readyState)) {
+ maybeInjectFrame();
onBodyDone();
}
}, 50);
--~--~---------~--~----~------------~-------~--~----~
http://groups.google.com/group/Google-Web-Toolkit-Contributors
-~----------~----~----~----~------~----~------~--~---