Bug 1571066: Return WindowProxyHolder from nsDocShell::GetWindowProxy. r=peterv
authorKris Maglione <maglione.k@gmail.com>
Tue, 12 Nov 2019 08:32:09 +0000
changeset 501660 4ebefd304d2f40a91c9d595e750d5ec8372bfc6a
parent 501659 79b526e185ec5e0d70c7888b98e5a85e55c353f1
child 501661 452480b6db9cbf3b3125274898337425f1286b8c
push id114172
push userdluca@mozilla.com
push dateTue, 19 Nov 2019 11:31:10 +0000
treeherdermozilla-inbound@b5c5ba07d3db [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspeterv
bugs1571066
milestone72.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1571066: Return WindowProxyHolder from nsDocShell::GetWindowProxy. r=peterv Returning BrowsingContext* from these sorts of getters tends to lead to misuse. WindowProxyHolder is the semantically correct type to return here, in any case. Differential Revision: https://phabricator.services.mozilla.com/D52096
docshell/base/nsDocShell.h
dom/xul/XULFrameElement.cpp
--- a/docshell/base/nsDocShell.h
+++ b/docshell/base/nsDocShell.h
@@ -16,16 +16,17 @@
 #include "mozilla/TimeStamp.h"
 #include "mozilla/UniquePtr.h"
 #include "mozilla/WeakPtr.h"
 
 #include "mozilla/dom/BrowsingContext.h"
 #include "mozilla/dom/ProfileTimelineMarkerBinding.h"
 #include "mozilla/gfx/Matrix.h"
 #include "mozilla/dom/ChildSHistory.h"
+#include "mozilla/dom/WindowProxyHolder.h"
 
 #include "nsIAuthPromptProvider.h"
 #include "nsIBaseWindow.h"
 #include "nsIDeprecationWarner.h"
 #include "nsIDocShell.h"
 #include "nsIDocShellTreeItem.h"
 #include "nsIDOMStorageManager.h"
 #include "nsIInterfaceRequestor.h"
@@ -443,19 +444,19 @@ class nsDocShell final : public nsDocLoa
   static nsDocShell* Cast(nsIDocShell* aDocShell) {
     return static_cast<nsDocShell*>(aDocShell);
   }
 
   // Returns true if the current load is a force reload (started by holding
   // shift while triggering reload)
   bool IsForceReloading();
 
-  mozilla::dom::BrowsingContext* GetWindowProxy() {
+  mozilla::dom::WindowProxyHolder GetWindowProxy() {
     EnsureScriptEnvironment();
-    return mBrowsingContext;
+    return mozilla::dom::WindowProxyHolder(mBrowsingContext);
   }
 
   /**
    * Loads the given URI. See comments on nsDocShellLoadState members for more
    * information on information used. aDocShell and aRequest come from
    * onLinkClickSync, which is triggered during form submission.
    */
   MOZ_CAN_RUN_SCRIPT_BOUNDARY
--- a/dom/xul/XULFrameElement.cpp
+++ b/dom/xul/XULFrameElement.cpp
@@ -47,17 +47,17 @@ already_AddRefed<nsIWebNavigation> XULFr
   nsCOMPtr<nsIDocShell> docShell = GetDocShell();
   nsCOMPtr<nsIWebNavigation> webnav = do_QueryInterface(docShell);
   return webnav.forget();
 }
 
 Nullable<WindowProxyHolder> XULFrameElement::GetContentWindow() {
   RefPtr<nsDocShell> docShell = GetDocShell();
   if (docShell) {
-    return WindowProxyHolder(docShell->GetWindowProxy());
+    return docShell->GetWindowProxy();
   }
 
   return nullptr;
 }
 
 Document* XULFrameElement::GetContentDocument() {
   nsCOMPtr<nsIDocShell> docShell = GetDocShell();
   if (docShell) {