public void createBoxTree ( BoxTreeCreationStatus stat ) { boolean generated = false ; do { if ( stat . parent . isDisplayed ( ) ) { //add previously created boxes (the rest from the last twin) if ( stat . parent . preadd != null ) { addToTree ( stat . parent . preadd , stat ) ; stat . parent . preadd = null ; //don't need to keep this anymore } //create :before elements if ( stat . parent . previousTwin == null ) { Node n = createPseudoElement ( stat . parent , PseudoElementType . BEFORE ) ; if ( n != null && ( n . getNodeType ( ) == Node . ELEMENT_NODE || n . getNodeType ( ) == Node . TEXT_NODE ) ) { stat . curchild = - 1 ; createSubtree ( n , stat ) ; } } //create normal elements NodeList children = stat . parent . getElement ( ) . getChildNodes ( ) ; for ( int child = stat . parent . firstDOMChild ; child < stat . parent . lastDOMChild ; child ++ ) { Node n = children . item ( child ) ; if ( n . getNodeType ( ) == Node . ELEMENT_NODE || n . getNodeType ( ) == Node . TEXT_NODE ) { stat . curchild = child ; createSubtree ( n , stat ) ; } } //create :after elements if ( stat . parent . nextTwin == null ) { Node n = createPseudoElement ( stat . parent , PseudoElementType . AFTER ) ; if ( n != null && ( n . getNodeType ( ) == Node . ELEMENT_NODE || n . getNodeType ( ) == Node . TEXT_NODE ) ) { stat . curchild = children . getLength ( ) ; createSubtree ( n , stat ) ; } } normalizeBox ( stat . parent ) ; } //if a twin box has been created, continue creating the unprocessed boxes in the twin box if ( stat . parent . nextTwin != null ) { stat . parent = stat . parent . nextTwin ; generated = true ; } else generated = false ; } while ( generated ) ; }
Creates the box subtrees for all the child nodes of the DOM node corresponding to the box creatin status . Recursively creates the child boxes from the child nodes .