mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-17 22:32:51 +00:00
Bug 1350772 - Part 1. Check whether node can be splited. r=masayuki
At first, HTMLEditor::GetActiveEditingHost might return null in this situation, we should check whether nullptr is returned. At second, SplitNodeDeep returns error since curent is design mode and selection node has no parent. So we should check error. MozReview-Commit-ID: 2YlWXPNtf80 --HG-- extra : rebase_source : 5e9752353cdf8db906e94391e9660f61336a9614
This commit is contained in:
parent
6b9305b646
commit
c013bde6aa
@ -1524,10 +1524,11 @@ HTMLEditRules::WillInsertBreak(Selection& aSelection,
|
||||
nsCOMPtr<Element> blockParent = htmlEditor->GetBlock(node);
|
||||
NS_ENSURE_TRUE(blockParent, NS_ERROR_FAILURE);
|
||||
|
||||
// If the active editing host is an inline element, or if the active editing
|
||||
// host is the block parent itself, just append a br.
|
||||
// When there is an active editing host (the <body> if it's in designMode)
|
||||
// and a block which becomes the parent of line breaker is in it, do the
|
||||
// standard thing.
|
||||
nsCOMPtr<Element> host = htmlEditor->GetActiveEditingHost();
|
||||
if (!EditorUtils::IsDescendantOf(blockParent, host)) {
|
||||
if (host && !EditorUtils::IsDescendantOf(blockParent, host)) {
|
||||
nsresult rv = StandardBreakImpl(node, offset, aSelection);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
*aHandled = true;
|
||||
@ -6491,10 +6492,14 @@ HTMLEditRules::SplitParagraph(nsIDOMNode *aPara,
|
||||
// split the paragraph
|
||||
NS_ENSURE_STATE(mHTMLEditor);
|
||||
NS_ENSURE_STATE(selNode->IsContent());
|
||||
mHTMLEditor->SplitNodeDeep(*para, *selNode->AsContent(), *aOffset,
|
||||
HTMLEditor::EmptyContainers::yes,
|
||||
getter_AddRefs(leftPara),
|
||||
getter_AddRefs(rightPara));
|
||||
int32_t offset =
|
||||
mHTMLEditor->SplitNodeDeep(*para, *selNode->AsContent(), *aOffset,
|
||||
HTMLEditor::EmptyContainers::yes,
|
||||
getter_AddRefs(leftPara),
|
||||
getter_AddRefs(rightPara));
|
||||
if (NS_WARN_IF(offset == -1)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
// get rid of the break, if it is visible (otherwise it may be needed to prevent an empty p)
|
||||
NS_ENSURE_STATE(mHTMLEditor);
|
||||
if (mHTMLEditor->IsVisBreak(aBRNode)) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user