Skip to content

Commit

Permalink
Measure width exactly to avoid white padding at the right edge (#18648)
Browse files Browse the repository at this point in the history
Change-Id: Iaeb5fc84f08746967f664466c3e2e7d09d76e0cc
  • Loading branch information
Artur- committed Aug 24, 2015
1 parent 86cf519 commit 136e24a
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 8 deletions.
27 changes: 27 additions & 0 deletions client/src/com/vaadin/client/ComputedStyle.java
Expand Up @@ -331,4 +331,31 @@ public double getPaddingWidth() {


return paddingWidth; 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;
}

} }
13 changes: 5 additions & 8 deletions client/src/com/vaadin/client/ui/VFilterSelect.java
Expand Up @@ -617,14 +617,15 @@ public void setPosition(int offsetWidth, int offsetHeight) {
// Must take margin,border,padding manually into account for // Must take margin,border,padding manually into account for
// menu element as we measure the element child and set width to // menu element as we measure the element child and set width to
// the element parent // the element parent
int naturalMenuOuterWidth = naturalMenuWidth double naturalMenuOuterWidth = WidgetUtil
.getRequiredWidthDouble(menuFirstChild)
+ getMarginBorderPaddingWidth(menu.getElement()); + getMarginBorderPaddingWidth(menu.getElement());


/* /*
* IE requires us to specify the width for the container * IE requires us to specify the width for the container
* element. Otherwise it will be 100% wide * element. Otherwise it will be 100% wide
*/ */
int rootWidth = Math.max(desiredWidth - popupOuterPadding, double rootWidth = Math.max(desiredWidth - popupOuterPadding,
naturalMenuOuterWidth); naturalMenuOuterWidth);
getContainerElement().getStyle().setWidth(rootWidth, Unit.PX); getContainerElement().getStyle().setWidth(rootWidth, Unit.PX);
} }
Expand Down Expand Up @@ -1291,13 +1292,9 @@ public VFilterSelect() {
sinkEvents(Event.ONPASTE); sinkEvents(Event.ONPASTE);
} }


private static int getMarginBorderPaddingWidth(Element element) { private static double getMarginBorderPaddingWidth(Element element) {
final ComputedStyle s = new ComputedStyle(element); final ComputedStyle s = new ComputedStyle(element);
int[] margin = s.getMargin(); return s.getMarginWidth() + s.getBorderWidth() + s.getPaddingWidth();
int[] border = s.getBorder();
int[] padding = s.getPadding();
return margin[1] + margin[3] + border[1] + border[3] + padding[1]
+ padding[3];


} }


Expand Down

0 comments on commit 136e24a

Please sign in to comment.