summaryrefslogtreecommitdiffstats
path: root/editor/libeditor/HTMLEditUtils.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'editor/libeditor/HTMLEditUtils.cpp')
-rw-r--r--editor/libeditor/HTMLEditUtils.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/editor/libeditor/HTMLEditUtils.cpp b/editor/libeditor/HTMLEditUtils.cpp
index 3e737c4..d4cf140 100644
--- a/editor/libeditor/HTMLEditUtils.cpp
+++ b/editor/libeditor/HTMLEditUtils.cpp
@@ -43,6 +43,34 @@ bool HTMLEditUtils::IsInlineStyle(nsINode* aNode) {
nsGkAtoms::sup, nsGkAtoms::font);
}
+bool HTMLEditUtils::IsRemovableInlineStyleElement(Element& aElement) {
+ if (!aElement.IsHTMLElement()) {
+ return false;
+ }
+ // https://w3c.github.io/editing/execCommand.html#removeformat-candidate
+ if (aElement.IsAnyOfHTMLElements(
+ nsGkAtoms::abbr, // Chrome ignores, but does not make sense.
+ nsGkAtoms::acronym, nsGkAtoms::b,
+ nsGkAtoms::bdi, // Chrome ignores, but does not make sense.
+ nsGkAtoms::bdo, nsGkAtoms::big, nsGkAtoms::cite, nsGkAtoms::code,
+ // nsGkAtoms::del, Chrome ignores, but does not make sense but
+ // execCommand unofficial draft excludes this. Spec issue:
+ // https://github.com/w3c/editing/issues/192
+ nsGkAtoms::dfn, nsGkAtoms::em, nsGkAtoms::font, nsGkAtoms::i,
+ nsGkAtoms::ins, nsGkAtoms::kbd,
+ nsGkAtoms::mark, // Chrome ignores, but does not make sense.
+ nsGkAtoms::nobr, nsGkAtoms::q, nsGkAtoms::s, nsGkAtoms::samp,
+ nsGkAtoms::small, nsGkAtoms::span, nsGkAtoms::strike,
+ nsGkAtoms::strong, nsGkAtoms::sub, nsGkAtoms::sup, nsGkAtoms::tt,
+ nsGkAtoms::u, nsGkAtoms::var)) {
+ return true;
+ }
+ // If it's a <blink> element, we can remove it.
+ nsAutoString tagName;
+ aElement.GetTagName(tagName);
+ return tagName.LowerCaseEqualsASCII("blink");
+}
+
/**
* IsFormatNode() returns true if aNode is a format node.
*/