protected void layoutBlockFloating ( BlockBox subbox , int wlimit , BlockLayoutStatus stat ) { subbox . setFloats ( new FloatList ( subbox ) , new FloatList ( subbox ) , 0 , 0 , 0 ) ; subbox . doLayout ( wlimit , true , true ) ; FloatList f = ( subbox . getFloating ( ) == FLOAT_LEFT ) ? fleft : fright ; //float list at my side FloatList of = ( subbox . getFloating ( ) == FLOAT_LEFT ) ? fright : fleft ; //float list at the opposite side int floatX = ( subbox . getFloating ( ) == FLOAT_LEFT ) ? floatXl : floatXr ; //float offset at this side int oFloatX = ( subbox . getFloating ( ) == FLOAT_LEFT ) ? floatXr : floatXl ; //float offset at the opposite side int fy = stat . y + floatY ; //float Y position if ( fy < f . getLastY ( ) ) fy = f . getLastY ( ) ; //don't place above the last placed box int fx = f . getWidth ( fy ) ; //total width of floats at this side if ( fx < floatX ) fx = floatX ; //stay in the containing box if it is narrower if ( fx == 0 && floatX < 0 ) fx = floatX ; //if it is wider (and there are no floating boxes yet) int ofx = of . getWidth ( fy ) ; //total width of floats at the opposite side if ( ofx < oFloatX ) ofx = oFloatX ; //stay in the containing box at the opposite side if ( ofx == 0 && oFloatX < 0 ) ofx = oFloatX ; //moving the floating box down until it fits while ( ( fx > floatX || ofx > oFloatX || stat . inlineWidth > 0 ) //if the space can be narrower at least at one side && ( stat . inlineWidth + fx - floatX + ofx - oFloatX + subbox . getWidth ( ) > wlimit ) ) //the subbox doesn't fit in this Y coordinate { int nexty = FloatList . getNextY ( fleft , fright , fy ) ; if ( nexty == - 1 ) fy += Math . max ( stat . maxh , getLineHeight ( ) ) ; //if we don't know try increasing by a line else fy = nexty ; //recompute the limits for the new fy fx = f . getWidth ( fy ) ; if ( fx < floatX ) fx = floatX ; if ( fx == 0 && floatX < 0 ) fx = floatX ; ofx = of . getWidth ( fy ) ; if ( ofx < oFloatX ) ofx = oFloatX ; if ( ofx == 0 && oFloatX < 0 ) ofx = oFloatX ; //do not consider current line below stat . inlineWidth = 0 ; } subbox . setPosition ( fx , fy ) ; f . add ( subbox ) ; //a floating box must enclose all the floats inside int floatw = maxFloatWidth ( fy , fy + subbox . getHeight ( ) ) ; //maximal width if ( floatw > stat . maxw ) stat . maxw = floatw ; if ( stat . maxw > wlimit ) stat . maxw = wlimit ; }
Calculates the position for a floating box in the given context .