From 15ff80f4b8e3a9cd5001e7d75f9b35de4eeb45a4 Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Wed, 21 Mar 2012 17:39:38 +0200 Subject: [PATCH] Fixed problem with delete DOM attribute in IE8 and split browser specific overrides to a separate GWT module --- .../terminal/gwt/DefaultWidgetSet.gwt.xml | 41 +++----------- ...tWidgetSetBrowserSpecificOverrides.gwt.xml | 53 +++++++++++++++++++ .../gwt/client/ApplicationConnection.java | 10 ++-- .../terminal/gwt/client/LayoutManager.java | 13 +++-- .../terminal/gwt/client/LayoutManagerIE8.java | 20 +++++++ 5 files changed, 93 insertions(+), 44 deletions(-) create mode 100644 src/com/vaadin/terminal/gwt/DefaultWidgetSetBrowserSpecificOverrides.gwt.xml create mode 100644 src/com/vaadin/terminal/gwt/client/LayoutManagerIE8.java diff --git a/src/com/vaadin/terminal/gwt/DefaultWidgetSet.gwt.xml b/src/com/vaadin/terminal/gwt/DefaultWidgetSet.gwt.xml index 98032aa308..db273271e9 100644 --- a/src/com/vaadin/terminal/gwt/DefaultWidgetSet.gwt.xml +++ b/src/com/vaadin/terminal/gwt/DefaultWidgetSet.gwt.xml @@ -12,6 +12,9 @@ + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/com/vaadin/terminal/gwt/DefaultWidgetSetBrowserSpecificOverrides.gwt.xml b/src/com/vaadin/terminal/gwt/DefaultWidgetSetBrowserSpecificOverrides.gwt.xml new file mode 100644 index 0000000000..82c9f2cf90 --- /dev/null +++ b/src/com/vaadin/terminal/gwt/DefaultWidgetSetBrowserSpecificOverrides.gwt.xml @@ -0,0 +1,53 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java b/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java index b74200d195..ff5244a3c1 100644 --- a/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java +++ b/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java @@ -170,12 +170,15 @@ public class ApplicationConnection { private Set zeroHeightComponents = null; - private final LayoutManager layoutManager = new LayoutManager(this); + private final LayoutManager layoutManager; - private final RpcManager rpcManager = GWT.create(RpcManager.class); + private final RpcManager rpcManager; public ApplicationConnection() { view = GWT.create(RootConnector.class); + rpcManager = GWT.create(RpcManager.class); + layoutManager = GWT.create(LayoutManager.class); + layoutManager.setConnection(this); } public void init(WidgetSet widgetSet, ApplicationConfiguration cnf) { @@ -2168,8 +2171,7 @@ public class ApplicationConnection { * The identifier for the event * @return true if at least one listener has been registered on server side * for the event identified by eventIdentifier. - * @deprecated Use {@link ComponentState#hasEventListener(String)} - * instead + * @deprecated Use {@link ComponentState#hasEventListener(String)} instead */ @Deprecated public boolean hasEventListeners(ComponentConnector paintable, diff --git a/src/com/vaadin/terminal/gwt/client/LayoutManager.java b/src/com/vaadin/terminal/gwt/client/LayoutManager.java index a593754c17..78709a7134 100644 --- a/src/com/vaadin/terminal/gwt/client/LayoutManager.java +++ b/src/com/vaadin/terminal/gwt/client/LayoutManager.java @@ -16,12 +16,16 @@ import com.vaadin.terminal.gwt.client.ui.VNotification; public class LayoutManager { private static final String LOOP_ABORT_MESSAGE = "Aborting layout after 100 passes. This would probably be an infinite loop."; - private final ApplicationConnection connection; + private ApplicationConnection connection; private final Set nonPaintableElements = new HashSet(); private final MeasuredSize nullSize = new MeasuredSize(); private boolean layoutRunning = false; - public LayoutManager(ApplicationConnection connection) { + public void setConnection(ApplicationConnection connection) { + if (this.connection != null) { + throw new RuntimeException( + "LayoutManager connection can never be changed"); + } this.connection = connection; } @@ -65,7 +69,7 @@ public class LayoutManager { } } - private static native void setMeasuredSize(Element element, + protected native void setMeasuredSize(Element element, MeasuredSize measuredSize) /*-{ if (measuredSize) { @@ -81,8 +85,7 @@ public class LayoutManager { return element.vMeasuredSize || defaultSize; }-*/; - private static final MeasuredSize getMeasuredSize( - ComponentConnector paintable) { + private final MeasuredSize getMeasuredSize(ComponentConnector paintable) { Element element = paintable.getWidget().getElement(); MeasuredSize measuredSize = getMeasuredSize(element, null); if (measuredSize == null) { diff --git a/src/com/vaadin/terminal/gwt/client/LayoutManagerIE8.java b/src/com/vaadin/terminal/gwt/client/LayoutManagerIE8.java new file mode 100644 index 0000000000..88769bfb82 --- /dev/null +++ b/src/com/vaadin/terminal/gwt/client/LayoutManagerIE8.java @@ -0,0 +1,20 @@ +package com.vaadin.terminal.gwt.client; + +import com.google.gwt.dom.client.Element; + +public class LayoutManagerIE8 extends LayoutManager { + + @Override + protected native void setMeasuredSize(Element element, + MeasuredSize measuredSize) + // IE8 cannot do delete element.vMeasuredSize, at least in the case when + // element is not attached to the document (e.g. when a caption is removed) + /*-{ + if (measuredSize) { + element.vMeasuredSize = measuredSize; + } else { + element.vMeasuredSize = undefined; + } + }-*/; + +} -- 2.39.5