]> source.dussan.org Git - vaadin-framework.git/commitdiff
Check for appeared or disappeared scrollbars when sizes have changed
authorLeif Åstrand <leif@vaadin.com>
Wed, 11 Apr 2012 07:22:04 +0000 (10:22 +0300)
committerLeif Åstrand <leif@vaadin.com>
Wed, 11 Apr 2012 07:22:04 +0000 (10:22 +0300)
src/com/vaadin/terminal/gwt/client/LayoutManager.java
src/com/vaadin/terminal/gwt/client/ui/AccordionConnector.java
src/com/vaadin/terminal/gwt/client/ui/PanelConnector.java
src/com/vaadin/terminal/gwt/client/ui/RootConnector.java
src/com/vaadin/terminal/gwt/client/ui/TabsheetConnector.java
src/com/vaadin/terminal/gwt/client/ui/WindowConnector.java
src/com/vaadin/terminal/gwt/client/ui/layout/LayoutDependencyTree.java
src/com/vaadin/terminal/gwt/client/ui/layout/MayScrollChildren.java [new file with mode: 0644]
src/com/vaadin/terminal/gwt/client/ui/layout/RequiresOverflowAutoFix.java [deleted file]

index 2ad2c95b6e3091a3656f74b866aaeafd12f1b1ab..09c811a2dece875e33c261585b7fa49505e2a236 100644 (file)
@@ -22,7 +22,7 @@ import com.vaadin.terminal.gwt.client.ui.VNotification;
 import com.vaadin.terminal.gwt.client.ui.layout.ElementResizeEvent;
 import com.vaadin.terminal.gwt.client.ui.layout.ElementResizeListener;
 import com.vaadin.terminal.gwt.client.ui.layout.LayoutDependencyTree;
