*border, 0, 0);
*border, *padding, 0, 0);
HRuleFrame::Paint(nsIPresContext*      aPresContext,                  nsIRenderingContext& aRenderingContext,                  const nsRect&        aDirtyRect,                  nsFramePaintLayer    aWhichLayer,                  PRUint32             aFlags){  if (NS_FRAME_PAINT_LAYER_FOREGROUND != aWhichLayer) {    return NS_OK;  }  const nsStyleVisibility* vis =       (const nsStyleVisibility*)((nsIStyleContext*)mStyleContext)->GetStyleData(eStyleStruct_Visibility);  if (!vis->IsVisible()) {    return NS_OK;  }  nsIFrame *parent = nsnull;  //hack to get around lack of selection bit setting.  GetParent(&parent);//get the parent and check to see if its selected  PRBool isSelected = PR_FALSE;  if (parent)  {    nsCOMPtr<nsIContent> content;    parent->GetContent(getter_AddRefs(content));    nsFrameState  frameState;    if (content.get() == mContent)      parent->GetFrameState(&frameState);    else      GetFrameState(&frameState);    isSelected = (frameState & NS_FRAME_SELECTED_CONTENT) == NS_FRAME_SELECTED_CONTENT;  }  if (isSelected) //check the display flags to see if we draw this frame selected.  {    nsresult result;     nsCOMPtr<nsIPresShell> shell;    result = aPresContext->GetShell(getter_AddRefs(shell));    if (NS_FAILED(result))      return result;    PRInt16 displaySelection = nsISelectionDisplay::DISPLAY_ALL;    result = shell->GetSelectionFlags(&displaySelection);    if (NS_FAILED(result))      return result;    if (!(displaySelection & nsISelectionDisplay::DISPLAY_TEXT))      isSelected = PR_FALSE;  }  float p2t;  aPresContext->GetScaledPixelsToTwips(&p2t);  nscoord thickness = mThickness;  // Get style data  nscoord x0 = mBorderPadding.left;  nscoord y0 = mBorderPadding.top;  nscoord width = mRect.width -    (mBorderPadding.left + mBorderPadding.right);  nscoord height = mRect.height -    (mBorderPadding.top + mBorderPadding.bottom);  // Center hrule vertically within the available space  y0 += (height - thickness) / 2;  height = thickness;  // To shade or not to shade, that is the question. Begin by collecting the  // three decision criteria: rendering to the printer or the display, is the  // "Beveled Lines" checkbox set in the page setup dialog, and does the tag  // have the NOSHADE attribute set.  PRBool noShadeAttribute = GetNoShade();  // Now that we have the data to make the shading criteria, we next  // collect the decision criteria for rending in solid black:  // printing (which we already have) and the "Black Lines" setting in  // the page setup dialog  const nsStyleBackground* color;  // Draw a "shadowed" box around the rule area  nscolor selectionBGColor = 0;  if (isSelected)  {    nsILookAndFeel* look = nsnull;    if (NS_SUCCEEDED(aPresContext->GetLookAndFeel(&look)) && look) {      look->GetColor(nsILookAndFeel::eColor_TextSelectBackground, selectionBGColor);      NS_RELEASE(look);    }    aRenderingContext.SetColor (selectionBGColor);    aRenderingContext.FillRect(0,0,mRect.width,mRect.height);//(x0, y0, width, height);  }  if (!noShadeAttribute) {    nsRect rect(x0, y0, width, height);    const nsStyleBorder* border = (const nsStyleBorder*) mStyleContext->GetStyleData(eStyleStruct_Border);        nsCSSRendering::PaintBackground(aPresContext, aRenderingContext,                                    this,aDirtyRect, rect,                                    *border, 0, 0);    nsCSSRendering::PaintBorder(aPresContext, aRenderingContext,                                this,aDirtyRect, rect, *border,                                mStyleContext, 0);  } else {    nscolor colors[2];     // Get the background color that applies to this HR     color = nsCSSRendering::FindNonTransparentBackground(mStyleContext);     NS_Get3DColors(colors, color->mBackgroundColor);     // When a rule is not shaded, then we use a uniform color and    // draw half-circles on the end points.    aRenderingContext.SetColor (colors[0]);    nscoord diameter = height;    if ((diameter > width) || (diameter < NSIntPixelsToTwips(3, p2t))) {      // The half-circles on the ends of the rule aren't going to      // look right so don't bother drawing them.      aRenderingContext.FillRect(x0, y0, width, height);    } else {      aRenderingContext.FillArc(x0, y0, diameter, diameter, 90.0f, 270.0f);      aRenderingContext.FillArc(x0 + width - diameter, y0,                                diameter, diameter, 270.0f, 90.0f);      aRenderingContext.FillRect(x0 + diameter/2, y0,                                 width - diameter, height);     }  }  return NS_OK; }