if ( prev_inline.end_index >= current_node.getNodeValue().length() ) {  break;
if(Configuration.isTrue("xr.layout.whitespace.experimental",false)) { if ( prev_inline.end_index >= prev_inline.getMasterText().length()) { break; } } else { if ( prev_inline.end_index >= current_node.getNodeValue().length() ) {  break; }
    public Box layoutChildren( Context c, Box box ) {        //u.p("starting to lay out the children");        if ( LayoutUtil.isHiddenNode( box.getElement(), c ) ) {            return box;        }        if ( !box.isAnonymous() ) {            if ( LayoutUtil.isBlockLayout( box.getElement(), c ) ) {                // u.p("doing up block for: " + box);                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;        validateBounds(bounds);        bounds.x = 0;        bounds.y = 0;        bounds.height = 0;        // prepare remaining width and first linebox        int remaining_width = bounds.width;        LineBox curr_line = new LineBox();        c.setFirstLine(true);        curr_line.setParent(box);        curr_line.x = bounds.x;        curr_line.width = 0;        // account for text-indent        Element elem = block.getElement();        remaining_width = InlineUtil.doTextIndent( c, elem, remaining_width, curr_line );        LineBox prev_line = new LineBox();        prev_line.setParent(box);        prev_line.y = bounds.y;        prev_line.height = 0;        InlineBox prev_inline = null;                InlineBox prev_align_inline = null;                // get the list of inlines for this run        List inline_node_list = null;        if ( box.isAnonymous() ) {            inline_node_list = ( (AnonymousBlockBox)box ).node_list;        } else {            inline_node_list = InlineUtil.getInlineNodeList( elem, elem, c );        }        //u.p("in box: " + box);        //u.p("final inline node list = ");        //u.p(inline_node_list);                // loop until no more nodes        Node current_node = InlineUtil.nextTextNode( inline_node_list );        TextUtil.stripWhitespace( c, current_node, elem );        // adjust the first line for tabs                remaining_width = FloatUtil.adjustForTab( c, prev_line, remaining_width );        while ( current_node != null ) {            // loop until no more text in this node            while ( true ) {                                                                // debugging check                if ( bounds.width < 0 ) {                    u.p( "bounds width = " + bounds.width );                    u.dump_stack();                    System.exit( -1 );                }                                                                                // 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 ) {                    // replaced elements aren't split, so done with this one                    if ( LayoutUtil.isReplaced(c, current_node ) ) {                        break;                    }                    if ( LayoutUtil.isFloatedBlock( current_node, c ) ) {                        break;                    }                    if ( c.getRenderingContext().getLayoutFactory().isBreak( current_node ) ) {                        break;                    }                    // if no more unused text in this node                    if ( prev_inline.end_index >= current_node.getNodeValue().length() ) {                        // then break                        break;                    }                }                                                                                // the crash warning code                if ( bounds.width < 1 ) {                    u.p( "warning. width < 1 " + bounds.width );                }                                                // look at current inline                // break off the longest section that will fit                InlineBox new_inline = calculateInline( c, current_node, remaining_width, bounds.width,                    curr_line, prev_inline, elem, prev_align_inline );                // if this inline needs to be on a new line                if ( new_inline.break_before && !new_inline.floated ) {                    // u.p("breaking before");                    // finish up the current line                    remaining_width = bounds.width;                    saveLine( curr_line, prev_line, elem, bounds.width, bounds.x, c, block , false);                    bounds.height += curr_line.height;                    prev_line = curr_line;                    curr_line = new LineBox();                    curr_line.x = bounds.x;                    // adjust remaining width for floats                    curr_line.y = prev_line.y + prev_line.height;                    curr_line.setParent(prev_line.getParent());                    //u.p("set parent to: " + curr_line.getParent());                    remaining_width = FloatUtil.adjustForTab( c, curr_line, 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 ( !LayoutUtil.isFloated( new_inline, c ) ) {                    if ( !LayoutUtil.isFloatedBlock( new_inline.node, c ) ) {                        //u.p("calcing new height of line");                        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;                        }                    }                }                                //u.p("curr line: " + curr_line);                //u.p("parent = " + curr_line.getParent());                FloatUtil.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 ) {                    // u.p("breaking after");                    // then remaining_width = max_width                    remaining_width = bounds.width;                    // save the line                    saveLine( curr_line, prev_line, elem, bounds.width, bounds.x, c, block , false);                    // increase bounds height to account for the new line                    bounds.height += curr_line.height;                    prev_line = curr_line;                    curr_line = new LineBox();                    curr_line.x = bounds.x;                    // adjust remaining width for floats                    curr_line.y = prev_line.y + prev_line.height;                    curr_line.setParent(prev_line.getParent());                    //u.p("set parent to: " + curr_line.getParent());                    remaining_width = FloatUtil.adjustForTab( c, curr_line, remaining_width );                    curr_line.width = 0;                }                                // set the inline to use for left alignment                if ( !LayoutUtil.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 , true);        bounds.height += curr_line.height;        block.width = bounds.width;        block.height = bounds.height;        block.x = 0;        block.y = 0;        return block;    }