When widgets are added to a DeckPanel, their visibility, height, and width
attributes are modified. When these widgets are removed from the panel, the
modifications to these attributes still remain. To fix this problem, an
implementation of the disown(Widget) method has been added to DeckPanel. This
implementation calls the superclass' disown method, makes the widget visible,
and then clears out the width and height attributes of the widget.

This fix is very similar to the one for issue #626, where attributes set on a
widget by AbsolutePanel persisted after the widget was removed from the panel.

It is debatable as to whether the code to reset the attributes should have been
put in the remove(Widget) method or not. If the code was put there, then we
would have saved ourselves a method call. However, from the standpoint of
correctness, disown(Widget) seems like the best place to put this code, because
it is a required call when a widget is removed from a panel, and it is also the
last step before the widget is actually removed from the panel. 

Issue: 981
Patch by: fredsa,rdayal
Review by: jgw


git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@1033 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/user/src/com/google/gwt/user/client/ui/DeckPanel.java b/user/src/com/google/gwt/user/client/ui/DeckPanel.java
index 1ed9fb5..d9953a3 100644
--- a/user/src/com/google/gwt/user/client/ui/DeckPanel.java
+++ b/user/src/com/google/gwt/user/client/ui/DeckPanel.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2006 Google Inc.
+ * Copyright 2007 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
@@ -22,6 +22,13 @@
  * A panel that displays all of its child widgets in a 'deck', where only one
  * can be visible at a time. It is used by
  * {@link com.google.gwt.user.client.ui.TabPanel}.
+ *
+ * <p>
+ * Once a widget has been added to a DeckPanel, its visibility, width, and
+ * height attributes will be manipulated. When the widget is removed from
+ * the DeckPanel, it will be visible, and its width and height attributes
+ * will be cleared.
+ * </p>
  */
 public class DeckPanel extends ComplexPanel implements IndexedPanel {
 
@@ -117,6 +124,22 @@
     visibleWidget.setVisible(true);
   }
 
+  /**
+   * Calls the superclass' <code>disown(Widget)</code> method, makes the widget
+   * visible, and clears the widget's width and height attributes. This is done
+   * so that any changes to the visibility, height, or width of the widget
+   * that were done by the panel are undone when the widget is disowned from
+   * the panel.
+   *
+   * @param w the widget to be disowned
+   */
+  protected void disown(Widget w) {
+    super.disown(w);
+    DOM.setStyleAttribute(w.getElement(), "width", "");
+    DOM.setStyleAttribute(w.getElement(), "height", "");
+    w.setVisible(true);
+  }
+
   private void checkIndex(int index) {
     if ((index < 0) || (index >= getWidgetCount())) {
       throw new IndexOutOfBoundsException();