Bug 1973699, modernize nsDocShell accesses a bit, a=RyanVM DONTBUILD

Original Revision: https://phabricator.services.mozilla.com/D265021

Differential Revision: https://phabricator.services.mozilla.com/D266239
This commit is contained in:
Olli Pettay
2025-09-26 14:47:41 +00:00
committed by rvandermeulen@mozilla.com
parent d01e2df606
commit 312d909cd8
4 changed files with 11 additions and 9 deletions

View File

@@ -131,7 +131,7 @@ nsDSURIContentListener::DoContent(const nsACString& aContentType,
nsresult rv; nsresult rv;
NS_ENSURE_ARG_POINTER(aContentHandler); NS_ENSURE_ARG_POINTER(aContentHandler);
NS_ENSURE_TRUE(mDocShell, NS_ERROR_FAILURE); NS_ENSURE_TRUE(mDocShell, NS_ERROR_FAILURE);
RefPtr<nsDocShell> docShell = mDocShell; RefPtr<nsDocShell> docShell = mDocShell.get();
*aAbortProcess = false; *aAbortProcess = false;

View File

@@ -11,8 +11,9 @@
#include "nsIURIContentListener.h" #include "nsIURIContentListener.h"
#include "nsWeakReference.h" #include "nsWeakReference.h"
#include "nsITimer.h" #include "nsITimer.h"
#include "mozilla/WeakPtr.h"
#include "nsDocShell.h"
class nsDocShell;
class nsIInterfaceRequestor; class nsIInterfaceRequestor;
class nsIWebNavigationInfo; class nsIWebNavigationInfo;
class nsPIDOMWindowOuter; class nsPIDOMWindowOuter;
@@ -85,7 +86,7 @@ class nsDSURIContentListener final : public nsIURIContentListener,
} }
protected: protected:
nsDocShell* mDocShell; mozilla::MainThreadWeakPtr<nsDocShell> mDocShell;
// Hack to handle multipart images without creating a new viewer // Hack to handle multipart images without creating a new viewer
nsCOMPtr<nsIStreamListener> mExistingJPEGStreamListener; nsCOMPtr<nsIStreamListener> mExistingJPEGStreamListener;
nsCOMPtr<nsIChannel> mExistingJPEGRequest; nsCOMPtr<nsIChannel> mExistingJPEGRequest;

View File

@@ -17,7 +17,7 @@
using namespace mozilla; using namespace mozilla;
using namespace mozilla::dom; using namespace mozilla::dom;
nsDocShellEditorData::nsDocShellEditorData(nsIDocShell* aOwningDocShell) nsDocShellEditorData::nsDocShellEditorData(nsDocShell* aOwningDocShell)
: mDocShell(aOwningDocShell), : mDocShell(aOwningDocShell),
mDetachedEditingState(Document::EditingState::eOff), mDetachedEditingState(Document::EditingState::eOff),
mMakeEditable(false), mMakeEditable(false),
@@ -121,7 +121,7 @@ nsresult nsDocShellEditorData::DetachFromWindow() {
return NS_OK; return NS_OK;
} }
nsresult nsDocShellEditorData::ReattachToWindow(nsIDocShell* aDocShell) { nsresult nsDocShellEditorData::ReattachToWindow(nsDocShell* aDocShell) {
mDocShell = aDocShell; mDocShell = aDocShell;
nsCOMPtr<nsPIDOMWindowOuter> domWindow = nsCOMPtr<nsPIDOMWindowOuter> domWindow =

View File

@@ -12,8 +12,9 @@
#include "mozilla/RefPtr.h" #include "mozilla/RefPtr.h"
#include "mozilla/dom/Document.h" #include "mozilla/dom/Document.h"
#include "mozilla/WeakPtr.h"
#include "nsDocShell.h"
class nsIDocShell;
class nsEditingSession; class nsEditingSession;
namespace mozilla { namespace mozilla {
@@ -22,7 +23,7 @@ class HTMLEditor;
class nsDocShellEditorData { class nsDocShellEditorData {
public: public:
explicit nsDocShellEditorData(nsIDocShell* aOwningDocShell); explicit nsDocShellEditorData(nsDocShell* aOwningDocShell);
~nsDocShellEditorData(); ~nsDocShellEditorData();
MOZ_CAN_RUN_SCRIPT_BOUNDARY nsresult MakeEditable(bool aWaitForUriLoad); MOZ_CAN_RUN_SCRIPT_BOUNDARY nsresult MakeEditable(bool aWaitForUriLoad);
@@ -33,14 +34,14 @@ class nsDocShellEditorData {
SetHTMLEditor(mozilla::HTMLEditor* aHTMLEditor); SetHTMLEditor(mozilla::HTMLEditor* aHTMLEditor);
MOZ_CAN_RUN_SCRIPT_BOUNDARY void TearDownEditor(); MOZ_CAN_RUN_SCRIPT_BOUNDARY void TearDownEditor();
nsresult DetachFromWindow(); nsresult DetachFromWindow();
nsresult ReattachToWindow(nsIDocShell* aDocShell); nsresult ReattachToWindow(nsDocShell* aDocShell);
bool WaitingForLoad() const { return mMakeEditable; } bool WaitingForLoad() const { return mMakeEditable; }
protected: protected:
void EnsureEditingSession(); void EnsureEditingSession();
// The doc shell that owns us. Weak ref, since it always outlives us. // The doc shell that owns us. Weak ref, since it always outlives us.
nsIDocShell* mDocShell; mozilla::WeakPtr<nsDocShell> mDocShell;
// Only present for the content root docShell. Session is owned here. // Only present for the content root docShell. Session is owned here.
RefPtr<nsEditingSession> mEditingSession; RefPtr<nsEditingSession> mEditingSession;