Skip to content

Commit

Permalink
Bug 1837030: Treat fuzzily-matched text leaves as valid in OffsetAtPo…
Browse files Browse the repository at this point in the history
…int r=Jamie,nlapre, a=dmeehan

Differential Revision: https://phabricator.services.mozilla.com/D180515
  • Loading branch information
MReschenberg committed Jun 12, 2023
1 parent 51c25ca commit 55f706a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
11 changes: 11 additions & 0 deletions accessible/basetypes/HyperTextAccessibleBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,17 @@ int32_t HyperTextAccessibleBase::OffsetAtPoint(int32_t aX, int32_t aY,
nsAccUtils::ConvertToScreenCoords(aX, aY, aCoordType, thisAcc);
if (!thisAcc->Bounds().Contains(coords.x, coords.y)) {
// The requested point does not exist in this accessible.
// Check if we used fuzzy hittesting to get here and, if
// so, return 0 to indicate this text leaf is a valid match.
LayoutDeviceIntPoint p(aX, aY);
if (aCoordType != nsIAccessibleCoordinateType::COORDTYPE_SCREEN_RELATIVE) {
p = nsAccUtils::ConvertToScreenCoords(aX, aY, aCoordType, thisAcc);
}
Accessible* hittestMatch = nsAccUtils::DocumentFor(thisAcc)->ChildAtPoint(
p.x, p.y, Accessible::EWhichChildAtPoint::DeepestChild);
if (thisAcc == hittestMatch->Parent()) {
return 0;
}
return -1;
}

Expand Down
8 changes: 8 additions & 0 deletions accessible/tests/browser/hittest/browser_test_general.js
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,14 @@ addAccessibleTask(
generic, // Direct Child
invisible.firstChild // Deepest Child
);

await testOffsetAtPoint(
findAccessibleChildByID(docAcc, "invisible", [Ci.nsIAccessibleText]),
1,
1,
COORDTYPE_PARENT_RELATIVE,
0
);
},
{ chrome: false, iframe: true, remoteIframe: true }
);
Expand Down

0 comments on commit 55f706a

Please sign in to comment.