Bug 1587433: part 7.3) Adapt callers of `RangeBoundaryBase::Offset()`. r=smaug
☠☠ backed out by c0c22dbdd5b8 ☠ ☠
authorMirko Brodesser <mbrodesser@mozilla.com>
Mon, 16 Dec 2019 11:04:01 +0000
changeset 507074 f9255884980fc6a89687af026785c672b702aed2
parent 507073 50a798e664a1d32b734b47b68c0213d149abe604
child 507075 f8a7e23843b842bb01c695a0ba16f7d86bd08ec3
push id36922
push userncsoregi@mozilla.com
push dateMon, 16 Dec 2019 17:21:47 +0000
treeherdermozilla-central@27d0d6cc2131 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1587433
milestone73.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1587433: part 7.3) Adapt callers of `RangeBoundaryBase::Offset()`. r=smaug Differential Revision: https://phabricator.services.mozilla.com/D54493
editor/libeditor/DeleteRangeTransaction.cpp
--- a/editor/libeditor/DeleteRangeTransaction.cpp
+++ b/editor/libeditor/DeleteRangeTransaction.cpp
@@ -125,23 +125,26 @@ nsresult DeleteRangeTransaction::CreateT
 
   // see what kind of node we have
   if (RefPtr<Text> textNode = Text::FromNode(aStart.Container())) {
     // if the node is a chardata node, then delete chardata content
     int32_t numToDel;
     if (aStart == aEnd) {
       numToDel = 1;
     } else {
-      numToDel = aEnd.Offset() - aStart.Offset();
+      numToDel = *aEnd.Offset(RawRangeBoundary::OffsetFilter::kValidOffsets) -
+                 *aStart.Offset(RawRangeBoundary::OffsetFilter::kValidOffsets);
       MOZ_DIAGNOSTIC_ASSERT(numToDel > 0);
     }
 
     RefPtr<DeleteTextTransaction> deleteTextTransaction =
-        DeleteTextTransaction::MaybeCreate(*mEditorBase, *textNode,
-                                           aStart.Offset(), numToDel);
+        DeleteTextTransaction::MaybeCreate(
+            *mEditorBase, *textNode,
+            *aStart.Offset(RawRangeBoundary::OffsetFilter::kValidOffsets),
+            numToDel);
     // If the text node isn't editable, it should be never undone/redone.
     // So, the transaction shouldn't be recorded.
     if (NS_WARN_IF(!deleteTextTransaction)) {
       return NS_ERROR_FAILURE;
     }
     AppendChild(deleteTextTransaction);
     return NS_OK;
   }
@@ -178,21 +181,21 @@ nsresult DeleteRangeTransaction::CreateT
   RefPtr<Text> textNode = Text::FromNode(aPoint.Container());
   if (!textNode) {
     return NS_OK;
   }
 
   // If the node is a chardata node, then delete chardata content
   uint32_t startOffset, numToDelete;
   if (nsIEditor::eNext == aAction) {
-    startOffset = aPoint.Offset();
-    numToDelete = aPoint.Container()->Length() - aPoint.Offset();
+    startOffset = *aPoint.Offset(RawRangeBoundary::OffsetFilter::kValidOffsets);
+    numToDelete = aPoint.Container()->Length() - startOffset;
   } else {
     startOffset = 0;
-    numToDelete = aPoint.Offset();
+    numToDelete = *aPoint.Offset(RawRangeBoundary::OffsetFilter::kValidOffsets);
   }
 
   if (!numToDelete) {
     return NS_OK;
   }
 
   RefPtr<DeleteTextTransaction> deleteTextTransaction =
       DeleteTextTransaction::MaybeCreate(*mEditorBase, *textNode, startOffset,