A set of fixes for three layout issues: 4160, 4241, and 4243.
Review by: jlabanca (desk check)

git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@7250 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/user/src/com/google/gwt/user/client/ui/DockLayoutPanel.java b/user/src/com/google/gwt/user/client/ui/DockLayoutPanel.java
index 8653dec..54491f3 100644
--- a/user/src/com/google/gwt/user/client/ui/DockLayoutPanel.java
+++ b/user/src/com/google/gwt/user/client/ui/DockLayoutPanel.java
@@ -189,7 +189,7 @@
   }
 
   public void animate(int duration) {
-    animate(0, null);
+    animate(duration, null);
   }
 
   public void animate(int duration, final Layout.AnimationCallback callback) {
@@ -338,7 +338,15 @@
     widget.removeFromParent();
 
     // Logical attach.
-    getChildren().add(widget);
+    WidgetCollection children = getChildren();
+    if (before == null) {
+      children.add(widget);
+    }
+    else {
+      int index = children.indexOf(before);
+      children.insert(widget, index);
+    }
+
     if (direction == Direction.CENTER) {
       center = widget;
     }
diff --git a/user/src/com/google/gwt/user/client/ui/StackLayoutPanel.java b/user/src/com/google/gwt/user/client/ui/StackLayoutPanel.java
index 743d79d..4552f6f 100644
--- a/user/src/com/google/gwt/user/client/ui/StackLayoutPanel.java
+++ b/user/src/com/google/gwt/user/client/ui/StackLayoutPanel.java
@@ -211,7 +211,7 @@
   }
 
   private void animate(int duration) {
-    int top = 0, bottom = 0;
+    double top = 0, bottom = 0;
     int i = 0, visibleIndex = -1;
     for (; i < layoutData.size(); ++i) {
       LayoutData data = layoutData.get(i);