Bug 1345015 - Part 2. Don't promote range when selection node isn't content. r=masayuki
When using EditAction::insertBreak action, if selection node isn't content, this crash occurs. So we should reject to promote range when it isn't content node.
MozReview-Commit-ID: AJ4oEOmRTgm
--- a/editor/libeditor/HTMLEditRules.cpp
+++ b/editor/libeditor/HTMLEditRules.cpp
@@ -5693,16 +5693,28 @@ HTMLEditRules::PromoteRange(nsRange& aRa
startNode = block;
endNode = block;
startOffset = 0;
endOffset = block->Length();
}
}
}
+ if (aOperationType == EditAction::insertText ||
+ aOperationType == EditAction::insertIMEText ||
+ aOperationType == EditAction::insertBreak ||
+ aOperationType == EditAction::deleteText) {
+ if (!startNode->IsContent() ||
+ !endNode->IsContent()) {
+ // GetPromotedPoint cannot promote node when action type is text
+ // operation and selected node isn't content node.
+ return;
+ }
+ }
+
// Make a new adjusted range to represent the appropriate block content.
// This is tricky. The basic idea is to push out the range endpoints to
// truly enclose the blocks that we will affect.
EditorDOMPoint opStart =
GetPromotedPoint(kStart, *startNode, startOffset, aOperationType);
EditorDOMPoint opEnd =
GetPromotedPoint(kEnd, *endNode, endOffset, aOperationType);