Bug 1825054 - Don't get stuck in endless loop when getting bounds. r=morgan

Differential Revision: https://phabricator.services.mozilla.com/D173864
This commit is contained in:
Eitan Isaacson 2023-03-29 22:31:00 +00:00
Родитель 78935b829e
Коммит 545741bece
2 изменённых файлов: 22 добавлений и 1 удалений

Просмотреть файл

@ -1782,7 +1782,9 @@ LayoutDeviceIntRect TextLeafRange::Bounds() const {
nsIAccessibleText::BOUNDARY_LINE_START, eDirNext);
TextLeafPoint lastPointInLine = lineStartPoint.FindBoundary(
nsIAccessibleText::BOUNDARY_CHAR, eDirPrevious);
if (mEnd <= lastPointInLine) {
// If currPoint is the end of the document, lineStartPoint will be equal
// to currPoint and we would be in an endless loop.
if (lineStartPoint == currPoint || mEnd <= lastPointInLine) {
lastPointInLine = mEnd;
locatedFinalLine = true;
}

Просмотреть файл

@ -378,3 +378,22 @@ addAccessibleTask(
is(str, "hello", "Left word at start of input should be right word");
}
);
addAccessibleTask(`<p id="p">hello world</p>`, async (browser, accDoc) => {
let macDoc = accDoc.nativeInterface.QueryInterface(
Ci.nsIAccessibleMacInterface
);
let p = getNativeInterface(accDoc, "p");
let range = macDoc.getParameterizedAttributeValue(
"AXTextMarkerRangeForUIElement",
p
);
let bounds = macDoc.getParameterizedAttributeValue(
"AXBoundsForTextMarkerRange",
range
);
ok(bounds.origin && bounds.size, "Returned valid bounds");
});