From c351b6464a6154205a8bd6f79880df968df68777 Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Wed, 6 Nov 2013 15:26:42 +0200 Subject: Revert "Make Panel scroll the correct div (#12736)" Revert "Reverted change in how hack works (#12727, #12736)" Revert "Fixes the handling of the scroll position of a Window (#12736)" Revert "Recovering scroll position after regression problems. (#12727)" Revert "Ticket #12727 - Panels get unnecessary scroll bars in WebKit when content is 100% wide." This reverts commit 6a63d12afc5a4bf3971dd016f8e2761cd27bcc74. This reverts commit c48c94dc23da22b6d885c69b0bc697257f9dbf11. This reverts commit 017bd0684c7d6c8475c8b43514e6f3998095c8d6. This reverts commit 51a46a038fe0353f4babfd8218153eb68e2602ca. This reverts commit ab5b20cf502f99944c82f619ffef387f0525e8ba. Test cases were left as-is as the issue (#12736) still needs a workaround Change-Id: I0b6c2afb4a9be8629f2a8f880a8ae8d0a6d5088f --- client/src/com/vaadin/client/Util.java | 51 ---------------------------- client/src/com/vaadin/client/ui/VPanel.java | 2 -- client/src/com/vaadin/client/ui/VWindow.java | 33 +++++++++++++++--- 3 files changed, 29 insertions(+), 57 deletions(-) (limited to 'client') diff --git a/client/src/com/vaadin/client/Util.java b/client/src/com/vaadin/client/Util.java index fd7a354569..7c7978be09 100644 --- a/client/src/com/vaadin/client/Util.java +++ b/client/src/com/vaadin/client/Util.java @@ -32,7 +32,6 @@ import com.google.gwt.dom.client.Node; import com.google.gwt.dom.client.NodeList; import com.google.gwt.dom.client.Style; import com.google.gwt.dom.client.Style.Display; -import com.google.gwt.dom.client.Style.Unit; import com.google.gwt.dom.client.Touch; import com.google.gwt.user.client.Command; import com.google.gwt.user.client.DOM; @@ -555,56 +554,6 @@ public class Util { } - /** - * Prevents some browsers from adding scroll bars to a component (such as a - * Window) whose contents fit in the component. - *

- * See: bugs #11994 and #12736. - * - * @param contentNode - * an element that is scrollable - * - * @since 7.1.8 - */ - public static void removeUnneededScrollbars(final Element scrollable) { - if (BrowserInfo.get().isWebkit()) { - - /* - * Shake up the DOM a bit to make the window shed unnecessary - * scrollbars and resize correctly afterwards. This resulting code - * took over a week to summon forth, and involved some pretty hairy - * black magic. Don't touch it unless you know what you're doing! - * Fixes ticket #11994. Later modified to fix ticket #12736. - */ - Scheduler.get().scheduleFinally(new ScheduledCommand() { - - @Override - public void execute() { - // Adjusting the width or height may change the scroll - // position, so store the current position - int horizontalScrollPosition = scrollable.getScrollLeft(); - int verticalScrollPosition = scrollable.getScrollTop(); - - final String oldWidth = scrollable.getStyle().getWidth(); - final String oldHeight = scrollable.getStyle().getHeight(); - - scrollable.getStyle().setWidth(110, Unit.PCT); - scrollable.getOffsetWidth(); - scrollable.getStyle().setProperty("width", oldWidth); - scrollable.getStyle().setHeight(110, Unit.PCT); - scrollable.getOffsetHeight(); - scrollable.getStyle().setProperty("height", oldHeight); - - // Restore the scroll position - scrollable.setScrollLeft(horizontalScrollPosition); - scrollable.setScrollTop(verticalScrollPosition); - - } - }); - - } - } - /** * Parses shared state and fetches the relative size of the component. If a * dimension is not specified as relative it will return -1. If the shared diff --git a/client/src/com/vaadin/client/ui/VPanel.java b/client/src/com/vaadin/client/ui/VPanel.java index 307a2e4a91..6b02f079d1 100644 --- a/client/src/com/vaadin/client/ui/VPanel.java +++ b/client/src/com/vaadin/client/ui/VPanel.java @@ -24,7 +24,6 @@ import com.google.gwt.user.client.Event; import com.google.gwt.user.client.ui.SimplePanel; import com.vaadin.client.ApplicationConnection; import com.vaadin.client.Focusable; -import com.vaadin.client.Util; import com.vaadin.client.ui.ShortcutActionHandler.ShortcutActionHandlerOwner; import com.vaadin.client.ui.TouchScrollDelegate.TouchScrollHandler; @@ -207,6 +206,5 @@ public class VPanel extends SimplePanel implements ShortcutActionHandlerOwner, touchScrollHandler = TouchScrollDelegate.enableTouchScrolling(this); } touchScrollHandler.addElement(contentNode); - Util.removeUnneededScrollbars(contentNode); } } diff --git a/client/src/com/vaadin/client/ui/VWindow.java b/client/src/com/vaadin/client/ui/VWindow.java index 62937b6a67..396169eb8c 100644 --- a/client/src/com/vaadin/client/ui/VWindow.java +++ b/client/src/com/vaadin/client/ui/VWindow.java @@ -345,11 +345,36 @@ public class VWindow extends VOverlay implements ShortcutActionHandlerOwner, if (!visibilityChangesDisabled) { super.setVisible(visible); } + if (visible && BrowserInfo.get().isWebkit()) { - Util.removeUnneededScrollbars((Element) contents - .getFirstChildElement()); - updateContentsSize(); - positionOrSizeUpdated(); + + /* + * Shake up the DOM a bit to make the window shed unnecessary + * scrollbars and resize correctly afterwards. This resulting code + * took over a week to summon forth, and involved some pretty hairy + * black magic. Don't touch it unless you know what you're doing! + * Fixes ticket #11994 + */ + Scheduler.get().scheduleFinally(new ScheduledCommand() { + @Override + public void execute() { + final com.google.gwt.dom.client.Element scrollable = contents + .getFirstChildElement(); + final String oldWidth = scrollable.getStyle().getWidth(); + final String oldHeight = scrollable.getStyle().getHeight(); + + scrollable.getStyle().setWidth(110, Unit.PCT); + scrollable.getOffsetWidth(); + scrollable.getStyle().setProperty("width", oldWidth); + + scrollable.getStyle().setHeight(110, Unit.PCT); + scrollable.getOffsetHeight(); + scrollable.getStyle().setProperty("height", oldHeight); + + updateContentsSize(); + positionOrSizeUpdated(); + } + }); } } -- cgit v1.2.3 From 2e3e877e1bf99bbaf89d5dc45625ab44322c20e0 Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Wed, 6 Nov 2013 15:11:34 +0200 Subject: Fix scroll position handling in Window Webkit hack (#12736) Change-Id: If4d17c34b2d20ad983f21b892d3ab4c68f511780 --- client/src/com/vaadin/client/ui/VWindow.java | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'client') diff --git a/client/src/com/vaadin/client/ui/VWindow.java b/client/src/com/vaadin/client/ui/VWindow.java index 396169eb8c..73b57c7e5b 100644 --- a/client/src/com/vaadin/client/ui/VWindow.java +++ b/client/src/com/vaadin/client/ui/VWindow.java @@ -360,6 +360,12 @@ public class VWindow extends VOverlay implements ShortcutActionHandlerOwner, public void execute() { final com.google.gwt.dom.client.Element scrollable = contents .getFirstChildElement(); + + // Adjusting the width or height may change the scroll + // position, so store the current position + int horizontalScrollPosition = scrollable.getScrollLeft(); + int verticalScrollPosition = scrollable.getScrollTop(); + final String oldWidth = scrollable.getStyle().getWidth(); final String oldHeight = scrollable.getStyle().getHeight(); @@ -371,6 +377,10 @@ public class VWindow extends VOverlay implements ShortcutActionHandlerOwner, scrollable.getOffsetHeight(); scrollable.getStyle().setProperty("height", oldHeight); + // Restore the scroll position + scrollable.setScrollLeft(horizontalScrollPosition); + scrollable.setScrollTop(verticalScrollPosition); + updateContentsSize(); positionOrSizeUpdated(); } -- cgit v1.2.3 From 13858578966dad8cf5a6f10448b42961817beafc Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Fri, 8 Nov 2013 11:26:08 +0200 Subject: Do not apply fix on mobile devices or devices without scrollbars (#12736) Change-Id: I38ef869d87418c18197a59a5ecd3fb7e12e1c02e --- client/src/com/vaadin/client/BrowserInfo.java | 16 ++++++++++++++++ client/src/com/vaadin/client/ui/VWindow.java | 3 ++- 2 files changed, 18 insertions(+), 1 deletion(-) (limited to 'client') diff --git a/client/src/com/vaadin/client/BrowserInfo.java b/client/src/com/vaadin/client/BrowserInfo.java index 273964c889..78c5c1f59f 100644 --- a/client/src/com/vaadin/client/BrowserInfo.java +++ b/client/src/com/vaadin/client/BrowserInfo.java @@ -346,6 +346,22 @@ public class BrowserInfo { && Util.getNativeScrollbarSize() > 0; } + /** + * Indicates whether the browser might require juggling to properly update + * sizes inside elements with overflow: auto when adjusting absolutely + * positioned elements. + *

+ * See https://bugs.webkit.org/show_bug.cgi?id=123958 and + * http://code.google.com/p/chromium/issues/detail?id=316549 + * + * @since 7.1.8 + * @return true if the browser requires the workaround, + * otherwise false + */ + public boolean requiresPositionAbsoluteOverflowAutoFix() { + return (getWebkitVersion() > 0) && Util.getNativeScrollbarSize() > 0; + } + /** * Checks if the browser is run on iOS * diff --git a/client/src/com/vaadin/client/ui/VWindow.java b/client/src/com/vaadin/client/ui/VWindow.java index 73b57c7e5b..03a65e8ece 100644 --- a/client/src/com/vaadin/client/ui/VWindow.java +++ b/client/src/com/vaadin/client/ui/VWindow.java @@ -346,7 +346,8 @@ public class VWindow extends VOverlay implements ShortcutActionHandlerOwner, super.setVisible(visible); } - if (visible && BrowserInfo.get().isWebkit()) { + if (visible + && BrowserInfo.get().requiresPositionAbsoluteOverflowAutoFix()) { /* * Shake up the DOM a bit to make the window shed unnecessary -- cgit v1.2.3 From 0a2cf2c429fca3be697dcf37d386a4607d4bdbc3 Mon Sep 17 00:00:00 2001 From: Johannes Dahlström Date: Thu, 7 Nov 2013 19:55:32 +0200 Subject: Prevent showing "Session Expired" notification if navigating away (#12298) Currently only works if navigation initiated via Page.open(url, "_self"). Page.setLocation should be changed in 7.2 to use "_self" as well (#12925) Change-Id: I56ad66ffbbd1a83b64999307d23028cbd84bb508 --- client/src/com/vaadin/client/ui/VUI.java | 3 --- .../src/com/vaadin/client/ui/ui/UIConnector.java | 22 ++++++++++++---------- 2 files changed, 12 insertions(+), 13 deletions(-) (limited to 'client') diff --git a/client/src/com/vaadin/client/ui/VUI.java b/client/src/com/vaadin/client/ui/VUI.java index 4817bf9304..ba3495743d 100644 --- a/client/src/com/vaadin/client/ui/VUI.java +++ b/client/src/com/vaadin/client/ui/VUI.java @@ -100,9 +100,6 @@ public class VUI extends SimplePanel implements ResizeHandler, /** stored height of parent for embedded application auto-resize */ private int parentHeight; - /** For internal use only. May be removed or replaced in the future. */ - public boolean rendering; - /** For internal use only. May be removed or replaced in the future. */ public boolean immediate; diff --git a/client/src/com/vaadin/client/ui/ui/UIConnector.java b/client/src/com/vaadin/client/ui/ui/UIConnector.java index 8813d70609..149d99de17 100644 --- a/client/src/com/vaadin/client/ui/ui/UIConnector.java +++ b/client/src/com/vaadin/client/ui/ui/UIConnector.java @@ -130,11 +130,16 @@ public class UIConnector extends AbstractSingleComponentContainerConnector Scheduler.get().scheduleDeferred(new ScheduledCommand() { @Override public void execute() { - if (sessionExpired) { - getConnection().showSessionExpiredError(null); - } else { - getState().enabled = false; - updateEnabledState(getState().enabled); + // Only notify user if we're still running and not eg. + // navigating away (#12298) + if (getConnection().isApplicationRunning()) { + if (sessionExpired) { + getConnection().showSessionExpiredError(null); + } else { + getState().enabled = false; + updateEnabledState(getState().enabled); + } + getConnection().setApplicationRunning(false); } } }); @@ -192,7 +197,6 @@ public class UIConnector extends AbstractSingleComponentContainerConnector @Override public void updateFromUIDL(final UIDL uidl, ApplicationConnection client) { ConnectorMap paintableMap = ConnectorMap.get(getConnection()); - getWidget().rendering = true; getWidget().id = getConnectorId(); boolean firstPaint = getWidget().connection == null; getWidget().connection = client; @@ -285,9 +289,8 @@ public class UIConnector extends AbstractSingleComponentContainerConnector childIndex++; } if (isClosed) { - // don't render the content, something else will be opened to this - // browser view - getWidget().rendering = false; + // We're navigating away, so stop the application. + client.setApplicationRunning(false); return; } @@ -397,7 +400,6 @@ public class UIConnector extends AbstractSingleComponentContainerConnector } }); } - getWidget().rendering = false; } /** -- cgit v1.2.3 From 84521fa4b432ca8107a030a6bebfdf484bbee35a Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Mon, 11 Nov 2013 16:41:16 +0200 Subject: Use correct type for UIDL value to avoid development mode problems (#12545) Change-Id: Ib183e352fa64cb5c8f4d499ecb194768b18a16d6 --- client/src/com/vaadin/client/ui/VScrollTable.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'client') diff --git a/client/src/com/vaadin/client/ui/VScrollTable.java b/client/src/com/vaadin/client/ui/VScrollTable.java index 48fd85144f..d1d73f4e91 100644 --- a/client/src/com/vaadin/client/ui/VScrollTable.java +++ b/client/src/com/vaadin/client/ui/VScrollTable.java @@ -4232,8 +4232,8 @@ public class VScrollTable extends FlowPanel implements HasWidgets, // Already updated by setColWidth called from // TableHeads.updateCellsFromUIDL in case of a server // side resize - final String width = col.getStringAttribute("width"); - c.setWidth(Integer.parseInt(width), true); + final int width = col.getIntAttribute("width"); + c.setWidth(width, true); } } else if (recalcWidths) { c.setUndefinedWidth(); -- cgit v1.2.3