From 70c8ff8e5af7d2661b64fb92a158f2860af7766c Mon Sep 17 00:00:00 2001 From: "Matt A. Tobin" Date: Fri, 17 Apr 2020 06:10:23 -0400 Subject: Bug 1377978 - Make nsRange use uint32_t to offset Tag #1375 --- embedding/components/find/nsFind.cpp | 19 ++++++++++++------- embedding/components/find/nsWebBrowserFind.cpp | 2 +- 2 files changed, 13 insertions(+), 8 deletions(-) (limited to 'embedding') diff --git a/embedding/components/find/nsFind.cpp b/embedding/components/find/nsFind.cpp index 63304dafb..89221251e 100644 --- a/embedding/components/find/nsFind.cpp +++ b/embedding/components/find/nsFind.cpp @@ -609,7 +609,7 @@ nsFind::NextNode(nsIDOMRange* aSearchRange, // beginning/end of the search range. nsCOMPtr startNode; nsCOMPtr endNode; - int32_t startOffset, endOffset; + uint32_t startOffset, endOffset; if (aContinueOk) { #ifdef DEBUG_FIND printf("Match in progress: continuing past endpoint\n"); @@ -645,7 +645,8 @@ nsFind::NextNode(nsIDOMRange* aSearchRange, } } - rv = InitIterator(startNode, startOffset, endNode, endOffset); + rv = InitIterator(startNode, static_cast(startOffset), + endNode, static_cast(endOffset)); NS_ENSURE_SUCCESS(rv, rv); if (!aStartPoint) { aStartPoint = aSearchRange; @@ -665,14 +666,18 @@ nsFind::NextNode(nsIDOMRange* aSearchRange, if (mFindBackward) { aStartPoint->GetEndContainer(getter_AddRefs(node)); if (mIterNode.get() == node.get()) { - aStartPoint->GetEndOffset(&mIterOffset); + uint32_t endOffset; + aStartPoint->GetEndOffset(&endOffset); + mIterOffset = static_cast(endOffset); } else { mIterOffset = -1; // sign to start from end } } else { aStartPoint->GetStartContainer(getter_AddRefs(node)); if (mIterNode.get() == node.get()) { - aStartPoint->GetStartOffset(&mIterOffset); + uint32_t startOffset; + aStartPoint->GetStartOffset(&startOffset); + mIterOffset = static_cast(startOffset); } else { mIterOffset = 0; } @@ -997,7 +1002,7 @@ nsFind::Find(const nsAString& aPatText, nsIDOMRange* aSearchRange, // Get the end point, so we know when to end searches: nsCOMPtr endNode; - int32_t endOffset; + uint32_t endOffset; aEndPoint->GetEndContainer(getter_AddRefs(endNode)); aEndPoint->GetEndOffset(&endOffset); @@ -1132,8 +1137,8 @@ nsFind::Find(const nsAString& aPatText, nsIDOMRange* aSearchRange, // Have we gone past the endpoint yet? If we have, and we're not in the // middle of a match, return. if (mIterNode == endNode && - ((mFindBackward && findex < endOffset) || - (!mFindBackward && findex > endOffset))) { + ((mFindBackward && findex < static_cast(endOffset)) || + (!mFindBackward && findex > static_cast(endOffset)))) { ResetAll(); return NS_OK; } diff --git a/embedding/components/find/nsWebBrowserFind.cpp b/embedding/components/find/nsWebBrowserFind.cpp index aadc66f8e..5aefba975 100644 --- a/embedding/components/find/nsWebBrowserFind.cpp +++ b/embedding/components/find/nsWebBrowserFind.cpp @@ -518,7 +518,7 @@ nsWebBrowserFind::GetSearchLimits(nsIDOMRange* aSearchRange, nsCOMPtr range; nsCOMPtr node; - int32_t offset; + uint32_t offset; // Forward, not wrapping: SelEnd to DocEnd if (!mFindBackwards && !aWrap) { -- cgit v1.2.3