Backed out changeset 64d814cd18b3
authorChris Jones <jones.chris.g@gmail.com>
Wed, 04 Jan 2012 01:17:38 -0800
changeset 86567 a814c07a085fec703558a89979f4d88c7eb0d1ca
parent 86561 64d814cd18b35b73ddbb568b026d1df11a85b2dd
child 86568 ad98a08690cb7329ee47bda90ab8f9ea28c3e186
push id129
push userffxbld
push dateFri, 20 Apr 2012 19:40:49 +0000
treeherdermozilla-release@5bcfa0da3be9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
milestone12.0a1
backs out64d814cd18b35b73ddbb568b026d1df11a85b2dd
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Backed out changeset 64d814cd18b3
mobile/xul/chrome/content/common-ui.js
widget/android/nsScreenManagerAndroid.cpp
widget/android/nsScreenManagerAndroid.h
widget/cocoa/nsScreenCocoa.h
widget/cocoa/nsScreenCocoa.mm
widget/gonk/nsScreenManagerGonk.cpp
widget/gonk/nsScreenManagerGonk.h
widget/gtk2/nsScreenGtk.cpp
widget/gtk2/nsScreenGtk.h
widget/nsIScreen.idl
widget/os2/nsScreenOS2.cpp
widget/os2/nsScreenOS2.h
widget/qt/nsScreenQt.cpp
widget/qt/nsScreenQt.h
widget/shared/WidgetUtils.cpp
widget/shared/WidgetUtils.h
widget/windows/nsScreenWin.cpp
widget/windows/nsScreenWin.h
widget/xpwidgets/Makefile.in
widget/xpwidgets/nsBaseScreen.cpp
widget/xpwidgets/nsBaseScreen.h
--- a/mobile/xul/chrome/content/common-ui.js
+++ b/mobile/xul/chrome/content/common-ui.js
@@ -1171,17 +1171,18 @@ var FullScreenVideo = {
     messageManager.addMessageListener("Browser:FullScreenVideo:Close", this.hide.bind(this));
     messageManager.addMessageListener("Browser:FullScreenVideo:Play", this.play.bind(this));
     messageManager.addMessageListener("Browser:FullScreenVideo:Pause", this.pause.bind(this));
 
     // If the screen supports brightness locks, we will utilize that, see checkBrightnessLocking()
     try {
       this.screen = null;
       let screenManager = Cc["@mozilla.org/gfx/screenmanager;1"].getService(Ci.nsIScreenManager);
-      this.screen = screenManager.primaryScreen;
+      let screen = screenManager.primaryScreen.QueryInterface(Ci.nsIScreen_MOZILLA_2_0_BRANCH);
+      this.screen = screen;
     }
     catch (e) {} // The screen does not support brightness locks
   },
 
   play: function() {
     this.playing = true;
     this.checkBrightnessLocking();
   },
--- a/widget/android/nsScreenManagerAndroid.cpp
+++ b/widget/android/nsScreenManagerAndroid.cpp
@@ -37,16 +37,18 @@
  * ***** END LICENSE BLOCK ***** */
 
 #include "nsScreenManagerAndroid.h"
 #include "nsWindow.h"
 #include "AndroidBridge.h"
 
 using namespace mozilla;
 
+NS_IMPL_ISUPPORTS2(nsScreenAndroid, nsIScreen, nsIScreen_MOZILLA_2_0_BRANCH)
+
 nsScreenAndroid::nsScreenAndroid(void *nativeScreen)
 {
 }
 
 nsScreenAndroid::~nsScreenAndroid()
 {
 }
 
--- a/widget/android/nsScreenManagerAndroid.h
+++ b/widget/android/nsScreenManagerAndroid.h
@@ -36,33 +36,33 @@
  *
  * ***** END LICENSE BLOCK ***** */
 
 #ifndef nsScreenManagerAndroid_h___
 #define nsScreenManagerAndroid_h___
 
 #include "nsCOMPtr.h"
 
-#include "nsBaseScreen.h"
 #include "nsIScreenManager.h"
+#include "nsIScreen.h"
 #include "WidgetUtils.h"
 
