summaryrefslogtreecommitdiffstats
path: root/editor/libeditor
diff options
context:
space:
mode:
authorGaming4JC <g4jc@hyperbola.info>2020-05-22 22:26:28 -0400
committerMoonchild <moonchild@palemoon.org>2020-08-07 21:29:45 +0000
commitff21776616586562ab8c24f3180fff9901574038 (patch)
treef6ed28ca40abf75ebe8053526ed67294768da265 /editor/libeditor
parent2f022ab1faeb4703ecd9d7ca6b912bbe397531f6 (diff)
downloadUXP-ff21776616586562ab8c24f3180fff9901574038.tar
UXP-ff21776616586562ab8c24f3180fff9901574038.tar.gz
UXP-ff21776616586562ab8c24f3180fff9901574038.tar.lz
UXP-ff21776616586562ab8c24f3180fff9901574038.tar.xz
UXP-ff21776616586562ab8c24f3180fff9901574038.zip
Issue #1621 - Part 4: Check whether node can be splited.
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. Ref: Bug 1350772
Diffstat (limited to 'editor/libeditor')
-rw-r--r--editor/libeditor/HTMLEditRules.cpp19
1 files changed, 12 insertions, 7 deletions
diff --git a/editor/libeditor/HTMLEditRules.cpp b/editor/libeditor/HTMLEditRules.cpp
index b6dad01c5..dfc327a2c 100644
--- a/editor/libeditor/HTMLEditRules.cpp
+++ b/editor/libeditor/HTMLEditRules.cpp
@@ -1509,10 +1509,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;
@@ -6480,10 +6481,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)) {