-import com.vaadin.terminal.gwt.client.ui.layout.RequiresOverflowAutoFix;
+import com.vaadin.terminal.gwt.client.ui.layout.MayScrollChildren;
 
 public class LayoutManager {
     private static final String LOOP_ABORT_MESSAGE = "Aborting layout after 100 passes. This would probably be an infinite loop.";
@@ -425,7 +425,7 @@ public class LayoutManager {
     }
 
     private void doOverflowAutoFix(ComponentConnector connector) {
-        if (connector.getParent() instanceof RequiresOverflowAutoFix
+        if (connector.getParent() instanceof MayScrollChildren
                 && BrowserInfo.get().requiresOverflowAutoFix()
                 && !"absolute".equals(connector.getWidget().getElement()
                         .getStyle().getPosition())) {
index 454e698ef1dcd93ba800de4d0b59bf065c0dab1c..f6d3a4c8697cc6520d5c16b5cd1a8a173cf69d24 100644 (file)
@@ -11,12 +11,12 @@ import com.vaadin.terminal.gwt.client.ApplicationConnection;
 import com.vaadin.terminal.gwt.client.ComponentConnector;
 import com.vaadin.terminal.gwt.client.UIDL;
 import com.vaadin.terminal.gwt.client.ui.VAccordion.StackItem;
-import com.vaadin.terminal.gwt.client.ui.layout.RequiresOverflowAutoFix;
+import com.vaadin.terminal.gwt.client.ui.layout.MayScrollChildren;
 import com.vaadin.ui.Accordion;
 
 @Component(Accordion.class)
 public class AccordionConnector extends TabsheetBaseConnector implements
-        SimpleManagedLayout, RequiresOverflowAutoFix {
+        SimpleManagedLayout, MayScrollChildren {
 
     @Override
     public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
index ebfdcbcfa2f72128ac9a55f853b2741f6fdb4885..c40f5baa3a8515ff6a5eb932d326a8d40be39edd 100644 (file)
@@ -18,13 +18,13 @@ import com.vaadin.terminal.gwt.client.Paintable;
 import com.vaadin.terminal.gwt.client.UIDL;
 import com.vaadin.terminal.gwt.client.communication.RpcProxy;
 import com.vaadin.terminal.gwt.client.communication.ServerRpc;
-import com.vaadin.terminal.gwt.client.ui.layout.RequiresOverflowAutoFix;
+import com.vaadin.terminal.gwt.client.ui.layout.MayScrollChildren;
 import com.vaadin.ui.Panel;
 
 @Component(Panel.class)
 public class PanelConnector extends AbstractComponentContainerConnector
         implements Paintable, SimpleManagedLayout, PostLayoutListener,
-        RequiresOverflowAutoFix {
+        MayScrollChildren {
 
     public interface PanelServerRPC extends ClickRPC, ServerRpc {
 
index c1603097cc6559f80543c325ab36806a06d4d8dc..e800ffd685ece2e621eb3e0a8a5d865f202f84df 100644 (file)
@@ -34,12 +34,12 @@ import com.vaadin.terminal.gwt.client.communication.ServerRpc;
 import com.vaadin.terminal.gwt.client.communication.StateChangeEvent;
 import com.vaadin.terminal.gwt.client.communication.StateChangeEvent.StateChangeHandler;
 import com.vaadin.terminal.gwt.client.ui.Component.LoadStyle;
-import com.vaadin.terminal.gwt.client.ui.layout.RequiresOverflowAutoFix;
+import com.vaadin.terminal.gwt.client.ui.layout.MayScrollChildren;
 import com.vaadin.ui.Root;
 
 @Component(value = Root.class, loadStyle = LoadStyle.EAGER)
 public class RootConnector extends AbstractComponentContainerConnector
-        implements Paintable, RequiresOverflowAutoFix {
+        implements Paintable, MayScrollChildren {
 
     public interface RootServerRPC extends ClickRPC, ServerRpc {
 
index fa8f57edb2f6995279043678ba5914d0b240e888..6b798752a48bbf7ddd50f46e06bddf73aed44e08 100644 (file)
@@ -9,12 +9,12 @@ import com.google.gwt.user.client.ui.Widget;
 import com.vaadin.terminal.gwt.client.ApplicationConnection;
 import com.vaadin.terminal.gwt.client.ComponentConnector;
 import com.vaadin.terminal.gwt.client.UIDL;
-import com.vaadin.terminal.gwt.client.ui.layout.RequiresOverflowAutoFix;
+import com.vaadin.terminal.gwt.client.ui.layout.MayScrollChildren;
 import com.vaadin.ui.TabSheet;
 
 @Component(TabSheet.class)
 public class TabsheetConnector extends TabsheetBaseConnector implements
-        SimpleManagedLayout, RequiresOverflowAutoFix {
+        SimpleManagedLayout, MayScrollChildren {
 
     @Override
     public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
index 043c3ee04128e496fc002cea1de7f7175bef1403..6dcd3e71e4eb1e29fa15bc3aec0eb5ebeb793422 100644 (file)
@@ -24,12 +24,12 @@ import com.vaadin.terminal.gwt.client.communication.RpcProxy;
 import com.vaadin.terminal.gwt.client.communication.ServerRpc;
 import com.vaadin.terminal.gwt.client.ui.PanelConnector.PanelState;
 import com.vaadin.terminal.gwt.client.ui.ShortcutActionHandler.BeforeShortcutActionListener;
-import com.vaadin.terminal.gwt.client.ui.layout.RequiresOverflowAutoFix;
+import com.vaadin.terminal.gwt.client.ui.layout.MayScrollChildren;
 
 @Component(value = com.vaadin.ui.Window.class)
 public class WindowConnector extends AbstractComponentContainerConnector
         implements Paintable, BeforeShortcutActionListener,
-        SimpleManagedLayout, PostLayoutListener, RequiresOverflowAutoFix {
+        SimpleManagedLayout, PostLayoutListener, MayScrollChildren {
 
     public interface WindowServerRPC extends ClickRPC, ServerRpc {
     }
index 2e6dc34a4933311619734cd56e362407fb9d4979..52b530823aa5c168aa17750254d026bffd31f7c3 100644 (file)
@@ -221,6 +221,41 @@ public class LayoutDependencyTree {
                     layoutDependency.propagatePostLayoutMeasure();
                 }
             }
+
+            // Should also go through the hierarchy to discover appeared or
+            // disappeared scrollbars
+            LayoutDependency potentiallyChangedScrollbar = findPotentiallyChangedScrollbar();
+            if (potentiallyChangedScrollbar != null) {
+                potentiallyChangedScrollbar.setNeedsMeasure(true);
+            }
+
+        }
+
+        /**
+         * Go up the hierarchy to find a component whose size might have changed
+         * in the other direction because changes to this component causes
+         * scrollbars to appear or disappear.
+         * 
+         * @return
+         */
+        private LayoutDependency findPotentiallyChangedScrollbar() {
+            ComponentConnector currentConnector = connector;
+            while (true) {
+                ComponentContainerConnector parent = currentConnector
+                        .getParent();
+                if (parent == null) {
+                    return null;
+                }
+                if (parent instanceof MayScrollChildren) {
+                    return getDependency(currentConnector,
+                            getOppositeDirection());
+                }
+                currentConnector = parent;
+            }
+        }
+
+        private int getOppositeDirection() {
+            return direction == HORIZONTAL ? VERTICAL : HORIZONTAL;
         }
 
         public void markAsLayouted() {
diff --git a/src/com/vaadin/terminal/gwt/client/ui/layout/MayScrollChildren.java b/src/com/vaadin/terminal/gwt/client/ui/layout/MayScrollChildren.java
new file mode 100644 (file)
index 0000000..62c9937
--- /dev/null
@@ -0,0 +1,10 @@
+/*
+@VaadinApache2LicenseForJavaFiles@
+ */
+package com.vaadin.terminal.gwt.client.ui.layout;
+
+import com.vaadin.terminal.gwt.client.ComponentContainerConnector;
+
+public interface MayScrollChildren extends ComponentContainerConnector {
+
+}
diff --git a/src/com/vaadin/terminal/gwt/client/ui/layout/RequiresOverflowAutoFix.java b/src/com/vaadin/terminal/gwt/client/ui/layout/RequiresOverflowAutoFix.java
deleted file mode 100644 (file)
index 18e82c8..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-/*
-@VaadinApache2LicenseForJavaFiles@
- */
-package com.vaadin.terminal.gwt.client.ui.layout;
-
-import com.vaadin.terminal.gwt.client.ComponentContainerConnector;
-
-public interface RequiresOverflowAutoFix extends ComponentContainerConnector {
-
-}