Bug 651017, part 5: mechanical changes.
authorZack Weinberg <zackw@panix.com>
Sat, 16 Apr 2011 18:22:44 -0700
changeset 68310 3237cf9bc6f8e9573ca383e60fac07ad16fdba4c
parent 68309 3487552eaf91f81f15dfe5b8f787a1fea4730cb6
child 68311 2afcb1f14fad1acc2d90c3dd5d44c32bb8eea696
push idunknown
push userunknown
push dateunknown
bugs651017
milestone6.0a1
Bug 651017, part 5: mechanical changes.
accessible/src/base/nsTextAttrs.cpp
accessible/src/base/nsTextAttrs.h
content/base/public/nsIDocument.h
dom/base/nsScreen.cpp
dom/base/nsScreen.h
dom/ipc/TabChild.cpp
gfx/src/nsDeviceContext.cpp
gfx/src/nsDeviceContext.h
layout/base/nsCSSRendering.cpp
layout/base/nsDisplayList.h
layout/base/nsDocumentViewer.cpp
layout/base/nsLayoutUtils.cpp
layout/base/nsLayoutUtils.h
layout/base/nsPresContext.cpp
layout/base/nsPresContext.h
layout/base/nsPresShell.cpp
layout/forms/nsFormControlFrame.cpp
layout/generic/nsHTMLContainerFrame.h
layout/generic/nsObjectFrame.cpp
layout/generic/nsSimplePageSequence.cpp
layout/generic/nsSubDocumentFrame.cpp
layout/printing/nsPrintData.h
layout/printing/nsPrintEngine.cpp
layout/printing/nsPrintEngine.h
layout/style/nsMediaFeatures.cpp
layout/style/nsRuleNode.cpp
layout/svg/base/src/nsSVGGlyphFrame.h
layout/svg/base/src/nsSVGUtils.cpp
layout/xul/base/src/nsMenuPopupFrame.cpp
layout/xul/base/src/nsTextBoxFrame.cpp
layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp
view/public/nsIViewManager.h
view/src/nsView.cpp
view/src/nsViewManager.cpp
view/src/nsViewManager.h
widget/public/nsIWidget.h
widget/src/android/nsWindow.cpp
widget/src/android/nsWindow.h
widget/src/cocoa/nsChildView.h
widget/src/cocoa/nsChildView.mm
widget/src/cocoa/nsCocoaWindow.h
widget/src/cocoa/nsCocoaWindow.mm
widget/src/cocoa/nsNativeThemeCocoa.h
widget/src/cocoa/nsNativeThemeCocoa.mm
widget/src/gtk2/nsNativeThemeGTK.cpp
widget/src/gtk2/nsNativeThemeGTK.h
widget/src/gtk2/nsWindow.cpp
widget/src/gtk2/nsWindow.h
widget/src/os2/nsGfxDefs.h
widget/src/os2/nsWindow.cpp
widget/src/os2/nsWindow.h
widget/src/qt/nsNativeThemeQt.cpp
widget/src/qt/nsNativeThemeQt.h
widget/src/qt/nsWindow.cpp
widget/src/qt/nsWindow.h
widget/src/windows/nsNativeThemeWin.cpp
widget/src/windows/nsNativeThemeWin.h
widget/src/windows/nsWindow.cpp
widget/src/windows/nsWindow.h
widget/src/xpwidgets/PuppetWidget.cpp
widget/src/xpwidgets/PuppetWidget.h
widget/src/xpwidgets/nsBaseDragService.cpp
widget/src/xpwidgets/nsBaseWidget.cpp
widget/src/xpwidgets/nsBaseWidget.h
--- a/accessible/src/base/nsTextAttrs.cpp
+++ b/accessible/src/base/nsTextAttrs.cpp
@@ -461,17 +461,17 @@ nsFontSizeTextAttr::Format(const nscoord
   //
   // Note: according to IA2, "The conversion doesn't have to be exact.
   // The intent is to give the user a feel for the size of the text."
   // 
   // ATK does not specify a unit and will likely follow IA2 here.
   //
   // XXX todo: consider sharing this code with layout module? (bug 474621)
   float px =
-    NSAppUnitsToFloatPixels(aValue, nsIDeviceContext::AppUnitsPerCSSPixel());
+    NSAppUnitsToFloatPixels(aValue, nsDeviceContext::AppUnitsPerCSSPixel());
   // Each pt is 4/3 of a CSS pixel.
   int pts = NS_lround(px*3/4);
 
   nsAutoString value;
   value.AppendInt(pts);
   value.Append(NS_LITERAL_STRING("pt"));
   aFormattedValue = value;
 }
--- a/accessible/src/base/nsTextAttrs.h
+++ b/accessible/src/base/nsTextAttrs.h
@@ -332,17 +332,17 @@ private:
   /**
    * Return font size for the given frame.
    *
    * @param aFrame      [in] the given frame to query font-size
    * @return            font size
    */
    nscoord GetFontSize(nsIFrame *aFrame);
 
-  nsIDeviceContext *mDC;
+  nsDeviceContext *mDC;
 };
 
 
 /**
  * Class is used for the work with "font-weight" text attribute in
  * nsTextAttrsMgr class.
  */
 class nsFontWeightTextAttr : public nsTextAttr<PRInt32>
--- a/content/base/public/nsIDocument.h
+++ b/content/base/public/nsIDocument.h
@@ -74,17 +74,17 @@ class nsIPresShell;
 class nsIDocShell;
 class nsStyleSet;
 class nsIStyleSheet;
 class nsIStyleRule;
 class nsCSSStyleSheet;
 class nsIViewManager;
 class nsIDOMEvent;
 class nsIDOMEventTarget;
-class nsIDeviceContext;
+class nsDeviceContext;
 class nsIParser;
 class nsIDOMNode;
 class nsIDOMElement;
 class nsIDOMDocumentFragment;
 class nsILineBreaker;
 class nsIWordBreaker;
 class nsISelection;
 class nsIChannel;
