NS_RELEASE(select);
nsSelectControlFrame::GetDesiredSize(nsIPresContext* aPresContext,                                     const nsHTMLReflowState& aReflowState,                                     nsHTMLReflowMetrics& aDesiredLayoutSize,                                     nsSize& aDesiredWidgetSize){  nsIDOMHTMLSelectElement* select = GetSelect();  if (!select) {    return;  }  nsIDOMHTMLCollection* options = GetOptions(select);  if (!options) {    return;  }  // get the css size   nsSize styleSize;  GetStyleSize(*aPresContext, aReflowState, styleSize);  // get the size of the longest option   PRInt32 maxWidth = 1;  PRUint32 numOptions;  options->GetLength(&numOptions);  for (PRUint32 i = 0; i < numOptions; i++) {    nsIDOMHTMLOptionElement* option = GetOption(*options, i);    if (option) {      //option->CompressContent();       nsAutoString text;      if (NS_CONTENT_ATTR_HAS_VALUE != option->GetText(text)) {        continue;      }      nsSize textSize;      // use the style for the select rather that the option, since widgets don't support it      nsFormControlFrame::GetTextSize(*aPresContext, this, text, textSize, aReflowState.rendContext);       if (textSize.width > maxWidth) {        maxWidth = textSize.width;      }      NS_RELEASE(option);    }  }  PRInt32 rowHeight = 0;  nsSize calcSize, charSize;  PRBool widthExplicit, heightExplicit;  nsInputDimensionSpec textSpec(nsnull, PR_FALSE, nsnull, nsnull,                                maxWidth, PR_TRUE, nsHTMLAtoms::size, 1);  // XXX fix CalculateSize to return PRUint32  PRUint32 numRows = (PRUint32)CalculateSize(aPresContext, this, styleSize, textSpec,                                              calcSize, widthExplicit, heightExplicit, rowHeight,                                             aReflowState.rendContext);  // here it is determined whether we are a combo box  PRInt32 sizeAttr;  GetSize(&sizeAttr);  PRBool multiple;  if (!GetMultiple(&multiple) &&       ((1 >= sizeAttr) || ((ATTR_NOTSET == sizeAttr) && (1 >= numRows)))) {    mIsComboBox = PR_TRUE;  }      float p2t = aPresContext->GetPixelsToTwips();  aDesiredLayoutSize.width = calcSize.width;  // account for vertical scrollbar, if present    if (!widthExplicit && ((numRows < numOptions) || mIsComboBox)) {    aDesiredLayoutSize.width += GetScrollbarWidth(p2t);  }  // XXX put this in widget library, combo boxes are fixed height (visible part)  aDesiredLayoutSize.height = (mIsComboBox)    ? rowHeight + (2 * GetVerticalInsidePadding(p2t, rowHeight))    : calcSize.height;   aDesiredLayoutSize.ascent = aDesiredLayoutSize.height;  aDesiredLayoutSize.descent = 0;  aDesiredWidgetSize.width  = aDesiredLayoutSize.width;  aDesiredWidgetSize.height = aDesiredLayoutSize.height;  if (mIsComboBox) {  // add in pull down size    PRInt32 extra = NSIntPixelsToTwips(10, p2t);    aDesiredWidgetSize.height += (rowHeight * (numOptions > 20 ? 20 : numOptions)) + extra;  }  // override the width and height for a combo box that has already got a widget  if (mWidget && mIsComboBox) {    nscoord ignore;    GetWidgetSize(*aPresContext, ignore, aDesiredLayoutSize.height);    aDesiredLayoutSize.ascent = aDesiredLayoutSize.height;  }  NS_RELEASE(options);}