diff --git a/editor/libeditor/nsHTMLEditor.h b/editor/libeditor/nsHTMLEditor.h
index 0477a04ca423..f817329deddf 100644
--- a/editor/libeditor/nsHTMLEditor.h
+++ b/editor/libeditor/nsHTMLEditor.h
@@ -678,6 +678,7 @@ protected:
const nsAString* aAttribute);
bool NodeIsProperty(nsIDOMNode *aNode);
+ bool HasAttr(nsIDOMNode *aNode, const nsAString *aAttribute);
bool IsAtFrontOfNode(nsIDOMNode *aNode, int32_t aOffset);
bool IsAtEndOfNode(nsIDOMNode *aNode, int32_t aOffset);
bool IsOnlyAttribute(const nsIContent* aElement, const nsAString& aAttribute);
diff --git a/editor/libeditor/nsHTMLEditorStyle.cpp b/editor/libeditor/nsHTMLEditorStyle.cpp
index 7c0a62278b61..09a3c4dc1cf2 100644
--- a/editor/libeditor/nsHTMLEditorStyle.cpp
+++ b/editor/libeditor/nsHTMLEditorStyle.cpp
@@ -848,6 +848,26 @@ nsHTMLEditor::IsOnlyAttribute(const nsIContent* aContent,
return true;
}
+bool nsHTMLEditor::HasAttr(nsIDOMNode* aNode,
+ const nsAString* aAttribute)
+{
+ NS_ENSURE_TRUE(aNode, false);
+ if (!aAttribute || aAttribute->IsEmpty()) {
+ // everybody has the 'null' attribute
+ return true;
+ }
+
+ // get element
+ nsCOMPtr element = do_QueryInterface(aNode);
+ NS_ENSURE_TRUE(element, false);
+
+ nsCOMPtr atom = NS_Atomize(*aAttribute);
+ NS_ENSURE_TRUE(atom, false);
+
+ return element->HasAttr(kNameSpaceID_None, atom);
+}
+
+
nsresult
nsHTMLEditor::PromoteRangeIfStartsOrEndsInNamedAnchor(nsRange* inRange)
{