diff options
author | Matt A. Tobin <email@mattatobin.com> | 2020-04-17 06:10:23 -0400 |
---|---|---|
committer | Matt A. Tobin <email@mattatobin.com> | 2020-04-17 06:10:23 -0400 |
commit | 70c8ff8e5af7d2661b64fb92a158f2860af7766c (patch) | |
tree | e7fd37d81858a7dfa06fbf59880d837d9e7fa256 /layout | |
parent | 53428ad3f04ff1e01f0596ef0c592bdbe5fdd15b (diff) | |
download | UXP-70c8ff8e5af7d2661b64fb92a158f2860af7766c.tar UXP-70c8ff8e5af7d2661b64fb92a158f2860af7766c.tar.gz UXP-70c8ff8e5af7d2661b64fb92a158f2860af7766c.tar.lz UXP-70c8ff8e5af7d2661b64fb92a158f2860af7766c.tar.xz UXP-70c8ff8e5af7d2661b64fb92a158f2860af7766c.zip |
Bug 1377978 - Make nsRange use uint32_t to offset
Tag #1375
Diffstat (limited to 'layout')
-rw-r--r-- | layout/base/nsPresShell.cpp | 6 | ||||
-rw-r--r-- | layout/generic/nsImageFrame.cpp | 14 | ||||
-rw-r--r-- | layout/generic/nsSelection.cpp | 6 |
3 files changed, 17 insertions, 9 deletions
diff --git a/layout/base/nsPresShell.cpp b/layout/base/nsPresShell.cpp index 2407db650..0839f6bb7 100644 --- a/layout/base/nsPresShell.cpp +++ b/layout/base/nsPresShell.cpp @@ -4747,9 +4747,11 @@ PresShell::ClipListToRange(nsDisplayListBuilder *aBuilder, frame->GetOffsets(frameStartOffset, frameEndOffset); int32_t hilightStart = - atStart ? std::max(aRange->StartOffset(), frameStartOffset) : frameStartOffset; + atStart ? std::max(static_cast<int32_t>(aRange->StartOffset()), + frameStartOffset) : frameStartOffset; int32_t hilightEnd = - atEnd ? std::min(aRange->EndOffset(), frameEndOffset) : frameEndOffset; + atEnd ? std::min(static_cast<int32_t>(aRange->EndOffset()), + frameEndOffset) : frameEndOffset; if (hilightStart < hilightEnd) { // determine the location of the start and end edges of the range. nsPoint startPoint, endPoint; diff --git a/layout/generic/nsImageFrame.cpp b/layout/generic/nsImageFrame.cpp index c64520f2e..ee35ecad8 100644 --- a/layout/generic/nsImageFrame.cpp +++ b/layout/generic/nsImageFrame.cpp @@ -1836,7 +1836,7 @@ nsImageFrame::ShouldDisplaySelection() int32_t thisOffset = parentContent->IndexOf(mContent); nsCOMPtr<nsIDOMNode> parentNode = do_QueryInterface(parentContent); nsCOMPtr<nsIDOMNode> rangeNode; - int32_t rangeOffset; + uint32_t rangeOffset; nsCOMPtr<nsIDOMRange> range; selection->GetRangeAt(0,getter_AddRefs(range)); if (range) @@ -1844,12 +1844,16 @@ nsImageFrame::ShouldDisplaySelection() range->GetStartContainer(getter_AddRefs(rangeNode)); range->GetStartOffset(&rangeOffset); - if (parentNode && rangeNode && (rangeNode == parentNode) && rangeOffset == thisOffset) - { + if (parentNode && rangeNode && rangeNode == parentNode && + static_cast<int32_t>(rangeOffset) == thisOffset) { range->GetEndContainer(getter_AddRefs(rangeNode)); range->GetEndOffset(&rangeOffset); - if ((rangeNode == parentNode) && (rangeOffset == (thisOffset +1))) //+1 since that would mean this whole content is selected only - return false; //do not allow nsFrame do draw any further selection + // +1 since that would mean this whole content is selected only + if (rangeNode == parentNode && + static_cast<int32_t>(rangeOffset) == thisOffset + 1) { + // Do not allow nsFrame do draw any further selection + return false; + } } } } diff --git a/layout/generic/nsSelection.cpp b/layout/generic/nsSelection.cpp index f44ff7ea1..994ec4852 100644 --- a/layout/generic/nsSelection.cpp +++ b/layout/generic/nsSelection.cpp @@ -4119,13 +4119,15 @@ Selection::GetType(int16_t* aType) static inline bool RangeMatchesBeginPoint(nsRange* aRange, nsINode* aNode, int32_t aOffset) { - return aRange->GetStartParent() == aNode && aRange->StartOffset() == aOffset; + return aRange->GetStartParent() == aNode && + static_cast<int32_t>(aRange->StartOffset()) == aOffset; } static inline bool RangeMatchesEndPoint(nsRange* aRange, nsINode* aNode, int32_t aOffset) { - return aRange->GetEndParent() == aNode && aRange->EndOffset() == aOffset; + return aRange->GetEndParent() == aNode && + static_cast<int32_t>(aRange->EndOffset()) == aOffset; } // Selection::EqualsRangeAtPoint |