for (int i = 0; i < numChildren; i++) { nsOption* option = (nsOption*) select->ChildAt(i); option->CompressContent(); nsString text; if (PR_FALSE == option->GetContent(text)) { continue;
for (int childX = 0; childX < numChildren; childX++) { nsIContent* child = select->ChildAt(childX); nsOption* option; nsresult result = child->QueryInterface(kOptionIID, (void**)&option); if (NS_OK == result) { option->CompressContent(); nsString text; if (PR_FALSE == option->GetContent(text)) { continue; } nsSize textSize;  nsInputFrame::GetTextSize(*aPresContext, this, text, textSize); if (textSize.width > maxWidth) { maxWidth = textSize.width; } NS_RELEASE(option);
nsSelectFrame::GetDesiredSize(nsIPresContext* aPresContext,                              const nsReflowState& aReflowState,                              nsReflowMetrics& aDesiredLayoutSize,                              nsSize& aDesiredWidgetSize){  nsSelect* select;  GetContent((nsIContent *&)select);  // get the css size   nsSize styleSize;  GetStyleSize(*aPresContext, aReflowState, styleSize);  // get the size of the longest child  PRInt32 maxWidth = 1;  PRInt32 numChildren = select->ChildCount();  for (int i = 0; i < numChildren; i++) {    nsOption* option = (nsOption*) select->ChildAt(i);  // YYY this had better be an option     option->CompressContent();    nsString text;    if (PR_FALSE == option->GetContent(text)) {      continue;    }    nsSize textSize;    // use the style for the select rather that the option, since widgets don't support it    nsInputFrame::GetTextSize(*aPresContext, this, text, textSize);     if (textSize.width > maxWidth) {      maxWidth = textSize.width;    }    NS_RELEASE(option);  // YYY remove this comment if ok  }  PRInt32 rowHeight = 0;  nsSize calcSize, charSize;  PRBool widthExplicit, heightExplicit;  nsInputDimensionSpec textSpec(nsnull, PR_FALSE, nsnull, nsnull,                                maxWidth, PR_TRUE, nsHTMLAtoms::size, 1);  PRInt32 numRows = CalculateSize(aPresContext, this, styleSize, textSpec,                                   calcSize, widthExplicit, heightExplicit, rowHeight);  // here it is determined whether we are a combo box  PRInt32 sizeAttr = select->GetSize();  if (!select->GetMultiple() && ((1 == sizeAttr) || ((ATTR_NOTSET == sizeAttr) && (1 >= numRows)))) {    select->mIsComboBox = PR_TRUE;  }  aDesiredLayoutSize.width = calcSize.width;  // account for vertical scrollbar, if present    if (!widthExplicit && ((numRows < select->ChildCount()) || select->mIsComboBox)) {    float p2t = aPresContext->GetPixelsToTwips();    aDesiredLayoutSize.width += GetScrollbarWidth(p2t);  }  // XXX put this in widget library, combo boxes are fixed height (visible part)  aDesiredLayoutSize.height = (select->mIsComboBox) ? 350 : calcSize.height;   aDesiredLayoutSize.ascent = aDesiredLayoutSize.height;  aDesiredLayoutSize.descent = 0;  aDesiredWidgetSize.width  = aDesiredLayoutSize.width;  aDesiredWidgetSize.height = aDesiredLayoutSize.height;  if (select->mIsComboBox) {  // add in pull down size    aDesiredWidgetSize.height += (rowHeight * numChildren) + 100;  }  NS_RELEASE(select);}