Bug 1623413 - Part 2: Rename Collapse() to CollapseInLimiter() r=masayuki
authorKagami Sascha Rosylight <krosylight@mozilla.com>
Thu, 03 Sep 2020 03:45:26 +0000
changeset 547645 5d57d36010c1d67718ed2de777d737e8c0c73b34
parent 547644 6f419d6b635aa0106d580122ab183f8c75401460
child 547646 aa032cbc94551a0f6e7e821d78aa0388f998e830
push id37752
push usercbrindusan@mozilla.com
push dateThu, 03 Sep 2020 15:18:16 +0000
treeherdermozilla-central@aa032cbc9455 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmasayuki
bugs1623413
milestone82.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 1623413 - Part 2: Rename Collapse() to CollapseInLimiter() r=masayuki Depends on D88702 Differential Revision: https://phabricator.services.mozilla.com/D88920
dom/base/Selection.cpp
dom/base/Selection.h
dom/events/EventStateManager.cpp
editor/libeditor/CompositionTransaction.cpp
editor/libeditor/CreateElementTransaction.cpp
editor/libeditor/DeleteRangeTransaction.cpp
editor/libeditor/DeleteTextTransaction.cpp
editor/libeditor/EditorBase.cpp
editor/libeditor/HTMLEditSubActionHandler.cpp
editor/libeditor/HTMLEditor.cpp
editor/libeditor/HTMLEditor.h
editor/libeditor/HTMLEditorEventListener.cpp
editor/libeditor/InsertNodeTransaction.cpp
editor/libeditor/InsertTextTransaction.cpp
editor/libeditor/ReplaceTextTransaction.cpp
editor/libeditor/SplitNodeTransaction.cpp
editor/libeditor/TextEditSubActionHandler.cpp
editor/libeditor/TextEditor.cpp
editor/libeditor/TextEditorDataTransfer.cpp
editor/spellchecker/TextServicesDocument.cpp
layout/generic/nsFrameSelection.cpp
--- a/dom/base/Selection.cpp
+++ b/dom/base/Selection.cpp
@@ -2181,17 +2181,17 @@ void Selection::CollapseToStart(ErrorRes
     mFrameSelection->AddChangeReasons(
         nsISelectionListener::COLLAPSETOSTART_REASON);
   }
   nsINode* container = firstRange->GetStartContainer();
   if (!container) {
     aRv.Throw(NS_ERROR_FAILURE);
     return;
   }
-  Collapse(*container, firstRange->StartOffset(), aRv);
+  CollapseInLimiter(*container, firstRange->StartOffset(), aRv);
 }
 
 /*
  * Sets the whole selection to be one point
  * at the end of the current selection
  */
 void Selection::CollapseToEndJS(ErrorResult& aRv) {
   AutoRestore<bool> calledFromJSRestorer(mCalledByJS);
@@ -2217,17 +2217,17 @@ void Selection::CollapseToEnd(ErrorResul
     mFrameSelection->AddChangeReasons(
         nsISelectionListener::COLLAPSETOEND_REASON);
   }
   nsINode* container = lastRange->GetEndContainer();
   if (!container) {
     aRv.Throw(NS_ERROR_FAILURE);
     return;
   }
-  Collapse(*container, lastRange->EndOffset(), aRv);
+  CollapseInLimiter(*container, lastRange->EndOffset(), aRv);
 }
 
 void Selection::GetType(nsAString& aOutType) const {
   if (!RangeCount()) {
     aOutType.AssignLiteral("None");
   } else if (IsCollapsed()) {
     aOutType.AssignLiteral("Caret");
   } else {
@@ -3193,17 +3193,17 @@ void Selection::DeleteFromDocument(Error
       return;
     }
   }
 
   // Collapse to the new location.
   // If we deleted one character, then we move back one element.
   // FIXME  We don't know how to do this past frame boundaries yet.
   if (AnchorOffset() > 0) {
-    Collapse(GetAnchorNode(), AnchorOffset());
+    CollapseInLimiter(GetAnchorNode(), AnchorOffset());
   }
 #ifdef DEBUG
   else {
     printf("Don't know how to set selection back past frame boundary\n");
   }
 #endif
 }
 
