Merge OOPHM hosted.html into standard one.
Patch by: jat
Review by: rjrjr
git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@4665 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/dev/core/src/com/google/gwt/core/ext/linker/impl/hosted.html b/dev/core/src/com/google/gwt/core/ext/linker/impl/hosted.html
index aeec95e..154801d 100644
--- a/dev/core/src/com/google/gwt/core/ext/linker/impl/hosted.html
+++ b/dev/core/src/com/google/gwt/core/ext/linker/impl/hosted.html
@@ -4,37 +4,242 @@
var $doc = $wnd.document;
var $moduleName, $moduleBase
,$stats = $wnd.__gwtStatsEvent ? function(a) {return $wnd.__gwtStatsEvent(a);} : null;
+// Lightweight metrics
if ($stats) {
var moduleFuncName = location.search.substr(1);
var moduleFunc = $wnd[moduleFuncName];
var moduleName = moduleFunc ? moduleFunc.moduleName : "unknown";
$stats({moduleName:moduleName,subSystem:'startup',evtGroup:'moduleStartup',millis:(new Date()).getTime(),type:'moduleEvalStart'});
}
-</script></head>
-<body>
-<font face='arial' size='-1'>This html file is for hosted mode support.</font>
-<script><!--
-function gwtOnLoad(errFn, modName, modBase){
- $moduleName = modName;
- $moduleBase = modBase;
- if (!external.gwtOnLoad(window, modName, "1.6")) {
- if (errFn) {
- errFn(modName);
+
+var $hosted = "localhost:9997";
+var $legacyHosted = false;
+try {
+ // try/catch perhaps unnecessary, but I recall issues on IE if it isn't
+ // present
+ if (external.gwtOnLoad) {
+ $legacyHosted = true;
+ }
+} catch(e) {
+}
+if ($legacyHosted) {
+ function gwtOnLoad(errFn, modName, modBase){
+ $moduleName = modName;
+ $moduleBase = modBase;
+ if (!external.gwtOnLoad(window, modName, "1.6")) {
+ if (errFn) {
+ errFn(modName);
+ }
}
}
+
+ window.onunload = function() {
+ external.gwtOnLoad(window, null, "1.6");
+ };
+} else {
+ // install eval wrapper on FF to avoid EvalError problem
+ if (navigator.userAgent.toLowerCase().indexOf("gecko") != -1) {
+ var __eval = window.eval;
+ window.eval = function(s) {
+ return __eval(s);
+ }
+ }
+
+ // wrapper to call JS methods, which we need both to be able to supply a
+ // different this for method lookup and to get the exception back
+ function __gwt_jsInvoke(thisObj, methodName) {
+ try {
+ var args = Array.prototype.slice.call(arguments, 2);
+ return [0, window[methodName].apply(thisObj, args)];
+ } catch (e) {
+ return [1, e];
+ }
+ }
+
+ var __gwt_javaInvokes = [];
+ function __gwt_makeJavaInvoke(argCount) {
+ return __gwt_javaInvokes[argCount] || __gwt_doMakeJavaInvoke(argCount);
+ }
+
+ function __gwt_doMakeJavaInvoke(argCount) {
+ // IE6 won't eval() anonymous functions except as r-values
+ var argList = "";
+ for (var i = 0; i < argCount; i++) {
+ argList += ",p" + i;
+ }
+ var argListNoComma = argList.substring(1);
+
+ return eval(
+ "__gwt_javaInvokes[" + argCount + "] =\n" +
+ " function(thisObj, dispId" + argList + ") {\n" +
+ " var result = __static(dispId, thisObj" + argList + ");\n" +
+ " if (result[0]) {\n" +
+ " throw result[1];\n" +
+ " } else {\n" +
+ " return result[1];\n" +
+ " }\n" +
+ " }\n"
+ );
+ }
+
+ /*
+ * This is used to create tear-offs of Java methods. Each function corresponds
+ * to exactly one dispId, and also embeds the argument count. We get the "this"
+ * value from the context in which the function is being executed.
+ * Function-object identity is preserved by caching in a sparse array.
+ */
+ var __gwt_tearOffs = [];
+ var __gwt_tearOffGenerators = [];
+ function __gwt_makeTearOff(proxy, dispId, argCount) {
+ return __gwt_tearOffs[dispId] || __gwt_doMakeTearOff(dispId, argCount);
+ }
+
+ function __gwt_doMakeTearOff(dispId, argCount) {
+ return __gwt_tearOffs[dispId] =
+ (__gwt_tearOffGenerators[argCount] || __gwt_doMakeTearOffGenerator(argCount))(dispId);
+ }
+
+ function __gwt_doMakeTearOffGenerator(argCount) {
+ // IE6 won't eval() anonymous functions except as r-values
+ var argList = "";
+ for (var i = 0; i < argCount; i++) {
+ argList += ",p" + i;
+ }
+ var argListNoComma = argList.substring(1);
+
+ return eval(
+ "__gwt_tearOffGenerators[" + argCount + "] =\n" +
+ " function(dispId) {\n" +
+ " return function(" + argListNoComma + ") {\n" +
+ " var result = __static(dispId, this" + argList + ");\n" +
+ " if (result[0]) {\n" +
+ " throw result[1];\n" +
+ " } else {\n" +
+ " return result[1];\n" +
+ " }\n" +
+ " }\n" +
+ " }\n"
+ );
+ }
+
+ function __gwt_makeResult(isException, result) {
+ return [isException, result];
+ }
+
+ function findPluginObject() {
+ try {
+ return document.getElementById('pluginObject');
+ } catch (e) {
+ return null;
+ }
+ }
+
+ function findPluginEmbed() {
+ try {
+ return document.getElementById('pluginEmbed')
+ } catch (e) {
+ return null;
+ }
+ }
+
+ function findPluginXPCOM() {
+ try {
+ return __gwt_HostedModePlugin;
+ } catch (e) {
+ return null;
+ }
+ }
+
+ function gwtOnLoad(errFn, modName, modBase){
+ $moduleName = modName;
+ $moduleBase = modBase;
+
+ /*
+ * NOTE: this presently sucks and is the only formulation I can find that will
+ * work across browsers. On a Windows box where both plugins are registered,
+ * FF will instantiate the (non-working) IE plugin. But plugins have problems
+ * that prevent making this easy.
+ *
+ * The IE plugin will throw an exception in FF if you try to resolve
+ * "pluginObject.connect" as a value. Thus the try/catch below.
+ *
+ * The FF plugin will actually do illegal crashy things in IE if you try to
+ * resolve "pluginEmbed.connect" as a value. Thus we have to try the IE
+ * plugin first.
+ *
+ * Both plugins need some work to make them truly safe.
+ */
+ var pluginFinders = [
+ findPluginXPCOM,
+ findPluginObject,
+ findPluginEmbed,
+ ];
+ var found = false;
+ for (var i = 0; i < pluginFinders.length; ++i) {
+ try {
+ var plugin = pluginFinders[i]();
+ if (plugin != null) {
+ // TODO: split connect into init/connect so we can tell plugin
+ // failures from connection failures.
+ if (plugin.connect($hosted, $moduleName, window)) {
+ found = true;
+ break;
+ } else {
+ if (errFn) {
+ errFn(modName);
+ } else {
+ alert("failed to connect to hosted mode server at " + $hosted);
+ }
+ }
+ }
+ } catch (e) {
+ }
+ }
+ if (!found) {
+ alert("No GWT plugin found or hosted-mode connection failed");
+ }
+ }
+
+ window.onunload = function() {
+ // TODO: do we need to do anything here or just rely on the plugins
+ // unload call?
+ };
}
+// Lightweight metrics
window.fireOnModuleLoadStart = function(className) {
$stats && $stats({moduleName:$moduleName, subSystem:'startup', evtGroup:'moduleStartup', millis:(new Date()).getTime(), type:'onModuleLoadStart', className:className});
};
-window.onunload = function() {
- external.gwtOnLoad(window, null, "1.6");
-};
-
window.__gwt_module_id = 0;
-
-var query = window.location.search.substr(1);
+</script></head>
+<body>
+<font face='arial' size='-1'>This html file is for hosted mode support.</font>
+<script><!--
+// Lightweight metrics
$stats && $stats({moduleName:$moduleName,subSystem:'startup',evtGroup:'moduleStartup',millis:(new Date()).getTime(),type:'moduleEvalEnd'});
-if (query && $wnd[query]) $wnd[query].onScriptLoad();
+
+// OOPHM currently only supports IFrameLinker
+var query = parent.location.search;
+if (!$legacyHosted) {
+ if (!findPluginXPCOM()) {
+ document.write('<embed id="pluginEmbed" type="application/x-gwt-hosted-mode" width="10" height="10">');
+ document.write('</embed>');
+ document.write('<object id="pluginObject" CLASSID="CLSID:1D6156B6-002B-49E7-B5CA-C138FB843B4E">');
+ document.write('</object>');
+ }
+
+ var idx = query.indexOf("gwt.hosted=");
+ if (idx >= 0) {
+ var amp = query.indexOf("&", idx);
+ if (amp >= 0) {
+ $hosted = query.substring(idx + 11, amp);
+ } else {
+ $hosted = query.substring(idx + 11);
+ }
+ }
+}
+
+query = window.location.search.substring(1);
+if (query && $wnd[query]) setTimeout($wnd[query].onScriptLoad, 1);
--></script></body></html>
diff --git a/dev/oophm/overlay/com/google/gwt/core/ext/linker/impl/hosted.html b/dev/oophm/overlay/com/google/gwt/core/ext/linker/impl/hosted.html
deleted file mode 100644
index 1777bea..0000000
--- a/dev/oophm/overlay/com/google/gwt/core/ext/linker/impl/hosted.html
+++ /dev/null
@@ -1,210 +0,0 @@
-<html>
-<head><script>
-var $wnd = parent;
-var $doc = $wnd.document;
-var $moduleName, $moduleBase
-,$stats = $wnd.__gwtStatsEvent ? function(a) {return $wnd.__gwtStatsEvent(a);} : null;
-if ($stats) {
- var moduleFuncName = location.search.substr(1);
- var moduleFunc = $wnd[moduleFuncName];
- var moduleName = moduleFunc ? moduleFunc.moduleName : "unknown";
- $stats({moduleName:moduleName,subSystem:'startup',evtGroup:'moduleStartup',millis:(new Date()).getTime(),type:'moduleEvalStart'});
-}
-
-// install eval wrapper on FF to avoid EvalError problem
-if (navigator.userAgent.toLowerCase().indexOf("gecko") != -1) {
- var __eval = window.eval;
- window.eval = function(s) {
- return __eval(s);
- }
-}
-var $hosted = "localhost:9997";
-
-// wrapper to call JS methods, which we need both to be able to supply a
-// different this for method lookup and to get the exception back
-function __gwt_jsInvoke(thisObj, methodName) {
- try {
- var args = Array.prototype.slice.call(arguments, 2);
- return [0, window[methodName].apply(thisObj, args)];
- } catch (e) {
- return [1, e];
- }
-}
-
-var __gwt_javaInvokes = [];
-function __gwt_makeJavaInvoke(argCount) {
- return __gwt_javaInvokes[argCount] || __gwt_doMakeJavaInvoke(argCount);
-}
-
-function __gwt_doMakeJavaInvoke(argCount) {
- // IE6 won't eval() anonymous functions except as r-values
- var argList = "";
- for (var i = 0; i < argCount; i++) {
- argList += ",p" + i;
- }
- var argListNoComma = argList.substring(1);
-
- return eval(
- "__gwt_javaInvokes[" + argCount + "] =\n" +
- " function(thisObj, dispId" + argList + ") {\n" +
- " var result = __static(dispId, thisObj" + argList + ");\n" +
- " if (result[0]) {\n" +
- " throw result[1];\n" +
- " } else {\n" +
- " return result[1];\n" +
- " }\n" +
- " }\n"
- );
-}
-
-/*
- * This is used to create tear-offs of Java methods. Each function corresponds
- * to exactly one dispId, and also embeds the argument count. We get the "this"
- * value from the context in which the function is being executed.
- * Function-object identity is preserved by caching in a sparse array.
- */
-var __gwt_tearOffs = [];
-var __gwt_tearOffGenerators = [];
-function __gwt_makeTearOff(proxy, dispId, argCount) {
- return __gwt_tearOffs[dispId] || __gwt_doMakeTearOff(dispId, argCount);
-}
-
-function __gwt_doMakeTearOff(dispId, argCount) {
- return __gwt_tearOffs[dispId] =
- (__gwt_tearOffGenerators[argCount] || __gwt_doMakeTearOffGenerator(argCount))(dispId);
-}
-
-function __gwt_doMakeTearOffGenerator(argCount) {
- // IE6 won't eval() anonymous functions except as r-values
- var argList = "";
- for (var i = 0; i < argCount; i++) {
- argList += ",p" + i;
- }
- var argListNoComma = argList.substring(1);
-
- return eval(
- "__gwt_tearOffGenerators[" + argCount + "] =\n" +
- " function(dispId) {\n" +
- " return function(" + argListNoComma + ") {\n" +
- " var result = __static(dispId, this" + argList + ");\n" +
- " if (result[0]) {\n" +
- " throw result[1];\n" +
- " } else {\n" +
- " return result[1];\n" +
- " }\n" +
- " }\n" +
- " }\n"
- );
-}
-
-function __gwt_makeResult(isException, result) {
- return [isException, result];
-}
-
-function findPluginObject() {
- try {
- return document.getElementById('pluginObject');
- } catch (e) {
- return null;
- }
-}
-
-function findPluginEmbed() {
- try {
- return document.getElementById('pluginEmbed')
- } catch (e) {
- return null;
- }
-}
-
-function findPluginXPCOM() {
- try {
- return __gwt_HostedModePlugin;
- } catch (e) {
- return null;
- }
-}
-
-function gwtOnLoad(errFn, modName, modBase){
- $moduleName = modName;
- $moduleBase = modBase;
-
- /*
- * NOTE: this presently sucks and is the only formulation I can find that will
- * work across browsers. On a Windows box where both plugins are registered,
- * FF will instantiate the (non-working) IE plugin. But plugins have problems
- * that prevent making this easy.
- *
- * The IE plugin will throw an exception in FF if you try to resolve
- * "pluginObject.connect" as a value. Thus the try/catch below.
- *
- * The FF plugin will actually do illegal crashy things in IE if you try to
- * resolve "pluginEmbed.connect" as a value. Thus we have to try the IE
- * plugin first.
- *
- * Both plugins need some work to make them truly safe. I have no idea what
- * will happen in Safari.
- */
- var pluginFinders = [
- findPluginXPCOM,
- findPluginObject,
- findPluginEmbed,
- ];
- var found = false;
- for (var i = 0; i < pluginFinders.length; ++i) {
- try {
- var plugin = pluginFinders[i]();
- if (plugin != null) {
- if (plugin.connect($hosted, $moduleName, window)) {
- found = true;
- break;
- } else {
- if (errFn) {
- errFn(modName);
- } else {
- alert("failed to connect to hosted mode server at " + $hosted);
- }
- }
- }
- } catch (e) {
- }
- }
- if (!found) {
- alert("No GWT plugin found");
- }
-}
-
-window.fireOnModuleLoadStart = function(className) {
- $stats && $stats({moduleName:$moduleName, subSystem:'startup', evtGroup:'moduleStartup', millis:(new Date()).getTime(), type:'onModuleLoadStart', className:className});
-};
-
-window.onunload = function() {
-};
-
-window.__gwt_module_id = 0;
-</script></head>
-<body>
-<font face='arial' size='-1'>This html file is for hosted mode support.</font>
-<script><!--
-
-if (!findPluginXPCOM()) {
- document.write('<embed id="pluginEmbed" type="application/x-gwt-hosted-mode" width="10" height="10">');
- document.write('</embed>');
- document.write('<object id="pluginObject" CLASSID="CLSID:1D6156B6-002B-49E7-B5CA-C138FB843B4E">');
- document.write('</object>');
-}
-
-var query = parent.location.search;
-$stats && $stats({moduleName:$moduleName,subSystem:'startup',evtGroup:'moduleStartup',millis:(new Date()).getTime(),type:'moduleEvalEnd'});
-var idx = query.indexOf("gwt.hosted=");
-if (idx >= 0) {
- var amp = query.indexOf("&", idx);
- if (amp >= 0) {
- $hosted = query.substring(idx + 11, amp);
- } else {
- $hosted = query.substring(idx + 11);
- }
-}
-query = window.location.search.substring(1);
-if (query && $wnd[query]) setTimeout($wnd[query].onScriptLoad, 1);
---></script></body></html>