openInlineBoxes = new ArrayList(openInlineBoxes);
    public static void layoutContent(LayoutContext c, BlockBox box) {        int maxAvailableWidth = box.getContentWidth();        int remainingWidth = maxAvailableWidth;        LineBox currentLine = newLine(c, null, box);        LineBox previousLine = null;        InlineLayoutBox currentIB = null;        InlineLayoutBox previousIB = null;                int contentStart = 0;        List openInlineBoxes = null;                if (box instanceof AnonymousBlockBox) {            openInlineBoxes = ((AnonymousBlockBox)box).getOpenInlineBoxes();            if (openInlineBoxes != null) {                currentIB = addOpenInlineBoxes(c, currentLine, openInlineBoxes, maxAvailableWidth);            }        }                if (openInlineBoxes == null) {            openInlineBoxes = new ArrayList();        }                remainingWidth -= c.getBlockFormattingContext().getFloatDistance(c, currentLine, remainingWidth);        CalculatedStyle parentStyle = box.getStyle();        int minimumLineHeight = (int) parentStyle.getLineHeight(c);        int indent = (int) parentStyle.getFloatPropertyProportionalWidth(CSSName.TEXT_INDENT, maxAvailableWidth, c);        remainingWidth -= indent;        contentStart += indent;                MarkerData markerData = c.getCurrentMarkerData();        if (markerData != null &&                 box.getStyle().isIdent(                        CSSName.LIST_STYLE_POSITION, IdentValue.INSIDE)) {            remainingWidth -= markerData.getLayoutWidth();            contentStart += markerData.getLayoutWidth();        }        c.setCurrentMarkerData(null);        List pendingFloats = new ArrayList();        int pendingLeftMBP = 0;        int pendingRightMBP = 0;        boolean hasFirstLinePEs = false;        List pendingInlineLayers = new ArrayList();                if (c.getFirstLinesTracker().hasStyles()) {            box.styleText(c, c.getFirstLinesTracker().deriveAll(box.getStyle()));            hasFirstLinePEs = true;        }        boolean needFirstLetter = c.getFirstLettersTracker().hasStyles();                for (Iterator i = box.getInlineContent().iterator(); i.hasNext(); ) {            Styleable node = (Styleable)i.next();                        if (node.getStyle().isInline()) {                InlineBox iB = (InlineBox)node;                                CalculatedStyle style = iB.getStyle();                if (iB.isStartsHere()) {                    previousIB = currentIB;                    currentIB = new InlineLayoutBox(c, iB.getElement(), style, maxAvailableWidth);                    openInlineBoxes.add(iB);                    if (previousIB == null) {                        currentLine.addChildForLayout(c, currentIB);                    } else {                        previousIB.addInlineChild(c, currentIB);                    }                                        if (currentIB.element != null) {                        // FIXME Clean this up.  Name and id should be in same namespace                        // Also, only current use of id is for links.  Make that explicit                        // in the API?                        String name = c.getNamespaceHandler().getAnchorName(currentIB.element);                        if (name != null) {                            c.addNamedAnchor(name, currentIB);                        }                        String id = c.getNamespaceHandler().getID(currentIB.element);                        if (id != null && ! id.equals("")) {                            c.addIDBox(id, currentIB);                        }                    }                                        //To break the line well, assume we don't just want to paint padding on next line                    pendingLeftMBP += style.getMarginBorderPadding(                            c, maxAvailableWidth, CalculatedStyle.LEFT);                    pendingRightMBP += style.getMarginBorderPadding(                            c, maxAvailableWidth, CalculatedStyle.RIGHT);                }                                LineBreakContext lbContext = new LineBreakContext();                lbContext.setMaster(TextUtil.transformText(iB.getText(), style));                                if (iB.isDynamicFunction()) {                    lbContext.setMaster(iB.getContentFunction().getLayoutReplacementText());                }                                do {                    lbContext.reset();                    int fit = 0;                    if (lbContext.getStart() == 0) {                        fit += pendingLeftMBP;                    }                    if (hasTrimmableLeadingSpace(currentLine, style, lbContext)) {                        lbContext.setStart(lbContext.getStart() + 1);                    }                    if (needFirstLetter && !lbContext.isFinished()) {                        InlineLayoutBox firstLetter =                            addFirstLetterBox(c, currentLine, currentIB, lbContext,                                     maxAvailableWidth, remainingWidth);                        remainingWidth -= firstLetter.getInlineWidth();                        needFirstLetter = false;                    } else {                        lbContext.saveEnd();                        InlineText inlineText = layoutText(                                c, iB.getStyle(), remainingWidth - fit, lbContext, false);                        if (!lbContext.isUnbreakable() ||                                (lbContext.isUnbreakable() && ! currentLine.isContainsContent())) {                            if (iB.isDynamicFunction()) {                                inlineText.setFunctionData(new FunctionData(                                        iB.getContentFunction(), iB.getText()));                            }                            currentLine.setContainsDynamicFunction(inlineText.isDynamicFunction());                            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, pendingFloats,                                 hasFirstLinePEs, pendingInlineLayers, markerData,                                contentStart);                        markerData = null;                        contentStart = 0;                        if (currentLine.isFirstLine() && hasFirstLinePEs) {                            lbContext.setMaster(TextUtil.transformText(iB.getText(), iB.getStyle()));                        }                        previousLine = currentLine;                        currentLine = newLine(c, previousLine, box);                        currentIB = addOpenInlineBoxes(c, currentLine, openInlineBoxes,  maxAvailableWidth);                        previousIB = currentIB.getParent() instanceof LineBox ?                                null : (InlineLayoutBox) currentIB.getParent();                        remainingWidth = maxAvailableWidth;                        remainingWidth -= c.getBlockFormattingContext().getFloatDistance(c, currentLine, remainingWidth);                    }                } while (!lbContext.isFinished());                                if (iB.isEndsHere()) {                    int rightMBP = style.getMarginBorderPadding(                            c, maxAvailableWidth, CalculatedStyle.RIGHT);                    pendingRightMBP -= rightMBP;                    remainingWidth -= rightMBP;                    openInlineBoxes.remove(openInlineBoxes.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 : (InlineLayoutBox) currentIB.getParent();                }            } else {               BlockBox child = (BlockBox)node;                              if (child.getStyle().isNonFlowContent()) {                   remainingWidth -= processOutOfFlowContent(                           c, currentLine, child, remainingWidth, pendingFloats);               } else if (child.getStyle().isInlineBlock()) {                   layoutInlineBlock(c, box, child);                   if (child.getWidth() > remainingWidth && currentLine.isContainsContent()) {                       saveLine(currentLine, previousLine, c, box, minimumLineHeight,                               maxAvailableWidth, pendingFloats,  hasFirstLinePEs,                                pendingInlineLayers, markerData, contentStart);                       markerData = null;                       contentStart = 0;                       previousLine = currentLine;                       currentLine = newLine(c, previousLine, box);                       currentIB = addOpenInlineBoxes(c, currentLine, openInlineBoxes, maxAvailableWidth);                       previousIB = currentIB == null || currentIB.getParent() instanceof LineBox ?                               null : (InlineLayoutBox) currentIB.getParent();                       remainingWidth = maxAvailableWidth;                       remainingWidth -= c.getBlockFormattingContext().getFloatDistance(c, currentLine, remainingWidth);                                              child.reset(c);                       layoutInlineBlock(c, box, child);                   }                   if (currentIB == null) {                       currentLine.addChildForLayout(c, child);                   } else {                       currentIB.addInlineChild(c, child);                   }                   currentLine.setContainsContent(true);                   currentLine.setContainsBlockLevelContent(true);                   remainingWidth -= child.getWidth();                                      needFirstLetter = false;               }            }        }        currentLine.maybeTrimTrailingSpace(c);        saveLine(currentLine, previousLine, c, box, minimumLineHeight,                maxAvailableWidth, pendingFloats, hasFirstLinePEs,                pendingInlineLayers, markerData, contentStart);        if (currentLine.isFirstLine() && currentLine.height == 0 && markerData != null) {            c.setCurrentMarkerData(markerData);        }        markerData = null;        if (!c.shrinkWrap()) box.contentWidth = maxAvailableWidth;                box.setHeight(currentLine.y + currentLine.getHeight());    }