@@ -3270,17 +3270,17 @@ void Selection::Modify(const nsAString& 
   if (!extend) {
     nsINode* focusNode = GetFocusNode();
     // We should have checked earlier that there was a focus node.
     if (!focusNode) {
       aRv.Throw(NS_ERROR_UNEXPECTED);
       return;
     }
     uint32_t focusOffset = FocusOffset();
-    Collapse(focusNode, focusOffset);
+    CollapseInLimiter(focusNode, focusOffset);
   }
 
   // If the paragraph direction of the focused frame is right-to-left,
   // we may have to swap the direction of movement.
   nsIFrame* frame = GetPrimaryFrameForFocusNode(visual);
   if (frame) {
     nsBidiDirection paraDir = nsBidiPresUtils::ParagraphDirection(frame);
 
--- a/dom/base/Selection.h
+++ b/dom/base/Selection.h
@@ -185,28 +185,28 @@ class Selection final : public nsSupport
   [[nodiscard]] MOZ_CAN_RUN_SCRIPT_BOUNDARY nsresult
   AddRangesForSelectableNodes(
       nsRange* aRange, int32_t* aOutIndex,
       DispatchSelectstartEvent aDispatchSelectstartEvent);
 
  public:
   nsresult RemoveCollapsedRanges();
   nsresult Clear(nsPresContext* aPresContext);
-  nsresult Collapse(nsINode* aContainer, int32_t aOffset) {
+  nsresult CollapseInLimiter(nsINode* aContainer, int32_t aOffset) {
     if (!aContainer) {
       return NS_ERROR_INVALID_ARG;
     }
-    return Collapse(RawRangeBoundary(aContainer, aOffset));
+    return CollapseInLimiter(RawRangeBoundary(aContainer, aOffset));
   }
-  nsresult Collapse(const RawRangeBoundary& aPoint) {
+  nsresult CollapseInLimiter(const RawRangeBoundary& aPoint) {
     ErrorResult result;
-    Collapse(aPoint, result);
+    CollapseInLimiter(aPoint, result);
     return result.StealNSResult();
   }
-  void Collapse(const RawRangeBoundary& aPoint, ErrorResult& aRv) {
+  void CollapseInLimiter(const RawRangeBoundary& aPoint, ErrorResult& aRv) {
     CollapseInternal(InLimiter::eYes, aPoint, aRv);
   }
 
   MOZ_CAN_RUN_SCRIPT_BOUNDARY
   nsresult Extend(nsINode* aContainer, int32_t aOffset);
 
   /**
    * See mStyledRanges.mRanges.
@@ -433,19 +433,19 @@ class Selection final : public nsSupport
    * in the given node. When the selection is collapsed, and the content
    * is focused and editable, the caret will blink there.
    * @param aContainer The given node where the selection will be set
    * @param offset      Where in given dom node to place the selection (the
    *                    offset into the given node)
    */
   // TODO: mark as `MOZ_CAN_RUN_SCRIPT`
   // (https://bugzilla.mozilla.org/show_bug.cgi?id=1615296).
-  MOZ_CAN_RUN_SCRIPT_BOUNDARY void Collapse(nsINode& aContainer,
-                                            uint32_t aOffset,
-                                            ErrorResult& aRv) {
+  MOZ_CAN_RUN_SCRIPT_BOUNDARY void CollapseInLimiter(nsINode& aContainer,
+                                                     uint32_t aOffset,
+                                                     ErrorResult& aRv) {
     CollapseInternal(InLimiter::eYes, RawRangeBoundary(&aContainer, aOffset),
                      aRv);
   }
 
  private:
   enum class InLimiter {
     // If eYes, the method may reset selection limiter and move focus if the
     // given range is out of the limiter.
--- a/dom/events/EventStateManager.cpp
+++ b/dom/events/EventStateManager.cpp
@@ -5225,17 +5225,17 @@ nsresult EventStateManager::HandleMiddle
   int32_t offset;
   nsLayoutUtils::GetContainerAndOffsetAtEvent(
       aPresShell, aMouseEvent, getter_AddRefs(container), &offset);
   if (container) {
     // XXX If readonly or disabled <input> or <textarea> in contenteditable
     //     designMode editor is clicked, the point is in the editor.
     //     However, outer HTMLEditor and Selection should handle it.
     //     So, in such case, Selection::Collapse() will fail.
-    DebugOnly<nsresult> rv = selection->Collapse(container, offset);
+    DebugOnly<nsresult> rv = selection->CollapseInLimiter(container, offset);
     NS_WARNING_ASSERTION(NS_SUCCEEDED(rv),
                          "Failed to collapse Selection at middle clicked");
   }
 
   int32_t clipboardType = nsIClipboard::kGlobalClipboard;
   nsresult rv = NS_OK;
   nsCOMPtr<nsIClipboard> clipboardService =
       do_GetService("@mozilla.org/widget/clipboard;1", &rv);
--- a/editor/libeditor/CompositionTransaction.cpp
+++ b/editor/libeditor/CompositionTransaction.cpp
@@ -174,18 +174,18 @@ NS_IMETHODIMP CompositionTransaction::Un
   ErrorResult error;
   editorBase->DoDeleteText(textNode, mOffset, mStringToInsert.Length(), error);
   if (error.Failed()) {
     NS_WARNING("EditorBase::DoDeleteText() failed");
     return error.StealNSResult();
   }
 
   // set the selection to the insertion point where the string was removed
-  nsresult rv = selection->Collapse(textNode, mOffset);
-  NS_ASSERTION(NS_SUCCEEDED(rv), "Selection::Collapse() failed");
+  nsresult rv = selection->CollapseInLimiter(textNode, mOffset);
+  NS_ASSERTION(NS_SUCCEEDED(rv), "Selection::CollapseInLimiter() failed");
   return rv;
 }
 
 NS_IMETHODIMP CompositionTransaction::Merge(nsITransaction* aOtherTransaction,
                                             bool* aDidMerge) {
   if (NS_WARN_IF(!aOtherTransaction) || NS_WARN_IF(!aDidMerge)) {
     return NS_ERROR_INVALID_ARG;
   }
@@ -294,20 +294,20 @@ nsresult CompositionTransaction::SetIMES
       NS_ASSERTION(!setCaret, "The ranges already has caret position");
       NS_ASSERTION(!textRange.Length(),
                    "EditorBase doesn't support wide caret");
       int32_t caretOffset = static_cast<int32_t>(
           aOffsetInNode +
           std::min(textRange.mStartOffset, aLengthOfCompositionString));
       MOZ_ASSERT(caretOffset >= 0 &&
                  static_cast<uint32_t>(caretOffset) <= maxOffset);
-      rv = selection->Collapse(aTextNode, caretOffset);
+      rv = selection->CollapseInLimiter(aTextNode, caretOffset);
       NS_WARNING_ASSERTION(
           NS_SUCCEEDED(rv),
-          "Selection::Collapse() failed, but might be ignored");
+          "Selection::CollapseInLimiter() failed, but might be ignored");
       setCaret = setCaret || NS_SUCCEEDED(rv);
       if (!setCaret) {
         continue;
       }
       // If caret range is specified explicitly, we should show the caret if
       // it should be so.
       aEditorBase.HideCaret(false);
       continue;
@@ -367,18 +367,19 @@ nsresult CompositionTransaction::SetIMES
 
   // If the ranges doesn't include explicit caret position, let's set the
   // caret to the end of composition string.
   if (!setCaret) {
     int32_t caretOffset =
         static_cast<int32_t>(aOffsetInNode + aLengthOfCompositionString);
     MOZ_ASSERT(caretOffset >= 0 &&
                static_cast<uint32_t>(caretOffset) <= maxOffset);
-    rv = selection->Collapse(aTextNode, caretOffset);
-    NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "Selection::Collapse() failed");
+    rv = selection->CollapseInLimiter(aTextNode, caretOffset);
+    NS_WARNING_ASSERTION(NS_SUCCEEDED(rv),
+                         "Selection::CollapseInLimiter() failed");
 
     // If caret range isn't specified explicitly, we should hide the caret.
     // Hiding the caret benefits a Windows build (see bug 555642 comment #6).
     // However, when there is no range, we should keep showing caret.
     if (countOfRanges) {
       aEditorBase.HideCaret(true);
     }
   }
--- a/editor/libeditor/CreateElementTransaction.cpp
+++ b/editor/libeditor/CreateElementTransaction.cpp
@@ -114,19 +114,19 @@ NS_IMETHODIMP CreateElementTransaction::
   EditorRawDOMPoint afterNewNode(EditorRawDOMPoint::After(newElement));
   if (NS_WARN_IF(!afterNewNode.IsSet())) {
     // If mutation observer or mutation event listener moved or removed the
     // new node, we hit this case.  Should we use script blocker while we're
     // in this method?
     return NS_ERROR_FAILURE;
   }
   IgnoredErrorResult ignoredError;
-  selection->Collapse(afterNewNode, ignoredError);
+  selection->CollapseInLimiter(afterNewNode, ignoredError);
   NS_WARNING_ASSERTION(!ignoredError.Failed(),
-                       "Selection::Collapse() failed, but ignored");
+                       "Selection::CollapseInLimiter() failed, but ignored");
   return NS_OK;
 }
 
 void CreateElementTransaction::InsertNewNode(ErrorResult& aError) {
   MOZ_ASSERT(mNewElement);
   MOZ_ASSERT(mPointToInsert.IsSet());
 
   if (mPointToInsert.IsSetAndValid()) {
--- a/editor/libeditor/DeleteRangeTransaction.cpp
+++ b/editor/libeditor/DeleteRangeTransaction.cpp
@@ -93,18 +93,19 @@ NS_IMETHODIMP DeleteRangeTransaction::Do
   if (!mEditorBase->AllowsTransactionsToChangeSelection()) {
     return NS_OK;
   }
 
   RefPtr<Selection> selection = mEditorBase->GetSelection();
   if (NS_WARN_IF(!selection)) {
     return NS_ERROR_NOT_INITIALIZED;
   }
-  rv = selection->Collapse(startRef.AsRaw());
-  NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "Selection::Collapsed() failed");
+  rv = selection->CollapseInLimiter(startRef.AsRaw());
+  NS_WARNING_ASSERTION(NS_SUCCEEDED(rv),
+                       "Selection::CollapseInLimiter() failed");
   return rv;
 }
 
 NS_IMETHODIMP DeleteRangeTransaction::UndoTransaction() {
   nsresult rv = EditAggregateTransaction::UndoTransaction();
   NS_WARNING_ASSERTION(NS_SUCCEEDED(rv),
                        "EditAggregateTransaction::UndoTransaction() failed");
   return rv;
--- a/editor/libeditor/DeleteTextTransaction.cpp
+++ b/editor/libeditor/DeleteTextTransaction.cpp
@@ -126,18 +126,19 @@ NS_IMETHODIMP DeleteTextTransaction::DoT
   if (!editorBase->AllowsTransactionsToChangeSelection()) {
     return NS_OK;
   }
 
   RefPtr<Selection> selection = editorBase->GetSelection();
   if (NS_WARN_IF(!selection)) {
     return NS_ERROR_FAILURE;
   }
-  selection->Collapse(EditorRawDOMPoint(textNode, mOffset), error);
-  NS_WARNING_ASSERTION(!error.Failed(), "Selection::Collapse() failed");
+  selection->CollapseInLimiter(EditorRawDOMPoint(textNode, mOffset), error);
+  NS_WARNING_ASSERTION(!error.Failed(),
+                       "Selection::CollapseInLimiter() failed");
   return error.StealNSResult();
 }
 
 // XXX: We may want to store the selection state and restore it properly.  Was
 //     it an insertion point or an extended selection?
 NS_IMETHODIMP DeleteTextTransaction::UndoTransaction() {
   if (NS_WARN_IF(!CanDoIt())) {
     return NS_ERROR_NOT_AVAILABLE;
--- a/editor/libeditor/EditorBase.cpp
+++ b/editor/libeditor/EditorBase.cpp
@@ -1110,39 +1110,42 @@ NS_IMETHODIMP EditorBase::BeginningOfDoc
   if (NS_WARN_IF(!rootElement)) {
     return NS_ERROR_NULL_POINTER;
   }
 
   // find first editable thingy
   nsCOMPtr<nsINode> firstNode = GetFirstEditableNode(rootElement);
   if (!firstNode) {
     // just the root node, set selection to inside the root
-    nsresult rv = SelectionRefPtr()->Collapse(rootElement, 0);
-    NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "Selection::Collapse() failed");
+    nsresult rv = SelectionRefPtr()->CollapseInLimiter(rootElement, 0);
+    NS_WARNING_ASSERTION(NS_SUCCEEDED(rv),
+                         "Selection::CollapseInLimiter() failed");
     return rv;
   }
 
   if (firstNode->IsText()) {
     // If firstNode is text, set selection to beginning of the text node.
-    nsresult rv = SelectionRefPtr()->Collapse(firstNode, 0);
-    NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "Selection::Collapse() failed");
+    nsresult rv = SelectionRefPtr()->CollapseInLimiter(firstNode, 0);
+    NS_WARNING_ASSERTION(NS_SUCCEEDED(rv),
+                         "Selection::CollapseInLimiter() failed");
     return rv;
   }
 
   // Otherwise, it's a leaf node and we set the selection just in front of it.
   nsCOMPtr<nsIContent> parent = firstNode->GetParent();
   if (NS_WARN_IF(!parent)) {
     return NS_ERROR_NULL_POINTER;
   }
 
   MOZ_ASSERT(
       parent->ComputeIndexOf(firstNode) == 0,
       "How come the first node isn't the left most child in its parent?");
-  nsresult rv = SelectionRefPtr()->Collapse(parent, 0);
-  NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "Selection::Collapse() failed");
+  nsresult rv = SelectionRefPtr()->CollapseInLimiter(parent, 0);
+  NS_WARNING_ASSERTION(NS_SUCCEEDED(rv),
+                       "Selection::CollapseInLimiter() failed");
   return rv;
 }
 
 NS_IMETHODIMP EditorBase::EndOfDocument() {
   AutoEditActionDataSetter editActionData(*this, EditAction::eNotEditing);
   if (NS_WARN_IF(!editActionData.CanHandle())) {
     return NS_ERROR_NOT_INITIALIZED;
   }
@@ -1171,19 +1174,20 @@ nsresult EditorBase::CollapseSelectionTo
   nsIContent* lastContent = rootElement;
   for (nsIContent* child = lastContent->GetLastChild();
        child && (IsTextEditor() || HTMLEditUtils::IsContainerNode(*child));
        child = child->GetLastChild()) {
     lastContent = child;
   }
 
   uint32_t length = lastContent->Length();
-  nsresult rv =
-      SelectionRefPtr()->Collapse(lastContent, static_cast<int32_t>(length));
-  NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "Selection::Collapse() failed");
+  nsresult rv = SelectionRefPtr()->CollapseInLimiter(
+      lastContent, static_cast<int32_t>(length));
+  NS_WARNING_ASSERTION(NS_SUCCEEDED(rv),
+                       "Selection::CollapseInLimiter() failed");
   return rv;
 }
 
 NS_IMETHODIMP EditorBase::GetDocumentModified(bool* aOutDocModified) {
   if (NS_WARN_IF(!aOutDocModified)) {
     return NS_ERROR_INVALID_ARG;
   }
 
@@ -2702,22 +2706,22 @@ nsresult EditorBase::SetTextNodeWithoutT
   ErrorResult error;
   DoSetText(aTextNode, aString, error);
   if (error.Failed()) {
     NS_WARNING("EditorBase::DoSetText() failed");
     return error.StealNSResult();
   }
 
   DebugOnly<nsresult> rvIgnored =
-      SelectionRefPtr()->Collapse(&aTextNode, aString.Length());
+      SelectionRefPtr()->CollapseInLimiter(&aTextNode, aString.Length());
   if (NS_WARN_IF(Destroyed())) {
     return NS_ERROR_EDITOR_DESTROYED;
   }
   NS_ASSERTION(NS_SUCCEEDED(rvIgnored),
-               "Selection::Collapse() failed, but ignored");
+               "Selection::CollapseInLimiter() failed, but ignored");
 
   RangeUpdaterRef().SelAdjReplaceText(aTextNode, 0, length, aString.Length());
 
   // Let listeners know what happened
   if (!mActionListeners.IsEmpty() && !aString.IsEmpty()) {
     for (auto& listener : mActionListeners.Clone()) {
       DebugOnly<nsresult> rvIgnored =
           listener->DidInsertText(&aTextNode, 0, aString, NS_OK);
@@ -3232,22 +3236,23 @@ nsresult EditorBase::MaybeCreatePaddingB
     return NS_ERROR_EDITOR_DESTROYED;
   }
   if (NS_FAILED(rv)) {
     NS_WARNING("EditorBase::InsertNodeWithTransaction() failed");
     return rv;
   }
 
   // Set selection.
-  SelectionRefPtr()->Collapse(EditorRawDOMPoint(rootElement, 0), ignoredError);
+  SelectionRefPtr()->CollapseInLimiter(EditorRawDOMPoint(rootElement, 0),
+                                       ignoredError);
   if (NS_WARN_IF(Destroyed())) {
     return NS_ERROR_EDITOR_DESTROYED;
   }
   NS_WARNING_ASSERTION(!ignoredError.Failed(),
-                       "Selection::Collapse() failed, but ignored");
+                       "Selection::CollapseInLimiter() failed, but ignored");
   return NS_OK;
 }
 
 void EditorBase::BeginUpdateViewBatch() {
   MOZ_ASSERT(IsEditActionDataAvailable());
   MOZ_ASSERT(mUpdateCount >= 0, "bad state");
 
   if (!mUpdateCount) {
--- a/editor/libeditor/HTMLEditSubActionHandler.cpp
+++ b/editor/libeditor/HTMLEditSubActionHandler.cpp
@@ -3599,18 +3599,19 @@ HTMLEditor::AutoDeleteRangesHandler::Han
   if (result.isErr()) {
     NS_WARNING(
         "HTMLEditor::DeleteTextAndNormalizeSurroundingWhiteSpaces() failed");
     return EditActionHandled(result.unwrapErr());
   }
   const EditorDOMPoint& newCaretPosition = result.inspect();
   MOZ_ASSERT(newCaretPosition.IsSetAndValid());
 
-  DebugOnly<nsresult> rvIgnored = aHTMLEditor.SelectionRefPtr()->Collapse(
-      newCaretPosition.ToRawRangeBoundary());
+  DebugOnly<nsresult> rvIgnored =
+      aHTMLEditor.SelectionRefPtr()->CollapseInLimiter(
+          newCaretPosition.ToRawRangeBoundary());
   NS_WARNING_ASSERTION(NS_SUCCEEDED(rvIgnored),
                        "Selection::Collapse() failed, but ignored");
   return EditActionHandled();
 }
 
 EditActionResult HTMLEditor::AutoDeleteRangesHandler::
     HandleDeleteCollapsedSelectionAtWhiteSpaces(
         HTMLEditor& aHTMLEditor, nsIEditor::EDirection aDirectionAndAmount,
--- a/editor/libeditor/HTMLEditor.cpp
+++ b/editor/libeditor/HTMLEditor.cpp
@@ -4674,23 +4674,23 @@ nsresult HTMLEditor::DoJoinNodes(nsICont
     }
     if (NS_WARN_IF(error.Failed())) {
       return error.StealNSResult();
     }
   }
 
   if (allowedTransactionsToChangeSelection) {
     // Editor wants us to set selection at join point.
-    DebugOnly<nsresult> rvIgnored = SelectionRefPtr()->Collapse(
+    DebugOnly<nsresult> rvIgnored = SelectionRefPtr()->CollapseInLimiter(
         &aContentToKeep, AssertedCast<int32_t>(firstNodeLength));
     if (NS_WARN_IF(Destroyed())) {
       return NS_ERROR_EDITOR_DESTROYED;
     }
     NS_WARNING_ASSERTION(NS_SUCCEEDED(rvIgnored),
-                         "Selection::Collapse() failed, but ignored");
+                         "Selection::CollapseInLimiter() failed, but ignored");
   }
 
   return NS_OK;
 }
 
 nsresult HTMLEditor::MoveNodeWithTransaction(
     nsIContent& aContent, const EditorDOMPoint& aPointToInsert) {
   MOZ_ASSERT(aPointToInsert.IsSetAndValid());
@@ -4760,19 +4760,19 @@ already_AddRefed<Element> HTMLEditor::De
     NS_WARNING("EditorBase::CreateNodeWithTransaction() failed");
     return nullptr;
   }
 
   // We want the selection to be just after the new node
   EditorRawDOMPoint afterNewElement(EditorRawDOMPoint::After(newElement));
   MOZ_ASSERT(afterNewElement.IsSetAndValid());
   IgnoredErrorResult ignoredError;