--- a/dom/base/nsScreen.cpp
+++ b/dom/base/nsScreen.cpp
@@ -123,17 +123,17 @@ nsScreen::GetHeight(PRInt32* aHeight)
   *aHeight = rect.height;
 
   return rv;
 }
 
 NS_IMETHODIMP
 nsScreen::GetPixelDepth(PRInt32* aPixelDepth)
 {
-  nsIDeviceContext* context = GetDeviceContext();
+  nsDeviceContext* context = GetDeviceContext();
 
   if (!context) {
     *aPixelDepth = -1;
 
     return NS_ERROR_FAILURE;
   }
 
   PRUint32 depth;
@@ -189,26 +189,26 @@ nsScreen::GetAvailTop(PRInt32* aAvailTop
   nsRect rect;
   nsresult rv = GetAvailRect(rect);
 
   *aAvailTop = rect.y;
 
   return rv;
 }
 
-nsIDeviceContext*
+nsDeviceContext*
 nsScreen::GetDeviceContext()
 {
   return nsLayoutUtils::GetDeviceContextForScreenInfo(mDocShell);
 }
 
 nsresult
 nsScreen::GetRect(nsRect& aRect)
 {
-  nsIDeviceContext *context = GetDeviceContext();
+  nsDeviceContext *context = GetDeviceContext();
 
   if (!context) {
     return NS_ERROR_FAILURE;
   }
 
   context->GetRect(aRect);
 
   aRect.x = nsPresContext::AppUnitsToIntCSSPixels(aRect.x);
@@ -217,17 +217,17 @@ nsScreen::GetRect(nsRect& aRect)
   aRect.width = nsPresContext::AppUnitsToIntCSSPixels(aRect.width);
 
   return NS_OK;
 }
 
 nsresult
 nsScreen::GetAvailRect(nsRect& aRect)
 {
-  nsIDeviceContext *context = GetDeviceContext();
+  nsDeviceContext *context = GetDeviceContext();
 
   if (!context) {
     return NS_ERROR_FAILURE;
   }
 
   context->GetClientRect(aRect);
 
   aRect.x = nsPresContext::AppUnitsToIntCSSPixels(aRect.x);
--- a/dom/base/nsScreen.h
+++ b/dom/base/nsScreen.h
@@ -38,32 +38,32 @@
 #define nsScreen_h___
 
 #include "nsIDOMScreen.h"
 #include "nsISupports.h"
 #include "nsIScriptContext.h"
 #include "nsCOMPtr.h"
 
 class nsIDocShell;
-class nsIDeviceContext;
+class nsDeviceContext;
 struct nsRect;
 
 // Script "screen" object
 class nsScreen : public nsIDOMScreen
 {
 public:
   nsScreen(nsIDocShell* aDocShell);
   virtual ~nsScreen();
 
   NS_IMETHOD SetDocShell(nsIDocShell* aDocShell);
 
   NS_DECL_ISUPPORTS
   NS_DECL_NSIDOMSCREEN
 
 protected:
-  nsIDeviceContext* GetDeviceContext();
+  nsDeviceContext* GetDeviceContext();
   nsresult GetRect(nsRect& aRect);
   nsresult GetAvailRect(nsRect& aRect);
 
   nsIDocShell* mDocShell; // Weak Reference
 };
 
 #endif /* nsScreen_h___ */
--- a/dom/ipc/TabChild.cpp
+++ b/dom/ipc/TabChild.cpp
@@ -895,17 +895,17 @@ TabChild::InitWidget(const nsIntSize& si
     if (!mWidget) {
         NS_ERROR("couldn't create fake widget");
         return false;
     }
     mWidget->Create(
         nsnull, 0,              // no parents
         nsIntRect(nsIntPoint(0, 0), size),
         nsnull,                 // HandleWidgetEvent
-        nsnull                  // nsIDeviceContext
+        nsnull                  // nsDeviceContext
         );
 
     RenderFrameChild* remoteFrame =
         static_cast<RenderFrameChild*>(SendPRenderFrameConstructor());
     if (!remoteFrame) {
       NS_WARNING("failed to construct RenderFrame");
       return false;
     }
--- a/layout/base/nsCSSRendering.cpp
+++ b/layout/base/nsCSSRendering.cpp
@@ -1192,17 +1192,17 @@ nsCSSRendering::PaintBoxShadowOuter(nsPr
     // (renderContext == shadowContext) which is why we set up the color and clip
     // before doing this.
     if (nativeTheme) {
       // We don't clip the border-box from the shadow, nor any other box.
       // We assume that the native theme is going to paint over the shadow.
 
       // Draw the widget shape
       gfxContextMatrixAutoSaveRestore save(shadowContext);
-      nsIDeviceContext* devCtx = aPresContext->DeviceContext();
+      nsDeviceContext* devCtx = aPresContext->DeviceContext();
       nsRefPtr<nsRenderingContext> wrapperCtx;
       devCtx->CreateRenderingContextInstance(*getter_AddRefs(wrapperCtx));
       wrapperCtx->Init(devCtx, shadowContext);
       wrapperCtx->Translate(nsPoint(shadowItem->mXOffset, shadowItem->mYOffset));
 
       nsRect nativeRect;
       nativeRect.IntersectRect(frameRect, aDirtyRect);
 
--- a/layout/base/nsDisplayList.h
+++ b/layout/base/nsDisplayList.h
@@ -57,17 +57,17 @@
 #include "FrameLayerBuilder.h"
 #include "nsThemeConstants.h"
 
 #include <stdlib.h>
 
 class nsIPresShell;
 class nsIContent;
 class nsRenderingContext;
-class nsIDeviceContext;
+class nsDeviceContext;
 class nsDisplayTableItem;
 class nsDisplayItem;
 
 /*
  * An nsIFrame can have many different visual parts. For example an image frame
  * can have a background, border, and outline, the image itself, and a
  * translucent selection overlay. In general these parts can be drawn at
  * discontiguous z-levels; see CSS2.1 appendix E:
--- a/layout/base/nsDocumentViewer.cpp
+++ b/layout/base/nsDocumentViewer.cpp
@@ -433,17 +433,17 @@ protected:
   // IMPORTANT: The ownership implicit in the following member
   // variables has been explicitly checked and set using nsCOMPtr
   // for owning pointers and raw COM interface pointers for weak
   // (ie, non owning) references. If you add any members to this
   // class, please make the ownership explicit (pinkerton, scc).
 
   nsWeakPtr mContainer; // it owns me!
   nsWeakPtr mTopContainerWhilePrinting;
-  nsCOMPtr<nsIDeviceContext> mDeviceContext;  // We create and own this baby
+  nsRefPtr<nsDeviceContext> mDeviceContext;  // We create and own this baby
 
   // the following six items are explicitly in this order
   // so they will be destroyed in the reverse order (pinkerton, scc)
   nsCOMPtr<nsIDocument>    mDocument;
   nsCOMPtr<nsIWidget>      mWindow;      // may be null
   nsCOMPtr<nsIViewManager> mViewManager;
   nsRefPtr<nsPresContext>  mPresContext;
   nsCOMPtr<nsIPresShell>   mPresShell;
@@ -2272,17 +2272,17 @@ DocumentViewerImpl::MakeWindow(const nsS
     DetachFromTopLevelWidget();
   }
 
   nsresult rv;
   mViewManager = do_CreateInstance(kViewManagerCID, &rv);
   if (NS_FAILED(rv))
     return rv;
 
-  nsIDeviceContext *dx = mPresContext->DeviceContext();
+  nsDeviceContext *dx = mPresContext->DeviceContext();
 
   rv = mViewManager->Init(dx);
   if (NS_FAILED(rv))
     return rv;
 
   // The root view is always at 0,0.
   nsRect tbounds(nsPoint(0, 0), aSize);
   // Create a view
--- a/layout/base/nsLayoutUtils.cpp
+++ b/layout/base/nsLayoutUtils.cpp
@@ -3329,17 +3329,17 @@ nsLayoutUtils::DrawSingleUnscaledImage(n
                                        PRUint32             aImageFlags,
                                        const nsRect*        aSourceArea)
 {
   nsIntSize imageSize;
   aImage->GetWidth(&imageSize.width);
   aImage->GetHeight(&imageSize.height);
   NS_ENSURE_TRUE(imageSize.width > 0 && imageSize.height > 0, NS_ERROR_FAILURE);
 
-  nscoord appUnitsPerCSSPixel = nsIDeviceContext::AppUnitsPerCSSPixel();
+  nscoord appUnitsPerCSSPixel = nsDeviceContext::AppUnitsPerCSSPixel();
   nsSize size(imageSize.width*appUnitsPerCSSPixel,
               imageSize.height*appUnitsPerCSSPixel);
 
   nsRect source;
   if (aSourceArea) {
     source = *aSourceArea;
   } else {
     source.SizeTo(size);
@@ -3374,17 +3374,17 @@ nsLayoutUtils::DrawSingleImage(nsRenderi
     aImage->GetHeight(&imageSize.height);
   }
   NS_ENSURE_TRUE(imageSize.width > 0 && imageSize.height > 0, NS_ERROR_FAILURE);
 
   nsRect source;
   if (aSourceArea) {
     source = *aSourceArea;
   } else {
-    nscoord appUnitsPerCSSPixel = nsIDeviceContext::AppUnitsPerCSSPixel();
+    nscoord appUnitsPerCSSPixel = nsDeviceContext::AppUnitsPerCSSPixel();
     source.SizeTo(imageSize.width*appUnitsPerCSSPixel,
                   imageSize.height*appUnitsPerCSSPixel);
   }
 
   nsRect dest = nsLayoutUtils::GetWholeImageDestination(imageSize, source,
                                                         aDest);
   // Ensure that only a single image tile is drawn. If aSourceArea extends
   // outside the image bounds, we want to honor the aSourceArea-to-aDest
@@ -3469,17 +3469,17 @@ nsLayoutUtils::DrawImage(nsRenderingCont
 nsLayoutUtils::GetWholeImageDestination(const nsIntSize& aWholeImageSize,
                                         const nsRect& aImageSourceArea,
                                         const nsRect& aDestArea)
 {
   double scaleX = double(aDestArea.width)/aImageSourceArea.width;
   double scaleY = double(aDestArea.height)/aImageSourceArea.height;
   nscoord destOffsetX = NSToCoordRound(aImageSourceArea.x*scaleX);
   nscoord destOffsetY = NSToCoordRound(aImageSourceArea.y*scaleY);
-  nscoord appUnitsPerCSSPixel = nsIDeviceContext::AppUnitsPerCSSPixel();
+  nscoord appUnitsPerCSSPixel = nsDeviceContext::AppUnitsPerCSSPixel();
   nscoord wholeSizeX = NSToCoordRound(aWholeImageSize.width*appUnitsPerCSSPixel*scaleX);
   nscoord wholeSizeY = NSToCoordRound(aWholeImageSize.height*appUnitsPerCSSPixel*scaleY);
   return nsRect(aDestArea.TopLeft() - nsPoint(destOffsetX, destOffsetY),
                 nsSize(wholeSizeX, wholeSizeY));
 }
 
 void
 nsLayoutUtils::SetFontFromStyle(nsRenderingContext* aRC, nsStyleContext* aSC)
@@ -3671,17 +3671,17 @@ nsLayoutUtils::GetRectDifferenceStrips(c
   *aVStrip = unionRect;
   aVStrip->x += VStripStart;
   aVStrip->width -= VStripStart;
   *aHStrip = unionRect;
   aHStrip->y += HStripStart;
   aHStrip->height -= HStripStart;
 }
 
-nsIDeviceContext*
+nsDeviceContext*
 nsLayoutUtils::GetDeviceContextForScreenInfo(nsIDocShell* aDocShell)
 {
   nsCOMPtr<nsIDocShell> docShell = aDocShell;
   while (docShell) {
     // Now make sure our size is up to date.  That will mean that the device
     // context does the right thing on multi-monitor systems when we return it to
     // the caller.  It will also make sure that our prescontext has been created,
     // if we're supposed to have one.
@@ -3691,17 +3691,17 @@ nsLayoutUtils::GetDeviceContextForScreen
       return nsnull;
     }
 
     win->EnsureSizeUpToDate();
 
     nsRefPtr<nsPresContext> presContext;
     docShell->GetPresContext(getter_AddRefs(presContext));
     if (presContext) {
-      nsIDeviceContext* context = presContext->DeviceContext();
+      nsDeviceContext* context = presContext->DeviceContext();
       if (context) {
         return context;
       }
     }
 
     nsCOMPtr<nsIDocShellTreeItem> curItem = do_QueryInterface(docShell);
     nsCOMPtr<nsIDocShellTreeItem> parentItem;
     curItem->GetParent(getter_AddRefs(parentItem));
--- a/layout/base/nsLayoutUtils.h
+++ b/layout/base/nsLayoutUtils.h
@@ -1207,17 +1207,17 @@ public:
   static void GetRectDifferenceStrips(const nsRect& aR1, const nsRect& aR2,
                                       nsRect* aHStrip, nsRect* aVStrip);
 
   /**
    * Get a device context that can be used to get up-to-date device
    * dimensions for the given docshell.  For some reason, this is more
    * complicated than it ought to be in multi-monitor situations.
    */
-  static nsIDeviceContext*
+  static nsDeviceContext*
   GetDeviceContextForScreenInfo(nsIDocShell* aDocShell);
 
   /**
    * Some frames with 'position: fixed' (nsStylePosition::mDisplay ==
    * NS_STYLE_POSITION_FIXED) are not really fixed positioned, since
    * they're inside an element with -moz-transform.  This function says
    * whether such an element is a real fixed-pos element.
    */
--- a/layout/base/nsPresContext.cpp
+++ b/layout/base/nsPresContext.cpp
@@ -873,17 +873,17 @@ nsPresContext::UpdateAfterPreferencesCha
   if (mPrefChangePendingNeedsReflow) {
     NS_UpdateHint(hint, NS_STYLE_HINT_REFLOW);
   }
 
   RebuildAllStyleData(hint);
 }
 
 nsresult
-nsPresContext::Init(nsIDeviceContext* aDeviceContext)
+nsPresContext::Init(nsDeviceContext* aDeviceContext)
 {
   NS_ASSERTION(!mInitialized, "attempt to reinit pres context");
   NS_ENSURE_ARG(aDeviceContext);
 
   mDeviceContext = aDeviceContext;
   NS_ADDREF(mDeviceContext);
 
   if (mDeviceContext->SetPixelScale(mFullZoom))
--- a/layout/base/nsPresContext.h
+++ b/layout/base/nsPresContext.h
@@ -43,17 +43,17 @@
 
 #include "nsISupports.h"
 #include "nsColor.h"
 #include "nsCoord.h"
 #include "nsAString.h"
 #include "nsCOMPtr.h"
 #include "nsIPresShell.h"
 #include "nsRect.h"
-#include "nsIDeviceContext.h"
+#include "nsDeviceContext.h"
 #include "nsFont.h"
 #include "nsIWeakReference.h"
 #include "nsITheme.h"
 #include "nsILanguageAtomService.h"
 #include "nsIObserver.h"
 #include "nsITimer.h"
 #include "nsCRT.h"
 #include "nsIPrintSettings.h"
@@ -191,17 +191,17 @@ public:
     eContext_PageLayout    // paginated & editable.
   };
 
   nsPresContext(nsIDocument* aDocument, nsPresContextType aType) NS_HIDDEN;
 
   /**
    * Initialize the presentation context from a particular device.
    */
-  NS_HIDDEN_(nsresult) Init(nsIDeviceContext* aDeviceContext);
+  NS_HIDDEN_(nsresult) Init(nsDeviceContext* aDeviceContext);
 
   /**
    * Set the presentation shell that this context is bound to.
    * A presentation context may only be bound to a single shell.
    */
   NS_HIDDEN_(void) SetShell(nsIPresShell* aShell);
 
 
@@ -539,17 +539,17 @@ public:
   * This is a scaling factor for the display of the print preview.  It
   * does not affect layout.  It only affects the size of the onscreen pages
   * in print preview.
   * XXX Temporary: see http://wiki.mozilla.org/Gecko:PrintPreview
   */
   float GetPrintPreviewScale() { return mPPScale; }
   void SetPrintPreviewScale(float aScale) { mPPScale = aScale; }
 
-  nsIDeviceContext* DeviceContext() { return mDeviceContext; }
+  nsDeviceContext* DeviceContext() { return mDeviceContext; }
   nsIEventStateManager* EventStateManager() { return mEventManager; }
   nsIAtom* GetLanguageFromCharset() { return mLanguage; }
 
   float TextZoom() { return mTextZoom; }
   void SetTextZoom(float aZoom) {
     if (aZoom == mTextZoom)
       return;
 
@@ -581,35 +581,35 @@ public:
 
   float GetFullZoom() { return mFullZoom; }
   void SetFullZoom(float aZoom);
 
   nscoord GetAutoQualityMinFontSize() {
     return DevPixelsToAppUnits(mAutoQualityMinFontSizePixelsPref);
   }
   
-  static PRInt32 AppUnitsPerCSSPixel() { return nsIDeviceContext::AppUnitsPerCSSPixel(); }
+  static PRInt32 AppUnitsPerCSSPixel() { return nsDeviceContext::AppUnitsPerCSSPixel(); }
   PRInt32 AppUnitsPerDevPixel() const  { return mDeviceContext->AppUnitsPerDevPixel(); }
-  static PRInt32 AppUnitsPerCSSInch() { return nsIDeviceContext::AppUnitsPerCSSInch(); }
+  static PRInt32 AppUnitsPerCSSInch() { return nsDeviceContext::AppUnitsPerCSSInch(); }
 
   static nscoord CSSPixelsToAppUnits(PRInt32 aPixels)
   { return NSIntPixelsToAppUnits(aPixels,
-                                 nsIDeviceContext::AppUnitsPerCSSPixel()); }
+                                 nsDeviceContext::AppUnitsPerCSSPixel()); }
 
   static nscoord CSSPixelsToAppUnits(float aPixels)
   { return NSFloatPixelsToAppUnits(aPixels,
-             float(nsIDeviceContext::AppUnitsPerCSSPixel())); }
+             float(nsDeviceContext::AppUnitsPerCSSPixel())); }
 
   static PRInt32 AppUnitsToIntCSSPixels(nscoord aAppUnits)
   { return NSAppUnitsToIntPixels(aAppUnits,
-             float(nsIDeviceContext::AppUnitsPerCSSPixel())); }
+             float(nsDeviceContext::AppUnitsPerCSSPixel())); }
 
   static float AppUnitsToFloatCSSPixels(nscoord aAppUnits)
   { return NSAppUnitsToFloatPixels(aAppUnits,
-             float(nsIDeviceContext::AppUnitsPerCSSPixel())); }
+             float(nsDeviceContext::AppUnitsPerCSSPixel())); }
 
   nscoord DevPixelsToAppUnits(PRInt32 aPixels) const
   { return NSIntPixelsToAppUnits(aPixels,
                                  mDeviceContext->AppUnitsPerDevPixel()); }
 
   PRInt32 AppUnitsToDevPixels(nscoord aAppUnits) const
   { return NSAppUnitsToIntPixels(aAppUnits,
              float(mDeviceContext->AppUnitsPerDevPixel())); }
@@ -639,27 +639,27 @@ public:
   gfxRect AppUnitsToGfxUnits(const nsRect& aAppRect) const
   { return gfxRect(AppUnitsToGfxUnits(aAppRect.x),
                    AppUnitsToGfxUnits(aAppRect.y),
                    AppUnitsToGfxUnits(aAppRect.width),
                    AppUnitsToGfxUnits(aAppRect.height)); }
 
   static nscoord CSSTwipsToAppUnits(float aTwips)
   { return NSToCoordRoundWithClamp(
-      nsIDeviceContext::AppUnitsPerCSSInch() * NS_TWIPS_TO_INCHES(aTwips)); }
+      nsDeviceContext::AppUnitsPerCSSInch() * NS_TWIPS_TO_INCHES(aTwips)); }
 
   // Margin-specific version, since they often need TwipsToAppUnits
   static nsMargin CSSTwipsToAppUnits(const nsIntMargin &marginInTwips)
   { return nsMargin(CSSTwipsToAppUnits(float(marginInTwips.left)), 
                     CSSTwipsToAppUnits(float(marginInTwips.top)),
                     CSSTwipsToAppUnits(float(marginInTwips.right)),
                     CSSTwipsToAppUnits(float(marginInTwips.bottom))); }
 
   static nscoord CSSPointsToAppUnits(float aPoints)
