Bug 1587433: part 7.5) Adapt callers of `RangeBoundaryBase::Offset()`. r=smaug
☠☠ backed out by c0c22dbdd5b8 ☠ ☠
authorMirko Brodesser <mbrodesser@mozilla.com>
Wed, 11 Dec 2019 12:26:10 +0000
changeset 507076 79ec11ba7fde31452a85d2f854e9f4831ffb5582
parent 507075 f8a7e23843b842bb01c695a0ba16f7d86bd08ec3
child 507077 69ad70a4f85e79b26e1a86b6f134f4854a326eb1
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.5) Adapt callers of `RangeBoundaryBase::Offset()`. r=smaug Differential Revision: https://phabricator.services.mozilla.com/D54495
dom/base/RangeUtils.cpp
dom/base/nsContentUtils.cpp
editor/libeditor/HTMLEditSubActionHandler.cpp
--- a/dom/base/RangeUtils.cpp
+++ b/dom/base/RangeUtils.cpp
@@ -149,27 +149,31 @@ nsresult RangeUtils::CompareNodeToRange(
   // being -1 and it seems to deal with it, or at least we aren't aware of any
   // problems arising because of it. We don't have a better idea how to get
   // rid of the warning without much larger changes so we do this just to
   // silence the warning. (Bug 1438996)
 
   // is RANGE(start) <= NODE(start) ?
   bool disconnected = false;
   *aNodeIsBeforeRange =
-      nsContentUtils::ComparePoints(aAbstractRange->StartRef().Container(),
-                                    aAbstractRange->StartRef().Offset(), parent,
-                                    nodeStart, &disconnected) > 0;
+      nsContentUtils::ComparePoints(
+          aAbstractRange->StartRef().Container(),
+          *aAbstractRange->StartRef().Offset(
+              RangeBoundary::OffsetFilter::kValidOrInvalidOffsets),
+          parent, nodeStart, &disconnected) > 0;
   if (NS_WARN_IF(disconnected)) {
     return NS_ERROR_DOM_WRONG_DOCUMENT_ERR;
   }
 
   // is RANGE(end) >= NODE(end) ?
   *aNodeIsAfterRange =
-      nsContentUtils::ComparePoints(aAbstractRange->EndRef().Container(),
-                                    aAbstractRange->EndRef().Offset(), parent,
-                                    nodeEnd, &disconnected) < 0;
+      nsContentUtils::ComparePoints(
+          aAbstractRange->EndRef().Container(),
+          *aAbstractRange->EndRef().Offset(
+              RangeBoundary::OffsetFilter::kValidOrInvalidOffsets),
+          parent, nodeEnd, &disconnected) < 0;
   if (NS_WARN_IF(disconnected)) {
     return NS_ERROR_DOM_WRONG_DOCUMENT_ERR;
   }
   return NS_OK;
 }
 
 }  // namespace mozilla
--- a/dom/base/nsContentUtils.cpp
+++ b/dom/base/nsContentUtils.cpp
@@ -2491,19 +2491,24 @@ int32_t nsContentUtils::ComparePoints(
     const RangeBoundaryBase<FPT, FRT>& aFirstBoundary,
     const RangeBoundaryBase<SPT, SRT>& aSecondBoundary, bool* aDisconnected) {
   if (NS_WARN_IF(!aFirstBoundary.IsSet()) ||
       NS_WARN_IF(!aSecondBoundary.IsSet())) {
     return -1;
   }
   // XXX Re-implement this without calling `Offset()` as far as possible,
   //     and the other overload should be an alias of this.
-  return ComparePoints(aFirstBoundary.Container(), aFirstBoundary.Offset(),
-                       aSecondBoundary.Container(), aSecondBoundary.Offset(),
-                       aDisconnected);
+  return ComparePoints(
+      aFirstBoundary.Container(),
+      *aFirstBoundary.Offset(
+          RangeBoundaryBase<FPT, FRT>::OffsetFilter::kValidOrInvalidOffsets),
+      aSecondBoundary.Container(),
+      *aSecondBoundary.Offset(
+          RangeBoundaryBase<SPT, SRT>::OffsetFilter::kValidOrInvalidOffsets),
+      aDisconnected);
 }
 
 inline bool IsCharInSet(const char* aSet, const char16_t aChar) {
   char16_t ch;
   while ((ch = *aSet)) {
     if (aChar == char16_t(ch)) {
       return true;
     }
--- a/editor/libeditor/HTMLEditSubActionHandler.cpp
+++ b/editor/libeditor/HTMLEditSubActionHandler.cpp
@@ -7189,17 +7189,18 @@ EditorDOMPoint HTMLEditor::GetWhiteSpace
     const RangeBoundaryBase<PT, RT>& aPoint, ScanDirection aScanDirection) {
   if (NS_WARN_IF(!aPoint.IsSet()) ||
       NS_WARN_IF(!aPoint.Container()->IsContent())) {
     return EditorDOMPoint();
   }
 
   bool isSpace = false, isNBSP = false;
   nsIContent* newContent = aPoint.Container()->AsContent();
-  int32_t newOffset = aPoint.Offset();
+  int32_t newOffset = *aPoint.Offset(
+      RangeBoundaryBase<PT, RT>::OffsetFilter::kValidOrInvalidOffsets);
   while (newContent) {
     int32_t offset = -1;
     nsCOMPtr<nsIContent> content;
     if (aScanDirection == ScanDirection::Backward) {
       HTMLEditor::IsPrevCharInNodeWhitespace(newContent, newOffset, &isSpace,
                                              &isNBSP, getter_AddRefs(content),
                                              &offset);
     } else {