author | Chris Jones <jones.chris.g@gmail.com> |
Wed, 04 Jan 2012 18:12:48 -0800 | |
changeset 83782 | 45e9963f21e914e1dabaec4a7e984c906ac228fc |
parent 83781 | b48ad2fa617881de9c85bdcc5f25e95b29a464fb |
child 83783 | 4d652a824f11cd35ef1a9a93784586b7d906a899 |
push id | 4586 |
push user | cjones@mozilla.com |
push date | Thu, 05 Jan 2012 02:13:07 +0000 |
treeherder | mozilla-inbound@45e9963f21e9 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | roc |
bugs | 672166 |
milestone | 12.0a1 |
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
|
--- a/mobile/xul/chrome/content/common-ui.js +++ b/mobile/xul/chrome/content/common-ui.js @@ -1171,18 +1171,17 @@ 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); - let screen = screenManager.primaryScreen.QueryInterface(Ci.nsIScreen_MOZILLA_2_0_BRANCH); - this.screen = screen; + this.screen = screenManager.primaryScreen; } 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,18 +37,16 @@ * ***** 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 nsIScreen - , public mozilla::widget::BrightnessLockingWidget +class nsScreenAndroid : public nsBaseScreen { public: nsScreenAndroid(void *nativeScreen); ~nsScreenAndroid(); - NS_DECL_ISUPPORTS - NS_DECL_NSISCREEN + 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); protected: - void ApplyMinimumBrightness(PRUint32 aBrightness); + virtual void ApplyMinimumBrightness(PRUint32 aBrightness) MOZ_OVERRIDE; }; class nsScreenManagerAndroid : public nsIScreenManager { public: nsScreenManagerAndroid(); ~nsScreenManagerAndroid();
--- a/widget/cocoa/nsScreenCocoa.h +++ b/widget/cocoa/nsScreenCocoa.h @@ -36,27 +36,28 @@ * * ***** END LICENSE BLOCK ***** */ #ifndef nsScreenCocoa_h_ #define nsScreenCocoa_h_ #import <Cocoa/Cocoa.h> -#include "nsIScreen.h" +#include "nsBaseScreen.h" -class nsScreenCocoa : public nsIScreen +class nsScreenCocoa : public nsBaseScreen { public: nsScreenCocoa (NSScreen *screen); ~nsScreenCocoa (); - NS_DECL_ISUPPORTS - - NS_DECL_NSISCREEN + 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); NSScreen *CocoaScreen() { return mScreen; } private: NSScreen *mScreen; }; #endif // nsScreenCocoa_h_
--- a/widget/cocoa/nsScreenCocoa.mm +++ b/widget/cocoa/nsScreenCocoa.mm @@ -35,18 +35,16 @@ * 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,18 +36,16 @@ * * ***** END LICENSE BLOCK ***** */ #include "nsScreenManagerGonk.h" #include "nsWindow.h" using namespace mozilla; -NS_IMPL_ISUPPORTS2(nsScreenGonk, nsIScreen, nsIScreen) - nsScreenGonk::nsScreenGonk(void *nativeScreen) { } nsScreenGonk::~nsScreenGonk() { } @@ -59,36 +57,33 @@ 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,28 +36,29 @@ * * ***** 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 nsIScreen +class nsScreenGonk : public nsBaseScreen { public: - nsScreenGonk(void *nativeScreen); + nsScreenGonk(void* nativeScreen); ~nsScreenGonk(); - NS_DECL_ISUPPORTS - NS_DECL_NSISCREEN + 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); }; class nsScreenManagerGonk : public nsIScreenManager { public: nsScreenManagerGonk(); ~nsScreenManagerGonk();
--- a/widget/gtk2/nsScreenGtk.cpp +++ b/widget/gtk2/nsScreenGtk.cpp @@ -53,20 +53,16 @@ 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 "nsIScreen.h" +#include "nsBaseScreen.h" #include "nsRect.h" #include "gdk/gdk.h" #ifdef MOZ_X11 #include <X11/Xlib.h> // from Xinerama.h typedef struct { int screen_number; @@ -51,24 +51,26 @@ typedef struct { short y_org; short width; short height; } XineramaScreenInfo; #endif /* MOZ_X11 */ //------------------------------------------------------------------------ -class nsScreenGtk : public nsIScreen +class nsScreenGtk : public nsBaseScreen { public: nsScreenGtk(); ~nsScreenGtk(); - NS_DECL_ISUPPORTS - NS_DECL_NSISCREEN + 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); 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,43 +33,31 @@ * 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(f728830e-1dd1-11b2-9598-fb9f414f2465)] +[scriptable, uuid(498dcd6c-94a2-4c32-8c77-531b583dff37)] 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. */ @@ -77,10 +65,12 @@ interface nsIScreen_MOZILLA_2_0_BRANCH : /** * 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,20 +46,16 @@ 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,30 +33,32 @@ * 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 "nsIScreen.h" +#include "nsBaseScreen.h" #define INCL_WIN #define INCL_DOS #include <os2.h> //------------------------------------------------------------------------ -class nsScreenOS2 : public nsIScreen +class nsScreenOS2 : public nsBaseScreen { public: nsScreenOS2 ( ); virtual ~nsScreenOS2(); - NS_DECL_ISUPPORTS - NS_DECL_NSISCREEN + 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); private: }; #endif // nsScreenOS2_h___
--- a/widget/qt/nsScreenQt.cpp +++ b/widget/qt/nsScreenQt.cpp @@ -74,23 +74,16 @@ 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,43 +36,42 @@ * 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 "nsIScreen.h" +#include "nsBaseScreen.h" #ifdef MOZ_ENABLE_QMSYSTEM2 -#include "WidgetUtils.h" namespace MeeGo { class QmDisplayState; } #endif //------------------------------------------------------------------------ -class nsScreenQt : public nsIScreen -#ifdef MOZ_ENABLE_QMSYSTEM2 - , public mozilla::widget::BrightnessLockingWidget -#endif +class nsScreenQt : public nsBaseScreen { public: nsScreenQt (int aScreen); virtual ~nsScreenQt(); - NS_DECL_ISUPPORTS - NS_DECL_NSISCREEN + 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); #ifdef MOZ_ENABLE_QMSYSTEM2 - void ApplyMinimumBrightness(PRUint32 aType); +protected: + virtual void ApplyMinimumBrightness(PRUint32 aType) MOZ_OVERRIDE; private: MeeGo::QmDisplayState* mDisplayState; #endif private: int mScreen; }; #endif // nsScreenQt_h___
--- a/widget/shared/WidgetUtils.cpp +++ b/widget/shared/WidgetUtils.cpp @@ -75,59 +75,10 @@ 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,68 +40,27 @@ #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,20 +65,16 @@ 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,27 +34,29 @@ * 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 "nsIScreen.h" +#include "nsBaseScreen.h" //------------------------------------------------------------------------ -class nsScreenWin : public nsIScreen +class nsScreenWin : public nsBaseScreen { public: nsScreenWin ( void* inScreen ); ~nsScreenWin(); - NS_DECL_ISUPPORTS - NS_DECL_NSISCREEN + 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); 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,16 +52,17 @@ 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 \
new file mode 100644 --- /dev/null +++ b/widget/xpwidgets/nsBaseScreen.cpp @@ -0,0 +1,92 @@ +/* -*- 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); +}
new file mode 100644 --- /dev/null +++ b/widget/xpwidgets/nsBaseScreen.h @@ -0,0 +1,95 @@ +/* -*- 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