Cleanup of SafeHtml bypass functions.

Remove uses of appendHtmlConstant on non-constant values
Use proto.getSafeHtml() where feasible

Change-Id: I905ae8acb7bc66b1412cd7749737ae18ed4874a4
Review-Link: https://gwt-review.googlesource.com/#/c/13993/
diff --git a/user/src/com/google/gwt/cell/client/ButtonCellBase.java b/user/src/com/google/gwt/cell/client/ButtonCellBase.java
index 7952f8a..90fcd91 100644
--- a/user/src/com/google/gwt/cell/client/ButtonCellBase.java
+++ b/user/src/com/google/gwt/cell/client/ButtonCellBase.java
@@ -284,7 +284,7 @@
           iconSafeHtml = SafeHtmlUtils.EMPTY_SAFE_HTML;
         } else {
           AbstractImagePrototype proto = AbstractImagePrototype.create(icon);
-          SafeHtml iconOnly = SafeHtmlUtils.fromTrustedString(proto.getHTML());
+          SafeHtml iconOnly = proto.getSafeHtml();
           int halfHeight = (int) Math.round(icon.getHeight() / 2.0);
           SafeStylesBuilder styles = new SafeStylesBuilder();
           styles.marginTop(-halfHeight, Unit.PX);
@@ -326,7 +326,7 @@
       openTag.append(" class=\"" + classes.toSafeHtml().asString() + "\"");
       openTag.append(" tabindex=\"" + tabIndex + "\" ");
       openTag.append(attributes.toString()).append(">");
-      sb.appendHtmlConstant(openTag.toString());
+      sb.append(SafeHtmlUtils.fromTrustedString(openTag.toString()));
       sb.append(content);
       sb.appendHtmlConstant("</button>");
     }
diff --git a/user/src/com/google/gwt/user/cellview/client/CellBrowser.java b/user/src/com/google/gwt/user/cellview/client/CellBrowser.java
index c65a4c3..9aa50e3 100644
--- a/user/src/com/google/gwt/user/cellview/client/CellBrowser.java
+++ b/user/src/com/google/gwt/user/cellview/client/CellBrowser.java
@@ -1237,7 +1237,7 @@
   private SafeHtml getImageHtml(ImageResource res) {
     // Right-justify image if LTR, left-justify if RTL
     AbstractImagePrototype proto = AbstractImagePrototype.create(res);
-    SafeHtml image = SafeHtmlUtils.fromTrustedString(proto.getHTML());
+    SafeHtml image = proto.getSafeHtml();
 
     SafeStylesBuilder cssBuilder = new SafeStylesBuilder();
     if (LocaleInfo.getCurrentLocale().isRTL()) {
diff --git a/user/src/com/google/gwt/user/cellview/client/CellTree.java b/user/src/com/google/gwt/user/cellview/client/CellTree.java
index 17ad1a5..d73ed01 100644
--- a/user/src/com/google/gwt/user/cellview/client/CellTree.java
+++ b/user/src/com/google/gwt/user/cellview/client/CellTree.java
@@ -39,7 +39,6 @@
 import com.google.gwt.safecss.shared.SafeStylesBuilder;
 import com.google.gwt.safehtml.client.SafeHtmlTemplates;
 import com.google.gwt.safehtml.shared.SafeHtml;
-import com.google.gwt.safehtml.shared.SafeHtmlUtils;
 import com.google.gwt.user.client.Event;
 import com.google.gwt.user.client.ui.AbstractImagePrototype;
 import com.google.gwt.user.client.ui.Focusable;
@@ -1046,7 +1045,7 @@
     cssBuilder.appendTrustedString("height: " + res.getHeight() + "px;");
 
     AbstractImagePrototype proto = AbstractImagePrototype.create(res);
-    SafeHtml image = SafeHtmlUtils.fromTrustedString(proto.getHTML());
+    SafeHtml image = proto.getSafeHtml();
     return template
         .imageWrapper(classesBuilder.toString(), cssBuilder.toSafeStyles(), image);
   }
diff --git a/user/src/com/google/gwt/user/client/ui/RenderablePanel.java b/user/src/com/google/gwt/user/client/ui/RenderablePanel.java
index 22d3bdc..d67487f 100644
--- a/user/src/com/google/gwt/user/client/ui/RenderablePanel.java
+++ b/user/src/com/google/gwt/user/client/ui/RenderablePanel.java
@@ -21,6 +21,7 @@
 import com.google.gwt.dom.client.Element;
 import com.google.gwt.safehtml.shared.SafeHtml;
 import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
+import com.google.gwt.safehtml.shared.SafeHtmlUtils;
 import com.google.gwt.safehtml.shared.annotations.IsSafeHtml;
 import com.google.gwt.user.client.DOM;
 
@@ -67,7 +68,7 @@
    * @param html the panel's HTML
    */
   public RenderablePanel(@IsSafeHtml String html) {
-    this(new SafeHtmlBuilder().appendHtmlConstant(html).toSafeHtml());
+    this(SafeHtmlUtils.fromTrustedString(html));
   }
 
   /**