if(debug_counter > 143) {
final int limit = 20; if(debug_counter > limit) {
public Box layoutChildren(Context c, Box box) {    //u.p("InlineLayout.layoutChildren(: " + box);    //u.p("parent box = " + c.parent_box);    //u.p("placement point = " + c.placement_point);    if(!box.isAnonymous()) {        if(isBlockLayout(box.getElement(),c)) {            return super.layoutChildren(c,box);        }    }    int debug_counter = 0;    int childcount = 0;    BlockBox block = (BlockBox)box;    // calculate the initial position and dimensions    Rectangle bounds = new Rectangle();    bounds.width = c.getExtents().width;    bounds.width -= box.margin.left + box.border.left + box.padding.left +        box.padding.right + box.border.right + box.margin.right;    bounds.x = 0;    bounds.y = 0;    bounds.height = 0;    int remaining_width = bounds.width;    // account for text-indent    LineBox curr_line = new LineBox();    curr_line.x = bounds.x;    //curr_line.width = remaining_width;    curr_line.width = 0;    Element elem = block.getElement();    remaining_width = InlineUtil.doTextIndent(c,elem,remaining_width,curr_line);    LineBox prev_line = new LineBox();    prev_line.y = bounds.y;    prev_line.height = 0;    InlineBox prev_inline = null;        //boolean adjusted_left_tab = false;    if(c.getLeftTab().y > 0) {        c.getLeftTab().y -= c.placement_point.y;    }    if(c.getRightTab().y > 0) {        c.getRightTab().y -= c.placement_point.y;    }    if(c.getRightTab().y < 0) {        c.getRightTab().y = 0;    }    if(c.getLeftTab().y < 0) {        c.getLeftTab().y = 0;    }    InlineBox prev_align_inline = null;    List inline_node_list = null;    if(box.isAnonymous()) {        inline_node_list = ((AnonymousBlockBox)box).node_list;    } else {        inline_node_list = InlineUtil.getInlineNodeList(elem,elem,c);    }    // loop until no more nodes    Node current_node = InlineUtil.nextTextNode(inline_node_list);    TextUtil.stripWhitespace(c,current_node,elem);    // ajdust the first line for tabs    remaining_width = adjustForTab(c, prev_line, remaining_width);    while(current_node != null) {        // loop until no more text in this node        while(true) {            // test if there is no more text in the current text node            // if there is a prev, and if the prev was part of this current node            if(prev_inline != null && prev_inline.node == current_node) {                //u.p("prev inline = " + prev_inline);                //u.p("current text len = " + current_node.getNodeValue().length());                // replaced elements aren't split, so done with this one                if(isReplaced(current_node)) {                    //u.p("it's replaced. breaking");                    break;                }                if(isFloatedBlock(current_node,c)) {                    break;                }                if(InlineUtil.isBreak(current_node)) {                    break;                }                // if no more unused text in this node                if(prev_inline.end_index >= current_node.getNodeValue().length()) {                    // then break                    //u.p("used up all of the text. breaking");                    break;                }            }            if(bounds.width < 100) {                //u.p("warning. width < 0 " + width);            }            debug_counter++;            if(debug_counter > 143) {                u.on();                u.p("previous inline = " + prev_inline);                u.p("current line = " + curr_line);                u.p("lines = ");                //u.p(block.boxes);                u.p("current node = " + current_node + " text= " + current_node.getNodeValue());                u.p("rem width = " + remaining_width + " width " + bounds.width);            }            if(debug_counter > 143) {                u.p("element = " + elem);                org.joshy.x.p(elem);                u.p("previous inline = " + prev_inline);                u.p("current inline = " + curr_line);                u.p("lines = ");                //u.p(block.boxes);                u.p("db 1 hit");                throw new InfiniteLoopError("Infinite loop detected in InlineLayout");            }            // look at current inline            // break off the longest section that will fit            //u.p("looking for another inline from the text: " + current_node.getNodeValue());            InlineBox new_inline = this.calculateInline(c,current_node,remaining_width,bounds.width,                curr_line, prev_inline, elem, prev_align_inline);            //u.p("new inline box: " + new_inline);            // if this inline needs to be on a new line            if(new_inline.break_before && !new_inline.floated) {                // finish up the current line                remaining_width = bounds.width;                saveLine(curr_line, prev_line, elem, bounds.width, bounds.x, c, block);                bounds.height += curr_line.height;                prev_line = curr_line;                curr_line = new LineBox();                curr_line.x = bounds.x;                // adjust remaining width for floats                //u.p("left tab = " + left_tab + " right tab = " + c.getRightTab());                //if(c.getLeftTab().y > 0) {                remaining_width = adjustForTab(c, prev_line, remaining_width);                //curr_line.width = remaining_width;                curr_line.width = 0;            }            // save the new inline to the list            curr_line.addChild(new_inline);            // calc new height of the line            // don't count the inline towards the line height and            //line baseline if it's a floating inline.            if(!isFloated(new_inline,c)) {                if(!this.isFloatedBlock(new_inline.node,c)) {                    if(new_inline.height + new_inline.y > curr_line.height) {                        curr_line.height = new_inline.height + new_inline.y;                    }                    if(new_inline.baseline > curr_line.baseline) {                        curr_line.baseline = new_inline.baseline;                    }                }            }            InlineUtil.handleFloated(c, new_inline, curr_line, bounds.width, elem);            // calc new width of the line            curr_line.width += new_inline.width;            // reduce the available width            remaining_width = remaining_width - new_inline.width;            // if the last inline was at the end of a line, then go to next line            if(new_inline.break_after) {                // then remaining_width = max_width                remaining_width = bounds.width;                //u.p("width = " + width);                // save the line                //u.p("curr line = " + curr_line);                saveLine(curr_line, prev_line,elem,bounds.width,bounds.x,c,block);                bounds.height += curr_line.height;                //u.p("saved line: " + curr_line);                prev_line = curr_line;                curr_line = new LineBox();                curr_line.x = bounds.x;                // adjust remaining width for floats                //u.p("rem width = " + remaining_width);                //if(c.getLeftTab().y > 0) {                remaining_width = adjustForTab(c, prev_line, remaining_width);                //curr_line.width = remaining_width;                curr_line.width = 0;                //u.p("now rem width = " + remaining_width);            }            // set the inline to use for left alignment            if(!isFloated(new_inline,c)) {                prev_align_inline = new_inline;            } else {                prev_align_inline = prev_inline;            }            prev_inline = new_inline;        }        current_node = InlineUtil.nextTextNode(inline_node_list);        TextUtil.stripWhitespace(c,current_node,elem);    }    saveLine(curr_line,prev_line,elem,bounds.width,bounds.x,c,block);    //u.p("saving line 2: " + curr_line);    bounds.height += curr_line.height;    block.width = bounds.width;    block.height = bounds.height;    block.x = 0;    block.y = 0;    //u.p("returning final block of: " + box);    //u.p("last tab = " + c.getLeftTab());    //if(adjusted_left_tab) {    c.getLeftTab().y += c.placement_point.y;    c.getRightTab().y += c.placement_point.y;    //}    //c.setLeftTab(old_left_tab);    //u.p("final tabl = " + c.getLeftTab());    return block;}