Backed out 64d814cd18b3 for changing interface used by tabbrowser.xml. Thanks Ms2ger!

This commit is contained in:
Chris Jones 2012-01-04 01:18:23 -08:00
commit d5caa53698
21 changed files with 177 additions and 243 deletions

View File

@ -1176,7 +1176,8 @@ var FullScreenVideo = {
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
},

View File

@ -42,6 +42,8 @@
using namespace mozilla;
NS_IMPL_ISUPPORTS2(nsScreenAndroid, nsIScreen, nsIScreen_MOZILLA_2_0_BRANCH)
nsScreenAndroid::nsScreenAndroid(void *nativeScreen)
{
}

View File

@ -41,23 +41,23 @@
#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 :

View File

@ -41,18 +41,17 @@
#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; }

View File

@ -40,6 +40,8 @@
#include "nsObjCExceptions.h"
#include "nsCocoaUtils.h"
NS_IMPL_ISUPPORTS1(nsScreenCocoa, nsIScreen)
nsScreenCocoa::nsScreenCocoa (NSScreen *screen)
{
NS_OBJC_BEGIN_TRY_ABORT_BLOCK;

View File

@ -41,6 +41,8 @@
using namespace mozilla;
NS_IMPL_ISUPPORTS2(nsScreenGonk, nsIScreen, nsIScreen)
nsScreenGonk::nsScreenGonk(void *nativeScreen)
{
}
@ -62,14 +64,16 @@ 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)
{
@ -79,6 +83,7 @@ nsScreenGonk::GetPixelDepth(PRInt32 *aPixelDepth)
return NS_OK;
}
NS_IMETHODIMP
nsScreenGonk::GetColorDepth(PRInt32 *aColorDepth)
{

View File

@ -41,19 +41,18 @@
#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

View File

@ -58,6 +58,10 @@ nsScreenGtk :: ~nsScreenGtk()
}
// addref, release, QI
NS_IMPL_ISUPPORTS1(nsScreenGtk, nsIScreen)
NS_IMETHODIMP
nsScreenGtk :: GetRect(PRInt32 *outLeft, PRInt32 *outTop, PRInt32 *outWidth, PRInt32 *outHeight)
{

View File

@ -38,7 +38,7 @@
#ifndef nsScreenGtk_h___
#define nsScreenGtk_h___
#include "nsBaseScreen.h"
#include "nsIScreen.h"
#include "nsRect.h"
#include "gdk/gdk.h"
#ifdef MOZ_X11
@ -56,16 +56,14 @@ typedef struct {
//------------------------------------------------------------------------
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

View File

@ -38,9 +38,24 @@
#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.
*/
@ -50,9 +65,6 @@ interface nsIScreen : 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
@ -70,7 +82,5 @@ interface nsIScreen : 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;
};

View File

@ -51,6 +51,10 @@ nsScreenOS2 :: ~nsScreenOS2()
}
// addref, release, QI
NS_IMPL_ISUPPORTS1(nsScreenOS2, nsIScreen)
NS_IMETHODIMP
nsScreenOS2 :: GetRect(PRInt32 *outLeft, PRInt32 *outTop, PRInt32 *outWidth, PRInt32 *outHeight)
{

View File

@ -38,7 +38,7 @@
#ifndef nsScreenOS2_h___
#define nsScreenOS2_h___
#include "nsBaseScreen.h"
#include "nsIScreen.h"
#define INCL_WIN
#define INCL_DOS
@ -46,16 +46,14 @@
//------------------------------------------------------------------------
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:

View File

@ -79,6 +79,13 @@ 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)

View File

@ -41,9 +41,10 @@
#ifndef nsScreenQt_h___
#define nsScreenQt_h___
#include "nsBaseScreen.h"
#include "nsIScreen.h"
#ifdef MOZ_ENABLE_QMSYSTEM2
#include "WidgetUtils.h"
namespace MeeGo
{
class QmDisplayState;
@ -53,20 +54,20 @@ namespace MeeGo
//------------------------------------------------------------------------
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

View File

@ -80,5 +80,54 @@ 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

View File

@ -45,6 +45,7 @@
#include "nsIWidget.h"
#include "nsPIDOMWindow.h"
#include "nsIDOMWindow.h"
#include "nsIScreen.h"
namespace mozilla {
namespace widget {
@ -60,6 +61,46 @@ public:
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

View File

@ -70,6 +70,10 @@ nsScreenWin :: ~nsScreenWin()
}
// addref, release, QI
NS_IMPL_ISUPPORTS1(nsScreenWin, nsIScreen)
NS_IMETHODIMP
nsScreenWin :: GetRect(PRInt32 *outLeft, PRInt32 *outTop, PRInt32 *outWidth, PRInt32 *outHeight)
{

View File

@ -39,20 +39,18 @@
#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:

View File

@ -57,7 +57,6 @@ DEFINES += \
CPPSRCS = \
nsBaseAppShell.cpp \
nsBaseScreen.cpp \
nsBaseWidget.cpp \
nsTransferable.cpp \
nsHTMLFormatConverter.cpp \

View File

@ -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);
}

View File

@ -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