diff --git a/content/html/document/src/nsHTMLDocument.cpp b/content/html/document/src/nsHTMLDocument.cpp index 0d0f765be538..f8c967380d55 100644 --- a/content/html/document/src/nsHTMLDocument.cpp +++ b/content/html/document/src/nsHTMLDocument.cpp @@ -3762,9 +3762,8 @@ nsHTMLDocument::ChangeContentEditableCount(nsIContent *aElement, NS_ENSURE_SUCCESS(rv, rv); nsCOMPtr editor; - rv = editorDocShell->GetEditor(getter_AddRefs(editor)); - NS_ENSURE_SUCCESS(rv, rv); - + editorDocShell->GetEditor(getter_AddRefs(editor)); + if (editor) { nsCOMPtr range; rv = NS_NewRange(getter_AddRefs(range)); NS_ENSURE_SUCCESS(rv, rv); @@ -3783,6 +3782,7 @@ nsHTMLDocument::ChangeContentEditableCount(nsIContent *aElement, } } } + } return NS_OK; } @@ -3821,10 +3821,6 @@ nsHTMLDocument::TurnEditingOff() do_QueryInterface(docshell, &rv); NS_ENSURE_SUCCESS(rv, rv); - nsCOMPtr editor; - rv = editorDocShell->GetEditor(getter_AddRefs(editor)); - NS_ENSURE_SUCCESS(rv, rv); - nsCOMPtr editSession = do_GetInterface(docshell, &rv); NS_ENSURE_SUCCESS(rv, rv); @@ -3832,13 +3828,16 @@ nsHTMLDocument::TurnEditingOff() rv = editSession->TearDownEditorOnWindow(window, PR_TRUE); NS_ENSURE_SUCCESS(rv, rv); - nsCOMPtr editorss = do_QueryInterface(editor, &rv); - NS_ENSURE_SUCCESS(rv, rv); - + nsCOMPtr editor; + editorDocShell->GetEditor(getter_AddRefs(editor)); + nsCOMPtr editorss = do_QueryInterface(editor); + if (editorss) { editorss->RemoveOverrideStyleSheet(NS_LITERAL_STRING("resource:/res/contenteditable.css")); - if (mEditingState == eDesignMode) { + if (mEditingState == eDesignMode) editorss->RemoveOverrideStyleSheet(NS_LITERAL_STRING("resource:/res/designmode.css")); + } + if (mEditingState == eDesignMode) { rv = docshell->SetAllowJavascript(mScriptsEnabled); NS_ENSURE_SUCCESS(rv, rv); @@ -3907,8 +3906,9 @@ nsHTMLDocument::EditingStateChanged() NS_ENSURE_SUCCESS(rv, rv); nsCOMPtr editor; - rv = editorDocShell->GetEditor(getter_AddRefs(editor)); - NS_ENSURE_SUCCESS(rv, rv); + editorDocShell->GetEditor(getter_AddRefs(editor)); + if (!editor) + return NS_ERROR_FAILURE; nsCOMPtr editorss = do_QueryInterface(editor, &rv); NS_ENSURE_SUCCESS(rv, rv);