-class nsScreenAndroid : public nsBaseScreen
+class nsScreenAndroid
+  : public nsIScreen
+  , public mozilla::widget::BrightnessLockingWidget
 {
 public:
     nsScreenAndroid(void *nativeScreen);
     ~nsScreenAndroid();
 
-    NS_IMETHOD GetRect(PRInt32* aLeft, PRInt32* aTop, PRInt32* aWidth, PRInt32* aHeight);
-    NS_IMETHOD GetAvailRect(PRInt32* aLeft, PRInt32* aTop, PRInt32* aWidth, PRInt32* aHeight);
-    NS_IMETHOD GetPixelDepth(PRInt32* aPixelDepth);
-    NS_IMETHOD GetColorDepth(PRInt32* aColorDepth);
+    NS_DECL_ISUPPORTS
+    NS_DECL_NSISCREEN
 
 protected:
-    virtual void ApplyMinimumBrightness(PRUint32 aBrightness) MOZ_OVERRIDE;
+    void ApplyMinimumBrightness(PRUint32 aBrightness);
 };
 
 class nsScreenManagerAndroid :
     public nsIScreenManager
 {
 public:
     nsScreenManagerAndroid();
     ~nsScreenManagerAndroid();
--- a/widget/cocoa/nsScreenCocoa.h
+++ b/widget/cocoa/nsScreenCocoa.h
@@ -36,28 +36,27 @@
  *
  * ***** END LICENSE BLOCK ***** */
 
 #ifndef nsScreenCocoa_h_
 #define nsScreenCocoa_h_
 
 #import <Cocoa/Cocoa.h>
 
-#include "nsBaseScreen.h"
+#include "nsIScreen.h"
 
-class nsScreenCocoa : public nsBaseScreen
+class nsScreenCocoa : public nsIScreen
 {
 public:
     nsScreenCocoa (NSScreen *screen);
     ~nsScreenCocoa ();
 
-    NS_IMETHOD GetRect(PRInt32* aLeft, PRInt32* aTop, PRInt32* aWidth, PRInt32* aHeight);
-    NS_IMETHOD GetAvailRect(PRInt32* aLeft, PRInt32* aTop, PRInt32* aWidth, PRInt32* aHeight);
-    NS_IMETHOD GetPixelDepth(PRInt32* aPixelDepth);
-    NS_IMETHOD GetColorDepth(PRInt32* aColorDepth);
+    NS_DECL_ISUPPORTS
+
+    NS_DECL_NSISCREEN
 
     NSScreen *CocoaScreen() { return mScreen; }
 
 private:
     NSScreen *mScreen;
 };
 
 #endif // nsScreenCocoa_h_
--- a/widget/cocoa/nsScreenCocoa.mm
+++ b/widget/cocoa/nsScreenCocoa.mm
@@ -35,16 +35,18 @@
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include "nsScreenCocoa.h"
 #include "nsObjCExceptions.h"
 #include "nsCocoaUtils.h"
 
+NS_IMPL_ISUPPORTS1(nsScreenCocoa, nsIScreen)
+
 nsScreenCocoa::nsScreenCocoa (NSScreen *screen)
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
 
   mScreen = [screen retain];
 
   NS_OBJC_END_TRY_ABORT_BLOCK;
 }
--- a/widget/gonk/nsScreenManagerGonk.cpp
+++ b/widget/gonk/nsScreenManagerGonk.cpp
@@ -36,16 +36,18 @@
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include "nsScreenManagerGonk.h"
 #include "nsWindow.h"
 
 using namespace mozilla;
 
+NS_IMPL_ISUPPORTS2(nsScreenGonk, nsIScreen, nsIScreen)
+
 nsScreenGonk::nsScreenGonk(void *nativeScreen)
 {
 }
 
 nsScreenGonk::~nsScreenGonk()
 {
 }
 
@@ -57,33 +59,36 @@ nsScreenGonk::GetRect(PRInt32 *outLeft, 
     *outTop = gScreenBounds.y;
 
     *outWidth = gScreenBounds.width;
     *outHeight = gScreenBounds.height;
 
     return NS_OK;
 }
 