-  SelectionRefPtr()->Collapse(afterNewElement, ignoredError);
+  SelectionRefPtr()->CollapseInLimiter(afterNewElement, ignoredError);
   if (ignoredError.Failed()) {
-    NS_WARNING("Selection::Collapse() failed");
+    NS_WARNING("Selection::CollapseInLimiter() failed");
     // XXX Even if it succeeded to create new element, this returns error
     //     when Selection.Collapse() fails something.  This could occur with
     //     mutation observer or mutation event listener.
     return nullptr;
   }
   return newElement.forget();
 }
 
@@ -4808,46 +4808,49 @@ nsresult HTMLEditor::DeleteSelectionAndP
   }
 
   if (atAnchor.IsStartOfContainer()) {
     EditorRawDOMPoint atAnchorContainer(atAnchor.GetContainer());
     if (NS_WARN_IF(!atAnchorContainer.IsSetAndValid())) {
       return NS_ERROR_FAILURE;
     }
     ErrorResult error;
-    SelectionRefPtr()->Collapse(atAnchorContainer, error);
-    NS_WARNING_ASSERTION(!error.Failed(), "Selection::Collapse() failed");
+    SelectionRefPtr()->CollapseInLimiter(atAnchorContainer, error);
+    NS_WARNING_ASSERTION(!error.Failed(),
+                         "Selection::CollapseInLimiter() failed");
     return error.StealNSResult();
   }
 
   if (atAnchor.IsEndOfContainer()) {
     EditorRawDOMPoint afterAnchorContainer(atAnchor.GetContainer());
     if (NS_WARN_IF(!afterAnchorContainer.AdvanceOffset())) {
       return NS_ERROR_FAILURE;
     }
     ErrorResult error;
-    SelectionRefPtr()->Collapse(afterAnchorContainer, error);
-    NS_WARNING_ASSERTION(!error.Failed(), "Selection::Collapse() failed");
+    SelectionRefPtr()->CollapseInLimiter(afterAnchorContainer, error);
+    NS_WARNING_ASSERTION(!error.Failed(),
+                         "Selection::CollapseInLimiter() failed");
     return error.StealNSResult();
   }
 
   ErrorResult error;
   nsCOMPtr<nsIContent> newLeftNode = SplitNodeWithTransaction(atAnchor, error);
   if (error.Failed()) {
     NS_WARNING("HTMLEditor::SplitNodeWithTransaction() failed");
     return error.StealNSResult();
   }
 
   EditorRawDOMPoint atRightNode(atAnchor.GetContainer());
   if (NS_WARN_IF(!atRightNode.IsSet())) {
     return NS_ERROR_FAILURE;
   }
   MOZ_ASSERT(atRightNode.IsSetAndValid());
