From 756976ae2bdb270eafce1889b3fe1e43de0d0271 Mon Sep 17 00:00:00 2001 From: Kagami Sascha Rosylight Date: Thu, 15 Oct 2020 19:12:47 +0000 Subject: [PATCH] Bug 1615296 - Part 3: Fix remaining MOZ_CAN_RUN_SCRIPT warnings r=emilio Differential Revision: https://phabricator.services.mozilla.com/D93600 --- layout/base/nsDocumentViewer.cpp | 2 +- layout/generic/nsFrameSelection.cpp | 8 +++++--- toolkit/components/typeaheadfind/nsTypeAheadFind.cpp | 10 ++++------ toolkit/components/typeaheadfind/nsTypeAheadFind.h | 8 +++++--- 4 files changed, 15 insertions(+), 13 deletions(-) diff --git a/layout/base/nsDocumentViewer.cpp b/layout/base/nsDocumentViewer.cpp index 4402e894ce2e..542b1fa99bce 100644 --- a/layout/base/nsDocumentViewer.cpp +++ b/layout/base/nsDocumentViewer.cpp @@ -2410,7 +2410,7 @@ mozilla::dom::Selection* nsDocumentViewer::GetDocumentSelection() { * ============================================================================ */ -NS_IMETHODIMP nsDocumentViewer::ClearSelection() { +MOZ_CAN_RUN_SCRIPT_BOUNDARY NS_IMETHODIMP nsDocumentViewer::ClearSelection() { // use nsCopySupport::GetSelectionForCopy() ? RefPtr selection = GetDocumentSelection(); if (!selection) { diff --git a/layout/generic/nsFrameSelection.cpp b/layout/generic/nsFrameSelection.cpp index 8a1db0cdc909..1120ee8e7065 100644 --- a/layout/generic/nsFrameSelection.cpp +++ b/layout/generic/nsFrameSelection.cpp @@ -780,7 +780,7 @@ nsresult nsFrameSelection::MoveCaret(nsDirection aDirection, if (doCollapse) { const nsRange* anchorFocusRange = sel->GetAnchorFocusRange(); if (anchorFocusRange) { - nsINode* node; + RefPtr node; int32_t offset; if (visualMovement && nsBidiPresUtils::IsReversedDirectionFrame(frame)) { direction = nsDirection(1 - direction); @@ -876,7 +876,8 @@ 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->CollapseInLimiter(sel->GetFocusNode(), sel->FocusOffset()); + RefPtr node = sel->GetFocusNode(); + sel->CollapseInLimiter(node, sel->FocusOffset()); // Note: 'frame' might be dead here. if (!isBRFrame) { mCaret.mHint = CARET_ASSOCIATE_BEFORE; // We're now at the end of the @@ -1422,7 +1423,8 @@ nsresult nsFrameSelection::TakeFocus(nsIContent* const aNewFocus, bool oldDesiredPosSet = mDesiredCaretPos.mIsSet; // need to keep old desired // position if it was set. - mDomSelections[index]->CollapseInLimiter(aNewFocus, aContentOffset); + RefPtr selection = mDomSelections[index]; + selection->CollapseInLimiter(aNewFocus, aContentOffset); mDesiredCaretPos.mIsSet = oldDesiredPosSet; // now reset desired pos back. mBatching = saveBatching; diff --git a/toolkit/components/typeaheadfind/nsTypeAheadFind.cpp b/toolkit/components/typeaheadfind/nsTypeAheadFind.cpp index 70361db2e199..3a5e2e0acd9b 100644 --- a/toolkit/components/typeaheadfind/nsTypeAheadFind.cpp +++ b/toolkit/components/typeaheadfind/nsTypeAheadFind.cpp @@ -267,8 +267,7 @@ nsTypeAheadFind::SetSelectionModeAndRepaint(int16_t aToggle) { return NS_OK; } -NS_IMETHODIMP -nsTypeAheadFind::CollapseSelection() { +MOZ_CAN_RUN_SCRIPT_BOUNDARY NS_IMETHODIMP nsTypeAheadFind::CollapseSelection() { nsCOMPtr selectionController = do_QueryReferent(mSelectionController); if (!selectionController) { @@ -906,10 +905,9 @@ void nsTypeAheadFind::RangeStartsInsideLink(nsRange* aRange, *aIsStartingLink = false; } -NS_IMETHODIMP -nsTypeAheadFind::Find(const nsAString& aSearchString, bool aLinksOnly, - uint32_t aMode, bool aDontIterateFrames, - uint16_t* aResult) { +MOZ_CAN_RUN_SCRIPT_BOUNDARY NS_IMETHODIMP nsTypeAheadFind::Find( + const nsAString& aSearchString, bool aLinksOnly, uint32_t aMode, + bool aDontIterateFrames, uint16_t* aResult) { if (aMode == nsITypeAheadFind::FIND_PREVIOUS || aMode == nsITypeAheadFind::FIND_NEXT) { if (mTypeAheadBuffer.IsEmpty()) { diff --git a/toolkit/components/typeaheadfind/nsTypeAheadFind.h b/toolkit/components/typeaheadfind/nsTypeAheadFind.h index d66e9c722d73..b2d28efcb60b 100644 --- a/toolkit/components/typeaheadfind/nsTypeAheadFind.h +++ b/toolkit/components/typeaheadfind/nsTypeAheadFind.h @@ -51,9 +51,11 @@ class nsTypeAheadFind : public nsITypeAheadFind, nsresult GetWebBrowserFind(nsIDocShell* aDocShell, nsIWebBrowserFind** aWebBrowserFind); - nsresult FindInternal(uint32_t aMode, const nsAString& aSearchString, - bool aLinksOnly, bool aDontIterateFrames, - uint16_t* aResult); + MOZ_CAN_RUN_SCRIPT nsresult FindInternal(uint32_t aMode, + const nsAString& aSearchString, + bool aLinksOnly, + bool aDontIterateFrames, + uint16_t* aResult); void RangeStartsInsideLink(nsRange* aRange, bool* aIsInsideLink, bool* aIsStartingLink);