summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLeif Åstrand <leif@vaadin.com>2012-04-04 12:10:10 +0300
committerLeif Åstrand <leif@vaadin.com>2012-04-04 12:10:10 +0300
commitc84b02b1d82f839059a3ed985130ae0a3421bc32 (patch)
tree3c00f31be97fc43bca2a69967669d0328ebc5e5d /src
parentfa5f05b18b94a1b22f79a442ec3032489a4379f2 (diff)
downloadvaadin-framework-c84b02b1d82f839059a3ed985130ae0a3421bc32.tar.gz
vaadin-framework-c84b02b1d82f839059a3ed985130ae0a3421bc32.zip
Manage fix for overflow: auto in LayoutManager (#8615)
Diffstat (limited to 'src')
-rw-r--r--src/com/vaadin/terminal/gwt/client/BrowserInfo.java12
-rw-r--r--src/com/vaadin/terminal/gwt/client/LayoutManager.java38
-rw-r--r--src/com/vaadin/terminal/gwt/client/Util.java3
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/AccordionConnector.java3
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/PanelConnector.java7
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/RootConnector.java11
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/TabsheetConnector.java3
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/VAccordion.java3
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/VTabsheet.java1
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/VTabsheetPanel.java10
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/VView.java3
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/VWindow.java1
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/WindowConnector.java6
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/layout/RequiresOverflowAutoFix.java10
14 files changed, 73 insertions, 38 deletions
diff --git a/src/com/vaadin/terminal/gwt/client/BrowserInfo.java b/src/com/vaadin/terminal/gwt/client/BrowserInfo.java
index 50a59e4975..ef1dc481b1 100644
--- a/src/com/vaadin/terminal/gwt/client/BrowserInfo.java
+++ b/src/com/vaadin/terminal/gwt/client/BrowserInfo.java
@@ -300,4 +300,16 @@ public class BrowserInfo {
return touchDevice;
}
+ /**
+ * Indicates whether the browser might require juggling to properly update
+ * sizes inside elements with overflow: auto.
+ *
+ * @return <code>true</code> if the browser requires the workaround,
+ * otherwise <code>false</code>
+ */
+ public boolean requiresOverflowAutoFix() {
+ return (getWebkitVersion() > 0 || getOperaVersion() >= 11)
+ && Util.getNativeScrollbarSize() > 0;
+ }
+
}
diff --git a/src/com/vaadin/terminal/gwt/client/LayoutManager.java b/src/com/vaadin/terminal/gwt/client/LayoutManager.java
index f7c5570072..d772f7cb37 100644
--- a/src/com/vaadin/terminal/gwt/client/LayoutManager.java
+++ b/src/com/vaadin/terminal/gwt/client/LayoutManager.java
@@ -12,12 +12,14 @@ import java.util.Set;
import com.google.gwt.core.client.Duration;
import com.google.gwt.core.client.JsArrayString;
import com.google.gwt.dom.client.Element;
+import com.google.gwt.dom.client.Style.Unit;
import com.vaadin.terminal.gwt.client.MeasuredSize.MeasureResult;
import com.vaadin.terminal.gwt.client.ui.ManagedLayout;
import com.vaadin.terminal.gwt.client.ui.PostLayoutListener;
import com.vaadin.terminal.gwt.client.ui.SimpleManagedLayout;
import com.vaadin.terminal.gwt.client.ui.VNotification;
import com.vaadin.terminal.gwt.client.ui.layout.LayoutDependencyTree;
+import com.vaadin.terminal.gwt.client.ui.layout.RequiresOverflowAutoFix;
public class LayoutManager {
private static final String LOOP_ABORT_MESSAGE = "Aborting layout after 100 passes. This would probably be an infinite loop.";
@@ -30,6 +32,8 @@ public class LayoutManager {
private final Collection<ManagedLayout> needsHorizontalLayout = new HashSet<ManagedLayout>();
private final Collection<ManagedLayout> needsVerticalLayout = new HashSet<ManagedLayout>();
+ private final Collection<ComponentConnector> pendingOverflowFixes = new HashSet<ComponentConnector>();
+
public void setConnection(ApplicationConnection connection) {
if (this.connection != null) {
throw new RuntimeException(
@@ -272,6 +276,26 @@ public class LayoutManager {
private int measureConnectors(LayoutDependencyTree layoutDependencyTree,
boolean measureAll) {
+ if (!pendingOverflowFixes.isEmpty()) {
+ Duration duration = new Duration();
+ for (ComponentConnector componentConnector : pendingOverflowFixes) {
+ componentConnector.getWidget().getElement().getParentElement()
+ .getStyle().setTop(1, Unit.PX);
+ }
+ for (ComponentConnector componentConnector : pendingOverflowFixes) {
+ componentConnector.getWidget().getElement().getParentElement()
+ .getOffsetHeight();
+ }
+ for (ComponentConnector componentConnector : pendingOverflowFixes) {
+ componentConnector.getWidget().getElement().getParentElement()
+ .getStyle().setTop(0, Unit.PX);
+ layoutDependencyTree.setNeedsMeasure(componentConnector, true);
+ }
+ VConsole.log("Did overflow fix for " + pendingOverflowFixes.size()
+ + " elements in " + duration.elapsedMillis() + " ms");
+ pendingOverflowFixes.clear();
+ }
+
int measureCount = 0;
if (measureAll) {
ComponentConnector[] connectors = ConnectorMap.get(connection)
@@ -306,6 +330,9 @@ public class LayoutManager {
MeasureResult measureResult = measuredAndUpdate(element, measuredSize,
layoutDependencyTree);
+ if (measureResult.isChanged()) {
+ doOverflowAutoFix(connector);
+ }
if (measureResult.isHeightChanged()) {
layoutDependencyTree.markHeightAsChanged(connector);
}
@@ -314,6 +341,15 @@ public class LayoutManager {
}
}
+ private void doOverflowAutoFix(ComponentConnector connector) {
+ if (connector.getParent() instanceof RequiresOverflowAutoFix
+ && BrowserInfo.get().requiresOverflowAutoFix()
+ && !"absolute".equals(connector.getWidget().getElement()
+ .getStyle().getPosition())) {
+ pendingOverflowFixes.add(connector);
+ }
+ }
+
private void measureNonPaintables(LayoutDependencyTree layoutDependencyTree) {
for (Element element : nonPaintableElements) {
MeasuredSize measuredSize = getMeasuredSize(element, null);
@@ -455,6 +491,7 @@ public class LayoutManager {
if (heightChanged) {
currentDependencyTree.markHeightAsChanged(component);
+ doOverflowAutoFix(component);
}
currentDependencyTree.setNeedsVerticalMeasure(component, false);
}
@@ -494,6 +531,7 @@ public class LayoutManager {
if (widthChanged) {
currentDependencyTree.markWidthAsChanged(component);
+ doOverflowAutoFix(component);
}
currentDependencyTree.setNeedsHorizontalMeasure(component, false);
}
diff --git a/src/com/vaadin/terminal/gwt/client/Util.java b/src/com/vaadin/terminal/gwt/client/Util.java
index faaad8c7d2..374d210379 100644
--- a/src/com/vaadin/terminal/gwt/client/Util.java
+++ b/src/com/vaadin/terminal/gwt/client/Util.java
@@ -433,8 +433,7 @@ public class Util {
public static void runWebkitOverflowAutoFix(final Element elem) {
// Add max version if fix lands sometime to Webkit
// Starting from Opera 11.00, also a problem in Opera
- if ((BrowserInfo.get().getWebkitVersion() > 0 || BrowserInfo.get()
- .getOperaVersion() >= 11) && getNativeScrollbarSize() > 0) {
+ if (BrowserInfo.get().requiresOverflowAutoFix()) {
final String originalOverflow = elem.getStyle().getProperty(
"overflow");
if ("hidden".equals(originalOverflow)) {
diff --git a/src/com/vaadin/terminal/gwt/client/ui/AccordionConnector.java b/src/com/vaadin/terminal/gwt/client/ui/AccordionConnector.java
index 7153d46e4d..488b07b4c1 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/AccordionConnector.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/AccordionConnector.java
@@ -11,9 +11,10 @@ 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;
public class AccordionConnector extends TabsheetBaseConnector implements
- SimpleManagedLayout {
+ SimpleManagedLayout, RequiresOverflowAutoFix {
@Override
public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
diff --git a/src/com/vaadin/terminal/gwt/client/ui/PanelConnector.java b/src/com/vaadin/terminal/gwt/client/ui/PanelConnector.java
index e39781952a..03e30071a3 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/PanelConnector.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/PanelConnector.java
@@ -15,11 +15,12 @@ import com.vaadin.terminal.gwt.client.ConnectorHierarchyChangedEvent;
import com.vaadin.terminal.gwt.client.LayoutManager;
import com.vaadin.terminal.gwt.client.MouseEventDetails;
import com.vaadin.terminal.gwt.client.UIDL;
-import com.vaadin.terminal.gwt.client.Util;
import com.vaadin.terminal.gwt.client.communication.ServerRpc;
+import com.vaadin.terminal.gwt.client.ui.layout.RequiresOverflowAutoFix;
public class PanelConnector extends AbstractComponentContainerConnector
- implements SimpleManagedLayout, PostLayoutListener {
+ implements SimpleManagedLayout, PostLayoutListener,
+ RequiresOverflowAutoFix {
public interface PanelServerRPC extends ClickRPC, ServerRpc {
@@ -231,8 +232,6 @@ public class PanelConnector extends AbstractComponentContainerConnector
// Read actual value back to ensure update logic is correct
panel.scrollTop = panel.contentNode.getScrollTop();
panel.scrollLeft = panel.contentNode.getScrollLeft();
-
- Util.runWebkitOverflowAutoFix(panel.contentNode);
}
public void postLayout() {
diff --git a/src/com/vaadin/terminal/gwt/client/ui/RootConnector.java b/src/com/vaadin/terminal/gwt/client/ui/RootConnector.java
index 988c1558cc..bfab87f90f 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/RootConnector.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/RootConnector.java
@@ -27,13 +27,14 @@ import com.vaadin.terminal.gwt.client.ConnectorMap;
import com.vaadin.terminal.gwt.client.Focusable;
import com.vaadin.terminal.gwt.client.MouseEventDetails;
import com.vaadin.terminal.gwt.client.UIDL;
-import com.vaadin.terminal.gwt.client.Util;
import com.vaadin.terminal.gwt.client.VConsole;
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.layout.RequiresOverflowAutoFix;
-public class RootConnector extends AbstractComponentContainerConnector {
+public class RootConnector extends AbstractComponentContainerConnector
+ implements RequiresOverflowAutoFix {
public interface RootServerRPC extends ClickRPC, ServerRpc {
@@ -271,12 +272,6 @@ public class RootConnector extends AbstractComponentContainerConnector {
getWidget().scrollable = false;
}
- // Safari workaround must be run after scrollTop is updated as it sets
- // scrollTop using a deferred command.
- if (BrowserInfo.get().isSafari()) {
- Util.runWebkitOverflowAutoFix(getWidget().getElement());
- }
-
getWidget().scrollIntoView(uidl);
if (uidl.hasAttribute(VView.FRAGMENT_VARIABLE)) {
diff --git a/src/com/vaadin/terminal/gwt/client/ui/TabsheetConnector.java b/src/com/vaadin/terminal/gwt/client/ui/TabsheetConnector.java
index 180fb8ac34..dc6793a0be 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/TabsheetConnector.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/TabsheetConnector.java
@@ -9,9 +9,10 @@ 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;
public class TabsheetConnector extends TabsheetBaseConnector implements
- SimpleManagedLayout {
+ SimpleManagedLayout, RequiresOverflowAutoFix {
@Override
public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VAccordion.java b/src/com/vaadin/terminal/gwt/client/ui/VAccordion.java
index c496522094..ae7130fe6d 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/VAccordion.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/VAccordion.java
@@ -252,9 +252,6 @@ public class VAccordion extends VTabsheetBase {
super.setWidth(maxWidth + "px");
openTab.setWidth(maxWidth);
}
-
- Util.runWebkitOverflowAutoFix(openTab.getContainerElement());
-
}
/**
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VTabsheet.java b/src/com/vaadin/terminal/gwt/client/ui/VTabsheet.java
index ffef5825f4..76e507a783 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/VTabsheet.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/VTabsheet.java
@@ -939,7 +939,6 @@ public class VTabsheet extends VTabsheetBase implements Focusable,
public void iLayout() {
updateTabScroller();
- tp.runWebkitOverflowAutoFix();
}
/**
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VTabsheetPanel.java b/src/com/vaadin/terminal/gwt/client/ui/VTabsheetPanel.java
index 68270da85e..0bca530367 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/VTabsheetPanel.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/VTabsheetPanel.java
@@ -13,7 +13,6 @@ import com.google.gwt.user.client.Element;
import com.google.gwt.user.client.Event;
import com.google.gwt.user.client.ui.ComplexPanel;
import com.google.gwt.user.client.ui.Widget;
-import com.vaadin.terminal.gwt.client.Util;
/**
* A panel that displays all of its child widgets in a 'deck', where only one
@@ -194,15 +193,6 @@ public class VTabsheetPanel extends ComplexPanel {
// widget wrapper height
wrapperDiv.getStyle().setPropertyPx("height", height);
- runWebkitOverflowAutoFix();
- }
-
- public void runWebkitOverflowAutoFix() {
- if (visibleWidget != null) {
- Util.runWebkitOverflowAutoFix(DOM.getParent(visibleWidget
- .getElement()));
- }
-
}
public void replaceComponent(Widget oldComponent, Widget newComponent) {
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VView.java b/src/com/vaadin/terminal/gwt/client/ui/VView.java
index 014a016410..1c655ec6d9 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/VView.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/VView.java
@@ -26,7 +26,6 @@ import com.vaadin.terminal.gwt.client.BrowserInfo;
import com.vaadin.terminal.gwt.client.ComponentConnector;
import com.vaadin.terminal.gwt.client.Focusable;
import com.vaadin.terminal.gwt.client.UIDL;
-import com.vaadin.terminal.gwt.client.Util;
import com.vaadin.terminal.gwt.client.VConsole;
import com.vaadin.terminal.gwt.client.ui.ShortcutActionHandler.ShortcutActionHandlerOwner;
@@ -168,8 +167,6 @@ public class VView extends SimplePanel implements ResizeHandler,
}
if (changed) {
VConsole.log("Running layout functions due to window resize");
- Util.runWebkitOverflowAutoFix(getElement());
-
sendClientResized();
connection.doLayout(false);
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VWindow.java b/src/com/vaadin/terminal/gwt/client/ui/VWindow.java
index d3529987fa..4bc7bdf371 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/VWindow.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/VWindow.java
@@ -702,7 +702,6 @@ public class VWindow extends VOverlay implements ShortcutActionHandlerOwner,
client.runDescendentsLayout((HasWidgets) layout.getWidget());
}
- Util.runWebkitOverflowAutoFix(contentPanel.getElement());
client.doLayout(false);
}
diff --git a/src/com/vaadin/terminal/gwt/client/ui/WindowConnector.java b/src/com/vaadin/terminal/gwt/client/ui/WindowConnector.java
index e209c2aaa1..c61ae93d86 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/WindowConnector.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/WindowConnector.java
@@ -20,14 +20,14 @@ import com.vaadin.terminal.gwt.client.ComponentConnector;
import com.vaadin.terminal.gwt.client.LayoutManager;
import com.vaadin.terminal.gwt.client.MouseEventDetails;
import com.vaadin.terminal.gwt.client.UIDL;
-import com.vaadin.terminal.gwt.client.Util;
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;
public class WindowConnector extends AbstractComponentContainerConnector
implements BeforeShortcutActionListener, SimpleManagedLayout,
- PostLayoutListener {
+ PostLayoutListener, RequiresOverflowAutoFix {
public interface WindowServerRPC extends ClickRPC, ServerRpc {
}
@@ -301,8 +301,6 @@ public class WindowConnector extends AbstractComponentContainerConnector
} else {
childStyle.clearPosition();
}
-
- Util.runWebkitOverflowAutoFix(window.contentPanel.getElement());
}
public void postLayout() {
diff --git a/src/com/vaadin/terminal/gwt/client/ui/layout/RequiresOverflowAutoFix.java b/src/com/vaadin/terminal/gwt/client/ui/layout/RequiresOverflowAutoFix.java
new file mode 100644
index 0000000000..18e82c8824
--- /dev/null
+++ b/src/com/vaadin/terminal/gwt/client/ui/layout/RequiresOverflowAutoFix.java
@@ -0,0 +1,10 @@
+/*
+@VaadinApache2LicenseForJavaFiles@
+ */
+package com.vaadin.terminal.gwt.client.ui.layout;
+
+import com.vaadin.terminal.gwt.client.ComponentContainerConnector;
+
+public interface RequiresOverflowAutoFix extends ComponentContainerConnector {
+
+}