private static void layoutBlockChild( LayoutContext c, BlockBox parent, BlockBox child, boolean needPageClear, int childOffset, int trimmedPageCount, LayoutState layoutState) { layoutBlockChild0(c, parent, child, needPageClear, childOffset, trimmedPageCount); BreakAtLineContext bContext = child.calcBreakAtLineContext(c); if (bContext != null) { c.setBreakAtLineContext(bContext); c.restoreStateForRelayout(layoutState); child.reset(c); layoutBlockChild0(c, parent, child, needPageClear, childOffset, trimmedPageCount); c.setBreakAtLineContext(null); } }
if ( isPageBreakBetweenChildBoxes(relayoutDataList, runStart, runEnd, c, block) ) { result.setChanged(true); block.resetChildren(c, runStart, offset); result.setChildOffset(relayoutRun(c, localChildren, block, relayoutDataList, runStart, offset, true)); if ( isPageBreakBetweenChildBoxes(relayoutDataList, runStart, runEnd, c, block) ) { block.resetChildren(c, runStart, offset); result.setChildOffset(relayoutRun(c, localChildren, block, relayoutDataList, runStart, offset, false));
private static boolean isPageBreakBetweenChildBoxes(RelayoutDataList relayoutDataList, int runStart, int runEnd, LayoutContext c, BlockBox block) { for ( int i = runStart; i < runEnd; i++ ) { Box prevChild = block.getChild(i); Box nextChild = block.getChild(i+1); // if nextChild is made of several lines, then only the first line // is relevant for "page-break-before: avoid". Box nextLine = getFirstLine(nextChild) == null ? nextChild : getFirstLine(nextChild); int prevChildEnd = prevChild.getAbsY() + prevChild.getHeight(); int nextLineEnd = nextLine.getAbsY() + nextLine.getHeight(); if ( c.getRootLayer().crossesPageBreak(c, prevChildEnd, nextLineEnd) ) { return true; } } return false; }
layoutBlockChild( c, block, child, false, childOffset, NO_PAGE_TRIM, relayoutData == null ? null : relayoutData.getLayoutState()); c.restoreStateForRelayout(relayoutData.getLayoutState()); child.reset(c); layoutBlockChild( c, block, child, true, childOffset, pageCount, relayoutData.getLayoutState()); c.restoreStateForRelayout(relayoutData.getLayoutState()); child.reset(c); layoutBlockChild( c, block, child, false, childOffset, pageCount, relayoutData.getLayoutState()); processPageBreakAvoidRun( c, block, localChildren, offset, relayoutDataList, relayoutData, child); if (runResult.isChanged()) {
private static void layoutBlockChild0(LayoutContext c, BlockBox parent, BlockBox child, boolean needPageClear, int childOffset, int trimmedPageCount) { child.setNeedPageClear(needPageClear); child.initStaticPos(c, parent, childOffset); child.initContainingLayer(c); child.calcCanvasLocation(); c.translate(0, childOffset); repositionBox(c, child, trimmedPageCount); child.layout(c); c.translate(-child.getX(), -child.getY()); }
protected void layoutChildren(LayoutContext c, int contentStart) { setState(Box.CHILDREN_FLUX); ensureChildren(c); if (getFirstLetterStyle() != null) { c.getFirstLettersTracker().addStyle(getFirstLetterStyle()); } if (getFirstLineStyle() != null) { c.getFirstLinesTracker().addStyle(getFirstLineStyle()); } switch (getChildrenContentType()) { case CONTENT_INLINE: layoutInlineChildren(c, contentStart, calcInitialBreakAtLine(c), true); break; case CONTENT_BLOCK: BlockBoxing.layoutContent(c, this, contentStart); break; } if (getFirstLetterStyle() != null) { c.getFirstLettersTracker().removeLast(); } if (getFirstLineStyle() != null) { c.getFirstLinesTracker().removeLast(); } setState(Box.DONE); }
c.setMayCheckKeepTogether(false); layoutBlockChild( c, block, child, false, childOffset, NO_PAGE_TRIM, relayoutData.getLayoutState()); c.restoreStateForRelayout(relayoutData.getLayoutState()); child.reset(c); layoutBlockChild( c, block, child, true, childOffset, pageCount, relayoutData.getLayoutState()); c.restoreStateForRelayout(relayoutData.getLayoutState()); child.reset(c); layoutBlockChild( c, block, child, false, childOffset, pageCount, relayoutData.getLayoutState());
result.setChanged(true); block.resetChildren(c, runStart, offset); result.setChildOffset(relayoutRun(c, localChildren, block, relayoutDataList, runStart, offset, true)); runEndChild = block.getChild(runEnd); runEndChild.getAbsY() + runEndChild.getHeight())) { block.resetChildren(c, runStart, offset); result.setChildOffset(relayoutRun(c, localChildren, block, relayoutDataList, runStart, offset, false));
layoutBlockChild( c, block, child, false, childOffset, NO_PAGE_TRIM, relayoutData == null ? null : relayoutData.getLayoutState()); c.restoreStateForRelayout(relayoutData.getLayoutState()); child.reset(c); layoutBlockChild( c, block, child, true, childOffset, pageCount, relayoutData.getLayoutState()); c.restoreStateForRelayout(relayoutData.getLayoutState()); child.reset(c); layoutBlockChild( c, block, child, false, childOffset, pageCount, relayoutData.getLayoutState()); processPageBreakAvoidRun( c, block, localChildren, offset, relayoutDataList, relayoutData, child); if (runResult.isChanged()) {
private static void layoutBlockChild0(LayoutContext c, BlockBox parent, BlockBox child, boolean needPageClear, int childOffset, int trimmedPageCount) { child.setNeedPageClear(needPageClear); child.initStaticPos(c, parent, childOffset); child.initContainingLayer(c); child.calcCanvasLocation(); c.translate(0, childOffset); repositionBox(c, child, trimmedPageCount); child.layout(c); c.translate(-child.getX(), -child.getY()); }
protected void layoutChildren(LayoutContext c, int contentStart) { setState(Box.CHILDREN_FLUX); ensureChildren(c); if (getFirstLetterStyle() != null) { c.getFirstLettersTracker().addStyle(getFirstLetterStyle()); } if (getFirstLineStyle() != null) { c.getFirstLinesTracker().addStyle(getFirstLineStyle()); } switch (getChildrenContentType()) { case CONTENT_INLINE: layoutInlineChildren(c, contentStart, calcInitialBreakAtLine(c), true); break; case CONTENT_BLOCK: BlockBoxing.layoutContent(c, this, contentStart); break; } if (getFirstLetterStyle() != null) { c.getFirstLettersTracker().removeLast(); } if (getFirstLineStyle() != null) { c.getFirstLinesTracker().removeLast(); } setState(Box.DONE); }
c.setMayCheckKeepTogether(false); layoutBlockChild( c, block, child, false, childOffset, NO_PAGE_TRIM, relayoutData.getLayoutState()); c.restoreStateForRelayout(relayoutData.getLayoutState()); child.reset(c); layoutBlockChild( c, block, child, true, childOffset, pageCount, relayoutData.getLayoutState()); c.restoreStateForRelayout(relayoutData.getLayoutState()); child.reset(c); layoutBlockChild( c, block, child, false, childOffset, pageCount, relayoutData.getLayoutState());
private static void layoutBlockChild( LayoutContext c, BlockBox parent, BlockBox child, boolean needPageClear, int childOffset, int trimmedPageCount, LayoutState layoutState) { layoutBlockChild0(c, parent, child, needPageClear, childOffset, trimmedPageCount); BreakAtLineContext bContext = child.calcBreakAtLineContext(c); if (bContext != null) { c.setBreakAtLineContext(bContext); c.restoreStateForRelayout(layoutState); child.reset(c); layoutBlockChild0(c, parent, child, needPageClear, childOffset, trimmedPageCount); c.setBreakAtLineContext(null); } }