Bug 1735446 - part 4: Make Selection::GetRangeAt() take uint32_t instead of int32_t r=smaug
It's an internal API corresponding to `Selection.getRangeAt` DOM API. I think that it should use `uint32_t` rather than `size_t` because of the consistency with the DOM API and `Selection::RangeCount()`. This patch fixes all callers of `GetRangeAt()`, and rewrites it with ranged- loops unless original ones do not refer `RangeCount()` every time and may run script in the loop. Differential Revision: https://phabricator.services.mozilla.com/D128848
This commit is contained in:
@@ -2264,7 +2264,7 @@ nsRange* Selection::GetRangeAt(uint32_t aIndex, ErrorResult& aRv) {
|
||||
return range;
|
||||
}
|
||||
|
||||
nsRange* Selection::GetRangeAt(int32_t aIndex) const {
|
||||
nsRange* Selection::GetRangeAt(uint32_t aIndex) const {
|
||||
StyledRange empty(nullptr);
|
||||
return mStyledRanges.mRanges.SafeElementAt(aIndex, empty).mRange;
|
||||
}
|
||||
@@ -2748,8 +2748,11 @@ bool Selection::ContainsPoint(const nsPoint& aPoint) {
|
||||
return false;
|
||||
}
|
||||
PointInRectChecker checker(aPoint);
|
||||
for (uint32_t i = 0; i < RangeCount(); i++) {
|
||||
const uint32_t rangeCount = RangeCount();
|
||||
for (const uint32_t i : IntegerRange(rangeCount)) {
|
||||
MOZ_ASSERT(RangeCount() == rangeCount);
|
||||
nsRange* range = GetRangeAt(i);
|
||||
MOZ_ASSERT(range);
|
||||
nsRange::CollectClientRectsAndText(
|
||||
&checker, nullptr, range, range->GetStartContainer(),
|
||||
range->StartOffset(), range->GetEndContainer(), range->EndOffset(),
|
||||
|
||||
Reference in New Issue
Block a user