+
 NS_IMETHODIMP
 nsScreenGonk::GetAvailRect(PRInt32 *outLeft,  PRInt32 *outTop,
-                           PRInt32 *outWidth, PRInt32 *outHeight)
+                          PRInt32 *outWidth, PRInt32 *outHeight)
 {
     return GetRect(outLeft, outTop, outWidth, outHeight);
 }
 
 
+
 NS_IMETHODIMP
 nsScreenGonk::GetPixelDepth(PRInt32 *aPixelDepth)
 {
     // XXX do we need to lie here about 16bpp?  Or
     // should we actually check and return the right thing?
     *aPixelDepth = 24;
     return NS_OK;
 }
 
+
 NS_IMETHODIMP
 nsScreenGonk::GetColorDepth(PRInt32 *aColorDepth)
 {
     return GetPixelDepth(aColorDepth);
 }
 
 NS_IMPL_ISUPPORTS1(nsScreenManagerGonk, nsIScreenManager)
 
--- a/widget/gonk/nsScreenManagerGonk.h
+++ b/widget/gonk/nsScreenManagerGonk.h
@@ -36,29 +36,28 @@
  *
  * ***** END LICENSE BLOCK ***** */
 
 #ifndef nsScreenManagerGonk_h___
 #define nsScreenManagerGonk_h___
 
 #include "nsCOMPtr.h"
 
-#include "nsBaseScreen.h"
 #include "nsIScreenManager.h"
+#include "nsIScreen.h"
+#include "WidgetUtils.h"
 
-class nsScreenGonk : public nsBaseScreen
+class nsScreenGonk : public nsIScreen
 {
 public:
-    nsScreenGonk(void* nativeScreen);
+    nsScreenGonk(void *nativeScreen);
     ~nsScreenGonk();
 
-    NS_IMETHOD GetRect(PRInt32* aLeft, PRInt32* aTop, PRInt32* aWidth, PRInt32* aHeight);
-    NS_IMETHOD GetAvailRect(PRInt32* aLeft, PRInt32* aTop, PRInt32* aWidth, PRInt32* aHeight);
-    NS_IMETHOD GetPixelDepth(PRInt32* aPixelDepth);
-    NS_IMETHOD GetColorDepth(PRInt32* aColorDepth);
+    NS_DECL_ISUPPORTS
+    NS_DECL_NSISCREEN
 };
 
 class nsScreenManagerGonk : public nsIScreenManager
 {
 public:
     nsScreenManagerGonk();
     ~nsScreenManagerGonk();
 
--- a/widget/gtk2/nsScreenGtk.cpp
+++ b/widget/gtk2/nsScreenGtk.cpp
@@ -53,16 +53,20 @@ nsScreenGtk :: nsScreenGtk (  )
 }
 
 
 nsScreenGtk :: ~nsScreenGtk()
 {
 }
 
 
