if (setClipRect) { PRBool clipState; aRenderingContext.PopState(clipState); }
if (setClipRect) aRenderingContext.PopState();
PresShell::Paint(nsIView              *aView,                 nsIRenderingContext& aRenderingContext,                 const nsRect&        aDirtyRect){  nsIFrame* frame;  nsresult  rv = NS_OK;  if (mIsDestroying) {    NS_ASSERTION(PR_FALSE, "A paint message was dispatched to a destroyed PresShell");    return NS_OK;  }  NS_ASSERTION(!(nsnull == aView), "null view");  frame = NS_STATIC_CAST(nsIFrame*, aView->GetClientData());       if (nsnull != frame)  {    if (mCaret)      mCaret->EraseCaret();    // If the frame is absolutely positioned, then the 'clip' property    // applies    PRBool  setClipRect = SetClipRect(aRenderingContext, frame);    rv = frame->Paint(mPresContext, aRenderingContext, aDirtyRect,                      NS_FRAME_PAINT_LAYER_BACKGROUND);    rv = frame->Paint(mPresContext, aRenderingContext, aDirtyRect,                      NS_FRAME_PAINT_LAYER_FLOATS);    rv = frame->Paint(mPresContext, aRenderingContext, aDirtyRect,                      NS_FRAME_PAINT_LAYER_FOREGROUND);                          if (setClipRect) {      PRBool clipState;      aRenderingContext.PopState(clipState);    }#ifdef NS_DEBUG    // Draw a border around the frame    if (nsIFrameDebug::GetShowFrameBorders()) {      nsRect r = frame->GetRect();      aRenderingContext.SetColor(NS_RGB(0,0,255));      aRenderingContext.DrawRect(0, 0, r.width, r.height);    }    // Draw a border around the current event target    if ((nsIFrameDebug::GetShowEventTargetFrameBorder()) && (aView == mCurrentTargetView)) {      aRenderingContext.SetColor(NS_RGB(128,0,128));      aRenderingContext.DrawRect(mCurrentTargetRect.x, mCurrentTargetRect.y, mCurrentTargetRect.width, mCurrentTargetRect.height);    }#endif  }  return rv;}