@@ -126,7 +126,7 @@ nsEditingSession::MakeWindowEditable(mozIDOMWindowProxy* aWindow,
126
126
127
127
nsresult rv;
128
128
if (!mInteractive ) {
129
- rv = DisableJSAndPlugins (aWindow );
129
+ rv = DisableJSAndPlugins (*docShell );
130
130
NS_ENSURE_SUCCESS (rv, rv);
131
131
}
132
132
@@ -178,42 +178,39 @@ nsEditingSession::MakeWindowEditable(mozIDOMWindowProxy* aWindow,
178
178
return rv;
179
179
}
180
180
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) {
187
182
bool tmp;
188
- nsresult rv = docShell-> GetAllowJavascript (&tmp);
183
+ nsresult rv = aDocShell. GetAllowJavascript (&tmp);
189
184
NS_ENSURE_SUCCESS (rv, rv);
190
185
191
186
mScriptsEnabled = tmp;
192
187
193
- rv = docShell-> SetAllowJavascript (false );
188
+ rv = aDocShell. SetAllowJavascript (false );
194
189
NS_ENSURE_SUCCESS (rv, rv);
195
190
196
191
// Disable plugins in this document:
197
- mPluginsEnabled = docShell-> PluginsAllowedInCurrentDoc ();
192
+ mPluginsEnabled = aDocShell. PluginsAllowedInCurrentDoc ();
198
193
199
- rv = docShell-> SetAllowPlugins (false );
194
+ rv = aDocShell. SetAllowPlugins (false );
200
195
NS_ENSURE_SUCCESS (rv, rv);
201
196
202
197
mDisabledJSAndPlugins = true ;
203
198
204
199
return NS_OK;
205
200
}
206
201
207
- NS_IMETHODIMP
208
- nsEditingSession::RestoreJSAndPlugins (mozIDOMWindowProxy* aWindow) {
202
+ nsresult nsEditingSession::RestoreJSAndPlugins (nsPIDOMWindowOuter* aWindow) {
209
203
if (!mDisabledJSAndPlugins ) {
210
204
return NS_OK;
211
205
}
212
206
213
207
mDisabledJSAndPlugins = false ;
214
208
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 ();
217
214
NS_ENSURE_TRUE (docShell, NS_ERROR_FAILURE);
218
215
219
216
nsresult rv = docShell->SetAllowJavascript (mScriptsEnabled );
@@ -223,13 +220,6 @@ nsEditingSession::RestoreJSAndPlugins(mozIDOMWindowProxy* aWindow) {
223
220
return docShell->SetAllowPlugins (mPluginsEnabled );
224
221
}
225
222
226
- NS_IMETHODIMP
227
- nsEditingSession::GetJsAndPluginsDisabled (bool * aResult) {
228
- NS_ENSURE_ARG_POINTER (aResult);
229
- *aResult = mDisabledJSAndPlugins ;
230
- return NS_OK;
231
- }
232
-
233
223
/* ---------------------------------------------------------------------------
234
224
235
225
WindowIsEditable
@@ -541,7 +531,7 @@ nsEditingSession::TearDownEditorOnWindow(mozIDOMWindowProxy* aWindow) {
541
531
542
532
if (stopEditing) {
543
533
// Make things the way they were before we started editing.
544
- RestoreJSAndPlugins (aWindow );
534
+ RestoreJSAndPlugins (window );
545
535
RestoreAnimationMode (window);
546
536
547
537
if (mMakeWholeDocumentEditable ) {
@@ -1239,7 +1229,7 @@ nsresult nsEditingSession::DetachFromWindow(mozIDOMWindowProxy* aWindow) {
1239
1229
// make things the way they were before we started editing.
1240
1230
RemoveEditorControllers (window);
1241
1231
RemoveWebProgressListener (window);
1242
- RestoreJSAndPlugins (aWindow );
1232
+ RestoreJSAndPlugins (window );
1243
1233
RestoreAnimationMode (window);
1244
1234
1245
1235
// Kill our weak reference to our original window, in case
@@ -1267,7 +1257,7 @@ nsresult nsEditingSession::ReattachToWindow(mozIDOMWindowProxy* aWindow) {
1267
1257
1268
1258
// Disable plugins.
1269
1259
if (!mInteractive ) {
1270
- rv = DisableJSAndPlugins (aWindow );
1260
+ rv = DisableJSAndPlugins (*docShell );
1271
1261
NS_ENSURE_SUCCESS (rv, rv);
1272
1262
}
1273
1263
0 commit comments