summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorHenri Sara <henri.sara@itmill.com>2011-09-21 11:37:14 +0000
committerHenri Sara <henri.sara@itmill.com>2011-09-21 11:37:14 +0000
commit56742bd36ede2a9b497316087908ec99351ef4f6 (patch)
tree51e9dd226d8b14bfc87bb5b9fff410dd7c816ef8 /src
parenta44f6c12da95c3fe34dc3039f436127bed87d8d5 (diff)
parentf6f617b28fce628283769505c90ab35da6ec9709 (diff)
downloadvaadin-framework-56742bd36ede2a9b497316087908ec99351ef4f6.tar.gz
vaadin-framework-56742bd36ede2a9b497316087908ec99351ef4f6.zip
Merged changes from 6.6
svn changeset:21212/svn branch:6.7
Diffstat (limited to 'src')
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/VMenuBar.java48
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/VView.java33
2 files changed, 79 insertions, 2 deletions
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VMenuBar.java b/src/com/vaadin/terminal/gwt/client/ui/VMenuBar.java
index f74ff4a1f5..7f9707181d 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/VMenuBar.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/VMenuBar.java
@@ -12,6 +12,8 @@ import com.google.gwt.core.client.GWT;
import com.google.gwt.core.client.Scheduler;
import com.google.gwt.core.client.Scheduler.ScheduledCommand;
import com.google.gwt.dom.client.NodeList;
+import com.google.gwt.dom.client.Style;
+import com.google.gwt.dom.client.Style.Overflow;
import com.google.gwt.dom.client.Style.Unit;
import com.google.gwt.event.dom.client.FocusEvent;
import com.google.gwt.event.dom.client.FocusHandler;
@@ -724,6 +726,9 @@ public class VMenuBar extends SimpleFocusablePanel implements Paintable,
left = shadowSpace;
}
}
+
+ top = adjustPopupHeight(top, shadowSpace);
+
popup.setPopupPosition(left, top);
// IE7 really tests one's patience sometimes
@@ -749,6 +754,49 @@ public class VMenuBar extends SimpleFocusablePanel implements Paintable,
}
}
+ private int adjustPopupHeight(int top, final int shadowSpace) {
+ // Check that the popup will fit the screen
+ int availableHeight = RootPanel.getBodyElement().getOffsetHeight()
+ - top - shadowSpace;
+ int missingHeight = popup.getOffsetHeight() - availableHeight;
+ if (missingHeight > 0) {
+ // First move the top of the popup to get more space
+ // Don't move above top of screen, don't move more than needed
+ int moveUpBy = Math.min(top - shadowSpace, missingHeight);
+
+ // Update state
+ top -= moveUpBy;
+ missingHeight -= moveUpBy;
+ availableHeight += moveUpBy;
+
+ if (missingHeight > 0) {
+ int contentWidth = visibleChildMenu.getOffsetWidth();
+
+ // If there's still not enough room, limit height to fit and add
+ // a scroll bar
+ Style style = popup.getElement().getStyle();
+ style.setHeight(availableHeight, Unit.PX);
+ style.setOverflowY(Overflow.SCROLL);
+
+ // Make room for the scroll bar
+ if (BrowserInfo.get().isIE6()) {
+ // IE6 renders the sub menu arrow icons on the scroll bar
+ // unless we add some padding
+ style.setPaddingRight(Util.getNativeScrollbarSize(),
+ Unit.PX);
+ } else {
+ // For other browsers, adjusting the width of the popup is
+ // enough
+ style.setWidth(
+ contentWidth + Util.getNativeScrollbarSize(),
+ Unit.PX);
+ }
+ popup.updateShadowSizeAndPosition();
+ }
+ }
+ return top;
+ }
+
/**
* Hides the submenu of an item
*
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VView.java b/src/com/vaadin/terminal/gwt/client/ui/VView.java
index e49b83447f..af87610944 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/VView.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/VView.java
@@ -14,6 +14,8 @@ import com.google.gwt.core.client.Scheduler;
import com.google.gwt.core.client.Scheduler.ScheduledCommand;
import com.google.gwt.dom.client.DivElement;
import com.google.gwt.dom.client.Document;
+import com.google.gwt.dom.client.Style;
+import com.google.gwt.dom.client.Style.Display;
import com.google.gwt.event.dom.client.DomEvent.Type;
import com.google.gwt.event.logical.shared.ResizeEvent;
import com.google.gwt.event.logical.shared.ResizeHandler;
@@ -560,11 +562,38 @@ public class VView extends SimplePanel implements Container, ResizeHandler,
@Override
public int getWidth() {
- int w = getElement().getOffsetWidth() - getExcessWidth();
+ int w = getRealWidth();
if (w < 10 && BrowserInfo.get().isIE7()) {
// Overcome an IE7 bug #3295
Util.shakeBodyElement();
- w = getElement().getOffsetWidth() - getExcessWidth();
+ w = getRealWidth();
+ }
+ return w;
+ }
+
+ private int getRealWidth() {
+ if (connection.getConfiguration().isStandalone()) {
+ return getElement().getOffsetWidth() - getExcessWidth();
+ }
+
+ // If not running standalone, we might be inside elements that don't
+ // shrink with the browser window if our own components have
+ // calculated widths (#3125)
+ Element layoutElement = ((Widget) layout).getElement();
+ Style layoutStyle = layoutElement.getStyle();
+
+ // Set display:none to the entire application to get a width not
+ // influenced by the contents
+ String originalDisplay = layoutStyle.getDisplay();
+ layoutStyle.setDisplay(Display.NONE);
+
+ int w = getElement().getOffsetWidth() - getExcessWidth();
+
+ // Then restore the old display style before returning
+ if (originalDisplay.length() == 0) {
+ layoutStyle.clearDisplay();
+ } else {
+ layoutStyle.setDisplay(Display.valueOf(originalDisplay));
}
return w;
}