bug 1257287 - add nsIDocShell::GetEdItingSession()

This commit is contained in:
Trevor Saunders 2016-03-14 14:00:13 -04:00
parent 1114a59fb7
commit 2c05850952
5 changed files with 35 additions and 17 deletions

View File

@ -335,8 +335,13 @@ DocAccessible::GetEditor() const
(!mContent || !mContent->HasFlag(NODE_IS_EDITABLE)))
return nullptr;
nsCOMPtr<nsISupports> container = mDocumentNode->GetContainer();
nsCOMPtr<nsIEditingSession> editingSession(do_GetInterface(container));
nsCOMPtr<nsIDocShell> docShell = mDocumentNode->GetDocShell();
if (!docShell) {
return nullptr;
}
nsCOMPtr<nsIEditingSession> editingSession;
docShell->GetEditingSession(getter_AddRefs(editingSession));
if (!editingSession)
return nullptr; // No editing session interface

View File

@ -1314,7 +1314,8 @@ HyperTextAccessible::GetEditor() const
}
nsCOMPtr<nsIDocShell> docShell = nsCoreUtils::GetDocShellFor(mContent);
nsCOMPtr<nsIEditingSession> editingSession(do_GetInterface(docShell));
nsCOMPtr<nsIEditingSession> editingSession;
docShell->GetEditingSession(getter_AddRefs(editingSession));
if (!editingSession)
return nullptr; // No editing session interface

View File

@ -1025,16 +1025,11 @@ nsDocShell::GetInterface(const nsIID& aIID, void** aSink)
*aSink = mFind;
NS_ADDREF((nsISupports*)*aSink);
return NS_OK;
} else if (aIID.Equals(NS_GET_IID(nsIEditingSession)) &&
NS_SUCCEEDED(EnsureEditorData())) {
nsCOMPtr<nsIEditingSession> editingSession;
mEditorData->GetEditingSession(getter_AddRefs(editingSession));
if (editingSession) {
editingSession.forget(aSink);
return NS_OK;
}
return NS_NOINTERFACE;
} else if (aIID.Equals(NS_GET_IID(nsIEditingSession))) {
nsCOMPtr<nsIEditingSession> es;
GetEditingSession(getter_AddRefs(es));
es.forget(aSink);
return *aSink ? NS_OK : NS_NOINTERFACE;
} else if (aIID.Equals(NS_GET_IID(nsIClipboardDragDropHookList)) &&
NS_SUCCEEDED(EnsureTransferableHookData())) {
*aSink = mTransferableHookData;
@ -14358,3 +14353,14 @@ nsDocShell::IssueWarning(uint32_t aWarning, bool aAsError)
}
return NS_OK;
}
NS_IMETHODIMP
nsDocShell::GetEditingSession(nsIEditingSession** aEditSession)
{
if (!NS_SUCCEEDED(EnsureEditorData())) {
return NS_ERROR_FAILURE;
}
mEditorData->GetEditingSession(aEditSession);
return *aEditSession ? NS_OK : NS_ERROR_FAILURE;
}

View File

@ -26,6 +26,7 @@ interface nsIContentViewer;
interface nsIDOMEventTarget;
interface nsIDocShellLoadInfo;
interface nsIEditor;
interface nsIEditingSession;
interface nsISimpleEnumerator;
interface nsIInputStream;
interface nsIRequest;
@ -1091,4 +1092,9 @@ interface nsIDocShell : nsIDocShellTreeItem
[implicit_jscontext]
void setOriginAttributes(in jsval aAttrs);
/**
* The editing session for this docshell.
*/
readonly attribute nsIEditingSession editingSession;
};

View File

@ -2673,8 +2673,8 @@ nsHTMLDocument::TurnEditingOff()
if (!docshell)
return NS_ERROR_FAILURE;
nsresult rv;
nsCOMPtr<nsIEditingSession> editSession = do_GetInterface(docshell, &rv);
nsCOMPtr<nsIEditingSession> editSession;
nsresult rv = docshell->GetEditingSession(getter_AddRefs(editSession));
NS_ENSURE_SUCCESS(rv, rv);
// turn editing off
@ -2744,8 +2744,8 @@ nsHTMLDocument::EditingStateChanged()
if (!docshell)
return NS_ERROR_FAILURE;
nsresult rv;
nsCOMPtr<nsIEditingSession> editSession = do_GetInterface(docshell, &rv);
nsCOMPtr<nsIEditingSession> editSession;
nsresult rv = docshell->GetEditingSession(getter_AddRefs(editSession));
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIEditor> existingEditor;