summaryrefslogtreecommitdiffstats
path: root/client
diff options
context:
space:
mode:
authorArtur Signell <artur@vaadin.com>2015-08-24 21:13:14 +0300
committerMika Murtojarvi <mika@vaadin.com>2015-08-25 16:50:16 +0300
commitea87dcb23565b3f21631cec8875eaf634c5963ca (patch)
tree6ff994993579945061162787de827f618373b0b3 /client
parent6cfb9132d31a967fce1d0a53a6d322fd088db3e3 (diff)
downloadvaadin-framework-ea87dcb23565b3f21631cec8875eaf634c5963ca.tar.gz
vaadin-framework-ea87dcb23565b3f21631cec8875eaf634c5963ca.zip
Measure width exactly to avoid white padding at the right edge (#18648)
Change-Id: Iaeb5fc84f08746967f664466c3e2e7d09d76e0cc
Diffstat (limited to 'client')
-rw-r--r--client/src/com/vaadin/client/ComputedStyle.java27
-rw-r--r--client/src/com/vaadin/client/ui/VFilterSelect.java13
2 files changed, 32 insertions, 8 deletions
diff --git a/client/src/com/vaadin/client/ComputedStyle.java b/client/src/com/vaadin/client/ComputedStyle.java
index cd90e0e78b..676d18d245 100644
--- a/client/src/com/vaadin/client/ComputedStyle.java
+++ b/client/src/com/vaadin/client/ComputedStyle.java
@@ -331,4 +331,31 @@ public class ComputedStyle {
return paddingWidth;
}
+
+ /**
+ * Returns the sum of the top and bottom margin
+ *
+ * @since
+ * @return the sum of the top and bottom margin
+ */
+ public double getMarginHeight() {
+ double marginHeight = getDoubleProperty("marginTop");
+ marginHeight += getDoubleProperty("marginBottom");
+
+ return marginHeight;
+ }
+
+ /**
+ * Returns the sum of the top and bottom margin
+ *
+ * @since
+ * @return the sum of the left and right margin
+ */
+ public double getMarginWidth() {
+ double marginWidth = getDoubleProperty("marginLeft");
+ marginWidth += getDoubleProperty("marginRight");
+
+ return marginWidth;
+ }
+
}
diff --git a/client/src/com/vaadin/client/ui/VFilterSelect.java b/client/src/com/vaadin/client/ui/VFilterSelect.java
index d756c88f79..cf03382333 100644
--- a/client/src/com/vaadin/client/ui/VFilterSelect.java
+++ b/client/src/com/vaadin/client/ui/VFilterSelect.java
@@ -617,14 +617,15 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler,
// Must take margin,border,padding manually into account for
// menu element as we measure the element child and set width to
// the element parent
- int naturalMenuOuterWidth = naturalMenuWidth
+ double naturalMenuOuterWidth = WidgetUtil
+ .getRequiredWidthDouble(menuFirstChild)
+ getMarginBorderPaddingWidth(menu.getElement());
/*
* IE requires us to specify the width for the container
* element. Otherwise it will be 100% wide
*/
- int rootWidth = Math.max(desiredWidth - popupOuterPadding,
+ double rootWidth = Math.max(desiredWidth - popupOuterPadding,
naturalMenuOuterWidth);
getContainerElement().getStyle().setWidth(rootWidth, Unit.PX);
}
@@ -1291,13 +1292,9 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler,
sinkEvents(Event.ONPASTE);
}
- private static int getMarginBorderPaddingWidth(Element element) {
+ private static double getMarginBorderPaddingWidth(Element element) {
final ComputedStyle s = new ComputedStyle(element);
- int[] margin = s.getMargin();
- int[] border = s.getBorder();
- int[] padding = s.getPadding();
- return margin[1] + margin[3] + border[1] + border[3] + padding[1]
- + padding[3];
+ return s.getMarginWidth() + s.getBorderWidth() + s.getPaddingWidth();
}