diff options
author | Leif Åstrand <leif@vaadin.com> | 2013-05-17 16:14:27 +0300 |
---|---|---|
committer | Leif Åstrand <leif@vaadin.com> | 2013-05-17 16:14:27 +0300 |
commit | 73a50dbf002b381411a7c6ca1d6b4e59a93bbe0c (patch) | |
tree | 49dfcde7194cf82cc3e96519170decaf12051992 /client | |
parent | 5a9303869ce6912afcb158f6b75b3202d77a40a1 (diff) | |
parent | 0c8edf1ff0502070d92dc6d8ef5af304d7570934 (diff) | |
download | vaadin-framework-73a50dbf002b381411a7c6ca1d6b4e59a93bbe0c.tar.gz vaadin-framework-73a50dbf002b381411a7c6ca1d6b4e59a93bbe0c.zip |
Merge changes from origin/7.0
1a6200e Merge #6880 test from 6.8; fix itself is not needed in Vaadin 7
67696f3 SQLContainer.indexOfId() also searches backwards (#11849, #10376)
611e5f9 Test for #11267 adapted from 6.8.
609acd1 Fixed table height rendering in Android 2.3 #11331
63dd611 Centers VOverlays in visual viewport on iOS, Android, fixes #11614
5a33d7d Test for #11775
0c8edf1 Avoid marking AbstractField dirty in primitive getters (#11201)
Change-Id: I7437e0b249c1a95372d6f349e9d6336fb85f08a4
Diffstat (limited to 'client')
-rw-r--r-- | client/src/com/vaadin/client/BrowserInfo.java | 9 | ||||
-rw-r--r-- | client/src/com/vaadin/client/ui/VOverlay.java | 65 | ||||
-rw-r--r-- | client/src/com/vaadin/client/ui/VScrollTable.java | 16 |
3 files changed, 90 insertions, 0 deletions
diff --git a/client/src/com/vaadin/client/BrowserInfo.java b/client/src/com/vaadin/client/BrowserInfo.java index 73f3a68193..b3490c3ca4 100644 --- a/client/src/com/vaadin/client/BrowserInfo.java +++ b/client/src/com/vaadin/client/BrowserInfo.java @@ -396,10 +396,19 @@ public class BrowserInfo { && (getOperatingSystemMajorVersion() == 3 || getOperatingSystemMajorVersion() == 4); } + public boolean isAndroid23() { + return isAndroid() && getOperatingSystemMajorVersion() == 2 + && getOperatingSystemMinorVersion() == 3; + } + private int getOperatingSystemMajorVersion() { return browserDetails.getOperatingSystemMajorVersion(); } + private int getOperatingSystemMinorVersion() { + return browserDetails.getOperatingSystemMinorVersion(); + } + /** * Returns the browser major version e.g., 3 for Firefox 3.5, 4 for Chrome * 4, 8 for Internet Explorer 8. diff --git a/client/src/com/vaadin/client/ui/VOverlay.java b/client/src/com/vaadin/client/ui/VOverlay.java index d35201460e..9e809758ca 100644 --- a/client/src/com/vaadin/client/ui/VOverlay.java +++ b/client/src/com/vaadin/client/ui/VOverlay.java @@ -27,6 +27,7 @@ import com.google.gwt.event.logical.shared.CloseEvent; import com.google.gwt.event.logical.shared.CloseHandler; import com.google.gwt.user.client.DOM; import com.google.gwt.user.client.Element; +import com.google.gwt.user.client.Window; import com.google.gwt.user.client.ui.PopupPanel; import com.google.gwt.user.client.ui.RootPanel; import com.google.gwt.user.client.ui.Widget; @@ -689,4 +690,68 @@ public class VOverlay extends PopupPanel implements CloseHandler<PopupPanel> { return container; } + @Override + public void center() { + super.center(); + + // Some devices can be zoomed in, we should center to the visual + // viewport for those devices + BrowserInfo b = BrowserInfo.get(); + if (b.isAndroid() || b.isIOS()) { + int left = (getVisualViewportWidth() - getOffsetWidth()) >> 1; + int top = (getVisualViewportHeight() - getOffsetHeight()) >> 1; + setPopupPosition(Math.max(Window.getScrollLeft() + left, 0), + Math.max(Window.getScrollTop() + top, 0)); + } + + } + + /** + * Gets the visual viewport width, which is useful for e.g iOS where the + * view can be zoomed in while keeping the layout viewport intact. + * + * Falls back to layout viewport; for those browsers/devices the difference + * is that the scrollbar with is included (if there is a scrollbar). + * + * @since 7.0.7 + * @return + */ + private int getVisualViewportWidth() { + int w = (int) getSubpixelInnerWidth(); + if (w < 0) { + return Window.getClientWidth(); + } else { + return w; + } + } + + /** + * Gets the visual viewport height, which is useful for e.g iOS where the + * view can be zoomed in while keeping the layout viewport intact. + * + * Falls back to layout viewport; for those browsers/devices the difference + * is that the scrollbar with is included (if there is a scrollbar). + * + * @since 7.0.7 + * @return + */ + private int getVisualViewportHeight() { + int h = (int) getSubpixelInnerHeight(); + if (h < 0) { + return Window.getClientHeight(); + } else { + return h; + } + } + + private native double getSubpixelInnerWidth() + /*-{ + return $wnd.innerWidth !== undefined ? $wnd.innerWidth : -1; + }-*/; + + private native double getSubpixelInnerHeight() + /*-{ + return $wnd.innerHeight !== undefined ? $wnd.innerHeight :-1; + }-*/; + } diff --git a/client/src/com/vaadin/client/ui/VScrollTable.java b/client/src/com/vaadin/client/ui/VScrollTable.java index 8705a826cc..e2e82a1959 100644 --- a/client/src/com/vaadin/client/ui/VScrollTable.java +++ b/client/src/com/vaadin/client/ui/VScrollTable.java @@ -6692,6 +6692,17 @@ public class VScrollTable extends FlowPanel implements HasWidgets, private void setContainerHeight() { if (!isDynamicHeight()) { + + /* + * Android 2.3 cannot measure the height of the inline-block + * properly, and will return the wrong offset height. So for android + * 2.3 we set the element to a block element while measuring and + * then restore it which yields the correct result. #11331 + */ + if (BrowserInfo.get().isAndroid23()) { + getElement().getStyle().setDisplay(Display.BLOCK); + } + containerHeight = getOffsetHeight(); containerHeight -= showColHeaders ? tHead.getOffsetHeight() : 0; containerHeight -= tFoot.getOffsetHeight(); @@ -6699,7 +6710,12 @@ public class VScrollTable extends FlowPanel implements HasWidgets, if (containerHeight < 0) { containerHeight = 0; } + scrollBodyPanel.setHeight(containerHeight + "px"); + + if (BrowserInfo.get().isAndroid23()) { + getElement().getStyle().clearDisplay(); + } } } |