Bug 1660359 part 2: Allow a11y focus on a remote print preview OuterDocAccessible. r=jwatt,yzen

Print preview documents don't get DocAccessibles because this currently causes crashes and doesn't provide much value.
However, we still want to tell a11y clients something useful when a print preview document gets focus, rather than a11y focus just going nowhere.
Therefore, we allow a11y focus to land on the OuterDocAccessible (browser element) in this case.

Differential Revision: https://phabricator.services.mozilla.com/D87997
This commit is contained in:
James Teh 2020-08-27 06:12:25 +00:00
parent 08293afb21
commit 2f11033294
2 changed files with 9 additions and 0 deletions

View File

@ -370,6 +370,14 @@ nsINode* FocusManager::FocusedDOMNode() const {
nsIContent* focusedElm = DOMFocusManager->GetFocusedElement();
if (focusedElm) {
// Print preview documents don't get DocAccessibles, but we still want a11y
// focus to go somewhere useful. Therefore, we allow a11y focus to land on
// the OuterDocAccessible in this case.
// Note that this code only handles remote print preview documents.
if (EventStateManager::IsTopLevelRemoteTarget(focusedElm) &&
focusedElm->AsElement()->HasAttribute(u"printpreview"_ns)) {
return focusedElm;
}
// No focus on remote target elements like xul:browser having DOM focus and
// residing in chrome process because it means an element in content process
// keeps the focus. Similarly, suppress focus on OOP iframes because an

View File

@ -173,6 +173,7 @@ var PrintEventHandler = {
});
printPreviewBrowser.classList.add("printPreviewBrowser");
printPreviewBrowser.setAttribute("flex", "1");
printPreviewBrowser.setAttribute("printpreview", "true");
// Create the stack for the loading indicator.
let ourBrowser = window.docShell.chromeEventHandler;