Bug 1468708 - Part 4. Use EditorBase::GetPresContext to get nsPresContext in nsComposerDocumentCommands. r=masayuki

MozReview-Commit-ID: 5ubcYtk5Ylj

--HG--
extra : rebase_source : a83029c7f5c3b20d57ed367292baed2641f3a8bf
This commit is contained in:
Makoto Kato 2018-06-12 16:55:34 -07:00
parent 7b8d3f391a
commit bedfd9166e

View File

@ -35,22 +35,6 @@ class nsISupports;
#define STATE_ATTRIBUTE "state_attribute"
#define STATE_DATA "state_data"
static
nsresult
GetPresContextFromEditor(TextEditor* aTextEditor, nsPresContext** aResult)
{
if (NS_WARN_IF(!aResult) || NS_WARN_IF(!aTextEditor)) {
return NS_ERROR_INVALID_ARG;
}
*aResult = nullptr;
nsCOMPtr<nsIPresShell> presShell = aTextEditor->GetPresShell();
if (NS_WARN_IF(!presShell)) {
return NS_ERROR_FAILURE;
}
RefPtr<nsPresContext> presContext = presShell->GetPresContext();
presContext.forget(aResult);
return NS_OK;
}
NS_IMETHODIMP
nsSetDocumentOptionsCommand::IsCommandEnabled(const char * aCommandName,
@ -90,11 +74,10 @@ nsSetDocumentOptionsCommand::DoCommandParams(const char *aCommandName,
TextEditor* textEditor = editor->AsTextEditor();
MOZ_ASSERT(textEditor);
RefPtr<nsPresContext> presContext;
nsresult rv =
GetPresContextFromEditor(textEditor, getter_AddRefs(presContext));
NS_ENSURE_SUCCESS(rv, rv);
NS_ENSURE_TRUE(presContext, NS_ERROR_FAILURE);
RefPtr<nsPresContext> presContext = textEditor->GetPresContext();
if (NS_WARN_IF(!presContext)) {
return NS_ERROR_FAILURE;
}
int32_t animationMode;
rv = aParams->GetLongValue("imageAnimation", &animationMode);
@ -140,10 +123,10 @@ nsSetDocumentOptionsCommand::GetCommandStateParams(const char *aCommandName,
NS_ENSURE_SUCCESS(rv, rv);
// get pres context
RefPtr<nsPresContext> presContext;
rv = GetPresContextFromEditor(textEditor, getter_AddRefs(presContext));
NS_ENSURE_SUCCESS(rv, rv);
NS_ENSURE_TRUE(presContext, NS_ERROR_FAILURE);
RefPtr<nsPresContext> presContext = textEditor->GetPresContext();
if (NS_WARN_IF(!presContext)) {
return NS_ERROR_FAILURE;
}
int32_t animationMode;
rv = aParams->GetLongValue("imageAnimation", &animationMode);