+// addref, release, QI
+NS_IMPL_ISUPPORTS1(nsScreenGtk, nsIScreen)
+
+
 NS_IMETHODIMP
 nsScreenGtk :: GetRect(PRInt32 *outLeft, PRInt32 *outTop, PRInt32 *outWidth, PRInt32 *outHeight)
 {
   *outLeft = mRect.x;
   *outTop = mRect.y;
   *outWidth = mRect.width;
   *outHeight = mRect.height;
 
--- a/widget/gtk2/nsScreenGtk.h
+++ b/widget/gtk2/nsScreenGtk.h
@@ -33,17 +33,17 @@
  * 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 ***** */
 
 #ifndef nsScreenGtk_h___
 #define nsScreenGtk_h___
 
-#include "nsBaseScreen.h"
+#include "nsIScreen.h"
 #include "nsRect.h"
 #include "gdk/gdk.h"
 #ifdef MOZ_X11
 #include <X11/Xlib.h>
 
 // from Xinerama.h
 typedef struct {
    int   screen_number;
@@ -51,26 +51,24 @@ typedef struct {
    short y_org;
    short width;
    short height;
 } XineramaScreenInfo;
 #endif /* MOZ_X11 */
 
 //------------------------------------------------------------------------
 
-class nsScreenGtk : public nsBaseScreen
+class nsScreenGtk : public nsIScreen
 {
 public:
   nsScreenGtk();
   ~nsScreenGtk();
 
-  NS_IMETHOD GetRect(PRInt32* aLeft, PRInt32* aTop, PRInt32* aWidth, PRInt32* aHeight);
-  NS_IMETHOD GetAvailRect(PRInt32* aLeft, PRInt32* aTop, PRInt32* aWidth, PRInt32* aHeight);
-  NS_IMETHOD GetPixelDepth(PRInt32* aPixelDepth);
-  NS_IMETHOD GetColorDepth(PRInt32* aColorDepth);
+  NS_DECL_ISUPPORTS
+  NS_DECL_NSISCREEN
 
   void Init(GdkWindow *aRootWindow);
 #ifdef MOZ_X11
   void Init(XineramaScreenInfo *aScreenInfo);
 #endif /* MOZ_X11 */
 
 private:
   PRUint32 mScreenNum;
--- a/widget/nsIScreen.idl
+++ b/widget/nsIScreen.idl
@@ -33,31 +33,43 @@
  * 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 "nsISupports.idl"
 
-[scriptable, uuid(498dcd6c-94a2-4c32-8c77-531b583dff37)]
+
+[scriptable, uuid(f728830e-1dd1-11b2-9598-fb9f414f2465)]
 interface nsIScreen : nsISupports
 {
+  void GetRect ( out long left, out long top, out long width, out long height );
+  void GetAvailRect ( out long left, out long top, out long width, out long height );
+  
+  readonly attribute long pixelDepth;
+  readonly attribute long colorDepth;  
+};
+
+
+%{ C++
+
+%}
+
+[scriptable, uuid(f7c93d20-c4e4-4628-b343-cb5530b04f15)]
+interface nsIScreen_MOZILLA_2_0_BRANCH : nsISupports {
   /**
    * Levels of brightness for the screen, from off to full brightness.
    */
   const unsigned long BRIGHTNESS_DIM = 0;
   const unsigned long BRIGHTNESS_FULL = 1;
 
   /* The number of different brightness levels */
   const unsigned long BRIGHTNESS_LEVELS = 2;
 
-  void getRect(out long left, out long top, out long width, out long height);
-  void getAvailRect(out long left, out long top, out long width, out long height);
-
   /**
    * Locks the minimum brightness of the screen, forcing it to be at
    * least as bright as a certain brightness level. Each call to this
    * function must eventually be followed by a corresponding call to
    * unlockMinimumBrightness, with the same brightness level.
    *
    * @param brightness A brightness level, one of the above constants.
    */
@@ -65,12 +77,10 @@ interface nsIScreen : nsISupports
 
   /**
    * Releases a lock on the screen brightness. This must be called
    * (eventually) after a corresponding call to lockMinimumBrightness.
    *
    * @param brightness A brightness level, one of the above constants.
    */
   void unlockMinimumBrightness(in unsigned long brightness);
-  
-  readonly attribute long pixelDepth;
-  readonly attribute long colorDepth;  
 };
+
--- a/widget/os2/nsScreenOS2.cpp
+++ b/widget/os2/nsScreenOS2.cpp
@@ -46,16 +46,20 @@ nsScreenOS2 :: nsScreenOS2 (  )
 
 
 nsScreenOS2 :: ~nsScreenOS2()
 {
   // nothing to see here.
 }
 
 
+// addref, release, QI
+NS_IMPL_ISUPPORTS1(nsScreenOS2, nsIScreen)
+
+
 NS_IMETHODIMP
 nsScreenOS2 :: GetRect(PRInt32 *outLeft, PRInt32 *outTop, PRInt32 *outWidth, PRInt32 *outHeight)
 {
   LONG alArray[2];
 
   HPS hps = ::WinGetScreenPS( HWND_DESKTOP);
   HDC hdc = ::GpiQueryDevice (hps);
   ::DevQueryCaps(hdc, CAPS_WIDTH, 2, alArray);
--- a/widget/os2/nsScreenOS2.h
+++ b/widget/os2/nsScreenOS2.h
@@ -33,32 +33,30 @@
  * 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 ***** */
 
 #ifndef nsScreenOS2_h___
 #define nsScreenOS2_h___
 
-#include "nsBaseScreen.h"
+#include "nsIScreen.h"
 
 #define INCL_WIN
 #define INCL_DOS
 #include <os2.h>
 
 //------------------------------------------------------------------------
 
-class nsScreenOS2 : public nsBaseScreen
+class nsScreenOS2 : public nsIScreen
 {
 public:
   nsScreenOS2 ( );
   virtual ~nsScreenOS2();
 
-  NS_IMETHOD GetRect(PRInt32* aLeft, PRInt32* aTop, PRInt32* aWidth, PRInt32* aHeight);
-  NS_IMETHOD GetAvailRect(PRInt32* aLeft, PRInt32* aTop, PRInt32* aWidth, PRInt32* aHeight);
-  NS_IMETHOD GetPixelDepth(PRInt32* aPixelDepth);
-  NS_IMETHOD GetColorDepth(PRInt32* aColorDepth);
+  NS_DECL_ISUPPORTS
+  NS_DECL_NSISCREEN
 
 private:
 
 };
 
 #endif  // nsScreenOS2_h___ 
--- a/widget/qt/nsScreenQt.cpp
+++ b/widget/qt/nsScreenQt.cpp
@@ -74,16 +74,23 @@ nsScreenQt::nsScreenQt(int aScreen)
 nsScreenQt::~nsScreenQt()
 {
 #ifdef MOZ_ENABLE_QMSYSTEM2
     delete mDisplayState;
     mDisplayState = nsnull;
 #endif
 }
 
+// addref, release, QI
+#ifdef MOZ_ENABLE_QMSYSTEM2
+NS_IMPL_ISUPPORTS2(nsScreenQt, nsIScreen, nsIScreen_MOZILLA_2_0_BRANCH)
+#else
+NS_IMPL_ISUPPORTS1(nsScreenQt, nsIScreen)
+#endif
+
 NS_IMETHODIMP
 nsScreenQt::GetRect(PRInt32 *outLeft,PRInt32 *outTop,
                     PRInt32 *outWidth,PRInt32 *outHeight)
 {
     QRect r = QApplication::desktop()->screenGeometry(mScreen);
 #ifdef MOZ_ENABLE_QTMOBILITY
     r = MozQOrientationSensorFilter::GetRotationTransform().mapRect(r);
     // just rotating gives us weird negative coordinates, but we want to return
--- a/widget/qt/nsScreenQt.h
+++ b/widget/qt/nsScreenQt.h
@@ -36,42 +36,43 @@
  * 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 ***** */
 
 #ifndef nsScreenQt_h___
 #define nsScreenQt_h___
 
-#include "nsBaseScreen.h"
+#include "nsIScreen.h"
 
 #ifdef MOZ_ENABLE_QMSYSTEM2
+#include "WidgetUtils.h"
 namespace MeeGo
 {
     class QmDisplayState;
 }
 #endif
 
 
 //------------------------------------------------------------------------
 
-class nsScreenQt : public nsBaseScreen
+class nsScreenQt : public nsIScreen
+#ifdef MOZ_ENABLE_QMSYSTEM2
+                , public mozilla::widget::BrightnessLockingWidget
+#endif
 {
 public:
   nsScreenQt (int aScreen);
   virtual ~nsScreenQt();
 
-  NS_IMETHOD GetRect(PRInt32* aLeft, PRInt32* aTop, PRInt32* aWidth, PRInt32* aHeight);
-  NS_IMETHOD GetAvailRect(PRInt32* aLeft, PRInt32* aTop, PRInt32* aWidth, PRInt32* aHeight);
-  NS_IMETHOD GetPixelDepth(PRInt32* aPixelDepth);
-  NS_IMETHOD GetColorDepth(PRInt32* aColorDepth);
+  NS_DECL_ISUPPORTS
+  NS_DECL_NSISCREEN
 
 #ifdef MOZ_ENABLE_QMSYSTEM2
-protected:
-  virtual void ApplyMinimumBrightness(PRUint32 aType) MOZ_OVERRIDE;
+  void ApplyMinimumBrightness(PRUint32 aType);
 private:
   MeeGo::QmDisplayState* mDisplayState;
 #endif
 private:
   int mScreen;
 };
 
 #endif  // nsScreenQt_h___
--- a/widget/shared/WidgetUtils.cpp
+++ b/widget/shared/WidgetUtils.cpp
@@ -75,10 +75,59 @@ WidgetUtils::DOMWindowToWidget(nsIDOMWin
         baseWin = do_QueryInterface(window->GetDocShell());
       }
     }
   }
 
   return widget.forget();
 }
 
+// class BrightnessLockingWidget
+
+BrightnessLockingWidget::BrightnessLockingWidget()
+{
+  for (PRUint32 i = 0; i < nsIScreen_MOZILLA_2_0_BRANCH::BRIGHTNESS_LEVELS; i++)
+    mBrightnessLocks[i] = 0;
+}
+
+NS_IMETHODIMP
+BrightnessLockingWidget::LockMinimumBrightness(PRUint32 aBrightness)
+{
+  NS_ABORT_IF_FALSE(
+    aBrightness < nsIScreen_MOZILLA_2_0_BRANCH::BRIGHTNESS_LEVELS,
+    "Invalid brightness level to lock");
+  mBrightnessLocks[aBrightness]++;
+  NS_ABORT_IF_FALSE(mBrightnessLocks[aBrightness] > 0,
+    "Overflow after locking brightness level");
+
+  CheckMinimumBrightness();
+
+  return NS_OK;
+}
+
+NS_IMETHODIMP
+BrightnessLockingWidget::UnlockMinimumBrightness(PRUint32 aBrightness)
+{
+  NS_ABORT_IF_FALSE(
+    aBrightness < nsIScreen_MOZILLA_2_0_BRANCH::BRIGHTNESS_LEVELS,
+    "Invalid brightness level to lock");
+  NS_ABORT_IF_FALSE(mBrightnessLocks[aBrightness] > 0,
+    "Unlocking a brightness level with no corresponding lock");
+  mBrightnessLocks[aBrightness]--;
+
+  CheckMinimumBrightness();
+
+  return NS_OK;
+}
+
+void
+BrightnessLockingWidget::CheckMinimumBrightness()
+{
+  PRUint32 brightness = nsIScreen_MOZILLA_2_0_BRANCH::BRIGHTNESS_LEVELS;
+  for (PRUint32 i = 0; i < nsIScreen_MOZILLA_2_0_BRANCH::BRIGHTNESS_LEVELS; i++)
+    if (mBrightnessLocks[i] > 0)
+      brightness = i;
+
+  ApplyMinimumBrightness(brightness);
+}
+
 } // namespace widget
 } // namespace mozilla
