2015-05-03 19:32:37 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2012-05-21 11:12:37 +00: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-28 22:24:29 +00:00
|
|
|
|
2014-03-05 00:37:43 +00:00
|
|
|
#include "mozilla/dom/Event.h" // for nsIDOMEvent::InternalDOMEvent()
|
|
|
|
#include "mozilla/dom/ScreenBinding.h"
|
1999-01-28 22:24:29 +00:00
|
|
|
#include "nsScreen.h"
|
2013-10-01 21:00:38 +00:00
|
|
|
#include "nsIDocument.h"
|
2000-02-08 13:40:10 +00:00
|
|
|
#include "nsIDocShell.h"
|
2013-09-30 21:26:04 +00:00
|
|
|
#include "nsIDocument.h"
|
2006-04-08 01:46:06 +00:00
|
|
|
#include "nsPresContext.h"
|
1999-06-11 21:19:24 +00:00
|
|
|
#include "nsCOMPtr.h"
|
2011-12-04 17:07:00 +00:00
|
|
|
#include "nsIDocShellTreeItem.h"
|
2008-07-26 16:14:49 +00:00
|
|
|
#include "nsLayoutUtils.h"
|
2012-09-11 10:55:08 +00:00
|
|
|
#include "nsJSUtils.h"
|
2013-09-23 11:55:35 +00:00
|
|
|
#include "nsDeviceContext.h"
|
2011-12-04 17:07:00 +00:00
|
|
|
|
|
|
|
using namespace mozilla;
|
2012-03-14 10:10:48 +00:00
|
|
|
using namespace mozilla::dom;
|
2011-12-04 17:07:00 +00:00
|
|
|
|
2012-03-14 10:10:48 +00:00
|
|
|
/* static */ already_AddRefed<nsScreen>
|
|
|
|
nsScreen::Create(nsPIDOMWindow* aWindow)
|
1999-01-28 22:24:29 +00:00
|
|
|
{
|
2012-03-29 16:31:29 +00:00
|
|
|
MOZ_ASSERT(aWindow);
|
2015-07-17 05:10:35 +00:00
|
|
|
MOZ_ASSERT(aWindow->IsInnerWindow());
|
2012-03-29 16:31:29 +00:00
|
|
|
|
2012-03-14 10:10:48 +00:00
|
|
|
if (!aWindow->GetDocShell()) {
|
2012-07-30 14:20:58 +00:00
|
|
|
return nullptr;
|
2012-03-14 10:10:48 +00:00
|
|
|
}
|
|
|
|
|
2012-03-29 16:31:29 +00:00
|
|
|
nsCOMPtr<nsIScriptGlobalObject> sgo =
|
|
|
|
do_QueryInterface(static_cast<nsPIDOMWindow*>(aWindow));
|
2012-07-30 14:20:58 +00:00
|
|
|
NS_ENSURE_TRUE(sgo, nullptr);
|
2012-03-14 10:10:48 +00:00
|
|
|
|
2015-10-18 05:24:48 +00:00
|
|
|
RefPtr<nsScreen> screen = new nsScreen(aWindow);
|
2012-03-14 10:10:48 +00:00
|
|
|
return screen.forget();
|
|
|
|
}
|
|
|
|
|
2014-01-07 02:53:23 +00:00
|
|
|
nsScreen::nsScreen(nsPIDOMWindow* aWindow)
|
2014-04-01 06:13:50 +00:00
|
|
|
: DOMEventTargetHelper(aWindow)
|
2015-08-18 21:55:21 +00:00
|
|
|
, mScreenOrientation(new ScreenOrientation(aWindow, this))
|
2012-03-14 10:10:48 +00:00
|
|
|
{
|
2012-02-09 10:29:09 +00:00
|
|
|
}
|
1999-01-28 22:24:29 +00:00
|
|
|
|
2012-02-09 15:55:54 +00:00
|
|
|
nsScreen::~nsScreen()
|
|
|
|
{
|
|
|
|
}
|
2012-02-09 10:29:09 +00:00
|
|
|
|
2012-02-09 15:55:54 +00:00
|
|
|
|
2004-12-10 19:48:22 +00:00
|
|
|
// QueryInterface implementation for nsScreen
|
2015-08-18 21:55:21 +00:00
|
|
|
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(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 17:42:36 +00:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIDOMScreen)
|
2014-04-01 06:13:50 +00:00
|
|
|
NS_INTERFACE_MAP_END_INHERITING(DOMEventTargetHelper)
|
2012-03-14 18:14:53 +00:00
|
|
|
|
2014-04-01 06:13:50 +00:00
|
|
|
NS_IMPL_ADDREF_INHERITED(nsScreen, DOMEventTargetHelper)
|
|
|
|
NS_IMPL_RELEASE_INHERITED(nsScreen, DOMEventTargetHelper)
|
2012-03-14 18:14:53 +00:00
|
|
|
|
2015-08-18 21:55:21 +00:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_INHERITED(nsScreen,
|
|
|
|
DOMEventTargetHelper,
|
|
|
|
mScreenOrientation)
|
|
|
|
|
2012-10-14 07:40:11 +00:00
|
|
|
int32_t
|
|
|
|
nsScreen::GetPixelDepth(ErrorResult& aRv)
|
1999-01-28 22:24:29 +00:00
|
|
|
{
|
2015-06-07 13:02:00 +00:00
|
|
|
// Return 24 to prevent fingerprinting.
|
|
|
|
if (ShouldResistFingerprinting()) {
|
|
|
|
return 24;
|
|
|
|
}
|
|
|
|
|
2011-04-17 01:22:44 +00:00
|
|
|
nsDeviceContext* context = GetDeviceContext();
|
2002-05-28 22:55:39 +00:00
|
|
|
|
2003-09-19 21:06:52 +00:00
|
|
|
if (!context) {
|
2012-10-14 07:40:11 +00:00
|
|
|
aRv.Throw(NS_ERROR_FAILURE);
|
|
|
|
return -1;
|
2002-05-28 22:55:39 +00:00
|
|
|
}
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t depth;
|
2003-09-19 21:06:52 +00:00
|
|
|
context->GetDepth(depth);
|
2012-10-14 07:40:11 +00:00
|
|
|
return depth;
|
1999-01-28 22:24:29 +00:00
|
|
|
}
|
|
|
|
|
2012-10-14 07:40:11 +00:00
|
|
|
#define FORWARD_LONG_GETTER(_name) \
|
|
|
|
NS_IMETHODIMP \
|
|
|
|
nsScreen::Get ## _name(int32_t* aOut) \
|
|
|
|
{ \
|
|
|
|
ErrorResult rv; \
|
|
|
|
*aOut = Get ## _name(rv); \
|
2015-04-27 13:18:51 +00:00
|
|
|
return rv.StealNSResult(); \
|
2012-10-14 07:40:11 +00:00
|
|
|
}
|
1999-01-28 22:24:29 +00:00
|
|
|
|
2012-10-14 07:40:11 +00:00
|
|
|
FORWARD_LONG_GETTER(AvailWidth)
|
|
|
|
FORWARD_LONG_GETTER(AvailHeight)
|
|
|
|
FORWARD_LONG_GETTER(Width)
|
|
|
|
FORWARD_LONG_GETTER(Height)
|
2002-05-28 22:55:39 +00:00
|
|
|
|
2012-10-14 07:40:11 +00:00
|
|
|
FORWARD_LONG_GETTER(Top)
|
|
|
|
FORWARD_LONG_GETTER(Left)
|
|
|
|
FORWARD_LONG_GETTER(AvailTop)
|
|
|
|
FORWARD_LONG_GETTER(AvailLeft)
|
2002-05-28 22:55:39 +00:00
|
|
|
|
2012-10-14 07:40:11 +00:00
|
|
|
FORWARD_LONG_GETTER(PixelDepth)
|
|
|
|
FORWARD_LONG_GETTER(ColorDepth)
|
1999-01-28 22:24:29 +00:00
|
|
|
|
2011-04-17 01:22:44 +00:00
|
|
|
nsDeviceContext*
|
2004-12-10 19:48:22 +00:00
|
|
|
nsScreen::GetDeviceContext()
|
1999-06-11 21:19:24 +00:00
|
|
|
{
|
2012-03-14 18:14:53 +00:00
|
|
|
return nsLayoutUtils::GetDeviceContextForScreenInfo(GetOwner());
|
1999-06-11 21:19:24 +00:00
|
|
|
}
|
|
|
|
|
2003-09-19 21:06:52 +00:00
|
|
|
nsresult
|
2004-12-10 19:48:22 +00:00
|
|
|
nsScreen::GetRect(nsRect& aRect)
|
2003-09-19 21:06:52 +00:00
|
|
|
{
|
2015-06-07 13:02:00 +00:00
|
|
|
// Return window inner rect to prevent fingerprinting.
|
|
|
|
if (ShouldResistFingerprinting()) {
|
|
|
|
return GetWindowInnerRect(aRect);
|
|
|
|
}
|
|
|
|
|
2011-04-17 01:22:44 +00:00
|
|
|
nsDeviceContext *context = GetDeviceContext();
|
2003-09-19 21:06:52 +00:00
|
|
|
|
|
|
|
if (!context) {
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
context->GetRect(aRect);
|
|
|
|
|
2007-02-07 07:46:44 +00: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-19 21:06:52 +00:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
2004-12-10 19:48:22 +00:00
|
|
|
nsScreen::GetAvailRect(nsRect& aRect)
|
2003-09-19 21:06:52 +00:00
|
|
|
{
|
2015-06-07 13:02:00 +00:00
|
|
|
// Return window inner rect to prevent fingerprinting.
|
|
|
|
if (ShouldResistFingerprinting()) {
|
|
|
|
return GetWindowInnerRect(aRect);
|
|
|
|
}
|
|
|
|
|
2011-04-17 01:22:44 +00:00
|
|
|
nsDeviceContext *context = GetDeviceContext();
|
2003-09-19 21:06:52 +00:00
|
|
|
|
|
|
|
if (!context) {
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
1999-01-28 22:24:29 +00:00
|
|
|
|
2003-09-20 11:41:22 +00:00
|
|
|
context->GetClientRect(aRect);
|
2003-09-19 21:06:52 +00:00
|
|
|
|
2007-02-07 07:46:44 +00: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-19 21:06:52 +00:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2011-12-04 17:07:00 +00:00
|
|
|
|
2015-08-18 21:55:21 +00:00
|
|
|
mozilla::dom::ScreenOrientation*
|
|
|
|
nsScreen::Orientation() const
|
2012-03-14 10:10:48 +00:00
|
|
|
{
|
2015-08-18 21:55:21 +00:00
|
|
|
return mScreenOrientation;
|
2012-03-14 10:10:48 +00:00
|
|
|
}
|
|
|
|
|
2012-10-14 07:40:11 +00:00
|
|
|
void
|
2015-08-18 21:55:21 +00:00
|
|
|
nsScreen::GetMozOrientation(nsString& aOrientation) const
|
2012-03-14 10:10:48 +00:00
|
|
|
{
|
2015-06-07 13:02:00 +00:00
|
|
|
if (ShouldResistFingerprinting()) {
|
2012-10-14 07:40:11 +00:00
|
|
|
aOrientation.AssignLiteral("landscape-primary");
|
2015-06-07 13:02:00 +00:00
|
|
|
} else {
|
2015-08-18 21:55:21 +00:00
|
|
|
switch (mScreenOrientation->DeviceType()) {
|
|
|
|
case OrientationType::Portrait_primary:
|
2015-06-07 13:02:00 +00:00
|
|
|
aOrientation.AssignLiteral("portrait-primary");
|
|
|
|
break;
|
2015-08-18 21:55:21 +00:00
|
|
|
case OrientationType::Portrait_secondary:
|
2015-06-07 13:02:00 +00:00
|
|
|
aOrientation.AssignLiteral("portrait-secondary");
|
|
|
|
break;
|
2015-08-18 21:55:21 +00:00
|
|
|
case OrientationType::Landscape_primary:
|
2015-06-07 13:02:00 +00:00
|
|
|
aOrientation.AssignLiteral("landscape-primary");
|
|
|
|
break;
|
2015-08-18 21:55:21 +00:00
|
|
|
case OrientationType::Landscape_secondary:
|
2015-06-07 13:02:00 +00:00
|
|
|
aOrientation.AssignLiteral("landscape-secondary");
|
|
|
|
break;
|
|
|
|
default:
|
2015-08-18 21:55:21 +00:00
|
|
|
MOZ_CRASH("Unacceptable screen orientation type.");
|
2015-06-07 13:02:00 +00:00
|
|
|
}
|
2012-03-14 10:10:48 +00:00
|
|
|
}
|
2012-10-14 07:40:11 +00:00
|
|
|
}
|
2012-03-14 10:10:48 +00:00
|
|
|
|
2012-10-14 07:40:11 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsScreen::GetSlowMozOrientation(nsAString& aOrientation)
|
|
|
|
{
|
|
|
|
nsString orientation;
|
|
|
|
GetMozOrientation(orientation);
|
|
|
|
aOrientation = orientation;
|
2012-03-14 10:10:48 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
2012-03-29 19:43:16 +00:00
|
|
|
|
2015-08-21 00:25:05 +00:00
|
|
|
static void
|
|
|
|
UpdateDocShellOrientationLock(nsPIDOMWindow* aWindow,
|
|
|
|
ScreenOrientationInternal aOrientation)
|
|
|
|
{
|
|
|
|
if (!aWindow) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDocShell> docShell = aWindow->GetDocShell();
|
|
|
|
if (!docShell) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDocShellTreeItem> root;
|
|
|
|
docShell->GetSameTypeRootTreeItem(getter_AddRefs(root));
|
|
|
|
nsCOMPtr<nsIDocShell> rootShell(do_QueryInterface(root));
|
|
|
|
if (!rootShell) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
rootShell->SetOrientationLock(aOrientation);
|
|
|
|
}
|
|
|
|
|
2012-10-14 07:39:34 +00:00
|
|
|
bool
|
|
|
|
nsScreen::MozLockOrientation(const nsAString& aOrientation, ErrorResult& aRv)
|
|
|
|
{
|
|
|
|
nsString orientation(aOrientation);
|
|
|
|
Sequence<nsString> orientations;
|
2015-05-28 18:07:44 +00:00
|
|
|
if (!orientations.AppendElement(orientation, fallible)) {
|
2012-10-14 07:39:34 +00:00
|
|
|
aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return MozLockOrientation(orientations, aRv);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
nsScreen::MozLockOrientation(const Sequence<nsString>& aOrientations,
|
|
|
|
ErrorResult& aRv)
|
|
|
|
{
|
2015-08-18 21:55:09 +00:00
|
|
|
ScreenOrientationInternal orientation = eScreenOrientation_None;
|
2012-09-11 10:55:08 +00:00
|
|
|
|
2012-10-14 07:39:34 +00:00
|
|
|
for (uint32_t i = 0; i < aOrientations.Length(); ++i) {
|
|
|
|
const nsString& item = aOrientations[i];
|
2012-09-11 10:55:08 +00:00
|
|
|
|
|
|
|
if (item.EqualsLiteral("portrait")) {
|
2012-09-19 16:28:16 +00:00
|
|
|
orientation |= eScreenOrientation_PortraitPrimary |
|
|
|
|
eScreenOrientation_PortraitSecondary;
|
2012-09-11 10:55:08 +00: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 16:28:16 +00:00
|
|
|
orientation |= eScreenOrientation_LandscapePrimary |
|
|
|
|
eScreenOrientation_LandscapeSecondary;
|
2012-09-11 10:55:08 +00:00
|
|
|
} else if (item.EqualsLiteral("landscape-primary")) {
|
|
|
|
orientation |= eScreenOrientation_LandscapePrimary;
|
|
|
|
} else if (item.EqualsLiteral("landscape-secondary")) {
|
|
|
|
orientation |= eScreenOrientation_LandscapeSecondary;
|
2013-09-30 14:40:41 +00:00
|
|
|
} else if (item.EqualsLiteral("default")) {
|
|
|
|
orientation |= eScreenOrientation_Default;
|
2012-09-11 10:55:08 +00:00
|
|
|
} else {
|
2012-10-14 07:39:34 +00:00
|
|
|
// If we don't recognize the token, we should just return 'false'
|
2012-09-11 10:55:08 +00:00
|
|
|
// without throwing.
|
2012-10-14 07:39:34 +00:00
|
|
|
return false;
|
2012-09-11 10:55:08 +00:00
|
|
|
}
|
2012-03-29 19:43:16 +00:00
|
|
|
}
|
|
|
|
|
2015-08-18 22:28:01 +00:00
|
|
|
switch (mScreenOrientation->GetLockOrientationPermission(false)) {
|
2015-08-18 21:55:21 +00:00
|
|
|
case ScreenOrientation::LOCK_DENIED:
|
2012-10-14 07:39:34 +00:00
|
|
|
return false;
|
2015-08-18 21:55:21 +00:00
|
|
|
case ScreenOrientation::LOCK_ALLOWED:
|
2015-08-21 00:25:05 +00:00
|
|
|
UpdateDocShellOrientationLock(GetOwner(), orientation);
|
2015-08-18 21:55:21 +00:00
|
|
|
return mScreenOrientation->LockDeviceOrientation(orientation, false, aRv);
|
|
|
|
case ScreenOrientation::FULLSCREEN_LOCK_ALLOWED:
|
2015-08-21 00:25:05 +00:00
|
|
|
UpdateDocShellOrientationLock(GetOwner(), orientation);
|
2015-08-18 21:55:21 +00:00
|
|
|
return mScreenOrientation->LockDeviceOrientation(orientation, true, aRv);
|
2012-03-29 16:31:29 +00:00
|
|
|
}
|
|
|
|
|
2012-09-11 13:15:43 +00:00
|
|
|
// This is only for compilers that don't understand that the previous switch
|
|
|
|
// will always return.
|
2013-06-29 01:38:30 +00:00
|
|
|
MOZ_CRASH("unexpected lock orientation permission value");
|
2012-03-29 19:43:16 +00:00
|
|
|
}
|
|
|
|
|
2012-10-14 07:40:11 +00:00
|
|
|
void
|
2012-03-29 19:43:16 +00:00
|
|
|
nsScreen::MozUnlockOrientation()
|
|
|
|
{
|
2015-08-21 00:25:05 +00:00
|
|
|
UpdateDocShellOrientationLock(GetOwner(), eScreenOrientation_None);
|
2015-08-18 21:55:21 +00:00
|
|
|
mScreenOrientation->UnlockDeviceOrientation();
|
2012-10-14 07:40:11 +00:00
|
|
|
}
|
|
|
|
|
2013-11-07 13:40:23 +00:00
|
|
|
bool
|
|
|
|
nsScreen::IsDeviceSizePageSize()
|
|
|
|
{
|
|
|
|
nsPIDOMWindow* owner = GetOwner();
|
|
|
|
if (owner) {
|
|
|
|
nsIDocShell* docShell = owner->GetDocShell();
|
|
|
|
if (docShell) {
|
|
|
|
return docShell->GetDeviceSizeIsPageSize();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2012-10-14 07:40:11 +00:00
|
|
|
/* virtual */
|
|
|
|
JSObject*
|
Bug 1117172 part 3. Change the wrappercached WrapObject methods to allow passing in aGivenProto. r=peterv
The only manual changes here are to BindingUtils.h, BindingUtils.cpp,
Codegen.py, Element.cpp, IDBFileRequest.cpp, IDBObjectStore.cpp,
dom/workers/Navigator.cpp, WorkerPrivate.cpp, DeviceStorageRequestChild.cpp,
Notification.cpp, nsGlobalWindow.cpp, MessagePort.cpp, nsJSEnvironment.cpp,
Sandbox.cpp, XPCConvert.cpp, ExportHelpers.cpp, and DataStoreService.cpp. The
rest of this diff was generated by running the following commands:
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObject\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(Binding(?:_workers)?::Wrap\((?:aCx|cx|aContext|aCtx|js), [^,)]+)\)/\1, aGivenProto)/g'
2015-03-19 14:13:33 +00:00
|
|
|
nsScreen::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
|
2012-10-14 07:40:11 +00:00
|
|
|
{
|
Bug 1117172 part 3. Change the wrappercached WrapObject methods to allow passing in aGivenProto. r=peterv
The only manual changes here are to BindingUtils.h, BindingUtils.cpp,
Codegen.py, Element.cpp, IDBFileRequest.cpp, IDBObjectStore.cpp,
dom/workers/Navigator.cpp, WorkerPrivate.cpp, DeviceStorageRequestChild.cpp,
Notification.cpp, nsGlobalWindow.cpp, MessagePort.cpp, nsJSEnvironment.cpp,
Sandbox.cpp, XPCConvert.cpp, ExportHelpers.cpp, and DataStoreService.cpp. The
rest of this diff was generated by running the following commands:
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObject\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(Binding(?:_workers)?::Wrap\((?:aCx|cx|aContext|aCtx|js), [^,)]+)\)/\1, aGivenProto)/g'
2015-03-19 14:13:33 +00:00
|
|
|
return ScreenBinding::Wrap(aCx, this, aGivenProto);
|
2012-10-14 07:40:11 +00:00
|
|
|
}
|
|
|
|
|
2015-06-07 13:02:00 +00:00
|
|
|
nsresult
|
|
|
|
nsScreen::GetWindowInnerRect(nsRect& aRect)
|
|
|
|
{
|
|
|
|
aRect.x = 0;
|
|
|
|
aRect.y = 0;
|
2015-10-26 21:37:32 +00:00
|
|
|
nsCOMPtr<nsPIDOMWindow> win = GetOwner();
|
2015-06-07 13:02:00 +00:00
|
|
|
if (!win) {
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
nsresult rv = win->GetInnerWidth(&aRect.width);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
return win->GetInnerHeight(&aRect.height);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool nsScreen::ShouldResistFingerprinting() const
|
|
|
|
{
|
|
|
|
bool resist = false;
|
|
|
|
nsCOMPtr<nsPIDOMWindow> owner = GetOwner();
|
|
|
|
if (owner) {
|
|
|
|
resist = nsContentUtils::ShouldResistFingerprinting(owner->GetDocShell());
|
|
|
|
}
|
|
|
|
return resist;
|
|
|
|
}
|