Fixes Issue #983.
This change fixes an issue where the iframe shim used on IE6/7 to
prevent scrollbars from peeking through is not being hidden properly
when setVisible(false) is called. This also changes PopupPanel's
setVisible implementation to rely on visibility: hidden instead of
display:none, which ensures that the PopupPanel's size is accurate
even while it is not visible.
Patch by: bobv
Review by: knorton
git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@1007 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/user/src/com/google/gwt/user/client/ui/PopupPanel.java b/user/src/com/google/gwt/user/client/ui/PopupPanel.java
index 03cc1db..f9ee67d 100644
--- a/user/src/com/google/gwt/user/client/ui/PopupPanel.java
+++ b/user/src/com/google/gwt/user/client/ui/PopupPanel.java
@@ -260,6 +260,25 @@
DOM.setStyleAttribute(elem, "left", left + "px");
DOM.setStyleAttribute(elem, "top", top + "px");
}
+
+ /**
+ * Sets whether this object is visible.
+ *
+ * @param visible <code>true</code> to show the object, <code>false</code>
+ * to hide it
+ */
+ public void setVisible(boolean visible) {
+ // We use visibility here instead of UIObject's default of display
+ // Because the panel is absolutely positioned, this will not create
+ // "holes" in displayed contents and it allows normal layout passes
+ // to occur so the size of the PopupPanel can be reliably determined.
+ DOM.setStyleAttribute(getElement(), "visibility",
+ visible ? "visible" : "hidden");
+
+ // If the PopupImpl creates an iframe shim, it's also necessary to hide it
+ // as well.
+ impl.setVisible(getElement(), visible);
+ }
/**
* Shows the popup. It must have a child widget before this method is called.
diff --git a/user/src/com/google/gwt/user/client/ui/impl/PopupImpl.java b/user/src/com/google/gwt/user/client/ui/impl/PopupImpl.java
index 0a07e5a..8900e47 100644
--- a/user/src/com/google/gwt/user/client/ui/impl/PopupImpl.java
+++ b/user/src/com/google/gwt/user/client/ui/impl/PopupImpl.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
@@ -32,4 +32,7 @@
public void onShow(Element popup) {
}
+
+ public void setVisible(Element popup, boolean visible) {
+ }
}
diff --git a/user/src/com/google/gwt/user/client/ui/impl/PopupImplIE6.java b/user/src/com/google/gwt/user/client/ui/impl/PopupImplIE6.java
index b26256a..c01c87c 100644
--- a/user/src/com/google/gwt/user/client/ui/impl/PopupImplIE6.java
+++ b/user/src/com/google/gwt/user/client/ui/impl/PopupImplIE6.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
@@ -44,4 +44,8 @@
frame.style.setExpression('height', 'this.__popup.offsetHeight');
popup.parentElement.insertBefore(frame, popup);
}-*/;
+
+ public native void setVisible(Element popup, boolean visible) /*-{
+ popup.__frame.style.visibility = visible ? 'visible' : 'hidden';
+ }-*/;
}