private void save(BlockBox current, Layer layer, BlockFormattingContext bfc, int direction) { Point p = bfc.getOffset(); getFloats(direction).add(new BoxOffset(current, p.x, p.y)); layer.addFloat(current, bfc); current.getFloatedBoxData().setManager(this); current.calcCanvasLocation(); current.calcChildLocations(); }
private void save(BlockBox current, Layer layer, BlockFormattingContext bfc, int direction) { Point p = bfc.getOffset(); getFloats(direction).add(new BoxOffset(current, p.x, p.y)); layer.addFloat(current, bfc); current.getFloatedBoxData().setManager(this); current.calcCanvasLocation(); current.calcChildLocations(); }
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)); } }
private void alignToLastFloat(CssContext cssCtx, BlockFormattingContext bfc, BlockBox current, int direction) { List floats = getFloats(direction); if (floats.size() > 0) { Point offset = bfc.getOffset(); BoxOffset lastOffset = (BoxOffset) floats.get(floats.size() - 1); BlockBox last = lastOffset.getBox(); Rectangle currentBounds = current.getMarginEdge(cssCtx, -offset.x, -offset.y); Rectangle lastBounds = last.getMarginEdge(cssCtx, -lastOffset.getX(), -lastOffset.getY()); boolean moveOver = false; if (currentBounds.y < lastBounds.y) { currentBounds.translate(0, lastBounds.y - currentBounds.y); moveOver = true; } if (currentBounds.y >= lastBounds.y && currentBounds.y < lastBounds.y + lastBounds.height) { moveOver = true; } if (moveOver) { if (direction == LEFT) { currentBounds.x = lastBounds.x + last.getWidth(); } else if (direction == RIGHT) { currentBounds.x = lastBounds.x - current.getWidth(); } currentBounds.translate(offset.x, offset.y); current.setX(currentBounds.x); current.setY(currentBounds.y); } } }
private void alignToLastFloat(CssContext cssCtx, BlockFormattingContext bfc, BlockBox current, int direction) { List floats = getFloats(direction); if (floats.size() > 0) { Point offset = bfc.getOffset(); BoxOffset lastOffset = (BoxOffset) floats.get(floats.size() - 1); BlockBox last = (BlockBox) lastOffset.getBox(); Rectangle currentBounds = current.getMarginEdge(cssCtx, -offset.x, -offset.y); Rectangle lastBounds = last.getMarginEdge(cssCtx, -lastOffset.getX(), -lastOffset.getY()); boolean moveOver = false; if (currentBounds.y < lastBounds.y) { currentBounds.translate(0, lastBounds.y - currentBounds.y); moveOver = true; } if (currentBounds.y >= lastBounds.y && currentBounds.y < lastBounds.y + lastBounds.height) { moveOver = true; } if (moveOver) { if (direction == LEFT) { currentBounds.x = lastBounds.x + last.getWidth(); } else if (direction == RIGHT) { currentBounds.x = lastBounds.x - current.getWidth(); } currentBounds.translate(offset.x, offset.y); current.setX(currentBounds.x); current.setY(currentBounds.y); } } }