@@ -126,7 +126,7 @@ nsEditingSession::MakeWindowEditable(mozIDOMWindowProxy* aWindow,
126126
127127 nsresult rv;
128128 if (!mInteractive ) {
129- rv = DisableJSAndPlugins (aWindow );
129+ rv = DisableJSAndPlugins (*docShell );
130130 NS_ENSURE_SUCCESS (rv, rv);
131131 }
132132
@@ -178,42 +178,39 @@ nsEditingSession::MakeWindowEditable(mozIDOMWindowProxy* aWindow,
178178 return rv;
179179}
180180
181- NS_IMETHODIMP
182- nsEditingSession::DisableJSAndPlugins (mozIDOMWindowProxy* aWindow) {
183- NS_ENSURE_TRUE (aWindow, NS_ERROR_FAILURE);
184- nsIDocShell* docShell = nsPIDOMWindowOuter::From (aWindow)->GetDocShell ();
185- NS_ENSURE_TRUE (docShell, NS_ERROR_FAILURE);
186-
181+ nsresult nsEditingSession::DisableJSAndPlugins (nsIDocShell& aDocShell) {
187182 bool tmp;
188- nsresult rv = docShell-> GetAllowJavascript (&tmp);
183+ nsresult rv = aDocShell. GetAllowJavascript (&tmp);
189184 NS_ENSURE_SUCCESS (rv, rv);
190185
191186 mScriptsEnabled = tmp;
192187
193- rv = docShell-> SetAllowJavascript (false );
188+ rv = aDocShell. SetAllowJavascript (false );
194189 NS_ENSURE_SUCCESS (rv, rv);
195190
196191 // Disable plugins in this document:
197- mPluginsEnabled = docShell-> PluginsAllowedInCurrentDoc ();
192+ mPluginsEnabled = aDocShell. PluginsAllowedInCurrentDoc ();
198193
199- rv = docShell-> SetAllowPlugins (false );
194+ rv = aDocShell. SetAllowPlugins (false );
200195 NS_ENSURE_SUCCESS (rv, rv);
201196
202197 mDisabledJSAndPlugins = true ;
203198
204199 return NS_OK;
205200}
206201
207- NS_IMETHODIMP
208- nsEditingSession::RestoreJSAndPlugins (mozIDOMWindowProxy* aWindow) {
202+ nsresult nsEditingSession::RestoreJSAndPlugins (nsPIDOMWindowOuter* aWindow) {
209203 if (!mDisabledJSAndPlugins ) {
210204 return NS_OK;
211205 }
212206
213207 mDisabledJSAndPlugins = false ;
214208
215- NS_ENSURE_TRUE (aWindow, NS_ERROR_FAILURE);
216- nsIDocShell* docShell = nsPIDOMWindowOuter::From (aWindow)->GetDocShell ();
209+ if (NS_WARN_IF(!aWindow)) {
210+ // DetachFromWindow may call this method with nullptr.
211+ return NS_ERROR_FAILURE;
212+ }
213+ nsIDocShell* docShell = aWindow->GetDocShell ();
217214 NS_ENSURE_TRUE (docShell, NS_ERROR_FAILURE);
218215
219216 nsresult rv = docShell->SetAllowJavascript (mScriptsEnabled );
@@ -223,13 +220,6 @@ nsEditingSession::RestoreJSAndPlugins(mozIDOMWindowProxy* aWindow) {
223220 return docShell->SetAllowPlugins (mPluginsEnabled );
224221}
225222
226- NS_IMETHODIMP
227- nsEditingSession::GetJsAndPluginsDisabled (bool * aResult) {
228- NS_ENSURE_ARG_POINTER (aResult);
229- *aResult = mDisabledJSAndPlugins ;
230- return NS_OK;
231- }
232-
233223/* ---------------------------------------------------------------------------
234224
235225 WindowIsEditable
@@ -541,7 +531,7 @@ nsEditingSession::TearDownEditorOnWindow(mozIDOMWindowProxy* aWindow) {
541531
542532 if (stopEditing) {
543533 // Make things the way they were before we started editing.
544- RestoreJSAndPlugins (aWindow );
534+ RestoreJSAndPlugins (window );
545535 RestoreAnimationMode (window);
546536
547537 if (mMakeWholeDocumentEditable ) {
@@ -1239,7 +1229,7 @@ nsresult nsEditingSession::DetachFromWindow(mozIDOMWindowProxy* aWindow) {
12391229 // make things the way they were before we started editing.
12401230 RemoveEditorControllers (window);
12411231 RemoveWebProgressListener (window);
1242- RestoreJSAndPlugins (aWindow );
1232+ RestoreJSAndPlugins (window );
12431233 RestoreAnimationMode (window);
12441234
12451235 // Kill our weak reference to our original window, in case
@@ -1267,7 +1257,7 @@ nsresult nsEditingSession::ReattachToWindow(mozIDOMWindowProxy* aWindow) {
12671257
12681258 // Disable plugins.
12691259 if (!mInteractive ) {
1270- rv = DisableJSAndPlugins (aWindow );
1260+ rv = DisableJSAndPlugins (*docShell );
12711261 NS_ENSURE_SUCCESS (rv, rv);
12721262 }
12731263
0 commit comments