Make debugging the new linker bootstrap a little easier

Review by: cromwellian@google.com

git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@10160 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/dev/core/src/com/google/gwt/core/ext/linker/impl/SelectionScriptLinker.java b/dev/core/src/com/google/gwt/core/ext/linker/impl/SelectionScriptLinker.java
index 25eef01..47bc2ec 100644
--- a/dev/core/src/com/google/gwt/core/ext/linker/impl/SelectionScriptLinker.java
+++ b/dev/core/src/com/google/gwt/core/ext/linker/impl/SelectionScriptLinker.java
@@ -362,7 +362,7 @@
 
   protected String wrapPrimaryFragment(TreeLogger logger,
       LinkerContext context, String script, ArtifactSet artifacts,
-      CompilationResult result) {
+      CompilationResult result) throws UnableToCompleteException {
     return script;
   }
 
diff --git a/dev/core/src/com/google/gwt/core/ext/linker/impl/installScriptDirect.js b/dev/core/src/com/google/gwt/core/ext/linker/impl/installScriptDirect.js
index e843e7b..4ca4d72 100644
--- a/dev/core/src/com/google/gwt/core/ext/linker/impl/installScriptDirect.js
+++ b/dev/core/src/com/google/gwt/core/ext/linker/impl/installScriptDirect.js
@@ -15,9 +15,11 @@
     sendStats('moduleStartup', 'moduleRequested');
     docbody.appendChild(script);
 
-    // Remove the tags to shrink the DOM a little.
+    // Unless we're in pretty mode, remove the tags to shrink the DOM a little.
     // It should have installed its code immediately after being added.
+    __START_OBFUSCATED_ONLY__
     docbody.removeChild(script);
+    __END_OBFUSCATED_ONLY__
   }
 
   // Just pass along the filename so that a script tag can be installed in the
diff --git a/dev/core/src/com/google/gwt/core/ext/linker/impl/installScriptEarlyDownload.js b/dev/core/src/com/google/gwt/core/ext/linker/impl/installScriptEarlyDownload.js
index fcf0277..19587e9 100644
--- a/dev/core/src/com/google/gwt/core/ext/linker/impl/installScriptEarlyDownload.js
+++ b/dev/core/src/com/google/gwt/core/ext/linker/impl/installScriptEarlyDownload.js
@@ -16,9 +16,11 @@
     script.text = code;
     docbody.appendChild(script);
 
-    // Remove the tags to shrink the DOM a little.
+    // Unless we're in pretty mode, remove the tags to shrink the DOM a little.
     // It should have installed its code immediately after being added.
+    __START_OBFUSCATED_ONLY__
     docbody.removeChild(script);
+    __END_OBFUSCATED_ONLY__
   }
   
   // Set up a script tag to start downloading immediately, as well as a
diff --git a/dev/core/src/com/google/gwt/core/linker/CrossSiteIframeLinker.java b/dev/core/src/com/google/gwt/core/linker/CrossSiteIframeLinker.java
index 8defd81..6d55189 100644
--- a/dev/core/src/com/google/gwt/core/linker/CrossSiteIframeLinker.java
+++ b/dev/core/src/com/google/gwt/core/linker/CrossSiteIframeLinker.java
@@ -130,6 +130,14 @@
     replaceAll(ss, "__MODULE_NAME__", context.getModuleName());
     replaceAll(ss, "__HOSTED_FILENAME__", getHostedFilenameFull(context));
 
+    if (context.isOutputCompact()) {
+      replaceAll(ss, "__START_OBFUSCATED_ONLY__", "");
+      replaceAll(ss, "__END_OBFUSCATED_ONLY__", "");      
+    } else {
+      replaceAll(ss, "__START_OBFUSCATED_ONLY__", "/*");
+      replaceAll(ss, "__END_OBFUSCATED_ONLY__", "*/");
+    }
+
     return ss.toString();
   }
 
@@ -408,26 +416,20 @@
 
   @Override
   protected String wrapPrimaryFragment(TreeLogger logger, LinkerContext context, String script,
-      ArtifactSet artifacts, CompilationResult result) {
+      ArtifactSet artifacts, CompilationResult result) throws UnableToCompleteException {
     StringBuffer out = new StringBuffer();
     if (shouldIncludeBootstrapInPrimaryFragment(context)) {
-      try {
-        out.append(generateSelectionScript(logger, context, artifacts, result));
-      } catch (UnableToCompleteException e) {
-        logger.log(TreeLogger.ERROR, "Problem setting up selection script", e);
-        e.printStackTrace();
-      }
+      out.append(generateSelectionScript(logger, context, artifacts, result));
     }
-
     if (shouldInstallCode(context)) {
       // Rewrite the code so it can be installed with
       // __MODULE_FUNC__.onScriptDownloaded
       out.append(context.getModuleFunctionName());
       out.append(".onScriptDownloaded(");
-      out.append(JsToStringGenerationVisitor.javaScriptString(script.toString()));
+      out.append(JsToStringGenerationVisitor.javaScriptString(script));
       out.append(")");
     } else {
-      out.append(script.toString());
+      out.append(script);
     }
     return out.toString();
   }
diff --git a/dev/core/src/com/google/gwt/core/linker/DirectInstallLinker.java b/dev/core/src/com/google/gwt/core/linker/DirectInstallLinker.java
new file mode 100644
index 0000000..e406993
--- /dev/null
+++ b/dev/core/src/com/google/gwt/core/linker/DirectInstallLinker.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2010 Google Inc.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+package com.google.gwt.core.linker;
+
+import com.google.gwt.core.ext.LinkerContext;
+
+/**
+ * A linker that adds a script tag to the iframe rather than downloading the
+ * code as a string and then installing it into the iframe.
+ */
+public class DirectInstallLinker extends CrossSiteIframeLinker {
+  @Override
+  protected String getJsInstallScript(LinkerContext context) {
+    return "com/google/gwt/core/ext/linker/impl/installScriptDirect.js";
+  }
+  
+  @Override
+  protected boolean shouldInstallCode(LinkerContext context) {
+    return false;
+  }
+}
diff --git a/user/src/com/google/gwt/core/CrossSiteIframeLinker.gwt.xml b/user/src/com/google/gwt/core/CrossSiteIframeLinker.gwt.xml
index c7773ad..3679d19 100644
--- a/user/src/com/google/gwt/core/CrossSiteIframeLinker.gwt.xml
+++ b/user/src/com/google/gwt/core/CrossSiteIframeLinker.gwt.xml
@@ -12,9 +12,10 @@
 <!-- implied. License for the specific language governing permissions and   -->
 <!-- limitations under the License.                                         -->
 
-<!-- Defines the cross-site iframe linker   -->
+<!-- Defines the cross-site iframe linker and it's subclasses  -->
 <module>
   <define-linker name="xsiframe" class="com.google.gwt.core.linker.CrossSiteIframeLinker" />
+  <define-linker name="direct_install" class="com.google.gwt.core.linker.DirectInstallLinker" />
   <define-configuration-property name="xsiframe.failIfScriptTag" is_multi_valued="FALSE"/>
   <set-configuration-property name="xsiframe.failIfScriptTag" value="TRUE"/>