-  SelectionRefPtr()->Collapse(atRightNode, error);
-  NS_WARNING_ASSERTION(!error.Failed(), "Selection::Collapse() failed");
+  SelectionRefPtr()->CollapseInLimiter(atRightNode, error);
+  NS_WARNING_ASSERTION(!error.Failed(),
+                       "Selection::CollapseInLimiter() failed");
   return error.StealNSResult();
 }
 
 nsIContent* HTMLEditor::GetPriorHTMLSibling(nsINode* aNode,
                                             SkipWhiteSpace aSkipWS) const {
   MOZ_ASSERT(aNode);
 
   nsIContent* content = aNode->GetPreviousSibling();
--- a/editor/libeditor/HTMLEditor.h
+++ b/editor/libeditor/HTMLEditor.h
@@ -3024,22 +3024,23 @@ class HTMLEditor final : public TextEdit
   }
 
   template <typename PT, typename CT>
   MOZ_CAN_RUN_SCRIPT MOZ_NEVER_INLINE_DEBUG void CollapseSelectionTo(
       const EditorDOMPointBase<PT, CT>& aPoint, ErrorResult& aRv) const {
     MOZ_ASSERT(IsEditActionDataAvailable());
     MOZ_ASSERT(!aRv.Failed());
 
-    SelectionRefPtr()->Collapse(aPoint, aRv);
+    SelectionRefPtr()->CollapseInLimiter(aPoint, aRv);
     if (NS_WARN_IF(Destroyed())) {
       aRv = NS_ERROR_EDITOR_DESTROYED;
       return;
     }
-    NS_WARNING_ASSERTION(!aRv.Failed(), "Selection::Collapse() failed");
+    NS_WARNING_ASSERTION(!aRv.Failed(),
+                         "Selection::CollapseInLimiter() failed");
   }
 
   [[nodiscard]] MOZ_CAN_RUN_SCRIPT MOZ_NEVER_INLINE_DEBUG nsresult
   CollapseSelectionToStartOf(nsINode& aNode) {
     return CollapseSelectionTo(EditorRawDOMPoint(&aNode, 0));
   }
 
   MOZ_CAN_RUN_SCRIPT MOZ_NEVER_INLINE_DEBUG void CollapseSelectionToStartOf(
--- a/editor/libeditor/HTMLEditorEventListener.cpp
+++ b/editor/libeditor/HTMLEditorEventListener.cpp
@@ -349,19 +349,20 @@ nsresult HTMLEditorEventListener::Handle
   // Select entire element clicked on if NOT within an existing selection
   //   and not the entire body, or table-related elements
   if (HTMLEditUtils::IsImage(eventTargetElement)) {
     DebugOnly<nsresult> rvIgnored =
         aHTMLEditor.SelectElement(eventTargetElement);
     NS_WARNING_ASSERTION(NS_SUCCEEDED(rvIgnored),
                          "HTMLEditor::SelectElement() failed, but ignored");
   } else {
-    DebugOnly<nsresult> rvIgnored = selection->Collapse(parentContent, offset);
+    DebugOnly<nsresult> rvIgnored =
+        selection->CollapseInLimiter(parentContent, offset);
     NS_WARNING_ASSERTION(NS_SUCCEEDED(rvIgnored),
-                         "Selection::Collapse() failed, but ignored");
+                         "Selection::CollapseInLimiter() failed, but ignored");
   }
 
   // HACK !!! Context click places the caret but the context menu consumes
   // the event; so we need to check resizing state ourselves
   DebugOnly<nsresult> rvIgnored =
       aHTMLEditor.CheckSelectionStateForAnonymousButtons();
   NS_WARNING_ASSERTION(NS_SUCCEEDED(rvIgnored),
                        "HTMLEditor::CheckSelectionStateForAnonymousButtons() "
--- a/editor/libeditor/InsertNodeTransaction.cpp
+++ b/editor/libeditor/InsertNodeTransaction.cpp
@@ -136,19 +136,19 @@ NS_IMETHODIMP InsertNodeTransaction::DoT
   }
 
   // Place the selection just after the inserted element.
   EditorRawDOMPoint afterInsertedNode(
       EditorRawDOMPoint::After(contentToInsert));
   NS_WARNING_ASSERTION(afterInsertedNode.IsSet(),
                        "Failed to set after the inserted node");
   IgnoredErrorResult ignoredError;
