Adds setTagName to PotentialElement, so that PotentialElement instances can be passed to the as() method of Element subclasses (it's nicer than blindly calling .cast(), I think). Let me know if this looks clearner to you guys.
Review at http://gwt-code-reviews.appspot.com/1451810
git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@10323 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/user/src/com/google/gwt/user/client/ui/PotentialElement.java b/user/src/com/google/gwt/user/client/ui/PotentialElement.java
index 58f5a83..f8abf74 100644
--- a/user/src/com/google/gwt/user/client/ui/PotentialElement.java
+++ b/user/src/com/google/gwt/user/client/ui/PotentialElement.java
@@ -43,12 +43,21 @@
}
/**
+ * Builds a new PotentialElement with the tag name set to "div".
+ *
+ * @see #build(UIObject,String)
+ */
+ public static PotentialElement build(UIObject o) {
+ return build(o, "div");
+ }
+
+ /**
* Builds a new PotentialElement. This element keeps track of the
* {@link UIObject} so that it can call
* {@link UIObject#resolvePotentialElement} to get a real element when
* that is needed.
*/
- public static native PotentialElement build(UIObject o) /*-{
+ public static native PotentialElement build(UIObject o, String tagName) /*-{
return @com.google.gwt.dom.client.Element::as(Lcom/google/gwt/core/client/JavaScriptObject;)({
className: '',
clientHeight: 0,
@@ -71,6 +80,7 @@
},
src: '',
style: {},
+ tagName: tagName,
__gwt_resolve: @com.google.gwt.user.client.ui.PotentialElement::buildResolveCallback(Lcom/google/gwt/user/client/ui/UIObject;)(o),
title: ''
});
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 3f63fa5..6080825 100644
--- a/user/src/com/google/gwt/user/client/ui/RenderablePanel.java
+++ b/user/src/com/google/gwt/user/client/ui/RenderablePanel.java
@@ -36,6 +36,8 @@
private static Element hiddenDiv;
+ private static String TAG_NAME = "div";
+
interface HTMLTemplates extends SafeHtmlTemplates {
@Template("<div id=\"{0}\">{1}</div>")
SafeHtml renderWithId(String id, SafeHtml innerHtml);
@@ -86,7 +88,7 @@
*/
public RenderablePanel(SafeHtml safeHtml) {
this.html = safeHtml;
- setElement(PotentialElement.build(this));
+ setElement(PotentialElement.build(this, TAG_NAME));
}
/**