-  { return NSToCoordRound(aPoints * nsIDeviceContext::AppUnitsPerCSSInch() /
+  { return NSToCoordRound(aPoints * nsDeviceContext::AppUnitsPerCSSInch() /
                           POINTS_PER_INCH_FLOAT); }
 
   nscoord RoundAppUnitsToNearestDevPixels(nscoord aAppUnits) const
   { return DevPixelsToAppUnits(AppUnitsToDevPixels(aAppUnits)); }
 
   struct ScrollbarStyles {
     // Always one of NS_STYLE_OVERFLOW_SCROLL, NS_STYLE_OVERFLOW_HIDDEN,
     // or NS_STYLE_OVERFLOW_AUTO.
@@ -1043,17 +1043,17 @@ protected:
 
   // IMPORTANT: The ownership implicit in the following member variables
   // has been explicitly checked.  If you add any members to this class,
   // please make the ownership explicit (pinkerton, scc).
   
   nsPresContextType     mType;
   nsIPresShell*         mShell;         // [WEAK]
   nsCOMPtr<nsIDocument> mDocument;
-  nsIDeviceContext*     mDeviceContext; // [STRONG] could be weak, but
+  nsDeviceContext*     mDeviceContext; // [STRONG] could be weak, but
                                         // better safe than sorry.
                                         // Cannot reintroduce cycles
                                         // since there is no dependency
                                         // from gfx back to layout.
   nsIEventStateManager* mEventManager;  // [STRONG]
   nsILookAndFeel*       mLookAndFeel;   // [STRONG]
   nsRefPtr<nsRefreshDriver> mRefreshDriver;
   nsRefPtr<nsTransitionManager> mTransitionManager;
--- a/layout/base/nsPresShell.cpp
+++ b/layout/base/nsPresShell.cpp
@@ -3753,17 +3753,17 @@ PresShell::ClearFrameRefs(nsIFrame* aFra
   }
 }
 
 already_AddRefed<nsRenderingContext>
 PresShell::GetReferenceRenderingContext()
 {
   NS_TIME_FUNCTION_MIN(1.0);
 
-  nsIDeviceContext* devCtx = mPresContext->DeviceContext();
+  nsDeviceContext* devCtx = mPresContext->DeviceContext();
   nsRefPtr<nsRenderingContext> rc;
   if (mPresContext->IsScreen()) {
     devCtx->CreateRenderingContextInstance(*getter_AddRefs(rc));
     if (rc) {
       rc->Init(devCtx, gfxPlatform::GetPlatform()->ScreenReferenceSurface());
     }
   } else {
     devCtx->CreateRenderingContext(*getter_AddRefs(rc));
@@ -5267,17 +5267,17 @@ PresShell::RenderDocument(const nsRect& 
       aThebesContext->Clip();
       aThebesContext->SetOperator(gfxContext::OPERATOR_OVER);
     }
   }
 
   aThebesContext->Translate(gfxPoint(-nsPresContext::AppUnitsToFloatCSSPixels(aRect.x),
                                      -nsPresContext::AppUnitsToFloatCSSPixels(aRect.y)));
 
-  nsIDeviceContext* devCtx = mPresContext->DeviceContext();
+  nsDeviceContext* devCtx = mPresContext->DeviceContext();
   gfxFloat scale = gfxFloat(devCtx->AppUnitsPerDevPixel())/nsPresContext::AppUnitsPerCSSPixel();
   aThebesContext->Scale(scale, scale);
 
   // Since canvas APIs use floats to set up their matrices, we may have
   // some slight inaccuracy here. Adjust matrix components that are
   // integers up to the accuracy of floats to be those integers.
   aThebesContext->NudgeCurrentMatrixToIntegers();
 
@@ -5545,17 +5545,17 @@ PresShell::PaintRangePaintInfo(nsTArray<
                                nsIntRect* aScreenRect)
 {
   NS_TIME_FUNCTION_WITH_DOCURL;
 
   nsPresContext* pc = GetPresContext();
   if (!pc || aArea.width == 0 || aArea.height == 0)
     return nsnull;
 
-  nsIDeviceContext* deviceContext = pc->DeviceContext();
+  nsDeviceContext* deviceContext = pc->DeviceContext();
 
   // use the rectangle to create the surface
   nsIntRect pixelArea = aArea.ToOutsidePixels(pc->AppUnitsPerDevPixel());
 
   // if the area of the image is larger than the maximum area, scale it down
   float scale = 0.0;
   nsIntRect rootScreenRect =
     GetRootFrame()->GetScreenRectInAppUnits().ToNearestPixels(
@@ -8425,17 +8425,17 @@ PresShell::VerifyIncrementalReflow()
 
   // Create a presentation context to view the new frame tree
   nsRefPtr<nsPresContext> cx =
        new nsRootPresContext(mDocument, mPresContext->IsPaginated() ?
                                         nsPresContext::eContext_PrintPreview :
                                         nsPresContext::eContext_Galley);
   NS_ENSURE_TRUE(cx, PR_FALSE);
 
-  nsIDeviceContext *dc = mPresContext->DeviceContext();
+  nsDeviceContext *dc = mPresContext->DeviceContext();
   nsresult rv = cx->Init(dc);
   NS_ENSURE_SUCCESS(rv, PR_FALSE);
 
   // Get our scrolling preference
   nsIView* rootView = mViewManager->GetRootView();
   NS_ENSURE_TRUE(rootView->HasWidget(), PR_FALSE);
   nsIWidget* parentWidget = rootView->GetWidget();
 
--- a/layout/forms/nsFormControlFrame.cpp
+++ b/layout/forms/nsFormControlFrame.cpp
@@ -180,17 +180,17 @@ nsFormControlFrame::GetFormProperty(nsIA
 }
 
 // static
 nsRect
 nsFormControlFrame::GetUsableScreenRect(nsPresContext* aPresContext)
 {
   nsRect screen;
 
-  nsIDeviceContext *context = aPresContext->DeviceContext();
+  nsDeviceContext *context = aPresContext->DeviceContext();
   PRBool dropdownCanOverlapOSBar = PR_FALSE;
   nsILookAndFeel *lookAndFeel = aPresContext->LookAndFeel();
   lookAndFeel->GetMetric(nsILookAndFeel::eMetric_MenusCanOverlapOSBar,
                          dropdownCanOverlapOSBar);
   if ( dropdownCanOverlapOSBar )
     context->GetRect(screen);
   else
     context->GetClientRect(screen);
--- a/layout/generic/nsHTMLContainerFrame.h
+++ b/layout/generic/nsHTMLContainerFrame.h
@@ -50,17 +50,17 @@ struct nsStyleDisplay;
 struct nsStylePosition;
 struct nsHTMLReflowMetrics;
 struct nsHTMLReflowState;
 class nsLineBox;
 
 // Some macros for container classes to do sanity checking on
 // width/height/x/y values computed during reflow.
 // NOTE: AppUnitsPerCSSPixel value hardwired here to remove the
-// dependency on nsIDeviceContext.h.  It doesn't matter if it's a
+// dependency on nsDeviceContext.h.  It doesn't matter if it's a
 // little off.
 #ifdef DEBUG
 #define CRAZY_W (1000000*60)
 #define CRAZY_H CRAZY_W
 
 #define CRAZY_WIDTH(_x) (((_x) < -CRAZY_W) || ((_x) > CRAZY_W))
 #define CRAZY_HEIGHT(_y) (((_y) < -CRAZY_H) || ((_y) > CRAZY_H))
 #endif
--- a/layout/generic/nsObjectFrame.cpp
+++ b/layout/generic/nsObjectFrame.cpp
@@ -808,17 +808,17 @@ nsObjectFrame::CreateWidget(nscoord aWid
     NS_WARNING("Can't use native widgets, and can't hand a plugins a PuppetWidget");
   }
 
   nsIViewManager* viewMan = view->GetViewManager();
   // mark the view as hidden since we don't know the (x,y) until Paint
   // XXX is the above comment correct?
   viewMan->SetViewVisibility(view, nsViewVisibility_kHide);
 
-  nsCOMPtr<nsIDeviceContext> dx;
+  nsRefPtr<nsDeviceContext> dx;
   viewMan->GetDeviceContext(*getter_AddRefs(dx));
 
   //this is ugly. it was ripped off from didreflow(). MMP
   // Position and size view relative to its parent, not relative to our
   // parent frame (our parent frame may not have a view).
   
   nsIView* parentWithView;
   nsPoint origin;
--- a/layout/generic/nsSimplePageSequence.cpp
+++ b/layout/generic/nsSimplePageSequence.cpp
@@ -527,17 +527,17 @@ nsSimplePageSequenceFrame::PrintNextPage
     return NS_ERROR_FAILURE;
   }
 
   PRBool printEvenPages, printOddPages;
   mPageData->mPrintSettings->GetPrintOptions(nsIPrintSettings::kPrintEvenPages, &printEvenPages);
   mPageData->mPrintSettings->GetPrintOptions(nsIPrintSettings::kPrintOddPages, &printOddPages);
 
   // Begin printing of the document
-  nsIDeviceContext *dc = PresContext()->DeviceContext();
+  nsDeviceContext *dc = PresContext()->DeviceContext();
 
   nsresult rv = NS_OK;
 
   // See whether we should print this page
   mPrintThisPage = PR_TRUE;
 
   // If printing a range of pages check whether the page number is in the
   // range of pages to print
--- a/layout/generic/nsSubDocumentFrame.cpp
+++ b/layout/generic/nsSubDocumentFrame.cpp
@@ -934,29 +934,29 @@ nsSubDocumentFrame::BeginSwapDocShells(n
 }
 
 static PRBool
 EndSwapDocShellsForDocument(nsIDocument* aDocument, void*)
 {
   NS_PRECONDITION(aDocument, "");
 
   // Our docshell and view trees have been updated for the new hierarchy.
-  // Now also update all nsThebesDeviceContext::mWidget to that of the
+  // Now also update all nsDeviceContext::mWidget to that of the
   // container view in the new hierarchy.
   nsCOMPtr<nsISupports> container = aDocument->GetContainer();
   nsCOMPtr<nsIDocShell> ds = do_QueryInterface(container);
   if (ds) {
     nsCOMPtr<nsIContentViewer> cv;
     ds->GetContentViewer(getter_AddRefs(cv));
     while (cv) {
       nsCOMPtr<nsIDocumentViewer> dv = do_QueryInterface(cv);
       if (dv) {
         nsCOMPtr<nsPresContext> pc;
         dv->GetPresContext(getter_AddRefs(pc));
-        nsIDeviceContext* dc = pc ? pc->DeviceContext() : nsnull;
+        nsDeviceContext* dc = pc ? pc->DeviceContext() : nsnull;
         if (dc) {
           nsIView* v = dv->FindContainerView();
           dc->Init(v ? v->GetNearestWidget(nsnull) : nsnull);
         }
       }
       nsCOMPtr<nsIContentViewer> prev;
       cv->GetPreviousViewer(getter_AddRefs(prev));
       cv = prev;
--- a/layout/printing/nsPrintData.h
+++ b/layout/printing/nsPrintData.h
@@ -34,17 +34,17 @@
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 #ifndef nsPrintData_h___
 #define nsPrintData_h___
 
 // Interfaces
 #include "nsIDOMWindow.h"
-#include "nsIDeviceContext.h"
+#include "nsDeviceContext.h"
 #include "nsIPrintProgressParams.h"
 #include "nsIPrintOptions.h"
 #include "nsTArray.h"
 #include "nsCOMArray.h"
 #include "nsAutoPtr.h"
 
 // Classes
 class nsPrintObject;
@@ -87,17 +87,17 @@ public:
   void OnStartPrinting();
   void DoOnProgressChange(PRInt32      aProgess,
                           PRInt32      aMaxProgress,
                           PRBool       aDoStartStop,
                           PRInt32      aFlag);
 
 
   ePrintDataType               mType;            // the type of data this is (Printing or Print Preview)
-  nsCOMPtr<nsIDeviceContext>   mPrintDC;
+  nsRefPtr<nsDeviceContext>   mPrintDC;
   FILE                        *mDebugFilePtr;    // a file where information can go to when printing
 
   nsPrintObject *                mPrintObject;
   nsPrintObject *                mSelectedPO;
 
   nsCOMArray<nsIWebProgressListener> mPrintProgressListeners;
   nsCOMPtr<nsIPrintProgressParams> mPrintProgressParams;
 
--- a/layout/printing/nsPrintEngine.cpp
+++ b/layout/printing/nsPrintEngine.cpp
@@ -202,17 +202,17 @@ static const char * gPrintRangeStr[]    
 #define PRT_YESNO(_p)
 #define PR_PL(_p1)
 #endif
 
 #ifdef EXTENDED_DEBUG_PRINTING
 // Forward Declarations
 static void DumpPrintObjectsListStart(const char * aStr, nsTArray<nsPrintObject*> * aDocList);
 static void DumpPrintObjectsTree(nsPrintObject * aPO, int aLevel= 0, FILE* aFD = nsnull);
-static void DumpPrintObjectsTreeLayout(nsPrintObject * aPO,nsIDeviceContext * aDC, int aLevel= 0, FILE * aFD = nsnull);
+static void DumpPrintObjectsTreeLayout(nsPrintObject * aPO,nsDeviceContext * aDC, int aLevel= 0, FILE * aFD = nsnull);
 
 #define DUMP_DOC_LIST(_title) DumpPrintObjectsListStart((_title), mPrt->mPrintDocList);
 #define DUMP_DOC_TREE DumpPrintObjectsTree(mPrt->mPrintObject);
 #define DUMP_DOC_TREELAYOUT DumpPrintObjectsTreeLayout(mPrt->mPrintObject, mPrt->mPrintDC);
 #else
 #define DUMP_DOC_LIST(_title)
 #define DUMP_DOC_TREE
 #define DUMP_DOC_TREELAYOUT
@@ -425,17 +425,17 @@ nsresult nsPrintEngine::GetSeqFrameAndCo
 static int RemoveFilesInDir(const char * aDir);
 static void GetDocTitleAndURL(nsPrintObject* aPO, char *& aDocStr, char *& aURLStr);
 static void DumpPrintObjectsTree(nsPrintObject * aPO, int aLevel, FILE* aFD);
 static void DumpPrintObjectsList(nsTArray<nsPrintObject*> * aDocList);
 static void RootFrameList(nsPresContext* aPresContext, FILE* out, PRInt32 aIndent);
 static void DumpViews(nsIDocShell* aDocShell, FILE* out);
 static void DumpLayoutData(char* aTitleStr, char* aURLStr,
                            nsPresContext* aPresContext,
-                           nsIDeviceContext * aDC, nsIFrame * aRootFrame,
+                           nsDeviceContext * aDC, nsIFrame * aRootFrame,
                            nsIDocShell * aDocShell, FILE* aFD);
 #endif
 
 //--------------------------------------------------------------------------------
 
 nsresult
 nsPrintEngine::CommonPrint(PRBool                  aIsPrintPreview,
                            nsIPrintSettings*       aPrintSettings,
@@ -3562,17 +3562,17 @@ DumpViews(nsIDocShell* aDocShell, FILE* 
 }
 
 /** ---------------------------------------------------
  *  Dumps the Views and Frames
  */
 void DumpLayoutData(char*              aTitleStr,
                     char*              aURLStr,
                     nsPresContext*    aPresContext,
-                    nsIDeviceContext * aDC,
+                    nsDeviceContext * aDC,
                     nsIFrame *         aRootFrame,
                     nsIDocShekk *      aDocShell,
                     FILE*              aFD = nsnull)
 {
   if (!kPrintingLogMod || kPrintingLogMod->level != DUMP_LAYOUT_LEVEL) return;
 
   if (aPresContext == nsnull || aDC == nsnull) {
     return;
@@ -3696,17 +3696,17 @@ static void GetDocTitleAndURL(nsPrintObj
     nsAutoString strURL(docURLStr);
     aURLStr = ToNewCString(strURL);
     nsMemory::Free(docURLStr);
   }
 }
 
 //-------------------------------------------------------------
 static void DumpPrintObjectsTreeLayout(nsPrintObject * aPO,
-                                       nsIDeviceContext * aDC,
+                                       nsDeviceContext * aDC,
                                        int aLevel, FILE * aFD)
 {
   if (!kPrintingLogMod || kPrintingLogMod->level != DUMP_LAYOUT_LEVEL) return;
 
   NS_ASSERTION(aPO, "Pointer is null!");
   NS_ASSERTION(aDC, "Pointer is null!");
 
   const char types[][3] = {"DC", "FR", "IF", "FS"};
--- a/layout/printing/nsPrintEngine.h
+++ b/layout/printing/nsPrintEngine.h
@@ -45,17 +45,17 @@
 // Interfaces
 #include "nsIDocument.h"
 #include "nsIDOMWindow.h"
 #include "nsIObserver.h"
 
 // Classes
 class nsPagePrintTimer;
 class nsIDocShellTreeNode;
-class nsIDeviceContext;
+class nsDeviceContext;
 class nsIDocumentViewerPrint;
 class nsPrintObject;
 class nsIDocShell;
 class nsIPageSequenceFrame;
 
 //------------------------------------------------------------------------
 // nsPrintEngine Class
 //
--- a/layout/style/nsMediaFeatures.cpp
+++ b/layout/style/nsMediaFeatures.cpp
@@ -106,17 +106,17 @@ GetHeight(nsPresContext* aPresContext, c
           nsCSSValue& aResult)
 {
     nsSize size = GetSize(aPresContext);
     float pixelHeight = aPresContext->AppUnitsToFloatCSSPixels(size.height);
     aResult.SetFloatValue(pixelHeight, eCSSUnit_Pixel);
     return NS_OK;
 }
 
-inline static nsIDeviceContext*
+inline static nsDeviceContext*
 GetDeviceContextFor(nsPresContext* aPresContext)
 {
   // It would be nice to call
   // nsLayoutUtils::GetDeviceContextForScreenInfo here, except for two
   // things:  (1) it can flush, and flushing is bad here, and (2) it
   // doesn't really get us consistency in multi-monitor situations
   // *anyway*.
   return aPresContext->DeviceContext();
@@ -218,21 +218,21 @@ GetDeviceAspectRatio(nsPresContext* aPre
 {
     return MakeArray(GetDeviceSize(aPresContext), aResult);
 }
 
 static nsresult
 GetColor(nsPresContext* aPresContext, const nsMediaFeature*,
          nsCSSValue& aResult)
 {
-    // FIXME:  This implementation is bogus.  nsThebesDeviceContext
+    // FIXME:  This implementation is bogus.  nsDeviceContext
     // doesn't provide reliable information (should be fixed in bug
     // 424386).
     // FIXME: On a monochrome device, return 0!
-    nsIDeviceContext *dx = GetDeviceContextFor(aPresContext);
+    nsDeviceContext *dx = GetDeviceContextFor(aPresContext);
     PRUint32 depth;
     dx->GetDepth(depth);
     // The spec says to use bits *per color component*, so divide by 3,
     // and round down, since the spec says to use the smallest when the
     // color components differ.
     depth /= 3;
     aResult.SetIntValue(PRInt32(depth), eCSSUnit_Integer);
     return NS_OK;
@@ -263,17 +263,17 @@ GetMonochrome(nsPresContext* aPresContex
     return NS_OK;
 }
 
 static nsresult
 GetResolution(nsPresContext* aPresContext, const nsMediaFeature*,
               nsCSSValue& aResult)
 {
     // Resolution values are in device pixels, not CSS pixels.
-    nsIDeviceContext *dx = GetDeviceContextFor(aPresContext);
+    nsDeviceContext *dx = GetDeviceContextFor(aPresContext);
     float dpi = float(dx->AppUnitsPerPhysicalInch()) / float(dx->AppUnitsPerDevPixel());
     aResult.SetFloatValue(dpi, eCSSUnit_Inch);
     return NS_OK;
 }
 
 static nsresult
 GetScan(nsPresContext* aPresContext, const nsMediaFeature*,
         nsCSSValue& aResult)
--- a/layout/style/nsRuleNode.cpp
+++ b/layout/style/nsRuleNode.cpp
@@ -2649,17 +2649,17 @@ nsRuleNode::SetFont(nsPresContext* aPres
     systemFont.size = defaultVariableFont->size;
 
     if (NS_FAILED(aPresContext->DeviceContext()->GetSystemFont(sysID,
                                                                &systemFont))) {
         systemFont.name = defaultVariableFont->name;
     }
 
     // XXXldb All of this platform-specific stuff should be in the
-    // nsIDeviceContext implementations, not here.
+    // nsDeviceContext implementations, not here.
 
 #ifdef XP_WIN
     //
     // As far as I can tell the system default fonts and sizes for
     // on MS-Windows for Buttons, Listboxes/Comboxes and Text Fields are
     // all pre-determined and cannot be changed by either the control panel
     // or programmtically.
     //
--- a/layout/svg/base/src/nsSVGGlyphFrame.h
+++ b/layout/svg/base/src/nsSVGGlyphFrame.h
@@ -172,17 +172,17 @@ public:
   NS_IMETHOD_(nsISVGGlyphFragmentLeaf *) GetNextGlyphFragment();
   NS_IMETHOD_(void) SetWhitespaceHandling(PRUint8 aWhitespaceHandling);
   NS_IMETHOD_(PRBool) IsAllWhitespace();
 
 protected:
   friend class CharacterIterator;
 
   // Use a power of 2 here. It's not so important to match
-  // nsIDeviceContext::AppUnitsPerDevPixel, but since we do a lot of
+  // nsDeviceContext::AppUnitsPerDevPixel, but since we do a lot of
   // multiplying by 1/GetTextRunUnitsFactor, it's good for it to be a
   // power of 2 to avoid accuracy loss.
   static PRUint32 GetTextRunUnitsFactor() { return 64; }
   
   /**
    * @aParam aDrawScale font drawing must be scaled into user units
    * by this factor
    * @param aMetricsScale font metrics must be scaled into user units
--- a/layout/svg/base/src/nsSVGUtils.cpp
+++ b/layout/svg/base/src/nsSVGUtils.cpp
@@ -1460,17 +1460,17 @@ nsSVGRenderState::nsSVGRenderState(gfxAS
 {
   mGfxContext = new gfxContext(aSurface);
 }
 
 nsRenderingContext*
 nsSVGRenderState::GetRenderingContext(nsIFrame *aFrame)
 {
   if (!mRenderingContext) {
-    nsIDeviceContext* devCtx = aFrame->PresContext()->DeviceContext();
+    nsDeviceContext* devCtx = aFrame->PresContext()->DeviceContext();
     devCtx->CreateRenderingContextInstance(*getter_AddRefs(mRenderingContext));
     if (!mRenderingContext)
       return nsnull;
     mRenderingContext->Init(devCtx, mGfxContext);
   }
   return mRenderingContext;
 }
 
--- a/layout/xul/base/src/nsMenuPopupFrame.cpp
+++ b/layout/xul/base/src/nsMenuPopupFrame.cpp
@@ -1153,17 +1153,17 @@ nsMenuPopupFrame::SetPopupPosition(nsIFr
   FlipStyle hFlip = FlipStyle_None, vFlip = FlipStyle_None;
 
   nsMargin margin(0, 0, 0, 0);
   GetStyleMargin()->GetMargin(margin);
 
   // the screen rectangle of the root frame, in dev pixels.
   nsRect rootScreenRect = rootFrame->GetScreenRectInAppUnits();
 
-  nsIDeviceContext* devContext = presContext->DeviceContext();
+  nsDeviceContext* devContext = presContext->DeviceContext();
   nscoord offsetForContextMenu = 0;
   // if mScreenXPos and mScreenYPos are -1, then we are anchored. If they
   // have other values, then the popup appears unanchored at that screen
   // coordinate.
   if (mScreenXPos == -1 && mScreenYPos == -1) {
     // if we are anchored, there are certain things we don't want to do when
     // repositioning the popup to fit on the screen, such as end up positioned
     // over the anchor, for instance a popup appearing over the menu label.
--- a/layout/xul/base/src/nsTextBoxFrame.cpp
+++ b/layout/xul/base/src/nsTextBoxFrame.cpp
@@ -617,17 +617,17 @@ void nsTextBoxFrame::PaintOneShadow(gfxC
   nscolor shadowColor;
   if (aShadowDetails->mHasColor)
     shadowColor = aShadowDetails->mColor;
   else
     shadowColor = aForegroundColor;
 
   // Conjure an nsRenderingContext from a gfxContext for DrawText
   nsRefPtr<nsRenderingContext> renderingContext = nsnull;
-  nsIDeviceContext* devCtx = PresContext()->DeviceContext();
+  nsDeviceContext* devCtx = PresContext()->DeviceContext();
   devCtx->CreateRenderingContextInstance(*getter_AddRefs(renderingContext));
   if (!renderingContext)
     return;
   renderingContext->Init(devCtx, shadowContext);
 
   aCtx->Save();
   aCtx->NewPath();
   aCtx->SetColor(gfxRGBA(shadowColor));
--- a/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp
+++ b/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp
@@ -3746,18 +3746,18 @@ nsTreeBodyFrame::PaintProgressMeter(PRIn
     meterRect.width = meterWidth;
     PRBool useImageRegion = PR_TRUE;
     nsCOMPtr<imgIContainer> image;
     GetImage(aRowIndex, aColumn, PR_TRUE, meterContext, useImageRegion, getter_AddRefs(image));
     if (image) {
       PRInt32 width, height;
       image->GetWidth(&width);
       image->GetHeight(&height);
-      nsSize size(width*nsIDeviceContext::AppUnitsPerCSSPixel(),
-                  height*nsIDeviceContext::AppUnitsPerCSSPixel());
+      nsSize size(width*nsDeviceContext::AppUnitsPerCSSPixel(),
+                  height*nsDeviceContext::AppUnitsPerCSSPixel());
       nsLayoutUtils::DrawImage(&aRenderingContext, image,
           nsLayoutUtils::GetGraphicsFilterForFrame(this),
           nsRect(meterRect.TopLeft(), size), meterRect, meterRect.TopLeft(),
           aDirtyRect, imgIContainer::FLAG_NONE);
     } else {
       aRenderingContext.FillRect(meterRect);
     }
   }
@@ -3767,18 +3767,18 @@ nsTreeBodyFrame::PaintProgressMeter(PRIn
 
     PRBool useImageRegion = PR_TRUE;
     nsCOMPtr<imgIContainer> image;
     GetImage(aRowIndex, aColumn, PR_TRUE, meterContext, useImageRegion, getter_AddRefs(image));
     if (image) {
       PRInt32 width, height;
       image->GetWidth(&width);
       image->GetHeight(&height);
-      nsSize size(width*nsIDeviceContext::AppUnitsPerCSSPixel(),
-                  height*nsIDeviceContext::AppUnitsPerCSSPixel());
+      nsSize size(width*nsDeviceContext::AppUnitsPerCSSPixel(),
+                  height*nsDeviceContext::AppUnitsPerCSSPixel());
       nsLayoutUtils::DrawImage(&aRenderingContext, image,
           nsLayoutUtils::GetGraphicsFilterForFrame(this),
           nsRect(meterRect.TopLeft(), size), meterRect, meterRect.TopLeft(),
           aDirtyRect, imgIContainer::FLAG_NONE);
     }
   }
 }
 
--- a/view/public/nsIViewManager.h
+++ b/view/public/nsIViewManager.h
@@ -40,17 +40,17 @@
 
 #include "nscore.h"
 #include "nsIView.h"
 #include "nsEvent.h"
 
 class nsIWidget;
 struct nsRect;
 class nsRegion;
-class nsIDeviceContext;
+class nsDeviceContext;
 class nsIViewObserver;
 
 #define NS_IVIEWMANAGER_IID \
 { 0xa47cdaf9, 0x50fd, 0x40d8, \
   { 0x92, 0xe5, 0x93, 0x4f, 0xfb, 0x01, 0xdd, 0x98 } }
 
 class nsIViewManager : public nsISupports
 {
@@ -58,17 +58,17 @@ public:
 
   NS_DECLARE_STATIC_IID_ACCESSOR(NS_IVIEWMANAGER_IID)
   /**
    * Initialize the ViewManager
    * Note: this instance does not hold a reference to the viewobserver
    * because it holds a reference to this instance.
    * @result The result of the initialization, NS_OK if no errors
    */
-  NS_IMETHOD  Init(nsIDeviceContext* aContext) = 0;
+  NS_IMETHOD  Init(nsDeviceContext* aContext) = 0;
 
   /**
    * Create an ordinary view
    * @param aBounds initial bounds for view
    *        XXX We should eliminate this parameter; you can set the bounds after CreateView
    * @param aParent intended parent for view. this is not actually set in the
    *        nsIView through this method. it is only used by the initialization
    *        code to walk up the view tree, if necessary, to find resources.
@@ -270,17 +270,17 @@ public:
    * @result error status
    */
   NS_IMETHOD GetViewObserver(nsIViewObserver *&aObserver) = 0;
 
   /**
    * Get the device context associated with this manager
    * @result device context
    */
-  NS_IMETHOD  GetDeviceContext(nsIDeviceContext *&aContext) = 0;
+  NS_IMETHOD  GetDeviceContext(nsDeviceContext *&aContext) = 0;
 
   class UpdateViewBatch {
   public:
     UpdateViewBatch() {}
   /**
    * prevents the view manager from refreshing. allows UpdateView()
    * to notify widgets of damaged regions that should be repainted
    * when the batch is ended. Call EndUpdateViewBatch on this object
--- a/view/src/nsView.cpp
+++ b/view/src/nsView.cpp
@@ -730,17 +730,17 @@ nsresult nsView::CreateWidget(nsWidgetIn
   PRBool initDataPassedIn = !!aWidgetInitData;
   aWidgetInitData = aWidgetInitData ? aWidgetInitData : &defaultInitData;
   defaultInitData.mListenForResizes =
     (!initDataPassedIn && GetParent() &&
      GetParent()->GetViewManager() != mViewManager);
 
   nsIntRect trect = CalcWidgetBounds(aWidgetInitData->mWindowType);
 
-  nsCOMPtr<nsIDeviceContext> dx;
+  nsRefPtr<nsDeviceContext> dx;
   mViewManager->GetDeviceContext(*getter_AddRefs(dx));
 
   nsIWidget* parentWidget =
     GetParent() ? GetParent()->GetNearestWidget(nsnull) : nsnull;
   if (!parentWidget) {
     NS_ERROR("nsView::CreateWidget without suitable parent widget??");
     return NS_ERROR_FAILURE;
   }
@@ -770,17 +770,17 @@ nsresult nsView::CreateWidgetForParent(n
                     "Use CreateWidgetForPopup");
   NS_ABORT_IF_FALSE(aParentWidget, "Parent widget required");
 
   DefaultWidgetInitData defaultInitData;
   aWidgetInitData = aWidgetInitData ? aWidgetInitData : &defaultInitData;
 
   nsIntRect trect = CalcWidgetBounds(aWidgetInitData->mWindowType);
 
-  nsCOMPtr<nsIDeviceContext> dx;
+  nsRefPtr<nsDeviceContext> dx;
   mViewManager->GetDeviceContext(*getter_AddRefs(dx));
 
   mWindow =
     aParentWidget->CreateChild(trect, ::HandleEvent,
                                dx, nsnull, nsnull, aWidgetInitData).get();
   if (!mWindow) {
     return NS_ERROR_FAILURE;
   }
@@ -797,17 +797,17 @@ nsresult nsView::CreateWidgetForPopup(ns
 {
   AssertNoWindow();
   NS_ABORT_IF_FALSE(aWidgetInitData, "Widget init data required");
   NS_ABORT_IF_FALSE(aWidgetInitData->mWindowType == eWindowType_popup,
                     "Use one of the other CreateWidget methods");
 
   nsIntRect trect = CalcWidgetBounds(aWidgetInitData->mWindowType);
 
-  nsCOMPtr<nsIDeviceContext> dx;
+  nsRefPtr<nsDeviceContext> dx;
   mViewManager->GetDeviceContext(*getter_AddRefs(dx));
 
   // XXX/cjones: having these two separate creation cases seems ... um
   // ... unnecessary, but it's the way the old code did it.  Please
   // unify them by first finding a suitable parent nsIWidget, then
   // getting rid of aForceUseIWidgetParent.
   if (aParentWidget) {
     // XXX: using aForceUseIWidgetParent=true to preserve previous
@@ -867,17 +867,17 @@ nsresult nsIView::AttachToTopLevelWidget
   NS_PRECONDITION(nsnull != aWidget, "null widget ptr");
   /// XXXjimm This is a temporary workaround to an issue w/document
   // viewer (bug 513162).
   nsIView *oldView = GetAttachedViewFor(aWidget);
   if (oldView) {
     oldView->DetachFromTopLevelWidget();
   }
 
-  nsCOMPtr<nsIDeviceContext> dx;
+  nsRefPtr<nsDeviceContext> dx;
   mViewManager->GetDeviceContext(*getter_AddRefs(dx));
 
   // Note, the previous device context will be released. Detaching
   // will not restore the old one.
   nsresult rv = aWidget->AttachViewToTopLevel(
     nsIWidget::UsePuppetWidgets() ? ::HandleEvent : ::AttachedHandleEvent, dx);
   if (NS_FAILED(rv))
     return rv;
--- a/view/src/nsViewManager.cpp
+++ b/view/src/nsViewManager.cpp
@@ -206,17 +206,17 @@ nsViewManager::CreateRegion(nsIRegion* *
     rv = region->Init();
     *result = region;
   }
   return rv;
 }
 
 // We don't hold a reference to the presentation context because it
 // holds a reference to us.
-NS_IMETHODIMP nsViewManager::Init(nsIDeviceContext* aContext)
+NS_IMETHODIMP nsViewManager::Init(nsDeviceContext* aContext)
 {
   NS_PRECONDITION(nsnull != aContext, "null ptr");
 
   if (nsnull == aContext) {
     return NS_ERROR_NULL_POINTER;
   }
   if (nsnull != mContext) {
     return NS_ERROR_ALREADY_INITIALIZED;
@@ -1516,17 +1516,17 @@ NS_IMETHODIMP nsViewManager::GetViewObse
   if (nsnull != mObserver) {
     aObserver = mObserver;
     NS_ADDREF(mObserver);
     return NS_OK;
   } else
     return NS_ERROR_NO_INTERFACE;
 }
 
-NS_IMETHODIMP nsViewManager::GetDeviceContext(nsIDeviceContext *&aContext)
+NS_IMETHODIMP nsViewManager::GetDeviceContext(nsDeviceContext *&aContext)
 {
   NS_IF_ADDREF(mContext);
   aContext = mContext;
   return NS_OK;
 }
 
 void nsViewManager::TriggerRefresh(PRUint32 aUpdateFlags)
 {
--- a/view/src/nsViewManager.h
+++ b/view/src/nsViewManager.h
@@ -43,17 +43,17 @@
 #include "nsITimer.h"
 #include "prtime.h"
 #include "prinrval.h"
 #include "nsVoidArray.h"
 #include "nsThreadUtils.h"
 #include "nsIRegion.h"
 #include "nsView.h"
 #include "nsIViewObserver.h"
-#include "nsIDeviceContext.h"
+#include "nsDeviceContext.h"
 
 
 /**
    Invalidation model:
 
    1) Callers call into the view manager and ask it to update a view.
    
    2) The view manager finds the "right" widget for the view, henceforth called
@@ -95,17 +95,17 @@ protected:
 class nsViewManager : public nsIViewManager {
 public:
   nsViewManager();
 
   NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW
 
   NS_DECL_ISUPPORTS
 
-  NS_IMETHOD  Init(nsIDeviceContext* aContext);
+  NS_IMETHOD  Init(nsDeviceContext* aContext);
 
   NS_IMETHOD_(nsIView*) CreateView(const nsRect& aBounds,
                                    const nsIView* aParent,
                                    nsViewVisibility aVisibilityFlag = nsViewVisibility_kShow);
 
   NS_IMETHOD_(nsIView*) GetRootView();
   NS_IMETHOD  SetRootView(nsIView *aView);
 
@@ -139,17 +139,17 @@ public:
 
   NS_IMETHOD  SetViewVisibility(nsIView *aView, nsViewVisibility aVisible);
 
   NS_IMETHOD  SetViewZIndex(nsIView *aView, PRBool aAuto, PRInt32 aZIndex, PRBool aTopMost=PR_FALSE);
 
   NS_IMETHOD  SetViewObserver(nsIViewObserver *aObserver);
   NS_IMETHOD  GetViewObserver(nsIViewObserver *&aObserver);
 
-  NS_IMETHOD  GetDeviceContext(nsIDeviceContext *&aContext);
+  NS_IMETHOD  GetDeviceContext(nsDeviceContext *&aContext);
 
   virtual nsIViewManager* BeginUpdateViewBatch(void);
   NS_IMETHOD  EndUpdateViewBatch(PRUint32 aUpdateFlags);
 
   NS_IMETHOD GetRootWidget(nsIWidget **aWidget);
   NS_IMETHOD ForceUpdate();
  
   NS_IMETHOD IsPainting(PRBool& aIsPainting);
@@ -270,17 +270,17 @@ public: // NOT in nsIViewManager, so pri
   void PostPendingUpdate() { RootViewManager()->mHasPendingUpdates = PR_TRUE; }
 
   PRInt32 AppUnitsPerDevPixel() const
   {
     return mContext->AppUnitsPerDevPixel();
   }
 
 private:
-  nsCOMPtr<nsIDeviceContext> mContext;
+  nsRefPtr<nsDeviceContext> mContext;
   nsIViewObserver   *mObserver;
   // relative to mRootView and set only on the root view manager
   nsPoint           mMouseLocation;
 
   // The size for a resize that we delayed until the root view becomes
   // visible again.
   nsSize            mDelayedResize;
 
--- a/widget/public/nsIWidget.h
+++ b/widget/public/nsIWidget.h
@@ -55,17 +55,17 @@
 #include "nsTArray.h"
 #include "nsXULAppAPI.h"
 
 // forward declarations
 class   nsIAppShell;
 class   nsIToolkit;
 class   nsFontMetrics;
 class   nsRenderingContext;
-class   nsIDeviceContext;
+class   nsDeviceContext;
 struct  nsFont;
 class   nsIRollupListener;
 class   nsIMenuRollup;
 class   nsGUIEvent;
 class   imgIContainer;
 class   gfxASurface;
 class   nsIContent;
 class   ViewWrapper;
@@ -302,17 +302,17 @@ class nsIWidget : public nsISupports {
      * @param     aToolkit
      * @param     aInitData     data that is used for widget initialization
      *
      */
     NS_IMETHOD Create(nsIWidget        *aParent,
                       nsNativeWidget   aNativeParent,
                       const nsIntRect  &aRect,
                       EVENT_CALLBACK   aHandleEventFunction,
-                      nsIDeviceContext *aContext,
+                      nsDeviceContext *aContext,
                       nsIAppShell      *aAppShell = nsnull,
                       nsIToolkit       *aToolkit = nsnull,
                       nsWidgetInitData *aInitData = nsnull) = 0;
 
     /**
      * Allocate, initialize, and return a widget that is a child of
      * |this|.  The returned widget (if nonnull) has gone through the
      * equivalent of CreateInstance(widgetCID) + Create(...).
@@ -326,17 +326,17 @@ class nsIWidget : public nsISupports {
      * |aForceUseIWidgetParent| forces |CreateChild()| to only use the
      * |nsIWidget*| this, not its native widget (if it exists), when
      * calling |Create()|.  This is a timid hack around poorly
      * understood code, and shouldn't be used in new code.
      */
     virtual already_AddRefed<nsIWidget>
     CreateChild(const nsIntRect  &aRect,
                 EVENT_CALLBACK   aHandleEventFunction,
-                nsIDeviceContext *aContext,
+                nsDeviceContext *aContext,
                 nsIAppShell      *aAppShell = nsnull,
                 nsIToolkit       *aToolkit = nsnull,
                 nsWidgetInitData *aInitData = nsnull,
                 PRBool           aForceUseIWidgetParent = PR_FALSE) = 0;
 
     /**
      * Attach to a top level widget. 
      *
@@ -345,17 +345,17 @@ class nsIWidget : public nsISupports {
      * context. The primary event callback will continue to be called, so the
      * owning base window will continue to function.
      *
      * aViewEventFunction Event callback that will receive mirrored
      *                    events.
      * aContext The new device context for the view
      */
     NS_IMETHOD AttachViewToTopLevel(EVENT_CALLBACK aViewEventFunction,
-                                    nsIDeviceContext *aContext) = 0;
+                                    nsDeviceContext *aContext) = 0;
 
     /**
      * Accessor functions to get and set secondary client data. Used by
      * nsIView in connection with AttachViewToTopLevel above.
      */
     NS_IMETHOD SetAttachedViewPtr(ViewWrapper* aViewWrapper) = 0;
     virtual ViewWrapper* GetAttachedViewPtr() = 0;
 
@@ -931,17 +931,17 @@ class nsIWidget : public nsISupports {
 
     //@{
     virtual void AddChild(nsIWidget* aChild) = 0;
     virtual void RemoveChild(nsIWidget* aChild) = 0;
     virtual void* GetNativeData(PRUint32 aDataType) = 0;
     virtual void FreeNativeData(void * data, PRUint32 aDataType) = 0;//~~~
 
     // GetDeviceContext returns a weak pointer to this widget's device context
-    virtual nsIDeviceContext* GetDeviceContext() = 0;
+    virtual nsDeviceContext* GetDeviceContext() = 0;
 
     //@}
 
     /**
      * Set the widget's title.
      * Must be called after Create.
      *
      * @param aTitle string displayed as the title of the widget
--- a/widget/src/android/nsWindow.cpp
+++ b/widget/src/android/nsWindow.cpp
@@ -192,17 +192,17 @@ nsWindow::IsTopLevel()
         mWindowType == eWindowType_invisible;
 }
 
 NS_IMETHODIMP
 nsWindow::Create(nsIWidget *aParent,
                  nsNativeWidget aNativeParent,
                  const nsIntRect &aRect,
                  EVENT_CALLBACK aHandleEventFunction,
-                 nsIDeviceContext *aContext,
+                 nsDeviceContext *aContext,
                  nsIAppShell *aAppShell,
                  nsIToolkit *aToolkit,
                  nsWidgetInitData *aInitData)
 {
     ALOG("nsWindow[%p]::Create %p [%d %d %d %d]", (void*)this, (void*)aParent, aRect.x, aRect.y, aRect.width, aRect.height);
     nsWindow *parent = (nsWindow*) aParent;
 
     if (!AndroidBridge::Bridge()) {
--- a/widget/src/android/nsWindow.h
+++ b/widget/src/android/nsWindow.h
@@ -81,17 +81,17 @@ public:
     //
     // nsIWidget
     //
 
     NS_IMETHOD Create(nsIWidget *aParent,
                       nsNativeWidget aNativeParent,
                       const nsIntRect &aRect,
                       EVENT_CALLBACK aHandleEventFunction,
-                      nsIDeviceContext *aContext,
+                      nsDeviceContext *aContext,
                       nsIAppShell *aAppShell,
                       nsIToolkit *aToolkit,
                       nsWidgetInitData *aInitData);
     NS_IMETHOD Destroy(void);
     NS_IMETHOD ConfigureChildren(const nsTArray<nsIWidget::Configuration>&);
     NS_IMETHOD SetParent(nsIWidget* aNewParent);
     virtual nsIWidget *GetParent(void);
     virtual float GetDPI();
--- a/widget/src/cocoa/nsChildView.h
+++ b/widget/src/cocoa/nsChildView.h
@@ -303,17 +303,17 @@ public:
   
   NS_DECL_ISUPPORTS_INHERITED
 
   // nsIWidget interface
   NS_IMETHOD              Create(nsIWidget *aParent,
                                  nsNativeWidget aNativeParent,
                                  const nsIntRect &aRect,
                                  EVENT_CALLBACK aHandleEventFunction,
-                                 nsIDeviceContext *aContext,
+                                 nsDeviceContext *aContext,
                                  nsIAppShell *aAppShell = nsnull,
                                  nsIToolkit *aToolkit = nsnull,
                                  nsWidgetInitData *aInitData = nsnull);
 
   NS_IMETHOD              Destroy();
 
   NS_IMETHOD              Show(PRBool aState);
   NS_IMETHOD              IsVisible(PRBool& outState);
--- a/widget/src/cocoa/nsChildView.mm
+++ b/widget/src/cocoa/nsChildView.mm
@@ -529,17 +529,17 @@ nsChildView::~nsChildView()
 }
 
 NS_IMPL_ISUPPORTS_INHERITED1(nsChildView, nsBaseWidget, nsIPluginWidget)
 
 nsresult nsChildView::Create(nsIWidget *aParent,
                              nsNativeWidget aNativeParent,
                              const nsIntRect &aRect,
                              EVENT_CALLBACK aHandleEventFunction,
-                             nsIDeviceContext *aContext,
+                             nsDeviceContext *aContext,
                              nsIAppShell *aAppShell,
                              nsIToolkit *aToolkit,
                              nsWidgetInitData *aInitData)
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
 
   // Because the hidden window is created outside of an event loop,
   // we need to provide an autorelease pool to avoid leaking cocoa objects
--- a/widget/src/cocoa/nsCocoaWindow.h
+++ b/widget/src/cocoa/nsCocoaWindow.h
@@ -209,17 +209,17 @@ public:
 
     NS_DECL_ISUPPORTS_INHERITED
     NS_DECL_NSPIWIDGETCOCOA
       
     NS_IMETHOD              Create(nsIWidget* aParent,
                                    nsNativeWidget aNativeParent,
                                    const nsIntRect &aRect,
                                    EVENT_CALLBACK aHandleEventFunction,
-                                   nsIDeviceContext *aContext,
+                                   nsDeviceContext *aContext,
                                    nsIAppShell *aAppShell = nsnull,
                                    nsIToolkit *aToolkit = nsnull,
                                    nsWidgetInitData *aInitData = nsnull);
 
     NS_IMETHOD              Destroy();
 
     NS_IMETHOD              Show(PRBool aState);
     virtual nsIWidget*      GetSheetWindowParent(void);
@@ -303,17 +303,17 @@ public:
     NS_IMETHOD         ReparentNativeWidget(nsIWidget* aNewParent);
 protected:
 
   nsresult             CreateNativeWindow(const NSRect &aRect,
                                           nsBorderStyle aBorderStyle,
                                           PRBool aRectIsFrameRect);
   nsresult             CreatePopupContentView(const nsIntRect &aRect,
                                               EVENT_CALLBACK aHandleEventFunction,
-                                              nsIDeviceContext *aContext,
+                                              nsDeviceContext *aContext,
                                               nsIAppShell *aAppShell,
                                               nsIToolkit *aToolkit);
   void                 DestroyNativeWindow();
   void                 AdjustWindowShadow();
   void                 SetUpWindowFilter();
   void                 CleanUpWindowFilter();
   void                 UpdateBounds();
 
--- a/widget/src/cocoa/nsCocoaWindow.mm
+++ b/widget/src/cocoa/nsCocoaWindow.mm
@@ -235,17 +235,17 @@ static PRBool UseNativePopupWindows()
   nsresult rv = prefs->GetBoolPref("ui.use_native_popup_windows", &useNativePopupWindows);
   return (NS_SUCCEEDED(rv) && useNativePopupWindows);
 }
 
 nsresult nsCocoaWindow::Create(nsIWidget *aParent,
                                nsNativeWidget aNativeParent,
                                const nsIntRect &aRect,
                                EVENT_CALLBACK aHandleEventFunction,
-                               nsIDeviceContext *aContext,
+                               nsDeviceContext *aContext,
                                nsIAppShell *aAppShell,
                                nsIToolkit *aToolkit,
                                nsWidgetInitData *aInitData)
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
 
   // Because the hidden window is created outside of an event loop,
   // we have to provide an autorelease pool (see bug 559075).
@@ -443,17 +443,17 @@ nsresult nsCocoaWindow::CreateNativeWind
 
   return NS_OK;
 
   NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
 }
 
 NS_IMETHODIMP nsCocoaWindow::CreatePopupContentView(const nsIntRect &aRect,
                              EVENT_CALLBACK aHandleEventFunction,
-                             nsIDeviceContext *aContext,
+                             nsDeviceContext *aContext,
                              nsIAppShell *aAppShell,
                              nsIToolkit *aToolkit)
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
 
   // We need to make our content view a ChildView.
   mPopupContentView = new nsChildView();
   if (!mPopupContentView)
--- a/widget/src/cocoa/nsNativeThemeCocoa.h
+++ b/widget/src/cocoa/nsNativeThemeCocoa.h
@@ -44,44 +44,44 @@
 #include "nsITheme.h"
 #include "nsCOMPtr.h"
 #include "nsIAtom.h"
 #include "nsILookAndFeel.h"
 #include "nsNativeTheme.h"
 #include "gfxASurface.h"
 
 @class CellDrawView;
-class nsIDeviceContext;
+class nsDeviceContext;
 
 class nsNativeThemeCocoa : private nsNativeTheme,
                            public nsITheme
 {
 public:
   nsNativeThemeCocoa();
   virtual ~nsNativeThemeCocoa();
 
   NS_DECL_ISUPPORTS_INHERITED
 
   // The nsITheme interface.
   NS_IMETHOD DrawWidgetBackground(nsRenderingContext* aContext,
                                   nsIFrame* aFrame,
                                   PRUint8 aWidgetType,
                                   const nsRect& aRect,
                                   const nsRect& aDirtyRect);
-  NS_IMETHOD GetWidgetBorder(nsIDeviceContext* aContext, 
+  NS_IMETHOD GetWidgetBorder(nsDeviceContext* aContext, 
                              nsIFrame* aFrame,
                              PRUint8 aWidgetType,
                              nsIntMargin* aResult);
 
-  virtual PRBool GetWidgetPadding(nsIDeviceContext* aContext,
+  virtual PRBool GetWidgetPadding(nsDeviceContext* aContext,
                                   nsIFrame* aFrame,
                                   PRUint8 aWidgetType,
                                   nsIntMargin* aResult);
 
-  virtual PRBool GetWidgetOverflow(nsIDeviceContext* aContext, nsIFrame* aFrame,
+  virtual PRBool GetWidgetOverflow(nsDeviceContext* aContext, nsIFrame* aFrame,
                                    PRUint8 aWidgetType, nsRect* aOverflowRect);
 
   NS_IMETHOD GetMinimumWidgetSize(nsRenderingContext* aContext, nsIFrame* aFrame,
                                   PRUint8 aWidgetType,
                                   nsIntSize* aResult, PRBool* aIsOverridable);
   NS_IMETHOD WidgetStateChanged(nsIFrame* aFrame, PRUint8 aWidgetType, 
                                 nsIAtom* aAttribute, PRBool* aShouldRepaint);
   NS_IMETHOD ThemeChanged();
--- a/widget/src/cocoa/nsNativeThemeCocoa.mm
+++ b/widget/src/cocoa/nsNativeThemeCocoa.mm
@@ -1947,17 +1947,17 @@ nsNativeThemeCocoa::RTLAwareMargin(const
   return aMargin;
 }
 
 static const nsIntMargin kAquaDropdownBorder(5, 1, 22, 2);
 static const nsIntMargin kAquaComboboxBorder(4, 3, 20, 3);
 static const nsIntMargin kAquaSearchfieldBorder(19, 3, 5, 2);
 
 NS_IMETHODIMP
-nsNativeThemeCocoa::GetWidgetBorder(nsIDeviceContext* aContext, 
+nsNativeThemeCocoa::GetWidgetBorder(nsDeviceContext* aContext, 
                                     nsIFrame* aFrame,
                                     PRUint8 aWidgetType,
                                     nsIntMargin* aResult)
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
 
   aResult->SizeTo(0, 0, 0, 0);
 
@@ -2054,17 +2054,17 @@ nsNativeThemeCocoa::GetWidgetBorder(nsID
   NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
 }
 
 // Return PR_FALSE here to indicate that CSS padding values should be used. There is
 // no reason to make a distinction between padding and border values, just specify
 // whatever values you want in GetWidgetBorder and only use this to return PR_TRUE
 // if you want to override CSS padding values.
 PRBool
-nsNativeThemeCocoa::GetWidgetPadding(nsIDeviceContext* aContext, 
+nsNativeThemeCocoa::GetWidgetPadding(nsDeviceContext* aContext, 
                                      nsIFrame* aFrame,
                                      PRUint8 aWidgetType,
                                      nsIntMargin* aResult)
 {
   // We don't want CSS padding being used for certain widgets.
   // See bug 381639 for an example of why.
   switch (aWidgetType) {
     case NS_THEME_BUTTON:
@@ -2075,17 +2075,17 @@ nsNativeThemeCocoa::GetWidgetPadding(nsI
     case NS_THEME_RADIO:
       aResult->SizeTo(0, 0, 0, 0);
       return PR_TRUE;
   }
   return PR_FALSE;
 }
 
 PRBool
-nsNativeThemeCocoa::GetWidgetOverflow(nsIDeviceContext* aContext, nsIFrame* aFrame,
+nsNativeThemeCocoa::GetWidgetOverflow(nsDeviceContext* aContext, nsIFrame* aFrame,
                                       PRUint8 aWidgetType, nsRect* aOverflowRect)
 {
   switch (aWidgetType) {
     case NS_THEME_BUTTON:
     case NS_THEME_TEXTFIELD:
     case NS_THEME_TEXTFIELD_MULTILINE:
     case NS_THEME_SEARCHFIELD:
     case NS_THEME_LISTBOX:
--- a/widget/src/gtk2/nsNativeThemeGTK.cpp
+++ b/widget/src/gtk2/nsNativeThemeGTK.cpp
@@ -873,17 +873,17 @@ nsNativeThemeGTK::DrawWidgetBackground(n
       SetWidgetStateSafe(mSafeWidgetStates, aWidgetType, &state);
     }
   }
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsNativeThemeGTK::GetWidgetBorder(nsIDeviceContext* aContext, nsIFrame* aFrame,
+nsNativeThemeGTK::GetWidgetBorder(nsDeviceContext* aContext, nsIFrame* aFrame,
                                   PRUint8 aWidgetType, nsIntMargin* aResult)
 {
   GtkTextDirection direction = GetTextDirection(aFrame);
   aResult->top = aResult->left = aResult->right = aResult->bottom = 0;
   switch (aWidgetType) {
   case NS_THEME_SCROLLBAR_TRACK_VERTICAL:
   case NS_THEME_SCROLLBAR_TRACK_HORIZONTAL:
     {
@@ -924,17 +924,17 @@ nsNativeThemeGTK::GetWidgetBorder(nsIDev
                                   &aResult->right, &aResult->bottom, direction,
                                   IsFrameContentNodeInNamespace(aFrame, kNameSpaceID_XHTML));
     }
   }
   return NS_OK;
 }
 
 PRBool
-nsNativeThemeGTK::GetWidgetPadding(nsIDeviceContext* aContext,
+nsNativeThemeGTK::GetWidgetPadding(nsDeviceContext* aContext,
                                    nsIFrame* aFrame, PRUint8 aWidgetType,
                                    nsIntMargin* aResult)
 {
   switch (aWidgetType) {
     case NS_THEME_BUTTON_FOCUS:
     case NS_THEME_TOOLBAR_BUTTON:
     case NS_THEME_TOOLBAR_DUAL_BUTTON:
     case NS_THEME_TAB_SCROLLARROW_BACK:
@@ -953,17 +953,17 @@ nsNativeThemeGTK::GetWidgetPadding(nsIDe
       aResult->SizeTo(0, 0, 0, 0);
       return PR_TRUE;
   }
 
   return PR_FALSE;
 }
 
 PRBool
-nsNativeThemeGTK::GetWidgetOverflow(nsIDeviceContext* aContext,
+nsNativeThemeGTK::GetWidgetOverflow(nsDeviceContext* aContext,
                                     nsIFrame* aFrame, PRUint8 aWidgetType,
                                     nsRect* aOverflowRect)
 {
   nsMargin m;
   PRInt32 p2a;
   nsIntMargin extraSize;
   if (!GetExtraSizeForWidget(aFrame, aWidgetType, &extraSize))
     return PR_FALSE;
--- a/widget/src/gtk2/nsNativeThemeGTK.h
+++ b/widget/src/gtk2/nsNativeThemeGTK.h
@@ -54,25 +54,25 @@ public:
   NS_DECL_NSIOBSERVER
 
   // The nsITheme interface.
   NS_IMETHOD DrawWidgetBackground(nsRenderingContext* aContext,
                                   nsIFrame* aFrame, PRUint8 aWidgetType,
                                   const nsRect& aRect,
                                   const nsRect& aDirtyRect);
 
-  NS_IMETHOD GetWidgetBorder(nsIDeviceContext* aContext, nsIFrame* aFrame,
+  NS_IMETHOD GetWidgetBorder(nsDeviceContext* aContext, nsIFrame* aFrame,
                              PRUint8 aWidgetType, nsIntMargin* aResult);
 
-  virtual NS_HIDDEN_(PRBool) GetWidgetPadding(nsIDeviceContext* aContext,
+  virtual NS_HIDDEN_(PRBool) GetWidgetPadding(nsDeviceContext* aContext,
                                               nsIFrame* aFrame,
                                               PRUint8 aWidgetType,
                                               nsIntMargin* aResult);
 
-  virtual NS_HIDDEN_(PRBool) GetWidgetOverflow(nsIDeviceContext* aContext,
+  virtual NS_HIDDEN_(PRBool) GetWidgetOverflow(nsDeviceContext* aContext,
                                                nsIFrame* aFrame,
                                                PRUint8 aWidgetType,
                                                nsRect* aOverflowRect);
 
   NS_IMETHOD GetMinimumWidgetSize(nsRenderingContext* aContext,
                                   nsIFrame* aFrame, PRUint8 aWidgetType,
                                   nsIntSize* aResult, PRBool* aIsOverridable);
 
--- a/widget/src/gtk2/nsWindow.cpp
+++ b/widget/src/gtk2/nsWindow.cpp
@@ -3817,17 +3817,17 @@ CreateGdkWindow(GdkWindow *parent, GtkWi
     return window;
 }
 
 nsresult
 nsWindow::Create(nsIWidget        *aParent,
                  nsNativeWidget    aNativeParent,
                  const nsIntRect  &aRect,
                  EVENT_CALLBACK    aHandleEventFunction,
-                 nsIDeviceContext *aContext,
+                 nsDeviceContext *aContext,
                  nsIAppShell      *aAppShell,
                  nsIToolkit       *aToolkit,
                  nsWidgetInitData *aInitData)
 {
     // only set the base parent if we're going to be a dialog or a
     // toplevel
     nsIWidget *baseParent = aInitData &&
         (aInitData->mWindowType == eWindowType_dialog ||
--- a/widget/src/gtk2/nsWindow.h
+++ b/widget/src/gtk2/nsWindow.h
@@ -132,17 +132,17 @@ public:
     // called to check and see if a widget's dimensions are sane
     PRBool AreBoundsSane(void);
 
     // nsIWidget
     NS_IMETHOD         Create(nsIWidget        *aParent,
                               nsNativeWidget   aNativeParent,
                               const nsIntRect  &aRect,
                               EVENT_CALLBACK   aHandleEventFunction,
-                              nsIDeviceContext *aContext,
+                              nsDeviceContext *aContext,
                               nsIAppShell      *aAppShell,
                               nsIToolkit       *aToolkit,
                               nsWidgetInitData *aInitData);
     NS_IMETHOD         Destroy(void);
     virtual nsIWidget *GetParent();
     virtual float      GetDPI();
     virtual nsresult   SetParent(nsIWidget* aNewParent);
     NS_IMETHOD         SetModal(PRBool aModal);
--- a/widget/src/os2/nsGfxDefs.h
+++ b/widget/src/os2/nsGfxDefs.h
@@ -47,17 +47,17 @@
 #define INCL_DEV
 #include <os2.h>
 #include "prlog.h"
 #include "nsHashtable.h"
 
 #include <uconv.h> // XXX hack XXX
 
 class nsString;
-class nsIDeviceContext;
+class nsDeviceContext;
 
 #ifndef min
 #define min(a,b) (((a) < (b)) ? (a) : (b))
 #endif
 
 #define MK_RGB(r,g,b) ((r) * 65536) + ((g) * 256) + (b)
 
 #endif
--- a/widget/src/os2/nsWindow.cpp
+++ b/widget/src/os2/nsWindow.cpp
@@ -333,17 +333,17 @@ void nsWindow::ReleaseGlobals()
 
 //-----------------------------------------------------------------------------
 // Init an nsWindow & create the appropriate native window.
 
 NS_METHOD nsWindow::Create(nsIWidget* aParent,
                            nsNativeWidget aNativeParent,
                            const nsIntRect& aRect,
                            EVENT_CALLBACK aHandleEventFunction,
-                           nsIDeviceContext* aContext,
+                           nsDeviceContext* aContext,
                            nsIAppShell* aAppShell,
                            nsIToolkit* aToolkit,
                            nsWidgetInitData* aInitData)
 {
   mWindowState = nsWindowState_eInCreate;
 
   // Identify the parent's nsWindow & native window.  Only one of these
   // should be supplied.  Note:  only nsWindow saves pParent as mParent;
--- a/widget/src/os2/nsWindow.h
+++ b/widget/src/os2/nsWindow.h
@@ -160,17 +160,17 @@ public:
   nsWindow();
   virtual ~nsWindow();
 
   // from nsIWidget
   NS_IMETHOD            Create(nsIWidget* aParent,
                                nsNativeWidget aNativeParent,
                                const nsIntRect& aRect,
                                EVENT_CALLBACK aHandleEventFunction,
-                               nsIDeviceContext* aContext,
+                               nsDeviceContext* aContext,
                                nsIAppShell* aAppShell = nsnull,
                                nsIToolkit* aToolkit = nsnull,
                                nsWidgetInitData* aInitData = nsnull);
   NS_IMETHOD            Destroy();
   virtual nsIWidget*    GetParent();
   virtual float         GetDPI();
   NS_IMETHOD            Enable(PRBool aState);
   NS_IMETHOD            IsEnabled(PRBool* aState);
--- a/widget/src/qt/nsNativeThemeQt.cpp
+++ b/widget/src/qt/nsNativeThemeQt.cpp
@@ -341,17 +341,17 @@ nsNativeThemeQt::DrawWidgetBackground(QP
         break;
     }
 
     qPainter->restore();
     return NS_OK;
 }
 
 NS_IMETHODIMP
-nsNativeThemeQt::GetWidgetBorder(nsIDeviceContext* ,
+nsNativeThemeQt::GetWidgetBorder(nsDeviceContext* ,
                                  nsIFrame* aFrame,
                                  PRUint8 aWidgetType,
                                  nsIntMargin* aResult)
 {
     (*aResult).top = (*aResult).bottom = (*aResult).left = (*aResult).right = 0;
 
     QStyle* style = qApp->style();
     switch(aWidgetType) {
@@ -364,17 +364,17 @@ nsNativeThemeQt::GetWidgetBorder(nsIDevi
     default:
         break;
     }
 
     return NS_OK;
 }
 
 PRBool
-nsNativeThemeQt::GetWidgetPadding(nsIDeviceContext* ,
+nsNativeThemeQt::GetWidgetPadding(nsDeviceContext* ,
                                   nsIFrame*, PRUint8 aWidgetType,
                                   nsIntMargin* aResult)
 {
     // XXX: Where to get padding values, framewidth?
     if (aWidgetType == NS_THEME_TEXTFIELD ||
         aWidgetType == NS_THEME_TEXTFIELD_MULTILINE ||
         aWidgetType == NS_THEME_DROPDOWN) {
         aResult->SizeTo(2, 2, 2, 2);
--- a/widget/src/qt/nsNativeThemeQt.h
+++ b/widget/src/qt/nsNativeThemeQt.h
@@ -48,32 +48,32 @@
 #include "nsNativeTheme.h"
 
 class QComboBox;
 class QStyleOptionButton;
 class QStyleOptionFrameV2;
 class QStyleOptionComboBox;
 class QRect;
 class nsIFrame;
-class nsIDeviceContext;
+class nsDeviceContext;
 
 class nsNativeThemeQt : private nsNativeTheme,
                         public nsITheme
 {
 public:
   NS_DECL_ISUPPORTS_INHERITED
 
   // The nsITheme interface.
   NS_IMETHOD DrawWidgetBackground(nsRenderingContext* aContext,
                                   nsIFrame* aFrame,
                                   PRUint8 aWidgetType,
                                   const nsRect& aRect,
                                   const nsRect& aClipRect);
 
-  NS_IMETHOD GetWidgetBorder(nsIDeviceContext* aContext,
+  NS_IMETHOD GetWidgetBorder(nsDeviceContext* aContext,
                              nsIFrame* aFrame,
                              PRUint8 aWidgetType,
                              nsIntMargin* aResult);
 
   NS_IMETHOD GetMinimumWidgetSize(nsRenderingContext* aContext, nsIFrame* aFrame,
                                   PRUint8 aWidgetType,
                                   nsIntSize* aResult,
                                   PRBool* aIsOverridable);
@@ -84,17 +84,17 @@ public:
   NS_IMETHOD ThemeChanged();
 
   PRBool ThemeSupportsWidget(nsPresContext* aPresContext,
                              nsIFrame* aFrame,
                              PRUint8 aWidgetType);
 
   PRBool WidgetIsContainer(PRUint8 aWidgetType);
 
-  virtual NS_HIDDEN_(PRBool) GetWidgetPadding(nsIDeviceContext* aContext,
+  virtual NS_HIDDEN_(PRBool) GetWidgetPadding(nsDeviceContext* aContext,
                                               nsIFrame* aFrame,
                                               PRUint8 aWidgetType,
                                               nsIntMargin* aResult);
 
   NS_IMETHOD_(PRBool) ThemeDrawsFocusForWidget(nsPresContext* aPresContext,
                                                nsIFrame* aFrame, PRUint8 aWidgetType);
 
   PRBool ThemeNeedsComboboxDropmarker();
--- a/widget/src/qt/nsWindow.cpp
+++ b/widget/src/qt/nsWindow.cpp
@@ -2177,17 +2177,17 @@ GetBrandName(nsXPIDLString& brandName)
 }
 
 
 nsresult
 nsWindow::Create(nsIWidget        *aParent,
                  nsNativeWidget    aNativeParent,
                  const nsIntRect  &aRect,
                  EVENT_CALLBACK    aHandleEventFunction,
-                 nsIDeviceContext *aContext,
+                 nsDeviceContext *aContext,
                  nsIAppShell      *aAppShell,
                  nsIToolkit       *aToolkit,
                  nsWidgetInitData *aInitData)
 {
     // only set the base parent if we're not going to be a dialog or a
     // toplevel
     nsIWidget *baseParent = aParent;
 
@@ -2235,17 +2235,17 @@ nsWindow::Create(nsIWidget        *aPare
                          (aInitData && aInitData->mListenForResizes));
 
     return NS_OK;
 }
 
 already_AddRefed<nsIWidget>
 nsWindow::CreateChild(const nsIntRect&  aRect,
                       EVENT_CALLBACK    aHandleEventFunction,
-                      nsIDeviceContext* aContext,
+                      nsDeviceContext* aContext,
                       nsIAppShell*      aAppShell,
                       nsIToolkit*       aToolkit,
                       nsWidgetInitData* aInitData,
                       PRBool            /*aForceUseIWidgetParent*/)
 {
     //We need to force parent widget, otherwise GetTopLevelWindow doesn't work
     return nsBaseWidget::CreateChild(aRect,
                                      aHandleEventFunction,
--- a/widget/src/qt/nsWindow.h
+++ b/widget/src/qt/nsWindow.h
@@ -122,25 +122,25 @@ public:
     //
 
     NS_IMETHOD         ConfigureChildren(const nsTArray<nsIWidget::Configuration>&);
 
     NS_IMETHOD         Create(nsIWidget        *aParent,
                               nsNativeWidget   aNativeParent,
                               const nsIntRect  &aRect,
                               EVENT_CALLBACK   aHandleEventFunction,
-                              nsIDeviceContext *aContext,
+                              nsDeviceContext *aContext,
                               nsIAppShell      *aAppShell,
                               nsIToolkit       *aToolkit,
                               nsWidgetInitData *aInitData);
 
     virtual already_AddRefed<nsIWidget>
     CreateChild(const nsIntRect&  aRect,
                 EVENT_CALLBACK    aHandleEventFunction,
-                nsIDeviceContext* aContext,
+                nsDeviceContext* aContext,
                 nsIAppShell*      aAppShell = nsnull,
                 nsIToolkit*       aToolkit = nsnull,
                 nsWidgetInitData* aInitData = nsnull,
                 PRBool            aForceUseIWidgetParent = PR_TRUE);
 
     NS_IMETHOD         Destroy(void);
     NS_IMETHOD         SetParent(nsIWidget* aNewParent);
     virtual nsIWidget *GetParent(void);
--- a/widget/src/windows/nsNativeThemeWin.cpp
+++ b/widget/src/windows/nsNativeThemeWin.cpp
@@ -1579,17 +1579,17 @@ RENDER_AGAIN:
     goto RENDER_AGAIN;
 
   nativeDrawing.PaintToContext();
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsNativeThemeWin::GetWidgetBorder(nsIDeviceContext* aContext, 
+nsNativeThemeWin::GetWidgetBorder(nsDeviceContext* aContext, 
                                   nsIFrame* aFrame,
                                   PRUint8 aWidgetType,
                                   nsIntMargin* aResult)
 {
   HANDLE theme = GetTheme(aWidgetType);
   if (!theme)
     return ClassicGetWidgetBorder(aContext, aFrame, aWidgetType, aResult); 
 
@@ -1666,17 +1666,17 @@ nsNativeThemeWin::GetWidgetBorder(nsIDev
       aResult->right++;
     }
   }
 
   return NS_OK;
 }
 
 PRBool
-nsNativeThemeWin::GetWidgetPadding(nsIDeviceContext* aContext, 
+nsNativeThemeWin::GetWidgetPadding(nsDeviceContext* aContext, 
                                    nsIFrame* aFrame,
                                    PRUint8 aWidgetType,
                                    nsIntMargin* aResult)
 {
   switch (aWidgetType) {
     // Radios and checkboxes return a fixed size in GetMinimumWidgetSize
     // and have a meaningful baseline, so they can't have
     // author-specified padding.
@@ -1803,17 +1803,17 @@ nsNativeThemeWin::GetWidgetPadding(nsIDe
     aResult->right = right;
     aResult->left = left;
   }
   
   return PR_TRUE;
 }
 
 PRBool
-nsNativeThemeWin::GetWidgetOverflow(nsIDeviceContext* aContext, 
+nsNativeThemeWin::GetWidgetOverflow(nsDeviceContext* aContext, 
                                     nsIFrame* aFrame,
                                     PRUint8 aOverflowRect,
                                     nsRect* aResult)
 {
   /* This is disabled for now, because it causes invalidation problems --
    * see bug 420381.  The effect of not updating the overflow area is that
    * for dropdown buttons in content areas, there is a 1px border on 3 sides
    * where, if invalidated, the dropdown control probably won't be repainted.
@@ -2341,17 +2341,17 @@ nsNativeThemeWin::ClassicThemeSupportsWi
     case NS_THEME_WINDOW_BUTTON_BOX:
     case NS_THEME_WINDOW_BUTTON_BOX_MAXIMIZED:
       return PR_TRUE;
   }
   return PR_FALSE;
 }
 
 nsresult
-nsNativeThemeWin::ClassicGetWidgetBorder(nsIDeviceContext* aContext, 
+nsNativeThemeWin::ClassicGetWidgetBorder(nsDeviceContext* aContext, 
                                   nsIFrame* aFrame,
                                   PRUint8 aWidgetType,
                                   nsIntMargin* aResult)
 {
   switch (aWidgetType) {
     case NS_THEME_GROUPBOX:
     case NS_THEME_BUTTON:
       (*aResult).top = (*aResult).left = (*aResult).bottom = (*aResult).right = 2; 
--- a/widget/src/windows/nsNativeThemeWin.h
+++ b/widget/src/windows/nsNativeThemeWin.h
@@ -53,27 +53,27 @@ public:
 
   // The nsITheme interface.
   NS_IMETHOD DrawWidgetBackground(nsRenderingContext* aContext,
                                   nsIFrame* aFrame,
                                   PRUint8 aWidgetType,
                                   const nsRect& aRect,
                                   const nsRect& aDirtyRect);
 
-  NS_IMETHOD GetWidgetBorder(nsIDeviceContext* aContext, 
+  NS_IMETHOD GetWidgetBorder(nsDeviceContext* aContext, 
                              nsIFrame* aFrame,
                              PRUint8 aWidgetType,
                              nsIntMargin* aResult);
 
-  virtual PRBool GetWidgetPadding(nsIDeviceContext* aContext,
+  virtual PRBool GetWidgetPadding(nsDeviceContext* aContext,
                                   nsIFrame* aFrame,
                                   PRUint8 aWidgetType,
                                   nsIntMargin* aResult);
 
-  virtual PRBool GetWidgetOverflow(nsIDeviceContext* aContext,
+  virtual PRBool GetWidgetOverflow(nsDeviceContext* aContext,
                                    nsIFrame* aFrame,
                                    PRUint8 aWidgetType,
                                    nsRect* aOverflowRect);
 
   NS_IMETHOD GetMinimumWidgetSize(nsRenderingContext* aContext, nsIFrame* aFrame,
                                   PRUint8 aWidgetType,
                                   nsIntSize* aResult,
                                   PRBool* aIsOverridable);
@@ -104,17 +104,17 @@ protected:
                                 PRInt32& aPart, PRInt32& aState);
   nsresult ClassicGetThemePartAndState(nsIFrame* aFrame, PRUint8 aWidgetType,
                                    PRInt32& aPart, PRInt32& aState, PRBool& aFocused);
   nsresult ClassicDrawWidgetBackground(nsRenderingContext* aContext,
                                   nsIFrame* aFrame,
                                   PRUint8 aWidgetType,
                                   const nsRect& aRect,
                                   const nsRect& aClipRect);
-  nsresult ClassicGetWidgetBorder(nsIDeviceContext* aContext, 
+  nsresult ClassicGetWidgetBorder(nsDeviceContext* aContext, 
                              nsIFrame* aFrame,
                              PRUint8 aWidgetType,
                              nsIntMargin* aResult);
 
   nsresult ClassicGetMinimumWidgetSize(nsRenderingContext* aContext, nsIFrame* aFrame,
                                   PRUint8 aWidgetType,
                                   nsIntSize* aResult,
                                   PRBool* aIsOverridable);
--- a/widget/src/windows/nsWindow.cpp
+++ b/widget/src/windows/nsWindow.cpp
@@ -544,17 +544,17 @@ PRInt32 nsWindow::GetHeight(PRInt32 aPro
 }
 
 // Create the proper widget
 nsresult
 nsWindow::Create(nsIWidget *aParent,
                  nsNativeWidget aNativeParent,
                  const nsIntRect &aRect,
                  EVENT_CALLBACK aHandleEventFunction,
-                 nsIDeviceContext *aContext,
+                 nsDeviceContext *aContext,
                  nsIAppShell *aAppShell,
                  nsIToolkit *aToolkit,
                  nsWidgetInitData *aInitData)
 {
   nsWidgetInitData defaultInitData;
   if (!aInitData)
     aInitData = &defaultInitData;
 
--- a/widget/src/windows/nsWindow.h
+++ b/widget/src/windows/nsWindow.h
@@ -113,17 +113,17 @@ public:
 
   /**
    * nsIWidget interface
    */
   NS_IMETHOD              Create(nsIWidget *aParent,
                                  nsNativeWidget aNativeParent,
                                  const nsIntRect &aRect,
                                  EVENT_CALLBACK aHandleEventFunction,
-                                 nsIDeviceContext *aContext,
+                                 nsDeviceContext *aContext,
                                  nsIAppShell *aAppShell = nsnull,
                                  nsIToolkit *aToolkit = nsnull,
                                  nsWidgetInitData *aInitData = nsnull);
   NS_IMETHOD              Destroy();
   NS_IMETHOD              SetParent(nsIWidget *aNewParent);
   virtual nsIWidget*      GetParent(void);
   virtual float           GetDPI();
   NS_IMETHOD              Show(PRBool bState);
--- a/widget/src/xpwidgets/PuppetWidget.cpp
+++ b/widget/src/xpwidgets/PuppetWidget.cpp
@@ -103,17 +103,17 @@ PuppetWidget::~PuppetWidget()
   MOZ_COUNT_DTOR(PuppetWidget);
 }
 
 NS_IMETHODIMP
 PuppetWidget::Create(nsIWidget        *aParent,
                      nsNativeWidget   aNativeParent,
                      const nsIntRect  &aRect,
                      EVENT_CALLBACK   aHandleEventFunction,
-                     nsIDeviceContext *aContext,
+                     nsDeviceContext *aContext,
                      nsIAppShell      *aAppShell,
                      nsIToolkit       *aToolkit,
                      nsWidgetInitData *aInitData)
 {
   NS_ABORT_IF_FALSE(!aNativeParent, "got a non-Puppet native parent");
 
   BaseCreate(nsnull, aRect, aHandleEventFunction, aContext,
              aAppShell, aToolkit, aInitData);
@@ -143,17 +143,17 @@ PuppetWidget::Create(nsIWidget        *a
   }
 
   return NS_OK;
 }
 
 already_AddRefed<nsIWidget>
 PuppetWidget::CreateChild(const nsIntRect  &aRect,
                           EVENT_CALLBACK   aHandleEventFunction,
-                          nsIDeviceContext *aContext,
+                          nsDeviceContext *aContext,
                           nsIAppShell      *aAppShell,
                           nsIToolkit       *aToolkit,
                           nsWidgetInitData *aInitData,
                           PRBool           aForceUseIWidgetParent)
 {
   bool isPopup = IsPopup(aInitData);
   nsCOMPtr<nsIWidget> widget = nsIWidget::CreatePuppetWidget(mTabChild);
   return ((widget &&
--- a/widget/src/xpwidgets/PuppetWidget.h
+++ b/widget/src/xpwidgets/PuppetWidget.h
@@ -69,25 +69,25 @@ public:
   virtual ~PuppetWidget();
 
   NS_DECL_ISUPPORTS_INHERITED
 
   NS_IMETHOD Create(nsIWidget*        aParent,
                     nsNativeWidget    aNativeParent,
                     const nsIntRect&  aRect,
                     EVENT_CALLBACK    aHandleEventFunction,
-                    nsIDeviceContext* aContext,
+                    nsDeviceContext* aContext,
                     nsIAppShell*      aAppShell = nsnull,
                     nsIToolkit*       aToolkit = nsnull,
                     nsWidgetInitData* aInitData = nsnull);
 
   virtual already_AddRefed<nsIWidget>
   CreateChild(const nsIntRect  &aRect,
               EVENT_CALLBACK   aHandleEventFunction,
-              nsIDeviceContext *aContext,
+              nsDeviceContext *aContext,
               nsIAppShell      *aAppShell = nsnull,
               nsIToolkit       *aToolkit = nsnull,
               nsWidgetInitData *aInitData = nsnull,
               PRBool           aForceUseIWidgetParent = PR_FALSE);
 
   NS_IMETHOD Destroy();
 
   NS_IMETHOD Show(PRBool aState);
@@ -161,17 +161,17 @@ public:
 
   //
   // nsBaseWidget methods we override
   //
 
 //NS_IMETHOD              CaptureMouse(PRBool aCapture);
   virtual LayerManager*     GetLayerManager(LayerManagerPersistence aPersistence = LAYER_MANAGER_CURRENT,
                                             bool* aAllowRetaining = nsnull);
-//  virtual nsIDeviceContext* GetDeviceContext();
+//  virtual nsDeviceContext* GetDeviceContext();
   virtual gfxASurface*      GetThebesSurface();
 
   NS_IMETHOD ResetInputState();
   NS_IMETHOD SetIMEOpenState(PRBool aState);
   NS_IMETHOD GetIMEOpenState(PRBool *aState);
   NS_IMETHOD SetInputMode(const IMEContext& aContext);
   NS_IMETHOD GetInputMode(IMEContext& aContext);
   NS_IMETHOD CancelComposition();
--- a/widget/src/xpwidgets/nsBaseDragService.cpp
+++ b/widget/src/xpwidgets/nsBaseDragService.cpp
@@ -583,17 +583,17 @@ nsBaseDragService::DrawDragForImage(nsPr
   nsIntSize srcSize = aScreenDragRect->Size();
   nsIntSize destSize = srcSize;
 
   if (destSize.width == 0 || destSize.height == 0)
     return NS_ERROR_FAILURE;
 
   // if the image is larger than half the screen size, scale it down. This
   // scaling algorithm is the same as is used in nsPresShell::PaintRangePaintInfo
-  nsIDeviceContext* deviceContext = aPresContext->DeviceContext();
+  nsDeviceContext* deviceContext = aPresContext->DeviceContext();
   nsRect maxSize;
   deviceContext->GetClientRect(maxSize);
   nscoord maxWidth = aPresContext->AppUnitsToDevPixels(maxSize.width >> 1);
   nscoord maxHeight = aPresContext->AppUnitsToDevPixels(maxSize.height >> 1);
   if (destSize.width > maxWidth || destSize.height > maxHeight) {
     float scale = 1.0;
     if (destSize.width > maxWidth)
       scale = PR_MIN(scale, float(maxWidth) / destSize.width);
--- a/widget/src/xpwidgets/nsBaseWidget.cpp
+++ b/widget/src/xpwidgets/nsBaseWidget.cpp
@@ -32,17 +32,17 @@
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include "nsBaseWidget.h"
-#include "nsIDeviceContext.h"
+#include "nsDeviceContext.h"
 #include "nsCOMPtr.h"
 #include "nsGfxCIID.h"
 #include "nsWidgetsCID.h"
 #include "nsServiceManagerUtils.h"
 #include "nsIScreenManager.h"
 #include "nsAppDirectoryServiceDefs.h"
 #include "nsISimpleEnumerator.h"
 #include "nsIContent.h"
@@ -158,17 +158,17 @@ nsBaseWidget::~nsBaseWidget()
 //-------------------------------------------------------------------------
 //
 // Basic create.
 //
 //-------------------------------------------------------------------------
 void nsBaseWidget::BaseCreate(nsIWidget *aParent,
                               const nsIntRect &aRect,
                               EVENT_CALLBACK aHandleEventFunction,
-                              nsIDeviceContext *aContext,
+                              nsDeviceContext *aContext,
                               nsIAppShell *aAppShell,
                               nsIToolkit *aToolkit,
                               nsWidgetInitData *aInitData)
 {
   if (nsnull == mToolkit) {
     if (nsnull != aToolkit) {
       mToolkit = (nsIToolkit*)aToolkit;
       NS_ADDREF(mToolkit);
@@ -247,17 +247,17 @@ NS_IMETHODIMP nsBaseWidget::SetClientDat
 {
   mClientData = aClientData;
   return NS_OK;
 }
 
 already_AddRefed<nsIWidget>
 nsBaseWidget::CreateChild(const nsIntRect  &aRect,
                           EVENT_CALLBACK   aHandleEventFunction,
-                          nsIDeviceContext *aContext,
+                          nsDeviceContext *aContext,
                           nsIAppShell      *aAppShell,
                           nsIToolkit       *aToolkit,
                           nsWidgetInitData *aInitData,
                           PRBool           aForceUseIWidgetParent)
 {
   nsIWidget* parent = this;
   nsNativeWidget nativeParent = nsnull;
 
@@ -287,17 +287,17 @@ nsBaseWidget::CreateChild(const nsIntRec
   }
 
   return nsnull;
 }
 
 // Attach a view to our widget which we'll send events to. 
 NS_IMETHODIMP
 nsBaseWidget::AttachViewToTopLevel(EVENT_CALLBACK aViewEventFunction,
-                                   nsIDeviceContext *aContext)
+                                   nsDeviceContext *aContext)
 {
   NS_ASSERTION((mWindowType == eWindowType_toplevel ||
                 mWindowType == eWindowType_dialog ||
                 mWindowType == eWindowType_invisible ||
                 mWindowType == eWindowType_child),
                "Can't attach to window of that type");
 
   mViewCallback = aViewEventFunction;
@@ -910,17 +910,17 @@ nsIToolkit* nsBaseWidget::GetToolkit()
 }
 
 
 //-------------------------------------------------------------------------
 //
 // Return the used device context
 //
 //-------------------------------------------------------------------------
-nsIDeviceContext* nsBaseWidget::GetDeviceContext() 
+nsDeviceContext* nsBaseWidget::GetDeviceContext() 
 {
   return mContext; 
 }
 
 //-------------------------------------------------------------------------
 //
 // Get the thebes surface
 //
--- a/widget/src/xpwidgets/nsBaseWidget.h
+++ b/widget/src/xpwidgets/nsBaseWidget.h
@@ -108,17 +108,17 @@ public:
   NS_IMETHOD              GetWindowType(nsWindowType& aWindowType);
   virtual void            SetTransparencyMode(nsTransparencyMode aMode);
   virtual nsTransparencyMode GetTransparencyMode();
   virtual void            GetWindowClipRegion(nsTArray<nsIntRect>* aRects);
   NS_IMETHOD              SetWindowShadowStyle(PRInt32 aStyle);
   virtual void            SetShowsToolbarButton(PRBool aShow) {}
   NS_IMETHOD              HideWindowChrome(PRBool aShouldHide);
   NS_IMETHOD              MakeFullScreen(PRBool aFullScreen);
-  virtual nsIDeviceContext* GetDeviceContext();
+  virtual nsDeviceContext* GetDeviceContext();
   virtual nsIToolkit*     GetToolkit();
   virtual LayerManager*   GetLayerManager(LayerManagerPersistence aPersistence,
                                           bool* aAllowRetaining = nsnull);
   using nsIWidget::GetLayerManager;
 
   virtual void            DrawOver(LayerManager* aManager, nsIntRect aRect) {}
   virtual void            UpdateThemeGeometries(const nsTArray<ThemeGeometry>& aThemeGeometries) {}
   virtual gfxASurface*    GetThebesSurface();
@@ -159,22 +159,22 @@ public:
   NS_IMETHOD              OnIMETextChange(PRUint32 aStart, PRUint32 aOldEnd, PRUint32 aNewEnd) { return NS_ERROR_NOT_IMPLEMENTED; }
   NS_IMETHOD              OnIMESelectionChange(void) { return NS_ERROR_NOT_IMPLEMENTED; }
   virtual nsIMEUpdatePreference GetIMEUpdatePreference() { return nsIMEUpdatePreference(PR_FALSE, PR_FALSE); }
   NS_IMETHOD              OnDefaultButtonLoaded(const nsIntRect &aButtonRect) { return NS_ERROR_NOT_IMPLEMENTED; }
   NS_IMETHOD              OverrideSystemMouseScrollSpeed(PRInt32 aOriginalDelta, PRBool aIsHorizontal, PRInt32 &aOverriddenDelta);
   virtual already_AddRefed<nsIWidget>
   CreateChild(const nsIntRect  &aRect,
               EVENT_CALLBACK   aHandleEventFunction,
-              nsIDeviceContext *aContext,
+              nsDeviceContext *aContext,
               nsIAppShell      *aAppShell = nsnull,
               nsIToolkit       *aToolkit = nsnull,
               nsWidgetInitData *aInitData = nsnull,
               PRBool           aForceUseIWidgetParent = PR_FALSE);
-  NS_IMETHOD              AttachViewToTopLevel(EVENT_CALLBACK aViewEventFunction, nsIDeviceContext *aContext);
+  NS_IMETHOD              AttachViewToTopLevel(EVENT_CALLBACK aViewEventFunction, nsDeviceContext *aContext);
   virtual ViewWrapper*    GetAttachedViewPtr();
   NS_IMETHOD              SetAttachedViewPtr(ViewWrapper* aViewWrapper);
   NS_IMETHOD              ResizeClient(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight, PRBool aRepaint);
   NS_IMETHOD              GetNonClientMargins(nsIntMargin &margins);
   NS_IMETHOD              SetNonClientMargins(nsIntMargin &margins);
   NS_IMETHOD              RegisterTouchWindow();
   NS_IMETHOD              UnregisterTouchWindow();
 
@@ -222,17 +222,17 @@ protected:
 
   virtual void            ResolveIconName(const nsAString &aIconName,
                                           const nsAString &aIconSuffix,
                                           nsILocalFile **aResult);
   virtual void            OnDestroy();
   virtual void            BaseCreate(nsIWidget *aParent,
                                      const nsIntRect &aRect,
                                      EVENT_CALLBACK aHandleEventFunction,
-                                     nsIDeviceContext *aContext,
+                                     nsDeviceContext *aContext,
                                      nsIAppShell *aAppShell,
                                      nsIToolkit *aToolkit,
                                      nsWidgetInitData *aInitData);
 
   virtual nsIContent* GetLastRollup()
   {
     return mLastRollup;
   }
@@ -263,17 +263,17 @@ protected:
 
   BasicLayerManager* CreateBasicLayerManager();
 
 protected: 
   void*             mClientData;
   ViewWrapper*      mViewWrapperPtr;
   EVENT_CALLBACK    mEventCallback;
   EVENT_CALLBACK    mViewCallback;
-  nsIDeviceContext* mContext;
+  nsDeviceContext* mContext;
   nsIToolkit*       mToolkit;
   nsRefPtr<LayerManager> mLayerManager;
   nsRefPtr<LayerManager> mBasicLayerManager;
   nscolor           mBackground;
   nscolor           mForeground;
   nsCursor          mCursor;
   nsWindowType      mWindowType;
   nsBorderStyle     mBorderStyle;