2015-05-03 22:32:37 +03: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 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
|
|
|
|
2014-03-05 04:37:43 +04:00
|
|
|
#include "mozilla/dom/Event.h" // for nsIDOMEvent::InternalDOMEvent()
|
|
|
|
#include "mozilla/dom/ScreenBinding.h"
|
2016-06-09 13:42:21 +03:00
|
|
|
#include "nsContentUtils.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>
|
2016-01-30 20:05:36 +03:00
|
|
|
nsScreen::Create(nsPIDOMWindowInner* aWindow)
|
1999-01-29 01:24:29 +03:00
|
|
|
{
|
2012-03-29 20:31:29 +04:00
|
|
|
MOZ_ASSERT(aWindow);
|
2015-07-17 08:10:35 +03:00
|
|
|
MOZ_ASSERT(aWindow->IsInnerWindow());
|
2012-03-29 20:31:29 +04:00
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2016-01-30 20:05:36 +03:00
|
|
|
nsCOMPtr<nsIScriptGlobalObject> sgo = do_QueryInterface(aWindow);
|
2012-07-30 18:20:58 +04:00
|
|
|
NS_ENSURE_TRUE(sgo, nullptr);
|
2012-03-14 14:10:48 +04:00
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<nsScreen> screen = new nsScreen(aWindow);
|
2012-03-14 14:10:48 +04:00
|
|
|
return screen.forget();
|
|
|
|
}
|
|
|
|
|
2016-01-30 20:05:36 +03:00
|
|
|
nsScreen::nsScreen(nsPIDOMWindowInner* aWindow)
|
2014-04-01 10:13:50 +04:00
|
|
|
: DOMEventTargetHelper(aWindow)
|
2015-08-19 00:55:21 +03:00
|
|
|
, mScreenOrientation(new ScreenOrientation(aWindow, this))
|
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()
|
|
|
|
{
|
|
|
|
}
|
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
|
2015-08-19 00:55:21 +03: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 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
|
|
|
|
2015-08-19 00:55:21 +03:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_INHERITED(nsScreen,
|
|
|
|
DOMEventTargetHelper,
|
|
|
|
mScreenOrientation)
|
|
|
|
|
2012-10-14 11:40:11 +04:00
|
|
|
int32_t
|
|
|
|
nsScreen::GetPixelDepth(ErrorResult& aRv)
|
1999-01-29 01:24:29 +03:00
|
|
|
{
|
2015-06-07 16:02:00 +03:00
|
|
|
// Return 24 to prevent fingerprinting.
|
|
|
|
if (ShouldResistFingerprinting()) {
|
|
|
|
return 24;
|
|
|
|
}
|
|
|
|
|
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); \
|
2015-04-27 16:18:51 +03:00
|
|
|
return rv.StealNSResult(); \
|
2012-10-14 11:40:11 +04:00
|
|
|
}
|
1999-01-29 01:24:29 +03:00
|
|
|
|
2012-10-14 11:40:11 +04:00
|
|
|
FORWARD_LONG_GETTER(AvailWidth)
|
|
|
|
FORWARD_LONG_GETTER(AvailHeight)
|
2002-05-29 02:55:39 +04:00
|
|
|
|
2012-10-14 11:40:11 +04:00
|
|
|
FORWARD_LONG_GETTER(Top)
|
|
|
|
FORWARD_LONG_GETTER(AvailTop)
|
|
|
|
FORWARD_LONG_GETTER(AvailLeft)
|
2002-05-29 02:55:39 +04:00
|
|
|
|
2016-01-30 20:05:36 +03:00
|
|
|
nsPIDOMWindowOuter*
|
|
|
|
nsScreen::GetOuter() const
|
|
|
|
{
|
|
|
|
if (nsPIDOMWindowInner* inner = GetOwner()) {
|
|
|
|
return inner->GetOuterWindow();
|
|
|
|
}
|
|
|
|
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
2016-01-30 20:05:36 +03:00
|
|
|
return nsLayoutUtils::GetDeviceContextForScreenInfo(GetOuter());
|
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
|
|
|
{
|
2015-06-07 16:02:00 +03:00
|
|
|
// Return window inner rect to prevent fingerprinting.
|
|
|
|
if (ShouldResistFingerprinting()) {
|
|
|
|
return GetWindowInnerRect(aRect);
|
|
|
|
}
|
|
|
|
|
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);
|
2016-02-12 14:08:58 +03:00
|
|
|
LayoutDevicePoint screenTopLeftDev =
|
|
|
|
LayoutDevicePixel::FromAppUnits(aRect.TopLeft(),
|
|
|
|
context->AppUnitsPerDevPixel());
|
|
|
|
DesktopPoint screenTopLeftDesk =
|
|
|
|
screenTopLeftDev / context->GetDesktopToDeviceScale();
|
|
|
|
|
|
|
|
aRect.x = NSToIntRound(screenTopLeftDesk.x);
|
|
|
|
aRect.y = NSToIntRound(screenTopLeftDesk.y);
|
2003-09-20 01:06:52 +04:00
|
|
|
|
2007-02-07 10:46:44 +03:00
|
|
|
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
|
|
|
{
|
2015-06-07 16:02:00 +03:00
|
|
|
// Return window inner rect to prevent fingerprinting.
|
|
|
|
if (ShouldResistFingerprinting()) {
|
|
|
|
return GetWindowInnerRect(aRect);
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2016-02-12 14:08:58 +03:00
|
|
|
nsRect r;
|
|
|
|
context->GetRect(r);
|
|
|
|
LayoutDevicePoint screenTopLeftDev =
|
|
|
|
LayoutDevicePixel::FromAppUnits(r.TopLeft(),
|
|
|
|
context->AppUnitsPerDevPixel());
|
|
|
|
DesktopPoint screenTopLeftDesk =
|
|
|
|
screenTopLeftDev / context->GetDesktopToDeviceScale();
|
|
|
|
|
2003-09-20 15:41:22 +04:00
|
|
|
context->GetClientRect(aRect);
|
2003-09-20 01:06:52 +04:00
|
|
|
|
2016-02-12 14:08:58 +03:00
|
|
|
aRect.x = NSToIntRound(screenTopLeftDesk.x) +
|
|
|
|
nsPresContext::AppUnitsToIntCSSPixels(aRect.x - r.x);
|
|
|
|
aRect.y = NSToIntRound(screenTopLeftDesk.y) +
|
|
|
|
nsPresContext::AppUnitsToIntCSSPixels(aRect.y - r.y);
|
|
|
|
|
2007-02-07 10:46:44 +03:00
|
|
|
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
|
|
|
|
2015-08-19 00:55:21 +03:00
|
|
|
mozilla::dom::ScreenOrientation*
|
|
|
|
nsScreen::Orientation() const
|
2012-03-14 14:10:48 +04:00
|
|
|
{
|
2015-08-19 00:55:21 +03:00
|
|
|
return mScreenOrientation;
|
2012-03-14 14:10:48 +04:00
|
|
|
}
|
|
|
|
|
2012-10-14 11:40:11 +04:00
|
|
|
void
|
2016-12-22 22:05:54 +03:00
|
|
|
nsScreen::GetMozOrientation(nsString& aOrientation,
|
|
|
|
CallerType aCallerType) const
|
2012-03-14 14:10:48 +04:00
|
|
|
{
|
2016-12-22 22:05:54 +03:00
|
|
|
switch (mScreenOrientation->DeviceType(aCallerType)) {
|
2016-06-24 19:53:00 +03:00
|
|
|
case OrientationType::Portrait_primary:
|
|
|
|
aOrientation.AssignLiteral("portrait-primary");
|
|
|
|
break;
|
|
|
|
case OrientationType::Portrait_secondary:
|
|
|
|
aOrientation.AssignLiteral("portrait-secondary");
|
|
|
|
break;
|
|
|
|
case OrientationType::Landscape_primary:
|
2012-10-14 11:40:11 +04:00
|
|
|
aOrientation.AssignLiteral("landscape-primary");
|
2016-06-24 19:53:00 +03:00
|
|
|
break;
|
|
|
|
case OrientationType::Landscape_secondary:
|
|
|
|
aOrientation.AssignLiteral("landscape-secondary");
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
MOZ_CRASH("Unacceptable screen orientation type.");
|
2012-03-14 14:10:48 +04:00
|
|
|
}
|
2012-10-14 11:40:11 +04:00
|
|
|
}
|
2012-03-14 14:10:48 +04:00
|
|
|
|
2015-08-21 03:25:05 +03:00
|
|
|
static void
|
2016-01-30 20:05:36 +03:00
|
|
|
UpdateDocShellOrientationLock(nsPIDOMWindowInner* aWindow,
|
2015-08-21 03:25:05 +03:00
|
|
|
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 11:39:34 +04:00
|
|
|
bool
|
|
|
|
nsScreen::MozLockOrientation(const nsAString& aOrientation, ErrorResult& aRv)
|
|
|
|
{
|
|
|
|
nsString orientation(aOrientation);
|
|
|
|
Sequence<nsString> orientations;
|
2015-05-28 21:07:44 +03:00
|
|
|
if (!orientations.AppendElement(orientation, fallible)) {
|
2012-10-14 11:39:34 +04:00
|
|
|
aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return MozLockOrientation(orientations, aRv);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
nsScreen::MozLockOrientation(const Sequence<nsString>& aOrientations,
|
|
|
|
ErrorResult& aRv)
|
|
|
|
{
|
2016-06-24 19:53:00 +03:00
|
|
|
if (ShouldResistFingerprinting()) {
|
|
|
|
return false;
|
|
|
|
}
|
2015-08-19 00:55:09 +03:00
|
|
|
ScreenOrientationInternal orientation = eScreenOrientation_None;
|
2012-09-11 14:55:08 +04:00
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2015-08-19 01:28:01 +03:00
|
|
|
switch (mScreenOrientation->GetLockOrientationPermission(false)) {
|
2015-08-19 00:55:21 +03:00
|
|
|
case ScreenOrientation::LOCK_DENIED:
|
2012-10-14 11:39:34 +04:00
|
|
|
return false;
|
2015-08-19 00:55:21 +03:00
|
|
|
case ScreenOrientation::LOCK_ALLOWED:
|
2015-08-21 03:25:05 +03:00
|
|
|
UpdateDocShellOrientationLock(GetOwner(), orientation);
|
2015-08-19 00:55:21 +03:00
|
|
|
return mScreenOrientation->LockDeviceOrientation(orientation, false, aRv);
|
|
|
|
case ScreenOrientation::FULLSCREEN_LOCK_ALLOWED:
|
2015-08-21 03:25:05 +03:00
|
|
|
UpdateDocShellOrientationLock(GetOwner(), orientation);
|
2015-08-19 00:55:21 +03:00
|
|
|
return mScreenOrientation->LockDeviceOrientation(orientation, true, aRv);
|
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()
|
|
|
|
{
|
2016-06-24 19:53:00 +03:00
|
|
|
if (ShouldResistFingerprinting()) {
|
|
|
|
return;
|
|
|
|
}
|
2015-08-21 03:25:05 +03:00
|
|
|
UpdateDocShellOrientationLock(GetOwner(), eScreenOrientation_None);
|
2015-08-19 00:55:21 +03:00
|
|
|
mScreenOrientation->UnlockDeviceOrientation();
|
2012-10-14 11:40:11 +04:00
|
|
|
}
|
|
|
|
|
2013-11-07 17:40:23 +04:00
|
|
|
bool
|
|
|
|
nsScreen::IsDeviceSizePageSize()
|
|
|
|
{
|
2016-01-30 20:05:36 +03:00
|
|
|
if (nsPIDOMWindowInner* owner = GetOwner()) {
|
2013-11-07 17:40:23 +04:00
|
|
|
nsIDocShell* docShell = owner->GetDocShell();
|
|
|
|
if (docShell) {
|
|
|
|
return docShell->GetDeviceSizeIsPageSize();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2012-10-14 11:40:11 +04: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 17:13:33 +03:00
|
|
|
nsScreen::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
|
2012-10-14 11:40:11 +04: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 17:13:33 +03:00
|
|
|
return ScreenBinding::Wrap(aCx, this, aGivenProto);
|
2012-10-14 11:40:11 +04:00
|
|
|
}
|
|
|
|
|
2015-06-07 16:02:00 +03:00
|
|
|
nsresult
|
|
|
|
nsScreen::GetWindowInnerRect(nsRect& aRect)
|
|
|
|
{
|
|
|
|
aRect.x = 0;
|
|
|
|
aRect.y = 0;
|
2016-01-30 20:05:36 +03:00
|
|
|
nsCOMPtr<nsPIDOMWindowInner> win = GetOwner();
|
2015-06-07 16:02:00 +03: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;
|
2016-01-30 20:05:36 +03:00
|
|
|
nsCOMPtr<nsPIDOMWindowInner> owner = GetOwner();
|
2015-06-07 16:02:00 +03:00
|
|
|
if (owner) {
|
|
|
|
resist = nsContentUtils::ShouldResistFingerprinting(owner->GetDocShell());
|
|
|
|
}
|
|
|
|
return resist;
|
|
|
|
}
|