LayoutManager#getOuterWidth problems on displays with 120 DPI

We’re using extension and customized panel widget where both watch for resize events via
ElementResizeListener
.
They propagate the inner and outer dimensions to server and were working flawlessly (Vaadin 7.7.3).

However, displaying them on a machine with display scaling set to 125 % [120 DPI]
(Win10 x64, Chrome 54) the application enters the endless loop.
Client resize event notifies the server, server sets the component dimensions, the client is rendered with +/-1px changed dimensions and the loop continues forever.

The problem seems to be related to the dimensions rounding, tracing the
LayoutManager
methods leads to following observations:

  public void onElementResize(ElementResizeEvent e) {
    VConsole.log("DOUBLE width: " + e.getLayoutManager().getOuterWidthDouble(e.getElement()));
    // -> result is 610.0000610351562
    VConsole.log("INT width: " + e.getLayoutManager().getOuterWidth(e.getElement()));
    // -> result is 611 !!!!!!
    VConsole.log("ROUNDED width" + (int)Math.round(e.getLayoutManager().getOuterWidthDouble(e.getElement())));
    // -> result is 610

It seems that casting from
double
to
int
in the [i]
getOuterWidth
/i leads to very weird result, the float 610.0000610351562 is rounded to 611 instead of 610.

Using getOuterWidthDouble() and explicit rounding via Math.round seemed to address our problem and the widgets behave properly also on hight DPI displays.

However the behavior of the framework’s [i]
getOuterWidth
/i and its siblings seems to be pretty odd and since it is used also by the framework itself, it may potentially cause other problems when displayed on screens with custom DPI settings.