Bug 1806356: Create an accessible if the element's frame has a transform, r=Jamie

This revision changes the logic of MustCreateAccessible such that we always create
an accessible if the content's frame has been transformed. This ensures that we
have accessibles to which we apply transforms when calculating accessible bounds.
This revision also adds a test to verify that the accessible is created, even
when the element has role="presentation".

Differential Revision: https://phabricator.services.mozilla.com/D167760
This commit is contained in:
Nathan LaPre 2023-01-26 18:40:45 +00:00
Родитель 751a1f7bae
Коммит 0f763d9ab4
2 изменённых файлов: 44 добавлений и 1 удалений

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

@ -107,7 +107,18 @@ using namespace mozilla::dom;
* Return true if the element must be accessible.
*/
static bool MustBeAccessible(nsIContent* aContent, DocAccessible* aDocument) {
if (aContent->GetPrimaryFrame()->IsFocusable()) return true;
nsIFrame* frame = aContent->GetPrimaryFrame();
MOZ_ASSERT(frame);
if (frame->IsFocusable()) {
return true;
}
// If the frame has been transformed, we should create an accessible so that
// we can account for the transform when calculating the Accessible's bounds
// using the parent process cache.
if (frame->IsTransformed()) {
return true;
}
if (aContent->IsElement()) {
uint32_t attrCount = aContent->AsElement()->GetAttrCount();

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

@ -4,6 +4,9 @@
"use strict";
/* import globals from ../../mochitest/role.js */
loadScripts({ name: "role.js", dir: MOCHITESTS_DIR });
// test basic translation
addAccessibleTask(
`<p id="translate">hello world</p>`,
@ -114,3 +117,32 @@ addAccessibleTask(
},
{ topLevel: true, iframe: true, remoteIframe: true }
);
// Verify that a transform forces creation of an accessible.
addAccessibleTask(
`
<div id="div-transform" style="transform:translate(100px,100px);">
<p>test</p>
</div>
<div id="div-presentational" role="presentation" style="transform:translate(100px,100px);">
<p>test</p>
</div>
`,
async function(browser, docAcc) {
const tree = { SECTION: [{ PARAGRAPH: [{ TEXT_LEAF: [] }] }] };
const divWithTransform = findAccessibleChildByID(docAcc, "div-transform");
testAccessibleTree(divWithTransform, tree);
await testBoundsWithContent(docAcc, "div-transform", browser);
// An accessible should still be created, even if the role is "presentation."
const divPresentational = findAccessibleChildByID(
docAcc,
"div-presentational"
);
testAccessibleTree(divPresentational, tree);
await testBoundsWithContent(docAcc, "div-presentational", browser);
},
{ topLevel: true, iframe: true, remoteIframe: true }
);