Bug 1450418. Get rid of nsIDOMScreen. r=qdot
MozReview-Commit-ID: A5Rq0BSQt4V
--- a/dom/base/nsGlobalWindowInner.cpp
+++ b/dom/base/nsGlobalWindowInner.cpp
@@ -2327,25 +2327,16 @@ nsGlobalWindowInner::GetScreen(ErrorResu
aError.Throw(NS_ERROR_UNEXPECTED);
return nullptr;
}
}
return mScreen;
}
-nsIDOMScreen*
-nsGlobalWindowInner::GetScreen()
-{
- ErrorResult dummy;
- nsIDOMScreen* screen = GetScreen(dummy);
- dummy.SuppressException();
- return screen;
-}
-
nsHistory*
nsGlobalWindowInner::GetHistory(ErrorResult& aError)
{
if (!mHistory) {
mHistory = new nsHistory(this);
}
return mHistory;
--- a/dom/base/nsGlobalWindowInner.h
+++ b/dom/base/nsGlobalWindowInner.h
@@ -774,17 +774,16 @@ public:
already_AddRefed<nsICSSDeclaration>
GetComputedStyle(mozilla::dom::Element& aElt, const nsAString& aPseudoElt,
mozilla::ErrorResult& aError) override;
already_AddRefed<mozilla::dom::MediaQueryList> MatchMedia(
const nsAString& aQuery,
mozilla::dom::CallerType aCallerType,
mozilla::ErrorResult& aError);
nsScreen* GetScreen(mozilla::ErrorResult& aError);
- nsIDOMScreen* GetScreen() override;
void MoveTo(int32_t aXPos, int32_t aYPos,
mozilla::dom::CallerType aCallerType,
mozilla::ErrorResult& aError);
void MoveBy(int32_t aXDif, int32_t aYDif,
mozilla::dom::CallerType aCallerType,
mozilla::ErrorResult& aError);
void ResizeTo(int32_t aWidth, int32_t aHeight,
mozilla::dom::CallerType aCallerType,
--- a/dom/base/nsGlobalWindowOuter.cpp
+++ b/dom/base/nsGlobalWindowOuter.cpp
@@ -2591,20 +2591,20 @@ nsPIDOMWindowOuter::SetFrameElementInter
}
Navigator*
nsGlobalWindowOuter::GetNavigator()
{
FORWARD_TO_INNER(Navigator, (), nullptr);
}
-nsIDOMScreen*
+nsScreen*
nsGlobalWindowOuter::GetScreen()
{
- FORWARD_TO_INNER(GetScreen, (), nullptr);
+ FORWARD_TO_INNER(GetScreen, (IgnoreErrors()), nullptr);
}
void
nsPIDOMWindowOuter::MaybeActiveMediaComponents()
{
if (mMediaSuspend != nsISuspendedTypes::SUSPENDED_BLOCK) {
return;
}
@@ -3703,48 +3703,47 @@ nsGlobalWindowOuter::CheckSecurityLeftAn
#endif
if (nsGlobalWindowOuter* rootWindow = nsGlobalWindowOuter::Cast(GetPrivateRoot())) {
rootWindow->FlushPendingNotifications(FlushType::Layout);
}
nsCOMPtr<nsIBaseWindow> treeOwner = GetTreeOwnerWindow();
- nsCOMPtr<nsIDOMScreen> screen = GetScreen();
+ RefPtr<nsScreen> screen = GetScreen();
if (treeOwner && screen) {
- int32_t screenLeft, screenTop, screenWidth, screenHeight;
int32_t winLeft, winTop, winWidth, winHeight;
// Get the window size
treeOwner->GetPositionAndSize(&winLeft, &winTop, &winWidth, &winHeight);
// convert those values to CSS pixels
// XXX four separate retrievals of the prescontext
winLeft = DevToCSSIntPixels(winLeft);
winTop = DevToCSSIntPixels(winTop);
winWidth = DevToCSSIntPixels(winWidth);
winHeight = DevToCSSIntPixels(winHeight);
// Get the screen dimensions
// XXX This should use nsIScreenManager once it's fully fleshed out.
- screen->GetAvailLeft(&screenLeft);
- screen->GetAvailWidth(&screenWidth);
- screen->GetAvailHeight(&screenHeight);
+ int32_t screenLeft = screen->GetAvailLeft(IgnoreErrors());
+ int32_t screenWidth = screen->GetAvailWidth(IgnoreErrors());
+ int32_t screenHeight = screen->GetAvailHeight(IgnoreErrors());
#if defined(XP_MACOSX)
/* The mac's coordinate system is different from the assumed Windows'
system. It offsets by the height of the menubar so that a window
placed at (0,0) will be entirely visible. Unfortunately that
correction is made elsewhere (in Widget) and the meaning of
the Avail... coordinates is overloaded. Here we allow a window
to be placed at (0,0) because it does make sense to do so.
*/
- screen->GetTop(&screenTop);
+ int32_t screenTop = screen->GetTop(IgnoreErrors());
#else
- screen->GetAvailTop(&screenTop);
+ int32_t screenTop = screen->GetAvailTop(IgnoreErrors());
#endif
if (aLeft) {
if (screenLeft+screenWidth < *aLeft+winWidth)
*aLeft = screenLeft+screenWidth - winWidth;
if (screenLeft > *aLeft)
*aLeft = screenLeft;
}
--- a/dom/base/nsGlobalWindowOuter.h
+++ b/dom/base/nsGlobalWindowOuter.h
@@ -631,17 +631,17 @@ public:
nsIPrincipal& aSubjectPrincipal,
mozilla::ErrorResult& aError);
void PrintOuter(mozilla::ErrorResult& aError);
mozilla::dom::Selection* GetSelectionOuter();
already_AddRefed<nsISelection> GetSelection() override;
already_AddRefed<mozilla::dom::MediaQueryList> MatchMediaOuter(
const nsAString& aQuery,
mozilla::dom::CallerType aCallerType);
- nsIDOMScreen* GetScreen() override;
+ nsScreen* GetScreen();
void MoveToOuter(int32_t aXPos, int32_t aYPos,
mozilla::dom::CallerType aCallerType,
mozilla::ErrorResult& aError);
void MoveByOuter(int32_t aXDif, int32_t aYDif,
mozilla::dom::CallerType aCallerType,
mozilla::ErrorResult& aError);
nsresult MoveBy(int32_t aXDif, int32_t aYDif) override;
void ResizeToOuter(int32_t aWidth, int32_t aHeight,
--- a/dom/base/nsPIDOMWindow.h
+++ b/dom/base/nsPIDOMWindow.h
@@ -585,17 +585,16 @@ public:
mMarkedCCGeneration = aGeneration;
}
uint32_t GetMarkedCCGeneration()
{
return mMarkedCCGeneration;
}
- virtual nsIDOMScreen* GetScreen() = 0;
mozilla::dom::Navigator* Navigator();
virtual mozilla::dom::Location* GetLocation() = 0;
virtual nsresult GetControllers(nsIControllers** aControllers) = 0;
virtual already_AddRefed<nsIDOMWindowCollection> GetFrames() = 0;
virtual nsresult GetInnerWidth(int32_t* aWidth) = 0;
@@ -1089,17 +1088,16 @@ public:
uint32_t GetMarkedCCGeneration()
{
return mMarkedCCGeneration;
}
// XXX(nika): These feel like they should be inner window only, but they're
// called on the outer window.
- virtual nsIDOMScreen* GetScreen() = 0;
virtual mozilla::dom::Navigator* GetNavigator() = 0;
virtual mozilla::dom::Location* GetLocation() = 0;
virtual nsresult GetPrompter(nsIPrompt** aPrompt) = 0;
virtual nsresult GetControllers(nsIControllers** aControllers) = 0;
virtual already_AddRefed<nsISelection> GetSelection() = 0;
virtual already_AddRefed<nsPIDOMWindowOuter> GetOpener() = 0;
--- a/dom/base/nsScreen.cpp
+++ b/dom/base/nsScreen.cpp
@@ -45,17 +45,16 @@ nsScreen::nsScreen(nsPIDOMWindowInner* a
nsScreen::~nsScreen()
{
}
// QueryInterface implementation for nsScreen
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsScreen)
- NS_INTERFACE_MAP_ENTRY(nsIDOMScreen)
NS_INTERFACE_MAP_END_INHERITING(DOMEventTargetHelper)
NS_IMPL_ADDREF_INHERITED(nsScreen, DOMEventTargetHelper)
NS_IMPL_RELEASE_INHERITED(nsScreen, DOMEventTargetHelper)
NS_IMPL_CYCLE_COLLECTION_INHERITED(nsScreen,
DOMEventTargetHelper,
mScreenOrientation)
@@ -75,32 +74,16 @@ nsScreen::GetPixelDepth(ErrorResult& aRv
return -1;
}
uint32_t depth;
context->GetDepth(depth);
return depth;
}
-#define FORWARD_LONG_GETTER(_name) \
- NS_IMETHODIMP \
- nsScreen::Get ## _name(int32_t* aOut) \
- { \
- ErrorResult rv; \
- *aOut = Get ## _name(rv); \
- return rv.StealNSResult(); \
- }
-
-FORWARD_LONG_GETTER(AvailWidth)
-FORWARD_LONG_GETTER(AvailHeight)
-
-FORWARD_LONG_GETTER(Top)
-FORWARD_LONG_GETTER(AvailTop)
-FORWARD_LONG_GETTER(AvailLeft)
-
nsPIDOMWindowOuter*
nsScreen::GetOuter() const
{
if (nsPIDOMWindowInner* inner = GetOwner()) {
return inner->GetOuterWindow();
}
return nullptr;
--- a/dom/base/nsScreen.h
+++ b/dom/base/nsScreen.h
@@ -5,32 +5,29 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef nsScreen_h___
#define nsScreen_h___
#include "mozilla/Attributes.h"
#include "mozilla/dom/ScreenOrientation.h"
#include "mozilla/DOMEventTargetHelper.h"
#include "mozilla/ErrorResult.h"
-#include "nsIDOMScreen.h"
#include "nsCOMPtr.h"
#include "nsRect.h"
class nsDeviceContext;
// Script "screen" object
class nsScreen : public mozilla::DOMEventTargetHelper
- , public nsIDOMScreen
{
typedef mozilla::ErrorResult ErrorResult;
public:
static already_AddRefed<nsScreen> Create(nsPIDOMWindowInner* aWindow);
NS_DECL_ISUPPORTS_INHERITED
- NS_DECL_NSIDOMSCREEN
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsScreen, mozilla::DOMEventTargetHelper)
NS_REALLY_FORWARD_NSIDOMEVENTTARGET(mozilla::DOMEventTargetHelper)
nsPIDOMWindowInner* GetParentObject() const
{
return GetOwner();
}
--- a/dom/interfaces/base/domstubs.idl
+++ b/dom/interfaces/base/domstubs.idl
@@ -29,17 +29,16 @@ namespace dom {
class DOMException;
}
}
%}
// Base
interface nsIDOMWindow;
interface nsIDOMWindowCollection;
-interface nsIDOMScreen;
// Events
interface nsIDOMEvent;
interface nsIDOMEventTarget;
interface nsIDOMEventListener;
// HTML
interface nsIDOMHTMLHeadElement;
--- a/dom/interfaces/base/moz.build
+++ b/dom/interfaces/base/moz.build
@@ -12,17 +12,16 @@ XPIDL_SOURCES += [
'nsIBrowser.idl',
'nsIBrowserDOMWindow.idl',
'nsIContentPermissionPrompt.idl',
'nsIContentPrefService2.idl',
'nsIContentProcess.idl',
'nsIContentURIGrouper.idl',
'nsIDOMChromeWindow.idl',
'nsIDOMGlobalPropertyInitializer.idl',
- 'nsIDOMScreen.idl',
'nsIDOMWindow.idl',
'nsIDOMWindowCollection.idl',
'nsIDOMWindowUtils.idl',
'nsIFocusManager.idl',
'nsIIdleObserver.idl',
'nsIQueryContentEventResult.idl',
'nsIRemoteBrowser.idl',
'nsIServiceWorkerManager.idl',
deleted file mode 100644
--- a/dom/interfaces/base/nsIDOMScreen.idl
+++ /dev/null
@@ -1,16 +0,0 @@
-/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* 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/. */
-
-#include "nsIDOMEventTarget.idl"
-
-[builtinclass, uuid(82c7924b-4b46-4e5a-a8d2-6edb5fc0a60d)]
-interface nsIDOMScreen : nsIDOMEventTarget
-{
- readonly attribute long top;
- readonly attribute long availWidth;
- readonly attribute long availHeight;
- readonly attribute long availLeft;
- readonly attribute long availTop;
-};
--- a/layout/xul/nsMenuPopupFrame.cpp
+++ b/layout/xul/nsMenuPopupFrame.cpp
@@ -14,17 +14,16 @@
#include "nsNameSpaceManager.h"
#include "nsViewManager.h"
#include "nsWidgetsCID.h"
#include "nsMenuFrame.h"
#include "nsMenuBarFrame.h"
#include "nsPopupSetFrame.h"
#include "nsPIDOMWindow.h"
#include "nsIDOMEvent.h"
-#include "nsIDOMScreen.h"
#include "nsIDOMXULMenuListElement.h"
#include "nsIPresShell.h"
#include "nsFrameManager.h"
#include "nsIDocument.h"
#include "nsRect.h"
#include "nsIComponentManager.h"
#include "nsBoxLayoutState.h"
#include "nsIScrollableFrame.h"
--- a/xpcom/reflect/xptinfo/ShimInterfaceInfo.cpp
+++ b/xpcom/reflect/xptinfo/ShimInterfaceInfo.cpp
@@ -20,17 +20,16 @@
#include "nsIDOMEventTarget.h"
#include "nsIDOMGeoPositionError.h"
#include "nsIDOMHTMLInputElement.h"
#include "nsIDOMNode.h"
#include "nsIDOMNodeList.h"
#include "nsIDOMOfflineResourceList.h"
#include "nsIDOMParser.h"
#include "nsIDOMRange.h"
-#include "nsIDOMScreen.h"
#include "nsIDOMSerializer.h"
#include "nsIDOMXMLDocument.h"
#include "nsIDOMXULElement.h"
#include "nsIListBoxObject.h"
#include "nsIMessageManager.h"
#include "nsISelection.h"
#include "nsITreeBoxObject.h"
#include "nsIWebBrowserPersistable.h"
@@ -64,17 +63,16 @@
#include "mozilla/dom/NodeBinding.h"
#include "mozilla/dom/EventBinding.h"
#include "mozilla/dom/OfflineResourceListBinding.h"
#include "mozilla/dom/PositionErrorBinding.h"
#include "mozilla/dom/RangeBinding.h"
#ifdef MOZ_WEBRTC
#include "mozilla/dom/RTCDataChannelBinding.h"
#endif
-#include "mozilla/dom/ScreenBinding.h"
#include "mozilla/dom/SelectionBinding.h"
#include "mozilla/dom/StorageEventBinding.h"
#include "mozilla/dom/StyleSheetBinding.h"
#include "mozilla/dom/StyleSheetListBinding.h"
#include "mozilla/dom/SVGElementBinding.h"
#include "mozilla/dom/TimeEventBinding.h"
#include "mozilla/dom/TreeBoxObjectBinding.h"
#include "mozilla/dom/XMLDocumentBinding.h"
@@ -153,17 +151,16 @@ const ComponentsInterfaceShimEntry kComp
DEFINE_SHIM(NodeList),
DEFINE_SHIM(Node),
DEFINE_SHIM(OfflineResourceList),
DEFINE_SHIM_WITH_CUSTOM_INTERFACE(nsIDOMParser, DOMParser),
DEFINE_SHIM(Range),
#ifdef MOZ_WEBRTC
DEFINE_SHIM_WITH_CUSTOM_INTERFACE(nsIDOMDataChannel, RTCDataChannel),
#endif
- DEFINE_SHIM(Screen),
DEFINE_SHIM_WITH_CUSTOM_INTERFACE(nsIDOMSerializer, XMLSerializer),
DEFINE_SHIM_WITH_CUSTOM_INTERFACE(nsITreeBoxObject, TreeBoxObject),
DEFINE_SHIM_WITH_CUSTOM_INTERFACE(nsIWebBrowserPersistable, FrameLoader),
DEFINE_SHIM(XMLDocument),
DEFINE_SHIM(XULElement),
DEFINE_SHIM_WITH_CUSTOM_INTERFACE(nsISelection, Selection),
};
--- a/xpfe/appshell/nsXULWindow.cpp
+++ b/xpfe/appshell/nsXULWindow.cpp
@@ -15,26 +15,27 @@
#include "nsString.h"
#include "nsWidgetsCID.h"
#include "nsThreadUtils.h"
#include "nsNetCID.h"
#include "nsQueryObject.h"
#include "mozilla/Sprintf.h"
//Interfaces needed to be included
+#include "nsGlobalWindowOuter.h"
#include "nsIAppShell.h"
#include "nsIAppShellService.h"
#include "nsIServiceManager.h"
#include "nsIContentViewer.h"
#include "nsIDocument.h"
#include "nsIDOMDocument.h"
#include "nsIDOMElement.h"
#include "nsIDOMXULElement.h"
#include "nsPIDOMWindow.h"
-#include "nsIDOMScreen.h"
+#include "nsScreen.h"
#include "nsIEmbeddingSiteWindow.h"
#include "nsIInterfaceRequestor.h"
#include "nsIInterfaceRequestorUtils.h"
#include "nsIIOService.h"
#include "nsILoadContext.h"
#include "nsIObserverService.h"
#include "nsIWindowMediator.h"
#include "nsIScreenManager.h"
@@ -1023,33 +1024,35 @@ NS_IMETHODIMP nsXULWindow::EnsureAuthPro
if (wwatch)
wwatch->GetNewAuthPrompter(ourWindow, getter_AddRefs(mAuthPrompter));
}
return mAuthPrompter ? NS_OK : NS_ERROR_FAILURE;
}
NS_IMETHODIMP nsXULWindow::GetAvailScreenSize(int32_t* aAvailWidth, int32_t* aAvailHeight)
{
- nsresult rv;
-
nsCOMPtr<mozIDOMWindowProxy> domWindow;
GetWindowDOMWindow(getter_AddRefs(domWindow));
NS_ENSURE_STATE(domWindow);
- auto* window = nsPIDOMWindowOuter::From(domWindow);
- NS_ENSURE_STATE(window);
+ auto* window = nsGlobalWindowOuter::Cast(domWindow);
- nsCOMPtr<nsIDOMScreen> screen = window->GetScreen();
+ RefPtr<nsScreen> screen = window->GetScreen();
NS_ENSURE_STATE(screen);
- rv = screen->GetAvailWidth(aAvailWidth);
- NS_ENSURE_SUCCESS(rv, rv);
+ ErrorResult rv;
+ *aAvailWidth = screen->GetAvailWidth(rv);
+ if (NS_WARN_IF(rv.Failed())) {
+ return rv.StealNSResult();
+ }
- rv = screen->GetAvailHeight(aAvailHeight);
- NS_ENSURE_SUCCESS(rv, rv);
+ *aAvailHeight = screen->GetAvailHeight(rv);
+ if (NS_WARN_IF(rv.Failed())) {
+ return rv.StealNSResult();
+ }
return NS_OK;
}
// Rounds window size to 1000x1000, or, if there isn't enough available
// screen space, to a multiple of 200x100.
NS_IMETHODIMP nsXULWindow::ForceRoundedDimensions()
{