-  selection->Collapse(afterInsertedNode, ignoredError);
+  selection->CollapseInLimiter(afterInsertedNode, ignoredError);
   NS_WARNING_ASSERTION(!ignoredError.Failed(),
-                       "Selection::Collapse() failed, but ignored");
+                       "Selection::CollapseInLimiter() failed, but ignored");
   return NS_OK;
 }
 
 NS_IMETHODIMP InsertNodeTransaction::UndoTransaction() {
   if (NS_WARN_IF(!mEditorBase) || NS_WARN_IF(!mContentToInsert) ||
       NS_WARN_IF(!mPointToInsert.IsSet())) {
     return NS_ERROR_NOT_INITIALIZED;
   }
--- a/editor/libeditor/InsertTextTransaction.cpp
+++ b/editor/libeditor/InsertTextTransaction.cpp
@@ -60,20 +60,20 @@ NS_IMETHODIMP InsertTextTransaction::DoT
   }
 
   // Only set selection to insertion point if editor gives permission
   if (editorBase->AllowsTransactionsToChangeSelection()) {
     RefPtr<Selection> selection = editorBase->GetSelection();
     if (NS_WARN_IF(!selection)) {
       return NS_ERROR_FAILURE;
     }
-    DebugOnly<nsresult> rvIgnored =
-        selection->Collapse(textNode, mOffset + mStringToInsert.Length());
+    DebugOnly<nsresult> rvIgnored = selection->CollapseInLimiter(
+        textNode, mOffset + mStringToInsert.Length());
     NS_ASSERTION(NS_SUCCEEDED(rvIgnored),
-                 "Selection::Collapse() failed, but ignored");
+                 "Selection::CollapseInLimiter() failed, but ignored");
   } else {
     // Do nothing - DOM Range gravity will adjust selection
   }
   // XXX Other transactions do not do this but its callers do.
   //     Why do this transaction do this by itself?
   editorBase->RangeUpdaterRef().SelAdjInsertText(textNode, mOffset,
                                                  mStringToInsert.Length());
 
