inlineList.add(new FirstLineStyle(firstLine));
firstLineStyle = new FirstLineStyle(firstLine);
    public static List getInlineContentList(Element elem, Context c) {        List inlineList = new LinkedList();        List blockList = null;        if (elem == null) {            throw new NullPointerException("Trying to get ContentList for null element");        }        if (!elem.hasChildNodes()) {            //u.p("it's empty");            return inlineList;        }        // u.p("starting at: " + root);        Node curr = elem;        TextContent textContent = null;        CalculatedStyle style = c.css.getStyle(elem);        if (mayHaveFirstLine(style)) {            //put in a marker if there is first-line styling            CascadedStyle firstLine = c.css.getPseudoElementStyle(curr, "first-line");            if (firstLine != null) {                inlineList.add(new FirstLineStyle(firstLine));            }        }        if (mayHaveFirstLetter(style)) {            //put in a marker if there is first-letter styling            CascadedStyle firstLetter = c.css.getPseudoElementStyle(curr, "first-letter");            if (firstLetter != null) {                inlineList.add(new FirstLetterStyle(firstLetter));            }        }        while (true) {            // u.p("now list = " + list);            if (style == null) style = c.css.getStyle(curr);            // handle the nodes            // skip first time if root was the element            handling: if (curr != elem) {                if (curr.getNodeType() == Node.TEXT_NODE) {                    // u.p("adding textContent: " + curr);                    String text = curr.getNodeValue();                    if (textContent == null) textContent = new TextContent((Element) curr.getParentNode(), style);                    textContent.append(text);                    break handling;                }                if (curr.getNodeType() != Node.ELEMENT_NODE) break handling;                //Only elements here:                CalculatedStyle elementStyle = c.css.getStyle(curr);                if (LayoutUtil.isReplaced(c, curr)) {                    // u.p("adding replaced: " + curr);                    if (textContent != null) {                        inlineList.add(textContent);                        textContent = null;                    }                    inlineList.add(new ReplacedContent((Element) curr, elementStyle));                    break handling;                }                //TODO: check CSS-spec 9.7 for computing values for floats                if (LayoutUtil.isFloated(elementStyle)) {                    // u.p("adding floated block: " + curr);                    if (textContent != null) {                        inlineList.add(textContent);                        textContent = null;                    }                    inlineList.add(new FloatedBlockContent((Element) curr, elementStyle));                    break handling;                }                if (LayoutUtil.isBlockNode(curr, c)) {                    if (textContent != null) {                        inlineList.add(textContent);                        textContent = null;                    }                    if (blockList == null) blockList = new LinkedList();                    //TODO: handle run-in here                    blockList.add(new AnonymousBlockContent(elem, c.css.getStyle(elem), inlineList));                    inlineList = new LinkedList();                    blockList.add(new BlockContent((Element) curr, elementStyle));                }                //TODO: handle run-in content separately                //TODO: how about Absolute and Fixed children?            }            if (curr.getNodeType() == Node.ELEMENT_NODE) {                //TODO: before and after may be block!                //<br/> handling should be done by :before content                CascadedStyle before = c.css.getPseudoElementStyle(curr, "before");                if (before != null) {                    CalculatedStyle parentStyle = c.css.getStyle(curr);                    CalculatedStyle derived = c.css.getDerivedStyle(parentStyle, before);                    String content = derived.getStringProperty(CSSName.CONTENT);                    if (!content.equals("")) {                        if (textContent != null) {                            inlineList.add(textContent);                            textContent = null;                        }                        textContent = new TextContent((Element) curr, derived);                        textContent.append(content.replaceAll("\\\\A", "\n"));                        inlineList.add(textContent);                        textContent = null;                    }                    //do not reset style here, because if this element is empty, we will not have changed context                }            }            if (curr.hasChildNodes()) {                // u.p("about to test: " + curr);                // if it's a floating block we don't want to recurse                if (!LayoutUtil.isFloatedBlock(curr, c) &&                        !LayoutUtil.isReplaced(c, curr)) {                    //new element, new style                    if (textContent != null) {                        inlineList.add(textContent);                        textContent = null;                    }                    style = null;                    curr = curr.getFirstChild();                    // u.p("going to first child " + curr);                    continue;                }                // it's okay to recurse if it's the root that's the float,                // not the node being examined. this only matters when we                // start the loop at the root of a floated block                if (LayoutUtil.isFloatedBlock(curr, c)) {                    if (curr == elem) {                        //ok, the style should already be set and textContent should be null                        curr = curr.getFirstChild();                        continue;                    }                }            } else if (curr.getNodeType() == Node.ELEMENT_NODE) {                //it might still have :after content                CascadedStyle after = c.css.getPseudoElementStyle((Element) curr, "after");                if (after != null) {                    CalculatedStyle parentStyle = c.css.getStyle(curr);                    CalculatedStyle derived = c.css.getDerivedStyle(parentStyle, after);                    String content = derived.getStringProperty(CSSName.CONTENT);                    if (!content.equals("")) {                        if (textContent != null) {                            inlineList.add(textContent);                            textContent = null;                        }                        textContent = new TextContent((Element) curr, derived);                        textContent.append(content.replaceAll("\\\\A", "\n"));                        inlineList.add(textContent);                        textContent = null;                    }                }            }            // keep going up until we get another sibling            // or we are at elem.            while (true) {                if (curr.getNodeType() == Node.ELEMENT_NODE) {                    //check for :after content                    //this has not been checked yet because this element had child nodes                    CascadedStyle after = c.css.getPseudoElementStyle((Element) curr, "after");                    if (after != null) {                        CalculatedStyle parentStyle = c.css.getStyle(curr);                        CalculatedStyle derived = c.css.getDerivedStyle(parentStyle, after);                        String content = derived.getStringProperty(CSSName.CONTENT);                        if (!content.equals("")) {                            //textContent must be null here                            textContent = new TextContent((Element) curr, derived);                            textContent.append(content.replaceAll("\\\\A", "\n"));                            inlineList.add(textContent);                            textContent = null;                        }                    }                }                // u.p("going to parent: " + curr);                // if we are at the top then return null                if (curr == elem) {                    if (blockList != null) {//this was block content                        if (inlineList.size() != 0) {                            blockList.add(new AnonymousBlockContent(elem, c.css.getStyle(elem), inlineList));                        }                        return blockList;                    }                    return inlineList;                    //return null;                }                if (curr.getNextSibling() != null) {                    curr = curr.getNextSibling();                    // u.p("going to next sibling: " + curr);                    break;                }                curr = curr.getParentNode();                //new element, new style                if (textContent != null) {                    inlineList.add(textContent);                    textContent = null;                }                style = null;            }        }    }