Bug 1623858: part 26) Annotate MaybeAddRangeAndTruncateOverlaps with MOZ_CAN_RUN_SCRIPT. r=masayuki

Differential Revision: https://phabricator.services.mozilla.com/D69179

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Mirko Brodesser 2020-04-01 11:42:16 +00:00
parent 48b72003b0
commit 80129345c6
2 changed files with 10 additions and 6 deletions

View File

@ -923,8 +923,10 @@ nsresult Selection::AddRangesForUserSelectableNodes(
for (size_t i = 0; i < rangesToAdd.Length(); ++i) {
int32_t index;
const RefPtr<Selection> selection{this};
// `MOZ_KnownLive` needed because of broken static analysis
// (https://bugzilla.mozilla.org/show_bug.cgi?id=1622253#c1).
nsresult rv = mStyledRanges.MaybeAddRangeAndTruncateOverlaps(
rangesToAdd[i], &index, *selection);
MOZ_KnownLive(rangesToAdd[i]), &index, *selection);
NS_ENSURE_SUCCESS(rv, rv);
if (i == newAnchorFocusIndex) {
*aOutIndex = index;

View File

@ -169,7 +169,9 @@ class Selection final : public nsSupportsWeakReference,
/**
* See `AddRangesForSelectableNodes`.
*/
MOZ_MUST_USE nsresult AddRangesForUserSelectableNodes(
// TODO: annotate with `MOZ_CAN_RUN_SCRIPT` instead.
[[nodiscard]] MOZ_CAN_RUN_SCRIPT_BOUNDARY nsresult
AddRangesForUserSelectableNodes(
nsRange* aRange, int32_t* aOutIndex,
const DispatchSelectstartEvent aDispatchSelectstartEvent);
@ -184,7 +186,9 @@ class Selection final : public nsSupportsWeakReference,
* containing it. -1 if mStyledRanges.mRanges was empty and
* no range was added.
*/
MOZ_MUST_USE nsresult AddRangesForSelectableNodes(
// TODO: annotate with `MOZ_CAN_RUN_SCRIPT` instead.
[[nodiscard]] MOZ_CAN_RUN_SCRIPT_BOUNDARY nsresult
AddRangesForSelectableNodes(
nsRange* aRange, int32_t* aOutIndex,
DispatchSelectstartEvent aDispatchSelectstartEvent);
@ -795,9 +799,7 @@ class Selection final : public nsSupportsWeakReference,
* is already contained, to the one containing it. Hence
* it'll always be in [0, mRanges.Length()).
*/
// TODO: annotate with `MOZ_CAN_RUN_SCRIPT`
// (https://bugzilla.mozilla.org/show_bug.cgi?id=1625429).
MOZ_CAN_RUN_SCRIPT_BOUNDARY nsresult MaybeAddRangeAndTruncateOverlaps(
MOZ_CAN_RUN_SCRIPT nsresult MaybeAddRangeAndTruncateOverlaps(
nsRange* aRange, int32_t* aOutIndex, Selection& aSelection);
/**