public void ensureChildren(LayoutContext c) { if (getChildrenContentType() == CONTENT_UNKNOWN) { BoxBuilder.createChildren(c, this); } }
public void ensureChildren(LayoutContext c) { if (getChildrenContentType() == CONTENT_UNKNOWN) { BoxBuilder.createChildren(c, this); } }
public boolean isContainsInlineContent(LayoutContext c) { ensureChildren(c); switch (getChildrenContentType()) { case CONTENT_INLINE: return true; case CONTENT_EMPTY: return false; case CONTENT_BLOCK: for (Iterator i = getChildIterator(); i.hasNext(); ) { BlockBox box = (BlockBox)i.next(); if (box.isContainsInlineContent(c)) { return true; } } return false; } throw new RuntimeException("internal error: no children"); }
public boolean isContainsInlineContent(LayoutContext c) { ensureChildren(c); switch (getChildrenContentType()) { case CONTENT_INLINE: return true; case CONTENT_EMPTY: return false; case CONTENT_BLOCK: for (Iterator i = getChildIterator(); i.hasNext(); ) { BlockBox box = (BlockBox)i.next(); if (box.isContainsInlineContent(c)) { return true; } } return false; } throw new RuntimeException("internal error: no children"); }
private LineBox findLastLineBox() { int type = getChildrenContentType(); int ccount = getChildCount(); if (ccount > 0) { if (type == CONTENT_INLINE) { for (int i = ccount - 1; i >= 0; i--) { LineBox result = (LineBox) getChild(i); if (result.getHeight() > 0) { return result; } } } else if (type == CONTENT_BLOCK) { for (int i = ccount - 1; i >= 0; i--) { LineBox result = ((BlockBox) getChild(i)).findLastLineBox(); if (result != null) { return result; } } } } return null; }
private LineBox findLastLineBox() { int type = getChildrenContentType(); int ccount = getChildCount(); if (ccount > 0) { if (type == CONTENT_INLINE) { for (int i = ccount - 1; i >= 0; i--) { LineBox result = (LineBox) getChild(i); if (result.getHeight() > 0) { return result; } } } else if (type == CONTENT_BLOCK) { for (int i = ccount - 1; i >= 0; i--) { LineBox result = ((BlockBox) getChild(i)).findLastLineBox(); if (result != null) { return result; } } } } return null; }
private LineBox findFirstLineBox() { int type = getChildrenContentType(); int ccount = getChildCount(); if (ccount > 0) { if (type == CONTENT_INLINE) { for (int i = 0; i < ccount; i++) { LineBox result = (LineBox) getChild(i); if (result.getHeight() > 0) { return result; } } } else if (type == CONTENT_BLOCK) { for (int i = 0; i < ccount; i++) { LineBox result = ((BlockBox) getChild(i)).findFirstLineBox(); if (result != null) { return result; } } } } return null; }
private LineBox findFirstLineBox() { int type = getChildrenContentType(); int ccount = getChildCount(); if (ccount > 0) { if (type == CONTENT_INLINE) { for (int i = 0; i < ccount; i++) { LineBox result = (LineBox) getChild(i); if (result.getHeight() > 0) { return result; } } } else if (type == CONTENT_BLOCK) { for (int i = 0; i < ccount; i++) { LineBox result = ((BlockBox) getChild(i)).findFirstLineBox(); if (result != null) { return result; } } } } return null; }
private boolean isVerticalMarginsAdjoin(LayoutContext c) { CalculatedStyle style = getStyle(); BorderPropertySet borderWidth = style.getBorder(c); RectPropertySet padding = getPadding(c); boolean bordersOrPadding = (int) borderWidth.top() != 0 || (int) borderWidth.bottom() != 0 || (int) padding.top() != 0 || (int) padding.bottom() != 0; if (bordersOrPadding) { return false; } ensureChildren(c); if (getChildrenContentType() == CONTENT_INLINE) { return false; } else if (getChildrenContentType() == CONTENT_BLOCK) { for (Iterator i = getChildIterator(); i.hasNext();) { BlockBox child = (BlockBox) i.next(); if (child.isSkipWhenCollapsingMargins() || ! child.isVerticalMarginsAdjoin(c)) { return false; } } } return style.asFloat(CSSName.MIN_HEIGHT) == 0 && (isAutoHeight() || style.asFloat(CSSName.HEIGHT) == 0); }
private void findLastLineBox(LastLineBoxContext context) { int type = getChildrenContentType(); int ccount = getChildCount(); if (ccount > 0) { if (type == CONTENT_INLINE) { for (int i = ccount - 1; i >= 0; i--) { LineBox child = (LineBox) getChild(i); if (child.getHeight() > 0) { context.line = child; if (--context.current == 0) { return; } } } } else if (type == CONTENT_BLOCK) { for (int i = ccount - 1; i >= 0; i--) { ((BlockBox) getChild(i)).findLastLineBox(context); if (context.current == 0) { break; } } } } }
private void findLastLineBox(LastLineBoxContext context) { int type = getChildrenContentType(); int ccount = getChildCount(); if (ccount > 0) { if (type == CONTENT_INLINE) { for (int i = ccount - 1; i >= 0; i--) { LineBox child = (LineBox) getChild(i); if (child.getHeight() > 0) { context.line = child; if (--context.current == 0) { return; } } } } else if (type == CONTENT_BLOCK) { for (int i = ccount - 1; i >= 0; i--) { ((BlockBox) getChild(i)).findLastLineBox(context); if (context.current == 0) { break; } } } } }
private boolean isVerticalMarginsAdjoin(LayoutContext c) { CalculatedStyle style = getStyle(); BorderPropertySet borderWidth = style.getBorder(c); RectPropertySet padding = getPadding(c); boolean bordersOrPadding = (int) borderWidth.top() != 0 || (int) borderWidth.bottom() != 0 || (int) padding.top() != 0 || (int) padding.bottom() != 0; if (bordersOrPadding) { return false; } ensureChildren(c); if (getChildrenContentType() == CONTENT_INLINE) { return false; } else if (getChildrenContentType() == CONTENT_BLOCK) { for (Iterator i = getChildIterator(); i.hasNext();) { BlockBox child = (BlockBox) i.next(); if (child.isSkipWhenCollapsingMargins() || ! child.isVerticalMarginsAdjoin(c)) { return false; } } } return style.asFloat(CSSName.MIN_HEIGHT) == 0 && (isAutoHeight() || style.asFloat(CSSName.HEIGHT) == 0); }
private void collapseEmptySubtreeMargins(LayoutContext c, MarginCollapseResult result) { RectPropertySet margin = getMargin(c); result.update((int) margin.top()); result.update((int) margin.bottom()); setMarginTop(c, 0); setTopMarginCalculated(true); setMarginBottom(c, 0); setBottomMarginCalculated(true); ensureChildren(c); if (getChildrenContentType() == CONTENT_BLOCK) { for (Iterator i = getChildIterator(); i.hasNext();) { BlockBox child = (BlockBox) i.next(); child.collapseEmptySubtreeMargins(c, result); } } }
private void collapseEmptySubtreeMargins(LayoutContext c, MarginCollapseResult result) { RectPropertySet margin = getMargin(c); result.update((int) margin.top()); result.update((int) margin.bottom()); setMarginTop(c, 0); setTopMarginCalculated(true); setMarginBottom(c, 0); setBottomMarginCalculated(true); ensureChildren(c); if (getChildrenContentType() == CONTENT_BLOCK) { for (Iterator i = getChildIterator(); i.hasNext();) { BlockBox child = (BlockBox) i.next(); child.collapseEmptySubtreeMargins(c, result); } } }
private void collapseTopMargin( LayoutContext c, boolean calculationRoot, MarginCollapseResult result) { if (! isTopMarginCalculated()) { if (! isSkipWhenCollapsingMargins()) { calcDimensions(c); RectPropertySet margin = getMargin(c); result.update((int) margin.top()); if (! calculationRoot && (int) margin.top() != 0) { setMarginTop(c, 0); } if (isMayCollapseMarginsWithChildren() && isNoTopPaddingOrBorder(c)) { ensureChildren(c); if (getChildrenContentType() == CONTENT_BLOCK) { for (Iterator i = getChildIterator(); i.hasNext();) { BlockBox child = (BlockBox) i.next(); child.collapseTopMargin(c, false, result); if (child.isSkipWhenCollapsingMargins()) { continue; } break; } } } } setTopMarginCalculated(true); } }
private void collapseTopMargin( LayoutContext c, boolean calculationRoot, MarginCollapseResult result) { if (! isTopMarginCalculated()) { if (! isSkipWhenCollapsingMargins()) { calcDimensions(c); RectPropertySet margin = getMargin(c); result.update((int) margin.top()); if (! calculationRoot && (int) margin.top() != 0) { setMarginTop(c, 0); } if (isMayCollapseMarginsWithChildren() && isNoTopPaddingOrBorder(c)) { ensureChildren(c); if (getChildrenContentType() == CONTENT_BLOCK) { for (Iterator i = getChildIterator(); i.hasNext();) { BlockBox child = (BlockBox) i.next(); child.collapseTopMargin(c, false, result); if (child.isSkipWhenCollapsingMargins()) { continue; } break; } } } } setTopMarginCalculated(true); } }
public void reset(LayoutContext c) { super.reset(c); setTopMarginCalculated(false); setBottomMarginCalculated(false); setDimensionsCalculated(false); setMinMaxCalculated(false); setChildrenHeight(0); if (isReplaced()) { getReplacedElement().detach(c); setReplacedElement(null); } if (getChildrenContentType() == BlockBox.CONTENT_INLINE) { removeAllChildren(); } if (isFloated()) { _floatedBoxData.getManager().removeFloat(this); } if (getStyle().isRunning()) { c.getRootLayer().removeRunningBlock(this); } }
public void reset(LayoutContext c) { super.reset(c); setTopMarginCalculated(false); setBottomMarginCalculated(false); setDimensionsCalculated(false); setMinMaxCalculated(false); setChildrenHeight(0); if (isReplaced()) { getReplacedElement().detach(c); setReplacedElement(null); } if (getChildrenContentType() == BlockBox.CONTENT_INLINE) { removeAllChildren(); } if (isFloated()) { _floatedBoxData.getManager().removeFloat(this); _floatedBoxData.getDrawingLayer().removeFloat(this); } if (getStyle().isRunning()) { c.getRootLayer().removeRunningBlock(this); } }
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); }
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); }