aPresContext->GetPixelsToTwips(&p2t);
p2t = aPresContext->PixelsToTwips();
CanvasFrame::Paint(nsIPresContext*      aPresContext,                   nsIRenderingContext& aRenderingContext,                   const nsRect&        aDirtyRect,                   nsFramePaintLayer    aWhichLayer,                   PRUint32             aFlags){  // We are wrapping the root frame of a document. We  // need to check the pres shell to find out if painting is locked  // down (because we're still in the early stages of document  // and frame construction.  If painting is locked down, then we  // do not paint our children.    PRBool paintingSuppressed = PR_FALSE;  aPresContext->PresShell()->IsPaintingSuppressed(&paintingSuppressed);  if (paintingSuppressed) {    if (NS_FRAME_PAINT_LAYER_BACKGROUND == aWhichLayer) {      PaintSelf(aPresContext, aRenderingContext, aDirtyRect);    }    return NS_OK;  }  nsresult rv = nsHTMLContainerFrame::Paint(aPresContext, aRenderingContext, aDirtyRect, aWhichLayer);  if (NS_FRAME_PAINT_LAYER_FOREGROUND == aWhichLayer) {#ifdef DEBUG_CANVAS_FOCUS    nsCOMPtr<nsIContent> focusContent;    nsCOMPtr<nsIEventStateManager> esm;    aPresContext->GetEventStateManager(getter_AddRefs(esm));    if (esm) {      esm->GetFocusedContent(getter_AddRefs(focusContent));    }    PRBool hasFocus = PR_FALSE;    nsCOMPtr<nsISupports> container;    aPresContext->GetContainer(getter_AddRefs(container));    nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(container));    if (docShell) {      docShell->GetHasFocus(&hasFocus);      printf("%p - CanvasFrame::Paint R:%d,%d,%d,%d  DR: %d,%d,%d,%d\n", this,               mRect.x, mRect.y, mRect.width, mRect.height,              aDirtyRect.x, aDirtyRect.y, aDirtyRect.width, aDirtyRect.height);    }    printf("%p - Focus: %s   c: %p  DoPaint:%s\n", docShell.get(), hasFocus?"Y":"N",            focusContent.get(), mDoPaintFocus?"Y":"N");#endif    if (mDoPaintFocus) {      nsRect focusRect = GetRect();      /////////////////////      // draw focus      // XXX This is only temporary      const nsStyleVisibility* vis = (const nsStyleVisibility*)mStyleContext->GetStyleData(eStyleStruct_Visibility);      // Only paint the focus if we're visible      if (vis->IsVisible()) {        nsCOMPtr<nsIEventStateManager> stateManager;        nsresult rv = aPresContext->GetEventStateManager(getter_AddRefs(stateManager));        if (NS_SUCCEEDED(rv)) {          nsIFrame * parentFrame = GetParent();          nsIView* parentView = parentFrame->GetView();          nsIScrollableView* scrollableView;          if (NS_SUCCEEDED(CallQueryInterface(parentView, &scrollableView))) {            nscoord width, height;            scrollableView->GetContainerSize(&width, &height);            const nsIView* clippedView;            scrollableView->GetClipView(&clippedView);            nsRect vcr = clippedView->GetBounds();            focusRect.width = vcr.width;            focusRect.height = vcr.height;            nscoord x,y;            scrollableView->GetScrollPosition(x, y);            focusRect.x += x;            focusRect.y += y;          }          nsStyleOutline outlineStyle(aPresContext);          outlineStyle.SetOutlineStyle(NS_STYLE_BORDER_STYLE_DOTTED);          outlineStyle.SetOutlineInvert();                    float p2t;          aPresContext->GetPixelsToTwips(&p2t);          // XXX the CSS border for links is specified as 2px, but it          // is only drawn as 1px.  Match this here.          nscoord onePixel = NSIntPixelsToTwips(1, p2t);          nsRect borderInside(focusRect.x + onePixel,                              focusRect.y + onePixel,                              focusRect.width - 2 * onePixel,                              focusRect.height - 2 * onePixel);          nsCSSRendering::DrawDashedSides(0, aRenderingContext,                                           focusRect, nsnull,                                          nsnull, &outlineStyle,                                          PR_TRUE, focusRect,                                          borderInside, 0,                                           nsnull);        }      }    }  }  return rv;}