зеркало из https://github.com/mozilla/gecko-dev.git
Bug 283149 Move from nsIScriptGlobalObject to nsIDocShell for disabling JS
r=brade sr=jst
This commit is contained in:
Родитель
d5e48ee741
Коммит
2133c9daa7
|
@ -40,6 +40,7 @@
|
||||||
* ***** END LICENSE BLOCK ***** */
|
* ***** END LICENSE BLOCK ***** */
|
||||||
|
|
||||||
#include "nsIDOMWindow.h"
|
#include "nsIDOMWindow.h"
|
||||||
|
#include "nsIDOMWindowUtils.h"
|
||||||
#include "nsIDOMWindowInternal.h"
|
#include "nsIDOMWindowInternal.h"
|
||||||
#include "nsIDOMNSHTMLDocument.h"
|
#include "nsIDOMNSHTMLDocument.h"
|
||||||
#include "nsIDocument.h"
|
#include "nsIDocument.h"
|
||||||
|
@ -153,15 +154,13 @@ nsEditingSession::MakeWindowEditable(nsIDOMWindow *aWindow,
|
||||||
if (NS_FAILED(rv)) return rv;
|
if (NS_FAILED(rv)) return rv;
|
||||||
|
|
||||||
// Disable JavaScript in this document:
|
// Disable JavaScript in this document:
|
||||||
nsCOMPtr<nsIScriptGlobalObject> sgo (do_QueryInterface(aWindow));
|
PRBool scriptsEnabled;
|
||||||
if (sgo)
|
rv = docShell->GetAllowJavascript(&scriptsEnabled);
|
||||||
{
|
if (NS_FAILED(rv)) return rv;
|
||||||
nsIScriptContext *scriptContext = sgo->GetContext();
|
mScriptsEnabled = scriptsEnabled;
|
||||||
if (scriptContext)
|
if (scriptsEnabled) {
|
||||||
{
|
rv = docShell->SetAllowJavascript(PR_FALSE);
|
||||||
mScriptsEnabled = scriptContext->GetScriptsEnabled();
|
if (NS_FAILED(rv)) return rv;
|
||||||
scriptContext->SetScriptsEnabled(PR_FALSE, PR_TRUE);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Always remove existing editor
|
// Always remove existing editor
|
||||||
|
@ -379,23 +378,18 @@ nsEditingSession::SetupEditorOnWindow(nsIDOMWindow *aWindow)
|
||||||
|
|
||||||
// Flush out frame construction to make sure that the subframe's
|
// Flush out frame construction to make sure that the subframe's
|
||||||
// presshell is set up if it needs to be.
|
// presshell is set up if it needs to be.
|
||||||
// XXXbz we really shouldn't need a presShell/presContext here!
|
|
||||||
nsCOMPtr<nsIDocument> document(do_QueryInterface(doc));
|
nsCOMPtr<nsIDocument> document(do_QueryInterface(doc));
|
||||||
if (document) {
|
if (document) {
|
||||||
document->FlushPendingNotifications(Flush_Frames);
|
document->FlushPendingNotifications(Flush_Frames);
|
||||||
}
|
}
|
||||||
|
|
||||||
nsCOMPtr<nsIPresShell> presShell;
|
|
||||||
rv = docShell->GetPresShell(getter_AddRefs(presShell));
|
|
||||||
if (NS_FAILED(rv)) return rv;
|
|
||||||
if (!presShell) return NS_ERROR_FAILURE;
|
|
||||||
|
|
||||||
// Disable animation of images in this document:
|
// Disable animation of images in this document:
|
||||||
nsPresContext *presContext = presShell->GetPresContext();
|
nsCOMPtr<nsIDOMWindowUtils> utils(do_QueryInterface(aWindow));
|
||||||
if (!presContext) return NS_ERROR_FAILURE;
|
if (!utils) return NS_ERROR_FAILURE;
|
||||||
|
|
||||||
mImageAnimationMode = presContext->ImageAnimationMode();
|
rv = utils->GetImageAnimationMode(&mImageAnimationMode);
|
||||||
presContext->SetImageAnimationMode(imgIContainer::kDontAnimMode);
|
if (NS_FAILED(rv)) return rv;
|
||||||
|
utils->SetImageAnimationMode(imgIContainer::kDontAnimMode);
|
||||||
|
|
||||||
// create and set editor
|
// create and set editor
|
||||||
nsCOMPtr<nsIEditorDocShell> editorDocShell = do_QueryInterface(docShell, &rv);
|
nsCOMPtr<nsIEditorDocShell> editorDocShell = do_QueryInterface(docShell, &rv);
|
||||||
|
@ -437,6 +431,12 @@ nsEditingSession::SetupEditorOnWindow(nsIDOMWindow *aWindow)
|
||||||
NS_STATIC_CAST(nsIDocumentStateListener*, stateMaintainer));
|
NS_STATIC_CAST(nsIDocumentStateListener*, stateMaintainer));
|
||||||
if (NS_FAILED(rv)) return rv;
|
if (NS_FAILED(rv)) return rv;
|
||||||
|
|
||||||
|
// XXXbz we really shouldn't need a presShell here!
|
||||||
|
nsCOMPtr<nsIPresShell> presShell;
|
||||||
|
rv = docShell->GetPresShell(getter_AddRefs(presShell));
|
||||||
|
if (NS_FAILED(rv)) return rv;
|
||||||
|
if (!presShell) return NS_ERROR_FAILURE;
|
||||||
|
|
||||||
nsCOMPtr<nsISelectionController> selCon = do_QueryInterface(presShell);
|
nsCOMPtr<nsISelectionController> selCon = do_QueryInterface(presShell);
|
||||||
rv = editor->Init(domDoc, presShell, nsnull /* root content */,
|
rv = editor->Init(domDoc, presShell, nsnull /* root content */,
|
||||||
selCon, mEditorFlags);
|
selCon, mEditorFlags);
|
||||||
|
@ -611,26 +611,14 @@ nsEditingSession::TearDownEditorOnWindow(nsIDOMWindow *aWindow)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make things the way they were before we started editing.
|
// Make things the way they were before we started editing.
|
||||||
nsCOMPtr<nsIScriptGlobalObject> sgo(do_QueryInterface(aWindow));
|
if (mScriptsEnabled) {
|
||||||
|
docShell->SetAllowJavascript(PR_TRUE);
|
||||||
if (sgo) {
|
|
||||||
nsIScriptContext *scriptContext = sgo->GetContext();
|
|
||||||
|
|
||||||
if (mScriptsEnabled && scriptContext)
|
|
||||||
{
|
|
||||||
scriptContext->SetScriptsEnabled(PR_TRUE, PR_TRUE);
|
|
||||||
}
|
|
||||||
|
|
||||||
nsCOMPtr<nsIPresShell> presShell;
|
|
||||||
nsIDocShell *docShell = sgo->GetDocShell();
|
|
||||||
docShell->GetPresShell(getter_AddRefs(presShell));
|
|
||||||
|
|
||||||
nsPresContext *presContext;
|
|
||||||
if (presShell && (presContext = presShell->GetPresContext())) {
|
|
||||||
presContext->SetImageAnimationMode(mImageAnimationMode);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nsCOMPtr<nsIDOMWindowUtils> utils(do_QueryInterface(aWindow));
|
||||||
|
if (utils)
|
||||||
|
utils->SetImageAnimationMode(mImageAnimationMode);
|
||||||
|
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче