Bug 1460509 - part 45: Test if HTMLEditRules::PromoteRange() won't get range in Selection r?m_kato
PromoteRange() related methods do not change Selection nor the DOM tree.
Therefore, they must be safe. However, only PromoteRange() takes an nsRange
instance and modifies it. If it's in Selection, that causes selectionchange
event. Therefore, we should check if given range is in Selection with
MOZ_ASSERT().
MozReview-Commit-ID: AXkmHFB4P08
--- a/editor/libeditor/HTMLEditRules.cpp
+++ b/editor/libeditor/HTMLEditRules.cpp
@@ -6656,16 +6656,17 @@ HTMLEditRules::GetPromotedRanges(nsTArra
* PromoteRange() expands a range to include any parents for which all editable
* children are already in range.
*/
void
HTMLEditRules::PromoteRange(nsRange& aRange,
EditAction aOperationType)
{
MOZ_ASSERT(IsEditorDataAvailable());
+ MOZ_ASSERT(!aRange.IsInSelection());
if (!aRange.IsPositioned()) {
return;
}
nsCOMPtr<nsINode> startNode = aRange.GetStartContainer();
nsCOMPtr<nsINode> endNode = aRange.GetEndContainer();
int32_t startOffset = aRange.StartOffset();