--- a/editor/libeditor/ReplaceTextTransaction.cpp
+++ b/editor/libeditor/ReplaceTextTransaction.cpp
@@ -47,23 +47,23 @@ NS_IMETHODIMP ReplaceTextTransaction::Do
   }
 
   // XXX Should we stop setting selection when mutation event listener
   //     modifies the text node?
   RefPtr<Selection> selection = editorBase->GetSelection();
   if (NS_WARN_IF(!selection)) {
     return NS_ERROR_FAILURE;
   }
-  DebugOnly<nsresult> rvIgnored =
-      selection->Collapse(textNode, mOffset + mStringToInsert.Length());
+  DebugOnly<nsresult> rvIgnored = selection->CollapseInLimiter(
+      textNode, mOffset + mStringToInsert.Length());
   if (NS_WARN_IF(editorBase->Destroyed())) {
     return NS_ERROR_EDITOR_DESTROYED;
   }
   NS_ASSERTION(NS_SUCCEEDED(rvIgnored),
-               "Selection::Collapse() failed, but ignored");
+               "Selection::CollapseInLimiter() failed, but ignored");
   return NS_OK;
 }
 
 NS_IMETHODIMP ReplaceTextTransaction::UndoTransaction() {
   if (NS_WARN_IF(!mEditorBase) || NS_WARN_IF(!mTextNode) ||
       NS_WARN_IF(!HTMLEditUtils::IsSimplyEditableNode(*mTextNode))) {
     return NS_ERROR_NOT_AVAILABLE;
   }
@@ -102,23 +102,23 @@ NS_IMETHODIMP ReplaceTextTransaction::Un
   }
 
   // XXX Should we stop setting selection when mutation event listener
   //     modifies the text node?
   RefPtr<Selection> selection = editorBase->GetSelection();
   if (NS_WARN_IF(!selection)) {
     return NS_ERROR_FAILURE;
   }
-  DebugOnly<nsresult> rvIgnored =
-      selection->Collapse(textNode, mOffset + mStringToBeReplaced.Length());
+  DebugOnly<nsresult> rvIgnored = selection->CollapseInLimiter(
+      textNode, mOffset + mStringToBeReplaced.Length());
   if (NS_WARN_IF(editorBase->Destroyed())) {
     return NS_ERROR_EDITOR_DESTROYED;
   }
   NS_ASSERTION(NS_SUCCEEDED(rvIgnored),
-               "Selection::Collapse() failed, but ignored");
+               "Selection::CollapseInLimiter() failed, but ignored");
   return NS_OK;
 }
 
 NS_IMETHODIMP ReplaceTextTransaction::RedoTransaction() {
   if (NS_WARN_IF(!mEditorBase) || NS_WARN_IF(!mTextNode) ||
       NS_WARN_IF(!HTMLEditUtils::IsSimplyEditableNode(*mTextNode))) {
     return NS_ERROR_NOT_AVAILABLE;
   }
@@ -157,19 +157,19 @@ NS_IMETHODIMP ReplaceTextTransaction::Re
   }
 
   // XXX Should we stop setting selection when mutation event listener
   //     modifies the text node?
   RefPtr<Selection> selection = editorBase->GetSelection();
   if (NS_WARN_IF(!selection)) {
     return NS_ERROR_FAILURE;
   }
-  DebugOnly<nsresult> rvIgnored =
-      selection->Collapse(textNode, mOffset + mStringToInsert.Length());
+  DebugOnly<nsresult> rvIgnored = selection->CollapseInLimiter(
+      textNode, mOffset + mStringToInsert.Length());
   if (NS_WARN_IF(editorBase->Destroyed())) {
     return NS_ERROR_EDITOR_DESTROYED;
   }
   NS_ASSERTION(NS_SUCCEEDED(rvIgnored),
-               "Selection::Collapse() failed, but ignored");
+               "Selection::CollapseInLimiter() failed, but ignored");
   return NS_OK;
 }
 
 }  // namespace mozilla
--- a/editor/libeditor/SplitNodeTransaction.cpp
+++ b/editor/libeditor/SplitNodeTransaction.cpp
@@ -107,18 +107,19 @@ NS_IMETHODIMP SplitNodeTransaction::DoTr
       !htmlEditor->Destroyed(),
       "The editor has gone but SplitNodeTransaction keeps trying to modify "
       "Selection");
   RefPtr<Selection> selection = htmlEditor->GetSelection();
   if (NS_WARN_IF(!selection)) {
     return NS_ERROR_FAILURE;
   }
   EditorRawDOMPoint atEndOfLeftNode(EditorRawDOMPoint::AtEndOf(newLeftContent));
