public void doRefresh() {
        if (layoutConfig != null) {
            double minWidth = getMinRequired(layoutConfig, Dimension.X);
            double minHeight = getMinRequired(layoutConfig, Dimension.Y);

            final double visibleWidth = Math.floor(ElementUtil.getSubPixelClientWidth(scrollPanel.getElement()));
            final double visibleHeight = Math.floor(ElementUtil.getSubPixelClientHeight(scrollPanel.getElement()));
//            GWT.log(getElement() + " visibleWidth=" + visibleWidth + " visibleHeight=" + visibleHeight);
//            double barWidth = 12;
//            boolean scrollX = false;
//            boolean scrollY = false;

            if (!layoutConstraints.isFitWidth()) {
                if (preferredSize.getWidth() > 0) {
                    minWidth = Math.max(preferredSize.getWidth(), minWidth);
                } else {
                    minWidth = getMaxRequired(layoutConfig, Dimension.X);
                }
                preferredSize.setWidth((int) minWidth);
            }
            if (!layoutConstraints.isFitHeight()) {
                if (preferredSize.getHeight() > 0) {
                    minHeight = Math.max(preferredSize.getHeight(), minHeight);
                } else {
                    minHeight = getMaxRequired(layoutConfig, Dimension.Y);
                }
                preferredSize.setHeight((int) minHeight);
            }

            double designWidth = minWidth;
            double designHeight = minHeight;
            if (designMode) {
                if (!layoutConstraints.isFitWidth()) {
                    designWidth = minWidth * 2;
                }
                if (!layoutConstraints.isFitHeight()) {
                    designHeight = minHeight * 2;
                }
            }

//            for (int i = 0; i < 2; i++) {
//                if (!scrollX) {
//                    if (designWidth > visibleWidth) {
//                        scrollX = true;
//                        visibleHeight -= barWidth;
//                    }
//                }
//
//                if (!scrollY) {
//                    if (designHeight > visibleHeight) {
//                        scrollY = true;
//                        visibleWidth -= barWidth;
//                    }
//                }
//            }

            final double width;
            if (layoutConstraints.isFitWidth()) {
                width = Math.max(visibleWidth, minWidth);
            } else {
                width = minWidth;
            }

            final double height;
            if (layoutConstraints.isFitHeight()) {
                height = Math.max(visibleHeight, minHeight);
            } else {
                height = minHeight;
            }

            if (clear ||
                    outerSize == null ||
                    outerSize.getWidth() != width ||
                    outerSize.getHeight() != height ||
                    designSurfaceSize == null ||
                    designSurfaceSize.getWidth() != designWidth ||
                    designSurfaceSize.getHeight() != designHeight) {
                outerSize = new Size(width, height);

                if (designMode) {
                    designSurfaceSize = new Size(
                            Math.max(visibleWidth, designWidth),
                            Math.max(visibleHeight, designHeight));
                } else {
                    designSurfaceSize = outerSize;
                }

//                GWT.log("visibleWidth=" +
//                        visibleWidth +
//                        " designWidth=" +
//                        designWidth +
//                        " visibleHeight=" +
//                        visibleHeight +
//                        " designHeight=" +
//                        designHeight +
//                        " width=" +
//                        width +
//                        " height=" +
//                        height);

                designSurface.setSize(
                        designSurfaceSize.getWidth() + "px",
                        designSurfaceSize.getHeight() + "px");

                recalculateAll();

                if (clear) {
                    // Unbind tab layouts and clear.
                    for (final TabLayout tabLayout : layoutToWidgetMap.values()) {
                        tabLayout.unbind();
                    }
                    layoutToWidgetMap.clear();
                    splitToWidgetMap.clear();
                }

                // Move all widgets before they are attached to the design surface.
                layout();

                if (clear) {
                    // Add all widgets to the design surface.
                    for (final TabLayout w : layoutToWidgetMap.values()) {
                        designSurface.add(w);
                    }

                    // Add splitters to the design surface.
                    for (final Splitter w : splitToWidgetMap.values()) {
                        designSurface.add(w);
                    }
                }

                clear = false;
            }

            // Perform a resize on all child layouts.
            Scheduler.get().scheduleDeferred(this::resizeChildWidgets);
//            resizeChildWidgets();
        }
    }
Tests the supplied layout to see if it is the current mouse target and
returns mouse target if it is.

@param x               The mouse x coordinate.
@param y               The mouse y coordinate.
@param splitter        True if the layout is a splitter. Splitters are targeted
                       outside their rect.
@param layoutConfig    The layout data to test to see if it is a target.
@param positionAndSize The position and size of the layout being tested.
@return The mouse target if the tested layout is the target, else null.
stroom-core-client/src/main/java/stroom/dashboard/client/flexlayout/FlexLayout.java