зеркало из https://github.com/mozilla/pjs.git
Bug 748303 part 2 - Handle non-text/elements correctly when calling (Tag)CanContain(Tag); r=ehsan
This commit is contained in:
Родитель
8a9e41f864
Коммит
c6938beb78
|
@ -3528,6 +3528,17 @@ nsEditor::IsBlockNode(nsINode *aNode)
|
|||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
nsEditor::CanContain(nsIDOMNode* aParent, nsIDOMNode* aChild)
|
||||
{
|
||||
nsCOMPtr<nsIDOMElement> 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)
|
||||
{
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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<nsIDOMNode> parent = *ioParent;
|
||||
nsCOMPtr<nsIDOMNode> topChild = *ioParent;
|
||||
nsCOMPtr<nsIDOMNode> 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))
|
||||
|
|
Загрузка…
Ссылка в новой задаче