author | Boris Zbarsky <bzbarsky@mit.edu> |
Tue, 08 May 2018 13:52:41 -0400 | |
changeset 471669 | cb2fad352e0181674d7e2b4bc42ebea93f4fab5d |
parent 471668 | 13aee20c6c4b00fa2183fa5b7f975f17ce788a86 |
child 471670 | 1714b3b0dec5914c2fb32cb26e20c3d0a9d2e8ce |
push id | 9374 |
push user | jlund@mozilla.com |
push date | Mon, 18 Jun 2018 21:43:20 +0000 |
treeherder | mozilla-beta@160e085dfb0b [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | mats |
bugs | 1387143 |
milestone | 62.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
|
--- a/accessible/base/nsCoreUtils.cpp +++ b/accessible/base/nsCoreUtils.cpp @@ -272,17 +272,17 @@ nsCoreUtils::ScrollSubstringTo(nsIFrame* selection->RemoveAllRanges(IgnoreErrors()); selection->AddRange(*aRange, IgnoreErrors()); selection->ScrollIntoView(nsISelectionController::SELECTION_ANCHOR_REGION, aVertical, aHorizontal, Selection::SCROLL_SYNCHRONOUS); - selection->CollapseToStart(); + selection->CollapseToStart(IgnoreErrors()); return NS_OK; } void nsCoreUtils::ScrollFrameToPoint(nsIFrame *aScrollableFrame, nsIFrame *aFrame, const nsIntPoint& aPoint)
--- a/dom/base/Selection.cpp +++ b/dom/base/Selection.cpp @@ -2277,29 +2277,16 @@ Selection::RemoveRange(nsRange& aRange, } } /* * Collapse sets the whole selection to be one point. */ -NS_IMETHODIMP -Selection::Collapse(nsIDOMNode* aContainer, int32_t aOffset) -{ - nsCOMPtr<nsINode> container = do_QueryInterface(aContainer); - return Collapse(RawRangeBoundary(container, aOffset)); -} - -NS_IMETHODIMP -Selection::CollapseNative(nsINode* aContainer, int32_t aOffset) -{ - return Collapse(RawRangeBoundary(aContainer, aOffset)); -} - void Selection::CollapseJS(nsINode* aContainer, uint32_t aOffset, ErrorResult& aRv) { AutoRestore<bool> calledFromJSRestorer(mCalledByJS); mCalledByJS = true; if (!aContainer) { RemoveAllRanges(aRv); return; @@ -2426,24 +2413,16 @@ Selection::Collapse(const RawRangeBounda aRv.Throw(result); } } /* * Sets the whole selection to be one point * at the start of the current selection */ -NS_IMETHODIMP -Selection::CollapseToStart() -{ - ErrorResult result; - CollapseToStart(result); - return result.StealNSResult(); -} - void Selection::CollapseToStartJS(ErrorResult& aRv) { AutoRestore<bool> calledFromJSRestorer(mCalledByJS); mCalledByJS = true; CollapseToStart(aRv); } @@ -2473,24 +2452,16 @@ Selection::CollapseToStart(ErrorResult& } Collapse(*container, firstRange->StartOffset(), aRv); } /* * Sets the whole selection to be one point * at the end of the current selection */ -NS_IMETHODIMP -Selection::CollapseToEnd() -{ - ErrorResult result; - CollapseToEnd(result); - return result.StealNSResult(); -} - void Selection::CollapseToEndJS(ErrorResult& aRv) { AutoRestore<bool> calledFromJSRestorer(mCalledByJS); mCalledByJS = true; CollapseToEnd(aRv); }
--- a/dom/base/Selection.h +++ b/dom/base/Selection.h @@ -332,23 +332,45 @@ public: mozilla::ErrorResult& aRv); void SetColors(const nsAString& aForeColor, const nsAString& aBackColor, const nsAString& aAltForeColor, const nsAString& aAltBackColor, mozilla::ErrorResult& aRv); void ResetColors(mozilla::ErrorResult& aRv); - // Non-JS callers should use the following methods. + /** + * Non-JS callers should use the following + * collapse/collapseToStart/extend/etc methods, instead of the *JS + * versions that bindings call. + */ + + /** + * Collapses the selection to a single point, at the specified offset + * 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) + */ void Collapse(nsINode& aContainer, uint32_t aOffset, ErrorResult& aRv) { Collapse(RawRangeBoundary(&aContainer, aOffset), aRv); } void Collapse(const RawRangeBoundary& aPoint, ErrorResult& aRv); + /** + * Collapses the whole selection to a single point at the start + * of the current selection (irrespective of direction). If content + * is focused and editable, the caret will blink there. + */ void CollapseToStart(mozilla::ErrorResult& aRv); + /** + * Collapses the whole selection to a single point at the end + * of the current selection (irrespective of direction). If content + * is focused and editable, the caret will blink there. + */ void CollapseToEnd(mozilla::ErrorResult& aRv); void Extend(nsINode& aContainer, uint32_t aOffset, ErrorResult& aRv); void AddRange(nsRange& aRange, mozilla::ErrorResult& aRv); void SelectAllChildren(nsINode& aNode, mozilla::ErrorResult& aRv); void SetBaseAndExtent(nsINode& aAnchorNode, uint32_t aAnchorOffset, nsINode& aFocusNode, uint32_t aFocusOffset, mozilla::ErrorResult& aRv);
--- a/dom/base/nsFocusManager.cpp +++ b/dom/base/nsFocusManager.cpp @@ -2456,17 +2456,17 @@ nsFocusManager::MoveCaretToFocus(nsIPres aContent->IsNodeOfType(nsINode::eHTML_FORM_CONTROL)) { // If current focus node is a leaf, set range to before the // node by using the parent as a container. // This prevents it from appearing as selected. newRange->SetStartBefore(*aContent, IgnoreErrors()); newRange->SetEndBefore(*aContent, IgnoreErrors()); } domSelection->AddRange(*newRange, IgnoreErrors()); - domSelection->CollapseToStart(); + domSelection->CollapseToStart(IgnoreErrors()); } } } } nsresult nsFocusManager::SetCaretVisible(nsIPresShell* aPresShell, bool aVisible,
--- a/dom/base/nsGlobalWindowCommands.cpp +++ b/dom/base/nsGlobalWindowCommands.cpp @@ -557,17 +557,17 @@ nsClipboardCommand::DoCommand(const char nsCopySupport::FireClipboardEvent(eventMessage, nsIClipboard::kGlobalClipboard, presShell, nullptr, &actionTaken); if (notCancelled && !strcmp(aCommandName, "cmd_copyAndCollapseToEnd")) { dom::Selection *sel = presShell->GetCurrentSelection(SelectionType::eNormal); NS_ENSURE_TRUE(sel, NS_ERROR_FAILURE); - sel->CollapseToEnd(); + sel->CollapseToEnd(IgnoreErrors()); } return actionTaken ? NS_OK : NS_SUCCESS_DOM_NO_OPERATION; } NS_IMETHODIMP nsClipboardCommand::GetCommandStateParams(const char *aCommandName, nsICommandParams *aParams, nsISupports *aCommandContext)
--- a/dom/base/nsISelection.idl +++ b/dom/base/nsISelection.idl @@ -23,51 +23,28 @@ class Selection; * of nodes within the document. * * @version 1.0 */ [shim(Selection), uuid(e0a4d4b3-f34e-44bd-b1f2-4e3bde9b6915)] interface nsISelection : nsISupports { - /** - * Collapses the selection to a single point, at the specified offset - * in the given DOM node. When the selection is collapsed, and the content - * is focused and editable, the caret will blink there. - * @param parentNode The given dom node where the selection will be set - * @param offset Where in given dom node to place the selection (the offset into the given node) - */ - void collapse(in nsIDOMNode parentNode, in long offset); - [noscript] void collapseNative(in nsINode parentNode, in long offset); /** * Extends the selection by moving the selection end to the specified node and offset, * preserving the selection begin position. The new selection end result will always * be from the anchorNode to the new focusNode, regardless of direction. * @param parentNode The node where the selection will be extended to * @param offset Where in node to place the offset in the new selection end */ void extend(in nsIDOMNode parentNode, in long offset); [noscript] void extendNative(in nsINode parentNode, in long offset); /** - * Collapses the whole selection to a single point at the start - * of the current selection (irrespective of direction). If content - * is focused and editable, the caret will blink there. - */ - void collapseToStart(); - - /** - * Collapses the whole selection to a single point at the end - * of the current selection (irrespective of direction). If content - * is focused and editable, the caret will blink there. - */ - void collapseToEnd(); - - /** * Indicates whether the node is part of the selection. If partlyContained * is set to PR_TRUE, the function returns true when some part of the node * is part of the selection. If partlyContained is set to PR_FALSE, the * function only returns true when the entire node is part of the selection. */ boolean containsNode(in nsIDOMNode node, in boolean partlyContained); /**
--- a/editor/libeditor/EditorCommands.cpp +++ b/editor/libeditor/EditorCommands.cpp @@ -496,17 +496,17 @@ CopyAndCollapseToEndCommand::DoCommand(c TextEditor* textEditor = editor->AsTextEditor(); MOZ_ASSERT(textEditor); nsresult rv = textEditor->Copy(); if (NS_FAILED(rv)) { return rv; } RefPtr<dom::Selection> selection = textEditor->GetSelection(); if (selection) { - selection->CollapseToEnd(); + selection->CollapseToEnd(IgnoreErrors()); } return NS_OK; } NS_IMETHODIMP CopyAndCollapseToEndCommand::DoCommandParams(const char* aCommandName, nsICommandParams* aParams, nsISupports* aCommandRefCon)
--- a/editor/libeditor/HTMLEditor.cpp +++ b/editor/libeditor/HTMLEditor.cpp @@ -1557,19 +1557,19 @@ HTMLEditor::InsertElementAtSelection(Ele // If deleting, selection will be collapsed. // so if not, we collapse it if (!aDeleteSelection) { // Named Anchor is a special case, // We collapse to insert element BEFORE the selection // For all other tags, we insert AFTER the selection if (HTMLEditUtils::IsNamedAnchor(aElement)) { - selection->CollapseToStart(); + selection->CollapseToStart(IgnoreErrors()); } else { - selection->CollapseToEnd(); + selection->CollapseToEnd(IgnoreErrors()); } } if (selection->GetAnchorNode()) { EditorRawDOMPoint atAnchor(selection->AnchorRef()); // Adjust position based on the node we are going to insert. EditorRawDOMPoint pointToInsert = GetBetterInsertionPointFor(*aElement, atAnchor);
--- a/editor/libeditor/HTMLEditorDataTransfer.cpp +++ b/editor/libeditor/HTMLEditorDataTransfer.cpp @@ -328,17 +328,17 @@ HTMLEditor::DoInsertHTMLWithContext(cons // Braces for artificial block to scope AutoSelectionRestorer. // Save current selection since DeleteTableCell() perturbs it. { AutoSelectionRestorer selectionRestorer(selection, this); rv = DeleteTableCell(1); NS_ENSURE_SUCCESS(rv, rv); } // collapse selection to beginning of deleted table content - selection->CollapseToStart(); + selection->CollapseToStart(IgnoreErrors()); } // give rules a chance to handle or cancel RulesInfo ruleInfo(EditAction::insertElement); bool cancel, handled; rv = rules->WillDoAction(selection, &ruleInfo, &cancel, &handled); NS_ENSURE_SUCCESS(rv, rv); if (cancel) {
--- a/layout/base/PresShell.cpp +++ b/layout/base/PresShell.cpp @@ -3251,17 +3251,17 @@ PresShell::GoToAnchor(const nsAString& a jumpToRange->SelectNodeContents(*content, IgnoreErrors()); // Select the anchor RefPtr<Selection> sel = mSelection->GetSelection(SelectionType::eNormal); if (sel) { sel->RemoveAllRanges(IgnoreErrors()); sel->AddRange(*jumpToRange, IgnoreErrors()); if (!selectAnchor) { // Use a caret (collapsed selection) at the start of the anchor - sel->CollapseToStart(); + sel->CollapseToStart(IgnoreErrors()); } } // Selection is at anchor. // Now focus the document itself if focus is on an element within it. nsPIDOMWindowOuter *win = mDocument->GetWindow(); nsIFocusManager* fm = nsFocusManager::GetFocusManager(); if (fm && win) {
--- a/layout/base/nsDocumentViewer.cpp +++ b/layout/base/nsDocumentViewer.cpp @@ -2636,17 +2636,19 @@ nsDocumentViewer::GetDocumentSelection() NS_IMETHODIMP nsDocumentViewer::ClearSelection() { // use nsCopySupport::GetSelectionForCopy() ? RefPtr<mozilla::dom::Selection> selection = GetDocumentSelection(); if (!selection) { return NS_ERROR_FAILURE; } - return selection->CollapseToStart(); + ErrorResult rv; + selection->CollapseToStart(rv); + return rv.StealNSResult(); } NS_IMETHODIMP nsDocumentViewer::SelectAll() { // XXX this is a temporary implementation copied from nsWebShell // for now. I think nsDocument and friends should have some helper // functions to make this easier.
--- a/toolkit/components/typeaheadfind/nsTypeAheadFind.cpp +++ b/toolkit/components/typeaheadfind/nsTypeAheadFind.cpp @@ -274,17 +274,17 @@ nsTypeAheadFind::CollapseSelection() do_QueryReferent(mSelectionController); if (!selectionController) { return NS_OK; } RefPtr<Selection> selection = selectionController->GetSelection(nsISelectionController::SELECTION_NORMAL); if (selection) { - selection->CollapseToStart(); + selection->CollapseToStart(IgnoreErrors()); } return NS_OK; } NS_IMETHODIMP nsTypeAheadFind::Observe(nsISupports *aSubject, const char *aTopic, const char16_t *aData) @@ -527,17 +527,17 @@ nsTypeAheadFind::FindItNow(nsIPresShell continue; } mFoundRange = returnRange; // ------ Success! ------- // Hide old selection (new one may be on a different controller) if (selection) { - selection->CollapseToStart(); + selection->CollapseToStart(IgnoreErrors()); SetSelectionModeAndRepaint(nsISelectionController::SELECTION_ON); } // Make sure new document is selected if (presShell != startingPresShell) { // We are in a new document (because of frames/iframes) mPresShell = do_GetWeakReference(presShell); } @@ -1022,18 +1022,19 @@ nsTypeAheadFind::Find(const nsAString& a GetSelection(presShell, getter_AddRefs(selectionController), getter_AddRefs(selection)); // cache for reuse mSelectionController = do_GetWeakReference(selectionController); } else { selection = selectionController->GetSelection( nsISelectionController::SELECTION_NORMAL); } - if (selection) - selection->CollapseToStart(); + if (selection) { + selection->CollapseToStart(IgnoreErrors()); + } if (aSearchString.IsEmpty()) { mTypeAheadBuffer.Truncate(); // These will be initialized to their true values after the first character // is typed mStartFindRange = nullptr; mSelectionController = nullptr;