} else if (selectedIndex == i) {
} else { PRBool selected = PR_FALSE; option->GetSelected(&selected);  if (selected) PaintOption(PR_TRUE, aPresContext, aRenderingContext, text, x, y, inside, textHeight); else
nsNativeSelectControlFrame::PaintSelectControl(nsIPresContext& aPresContext,                                         nsIRenderingContext& aRenderingContext,                                         const nsRect& aDirtyRect){  aRenderingContext.PushState();  /**   * Resolve style for a pseudo frame within the given aParentContent & aParentContext.   * The tag should be lowercase and inclue the colon.   * ie: NS_NewAtom(":first-line");   */  nsIAtom * sbAtom = NS_NewAtom(":scrollbar-look");  nsIStyleContext* scrollbarStyle;  aPresContext.ResolvePseudoStyleContextFor(mContent, sbAtom, mStyleContext,                                            PR_FALSE, &scrollbarStyle);  NS_RELEASE(sbAtom);  sbAtom = NS_NewAtom(":scrollbar-arrow-look");  nsIStyleContext* arrowStyle;  aPresContext.ResolvePseudoStyleContextFor(mContent, sbAtom, mStyleContext,                                            PR_FALSE, &arrowStyle);  NS_RELEASE(sbAtom);  nsIDOMHTMLCollection* options = GetOptions();  if (!options) {    return;  }  PRUint32 numOptions;  options->GetLength(&numOptions);  float scale;  nsIDeviceContext * context;  aRenderingContext.GetDeviceContext(context);  context->GetCanonicalPixelScale(scale);  const nsStyleSpacing* spacing =    (const nsStyleSpacing*)mStyleContext->GetStyleData(eStyleStruct_Spacing);  nsMargin border;  spacing->CalcBorderFor(this, border);  float p2t;  aPresContext.GetScaledPixelsToTwips(&p2t);  nscoord onePixel = NSIntPixelsToTwips(1, p2t);  nsRect outside(0, 0, mRect.width, mRect.height);  outside.Deflate(border);  outside.Deflate(onePixel, onePixel);  nsRect inside(outside);  aRenderingContext.SetColor(NS_RGB(0,0,0));  nsFont font(aPresContext.GetDefaultFixedFontDeprecated());   GetFont(&aPresContext, font);  aRenderingContext.SetFont(font);  //nscoord textWidth;  nscoord textHeight;  nsString text;  // Calculate the height of the text  nsIFontMetrics* metrics;  context->GetMetricsFor(font, metrics);  metrics->GetHeight(textHeight);  // Calculate the width of the scrollbar  PRInt32 scrollbarWidth;  if ((PRInt32)numOptions > mNumRows) {    float sbWidth;    float sbHeight;    context->GetCanonicalPixelScale(scale);    context->GetScrollBarDimensions(sbWidth, sbHeight);    scrollbarWidth = PRInt32(sbWidth * scale);  } else {    scrollbarWidth = 0;  }  // shrink the inside rect's width for the scrollbar  inside.width  -= scrollbarWidth;  PRBool clipEmpty;  aRenderingContext.PushState();  nsRect clipRect(inside);   clipRect.Inflate(onePixel, onePixel);  aRenderingContext.SetClipRect(clipRect, nsClipCombine_kReplace, clipEmpty);  nscoord x = inside.x + onePixel;  nscoord y;  if (mIsComboBox) {    y = ((inside.height  - textHeight) / 2)  + inside.y;  } else {    y = inside.y;  }    // Get Selected index out of Content model  PRInt32 selectedIndex = GetSelectedIndex();  PRBool multiple = PR_FALSE;  GetMultiple(&multiple);  nsIDOMNode* node;  nsIDOMHTMLOptionElement* option;  for (PRInt32 i = 0; i < (PRInt32)numOptions; i++) {    options->Item(i, &node);    if (node) {      nsresult result = node->QueryInterface(kIDOMHTMLOptionElementIID, (void**)&option);      if ((NS_OK == result) && option) {        // XXX need to compress whitespace        if (NS_CONTENT_ATTR_HAS_VALUE != option->GetText(text)) {            text = " ";        }        if (mIsComboBox) {            // Paint a non-selected option          if ((selectedIndex == -1) && (i == 0)) {            PaintOption(PR_FALSE, aPresContext, aRenderingContext, text, x, y, inside, textHeight);          }          else if (selectedIndex == i) {            PaintOption(PR_FALSE, aPresContext, aRenderingContext, text, x, y, inside, textHeight);          }          if ((-1 == selectedIndex && (0 == i)) || (selectedIndex == i)) {            i = numOptions;          }        } else {          // Its a list box          if (!multiple) {             // Single select list box            if (selectedIndex == i)              PaintOption(PR_TRUE, aPresContext, aRenderingContext, text, x, y, inside, textHeight);            else              PaintOption(PR_FALSE, aPresContext, aRenderingContext, text, x, y, inside, textHeight);          }          else {            PRBool selected = PR_FALSE;            option->GetSelected(&selected);             // Multi-selection list box            if (selected)               PaintOption(PR_TRUE, aPresContext, aRenderingContext, text, x, y, inside, textHeight);            else              PaintOption(PR_FALSE, aPresContext, aRenderingContext, text, x, y, inside, textHeight);          }               y += textHeight;          if (i == mNumRows-1) {            i = numOptions;          }           }      }               NS_RELEASE(option);    }    NS_RELEASE(node);  }   aRenderingContext.PopState(clipEmpty);  // Draw Scrollbars  if ((PRInt32)numOptions > mNumRows) {    //const nsStyleColor* myColor =    //  (const nsStyleColor*)mStyleContext->GetStyleData(eStyleStruct_Color);    if (mIsComboBox) {      // Get the Scrollbar's Arrow's Style structs      const nsStyleSpacing* arrowSpacing = (const nsStyleSpacing*)arrowStyle->GetStyleData(eStyleStruct_Spacing);//XXX      const nsStyleColor*   arrowColor   = (const nsStyleColor*)arrowStyle->GetStyleData(eStyleStruct_Color);      nsRect srect(mRect.width-scrollbarWidth-onePixel, onePixel, scrollbarWidth, mRect.height-(onePixel*2));      nsFormControlHelper::PaintArrow(nsFormControlHelper::eArrowDirection_Down, aRenderingContext,aPresContext,                       aDirtyRect, srect, onePixel, arrowStyle, *arrowSpacing, this, mRect);    } else {      nsRect srect(mRect.width-scrollbarWidth-onePixel, onePixel, scrollbarWidth, mRect.height-(onePixel*2));      nsFormControlHelper::PaintScrollbar(aRenderingContext,aPresContext, aDirtyRect, srect, PR_FALSE, onePixel,                                                                     scrollbarStyle, arrowStyle, this, mRect);       }  }  NS_RELEASE(context);  NS_RELEASE(options);  aRenderingContext.PopState(clipEmpty);  NS_RELEASE(scrollbarStyle);  NS_RELEASE(arrowStyle);}