Bug 1460509 - part 45: Test if HTMLEditRules::PromoteRange() won't get range in Selection r?m_kato draft
authorMasayuki Nakano <masayuki@d-toybox.com>
Tue, 15 May 2018 18:39:27 +0900
changeset 798763 721d4dddaa2a5a4af8898e08777f75b8b4dc2e44
parent 798762 137b2f47174b3c469933f7bef433bad57fe73c60
child 798764 5f0c37e2f604b38cd2700fc881f00e982dfad088
push id110840
push usermasayuki@d-toybox.com
push dateWed, 23 May 2018 13:41:58 +0000
reviewersm_kato
bugs1460509
milestone62.0a1
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
editor/libeditor/HTMLEditRules.cpp
--- 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();