-  selection->Collapse(atEndOfLeftNode, error);
-  NS_WARNING_ASSERTION(!error.Failed(), "Selection::Collapse() failed");
+  selection->CollapseInLimiter(atEndOfLeftNode, error);
+  NS_WARNING_ASSERTION(!error.Failed(),
+                       "Selection::CollapseInLimiter() failed");
   return error.StealNSResult();
 }
 
 NS_IMETHODIMP SplitNodeTransaction::UndoTransaction() {
   if (NS_WARN_IF(!mHTMLEditor) || NS_WARN_IF(!mNewLeftContent) ||
       NS_WARN_IF(!mContainerParentNode) ||
       NS_WARN_IF(!mStartOfRightContent.IsInContentNode())) {
     return NS_ERROR_NOT_AVAILABLE;
--- a/editor/libeditor/TextEditSubActionHandler.cpp
+++ b/editor/libeditor/TextEditSubActionHandler.cpp
@@ -261,19 +261,19 @@ EditActionResult TextEditor::InsertLineF
     return EditActionIgnored(rv);
   }
 
   // set the selection to the correct location
   MOZ_ASSERT(
       !pointAfterInsertedLineFeed.GetChild(),
       "After inserting text into a text node, pointAfterInsertedLineFeed."
       "GetChild() should be nullptr");
-  rv = SelectionRefPtr()->Collapse(pointAfterInsertedLineFeed);
+  rv = SelectionRefPtr()->CollapseInLimiter(pointAfterInsertedLineFeed);
   if (NS_FAILED(rv)) {
-    NS_WARNING("Selection::Collapse() failed");
+    NS_WARNING("Selection::CollapseInLimiter() failed");
     return EditActionIgnored(rv);
   }
 
   // XXX I don't think we still need this.  This must have been required when
   //     `<textarea>` was implemented with text nodes and `<br>` elements.
   // see if we're at the end of the editor range
   EditorRawDOMPoint endPoint(EditorBase::GetEndPoint(*SelectionRefPtr()));
   if (endPoint == pointAfterInsertedLineFeed) {
@@ -341,21 +341,22 @@ nsresult TextEditor::EnsureCaretNotAtEnd
   }
 
   EditorRawDOMPoint afterStartContainer(
       EditorRawDOMPoint::After(*selectionStartPoint.GetContainer()));
   if (NS_WARN_IF(!afterStartContainer.IsSet())) {
     return NS_ERROR_FAILURE;
   }
   IgnoredErrorResult ignoredError;
-  SelectionRefPtr()->Collapse(afterStartContainer, ignoredError);
+  SelectionRefPtr()->CollapseInLimiter(afterStartContainer, ignoredError);
   if (NS_WARN_IF(Destroyed())) {
     return NS_ERROR_EDITOR_DESTROYED;
   }
-  NS_WARNING_ASSERTION(!ignoredError.Failed(), "Selection::Collapse() failed");
+  NS_WARNING_ASSERTION(!ignoredError.Failed(),
+                       "Selection::CollapseInLimiter() failed");
   return ignoredError.StealNSResult();
 }
 
 void TextEditor::HandleNewLinesInStringForSingleLineEditor(
     nsString& aString) const {
   static const char16_t kLF = static_cast<char16_t>('\n');
   MOZ_ASSERT(IsEditActionDataAvailable());
   MOZ_ASSERT(IsPlaintextEditor());
@@ -584,22 +585,24 @@ EditActionResult TextEditor::HandleInser
           !ignoredError.Failed(),
           "Selection::SetInterlinePosition() failed, but ignored");
 
       MOZ_ASSERT(
           !pointAfterStringInserted.GetChild(),
           "After inserting text into a text node, pointAfterStringInserted."
           "GetChild() should be nullptr");
       ignoredError = IgnoredErrorResult();
-      SelectionRefPtr()->Collapse(pointAfterStringInserted, ignoredError);
+      SelectionRefPtr()->CollapseInLimiter(pointAfterStringInserted,
+                                           ignoredError);
       if (NS_WARN_IF(Destroyed())) {
         return EditActionHandled(NS_ERROR_EDITOR_DESTROYED);
       }
-      NS_WARNING_ASSERTION(!ignoredError.Failed(),
-                           "Selection::Collapse() failed, but ignored");
+      NS_WARNING_ASSERTION(
+          !ignoredError.Failed(),
+          "Selection::CollapseInLimiter() failed, but ignored");
     }
   }
 
   // Unmask inputted character(s) if necessary.
   if (IsPasswordEditor() && IsMaskingPassword() && CanEchoPasswordNow()) {
     nsresult rv = SetUnmaskRangeAndNotify(start, insertionString.Length(),
                                           LookAndFeel::GetPasswordMaskDelay());
     NS_WARNING_ASSERTION(NS_SUCCEEDED(rv),
--- a/editor/libeditor/TextEditor.cpp
+++ b/editor/libeditor/TextEditor.cpp
@@ -593,19 +593,20 @@ nsresult TextEditor::SetTextAsSubAction(
 
     // We want to select trailing `<br>` element to remove all nodes to replace
     // all, but TextEditor::SelectEntireDocument() doesn't select such `<br>`
     // elements.
     // XXX We should make ReplaceSelectionAsSubAction() take range.  Then,
     //     we can saving the expensive cost of modifying `Selection` here.
     nsresult rv;
     if (IsEmpty()) {
-      rv = SelectionRefPtr()->Collapse(rootElement, 0);
-      NS_WARNING_ASSERTION(NS_SUCCEEDED(rv),
-                           "Selection::Collapse() failed, but ignored");
+      rv = SelectionRefPtr()->CollapseInLimiter(rootElement, 0);
+      NS_WARNING_ASSERTION(
+          NS_SUCCEEDED(rv),
+          "Selection::CollapseInLimiter() failed, but ignored");
     } else {
       // XXX Oh, we shouldn't select padding `<br>` element for empty last
       //     line here since we will need to recreate it in multiline
       //     text editor.
       ErrorResult error;
       SelectionRefPtr()->SelectAllChildren(*rootElement, error);
       NS_WARNING_ASSERTION(
           !error.Failed(),
@@ -1540,18 +1541,19 @@ nsresult TextEditor::SelectEntireDocumen
   Element* anonymousDivElement = GetRoot();
   if (NS_WARN_IF(!anonymousDivElement)) {
     return NS_ERROR_NOT_INITIALIZED;
   }
 
   // If we're empty, don't select all children because that would select the
   // padding <br> element for empty editor.
   if (IsEmpty()) {
-    nsresult rv = SelectionRefPtr()->Collapse(anonymousDivElement, 0);
-    NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "Selection::Collapse() failed");
+    nsresult rv = SelectionRefPtr()->CollapseInLimiter(anonymousDivElement, 0);
+    NS_WARNING_ASSERTION(NS_SUCCEEDED(rv),
+                         "Selection::CollapseInLimiter() failed");
     return rv;
   }
 
   // XXX We just need to select all of first text node (if there is).
   //     Why do we do this kind of complicated things?
 
   // Don't select the trailing BR node if we have one
   nsCOMPtr<nsIContent> childNode;
--- a/editor/libeditor/TextEditorDataTransfer.cpp
+++ b/editor/libeditor/TextEditorDataTransfer.cpp
@@ -100,21 +100,22 @@ nsresult TextEditor::PrepareToInsertCont
         IsTextEditor() ? nsIEditor::eNoStrip : nsIEditor::eStrip);
     if (NS_FAILED(rv)) {
       NS_WARNING("EditorBase::DeleteSelectionAsSubAction(eNone) failed");
       return rv;
     }
   }
 
   IgnoredErrorResult error;
-  SelectionRefPtr()->Collapse(pointToInsert, error);
+  SelectionRefPtr()->CollapseInLimiter(pointToInsert, error);
   if (NS_WARN_IF(Destroyed())) {
     return NS_ERROR_EDITOR_DESTROYED;
   }
-  NS_WARNING_ASSERTION(!error.Failed(), "Selection::Collapse() failed");
+  NS_WARNING_ASSERTION(!error.Failed(),
+                       "Selection::CollapseInLimiter() failed");
   return error.StealNSResult();
 }
 
 nsresult TextEditor::InsertTextAt(const nsAString& aStringToInsert,
                                   const EditorDOMPoint& aPointToInsert,
                                   bool aDoDeleteSelection) {
   MOZ_ASSERT(IsEditActionDataAvailable());
 
--- a/editor/spellchecker/TextServicesDocument.cpp
+++ b/editor/spellchecker/TextServicesDocument.cpp
@@ -1183,18 +1183,18 @@ nsresult TextServicesDocument::InsertTex
     mSelStartIndex = mSelEndIndex = i;
 
     RefPtr<Selection> selection =
         mSelCon->GetSelection(nsISelectionController::SELECTION_NORMAL);
     if (NS_WARN_IF(!selection)) {
       return rv;
     }
 
-    rv = selection->Collapse(itEntry->mNode,
-                             itEntry->mNodeOffset + itEntry->mLength);
+    rv = selection->CollapseInLimiter(itEntry->mNode,
+                                      itEntry->mNodeOffset + itEntry->mLength);
 
     if (NS_FAILED(rv)) {
       return rv;
     }
   } else if (entry->mStrOffset + entry->mLength > mSelStartOffset) {
     // We are inserting text into the middle of the current offset entry.
     // split the current entry into two parts, then insert an inserted text
     // entry between them!
@@ -1752,17 +1752,17 @@ nsresult TextServicesDocument::SetSelect
     selection = mSelCon->GetSelection(nsISelectionController::SELECTION_NORMAL);
     if (NS_WARN_IF(!selection)) {
       return NS_ERROR_FAILURE;
     }
   }
 
   if (!aLength) {
     if (aDoUpdate) {
-      nsresult rv = selection->Collapse(startNode, startNodeOffset);
+      nsresult rv = selection->CollapseInLimiter(startNode, startNodeOffset);
       if (NS_WARN_IF(NS_FAILED(rv))) {
         return rv;
       }
     }
     mSelEndIndex = mSelStartIndex;
     mSelEndOffset = mSelStartOffset;
     return NS_OK;
   }
@@ -1796,17 +1796,17 @@ nsresult TextServicesDocument::SetSelect
     }
   }
 
   if (!aDoUpdate) {
     return NS_OK;
   }
 
   if (!endNode) {
-    nsresult rv = selection->Collapse(startNode, startNodeOffset);
+    nsresult rv = selection->CollapseInLimiter(startNode, startNodeOffset);
     NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "Failed to collapse selection");
     return rv;
   }
 
   ErrorResult error;
   selection->SetStartAndEndInLimiter(
       RawRangeBoundary(startNode, startNodeOffset),
       RawRangeBoundary(endNode, endNodeOffset), error);
