Bug 1800787 - [devtools] Accessibility picker: Hit test using sub-document/panel Accessible if the target is inside a sub-document/panel. r=ayeddi,devtools-reviewers,nchevobbe

This allows the picker to work correctly inside pop-ups, even if the pop-up contains a sub-document.

Differential Revision: https://phabricator.services.mozilla.com/D187242
This commit is contained in:
James Teh 2023-10-09 06:02:08 +00:00
Родитель d265ec4f5f
Коммит cd625cdced
1 изменённых файлов: 8 добавлений и 2 удалений

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

@ -1099,11 +1099,17 @@ class AccessibleWalkerActor extends Actor {
*/
_findAndAttachAccessible(event) {
const target = event.originalTarget || event.target;
const docAcc = this.getRawAccessibleFor(this.rootDoc);
const win = target.ownerGlobal;
// This event might be inside a sub-document, so don't use this.rootDoc.
const docAcc = this.getRawAccessibleFor(win.document);
const zoom = this.isXUL ? 1 : getCurrentZoom(win);
const scale = this.pixelRatio / zoom;
const rawAccessible = docAcc.getDeepestChildAtPointInProcess(
// If the target is inside a pop-up widget, we need to query the pop-up
// Accessible, not the DocAccessible. The DocAccessible can't hit test
// inside pop-ups.
const popup = win.isChromeWindow ? target.closest("panel") : null;
const containerAcc = popup ? this.getRawAccessibleFor(popup) : docAcc;
const rawAccessible = containerAcc.getDeepestChildAtPointInProcess(
event.screenX * scale,
event.screenY * scale
);