private void alignToLastOpposingFloat(CssContext cssCtx, BlockFormattingContext bfc, BlockBox current, int direction) { List floats = getOpposingFloats(direction); if (floats.size() > 0) { Point offset = bfc.getOffset(); BoxOffset lastOffset = (BoxOffset) floats.get(floats.size() - 1); Rectangle currentBounds = current.getMarginEdge(cssCtx, -offset.x, -offset.y); Rectangle lastBounds = lastOffset.getBox().getMarginEdge(cssCtx, -lastOffset.getX(), -lastOffset.getY()); if (currentBounds.y < lastBounds.y) { currentBounds.translate(0, lastBounds.y - currentBounds.y); currentBounds.translate(offset.x, offset.y); current.setY(currentBounds.y); } } }
private void alignToLastOpposingFloat(CssContext cssCtx, BlockFormattingContext bfc, BlockBox current, int direction) { List floats = getOpposingFloats(direction); if (floats.size() > 0) { Point offset = bfc.getOffset(); BoxOffset lastOffset = (BoxOffset) floats.get(floats.size() - 1); Rectangle currentBounds = current.getMarginEdge(cssCtx, -offset.x, -offset.y); Rectangle lastBounds = lastOffset.getBox().getMarginEdge(cssCtx, -lastOffset.getX(), -lastOffset.getY()); if (currentBounds.y < lastBounds.y) { currentBounds.translate(0, lastBounds.y - currentBounds.y); currentBounds.translate(offset.x, offset.y); current.setY(currentBounds.y); } } }
private void position(CssContext cssCtx, BlockFormattingContext bfc, BlockBox current, int direction) { moveAllTheWayOver(current, direction); alignToLastOpposingFloat(cssCtx, bfc, current, direction); alignToLastFloat(cssCtx, bfc, current, direction); if (!fitsInContainingBlock(current) || overlaps(cssCtx, bfc, current, getFloats(direction))) { moveAllTheWayOver(current, direction); moveFloatBelow(cssCtx, bfc, current, getFloats(direction)); } if (overlaps(cssCtx, bfc, current, getOpposingFloats(direction))) { moveAllTheWayOver(current, direction); moveFloatBelow(cssCtx, bfc, current, getFloats(direction)); moveFloatBelow(cssCtx, bfc, current, getOpposingFloats(direction)); } if (current.getStyle().isCleared()) { if (current.getStyle().isClearLeft() && direction == LEFT) { moveAllTheWayOver(current, LEFT); } else if (current.getStyle().isClearRight() && direction == RIGHT) { moveAllTheWayOver(current, RIGHT); } moveFloatBelow(cssCtx, bfc, current, getFloats(direction)); } }
private void position(CssContext cssCtx, BlockFormattingContext bfc, BlockBox current, int direction) { moveAllTheWayOver(current, direction); alignToLastOpposingFloat(cssCtx, bfc, current, direction); alignToLastFloat(cssCtx, bfc, current, direction); if (!fitsInContainingBlock(current) || overlaps(cssCtx, bfc, current, getFloats(direction))) { moveAllTheWayOver(current, direction); moveFloatBelow(cssCtx, bfc, current, getFloats(direction)); } if (overlaps(cssCtx, bfc, current, getOpposingFloats(direction))) { moveAllTheWayOver(current, direction); moveFloatBelow(cssCtx, bfc, current, getFloats(direction)); moveFloatBelow(cssCtx, bfc, current, getOpposingFloats(direction)); } if (current.getStyle().isCleared()) { if (current.getStyle().isClearLeft() && direction == LEFT) { moveAllTheWayOver(current, LEFT); } else if (current.getStyle().isClearRight() && direction == RIGHT) { moveAllTheWayOver(current, RIGHT); } moveFloatBelow(cssCtx, bfc, current, getFloats(direction)); } }