--- a/editor/composer/nsComposerCommands.cpp
+++ b/editor/composer/nsComposerCommands.cpp
@@ -29,26 +29,20 @@
#include "nsString.h" // for nsAutoString, nsString, etc
#include "nsStringFwd.h" // for nsString
class nsISupports;
using mozilla::dom::Element;
using mozilla::ErrorResult;
//prototype
-nsresult GetListState(mozilla::HTMLEditor* aHTMLEditor,
- bool* aMixed,
- nsAString& aLocalName);
-nsresult RemoveOneProperty(mozilla::HTMLEditor* aHTMLEditor,
- const nsAString& aProp);
-nsresult RemoveTextProperty(mozilla::HTMLEditor* aHTMLEditor,
- const nsAString& aProp);
-nsresult SetTextProperty(mozilla::HTMLEditor* aHTMLEditor,
- const nsAString& aProp);
-
+static nsresult
+GetListState(mozilla::HTMLEditor* aHTMLEditor,
+ bool* aMixed,
+ nsAString& aLocalName);
//defines
#define STATE_ENABLED "state_enabled"
#define STATE_ALL "state_all"
#define STATE_ANY "state_any"
#define STATE_MIXED "state_mixed"
#define STATE_BEGIN "state_begin"
#define STATE_END "state_end"
@@ -248,40 +242,50 @@ nsStyleUpdatingCommand::ToggleState(mozi
NS_ENSURE_SUCCESS(rv, rv);
rv = params->GetBooleanValue(STATE_ALL, &doTagRemoval);
NS_ENSURE_SUCCESS(rv, rv);
}
if (doTagRemoval) {
// Also remove equivalent properties (bug 317093)
if (mTagName == nsGkAtoms::b) {
- rv = RemoveTextProperty(aHTMLEditor, NS_LITERAL_STRING("strong"));
- NS_ENSURE_SUCCESS(rv, rv);
+ rv = aHTMLEditor->RemoveInlineProperty(nsGkAtoms::strong, nullptr);
+ if (NS_WARN_IF(NS_FAILED(rv))) {
+ return rv;
+ }
} else if (mTagName == nsGkAtoms::i) {
- rv = RemoveTextProperty(aHTMLEditor, NS_LITERAL_STRING("em"));
- NS_ENSURE_SUCCESS(rv, rv);
+ rv = aHTMLEditor->RemoveInlineProperty(nsGkAtoms::em, nullptr);
+ if (NS_WARN_IF(NS_FAILED(rv))) {
+ return rv;
+ }
} else if (mTagName == nsGkAtoms::strike) {
- rv = RemoveTextProperty(aHTMLEditor, NS_LITERAL_STRING("s"));
- NS_ENSURE_SUCCESS(rv, rv);
+ rv = aHTMLEditor->RemoveInlineProperty(nsGkAtoms::s, nullptr);
+ if (NS_WARN_IF(NS_FAILED(rv))) {
+ return rv;
+ }
}
- rv = RemoveTextProperty(aHTMLEditor, nsDependentAtomString(mTagName));
- } else {
- // Superscript and Subscript styles are mutually exclusive
- aHTMLEditor->BeginTransaction();
+ rv = aHTMLEditor->RemoveInlineProperty(mTagName, nullptr);
+ if (NS_WARN_IF(NS_FAILED(rv))) {
+ return rv;
+ }
+ return rv;
+ }
- nsDependentAtomString tagName(mTagName);
- if (mTagName == nsGkAtoms::sub || mTagName == nsGkAtoms::sup) {
- rv = RemoveTextProperty(aHTMLEditor, tagName);
- }
- if (NS_SUCCEEDED(rv))
- rv = SetTextProperty(aHTMLEditor, tagName);
+ // Superscript and Subscript styles are mutually exclusive
+ aHTMLEditor->BeginTransaction();
- aHTMLEditor->EndTransaction();
+ if (mTagName == nsGkAtoms::sub || mTagName == nsGkAtoms::sup) {
+ rv = aHTMLEditor->RemoveInlineProperty(mTagName, nullptr);
}
+ if (NS_SUCCEEDED(rv)) {
+ rv = aHTMLEditor->SetInlineProperty(mTagName, nullptr, EmptyString());
+ }
+
+ aHTMLEditor->EndTransaction();
return rv;
}
nsListCommand::nsListCommand(nsAtom* aTagName)
: nsBaseStateUpdatingCommand(aTagName)
{
}
@@ -1536,17 +1540,17 @@ nsInsertTagCommand::GetCommandStateParam
return aParams->SetBooleanValue(STATE_ENABLED, outCmdEnabled);
}
/****************************/
//HELPER METHODS
/****************************/
-nsresult
+static nsresult
GetListState(mozilla::HTMLEditor* aHTMLEditor,
bool* aMixed,
nsAString& aLocalName)
{
MOZ_ASSERT(aHTMLEditor);
MOZ_ASSERT(aMixed);
*aMixed = false;
@@ -1564,52 +1568,8 @@ GetListState(mozilla::HTMLEditor* aHTMLE
aLocalName.AssignLiteral("ol");
} else if (bUL) {
aLocalName.AssignLiteral("ul");
} else if (bDL) {
aLocalName.AssignLiteral("dl");
}
return NS_OK;
}
-
-nsresult
-RemoveOneProperty(mozilla::HTMLEditor* aHTMLEditor,
- const nsAString& aProp)
-{
- MOZ_ASSERT(aHTMLEditor);
-
- /// XXX Hack alert! Look in nsIEditProperty.h for this
- RefPtr<nsAtom> styleAtom = NS_Atomize(aProp);
- NS_ENSURE_TRUE(styleAtom, NS_ERROR_OUT_OF_MEMORY);
-
- return aHTMLEditor->RemoveInlineProperty(styleAtom, nullptr);
-}
-
-
-// the name of the attribute here should be the contents of the appropriate
-// tag, e.g. 'b' for bold, 'i' for italics.
-nsresult
-RemoveTextProperty(mozilla::HTMLEditor* aHTMLEditor,
- const nsAString& aProp)
-{
- MOZ_ASSERT(aHTMLEditor);
-
- if (aProp.LowerCaseEqualsLiteral("all")) {
- return aHTMLEditor->RemoveAllInlineProperties();
- }
-
- return RemoveOneProperty(aHTMLEditor, aProp);
-}
-
-// the name of the attribute here should be the contents of the appropriate
-// tag, e.g. 'b' for bold, 'i' for italics.
-nsresult
-SetTextProperty(mozilla::HTMLEditor* aHTMLEditor,
- const nsAString& aProp)
-{
- MOZ_ASSERT(aHTMLEditor);
-
- /// XXX Hack alert! Look in nsIEditProperty.h for this
- RefPtr<nsAtom> styleAtom = NS_Atomize(aProp);
- NS_ENSURE_TRUE(styleAtom, NS_ERROR_OUT_OF_MEMORY);
-
- return aHTMLEditor->SetInlineProperty(styleAtom, nullptr, EmptyString());
-}