mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Fix for bug 390446 (Javascript is still disabled after leaving a page that had designMode on). r/sr=jst.
This commit is contained in:
parent
1c227b78cc
commit
57decd655d
@ -3922,7 +3922,7 @@ nsHTMLDocument::TurnEditingOff()
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// turn editing off
|
||||
rv = editSession->TearDownEditorOnWindow(window, PR_TRUE);
|
||||
rv = editSession->TearDownEditorOnWindow(window);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIEditor> editor;
|
||||
@ -3934,14 +3934,6 @@ nsHTMLDocument::TurnEditingOff()
|
||||
editorss->RemoveOverrideStyleSheet(NS_LITERAL_STRING("resource://gre/res/designmode.css"));
|
||||
}
|
||||
|
||||
if (mEditingState == eDesignMode) {
|
||||
rv = docshell->SetAllowJavascript(mScriptsEnabled);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = docshell->SetAllowPlugins(mPluginsEnabled);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
mEditingState = eOff;
|
||||
|
||||
return NS_OK;
|
||||
@ -4038,22 +4030,8 @@ nsHTMLDocument::EditingStateChanged()
|
||||
// designMode is being turned on (overrides contentEditable).
|
||||
editorss->AddOverrideStyleSheet(NS_LITERAL_STRING("resource://gre/res/designmode.css"));
|
||||
|
||||
// Store scripting and plugins state.
|
||||
PRBool tmp;
|
||||
rv = docshell->GetAllowJavascript(&tmp);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
mScriptsEnabled = tmp;
|
||||
|
||||
rv = docshell->SetAllowJavascript(PR_FALSE);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = docshell->GetAllowPlugins(&tmp);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
mPluginsEnabled = tmp;
|
||||
|
||||
rv = docshell->SetAllowPlugins(PR_FALSE);
|
||||
// Disable scripting and plugins.
|
||||
rv = editSession->DisableJSAndPlugins(window);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
updateState = PR_TRUE;
|
||||
@ -4063,10 +4041,7 @@ nsHTMLDocument::EditingStateChanged()
|
||||
// designMode is being turned off (contentEditable is still on).
|
||||
editorss->RemoveOverrideStyleSheet(NS_LITERAL_STRING("resource://gre/res/designmode.css"));
|
||||
|
||||
rv = docshell->SetAllowJavascript(mScriptsEnabled);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = docshell->SetAllowPlugins(mPluginsEnabled);
|
||||
rv = editSession->RestoreJSAndPlugins(window);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
updateState = PR_TRUE;
|
||||
@ -4089,7 +4064,7 @@ nsHTMLDocument::EditingStateChanged()
|
||||
if (NS_FAILED(rv)) {
|
||||
// Editor setup failed. Editing is not on after all.
|
||||
// XXX Should we reset the editable flag on nodes?
|
||||
editSession->TearDownEditorOnWindow(window, PR_TRUE);
|
||||
editSession->TearDownEditorOnWindow(window);
|
||||
mEditingState = eOff;
|
||||
|
||||
return rv;
|
||||
|
@ -378,8 +378,6 @@ protected:
|
||||
|
||||
PRUint32 mContentEditableCount;
|
||||
EditingState mEditingState;
|
||||
PRPackedBool mScriptsEnabled;
|
||||
PRPackedBool mPluginsEnabled;
|
||||
|
||||
nsresult DoClipboardSecurityCheck(PRBool aPaste);
|
||||
static jsval sCutCopyInternal_id;
|
||||
|
@ -73,7 +73,7 @@ nsDocShellEditorData::~nsDocShellEditorData()
|
||||
nsCOMPtr<nsIDOMWindow> domWindow = do_GetInterface(mDocShell);
|
||||
// This will eventually call nsDocShellEditorData::SetEditor(nsnull)
|
||||
// which will call mEditorPreDestroy() and delete the editor
|
||||
mEditingSession->TearDownEditorOnWindow(domWindow, PR_TRUE);
|
||||
mEditingSession->TearDownEditorOnWindow(domWindow);
|
||||
}
|
||||
else if (mEditor) // Should never have this w/o nsEditingSession!
|
||||
{
|
||||
|
@ -43,7 +43,7 @@
|
||||
|
||||
interface nsIEditor;
|
||||
|
||||
[scriptable, uuid(aee80d50-2065-4411-834d-0cadfb649a19)]
|
||||
[scriptable, uuid(274cd32e-3675-47e1-9d8a-fc6504ded9ce)]
|
||||
|
||||
interface nsIEditingSession : nsISupports
|
||||
{
|
||||
@ -101,10 +101,20 @@ interface nsIEditingSession : nsISupports
|
||||
/**
|
||||
* Destroy editor and related support objects
|
||||
*/
|
||||
void tearDownEditorOnWindow(in nsIDOMWindow window, in boolean aStopEditing);
|
||||
void tearDownEditorOnWindow(in nsIDOMWindow window);
|
||||
|
||||
void setEditorOnControllers(in nsIDOMWindow aWindow,
|
||||
in nsIEditor aEditor);
|
||||
|
||||
/**
|
||||
* Disable scripts and plugins in aWindow.
|
||||
*/
|
||||
void disableJSAndPlugins(in nsIDOMWindow aWindow);
|
||||
|
||||
/**
|
||||
* Restore JS and plugins (enable/disable them) according to the state they
|
||||
* were before the last call to disableJSAndPlugins.
|
||||
*/
|
||||
void restoreJSAndPlugins(in nsIDOMWindow aWindow);
|
||||
};
|
||||
|
||||
|
@ -97,6 +97,7 @@ nsEditingSession::nsEditingSession()
|
||||
, mCanCreateEditor(PR_FALSE)
|
||||
, mInteractive(PR_FALSE)
|
||||
, mMakeWholeDocumentEditable(PR_TRUE)
|
||||
, mDisabledJSAndPlugins(PR_FALSE)
|
||||
, mScriptsEnabled(PR_TRUE)
|
||||
, mPluginsEnabled(PR_TRUE)
|
||||
, mProgressListenerRegistered(PR_FALSE)
|
||||
@ -156,28 +157,12 @@ nsEditingSession::MakeWindowEditable(nsIDOMWindow *aWindow,
|
||||
|
||||
nsresult rv;
|
||||
if (!mInteractive) {
|
||||
// Disable JavaScript in this document:
|
||||
PRBool tmp;
|
||||
rv = docShell->GetAllowJavascript(&tmp);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
mScriptsEnabled = tmp;
|
||||
|
||||
rv = docShell->SetAllowJavascript(PR_FALSE);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Disable plugins in this document:
|
||||
rv = docShell->GetAllowPlugins(&tmp);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
mPluginsEnabled = tmp;
|
||||
|
||||
rv = docShell->SetAllowPlugins(PR_FALSE);
|
||||
rv = DisableJSAndPlugins(aWindow);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
// Always remove existing editor
|
||||
TearDownEditorOnWindow(aWindow, PR_FALSE);
|
||||
TearDownEditorOnWindow(aWindow);
|
||||
|
||||
// Tells embedder that startup is in progress
|
||||
mEditorStatus = eEditorCreationInProgress;
|
||||
@ -226,11 +211,55 @@ nsEditingSession::MakeWindowEditable(nsIDOMWindow *aWindow,
|
||||
// Since this is used only when editing an existing page,
|
||||
// it IS ok to destroy current editor
|
||||
if (NS_FAILED(rv))
|
||||
TearDownEditorOnWindow(aWindow, PR_FALSE);
|
||||
TearDownEditorOnWindow(aWindow);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsEditingSession::DisableJSAndPlugins(nsIDOMWindow *aWindow)
|
||||
{
|
||||
nsIDocShell *docShell = GetDocShellFromWindow(aWindow);
|
||||
if (!docShell) return NS_ERROR_FAILURE;
|
||||
|
||||
PRBool tmp;
|
||||
nsresult rv = docShell->GetAllowJavascript(&tmp);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
mScriptsEnabled = tmp;
|
||||
|
||||
rv = docShell->SetAllowJavascript(PR_FALSE);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Disable plugins in this document:
|
||||
rv = docShell->GetAllowPlugins(&tmp);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
mPluginsEnabled = tmp;
|
||||
|
||||
rv = docShell->SetAllowPlugins(PR_FALSE);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
mDisabledJSAndPlugins = PR_TRUE;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsEditingSession::RestoreJSAndPlugins(nsIDOMWindow *aWindow)
|
||||
{
|
||||
mDisabledJSAndPlugins = PR_FALSE;
|
||||
|
||||
nsIDocShell *docShell = GetDocShellFromWindow(aWindow);
|
||||
if (!docShell) return NS_ERROR_FAILURE;
|
||||
|
||||
nsresult rv = docShell->SetAllowJavascript(mScriptsEnabled);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Disable plugins in this document:
|
||||
return docShell->SetAllowPlugins(mPluginsEnabled);
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
|
||||
WindowIsEditable
|
||||
@ -500,12 +529,10 @@ nsEditingSession::SetupEditorOnWindow(nsIDOMWindow *aWindow)
|
||||
|
||||
TearDownEditorOnWindow
|
||||
|
||||
void tearDownEditorOnWindow (in nsIDOMWindow aWindow,
|
||||
in boolean aStopEditing);
|
||||
void tearDownEditorOnWindow (in nsIDOMWindow aWindow);
|
||||
----------------------------------------------------------------------------*/
|
||||
NS_IMETHODIMP
|
||||
nsEditingSession::TearDownEditorOnWindow(nsIDOMWindow *aWindow,
|
||||
PRBool aStopEditing)
|
||||
nsEditingSession::TearDownEditorOnWindow(nsIDOMWindow *aWindow)
|
||||
{
|
||||
if (!mDoneSetup)
|
||||
return NS_OK;
|
||||
@ -523,7 +550,12 @@ nsEditingSession::TearDownEditorOnWindow(nsIDOMWindow *aWindow,
|
||||
|
||||
mDoneSetup = PR_FALSE;
|
||||
|
||||
if (aStopEditing) {
|
||||
// Check if we're turning off editing (from contentEditable or designMode).
|
||||
nsCOMPtr<nsIDOMDocument> domDoc;
|
||||
aWindow->GetDocument(getter_AddRefs(domDoc));
|
||||
nsCOMPtr<nsIHTMLDocument> htmlDoc = do_QueryInterface(domDoc);
|
||||
PRBool stopEditing = htmlDoc && htmlDoc->IsEditingOn();
|
||||
if (stopEditing) {
|
||||
nsCOMPtr<nsIWebProgress> webProgress = do_GetInterface(docShell);
|
||||
if (webProgress) {
|
||||
webProgress->RemoveProgressListener(this);
|
||||
@ -628,27 +660,19 @@ nsEditingSession::TearDownEditorOnWindow(nsIDOMWindow *aWindow,
|
||||
mHTMLCommandControllerId = 0;
|
||||
}
|
||||
|
||||
if (aStopEditing) {
|
||||
if (!mInteractive) {
|
||||
if (stopEditing) {
|
||||
if (mDisabledJSAndPlugins) {
|
||||
// Make things the way they were before we started editing.
|
||||
if (mScriptsEnabled) {
|
||||
docShell->SetAllowJavascript(PR_TRUE);
|
||||
}
|
||||
|
||||
if (mPluginsEnabled) {
|
||||
docShell->SetAllowPlugins(PR_TRUE);
|
||||
}
|
||||
RestoreJSAndPlugins(aWindow);
|
||||
}
|
||||
|
||||
if (!mInteractive) {
|
||||
nsCOMPtr<nsIDOMWindowUtils> utils(do_GetInterface(aWindow));
|
||||
if (utils)
|
||||
utils->SetImageAnimationMode(mImageAnimationMode);
|
||||
}
|
||||
|
||||
if (mMakeWholeDocumentEditable) {
|
||||
nsCOMPtr<nsIDOMDocument> domDoc;
|
||||
rv = aWindow->GetDocument(getter_AddRefs(domDoc));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIDocument> doc = do_QueryInterface(domDoc, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
@ -991,7 +1015,7 @@ nsEditingSession::StartDocumentLoad(nsIWebProgress *aWebProgress,
|
||||
aWebProgress->GetDOMWindow(getter_AddRefs(domWindow));
|
||||
if (domWindow)
|
||||
{
|
||||
TearDownEditorOnWindow(domWindow, PR_FALSE);
|
||||
TearDownEditorOnWindow(domWindow);
|
||||
}
|
||||
|
||||
if (aIsToBeMadeEditable)
|
||||
|
@ -132,6 +132,8 @@ protected:
|
||||
PRPackedBool mInteractive;
|
||||
PRPackedBool mMakeWholeDocumentEditable;
|
||||
|
||||
PRPackedBool mDisabledJSAndPlugins;
|
||||
|
||||
// True if scripts were enabled before the editor turned scripts
|
||||
// off, otherwise false.
|
||||
PRPackedBool mScriptsEnabled;
|
||||
|
@ -172,7 +172,7 @@ void CnsIEditSession::TearEditorWinTest(PRInt16 displayMode)
|
||||
editingSession = GetEditSessionObject();
|
||||
domWindow = GetTheDOMWindow(qaWebBrowser);
|
||||
if (editingSession) {
|
||||
rv = editingSession->TearDownEditorOnWindow(domWindow, PR_FALSE);
|
||||
rv = editingSession->TearDownEditorOnWindow(domWindow);
|
||||
RvTestResult(rv, "TearDownEditorOnWindow() test", displayMode);
|
||||
if (displayMode == 1)
|
||||
RvTestResultDlg(rv, "TearDownEditorOnWindow() test");
|
||||
|
Loading…
Reference in New Issue
Block a user