if (getMaster() instanceof BlockBox) { BlockBox box = (BlockBox) getMaster(); box.paintBackground(c); box.paintBorder(c); } } private void paintReplacedElement(RenderingContext c, BlockBox replaced) {
if (getMaster().getStyle().isAbsolute() && ! c.isPrint()) { ((BlockBox)getMaster()).positionAbsolute(c, BlockBox.POSITION_BOTH); } else if (getMaster().getStyle().isRelative() && (isInline() || ((BlockBox)getMaster()).isInline())) { getMaster().positionRelative(c); if (! isInline()) { getMaster().calcCanvasLocation(); getMaster().calcChildLocations(); } } } private boolean containsFixedLayer() {
private void position(LayoutContext c) { if (getMaster().getStyle().isAbsolute() && ! c.isPrint()) { ((BlockBox)getMaster()).positionAbsolute(c, BlockBox.POSITION_BOTH); } else if (getMaster().getStyle().isRelative() && (isInline() || ((BlockBox)getMaster()).isInline())) { getMaster().positionRelative(c); if (! isInline()) { getMaster().calcCanvasLocation(); getMaster().calcChildLocations(); } } }
for (Iterator i = getChildren().iterator(); i.hasNext();) { Layer child = (Layer) i.next(); if (child.getMaster().getStyle().isFixed() || child.containsFixedLayer()) { return true; } } return false; } public boolean containsFixedContent() {
private boolean containsFixedLayer() { for (Iterator i = getChildren().iterator(); i.hasNext();) { Layer child = (Layer) i.next(); if (child.getMaster().getStyle().isFixed() || child.containsFixedLayer()) { return true; } } return false; }
getMaster().calcPaintingInfo(c, true); PaintingInfo result = (PaintingInfo)getMaster().getPaintingInfo().copyOf(); List children = getChildren(); for (int i = 0; i < children.size(); i++) { Layer child = (Layer)children.get(i); if (child.getMaster().getStyle().isFixed()) { continue; } else if (child.getMaster().getStyle().isAbsolute()) { PaintingInfo info = child.calcPaintingDimension(c); moveIfGreater(result.getOuterMarginCorner(), info.getOuterMarginCorner()); } } return result; } public void positionChildren(LayoutContext c) {
public void collect( CssContext c, Shape clip, Layer layer, List blockContent, List inlineContent, BoxRangeLists rangeLists) { if (layer.isInline()) { collectInlineLayer(c, clip, layer, blockContent, inlineContent, rangeLists); } else { collect(c, clip, layer, layer.getMaster(), blockContent, inlineContent, rangeLists); } }
private PaintingInfo calcPaintingDimension(LayoutContext c) { getMaster().calcPaintingInfo(c, true); PaintingInfo result = (PaintingInfo)getMaster().getPaintingInfo().copyOf(); List children = getChildren(); for (int i = 0; i < children.size(); i++) { Layer child = (Layer)children.get(i); if (child.getMaster().getStyle().isFixed()) { continue; } else if (child.getMaster().getStyle().isAbsolute()) { PaintingInfo info = child.calcPaintingDimension(c); moveIfGreater(result.getOuterMarginCorner(), info.getOuterMarginCorner()); } } return result; }
public void collect( CssContext c, Shape clip, Layer layer, List blockContent, List inlineContent, BoxRangeLists rangeLists) { if (layer.isInline()) { collectInlineLayer(c, clip, layer, blockContent, inlineContent, rangeLists); } else { collect(c, clip, layer, layer.getMaster(), blockContent, inlineContent, rangeLists); } }
private void collectInlineLayer( CssContext c, Shape clip, Layer layer, List blockContent, List inlineContent, BoxRangeLists rangeLists) { InlineLayoutBox iB = (InlineLayoutBox)layer.getMaster(); List content = iB.getElementWithContent(); for (int i = 0; i < content.size(); i++) { Box b = (Box)content.get(i); if (b.intersects(c, clip)) { if (b instanceof InlineLayoutBox) { inlineContent.add(b); } else { BlockBox bb = (BlockBox)b; if (bb.isInline()) { if (intersectsAny(c, clip, b)) { inlineContent.add(b); } } else { collect(c, clip, layer, bb, blockContent, inlineContent, rangeLists); } } } } }
List children = getChildren(); if (children.size() > 0) { LayoutState state = c.captureLayoutState(); for (int i = 0; i < children.size(); i++) { Layer child = (Layer)children.get(i); if (child.isRequiresLayout()) { layoutAbsoluteChild(c, child); if (child.getMaster().getStyle().isAvoidPageBreakInside() && child.getMaster().crossesPageBreak(c)) { child.getMaster().reset(c); ((BlockBox)child.getMaster()).setNeedPageClear(true); layoutAbsoluteChild(c, child); if (child.getMaster().crossesPageBreak(c)) { child.getMaster().reset(c); layoutAbsoluteChild(c, child); } } child.setRequiresLayout(false); child.finish(c); c.getRootLayer().ensureHasPage(c, child.getMaster()); } } c.restoreLayoutState(state); } } private void layoutAbsoluteChild(LayoutContext c, Layer child) {
private void collectInlineLayer( CssContext c, Shape clip, Layer layer, List blockContent, List inlineContent, BoxRangeLists rangeLists) { InlineLayoutBox iB = (InlineLayoutBox)layer.getMaster(); List content = iB.getElementWithContent(); for (int i = 0; i < content.size(); i++) { Box b = (Box)content.get(i); if (b.intersects(c, clip)) { if (b instanceof InlineLayoutBox) { inlineContent.add(b); } else { BlockBox bb = (BlockBox)b; if (bb.isInline()) { if (intersectsAny(c, clip, b)) { inlineContent.add(b); } } else { collect(c, clip, layer, bb, blockContent, inlineContent, rangeLists); } } } } }
/** * Renders according to scale factor * * @param c the RenderingContext to use * @param root The Layer to render */ protected void doRender(RenderingContext c, Layer root) { Graphics2D g = ((Java2DOutputDevice) c.getOutputDevice()).getGraphics(); if (!(g instanceof PrinterGraphics) && isOpaque()) { g.setColor(getBackground()); g.fillRect(0, 0, getWidth(), getHeight()); } AffineTransform current = g.getTransform(); PaintingInfo pI = root.getMaster().getPaintingInfo(); Dimension layoutSize = pI.getOuterMarginCorner(); calculateScaleAccordingToPolicy(layoutSize); if (lastLayoutSize == null) { lastLayoutSize = layoutSize; setPreferredSize(new Dimension((int) (lastLayoutSize.width * scale), (int) (lastLayoutSize.height * scale))); revalidate(); } g.transform(AffineTransform.getScaleInstance(scale, scale)); super.doRender(c, root); g.setTransform(current); }
Rectangle rect = c.getFixedRectangle(); Box fixed = getMaster(); fixed.setX(0); fixed.setY(0); fixed.setAbsX(0); fixed.setAbsY(0); fixed.setContainingBlock(new ViewportBox(rect)); ((BlockBox)fixed).positionAbsolute(c, BlockBox.POSITION_BOTH); fixed.calcPaintingInfo(c, false); } private void paintLayerBackgroundAndBorder(RenderingContext c) {
private void positionFixedLayer(RenderingContext c) { Rectangle rect = c.getFixedRectangle(); Box fixed = getMaster(); fixed.setX(0); fixed.setY(0); fixed.setAbsX(0); fixed.setAbsY(0); fixed.setContainingBlock(new ViewportBox(rect)); ((BlockBox)fixed).positionAbsolute(c, BlockBox.POSITION_BOTH); fixed.calcPaintingInfo(c, false); }
public static void layoutAbsolute( LayoutContext c, LineBox currentLine, BlockBox box) { MarkerData markerData = c.getCurrentMarkerData(); c.setCurrentMarkerData(null); if (box.getStyle().isFixed()) { box.setContainingBlock(c.getRootLayer().getMaster().getContainingBlock()); } else { box.setContainingBlock(c.getLayer().getMaster()); } box.setStaticEquivalent(currentLine); // If printing, don't layout until we know where its going if (! c.isPrint()) { box.layout(c); } else { c.pushLayer(box); c.getLayer().setRequiresLayout(true); c.popLayer(); } c.setCurrentMarkerData(markerData); }
public void initContainingLayer(LayoutContext c) { if (getLayer() != null) { setContainingLayer(getLayer()); } else if (getContainingLayer() == null) { if (getParent() == null || getParent().getContainingLayer() == null) { throw new RuntimeException("internal error"); } setContainingLayer(getParent().getContainingLayer()); // FIXME Will be glacially slow for large inline relative layers. Could // be much more efficient. We're just looking for block boxes which are // directly wrapped by an inline relative layer (i.e. block boxes sandwiched // between anonymous block boxes) if (c.getLayer().isInline()) { List content = ((InlineLayoutBox)c.getLayer().getMaster()).getElementWithContent(); if (content.contains(this)) { setContainingLayer(c.getLayer()); } } } }
public void initContainingLayer(LayoutContext c) { if (getLayer() != null) { setContainingLayer(getLayer()); } else if (getContainingLayer() == null) { if (getParent() == null || getParent().getContainingLayer() == null) { throw new RuntimeException("internal error"); } setContainingLayer(getParent().getContainingLayer()); // FIXME Will be glacially slow for large inline relative layers. Could // be much more efficient. We're just looking for block boxes which are // directly wrapped by an inline relative layer (i.e. block boxes sandwiched // between anonymous block boxes) if (c.getLayer().isInline()) { List content = ((InlineLayoutBox)c.getLayer().getMaster()).getElementWithContent(); if (content.contains(this)) { setContainingLayer(c.getLayer()); } } } }
public static void layoutAbsolute( LayoutContext c, LineBox currentLine, BlockBox box) { MarkerData markerData = c.getCurrentMarkerData(); c.setCurrentMarkerData(null); box.setContainingBlock(c.getLayer().getMaster()); box.setStaticEquivalent(currentLine); // If printing, don't layout until we know where its going if (! c.isPrint()) { box.layout(c); } else { c.pushLayer(box); c.getLayer().setRequiresLayout(true); c.popLayer(); } c.setCurrentMarkerData(markerData); }