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
|
|
|
|
2016-06-09 13:42:21 +03:00
|
|
|
#include "nsContentUtils.h"
|
1999-01-29 01:24:29 +03:00
|
|
|
#include "nsScreen.h"
|
2019-01-02 16:05:23 +03:00
|
|
|
#include "mozilla/dom/Document.h"
|
2000-02-08 16:40:10 +03:00
|
|
|
#include "nsIDocShell.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"
|
2022-02-15 23:22:54 +03:00
|
|
|
#include "mozilla/widget/ScreenManager.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
|
|
|
|
2019-02-26 01:05:29 +03:00
|
|
|
/* static */
|
|
|
|
already_AddRefed<nsScreen> nsScreen::Create(nsPIDOMWindowInner* aWindow) {
|
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
|
|
|
}
|
|
|
|
|
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),
|
2023-03-27 16:21:43 +03:00
|
|
|
mScreenOrientation(new ScreenOrientation(aWindow, this)) {}
|
2012-02-09 14:29:09 +04:00
|
|
|
|
2020-02-21 13:41:47 +03:00
|
|
|
nsScreen::~nsScreen() = default;
|
2012-02-09 19:55:54 +04:00
|
|
|
|
2004-12-10 22:48:22 +03:00
|
|
|
// QueryInterface implementation for nsScreen
|
2017-08-30 02:02:48 +03:00
|
|
|
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsScreen)
|
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) {
|
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
|
|
|
}
|
|
|
|
|
2022-03-24 21:19:49 +03:00
|
|
|
return context->GetDepth();
|
1999-01-29 01:24:29 +03:00
|
|
|
}
|
|
|
|
|
2016-01-30 20:05:36 +03:00
|
|
|
nsPIDOMWindowOuter* nsScreen::GetOuter() const {
|
|
|
|
if (nsPIDOMWindowInner* inner = GetOwner()) {
|
|
|
|
return inner->GetOuterWindow();
|
|
|
|
}
|
|
|
|
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2023-02-14 09:16:33 +03:00
|
|
|
nsDeviceContext* nsScreen::GetDeviceContext() const {
|
2016-01-30 20:05:36 +03:00
|
|
|
return nsLayoutUtils::GetDeviceContextForScreenInfo(GetOuter());
|
1999-06-12 01:19:24 +04:00
|
|
|
}
|
|
|
|
|
2022-02-16 15:18:12 +03:00
|
|
|
nsresult nsScreen::GetRect(CSSIntRect& aRect) {
|
2015-06-07 16:02:00 +03:00
|
|
|
// Return window inner rect to prevent fingerprinting.
|
|
|
|
if (ShouldResistFingerprinting()) {
|
|
|
|
return GetWindowInnerRect(aRect);
|
|
|
|
}
|
|
|
|
|
2019-08-26 02:53:54 +03:00
|
|
|
// Here we manipulate the value of aRect to represent the screen size,
|
|
|
|
// if in RDM.
|
2022-02-16 15:18:12 +03:00
|
|
|
if (nsCOMPtr<nsPIDOMWindowInner> owner = GetOwner()) {
|
|
|
|
if (Document* doc = owner->GetExtantDoc()) {
|
|
|
|
Maybe<CSSIntSize> deviceSize =
|
2019-08-26 02:53:54 +03:00
|
|
|
nsGlobalWindowOuter::GetRDMDeviceSize(*doc);
|
|
|
|
if (deviceSize.isSome()) {
|
2022-02-16 15:18:12 +03:00
|
|
|
const CSSIntSize& size = deviceSize.value();
|
2019-08-26 02:53:54 +03:00
|
|
|
aRect.SetRect(0, 0, size.width, size.height);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2022-02-16 15:18:12 +03:00
|
|
|
nsRect r;
|
|
|
|
context->GetRect(r);
|
|
|
|
aRect = CSSIntRect::FromAppUnitsRounded(r);
|
2003-09-20 01:06:52 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2022-02-16 15:18:12 +03:00
|
|
|
nsresult nsScreen::GetAvailRect(CSSIntRect& aRect) {
|
2015-06-07 16:02:00 +03:00
|
|
|
// Return window inner rect to prevent fingerprinting.
|
|
|
|
if (ShouldResistFingerprinting()) {
|
|
|
|
return GetWindowInnerRect(aRect);
|
|
|
|
}
|
|
|
|
|
2019-08-26 02:53:54 +03:00
|
|
|
// Here we manipulate the value of aRect to represent the screen size,
|
2019-06-05 18:44:04 +03:00
|
|
|
// if in RDM.
|
2022-02-16 15:18:12 +03:00
|
|
|
if (nsCOMPtr<nsPIDOMWindowInner> owner = GetOwner()) {
|
|
|
|
if (Document* doc = owner->GetExtantDoc()) {
|
|
|
|
Maybe<CSSIntSize> deviceSize =
|
2019-08-26 02:53:54 +03:00
|
|
|
nsGlobalWindowOuter::GetRDMDeviceSize(*doc);
|
|
|
|
if (deviceSize.isSome()) {
|
2022-02-16 15:18:12 +03:00
|
|
|
const CSSIntSize& size = deviceSize.value();
|
2019-08-26 02:53:54 +03:00
|
|
|
aRect.SetRect(0, 0, size.width, size.height);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2019-08-26 02:53:31 +03:00
|
|
|
}
|
2019-06-05 18:44:04 +03: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
|
|
|
|
2016-02-12 14:08:58 +03:00
|
|
|
nsRect r;
|
2022-02-16 15:18:12 +03:00
|
|
|
context->GetClientRect(r);
|
|
|
|
aRect = CSSIntRect::FromAppUnitsRounded(r);
|
2022-02-16 02:47:51 +03:00
|
|
|
return NS_OK;
|
2012-03-14 14:10:48 +04:00
|
|
|
}
|
|
|
|
|
2022-02-16 15:18:12 +03:00
|
|
|
uint16_t nsScreen::GetOrientationAngle() const {
|
2023-02-14 09:16:33 +03:00
|
|
|
nsDeviceContext* context = GetDeviceContext();
|
|
|
|
if (context) {
|
|
|
|
return context->GetScreenOrientationAngle();
|
|
|
|
}
|
2022-02-16 15:18:12 +03:00
|
|
|
RefPtr<widget::Screen> s =
|
|
|
|
widget::ScreenManager::GetSingleton().GetPrimaryScreen();
|
|
|
|
return s->GetOrientationAngle();
|
|
|
|
}
|
|
|
|
|
|
|
|
hal::ScreenOrientation nsScreen::GetOrientationType() const {
|
2023-02-14 09:16:33 +03:00
|
|
|
nsDeviceContext* context = GetDeviceContext();
|
|
|
|
if (context) {
|
|
|
|
return context->GetScreenOrientationType();
|
|
|
|
}
|
2022-02-16 15:18:12 +03:00
|
|
|
RefPtr<widget::Screen> s =
|
|
|
|
widget::ScreenManager::GetSingleton().GetPrimaryScreen();
|
|
|
|
return s->GetOrientationType();
|
2022-02-16 02:47:51 +03:00
|
|
|
}
|
2022-02-16 01:25:05 +03:00
|
|
|
|
2023-03-27 16:21:43 +03:00
|
|
|
ScreenOrientation* nsScreen::Orientation() const { return mScreenOrientation; }
|
2022-02-16 15:18:12 +03:00
|
|
|
|
2016-12-22 22:05:54 +03:00
|
|
|
void nsScreen::GetMozOrientation(nsString& aOrientation,
|
|
|
|
CallerType aCallerType) const {
|
|
|
|
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
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
Bug 1697647 - Add screen orientation lock api r=ipc-reviewers,mccr8,agi,smaug,jonalmeida
Previously, the screenOrientation.lock API was for Fennec and not supported for Fenix and multi-process use. The overall idea is to now allow apps to use the API through a delegate and make asynchronous calls to LockDeviceOrientation. This required replacing the existing code that returned a default false bool to calls that perform the requested orientation change and instead return a promise that contained either an allow or deny value.
Returning a promise instead of a bool involved changing the API calls from the C++ side to Java. The new general control flow of screenOrientation lock follows: an app calls C++ ScreenOrientation.lock() which eventually dispatches LockOrientationTask to resolve the pending orientation promise. Hal.cpp sends an IPC call to the content process and RecvLockScreenOrientation retrieves the current instance of geckoRuntime and calls the java side LockScreenOrientation. Apps must create a delegate and override onOrientationLock to set the requested orientation. In geckoview's testing, this is done with the android API setRequestedOrientation. Once a device orientation change has been triggered, native OnOrientationChange calls to NotifyScreenConfigurationChange, which notifies all observers and dispatches a change event to resolve the pending orientation promise.
Testing:
I used a demo on the GeckoView Example (https://usefulangle.com/demos/105/screen.html) to test locking to landscape orientation. This required a change to the GVE to show the app from recreating the whole thing on orientation change. In the example AndroidManifest xml file, `orientation` prevents restart when orientation changes.
The Junit/Kotlin tests were to verify that the expected orientation delegate was called with the expected new orientation value, in an orientation change, if the new orientation was the same as the current, and if the pre-lock conditions such as being fullscreen were not met.
A static preference `dom.screenorientation.allow-lock` was added to the dom group, since it affects the ui dom) and is currently turned off. C++ can access it through its mirrored variable dom_screenorientation_allow_lock (same name but with underscores). The junit tests turn the preference on and test the lock feature.
Reference:
Orientation constant values:
C++
1 ScreenOrientation_PortraitPrimary); - vertical with button at bottom
2 ScreenOrientation_PortraitSecondary); - vertical with button at top
4 ScreenOrientation_LandscapePrimary); - horizational w button right
8 ScreenOrientation_LandscapeSecondary); - horization button left
16 ScreenOrientation_Default);
Java
1 GeckoScreenOrientation.ScreenOrientation.PORTRAIT_PRIMARY.value
2 GeckoScreenOrientation.ScreenOrientation.PORTRAIT_SECONDARY.value
4 GeckoScreenOrientation.ScreenOrientation.LANDSCAPE_PRIMARY.value
8 GeckoScreenOrientation.ScreenOrientation.LANDSCAPE_SECONDARY.value
Java public API
0 ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE
1 Activitynfo.SCREEN_ORIENTATION_PORTRAIT
Android
1 ORIENTATION_PORTRAIT
2 ORIENTATION_LANDSCAPE
Differential Revision: https://phabricator.services.mozilla.com/D129427
2021-12-06 16:58:37 +03:00
|
|
|
// This function is deprecated, use ScreenOrientation API instead.
|
2012-10-14 11:39:34 +04:00
|
|
|
bool nsScreen::MozLockOrientation(const Sequence<nsString>& aOrientations,
|
|
|
|
ErrorResult& aRv) {
|
Bug 1697647 - Add screen orientation lock api r=ipc-reviewers,mccr8,agi,smaug,jonalmeida
Previously, the screenOrientation.lock API was for Fennec and not supported for Fenix and multi-process use. The overall idea is to now allow apps to use the API through a delegate and make asynchronous calls to LockDeviceOrientation. This required replacing the existing code that returned a default false bool to calls that perform the requested orientation change and instead return a promise that contained either an allow or deny value.
Returning a promise instead of a bool involved changing the API calls from the C++ side to Java. The new general control flow of screenOrientation lock follows: an app calls C++ ScreenOrientation.lock() which eventually dispatches LockOrientationTask to resolve the pending orientation promise. Hal.cpp sends an IPC call to the content process and RecvLockScreenOrientation retrieves the current instance of geckoRuntime and calls the java side LockScreenOrientation. Apps must create a delegate and override onOrientationLock to set the requested orientation. In geckoview's testing, this is done with the android API setRequestedOrientation. Once a device orientation change has been triggered, native OnOrientationChange calls to NotifyScreenConfigurationChange, which notifies all observers and dispatches a change event to resolve the pending orientation promise.
Testing:
I used a demo on the GeckoView Example (https://usefulangle.com/demos/105/screen.html) to test locking to landscape orientation. This required a change to the GVE to show the app from recreating the whole thing on orientation change. In the example AndroidManifest xml file, `orientation` prevents restart when orientation changes.
The Junit/Kotlin tests were to verify that the expected orientation delegate was called with the expected new orientation value, in an orientation change, if the new orientation was the same as the current, and if the pre-lock conditions such as being fullscreen were not met.
A static preference `dom.screenorientation.allow-lock` was added to the dom group, since it affects the ui dom) and is currently turned off. C++ can access it through its mirrored variable dom_screenorientation_allow_lock (same name but with underscores). The junit tests turn the preference on and test the lock feature.
Reference:
Orientation constant values:
C++
1 ScreenOrientation_PortraitPrimary); - vertical with button at bottom
2 ScreenOrientation_PortraitSecondary); - vertical with button at top
4 ScreenOrientation_LandscapePrimary); - horizational w button right
8 ScreenOrientation_LandscapeSecondary); - horization button left
16 ScreenOrientation_Default);
Java
1 GeckoScreenOrientation.ScreenOrientation.PORTRAIT_PRIMARY.value
2 GeckoScreenOrientation.ScreenOrientation.PORTRAIT_SECONDARY.value
4 GeckoScreenOrientation.ScreenOrientation.LANDSCAPE_PRIMARY.value
8 GeckoScreenOrientation.ScreenOrientation.LANDSCAPE_SECONDARY.value
Java public API
0 ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE
1 Activitynfo.SCREEN_ORIENTATION_PORTRAIT
Android
1 ORIENTATION_PORTRAIT
2 ORIENTATION_LANDSCAPE
Differential Revision: https://phabricator.services.mozilla.com/D129427
2021-12-06 16:58:37 +03:00
|
|
|
return false;
|
2012-03-29 23:43:16 +04:00
|
|
|
}
|
|
|
|
|
Bug 1697647 - Add screen orientation lock api r=ipc-reviewers,mccr8,agi,smaug,jonalmeida
Previously, the screenOrientation.lock API was for Fennec and not supported for Fenix and multi-process use. The overall idea is to now allow apps to use the API through a delegate and make asynchronous calls to LockDeviceOrientation. This required replacing the existing code that returned a default false bool to calls that perform the requested orientation change and instead return a promise that contained either an allow or deny value.
Returning a promise instead of a bool involved changing the API calls from the C++ side to Java. The new general control flow of screenOrientation lock follows: an app calls C++ ScreenOrientation.lock() which eventually dispatches LockOrientationTask to resolve the pending orientation promise. Hal.cpp sends an IPC call to the content process and RecvLockScreenOrientation retrieves the current instance of geckoRuntime and calls the java side LockScreenOrientation. Apps must create a delegate and override onOrientationLock to set the requested orientation. In geckoview's testing, this is done with the android API setRequestedOrientation. Once a device orientation change has been triggered, native OnOrientationChange calls to NotifyScreenConfigurationChange, which notifies all observers and dispatches a change event to resolve the pending orientation promise.
Testing:
I used a demo on the GeckoView Example (https://usefulangle.com/demos/105/screen.html) to test locking to landscape orientation. This required a change to the GVE to show the app from recreating the whole thing on orientation change. In the example AndroidManifest xml file, `orientation` prevents restart when orientation changes.
The Junit/Kotlin tests were to verify that the expected orientation delegate was called with the expected new orientation value, in an orientation change, if the new orientation was the same as the current, and if the pre-lock conditions such as being fullscreen were not met.
A static preference `dom.screenorientation.allow-lock` was added to the dom group, since it affects the ui dom) and is currently turned off. C++ can access it through its mirrored variable dom_screenorientation_allow_lock (same name but with underscores). The junit tests turn the preference on and test the lock feature.
Reference:
Orientation constant values:
C++
1 ScreenOrientation_PortraitPrimary); - vertical with button at bottom
2 ScreenOrientation_PortraitSecondary); - vertical with button at top
4 ScreenOrientation_LandscapePrimary); - horizational w button right
8 ScreenOrientation_LandscapeSecondary); - horization button left
16 ScreenOrientation_Default);
Java
1 GeckoScreenOrientation.ScreenOrientation.PORTRAIT_PRIMARY.value
2 GeckoScreenOrientation.ScreenOrientation.PORTRAIT_SECONDARY.value
4 GeckoScreenOrientation.ScreenOrientation.LANDSCAPE_PRIMARY.value
8 GeckoScreenOrientation.ScreenOrientation.LANDSCAPE_SECONDARY.value
Java public API
0 ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE
1 Activitynfo.SCREEN_ORIENTATION_PORTRAIT
Android
1 ORIENTATION_PORTRAIT
2 ORIENTATION_LANDSCAPE
Differential Revision: https://phabricator.services.mozilla.com/D129427
2021-12-06 16:58:37 +03:00
|
|
|
void nsScreen::MozUnlockOrientation() {}
|
2012-10-14 11:40:11 +04:00
|
|
|
|
|
|
|
/* virtual */
|
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
|
|
|
JSObject* nsScreen::WrapObject(JSContext* aCx,
|
|
|
|
JS::Handle<JSObject*> aGivenProto) {
|
2018-06-26 00:20:54 +03:00
|
|
|
return Screen_Binding::Wrap(aCx, this, aGivenProto);
|
2012-10-14 11:40:11 +04:00
|
|
|
}
|
|
|
|
|
2022-02-16 15:18:12 +03:00
|
|
|
nsresult nsScreen::GetWindowInnerRect(CSSIntRect& aRect) {
|
2018-02-19 23:15:23 +03:00
|
|
|
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;
|
|
|
|
}
|
2020-11-13 15:44:01 +03:00
|
|
|
double width;
|
|
|
|
double height;
|
|
|
|
nsresult rv = win->GetInnerWidth(&width);
|
2015-06-07 16:02:00 +03:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
2020-11-13 15:44:01 +03:00
|
|
|
rv = win->GetInnerHeight(&height);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
aRect.SizeTo(std::round(width), std::round(height));
|
|
|
|
return NS_OK;
|
2015-06-07 16:02:00 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
bool nsScreen::ShouldResistFingerprinting() const {
|
2016-01-30 20:05:36 +03:00
|
|
|
nsCOMPtr<nsPIDOMWindowInner> owner = GetOwner();
|
2022-11-30 22:03:38 +03:00
|
|
|
return owner &&
|
|
|
|
nsGlobalWindowInner::Cast(owner)->ShouldResistFingerprinting();
|
2015-06-07 16:02:00 +03:00
|
|
|
}
|