@@ -2058,8 +2058,8 @@ bool TextLeafRange::Crop(Accessible* aContainer) {
2058
2058
LayoutDeviceIntRect TextLeafRange::Bounds () const {
2059
2059
// Walk all the lines and union them into the result rectangle.
2060
2060
LayoutDeviceIntRect result = TextLeafPoint{mStart }.CharBounds ();
2061
- const bool succeeded =
2062
- WalkLineRects ( [&result](LayoutDeviceIntRect aLineRect) {
2061
+ const bool succeeded = WalkLineRects (
2062
+ [&result](TextLeafRange aLine, LayoutDeviceIntRect aLineRect) {
2063
2063
result.UnionRect (result, aLineRect);
2064
2064
});
2065
2065
@@ -2078,7 +2078,8 @@ nsTArray<LayoutDeviceIntRect> TextLeafRange::LineRects() const {
2078
2078
}
2079
2079
2080
2080
nsTArray<LayoutDeviceIntRect> lineRects;
2081
- WalkLineRects ([&lineRects, &contentBounds](LayoutDeviceIntRect aLineRect) {
2081
+ WalkLineRects ([&lineRects, &contentBounds](TextLeafRange aLine,
2082
+ LayoutDeviceIntRect aLineRect) {
2082
2083
// Clip the bounds to the bounds of the content area.
2083
2084
bool boundsVisible = true ;
2084
2085
if (contentBounds.isSome ()) {
@@ -2253,22 +2254,25 @@ bool TextLeafRange::WalkLineRects(LineRectCallback aCallback) const {
2253
2254
// start of the next line and going back one char. We don't
2254
2255
// use BOUNDARY_LINE_END here because it is equivalent to LINE_START when
2255
2256
// the line doesn't end with a line feed character.
2256
- TextLeafPoint lineStartPoint = currPoint.FindBoundary (
2257
+ TextLeafPoint nextLineStartPoint = currPoint.FindBoundary (
2257
2258
nsIAccessibleText::BOUNDARY_LINE_START, eDirNext);
2258
- TextLeafPoint lastPointInLine = lineStartPoint .FindBoundary (
2259
+ TextLeafPoint lastPointInLine = nextLineStartPoint .FindBoundary (
2259
2260
nsIAccessibleText::BOUNDARY_CHAR, eDirPrevious);
2260
- // If currPoint is the end of the document, lineStartPoint will be equal
2261
+ // If currPoint is the end of the document, nextLineStartPoint will be equal
2261
2262
// to currPoint and we would be in an endless loop.
2262
- if (lineStartPoint == currPoint || mEnd <= lastPointInLine) {
2263
+ if (nextLineStartPoint == currPoint || mEnd <= lastPointInLine) {
2263
2264
lastPointInLine = mEnd ;
2264
2265
locatedFinalLine = true ;
2265
2266
}
2266
2267
2267
- LayoutDeviceIntRect currLine = currPoint.CharBounds ();
2268
- currLine.UnionRect (currLine, lastPointInLine.CharBounds ());
2269
- aCallback (currLine);
2268
+ LayoutDeviceIntRect currLineRect = currPoint.CharBounds ();
2269
+ currLineRect.UnionRect (currLineRect, lastPointInLine.CharBounds ());
2270
+ // The range we pass must include the last character and range ends are
2271
+ // exclusive, hence the use of nextLineStartPoint.
2272
+ TextLeafRange currLine = TextLeafRange (currPoint, nextLineStartPoint);
2273
+ aCallback (currLine, currLineRect);
2270
2274
2271
- currPoint = lineStartPoint ;
2275
+ currPoint = nextLineStartPoint ;
2272
2276
}
2273
2277
return true ;
2274
2278
}
0 commit comments