Bug 1828373: Create accs for elements with overflow:scroll and overflow:auto styling r=nlapre,Jamie

Differential Revision: https://phabricator.services.mozilla.com/D176202
This commit is contained in:
Morgan Rae Reschenberg
2023-05-03 22:26:40 +00:00
parent 95c5c6a41e
commit 05cf01d27d
6 changed files with 130 additions and 28 deletions

View File

@@ -195,6 +195,15 @@ static bool AttributesMustBeAccessible(nsIContent* aContent,
*/
static bool MustBeGenericAccessible(nsIContent* aContent,
DocAccessible* aDocument) {
if (aContent->IsInNativeAnonymousSubtree() || aContent->IsSVGElement()) {
// We should not force create accs for anonymous content.
// This is an issue for inputs, which have an intermediate
// container with relevant overflow styling between the input
// and its internal input content.
// We should also avoid this for SVG elements (ie. `<foreignobject>`s
// which have default overflow:hidden styling).
return false;
}
nsIFrame* frame = aContent->GetPrimaryFrame();
MOZ_ASSERT(frame);
nsAutoCString overflow;
@@ -202,7 +211,8 @@ static bool MustBeGenericAccessible(nsIContent* aContent,
// If the frame has been transformed, and the content has any children, we
// should create an Accessible so that we can account for the transform when
// calculating the Accessible's bounds using the parent process cache.
// Ditto for content which is position: fixed or sticky.
// Ditto for content which is position: fixed or sticky or has overflow
// styling (auto, scroll, hidden).
// However, don't do this for XUL widgets, as this breaks XUL a11y code
// expectations in some cases. XUL widgets are only used in the parent
// process and can't be cached anyway.
@@ -210,7 +220,8 @@ static bool MustBeGenericAccessible(nsIContent* aContent,
(frame->IsTransformed() || frame->IsStickyPositioned() ||
(frame->StyleDisplay()->mPosition == StylePositionProperty::Fixed &&
nsLayoutUtils::IsReallyFixedPos(frame)) ||
overflow.Equals("hidden"_ns));
(overflow.Equals("auto"_ns) || overflow.Equals("scroll"_ns) ||
overflow.Equals("hidden"_ns)));
}
/**
@@ -520,11 +531,13 @@ void nsAccessibilityService::NotifyOfComputedStyleChange(
LocalAccessible* accessible = aContent == document->GetContent()
? document
: document->GetAccessible(aContent);
if (!accessible && aContent && aContent->HasChildren()) {
if (!accessible && aContent && aContent->HasChildren() &&
!aContent->IsInNativeAnonymousSubtree()) {
// If the content has children and its frame has a transform, create an
// Accessible so that we can account for the transform when calculating
// the Accessible's bounds using the parent process cache. Ditto for
// position: fixed/sticky and overflow: hidden content.
// position: fixed/sticky and content with overflow styling (hidden, auto,
// scroll)
const nsIFrame* frame = aContent->GetPrimaryFrame();
const ComputedStyle* newStyle = frame ? frame->Style() : nullptr;
nsAutoCString overflow;
@@ -533,7 +546,8 @@ void nsAccessibilityService::NotifyOfComputedStyleChange(
(newStyle->StyleDisplay()->HasTransform(frame) ||
newStyle->StyleDisplay()->mPosition == StylePositionProperty::Fixed ||
newStyle->StyleDisplay()->mPosition == StylePositionProperty::Sticky ||
overflow.Equals("hidden"_ns))) {
(overflow.Equals("hidden"_ns) || overflow.Equals("scroll"_ns) ||
overflow.Equals("auto"_ns)))) {
document->ContentInserted(aContent, aContent->GetNextSibling());
}
} else if (accessible && IPCAccessibilityActive() &&