void applyCSS(HTMLElement document,HTMLComponent htmlC,Vector externalCSS,Vector embeddedCSS){
  int externalSize=0;
  int embeddedSize=0;
  if (externalCSS != null) {
    externalSize=externalCSS.size();
  }
  if (embeddedCSS != null) {
    embeddedSize=embeddedCSS.size();
  }
  if (externalSize + embeddedSize == 0) {
    applyStyleAttributeRecursive(document,htmlC);
  }
 else {
    CSSElement[] css=new CSSElement[externalSize + embeddedSize];
    for (int i=0; i < externalSize; i++) {
      css[i]=(CSSElement)externalCSS.elementAt(i);
    }
    for (int i=0; i < embeddedSize; i++) {
      css[i + externalSize]=(CSSElement)embeddedCSS.elementAt(i);
    }
    css=sortSelectorsBySpecificity(css);
    applyCSS(document,htmlC,css,null,null);
  }
}

void applyCSS ( HTMLElement document , HTMLComponent htmlC , Vector externalCSS , Vector embeddedCSS ) { int externalSize = 0 ; int embeddedSize = 0 ; if ( externalCSS != null ) { externalSize = externalCSS . size ( ) ; } if ( embeddedCSS != null ) { embeddedSize = embeddedCSS . size ( ) ; } if ( externalSize + embeddedSize == 0 ) { applyStyleAttributeRecursive ( document , htmlC ) ; } else { CSSElement [ ] css = new CSSElement [ externalSize + embeddedSize ] ; for ( int i = 0 ; i < externalSize ; i ++ ) { css [ i ] = ( CSSElement ) externalCSS . elementAt ( i ) ; } for ( int i = 0 ; i < embeddedSize ; i ++ ) { css [ i + externalSize ] = ( CSSElement ) embeddedCSS . elementAt ( i ) ; } css = sortSelectorsBySpecificity ( css ) ; applyCSS ( document , htmlC , css , null , null ) ; } }
applies all css directives to the given document and htmlcomponent , including external css files , embedded css segments and inline css ( style attribute ) this is called by htmlcomponent after the document was fully parsed and all external css have been retrieved . this method actually initializes a sorted css array to be used by the recursive private applycss method .
