Skip to content
This repository has been archived by the owner on Aug 4, 2022. It is now read-only.

Commit

Permalink
Bug 714416: Get rid of nsIScreen_MOZILLA_2_0_BRANCH and create nsBase…
Browse files Browse the repository at this point in the history
…Screen for shared code. sr=roc
  • Loading branch information
joneschrisg committed Jan 4, 2012
1 parent d56c4f9 commit 9ae72f3
Show file tree
Hide file tree
Showing 21 changed files with 243 additions and 177 deletions.
3 changes: 1 addition & 2 deletions mobile/xul/chrome/content/common-ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -1176,8 +1176,7 @@ var FullScreenVideo = {
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
},
Expand Down
2 changes: 0 additions & 2 deletions widget/android/nsScreenManagerAndroid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@

using namespace mozilla;

NS_IMPL_ISUPPORTS2(nsScreenAndroid, nsIScreen, nsIScreen_MOZILLA_2_0_BRANCH)

nsScreenAndroid::nsScreenAndroid(void *nativeScreen)
{
}
Expand Down
14 changes: 7 additions & 7 deletions widget/android/nsScreenManagerAndroid.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,23 +41,23 @@

#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 :
Expand Down
11 changes: 6 additions & 5 deletions widget/cocoa/nsScreenCocoa.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,18 @@

#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; }

Expand Down
2 changes: 0 additions & 2 deletions widget/cocoa/nsScreenCocoa.mm
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@
#include "nsObjCExceptions.h"
#include "nsCocoaUtils.h"

NS_IMPL_ISUPPORTS1(nsScreenCocoa, nsIScreen)

nsScreenCocoa::nsScreenCocoa (NSScreen *screen)
{
NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
Expand Down
7 changes: 1 addition & 6 deletions widget/gonk/nsScreenManagerGonk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@

using namespace mozilla;

NS_IMPL_ISUPPORTS2(nsScreenGonk, nsIScreen, nsIScreen)

nsScreenGonk::nsScreenGonk(void *nativeScreen)
{
}
Expand All @@ -64,16 +62,14 @@ nsScreenGonk::GetRect(PRInt32 *outLeft, PRInt32 *outTop,
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)
{
Expand All @@ -83,7 +79,6 @@ nsScreenGonk::GetPixelDepth(PRInt32 *aPixelDepth)
return NS_OK;
}


NS_IMETHODIMP
nsScreenGonk::GetColorDepth(PRInt32 *aColorDepth)
{
Expand Down
13 changes: 7 additions & 6 deletions widget/gonk/nsScreenManagerGonk.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,19 @@

#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
Expand Down
4 changes: 0 additions & 4 deletions widget/gtk2/nsScreenGtk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,6 @@ nsScreenGtk :: ~nsScreenGtk()
}


// addref, release, QI
NS_IMPL_ISUPPORTS1(nsScreenGtk, nsIScreen)


NS_IMETHODIMP
nsScreenGtk :: GetRect(PRInt32 *outLeft, PRInt32 *outTop, PRInt32 *outWidth, PRInt32 *outHeight)
{
Expand Down
10 changes: 6 additions & 4 deletions widget/gtk2/nsScreenGtk.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
#ifndef nsScreenGtk_h___
#define nsScreenGtk_h___

#include "nsIScreen.h"
#include "nsBaseScreen.h"
#include "nsRect.h"
#include "gdk/gdk.h"
#ifdef MOZ_X11
Expand All @@ -56,14 +56,16 @@ typedef struct {

//------------------------------------------------------------------------

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
Expand Down
24 changes: 7 additions & 17 deletions widget/nsIScreen.idl
Original file line number Diff line number Diff line change
Expand Up @@ -38,24 +38,9 @@

#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.
*/
Expand All @@ -65,6 +50,9 @@ interface nsIScreen_MOZILLA_2_0_BRANCH : nsISupports {
/* 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
Expand All @@ -82,5 +70,7 @@ interface nsIScreen_MOZILLA_2_0_BRANCH : nsISupports {
* @param brightness A brightness level, one of the above constants.
*/
void unlockMinimumBrightness(in unsigned long brightness);

readonly attribute long pixelDepth;
readonly attribute long colorDepth;
};

4 changes: 0 additions & 4 deletions widget/os2/nsScreenOS2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,6 @@ nsScreenOS2 :: ~nsScreenOS2()
}


// addref, release, QI
NS_IMPL_ISUPPORTS1(nsScreenOS2, nsIScreen)


NS_IMETHODIMP
nsScreenOS2 :: GetRect(PRInt32 *outLeft, PRInt32 *outTop, PRInt32 *outWidth, PRInt32 *outHeight)
{
Expand Down
10 changes: 6 additions & 4 deletions widget/os2/nsScreenOS2.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,22 +38,24 @@
#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:

Expand Down
7 changes: 0 additions & 7 deletions widget/qt/nsScreenQt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,6 @@ nsScreenQt::~nsScreenQt()
#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)
Expand Down
17 changes: 8 additions & 9 deletions widget/qt/nsScreenQt.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,9 @@
#ifndef nsScreenQt_h___
#define nsScreenQt_h___

#include "nsIScreen.h"
#include "nsBaseScreen.h"

#ifdef MOZ_ENABLE_QMSYSTEM2
#include "WidgetUtils.h"
namespace MeeGo
{
class QmDisplayState;
Expand All @@ -54,20 +53,20 @@ namespace MeeGo

//------------------------------------------------------------------------

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
Expand Down
49 changes: 0 additions & 49 deletions widget/shared/WidgetUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,54 +80,5 @@ WidgetUtils::DOMWindowToWidget(nsIDOMWindow *aDOMWindow)
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
Loading

0 comments on commit 9ae72f3

Please sign in to comment.