Bug 1476145 part 1. Add a getter to get the nsIDOMWindowUtils from a window. r=nika

The new attribute is not [Cached] because we would need to bump
JSCLASS_GLOBAL_APPLICATION_SLOTS for that and it's not obvious that we should do
that.
This commit is contained in:
Boris Zbarsky 2018-07-24 19:47:40 -04:00
Родитель 0ebdcdbf60
Коммит 575eb424f0
6 изменённых файлов: 31 добавлений и 9 удалений

Просмотреть файл

@ -2400,6 +2400,12 @@ nsGlobalWindowInner::GetInstallTrigger()
return do_AddRef(mInstallTrigger);
}
nsIDOMWindowUtils*
nsGlobalWindowInner::GetWindowUtils(ErrorResult& aRv)
{
FORWARD_TO_OUTER_OR_THROW(WindowUtils, (), aRv, nullptr);
}
nsGlobalWindowInner::CallState
nsGlobalWindowInner::ShouldReportForServiceWorkerScopeInternal(const nsACString& aScope,
bool* aResultOut)

Просмотреть файл

@ -64,6 +64,7 @@ class nsIBaseWindow;
class nsIContent;
class nsICSSDeclaration;
class nsIDocShellTreeOwner;
class nsIDOMWindowUtils;
class nsDOMOfflineResourceList;
class nsIScrollableFrame;
class nsIControllers;
@ -987,6 +988,8 @@ public:
already_AddRefed<mozilla::dom::InstallTriggerImpl> GetInstallTrigger();
nsIDOMWindowUtils* GetWindowUtils(mozilla::ErrorResult& aRv);
void UpdateTopInnerWindow();
virtual bool IsInSyncOperation() override

Просмотреть файл

@ -6818,15 +6818,8 @@ nsGlobalWindowOuter::GetInterfaceInternal(const nsIID& aIID, void** aSink)
}
#endif
else if (aIID.Equals(NS_GET_IID(nsIDOMWindowUtils))) {
nsGlobalWindowOuter* outer = GetOuterWindowInternal();
NS_ENSURE_TRUE(outer, NS_ERROR_NOT_INITIALIZED);
if (!mWindowUtils) {
mWindowUtils = new nsDOMWindowUtils(outer);
}
*aSink = mWindowUtils;
NS_ADDREF(((nsISupports *) *aSink));
nsCOMPtr<nsIDOMWindowUtils> utils = WindowUtils();
utils.forget(aSink);
}
else if (aIID.Equals(NS_GET_IID(nsILoadContext))) {
nsGlobalWindowOuter* outer = GetOuterWindowInternal();
@ -7391,6 +7384,15 @@ nsGlobalWindowOuter::GetWindowRootOuter()
return root.forget().downcast<nsWindowRoot>();
}
nsIDOMWindowUtils*
nsGlobalWindowOuter::WindowUtils()
{
if (!mWindowUtils) {
mWindowUtils = new nsDOMWindowUtils(this);
}
return mWindowUtils;
}
//Note: This call will lock the cursor, it will not change as it moves.
//To unlock, the cursor must be set back to CURSOR_AUTO.
void

Просмотреть файл

@ -61,6 +61,7 @@ class nsIBaseWindow;
class nsIContent;
class nsICSSDeclaration;
class nsIDocShellTreeOwner;
class nsIDOMWindowUtils;
class nsIScrollableFrame;
class nsIControllers;
class nsIJSID;
@ -740,6 +741,8 @@ public:
already_AddRefed<nsWindowRoot> GetWindowRootOuter();
nsIDOMWindowUtils* WindowUtils();
virtual bool IsInSyncOperation() override
{
return GetExtantDoc() && GetExtantDoc()->IsInSyncOperation();

Просмотреть файл

@ -1833,6 +1833,7 @@ addExternalIface('MozTreeView', nativeType='nsITreeView',
addExternalIface('MozWakeLockListener', headerFile='nsIDOMWakeLockListener.h')
addExternalIface('nsIBrowserDOMWindow', nativeType='nsIBrowserDOMWindow',
notflattened=True)
addExternalIface('nsIDOMWindowUtils', nativeType='nsIDOMWindowUtils', notflattened=True)
addExternalIface('nsIEventTarget', nativeType='nsIEventTarget', notflattened=True)
addExternalIface('nsIFile', nativeType='nsIFile', notflattened=True)
addExternalIface('nsILoadGroup', nativeType='nsILoadGroup',

Просмотреть файл

@ -21,6 +21,7 @@
interface IID;
interface nsIBrowserDOMWindow;
interface XULControllers;
interface nsIDOMWindowUtils;
typedef OfflineResourceList ApplicationCache;
@ -357,6 +358,12 @@ partial interface Window {
*/
[Replaceable]
readonly attribute InstallTriggerImpl? InstallTrigger;
/**
* Get the nsIDOMWindowUtils for this window.
*/
[Constant, Throws, ChromeOnly]
readonly attribute nsIDOMWindowUtils windowUtils;
};
Window implements TouchEventHandlers;