diff --git a/editor/libeditor/base/nsEditor.cpp b/editor/libeditor/base/nsEditor.cpp index 86a18a1cb82..36e7b677729 100644 --- a/editor/libeditor/base/nsEditor.cpp +++ b/editor/libeditor/base/nsEditor.cpp @@ -3528,6 +3528,17 @@ nsEditor::IsBlockNode(nsINode *aNode) return false; } +bool +nsEditor::CanContain(nsIDOMNode* aParent, nsIDOMNode* aChild) +{ + nsCOMPtr parentElement = do_QueryInterface(aParent); + NS_ENSURE_TRUE(parentElement, false); + + nsAutoString parentStringTag; + parentElement->GetTagName(parentStringTag); + return TagCanContain(parentStringTag, aChild); +} + bool nsEditor::CanContainTag(nsIDOMNode* aParent, const nsAString &aChildTag) { diff --git a/editor/libeditor/base/nsEditor.h b/editor/libeditor/base/nsEditor.h index e6448c18e20..63a4b287ee4 100644 --- a/editor/libeditor/base/nsEditor.h +++ b/editor/libeditor/base/nsEditor.h @@ -534,6 +534,7 @@ public: /** returns true if aParent can contain a child of type aTag */ + bool CanContain(nsIDOMNode* aParent, nsIDOMNode* aChild); bool CanContainTag(nsIDOMNode* aParent, const nsAString &aTag); bool TagCanContain(const nsAString &aParentTag, nsIDOMNode* aChild); virtual bool TagCanContainTag(const nsAString &aParentTag, const nsAString &aChildTag); diff --git a/editor/libeditor/html/nsHTMLEditor.cpp b/editor/libeditor/html/nsHTMLEditor.cpp index 61b91b877c2..339e35e6c90 100644 --- a/editor/libeditor/html/nsHTMLEditor.cpp +++ b/editor/libeditor/html/nsHTMLEditor.cpp @@ -1846,17 +1846,13 @@ nsHTMLEditor::InsertNodeAtPoint(nsIDOMNode *aNode, NS_ENSURE_TRUE(ioOffset, NS_ERROR_NULL_POINTER); nsresult res = NS_OK; - nsAutoString tagName; - aNode->GetNodeName(tagName); - ToLowerCase(tagName); nsCOMPtr parent = *ioParent; nsCOMPtr topChild = *ioParent; nsCOMPtr tmp; PRInt32 offsetOfInsert = *ioOffset; // Search up the parent chain to find a suitable container - while (!CanContainTag(parent, tagName)) - { + while (!CanContain(parent, aNode)) { // If the current parent is a root (body or table element) // then go no further - we can't insert if (nsTextEditUtils::IsBody(parent) || nsHTMLEditUtils::IsTableElement(parent))