diff --git a/dom/base/Selection.cpp b/dom/base/Selection.cpp index 4b66be1af546..743d934c9c83 100644 --- a/dom/base/Selection.cpp +++ b/dom/base/Selection.cpp @@ -2186,7 +2186,7 @@ void Selection::CollapseToStart(ErrorResult& aRv) { aRv.Throw(NS_ERROR_FAILURE); return; } - Collapse(*container, firstRange->StartOffset(), aRv); + CollapseInLimiter(*container, firstRange->StartOffset(), aRv); } /* @@ -2222,7 +2222,7 @@ void Selection::CollapseToEnd(ErrorResult& aRv) { aRv.Throw(NS_ERROR_FAILURE); return; } - Collapse(*container, lastRange->EndOffset(), aRv); + CollapseInLimiter(*container, lastRange->EndOffset(), aRv); } void Selection::GetType(nsAString& aOutType) const { @@ -3198,7 +3198,7 @@ void Selection::DeleteFromDocument(ErrorResult& aRv) { // 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 { @@ -3275,7 +3275,7 @@ void Selection::Modify(const nsAString& aAlter, const nsAString& aDirection, return; } uint32_t focusOffset = FocusOffset(); - Collapse(focusNode, focusOffset); + CollapseInLimiter(focusNode, focusOffset); } // If the paragraph direction of the focused frame is right-to-left, diff --git a/dom/base/Selection.h b/dom/base/Selection.h index d6269d8bfd7a..fdf52f50b609 100644 --- a/dom/base/Selection.h +++ b/dom/base/Selection.h @@ -190,18 +190,18 @@ class Selection final : public nsSupportsWeakReference, 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); } @@ -438,9 +438,9 @@ class Selection final : public nsSupportsWeakReference, */ // 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); } diff --git a/dom/events/EventStateManager.cpp b/dom/events/EventStateManager.cpp index b39d4749aabb..a9db5102b0df 100644 --- a/dom/events/EventStateManager.cpp +++ b/dom/events/EventStateManager.cpp @@ -5230,7 +5230,7 @@ nsresult EventStateManager::HandleMiddleClickPaste( // 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 rv = selection->Collapse(container, offset); + DebugOnly rv = selection->CollapseInLimiter(container, offset); NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "Failed to collapse Selection at middle clicked"); } diff --git a/editor/libeditor/CompositionTransaction.cpp b/editor/libeditor/CompositionTransaction.cpp index f426f3346f35..136718201a26 100644 --- a/editor/libeditor/CompositionTransaction.cpp +++ b/editor/libeditor/CompositionTransaction.cpp @@ -179,8 +179,8 @@ NS_IMETHODIMP CompositionTransaction::UndoTransaction() { } // 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; } @@ -299,10 +299,10 @@ nsresult CompositionTransaction::SetIMESelection( std::min(textRange.mStartOffset, aLengthOfCompositionString)); MOZ_ASSERT(caretOffset >= 0 && static_cast(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; @@ -372,8 +372,9 @@ nsresult CompositionTransaction::SetIMESelection( static_cast(aOffsetInNode + aLengthOfCompositionString); MOZ_ASSERT(caretOffset >= 0 && static_cast(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). diff --git a/editor/libeditor/CreateElementTransaction.cpp b/editor/libeditor/CreateElementTransaction.cpp index 81793834fc35..2dee25c7361f 100644 --- a/editor/libeditor/CreateElementTransaction.cpp +++ b/editor/libeditor/CreateElementTransaction.cpp @@ -119,9 +119,9 @@ NS_IMETHODIMP CreateElementTransaction::DoTransaction() { 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; } diff --git a/editor/libeditor/DeleteRangeTransaction.cpp b/editor/libeditor/DeleteRangeTransaction.cpp index 6d48cce8645d..0980201c0b9f 100644 --- a/editor/libeditor/DeleteRangeTransaction.cpp +++ b/editor/libeditor/DeleteRangeTransaction.cpp @@ -98,8 +98,9 @@ NS_IMETHODIMP DeleteRangeTransaction::DoTransaction() { 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; } diff --git a/editor/libeditor/DeleteTextTransaction.cpp b/editor/libeditor/DeleteTextTransaction.cpp index 8d5ae17a530a..6e759db34183 100644 --- a/editor/libeditor/DeleteTextTransaction.cpp +++ b/editor/libeditor/DeleteTextTransaction.cpp @@ -131,8 +131,9 @@ NS_IMETHODIMP DeleteTextTransaction::DoTransaction() { 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(); } diff --git a/editor/libeditor/EditorBase.cpp b/editor/libeditor/EditorBase.cpp index d2d78c9cbca7..e7a73e877298 100644 --- a/editor/libeditor/EditorBase.cpp +++ b/editor/libeditor/EditorBase.cpp @@ -1115,15 +1115,17 @@ NS_IMETHODIMP EditorBase::BeginningOfDocument() { nsCOMPtr 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; } @@ -1136,8 +1138,9 @@ NS_IMETHODIMP EditorBase::BeginningOfDocument() { 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; } @@ -1176,9 +1179,10 @@ nsresult EditorBase::CollapseSelectionToEnd() const { } uint32_t length = lastContent->Length(); - nsresult rv = - SelectionRefPtr()->Collapse(lastContent, static_cast(length)); - NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "Selection::Collapse() failed"); + nsresult rv = SelectionRefPtr()->CollapseInLimiter( + lastContent, static_cast(length)); + NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), + "Selection::CollapseInLimiter() failed"); return rv; } @@ -2707,12 +2711,12 @@ nsresult EditorBase::SetTextNodeWithoutTransaction(const nsAString& aString, } DebugOnly 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()); @@ -3237,12 +3241,13 @@ nsresult EditorBase::MaybeCreatePaddingBRElementForEmptyEditor() { } // 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; } diff --git a/editor/libeditor/HTMLEditSubActionHandler.cpp b/editor/libeditor/HTMLEditSubActionHandler.cpp index fe8a85d5dded..34cd83c07421 100644 --- a/editor/libeditor/HTMLEditSubActionHandler.cpp +++ b/editor/libeditor/HTMLEditSubActionHandler.cpp @@ -3604,8 +3604,9 @@ HTMLEditor::AutoDeleteRangesHandler::HandleDeleteTextAroundCollapsedSelection( const EditorDOMPoint& newCaretPosition = result.inspect(); MOZ_ASSERT(newCaretPosition.IsSetAndValid()); - DebugOnly rvIgnored = aHTMLEditor.SelectionRefPtr()->Collapse( - newCaretPosition.ToRawRangeBoundary()); + DebugOnly rvIgnored = + aHTMLEditor.SelectionRefPtr()->CollapseInLimiter( + newCaretPosition.ToRawRangeBoundary()); NS_WARNING_ASSERTION(NS_SUCCEEDED(rvIgnored), "Selection::Collapse() failed, but ignored"); return EditActionHandled(); diff --git a/editor/libeditor/HTMLEditor.cpp b/editor/libeditor/HTMLEditor.cpp index 7ab3ac14f21d..2936c2e5c8d1 100644 --- a/editor/libeditor/HTMLEditor.cpp +++ b/editor/libeditor/HTMLEditor.cpp @@ -4679,13 +4679,13 @@ nsresult HTMLEditor::DoJoinNodes(nsIContent& aContentToKeep, if (allowedTransactionsToChangeSelection) { // Editor wants us to set selection at join point. - DebugOnly rvIgnored = SelectionRefPtr()->Collapse( + DebugOnly rvIgnored = SelectionRefPtr()->CollapseInLimiter( &aContentToKeep, AssertedCast(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; @@ -4765,9 +4765,9 @@ already_AddRefed HTMLEditor::DeleteSelectionAndCreateElement( 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. @@ -4813,8 +4813,9 @@ nsresult HTMLEditor::DeleteSelectionAndPrepareToCreateNode() { 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(); } @@ -4824,8 +4825,9 @@ nsresult HTMLEditor::DeleteSelectionAndPrepareToCreateNode() { 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(); } @@ -4841,8 +4843,9 @@ nsresult HTMLEditor::DeleteSelectionAndPrepareToCreateNode() { 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(); } diff --git a/editor/libeditor/HTMLEditor.h b/editor/libeditor/HTMLEditor.h index d7c4363b738b..4b328e01dcf3 100644 --- a/editor/libeditor/HTMLEditor.h +++ b/editor/libeditor/HTMLEditor.h @@ -3029,12 +3029,13 @@ class HTMLEditor final : public TextEditor, 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 diff --git a/editor/libeditor/HTMLEditorEventListener.cpp b/editor/libeditor/HTMLEditorEventListener.cpp index c126774e53d8..2f40bbfdbe3b 100644 --- a/editor/libeditor/HTMLEditorEventListener.cpp +++ b/editor/libeditor/HTMLEditorEventListener.cpp @@ -354,9 +354,10 @@ nsresult HTMLEditorEventListener::HandleSecondaryMouseButtonDown( NS_WARNING_ASSERTION(NS_SUCCEEDED(rvIgnored), "HTMLEditor::SelectElement() failed, but ignored"); } else { - DebugOnly rvIgnored = selection->Collapse(parentContent, offset); + DebugOnly 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 diff --git a/editor/libeditor/InsertNodeTransaction.cpp b/editor/libeditor/InsertNodeTransaction.cpp index dc35c645feb0..aa853e39087c 100644 --- a/editor/libeditor/InsertNodeTransaction.cpp +++ b/editor/libeditor/InsertNodeTransaction.cpp @@ -141,9 +141,9 @@ NS_IMETHODIMP InsertNodeTransaction::DoTransaction() { 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; } diff --git a/editor/libeditor/InsertTextTransaction.cpp b/editor/libeditor/InsertTextTransaction.cpp index 1d0ddacf9b7f..23f03e183996 100644 --- a/editor/libeditor/InsertTextTransaction.cpp +++ b/editor/libeditor/InsertTextTransaction.cpp @@ -65,10 +65,10 @@ NS_IMETHODIMP InsertTextTransaction::DoTransaction() { if (NS_WARN_IF(!selection)) { return NS_ERROR_FAILURE; } - DebugOnly rvIgnored = - selection->Collapse(textNode, mOffset + mStringToInsert.Length()); + DebugOnly 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 } diff --git a/editor/libeditor/ReplaceTextTransaction.cpp b/editor/libeditor/ReplaceTextTransaction.cpp index 6fedf9e0bf43..60c8cf3d3937 100644 --- a/editor/libeditor/ReplaceTextTransaction.cpp +++ b/editor/libeditor/ReplaceTextTransaction.cpp @@ -52,13 +52,13 @@ NS_IMETHODIMP ReplaceTextTransaction::DoTransaction() { if (NS_WARN_IF(!selection)) { return NS_ERROR_FAILURE; } - DebugOnly rvIgnored = - selection->Collapse(textNode, mOffset + mStringToInsert.Length()); + DebugOnly 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; } @@ -107,13 +107,13 @@ NS_IMETHODIMP ReplaceTextTransaction::UndoTransaction() { if (NS_WARN_IF(!selection)) { return NS_ERROR_FAILURE; } - DebugOnly rvIgnored = - selection->Collapse(textNode, mOffset + mStringToBeReplaced.Length()); + DebugOnly 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; } @@ -162,13 +162,13 @@ NS_IMETHODIMP ReplaceTextTransaction::RedoTransaction() { if (NS_WARN_IF(!selection)) { return NS_ERROR_FAILURE; } - DebugOnly rvIgnored = - selection->Collapse(textNode, mOffset + mStringToInsert.Length()); + DebugOnly 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; } diff --git a/editor/libeditor/SplitNodeTransaction.cpp b/editor/libeditor/SplitNodeTransaction.cpp index f44e5d2a81ce..4d5f86e9ac7c 100644 --- a/editor/libeditor/SplitNodeTransaction.cpp +++ b/editor/libeditor/SplitNodeTransaction.cpp @@ -112,8 +112,9 @@ NS_IMETHODIMP SplitNodeTransaction::DoTransaction() { 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(); } diff --git a/editor/libeditor/TextEditSubActionHandler.cpp b/editor/libeditor/TextEditSubActionHandler.cpp index 0e24978bf2a9..66763b173c15 100644 --- a/editor/libeditor/TextEditSubActionHandler.cpp +++ b/editor/libeditor/TextEditSubActionHandler.cpp @@ -266,9 +266,9 @@ EditActionResult TextEditor::InsertLineFeedCharacterAtSelection() { !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); } @@ -346,11 +346,12 @@ nsresult TextEditor::EnsureCaretNotAtEndOfTextNode() { 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(); } @@ -589,12 +590,14 @@ EditActionResult TextEditor::HandleInsertText( "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"); } } diff --git a/editor/libeditor/TextEditor.cpp b/editor/libeditor/TextEditor.cpp index 7aece75ab2fb..2c2e2616f36e 100644 --- a/editor/libeditor/TextEditor.cpp +++ b/editor/libeditor/TextEditor.cpp @@ -598,9 +598,10 @@ nsresult TextEditor::SetTextAsSubAction(const nsAString& aString) { // 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 `
` element for empty last // line here since we will need to recreate it in multiline @@ -1545,8 +1546,9 @@ nsresult TextEditor::SelectEntireDocument() { // If we're empty, don't select all children because that would select the // padding
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; } diff --git a/editor/libeditor/TextEditorDataTransfer.cpp b/editor/libeditor/TextEditorDataTransfer.cpp index 1381ff7f884f..c44021159679 100644 --- a/editor/libeditor/TextEditorDataTransfer.cpp +++ b/editor/libeditor/TextEditorDataTransfer.cpp @@ -105,11 +105,12 @@ nsresult TextEditor::PrepareToInsertContent( } 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(); } diff --git a/editor/spellchecker/TextServicesDocument.cpp b/editor/spellchecker/TextServicesDocument.cpp index 2d53f5dc07e6..5ffa52e8fd25 100644 --- a/editor/spellchecker/TextServicesDocument.cpp +++ b/editor/spellchecker/TextServicesDocument.cpp @@ -1188,8 +1188,8 @@ nsresult TextServicesDocument::InsertText(const nsAString& aText) { 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; @@ -1757,7 +1757,7 @@ nsresult TextServicesDocument::SetSelectionInternal(int32_t aOffset, 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; } @@ -1801,7 +1801,7 @@ nsresult TextServicesDocument::SetSelectionInternal(int32_t aOffset, } 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; } diff --git a/layout/generic/nsFrameSelection.cpp b/layout/generic/nsFrameSelection.cpp index 5b3035b12bfb..842d22aaf119 100644 --- a/layout/generic/nsFrameSelection.cpp +++ b/layout/generic/nsFrameSelection.cpp @@ -789,7 +789,7 @@ nsresult nsFrameSelection::MoveCaret(nsDirection aDirection, node = anchorFocusRange->GetEndContainer(); offset = anchorFocusRange->EndOffset(); } - sel->Collapse(node, offset); + sel->CollapseInLimiter(node, offset); } sel->ScrollIntoView(nsISelectionController::SELECTION_FOCUS_REGION, ScrollAxis(), ScrollAxis(), scrollFlags); @@ -873,7 +873,7 @@ nsresult nsFrameSelection::MoveCaret(nsDirection aDirection, // 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 @@ -1419,7 +1419,7 @@ nsresult nsFrameSelection::TakeFocus(nsIContent* const aNewFocus, 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; @@ -2574,7 +2574,7 @@ nsresult nsFrameSelection::TableSelection::HandleMouseUpOrDown( // 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(