2001-09-26 02:43:09 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
1999-01-29 01:24:29 +03:00
|
|
|
|
2011-12-04 21:07:00 +04:00
|
|
|
#include "mozilla/Hal.h"
|
2014-03-05 04:37:43 +04:00
|
|
|
#include "mozilla/dom/Event.h" // for nsIDOMEvent::InternalDOMEvent()
|
|
|
|
#include "mozilla/dom/ScreenBinding.h"
|
1999-01-29 01:24:29 +03:00
|
|
|
#include "nsScreen.h"
|
2013-10-02 01:00:38 +04:00
|
|
|
#include "nsIDocument.h"
|
2000-02-08 16:40:10 +03:00
|
|
|
#include "nsIDocShell.h"
|
2013-10-01 01:26:04 +04:00
|
|
|
#include "nsIDocument.h"
|
2006-04-08 05:46:06 +04:00
|
|
|
#include "nsPresContext.h"
|
1999-06-12 01:19:24 +04:00
|
|
|
#include "nsCOMPtr.h"
|
2011-12-04 21:07:00 +04:00
|
|
|
#include "nsIDocShellTreeItem.h"
|
2008-07-26 20:14:49 +04:00
|
|
|
#include "nsLayoutUtils.h"
|
2012-09-11 14:55:08 +04:00
|
|
|
#include "nsJSUtils.h"
|
2013-09-23 15:55:35 +04:00
|
|
|
#include "nsDeviceContext.h"
|
2011-12-04 21:07:00 +04:00
|
|
|
|
|
|
|
using namespace mozilla;
|
2012-03-14 14:10:48 +04:00
|
|
|
using namespace mozilla::dom;
|
2011-12-04 21:07:00 +04:00
|
|
|
|
2012-03-14 14:10:48 +04:00
|
|
|
/* static */ already_AddRefed<nsScreen>
|
|
|
|
nsScreen::Create(nsPIDOMWindow* aWindow)
|
1999-01-29 01:24:29 +03:00
|
|
|
{
|
2012-03-29 20:31:29 +04:00
|
|
|
MOZ_ASSERT(aWindow);
|
|
|
|
|
2012-03-14 14:10:48 +04:00
|
|
|
if (!aWindow->GetDocShell()) {
|
2012-07-30 18:20:58 +04:00
|
|
|
return nullptr;
|
2012-03-14 14:10:48 +04:00
|
|
|
}
|
|
|
|
|
2012-03-29 20:31:29 +04:00
|
|
|
nsCOMPtr<nsIScriptGlobalObject> sgo =
|
|
|
|
do_QueryInterface(static_cast<nsPIDOMWindow*>(aWindow));
|
2012-07-30 18:20:58 +04:00
|
|
|
NS_ENSURE_TRUE(sgo, nullptr);
|
2012-03-14 14:10:48 +04:00
|
|
|
|
2014-01-07 06:53:23 +04:00
|
|
|
nsRefPtr<nsScreen> screen = new nsScreen(aWindow);
|
2012-03-14 14:10:48 +04:00
|
|
|
|
2012-05-09 01:36:07 +04:00
|
|
|
hal::RegisterScreenConfigurationObserver(screen);
|
|
|
|
hal::ScreenConfiguration config;
|
|
|
|
hal::GetCurrentScreenConfiguration(&config);
|
|
|
|
screen->mOrientation = config.orientation();
|
2012-03-14 14:10:48 +04:00
|
|
|
|
|
|
|
return screen.forget();
|
|
|
|
}
|
|
|
|
|
2014-01-07 06:53:23 +04:00
|
|
|
nsScreen::nsScreen(nsPIDOMWindow* aWindow)
|
2014-04-01 10:13:50 +04:00
|
|
|
: DOMEventTargetHelper(aWindow)
|
2014-01-07 06:53:23 +04:00
|
|
|
, mEventListener(nullptr)
|
2012-03-14 14:10:48 +04:00
|
|
|
{
|
2012-02-09 14:29:09 +04:00
|
|
|
}
|
1999-01-29 01:24:29 +03:00
|
|
|
|
2012-02-09 19:55:54 +04:00
|
|
|
nsScreen::~nsScreen()
|
|
|
|
{
|
2013-05-13 15:00:42 +04:00
|
|
|
MOZ_ASSERT(!mEventListener);
|
2012-05-09 01:36:07 +04:00
|
|
|
hal::UnregisterScreenConfigurationObserver(this);
|
2012-02-09 19:55:54 +04:00
|
|
|
}
|
2012-02-09 14:29:09 +04:00
|
|
|
|
2012-02-09 19:55:54 +04:00
|
|
|
|
2004-12-10 22:48:22 +03:00
|
|
|
// QueryInterface implementation for nsScreen
|
2013-02-07 14:19:08 +04:00
|
|
|
NS_INTERFACE_MAP_BEGIN(nsScreen)
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 21:42:36 +04:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIDOMScreen)
|
2014-04-01 10:13:50 +04:00
|
|
|
NS_INTERFACE_MAP_END_INHERITING(DOMEventTargetHelper)
|
2012-03-14 22:14:53 +04:00
|
|
|
|
2014-04-01 10:13:50 +04:00
|
|
|
NS_IMPL_ADDREF_INHERITED(nsScreen, DOMEventTargetHelper)
|
|
|
|
NS_IMPL_RELEASE_INHERITED(nsScreen, DOMEventTargetHelper)
|
2012-03-14 22:14:53 +04:00
|
|
|
|
2012-10-14 11:40:11 +04:00
|
|
|
int32_t
|
|
|
|
nsScreen::GetPixelDepth(ErrorResult& aRv)
|
1999-01-29 01:24:29 +03:00
|
|
|
{
|
2011-04-17 05:22:44 +04:00
|
|
|
nsDeviceContext* context = GetDeviceContext();
|
2002-05-29 02:55:39 +04:00
|
|
|
|
2003-09-20 01:06:52 +04:00
|
|
|
if (!context) {
|
2012-10-14 11:40:11 +04:00
|
|
|
aRv.Throw(NS_ERROR_FAILURE);
|
|
|
|
return -1;
|
2002-05-29 02:55:39 +04:00
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t depth;
|
2003-09-20 01:06:52 +04:00
|
|
|
context->GetDepth(depth);
|
2012-10-14 11:40:11 +04:00
|
|
|
return depth;
|
1999-01-29 01:24:29 +03:00
|
|
|
}
|
|
|
|
|
2012-10-14 11:40:11 +04:00
|
|
|
#define FORWARD_LONG_GETTER(_name) \
|
|
|
|
NS_IMETHODIMP \
|
|
|
|
nsScreen::Get ## _name(int32_t* aOut) \
|
|
|
|
{ \
|
|
|
|
ErrorResult rv; \
|
|
|
|
*aOut = Get ## _name(rv); \
|
|
|
|
return rv.ErrorCode(); \
|
|
|
|
}
|
1999-01-29 01:24:29 +03:00
|
|
|
|
2012-10-14 11:40:11 +04:00
|
|
|
FORWARD_LONG_GETTER(AvailWidth)
|
|
|
|
FORWARD_LONG_GETTER(AvailHeight)
|
|
|
|
FORWARD_LONG_GETTER(Width)
|
|
|
|
FORWARD_LONG_GETTER(Height)
|
2002-05-29 02:55:39 +04:00
|
|
|
|
2012-10-14 11:40:11 +04:00
|
|
|
FORWARD_LONG_GETTER(Top)
|
|
|
|
FORWARD_LONG_GETTER(Left)
|
|
|
|
FORWARD_LONG_GETTER(AvailTop)
|
|
|
|
FORWARD_LONG_GETTER(AvailLeft)
|
2002-05-29 02:55:39 +04:00
|
|
|
|
2012-10-14 11:40:11 +04:00
|
|
|
FORWARD_LONG_GETTER(PixelDepth)
|
|
|
|
FORWARD_LONG_GETTER(ColorDepth)
|
1999-01-29 01:24:29 +03:00
|
|
|
|
2011-04-17 05:22:44 +04:00
|
|
|
nsDeviceContext*
|
2004-12-10 22:48:22 +03:00
|
|
|
nsScreen::GetDeviceContext()
|
1999-06-12 01:19:24 +04:00
|
|
|
{
|
2012-03-14 22:14:53 +04:00
|
|
|
return nsLayoutUtils::GetDeviceContextForScreenInfo(GetOwner());
|
1999-06-12 01:19:24 +04:00
|
|
|
}
|
|
|
|
|
2003-09-20 01:06:52 +04:00
|
|
|
nsresult
|
2004-12-10 22:48:22 +03:00
|
|
|
nsScreen::GetRect(nsRect& aRect)
|
2003-09-20 01:06:52 +04:00
|
|
|
{
|
2011-04-17 05:22:44 +04:00
|
|
|
nsDeviceContext *context = GetDeviceContext();
|
2003-09-20 01:06:52 +04:00
|
|
|
|
|
|
|
if (!context) {
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
context->GetRect(aRect);
|
|
|
|
|
2007-02-07 10:46:44 +03:00
|
|
|
aRect.x = nsPresContext::AppUnitsToIntCSSPixels(aRect.x);
|
|
|
|
aRect.y = nsPresContext::AppUnitsToIntCSSPixels(aRect.y);
|
|
|
|
aRect.height = nsPresContext::AppUnitsToIntCSSPixels(aRect.height);
|
|
|
|
aRect.width = nsPresContext::AppUnitsToIntCSSPixels(aRect.width);
|
2003-09-20 01:06:52 +04:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
2004-12-10 22:48:22 +03:00
|
|
|
nsScreen::GetAvailRect(nsRect& aRect)
|
2003-09-20 01:06:52 +04:00
|
|
|
{
|
2011-04-17 05:22:44 +04:00
|
|
|
nsDeviceContext *context = GetDeviceContext();
|
2003-09-20 01:06:52 +04:00
|
|
|
|
|
|
|
if (!context) {
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
1999-01-29 01:24:29 +03:00
|
|
|
|
2003-09-20 15:41:22 +04:00
|
|
|
context->GetClientRect(aRect);
|
2003-09-20 01:06:52 +04:00
|
|
|
|
2007-02-07 10:46:44 +03:00
|
|
|
aRect.x = nsPresContext::AppUnitsToIntCSSPixels(aRect.x);
|
|
|
|
aRect.y = nsPresContext::AppUnitsToIntCSSPixels(aRect.y);
|
|
|
|
aRect.height = nsPresContext::AppUnitsToIntCSSPixels(aRect.height);
|
|
|
|
aRect.width = nsPresContext::AppUnitsToIntCSSPixels(aRect.width);
|
2003-09-20 01:06:52 +04:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2011-12-04 21:07:00 +04:00
|
|
|
|
2012-03-14 14:10:48 +04:00
|
|
|
void
|
2012-05-09 01:36:07 +04:00
|
|
|
nsScreen::Notify(const hal::ScreenConfiguration& aConfiguration)
|
2012-03-14 14:10:48 +04:00
|
|
|
{
|
|
|
|
ScreenOrientation previousOrientation = mOrientation;
|
2012-05-09 01:36:07 +04:00
|
|
|
mOrientation = aConfiguration.orientation();
|
2012-03-14 14:10:48 +04:00
|
|
|
|
2012-09-19 20:28:16 +04:00
|
|
|
NS_ASSERTION(mOrientation == eScreenOrientation_PortraitPrimary ||
|
|
|
|
mOrientation == eScreenOrientation_PortraitSecondary ||
|
|
|
|
mOrientation == eScreenOrientation_LandscapePrimary ||
|
|
|
|
mOrientation == eScreenOrientation_LandscapeSecondary,
|
2012-03-14 14:10:48 +04:00
|
|
|
"Invalid orientation value passed to notify method!");
|
|
|
|
|
|
|
|
if (mOrientation != previousOrientation) {
|
2012-09-28 00:11:31 +04:00
|
|
|
DispatchTrustedEvent(NS_LITERAL_STRING("mozorientationchange"));
|
2012-03-14 14:10:48 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-10-14 11:40:11 +04:00
|
|
|
void
|
|
|
|
nsScreen::GetMozOrientation(nsString& aOrientation)
|
2012-03-14 14:10:48 +04:00
|
|
|
{
|
|
|
|
switch (mOrientation) {
|
2012-10-14 11:40:11 +04:00
|
|
|
case eScreenOrientation_PortraitPrimary:
|
|
|
|
aOrientation.AssignLiteral("portrait-primary");
|
|
|
|
break;
|
|
|
|
case eScreenOrientation_PortraitSecondary:
|
|
|
|
aOrientation.AssignLiteral("portrait-secondary");
|
|
|
|
break;
|
|
|
|
case eScreenOrientation_LandscapePrimary:
|
|
|
|
aOrientation.AssignLiteral("landscape-primary");
|
|
|
|
break;
|
|
|
|
case eScreenOrientation_LandscapeSecondary:
|
|
|
|
aOrientation.AssignLiteral("landscape-secondary");
|
|
|
|
break;
|
|
|
|
case eScreenOrientation_None:
|
|
|
|
default:
|
2013-06-29 05:38:30 +04:00
|
|
|
MOZ_CRASH("Unacceptable mOrientation value");
|
2012-03-14 14:10:48 +04:00
|
|
|
}
|
2012-10-14 11:40:11 +04:00
|
|
|
}
|
2012-03-14 14:10:48 +04:00
|
|
|
|
2012-10-14 11:40:11 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsScreen::GetSlowMozOrientation(nsAString& aOrientation)
|
|
|
|
{
|
|
|
|
nsString orientation;
|
|
|
|
GetMozOrientation(orientation);
|
|
|
|
aOrientation = orientation;
|
2012-03-14 14:10:48 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
2012-03-29 23:43:16 +04:00
|
|
|
|
2012-09-11 17:15:43 +04:00
|
|
|
nsScreen::LockPermission
|
|
|
|
nsScreen::GetLockOrientationPermission() const
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsPIDOMWindow> owner = GetOwner();
|
|
|
|
if (!owner) {
|
|
|
|
return LOCK_DENIED;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Chrome can always lock the screen orientation.
|
2014-01-20 11:58:26 +04:00
|
|
|
nsIDocShell* docShell = owner->GetDocShell();
|
|
|
|
if (docShell && docShell->ItemType() == nsIDocShellTreeItem::typeChrome) {
|
2012-09-11 17:15:43 +04:00
|
|
|
return LOCK_ALLOWED;
|
|
|
|
}
|
|
|
|
|
2013-06-12 10:48:15 +04:00
|
|
|
nsCOMPtr<nsIDocument> doc = owner->GetDoc();
|
2013-05-09 15:33:55 +04:00
|
|
|
if (!doc || doc->Hidden()) {
|
2012-09-11 17:15:43 +04:00
|
|
|
return LOCK_DENIED;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Apps can always lock the screen orientation.
|
|
|
|
if (doc->NodePrincipal()->GetAppStatus() >=
|
|
|
|
nsIPrincipal::APP_STATUS_INSTALLED) {
|
|
|
|
return LOCK_ALLOWED;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Other content must be full-screen in order to lock orientation.
|
2013-06-12 10:48:15 +04:00
|
|
|
return doc->MozFullScreen() ? FULLSCREEN_LOCK_ALLOWED : LOCK_DENIED;
|
2012-09-11 17:15:43 +04:00
|
|
|
}
|
|
|
|
|
2012-10-14 11:39:34 +04:00
|
|
|
bool
|
|
|
|
nsScreen::MozLockOrientation(const nsAString& aOrientation, ErrorResult& aRv)
|
|
|
|
{
|
|
|
|
nsString orientation(aOrientation);
|
|
|
|
Sequence<nsString> orientations;
|
|
|
|
if (!orientations.AppendElement(orientation)) {
|
|
|
|
aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return MozLockOrientation(orientations, aRv);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
nsScreen::MozLockOrientation(const Sequence<nsString>& aOrientations,
|
|
|
|
ErrorResult& aRv)
|
|
|
|
{
|
2012-09-11 14:55:08 +04:00
|
|
|
ScreenOrientation orientation = eScreenOrientation_None;
|
|
|
|
|
2012-10-14 11:39:34 +04:00
|
|
|
for (uint32_t i = 0; i < aOrientations.Length(); ++i) {
|
|
|
|
const nsString& item = aOrientations[i];
|
2012-09-11 14:55:08 +04:00
|
|
|
|
|
|
|
if (item.EqualsLiteral("portrait")) {
|
2012-09-19 20:28:16 +04:00
|
|
|
orientation |= eScreenOrientation_PortraitPrimary |
|
|
|
|
eScreenOrientation_PortraitSecondary;
|
2012-09-11 14:55:08 +04:00
|
|
|
} else if (item.EqualsLiteral("portrait-primary")) {
|
|
|
|
orientation |= eScreenOrientation_PortraitPrimary;
|
|
|
|
} else if (item.EqualsLiteral("portrait-secondary")) {
|
|
|
|
orientation |= eScreenOrientation_PortraitSecondary;
|
|
|
|
} else if (item.EqualsLiteral("landscape")) {
|
2012-09-19 20:28:16 +04:00
|
|
|
orientation |= eScreenOrientation_LandscapePrimary |
|
|
|
|
eScreenOrientation_LandscapeSecondary;
|
2012-09-11 14:55:08 +04:00
|
|
|
} else if (item.EqualsLiteral("landscape-primary")) {
|
|
|
|
orientation |= eScreenOrientation_LandscapePrimary;
|
|
|
|
} else if (item.EqualsLiteral("landscape-secondary")) {
|
|
|
|
orientation |= eScreenOrientation_LandscapeSecondary;
|
2013-09-30 18:40:41 +04:00
|
|
|
} else if (item.EqualsLiteral("default")) {
|
|
|
|
orientation |= eScreenOrientation_Default;
|
2012-09-11 14:55:08 +04:00
|
|
|
} else {
|
2012-10-14 11:39:34 +04:00
|
|
|
// If we don't recognize the token, we should just return 'false'
|
2012-09-11 14:55:08 +04:00
|
|
|
// without throwing.
|
2012-10-14 11:39:34 +04:00
|
|
|
return false;
|
2012-09-11 14:55:08 +04:00
|
|
|
}
|
2012-03-29 23:43:16 +04:00
|
|
|
}
|
|
|
|
|
2012-09-11 17:15:43 +04:00
|
|
|
switch (GetLockOrientationPermission()) {
|
|
|
|
case LOCK_DENIED:
|
2012-10-14 11:39:34 +04:00
|
|
|
return false;
|
2012-09-11 17:15:43 +04:00
|
|
|
case LOCK_ALLOWED:
|
2012-10-14 11:39:34 +04:00
|
|
|
return hal::LockScreenOrientation(orientation);
|
|
|
|
case FULLSCREEN_LOCK_ALLOWED: {
|
2012-12-07 21:33:39 +04:00
|
|
|
// We need to register a listener so we learn when we leave full-screen
|
|
|
|
// and when we will have to unlock the screen.
|
|
|
|
// This needs to be done before LockScreenOrientation call to make sure
|
|
|
|
// the locking can be unlocked.
|
2013-05-13 15:00:42 +04:00
|
|
|
nsCOMPtr<EventTarget> target = do_QueryInterface(GetOwner()->GetDoc());
|
2012-12-07 21:33:39 +04:00
|
|
|
if (!target) {
|
2012-10-14 11:39:34 +04:00
|
|
|
return false;
|
2012-09-11 17:15:43 +04:00
|
|
|
}
|
2012-03-29 20:31:11 +04:00
|
|
|
|
2012-12-07 21:33:39 +04:00
|
|
|
if (!hal::LockScreenOrientation(orientation)) {
|
|
|
|
return false;
|
2012-09-11 17:15:43 +04:00
|
|
|
}
|
2012-03-29 20:31:11 +04:00
|
|
|
|
2012-12-07 21:33:39 +04:00
|
|
|
// We are fullscreen and lock has been accepted.
|
2012-09-11 17:15:43 +04:00
|
|
|
if (!mEventListener) {
|
|
|
|
mEventListener = new FullScreenEventListener();
|
|
|
|
}
|
2012-08-13 20:58:38 +04:00
|
|
|
|
2012-10-14 11:39:34 +04:00
|
|
|
aRv = target->AddSystemEventListener(NS_LITERAL_STRING("mozfullscreenchange"),
|
|
|
|
mEventListener, /* useCapture = */ true);
|
|
|
|
return true;
|
|
|
|
}
|
2012-03-29 20:31:29 +04:00
|
|
|
}
|
|
|
|
|
2012-09-11 17:15:43 +04:00
|
|
|
// This is only for compilers that don't understand that the previous switch
|
|
|
|
// will always return.
|
2013-06-29 05:38:30 +04:00
|
|
|
MOZ_CRASH("unexpected lock orientation permission value");
|
2012-03-29 23:43:16 +04:00
|
|
|
}
|
|
|
|
|
2012-10-14 11:40:11 +04:00
|
|
|
void
|
2012-03-29 23:43:16 +04:00
|
|
|
nsScreen::MozUnlockOrientation()
|
|
|
|
{
|
|
|
|
hal::UnlockScreenOrientation();
|
2012-10-14 11:40:11 +04:00
|
|
|
}
|
|
|
|
|
2013-11-07 17:40:23 +04:00
|
|
|
bool
|
|
|
|
nsScreen::IsDeviceSizePageSize()
|
|
|
|
{
|
|
|
|
nsPIDOMWindow* owner = GetOwner();
|
|
|
|
if (owner) {
|
|
|
|
nsIDocShell* docShell = owner->GetDocShell();
|
|
|
|
if (docShell) {
|
|
|
|
return docShell->GetDeviceSizeIsPageSize();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2012-10-14 11:40:11 +04:00
|
|
|
/* virtual */
|
|
|
|
JSObject*
|
2014-04-09 02:27:18 +04:00
|
|
|
nsScreen::WrapObject(JSContext* aCx)
|
2012-10-14 11:40:11 +04:00
|
|
|
{
|
Bug 991742 part 6. Remove the "aScope" argument of binding Wrap() methods. r=bholley
This patch was mostly generated with this command:
find . -name "*.h" -o -name "*.cpp" | xargs sed -e 's/Binding::Wrap(aCx, aScope, this/Binding::Wrap(aCx, this/' -e 's/Binding_workers::Wrap(aCx, aScope, this/Binding_workers::Wrap(aCx, this/' -e 's/Binding::Wrap(cx, scope, this/Binding::Wrap(cx, this/' -i ""
plus a few manual fixes to dom/bindings/Codegen.py, js/xpconnect/src/event_impl_gen.py, and a few C++ files that were not caught in the search-and-replace above.
2014-04-09 02:27:17 +04:00
|
|
|
return ScreenBinding::Wrap(aCx, this);
|
2012-10-14 11:40:11 +04:00
|
|
|
}
|
|
|
|
|
2014-04-27 11:06:00 +04:00
|
|
|
NS_IMPL_ISUPPORTS(nsScreen::FullScreenEventListener, nsIDOMEventListener)
|
2012-03-29 20:31:11 +04:00
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsScreen::FullScreenEventListener::HandleEvent(nsIDOMEvent* aEvent)
|
|
|
|
{
|
|
|
|
#ifdef DEBUG
|
|
|
|
nsAutoString eventType;
|
|
|
|
aEvent->GetType(eventType);
|
|
|
|
|
|
|
|
MOZ_ASSERT(eventType.EqualsLiteral("mozfullscreenchange"));
|
|
|
|
#endif
|
|
|
|
|
2013-04-20 02:18:32 +04:00
|
|
|
nsCOMPtr<EventTarget> target = aEvent->InternalDOMEvent()->GetCurrentTarget();
|
2013-06-12 10:48:15 +04:00
|
|
|
MOZ_ASSERT(target);
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDocument> doc = do_QueryInterface(target);
|
|
|
|
MOZ_ASSERT(doc);
|
2012-03-29 20:31:11 +04:00
|
|
|
|
2012-04-23 12:30:58 +04:00
|
|
|
// We have to make sure that the event we got is the event sent when
|
|
|
|
// fullscreen is disabled because we could get one when fullscreen
|
|
|
|
// got enabled if the lock call is done at the same moment.
|
2013-06-12 10:48:15 +04:00
|
|
|
if (doc->MozFullScreen()) {
|
2013-05-13 15:00:42 +04:00
|
|
|
return NS_OK;
|
2012-04-23 12:30:58 +04:00
|
|
|
}
|
|
|
|
|
2012-03-29 20:31:11 +04:00
|
|
|
target->RemoveSystemEventListener(NS_LITERAL_STRING("mozfullscreenchange"),
|
|
|
|
this, true);
|
|
|
|
|
|
|
|
hal::UnlockScreenOrientation();
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|