--- a/layout/generic/nsFrameSelection.cpp
+++ b/layout/generic/nsFrameSelection.cpp
@@ -784,17 +784,17 @@ nsresult nsFrameSelection::MoveCaret(nsD
       }
       if (direction == eDirPrevious) {
         node = anchorFocusRange->GetStartContainer();
         offset = anchorFocusRange->StartOffset();
       } else {
         node = anchorFocusRange->GetEndContainer();
         offset = anchorFocusRange->EndOffset();
       }
-      sel->Collapse(node, offset);
+      sel->CollapseInLimiter(node, offset);
     }
     sel->ScrollIntoView(nsISelectionController::SELECTION_FOCUS_REGION,
                         ScrollAxis(), ScrollAxis(), scrollFlags);
     return NS_OK;
   }
 
   CaretAssociateHint tHint(mCaret.mHint);  // temporary variable so we dont set
                                            // mCaret.mHint until it is necessary
@@ -868,17 +868,17 @@ nsresult nsFrameSelection::MoveCaret(nsD
     rv = TakeFocus(MOZ_KnownLive(pos.mResultContent), pos.mContentOffset,
                    pos.mContentOffset, tHint, focusMode);
   } else if (aAmount <= eSelectWordNoSpace && direction == eDirNext &&
              !aContinueSelection) {
     // Collapse selection if PeekOffset failed, we either
     //  1. bumped into the BRFrame, bug 207623
     //  2. had select-all in a text input (DIV range), bug 352759.
     bool isBRFrame = frame->IsBrFrame();
-    sel->Collapse(sel->GetFocusNode(), sel->FocusOffset());
+    sel->CollapseInLimiter(sel->GetFocusNode(), sel->FocusOffset());
     // Note: 'frame' might be dead here.
     if (!isBRFrame) {
       mCaret.mHint = CARET_ASSOCIATE_BEFORE;  // We're now at the end of the
                                               // frame to the left.
     }
     rv = NS_OK;
   } else {
     rv = result.isErr() ? result.unwrapErr() : NS_OK;
@@ -1414,17 +1414,17 @@ nsresult nsFrameSelection::TakeFocus(nsI
         const RefPtr<Selection> selection{mDomSelections[index]};
         selection->AddRangeAndSelectFramesAndNotifyListeners(*newRange,
                                                              IgnoreErrors());
         mBatching = saveBatching;
       } else {
         bool oldDesiredPosSet =
             mDesiredCaretPos.mIsSet;  // need to keep old desired
                                       // position if it was set.
-        mDomSelections[index]->Collapse(aNewFocus, aContentOffset);
+        mDomSelections[index]->CollapseInLimiter(aNewFocus, aContentOffset);
         mDesiredCaretPos.mIsSet =
             oldDesiredPosSet;  // now reset desired pos back.
         mBatching = saveBatching;
       }
       if (aContentEndOffset != aContentOffset) {
         mDomSelections[index]->Extend(aNewFocus, aContentEndOffset);
       }
 
@@ -2569,17 +2569,17 @@ nsresult nsFrameSelection::TableSelectio
             // Collapse to "normal" selection inside the cell
             mStartSelectedCell = nullptr;
             mEndSelectedCell = nullptr;
             mAppendStartSelectedCell = nullptr;
             // TODO: We need a "Collapse to just before deepest child" routine
             // Even better, should we collapse to just after the LAST deepest
             // child
             //  (i.e., at the end of the cell's contents)?
-            return aNormalSelection.Collapse(aChildContent, 0);
+            return aNormalSelection.CollapseInLimiter(aChildContent, 0);
           }
 #ifdef DEBUG_TABLE_SELECTION
           printf(
               "HandleTableSelection: Removing cell from multi-cell "
               "selection\n");
 #endif
           // Unselecting the start of previous block
           // XXX What do we use now!