--- a/widget/shared/WidgetUtils.h
+++ b/widget/shared/WidgetUtils.h
@@ -40,27 +40,68 @@
 
 #ifndef __mozilla_widget_WidgetUtils_h__
 #define __mozilla_widget_WidgetUtils_h__
 
 #include "nsCOMPtr.h"
 #include "nsIWidget.h"
 #include "nsPIDOMWindow.h"
 #include "nsIDOMWindow.h"
+#include "nsIScreen.h"
 
 namespace mozilla {
 namespace widget {
 
 class WidgetUtils
 {
 public:
 
   /**
    * Starting at the docshell item for the passed in DOM window this looks up
    * the docshell tree until it finds a docshell item that has a widget.
    */
   static already_AddRefed<nsIWidget> DOMWindowToWidget(nsIDOMWindow *aDOMWindow);
 };
 
+/**
+ * Simple management of screen brightness locks. This abstract base class
+ * allows all widget implementations to share brightness locking code.
+ */
+class BrightnessLockingWidget : public nsIScreen_MOZILLA_2_0_BRANCH
+{
+public:
+  BrightnessLockingWidget();
+
+  NS_IMETHOD LockMinimumBrightness(PRUint32 aBrightness);
+  NS_IMETHOD UnlockMinimumBrightness(PRUint32 aBrightness);
+
+protected:
+  /**
+   * Manually set the current level of brightness locking. This is called after
+   * we determine, based on the current active locks, what the strongest
+   * lock is. You should normally not call this function - it will be
+   * called automatically by this class.
+   *
+   * Each widget implementation should implement this in a way that
+   * makes sense there. This is normally the only function that
+   * contains widget-specific code.
+   *
+   * @param aBrightness The current brightness level to set. If this is
+   *                    nsIScreen_MOZILLA_2_0_BRANCH::BRIGHTNESS_LEVELS
+   *                    (an impossible value for a brightness level to be),
+   *                    then that signifies that there is no current
+   *                    minimum brightness level, and the screen can shut off.
+   */
+  virtual void ApplyMinimumBrightness(PRUint32 aBrightness) = 0;
+
+  /**
+   * Checks what the minimum brightness value is, and calls
+   * ApplyMinimumBrightness.
+   */
+  void CheckMinimumBrightness();
+
+  PRUint32 mBrightnessLocks[nsIScreen_MOZILLA_2_0_BRANCH::BRIGHTNESS_LEVELS];
+};
+
 } // namespace widget
 } // namespace mozilla
 
 #endif
