Node working = parent.getFirstChild();
boolean needStartText = inline;
boolean needEndText = inline;
if (working != null) {
InlineBox previousIB = null;
do {
Styleable child = null;
short nodeType = working.getNodeType();
if (nodeType == Node.ELEMENT_NODE) {
Element element = (Element) working;
CalculatedStyle style = sharedContext.getStyle(element);
if (style.isDisplayNone()) {
continue;
}
c.resolveCounters(style);
if (style.isIdent(CSSName.DISPLAY, IdentValue.TABLE_COLUMN)
|| style.isIdent(CSSName.DISPLAY, IdentValue.TABLE_COLUMN_GROUP)) {
if ((blockParent != null) &&
(blockParent.getStyle().isTable() || blockParent.getStyle().isInlineTable())) {
TableBox table = (TableBox) blockParent;
addColumnOrColumnGroup(c, table, element, style);
}
continue;
}
if (style.isInline()) {
if (needStartText) {
needStartText = false;
InlineBox iB = createInlineBox("", parent, parentStyle, null);
iB.setStartsHere(true);
iB.setEndsHere(false);
children.add(iB);
previousIB = iB;
}
createChildren(c, null, element, children, info, true);
if (inline) {
if (previousIB != null) {
previousIB.setEndsHere(false);
}
needEndText = true;
}
} else {
child = createBlockBox(style, info, false);
child.setStyle(style);
child.setElement(element);
if (style.isListItem()) {
BlockBox block = (BlockBox) child;
block.setListCounter(c.getCounterContext(style).getCurrentCounterValue("list-item"));
}
if (style.isTable() || style.isInlineTable()) {
TableBox table = (TableBox) child;
table.ensureChildren(c);
child = reorderTableContent(c, table);
}
if (!info.isContainsBlockLevelContent()
&& !style.isLayedOutInInlineContext()) {
info.setContainsBlockLevelContent(true);
}
BlockBox block = (BlockBox) child;
if (block.getStyle().mayHaveFirstLine()) {
block.setFirstLineStyle(c.getCss().getPseudoElementStyle(element,
"first-line"));
}
if (block.getStyle().mayHaveFirstLetter()) {
block.setFirstLetterStyle(c.getCss().getPseudoElementStyle(element,
"first-letter"));
}
//I think we need to do this to evaluate counters correctly
block.ensureChildren(c);
}
} else if (nodeType == Node.TEXT_NODE || nodeType == Node.CDATA_SECTION_NODE) {
needStartText = false;
needEndText = false;
Text textNode = (Text)working;
/*
StringBuffer text = new StringBuffer(textNode.getData());
Node maybeText = textNode;
while (true) {
maybeText = textNode.getNextSibling();
if (maybeText != null) {
short maybeNodeType = maybeText.getNodeType();
if (maybeNodeType == Node.TEXT_NODE ||
maybeNodeType == Node.CDATA_SECTION_NODE) {
textNode = (Text)maybeText;
text.append(textNode.getData());
} else {
break;
}
} else {
break;
}
}
working = textNode;
child = createInlineBox(text.toString(), parent, parentStyle, textNode);
*/
child = createInlineBox(textNode.getData(), parent, parentStyle, textNode);
InlineBox iB = (InlineBox) child;
iB.setEndsHere(true);
if (previousIB == null) {
iB.setStartsHere(true);
} else {
previousIB.setEndsHere(false);
}
previousIB = iB;
}
if (child != null) {
children.add(child);
}
} while ((working = working.getNextSibling()) != null);
}
if (needStartText || needEndText) {
InlineBox iB = createInlineBox("", parent, parentStyle, null);
iB.setStartsHere(needStartText);
iB.setEndsHere(needEndText);
children.add(iB);
}
insertGeneratedContent(c, parent, parentStyle, "after", children, info);
}