hasFirstLinePCs, pendingInlineLayers);
hasFirstLinePCs, pendingInlineLayers, markerData);
    public static void layoutContent(LayoutContext c, Box box, List contentList) {        int maxAvailableWidth = c.getExtents().width;        int remainingWidth = maxAvailableWidth;        int minimumLineHeight = (int) c.getCurrentStyle().getLineHeight(c);        LineBox currentLine = newLine(c, null, box);        LineBox previousLine = null;        InlineBox currentIB = null;        InlineBox previousIB = null;        List elementStack = new ArrayList();        if (box instanceof AnonymousBlockBox) {            List pending = ((BlockBox) box.getParent()).getPendingInlineElements();            if (pending != null) {                currentIB = addNestedInlineBoxes(c, currentLine, pending,                         maxAvailableWidth);                elementStack = pending;            }        }        CalculatedStyle parentStyle = c.getCurrentStyle();        int indent = (int) parentStyle.getFloatPropertyProportionalWidth(CSSName.TEXT_INDENT, maxAvailableWidth, c);        remainingWidth -= indent;        currentLine.x = indent;                MarkerData markerData = c.getCurrentMarkerData();        if (markerData != null &&                 box.getStyle().getCalculatedStyle().isIdent(                        CSSName.LIST_STYLE_POSITION, IdentValue.INSIDE)) {            remainingWidth -= markerData.getLayoutWidth();            currentLine.x += markerData.getLayoutWidth();        }        remainingWidth -= c.getBlockFormattingContext().getFloatDistance(c, currentLine, remainingWidth);        List pendingFloats = new ArrayList();        int pendingLeftMBP = 0;        int pendingRightMBP = 0;        boolean hasFirstLinePCs = false;        List pendingInlineLayers = new ArrayList();                if (c.getFirstLinesTracker().hasStyles()) {            c.getFirstLinesTracker().pushStyles(c);            hasFirstLinePCs = true;        }        boolean needFirstLetter = c.getFirstLettersTracker().hasStyles();                for (int i = 0; i < contentList.size(); i++) {            Object o = contentList.get(i);                        if (o instanceof FirstLineStyle || o instanceof FirstLetterStyle) {                continue;            }            if (o instanceof StylePush) {                StylePush sp = (StylePush) o;                CascadedStyle cascaded = sp.getStyle(c);                c.pushStyle(cascaded);                CalculatedStyle style = c.getCurrentStyle();                previousIB = currentIB;                currentIB = new InlineBox(sp.getElement(), style, maxAvailableWidth);                currentIB.calculateHeight(c);                elementStack.add(new InlineBoxInfo(cascaded, currentIB));                if (previousIB == null) {                    currentLine.addChild(c, currentIB);                } else {                    previousIB.addInlineChild(c, currentIB);                }                                //To break the line well, assume we don't just want to paint padding on next line                pendingLeftMBP += style.getLeftMarginBorderPadding(c, maxAvailableWidth);                pendingRightMBP += style.getRightMarginBorderPadding(c, maxAvailableWidth);                continue;            }            if (o instanceof StylePop) {                CalculatedStyle style = c.getCurrentStyle();                int rightMBP = style.getRightMarginBorderPadding(c, maxAvailableWidth);                pendingRightMBP -= rightMBP;                remainingWidth -= rightMBP;                elementStack.remove(elementStack.size() - 1);                currentIB.setEndsHere(true);                                if (currentIB.getStyle().requiresLayer()) {                    if (currentIB.element == null ||                             currentIB.element != c.getLayer().getMaster().element) {                        throw new RuntimeException("internal error");                    }                    c.getLayer().setEnd(currentIB);                    c.popLayer();                    pendingInlineLayers.add(currentIB.getContainingLayer());                }                previousIB = currentIB;                currentIB = currentIB.getParent() instanceof LineBox ?                        null : (InlineBox) currentIB.getParent();                c.popStyle();                continue;            }            Content content = (Content) o;            if (mustBeTakenOutOfFlow(content)) {                remainingWidth -= processOutOfFlowContent(c, content, currentLine,                         remainingWidth, pendingFloats);            } else if (isInlineBlock(content)) {                Box inlineBlock = layoutInlineBlock(c, box, content);                if (inlineBlock.getWidth() > remainingWidth && currentLine.isContainsContent()) {                    saveLine(currentLine, previousLine, c, box, minimumLineHeight,                            maxAvailableWidth, elementStack, pendingFloats,                             hasFirstLinePCs, pendingInlineLayers);                    previousLine = currentLine;                    currentLine = newLine(c, previousLine, box);                    currentIB = addNestedInlineBoxes(c, currentLine, elementStack,                             maxAvailableWidth);                    previousIB = currentIB == null || currentIB.getParent() instanceof LineBox ?                            null : (InlineBox) currentIB.getParent();                    remainingWidth = maxAvailableWidth;                    remainingWidth -= c.getBlockFormattingContext().getFloatDistance(c, currentLine, remainingWidth);                                        if (inlineBlock.getLayer() != null) {                        inlineBlock.getLayer().detach();                    }                    inlineBlock = layoutInlineBlock(c, box, content);                }                if (currentIB == null) {                    currentLine.addChild(c, inlineBlock);                } else {                    currentIB.addInlineChild(c, inlineBlock);                }                currentLine.setContainsContent(true);                currentLine.setContainsBlockLevelContent(true);                remainingWidth -= inlineBlock.getWidth();                                needFirstLetter = false;            } else {                TextContent text = (TextContent) content;                LineBreakContext lbContext = new LineBreakContext();                lbContext.setMaster(TextUtil.transformText(text.getText(), c.getCurrentStyle()));                do {                    lbContext.reset();                    int fit = 0;                    if (lbContext.getStart() == 0) {                        fit += pendingLeftMBP;                    }                    if (hasTrimmableLeadingSpace(currentLine, c.getCurrentStyle(),                            lbContext)) {                        lbContext.setStart(lbContext.getStart() + 1);                    }                    if (needFirstLetter && !lbContext.isFinished()) {                        InlineBox firstLetter =                            addFirstLetterBox(c, currentLine, currentIB, lbContext,                                     maxAvailableWidth, remainingWidth);                        remainingWidth -= firstLetter.getInlineWidth();                        needFirstLetter = false;                    } else {                        lbContext.saveEnd();                        InlineText inlineText = layoutText(                                c, remainingWidth - fit, lbContext, false);                        if (!lbContext.isUnbreakable() ||                                (lbContext.isUnbreakable() && ! currentLine.isContainsContent())) {                            currentIB.addInlineChild(c, inlineText);                            currentLine.setContainsContent(true);                            lbContext.setStart(lbContext.getEnd());                            remainingWidth -= inlineText.getWidth();                        } else {                            lbContext.resetEnd();                        }                    }                    if (lbContext.isNeedsNewLine()) {                        saveLine(currentLine, previousLine, c, box, minimumLineHeight,                                maxAvailableWidth, elementStack, pendingFloats,                                 hasFirstLinePCs, pendingInlineLayers);                        if (currentLine.isFirstLine() && hasFirstLinePCs) {                            lbContext.setMaster(TextUtil.transformText(                                    text.getText(), c.getCurrentStyle()));                        }                        previousLine = currentLine;                        currentLine = newLine(c, previousLine, box);                        currentIB = addNestedInlineBoxes(c, currentLine, elementStack,                                 maxAvailableWidth);                        previousIB = currentIB.getParent() instanceof LineBox ?                                null : (InlineBox) currentIB.getParent();                        remainingWidth = maxAvailableWidth;                        remainingWidth -= c.getBlockFormattingContext().getFloatDistance(c, currentLine, remainingWidth);                    }                } while (!lbContext.isFinished());            }        }        saveLine(currentLine, previousLine, c, box, minimumLineHeight,                maxAvailableWidth, elementStack, pendingFloats, hasFirstLinePCs,                pendingInlineLayers);        if (box instanceof AnonymousBlockBox) {            ((BlockBox) box.getParent()).setPendingInlineElements(elementStack.size() == 0 ? null : elementStack);        }                if (!c.shrinkWrap()) box.contentWidth = maxAvailableWidth;                box.setHeight(currentLine.y + currentLine.getHeight());    }