mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-10 03:45:46 +00:00
Bug 1533250 - Remove *JSAndPlugins* methods from nsIEditingSession. r=masayuki
Firefox, comm-central and bluegriffon don't use `*JSAndPlugin*` methods of `nsIEditingSession` from script. Let's remove or move to `nsEditingSession`. Differential Revision: https://phabricator.services.mozilla.com/D22465 --HG-- extra : rebase_source : 256fb4025fe8c6f5a61d5b015af942ff65759c23
This commit is contained in:
parent
d348fe8fc5
commit
ba8662db5b
@ -126,7 +126,7 @@ nsEditingSession::MakeWindowEditable(mozIDOMWindowProxy* aWindow,
|
||||
|
||||
nsresult rv;
|
||||
if (!mInteractive) {
|
||||
rv = DisableJSAndPlugins(aWindow);
|
||||
rv = DisableJSAndPlugins(*docShell);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
@ -178,25 +178,20 @@ nsEditingSession::MakeWindowEditable(mozIDOMWindowProxy* aWindow,
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsEditingSession::DisableJSAndPlugins(mozIDOMWindowProxy* aWindow) {
|
||||
NS_ENSURE_TRUE(aWindow, NS_ERROR_FAILURE);
|
||||
nsIDocShell* docShell = nsPIDOMWindowOuter::From(aWindow)->GetDocShell();
|
||||
NS_ENSURE_TRUE(docShell, NS_ERROR_FAILURE);
|
||||
|
||||
nsresult nsEditingSession::DisableJSAndPlugins(nsIDocShell& aDocShell) {
|
||||
bool tmp;
|
||||
nsresult rv = docShell->GetAllowJavascript(&tmp);
|
||||
nsresult rv = aDocShell.GetAllowJavascript(&tmp);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
mScriptsEnabled = tmp;
|
||||
|
||||
rv = docShell->SetAllowJavascript(false);
|
||||
rv = aDocShell.SetAllowJavascript(false);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Disable plugins in this document:
|
||||
mPluginsEnabled = docShell->PluginsAllowedInCurrentDoc();
|
||||
mPluginsEnabled = aDocShell.PluginsAllowedInCurrentDoc();
|
||||
|
||||
rv = docShell->SetAllowPlugins(false);
|
||||
rv = aDocShell.SetAllowPlugins(false);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
mDisabledJSAndPlugins = true;
|
||||
@ -204,16 +199,18 @@ nsEditingSession::DisableJSAndPlugins(mozIDOMWindowProxy* aWindow) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsEditingSession::RestoreJSAndPlugins(mozIDOMWindowProxy* aWindow) {
|
||||
nsresult nsEditingSession::RestoreJSAndPlugins(nsPIDOMWindowOuter* aWindow) {
|
||||
if (!mDisabledJSAndPlugins) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
mDisabledJSAndPlugins = false;
|
||||
|
||||
NS_ENSURE_TRUE(aWindow, NS_ERROR_FAILURE);
|
||||
nsIDocShell* docShell = nsPIDOMWindowOuter::From(aWindow)->GetDocShell();
|
||||
if (NS_WARN_IF(!aWindow)) {
|
||||
// DetachFromWindow may call this method with nullptr.
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
nsIDocShell* docShell = aWindow->GetDocShell();
|
||||
NS_ENSURE_TRUE(docShell, NS_ERROR_FAILURE);
|
||||
|
||||
nsresult rv = docShell->SetAllowJavascript(mScriptsEnabled);
|
||||
@ -223,13 +220,6 @@ nsEditingSession::RestoreJSAndPlugins(mozIDOMWindowProxy* aWindow) {
|
||||
return docShell->SetAllowPlugins(mPluginsEnabled);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsEditingSession::GetJsAndPluginsDisabled(bool* aResult) {
|
||||
NS_ENSURE_ARG_POINTER(aResult);
|
||||
*aResult = mDisabledJSAndPlugins;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
|
||||
WindowIsEditable
|
||||
@ -541,7 +531,7 @@ nsEditingSession::TearDownEditorOnWindow(mozIDOMWindowProxy* aWindow) {
|
||||
|
||||
if (stopEditing) {
|
||||
// Make things the way they were before we started editing.
|
||||
RestoreJSAndPlugins(aWindow);
|
||||
RestoreJSAndPlugins(window);
|
||||
RestoreAnimationMode(window);
|
||||
|
||||
if (mMakeWholeDocumentEditable) {
|
||||
@ -1239,7 +1229,7 @@ nsresult nsEditingSession::DetachFromWindow(mozIDOMWindowProxy* aWindow) {
|
||||
// make things the way they were before we started editing.
|
||||
RemoveEditorControllers(window);
|
||||
RemoveWebProgressListener(window);
|
||||
RestoreJSAndPlugins(aWindow);
|
||||
RestoreJSAndPlugins(window);
|
||||
RestoreAnimationMode(window);
|
||||
|
||||
// Kill our weak reference to our original window, in case
|
||||
@ -1267,7 +1257,7 @@ nsresult nsEditingSession::ReattachToWindow(mozIDOMWindowProxy* aWindow) {
|
||||
|
||||
// Disable plugins.
|
||||
if (!mInteractive) {
|
||||
rv = DisableJSAndPlugins(aWindow);
|
||||
rv = DisableJSAndPlugins(*docShell);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
|
@ -86,6 +86,17 @@ class nsEditingSession final : public nsIEditingSession,
|
||||
void RemoveListenersAndControllers(nsPIDOMWindowOuter* aWindow,
|
||||
mozilla::HTMLEditor* aHTMLEditor);
|
||||
|
||||
/**
|
||||
* Disable scripts and plugins in aDocShell.
|
||||
*/
|
||||
nsresult DisableJSAndPlugins(nsIDocShell& aDocShell);
|
||||
|
||||
/**
|
||||
* Restore JS and plugins (enable/disable them) according to the state they
|
||||
* were before the last call to disableJSAndPlugins.
|
||||
*/
|
||||
nsresult RestoreJSAndPlugins(nsPIDOMWindowOuter* aWindow);
|
||||
|
||||
protected:
|
||||
bool mDoneSetup; // have we prepared for editing yet?
|
||||
|
||||
|
@ -80,17 +80,6 @@ interface nsIEditingSession : nsISupports
|
||||
void setEditorOnControllers(in mozIDOMWindowProxy aWindow,
|
||||
in nsIEditor aEditor);
|
||||
|
||||
/**
|
||||
* Disable scripts and plugins in aWindow.
|
||||
*/
|
||||
void disableJSAndPlugins(in mozIDOMWindowProxy aWindow);
|
||||
|
||||
/**
|
||||
* Restore JS and plugins (enable/disable them) according to the state they
|
||||
* were before the last call to disableJSAndPlugins.
|
||||
*/
|
||||
void restoreJSAndPlugins(in mozIDOMWindowProxy aWindow);
|
||||
|
||||
/**
|
||||
* Removes all the editor's controllers/listeners etc and makes the window
|
||||
* uneditable.
|
||||
@ -103,11 +92,6 @@ interface nsIEditingSession : nsISupports
|
||||
*/
|
||||
void reattachToWindow(in mozIDOMWindowProxy aWindow);
|
||||
|
||||
/**
|
||||
* Whether this session has disabled JS and plugins.
|
||||
*/
|
||||
readonly attribute boolean jsAndPluginsDisabled;
|
||||
|
||||
%{C++
|
||||
/**
|
||||
* This method is implemented with nsIDocShell::GetHTMLEditor(). I.e.,
|
||||
|
Loading…
Reference in New Issue
Block a user