Fixed a IE7 bug in the TreeItem animation where the children would be completely visible for an instant when expanding the children.

Patch by: jlabanca
Review by: ecc
Issue: 2338



git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@2567 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/reference/code-museum/src/com/google/gwt/museum/client/defaultmuseum/DefaultMuseum.java b/reference/code-museum/src/com/google/gwt/museum/client/defaultmuseum/DefaultMuseum.java
index 638a9a7..0b21af2 100644
--- a/reference/code-museum/src/com/google/gwt/museum/client/defaultmuseum/DefaultMuseum.java
+++ b/reference/code-museum/src/com/google/gwt/museum/client/defaultmuseum/DefaultMuseum.java
@@ -32,5 +32,6 @@
     addIssue(new Issue2307());

     addIssue(new Issue2321());

     addIssue(new Issue2331());

+    addIssue(new Issue2338());

   }

 }

diff --git a/reference/code-museum/src/com/google/gwt/museum/client/defaultmuseum/Issue2338.java b/reference/code-museum/src/com/google/gwt/museum/client/defaultmuseum/Issue2338.java
new file mode 100644
index 0000000..7428af8
--- /dev/null
+++ b/reference/code-museum/src/com/google/gwt/museum/client/defaultmuseum/Issue2338.java
@@ -0,0 +1,54 @@
+/*

+ * Copyright 2008 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.museum.client.defaultmuseum;

+

+import com.google.gwt.museum.client.common.AbstractIssue;

+import com.google.gwt.user.client.ui.Tree;

+import com.google.gwt.user.client.ui.TreeItem;

+import com.google.gwt.user.client.ui.Widget;

+

+/**

+ * Opening a tree item flickers in IE7 because all of the children are shown for

+ * an instant, and then the animation continues normally.

+ */

+public class Issue2338 extends AbstractIssue {

+

+  @Override

+  public Widget createIssue() {

+    Tree tree = new Tree();

+    TreeItem root = tree.addItem("Root");

+    for (int i = 0; i < 5; i++) {

+      root.addItem("Item " + i);

+    }

+    return tree;

+  }

+

+  @Override

+  public String getInstructions() {

+    return "Open the root node and you should not see a flicker";

+  }

+

+  @Override

+  public String getSummary() {

+    return "Tree animation flickers when expanding a TreeItem";

+  }

+

+  @Override

+  public boolean hasCSS() {

+    return false;

+  }

+

+}

diff --git a/user/src/com/google/gwt/user/client/ui/TreeItem.java b/user/src/com/google/gwt/user/client/ui/TreeItem.java
index 9609457..f3c2c15 100644
--- a/user/src/com/google/gwt/user/client/ui/TreeItem.java
+++ b/user/src/com/google/gwt/user/client/ui/TreeItem.java
@@ -100,6 +100,10 @@
         height = scrollHeight - height;
       }
 
+      // Issue 2338: If the height is 0px, IE7 will display all of the children
+      // instead of hiding them completely.
+      height = Math.max(height, 1);
+
       DOM.setStyleAttribute(curItem.childSpanElem, "height", height + "px");
 
       // We need to set the width explicitly of the item might be cropped
@@ -684,9 +688,9 @@
       tree.showClosedImage(this);
     }
 
-    // We may need to update the tree's selection in response to a tree state change. For
-    // example, if the tree's currently selected item is a descendant of an item whose
-    // branch was just collapsed, then the item itself should become the newly-selected item.
+    // We may need to update the tree's selection in response to a tree state
+    // change. For example, if the tree's currently selected item is a
+    // descendant of an item whose branch was just collapsed, then the item
     // itself should become the newly-selected item.
     if (updateTreeSelection) {
       tree.maybeUpdateSelection(this, this.open);