--- a/widget/windows/nsScreenWin.cpp
+++ b/widget/windows/nsScreenWin.cpp
@@ -65,16 +65,20 @@ nsScreenWin :: nsScreenWin ( void* inScr
 
 
 nsScreenWin :: ~nsScreenWin()
 {
   // nothing to see here.
 }
 
 
+// addref, release, QI
+NS_IMPL_ISUPPORTS1(nsScreenWin, nsIScreen)
+
+
 NS_IMETHODIMP
 nsScreenWin :: GetRect(PRInt32 *outLeft, PRInt32 *outTop, PRInt32 *outWidth, PRInt32 *outHeight)
 {
   BOOL success = FALSE;
 #if _MSC_VER >= 1200
   if ( mScreen ) {
     MONITORINFO info;
     info.cbSize = sizeof(MONITORINFO);
--- a/widget/windows/nsScreenWin.h
+++ b/widget/windows/nsScreenWin.h
@@ -34,29 +34,27 @@
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #ifndef nsScreenWin_h___
 #define nsScreenWin_h___
 
 #include <windows.h>
-#include "nsBaseScreen.h"
+#include "nsIScreen.h"
 
 //------------------------------------------------------------------------
 
-class nsScreenWin : public nsBaseScreen
+class nsScreenWin : public nsIScreen
 {
 public:
   nsScreenWin ( void* inScreen );
   ~nsScreenWin();
 
-  NS_IMETHOD GetRect(PRInt32* aLeft, PRInt32* aTop, PRInt32* aWidth, PRInt32* aHeight);
-  NS_IMETHOD GetAvailRect(PRInt32* aLeft, PRInt32* aTop, PRInt32* aWidth, PRInt32* aHeight);
-  NS_IMETHOD GetPixelDepth(PRInt32* aPixelDepth);
-  NS_IMETHOD GetColorDepth(PRInt32* aColorDepth);
+  NS_DECL_ISUPPORTS
+  NS_DECL_NSISCREEN
 
 private:
 
   void* mScreen;                    // a |HMONITOR|, can't use this type in header file though.
 };
 
 #endif  // nsScreenWin_h___ 
--- a/widget/xpwidgets/Makefile.in
+++ b/widget/xpwidgets/Makefile.in
@@ -52,17 +52,16 @@ EXPORTS = \
 
 DEFINES += \
   -D_IMPL_NS_WIDGET \
   -DNO_NSPR_10_SUPPORT=1 \
   $(NULL)
 
 CPPSRCS		= \
 		nsBaseAppShell.cpp \
-		nsBaseScreen.cpp \
 		nsBaseWidget.cpp \
 		nsTransferable.cpp \
 		nsHTMLFormatConverter.cpp \
 		nsBaseDragService.cpp \
 		nsPrimitiveHelpers.cpp \
 		nsXPLookAndFeel.cpp \
 		nsClipboardHelper.cpp \
 		nsPrintOptionsImpl.cpp \
deleted file mode 100644
--- a/widget/xpwidgets/nsBaseScreen.cpp
+++ /dev/null
@@ -1,92 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
- * vim: sw=2 ts=8 et :
- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at:
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is Mozilla Code.
- *
- * The Initial Developer of the Original Code is
- *   The Mozilla Foundation
- * Portions created by the Initial Developer are Copyright (C) 2011
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *   Chris Jones <jones.chris.g@gmail.com>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * 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 "nsBaseScreen.h"
-
-NS_IMPL_ISUPPORTS1(nsBaseScreen, nsIScreen)
-
-nsBaseScreen::nsBaseScreen()
-{
-  for (PRUint32 i = 0; i < nsIScreen::BRIGHTNESS_LEVELS; i++)
-    mBrightnessLocks[i] = 0;
-}
-
-nsBaseScreen::~nsBaseScreen() { }
-
-NS_IMETHODIMP
-nsBaseScreen::LockMinimumBrightness(PRUint32 aBrightness)
-{
-  NS_ABORT_IF_FALSE(
-    aBrightness < nsIScreen::BRIGHTNESS_LEVELS,
-    "Invalid brightness level to lock");
-  mBrightnessLocks[aBrightness]++;
-  NS_ABORT_IF_FALSE(mBrightnessLocks[aBrightness] > 0,
-    "Overflow after locking brightness level");
-
-  CheckMinimumBrightness();
-
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-nsBaseScreen::UnlockMinimumBrightness(PRUint32 aBrightness)
-{
-  NS_ABORT_IF_FALSE(
-    aBrightness < nsIScreen::BRIGHTNESS_LEVELS,
-    "Invalid brightness level to lock");
-  NS_ABORT_IF_FALSE(mBrightnessLocks[aBrightness] > 0,
-    "Unlocking a brightness level with no corresponding lock");
-  mBrightnessLocks[aBrightness]--;
-
-  CheckMinimumBrightness();
-
-  return NS_OK;
-}
-
-void
-nsBaseScreen::CheckMinimumBrightness()
-{
-  PRUint32 brightness = nsIScreen::BRIGHTNESS_LEVELS;
-  for (PRUint32 i = 0; i < nsIScreen::BRIGHTNESS_LEVELS; i++)
-    if (mBrightnessLocks[i] > 0)
-      brightness = i;
-
-  ApplyMinimumBrightness(brightness);
-}
deleted file mode 100644
--- a/widget/xpwidgets/nsBaseScreen.h
+++ /dev/null
@@ -1,95 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
- * vim: sw=2 ts=8 et :
- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at:
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is Mozilla Code.
- *
- * The Initial Developer of the Original Code is
- *   The Mozilla Foundation
- * Portions created by the Initial Developer are Copyright (C) 2011
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *   Chris Jones <jones.chris.g@gmail.com>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * 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 ***** */
-
-#ifndef nsBaseScreen_h
-#define nsBaseScreen_h
-
-#include "mozilla/Attributes.h"
-#include "nsIScreen.h"
-
-class nsBaseScreen : public nsIScreen
-{
-public:
-  nsBaseScreen();
-  virtual ~nsBaseScreen();
-  
-  NS_DECL_ISUPPORTS
-
-  // nsIScreen interface
-
-  /**
-   * Simple management of screen brightness locks. This abstract base class
-   * allows all widget implementations to share brightness locking code.
-   */
-  NS_IMETHOD LockMinimumBrightness(PRUint32 aBrightness);
-  NS_IMETHOD UnlockMinimumBrightness(PRUint32 aBrightness);
-
-protected:
-  /**
-   * Manually set the current level of brightness locking. This is called after
-   * we determine, based on the current active locks, what the strongest
-   * lock is. You should normally not call this function - it will be
-   * called automatically by this class.
-   *
-   * Each widget implementation should implement this in a way that
-   * makes sense there. This is normally the only function that
-   * contains widget-specific code.
-   *
-   * The default implementation does nothing.
-   *
-   * @param aBrightness The current brightness level to set. If this is
-   *                    nsIScreen_MOZILLA_2_0_BRANCH::BRIGHTNESS_LEVELS
-   *                    (an impossible value for a brightness level to be),
-   *                    then that signifies that there is no current
-   *                    minimum brightness level, and the screen can shut off.
-   */
-  virtual void ApplyMinimumBrightness(PRUint32 aBrightness) { }
-
-private:
-  /**
-   * Checks what the minimum brightness value is, and calls
-   * ApplyMinimumBrightness.
-   */
-  void CheckMinimumBrightness();
-
-  PRUint32 mBrightnessLocks[nsIScreen::BRIGHTNESS_LEVELS];
-};
-
-#endif // nsBaseScreen_h