private void createSubtree ( Node n , BoxTreeCreationStatus stat ) { //store current status for the parent stat . parent . curstat = new BoxTreeCreationStatus ( stat ) ; //Create the new box for the child Box newbox ; boolean istext = false ; if ( n . getNodeType ( ) == Node . TEXT_NODE ) { newbox = createTextBox ( ( Text ) n , stat ) ; istext = true ; } else newbox = createElementBox ( ( Element ) n , stat ) ; //Create the child subtree if ( ! istext ) { //Determine the containing boxes of the children BoxTreeCreationStatus newstat = new BoxTreeCreationStatus ( stat ) ; newstat . parent = ( ElementBox ) newbox ; if ( ( ( ElementBox ) newbox ) . mayContainBlocks ( ) ) //the new box forms a block context { BlockBox block = ( BlockBox ) newbox ; //propagate overflow if necessary if ( ! overflowPropagated ) overflowPropagated = viewport . checkPropagateOverflow ( block ) ; //positioned element? if ( block . position == BlockBox . POS_ABSOLUTE || block . position == BlockBox . POS_RELATIVE || block . position == BlockBox . POS_FIXED ) { //A positioned box forms a content box for following absolutely positioned boxes newstat . absbox = block ; //update clip box for the block ElementBox cblock = block . getContainingBlockBox ( ) ; if ( cblock instanceof BlockBox && ( cblock . getClipBlock ( ) == null || ( ( BlockBox ) cblock ) . getOverflowX ( ) != Overflow . VISIBLE ) ) block . setClipBlock ( ( BlockBox ) cblock ) ; else block . setClipBlock ( cblock . getClipBlock ( ) ) ; //A box with overflow:hidden creates a clipping box if ( block . overflowX != BlockBox . OVERFLOW_VISIBLE || block . clipRegion != null ) newstat . clipbox = block ; else newstat . clipbox = block . getClipBlock ( ) ; } else //not positioned element { //A box with overflow:hidden creates a clipping box if ( block . overflowX != BlockBox . OVERFLOW_VISIBLE ) newstat . clipbox = block ; } //Any block box forms a containing box for not positioned elements newstat . contbox = block ; //Last inflow box is local for block boxes newstat . lastinflow = null ; //TODO this does not work in some cases (absolute.html) //create the subtree createBoxTree ( newstat ) ; //remove trailing whitespaces in blocks removeTrailingWhitespaces ( block ) ; } else createBoxTree ( newstat ) ; } //Add the new box to the parent according to its type addToTree ( newbox , stat ) ; }
Creates a subtree of a parent box that corresponds to a single child DOM node of this box and adds the subtree to the complete tree .