Revision: 10672
Author:   rdcas...@google.com
Date:     Mon Sep 26 13:26:56 2011
Log:      Rolling back 24166710. It's broken on IE7/WinXP.

Review by: rj...@google.com
http://code.google.com/p/google-web-toolkit/source/detail?r=10672

Modified:
 /trunk/user/src/com/google/gwt/user/client/ui/PotentialElement.java
 /trunk/user/src/com/google/gwt/user/client/ui/RenderablePanel.java

=======================================
--- /trunk/user/src/com/google/gwt/user/client/ui/PotentialElement.java Fri Sep 23 05:24:04 2011 +++ /trunk/user/src/com/google/gwt/user/client/ui/PotentialElement.java Mon Sep 26 13:26:56 2011
@@ -17,8 +17,6 @@

 import com.google.gwt.core.client.JavaScriptObject;
 import com.google.gwt.dom.client.Element;
-import com.google.gwt.dom.builder.shared.HtmlElementBuilder;
-import com.google.gwt.dom.builder.shared.HtmlBuilderFactory;

 /**
  * EXPERIMENTAL and subject to change. Do not use this in production code.
@@ -39,10 +37,6 @@
  */
 public class PotentialElement extends Element {

-  static {
-    declareShim();
-  }
-
   public static PotentialElement as(Element e) {
     assert isPotential(e);
     return (PotentialElement) e;
@@ -64,34 +58,34 @@
    * that is needed.
    */
public static native PotentialElement build(UIObject o, String tagName) /*-{
-    var el = new $wnd.GwtPotentialElementShim();
-    el.tagName = tagName;
- el.__gwt_resolve = @com.google.gwt.user.client.ui.PotentialElement::buildResolveCallback(Lcom/google/gwt/user/client/ui/UIObject;)(o); - return @com.google.gwt.dom.client.Element::as(Lcom/google/gwt/core/client/JavaScriptObject;)(el); + return @com.google.gwt.dom.client.Element::as(Lcom/google/gwt/core/client/JavaScriptObject;)({
+      className: '',
+      clientHeight: 0,
+      clientWidth: 0,
+      dir: '',
+      getAttribute: function(name, value) {
+        return this[name];
+      },
+      href: '',
+      id: '',
+      lang: '',
+ // should be @com.google.gwt.dom.client.Node.ELEMENT_MODE, but the compiler
+      // doesn't like that.
+      nodeType: 1,
+      removeAttribute: function(name, value) {
+        this[name] = undefined;
+      },
+      setAttribute: function(name, value) {
+        this[name] = value;
+      },
+      src: '',
+      style: {},
+      tagName: tagName,
+ __gwt_resolve: @com.google.gwt.user.client.ui.PotentialElement::buildResolveCallback(Lcom/google/gwt/user/client/ui/UIObject;)(o),
+      title: ''
+    });
   }-*/;

-  /**
- * Creates an {@link HtmlElementBuilder} instance inheriting all attributes
-   * set for the given PotentialElement.
-   *
- * @param potentialElement assumed to be a PotentialElement, used as basis for
-   *     the builder
-   * @return a propertly configured {@link HtmlElementBuilder} instance
-   */
- public static HtmlElementBuilder createBuilderFor(Element potentialElement) {
-    PotentialElement el = PotentialElement.as(potentialElement);
-    HtmlElementBuilder builder = HtmlBuilderFactory.get().trustedCreate(
-        el.getTagName());
-    el.mergeInto(builder);
-    return builder;
-  }
-
-  /**
- * Tests whether a given {@link JavaScriptObject} represents a PotentialElement.
-   *
-   * @param o the {@link JavaScriptObject} to be tested
-   * @return true if the given object is a PotentialElement instance
-   */
   public static native boolean isPotential(JavaScriptObject o) /*-{
     try {
       return (!!o) &&  (!!o.__gwt_resolve);
@@ -123,35 +117,6 @@
     throw "A PotentialElement cannot be resolved twice.";
   }-*/;

-  private static final native void declareShim() /*-{
-    var shim = function() {};
-    shim.prototype = {
-      className: '',
-      clientHeight: 0,
-      clientWidth: 0,
-      dir: '',
-      getAttribute: function(name, value) {
-        return this[name];
-      },
-      href: '',
-      id: '',
-      lang: '',
- // should be @com.google.gwt.dom.client.Node.ELEMENT_MODE, but the compiler
-      // doesn't like that.
-      nodeType: 1,
-      removeAttribute: function(name, value) {
-        this[name] = undefined;
-      },
-      setAttribute: function(name, value) {
-        this[name] = value;
-      },
-      src: '',
-      style: {},
-      title: ''
-    };
-    $wnd.GwtPotentialElementShim = shim;
-  }-*/;
-
   protected PotentialElement() {
   }

@@ -159,53 +124,6 @@
this.__gwt_resolve = @com.google.gwt.user.client.ui.PotentialElement::buildResolveCallback(Lcom/google/gwt/user/client/ui/UIObject;)(resolver);
   }-*/;

-  /**
- * Copy only the fields that have actually changed from the values in the shim - * prototype. Do this by severing the __proto__ link, allowing us to iterate
-   * only on the fields set in this specific instance.
-   */
-  private native void mergeInto(HtmlElementBuilder builder) /*-{
-    var savedProto = this.__proto__;
-    var tagName = this.tagName;
-    var gwtResolve = this.__gwt_resolve;
-    var className = this.className;
-
-    try {
-      this.__proto__ = null;
-      this.tagName = null;
-      this.__gwt_resolve = null;
-
- // className needs special treatment because the actual HTML attribute is
-      // called "class" and not "className".
-      if (this.className) {
- build...@com.google.gwt.dom.builder.shared.ElementBuilder::className(Ljava/lang/String;)(
-            this.className);
-        this.className = null;
-      }
-
-      // Iterate over all attributes, and copy them to the ElementBuilder.
-      for (attr in this) {
-        if (!this[attr]) {
-          continue;
-        }
-        if (typeof this[attr] == 'number') {
- build...@com.google.gwt.dom.builder.shared.ElementBuilder::attribute(Ljava/lang/String;I)(
-              attr, this[attr]);
-        } else {
- build...@com.google.gwt.dom.builder.shared.ElementBuilder::attribute(Ljava/lang/String;Ljava/lang/String;)(
-              attr, this[attr]);
-        }
-      }
-    } finally {
-      this.__proto__ = savedProto;
-      if (className) {
-        this.className = className;
-      }
-      this.__gwt_resolve = gwtResolve;
-      this.tagName = tagName;
-    }
-  }-*/;
-
   /**
    * Calls the <code>__gwt_resolve</code> method on the underlying
* JavaScript object if it exists. On objects created via {@link #build}, this
=======================================
--- /trunk/user/src/com/google/gwt/user/client/ui/RenderablePanel.java Fri Sep 23 05:24:04 2011 +++ /trunk/user/src/com/google/gwt/user/client/ui/RenderablePanel.java Mon Sep 26 13:26:56 2011
@@ -15,7 +15,8 @@
  */
 package com.google.gwt.user.client.ui;

-import com.google.gwt.dom.builder.shared.HtmlElementBuilder;
+import com.google.gwt.dom.builder.shared.HtmlDivBuilder;
+import com.google.gwt.dom.builder.shared.HtmlBuilderFactory;
 import com.google.gwt.dom.client.Document;
 import com.google.gwt.dom.client.Element;
 import com.google.gwt.safehtml.shared.SafeHtml;
@@ -188,12 +189,18 @@

   @Override
   public SafeHtml render(RenderableStamper stamper) {
- HtmlElementBuilder builder = PotentialElement.createBuilderFor(getElement());
-    stamper.stamp(builder);
-    builder.html(getInnerHtml()).end();
-
-    SafeHtml returnValue = builder.asSafeHtml();
-    return returnValue;
+    String styleName = getStyleName();
+
+    HtmlDivBuilder divBuilder = HtmlBuilderFactory.get()
+        .createDivBuilder();
+    if (styleName != null) {
+      divBuilder.className(styleName);
+      styleName = null;
+    }
+    stamper.stamp(divBuilder);
+    divBuilder.html(getInnerHtml()).end();
+
+    return divBuilder.asSafeHtml();
   }

   @Override
@@ -229,8 +236,6 @@
    * that may have been added to the panel.
    */
   private void buildAndInitDivContainer() {
-    // TODO(rdcastro): Use the same technique as in render() above.
-
     // Build the div that'll container the panel's HTML.
     Element element = Document.get().createDivElement();
     element.setInnerHTML(getInnerHtml().asString());

--
http://groups.google.com/group/Google-Web-Toolkit-Contributors

Reply via email to