Bug 1191354 part 5 - Clean up nsHTMLEditRules::IsEmptyInline; r=ehsan

This commit is contained in:
Aryeh Gregor 2016-05-01 16:14:39 +03:00
parent 2f2e3c0922
commit fcbd93de52
2 changed files with 16 additions and 17 deletions

View File

@ -3019,7 +3019,7 @@ nsHTMLEditRules::WillMakeList(Selection* aSelection,
for (auto& curNode : arrayOfNodes) {
// if curNode is not a Break or empty inline, we're done
if (!nsTextEditUtils::IsBreak(curNode) &&
!IsEmptyInline(GetAsDOMNode(curNode))) {
!IsEmptyInline(curNode)) {
bOnlyBreaks = false;
break;
}
@ -3087,7 +3087,7 @@ nsHTMLEditRules::WillMakeList(Selection* aSelection,
// here's where we actually figure out what to do
nsCOMPtr<nsIDOMNode> newBlock;
NS_ENSURE_STATE(arrayOfNodes[i]->IsContent());
nsCOMPtr<nsIContent> curNode = arrayOfNodes[i]->AsContent();
OwningNonNull<nsIContent> curNode = *arrayOfNodes[i]->AsContent();
int32_t offset;
curParent = nsEditor::GetNodeLocation(curNode, &offset);
@ -3104,7 +3104,7 @@ nsHTMLEditRules::WillMakeList(Selection* aSelection,
NS_ENSURE_SUCCESS(res, res);
prevListItem = 0;
continue;
} else if (IsEmptyInline(GetAsDOMNode(curNode))) {
} else if (IsEmptyInline(curNode)) {
// if curNode is an empty inline container, delete it
NS_ENSURE_STATE(mHTMLEditor);
res = mHTMLEditor->DeleteNode(curNode);
@ -7776,20 +7776,19 @@ nsHTMLEditRules::SelectionEndpointInNode(nsINode* aNode, bool* aResult)
return NS_OK;
}
///////////////////////////////////////////////////////////////////////////
// IsEmptyInline: return true if aNode is an empty inline container
//
//
/**
* IsEmptyInline: Return true if aNode is an empty inline container
*/
bool
nsHTMLEditRules::IsEmptyInline(nsIDOMNode *aNode)
nsHTMLEditRules::IsEmptyInline(nsINode& aNode)
{
if (aNode && IsInlineNode(aNode) && mHTMLEditor &&
mHTMLEditor->IsContainer(aNode))
{
bool bEmpty;
NS_ENSURE_TRUE(mHTMLEditor, false);
mHTMLEditor->IsEmptyNode(aNode, &bEmpty);
return bEmpty;
NS_ENSURE_TRUE(mHTMLEditor, false);
nsCOMPtr<nsIEditor> kungFuDeathGrip(mHTMLEditor);
if (IsInlineNode(aNode.AsDOMNode()) && mHTMLEditor->IsContainer(&aNode)) {
bool isEmpty = true;
mHTMLEditor->IsEmptyNode(&aNode, &isEmpty);
return isEmpty;
}
return false;
}
@ -7818,7 +7817,7 @@ nsHTMLEditRules::ListIsEmptyLine(nsTArray<OwningNonNull<nsINode>>& aArrayOfNodes
return false;
}
brCount++;
} else if (IsEmptyInline(GetAsDOMNode(node))) {
} else if (IsEmptyInline(node)) {
// Empty inline, keep looking
} else {
return false;

View File

@ -339,7 +339,7 @@ protected:
nsresult UpdateDocChangeRange(nsRange* aRange);
nsresult ConfirmSelectionInBody();
nsresult InsertMozBRIfNeeded(nsINode& aNode);
bool IsEmptyInline(nsIDOMNode *aNode);
bool IsEmptyInline(nsINode& aNode);
bool ListIsEmptyLine(nsTArray<mozilla::OwningNonNull<nsINode>>& arrayOfNodes);
nsresult RemoveAlignment(nsIDOMNode * aNode, const nsAString & aAlignType, bool aChildrenOnly);
nsresult MakeSureElemStartsOrEndsOnCR(nsIDOMNode *aNode, bool aStarts);