Bug 1775684 part 2: Don't create a DocAccessible if it doesn't exist yet when handling notifications for cache/tree updates. r=morgan

We only use these notifications from layout to push cache updates or insert Accessibles that were skipped during the initial build.
If the DocAccessible doesn't exist yet, creating it is pointless since we can't do this update until the tree is built.
The correct data will be included in the initial tree and cache push anyway.
Aside from pointless refresh ticks, this really shouldn't make any difference, since we don't build the initial tree until layout is ready anyway.
However, the only remotely relevant thing I can think of that's changed in the a11y code lately that might have caused a spike in these test failures is that bounds notifications might get fired earlier/more often from layout, potentially causing earlier creation of DocAccessibles.
Any change to timing might cause a shift in intermittent failures, and since this is wasteful anyway, we may as well fix it.

Differential Revision: https://phabricator.services.mozilla.com/D168911
This commit is contained in:
James Teh 2023-02-09 04:50:53 +00:00
Родитель 8cd27f807a
Коммит 631c9ecf0a
1 изменённых файлов: 4 добавлений и 4 удалений

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

@ -424,7 +424,7 @@ void nsAccessibilityService::NotifyOfPossibleBoundsChange(
mozilla::PresShell* aPresShell, nsIContent* aContent) {
if (IPCAccessibilityActive() &&
StaticPrefs::accessibility_cache_enabled_AtStartup()) {
DocAccessible* document = GetDocAccessible(aPresShell);
DocAccessible* document = aPresShell->GetDocAccessible();
if (document) {
// DocAccessible::GetAccessible() won't return the document if a root
// element like body is passed.
@ -440,7 +440,7 @@ void nsAccessibilityService::NotifyOfPossibleBoundsChange(
void nsAccessibilityService::NotifyOfComputedStyleChange(
mozilla::PresShell* aPresShell, nsIContent* aContent) {
DocAccessible* document = GetDocAccessible(aPresShell);
DocAccessible* document = aPresShell->GetDocAccessible();
if (!document) {
return;
}
@ -473,7 +473,7 @@ void nsAccessibilityService::NotifyOfComputedStyleChange(
void nsAccessibilityService::NotifyOfResolutionChange(
mozilla::PresShell* aPresShell, float aResolution) {
if (StaticPrefs::accessibility_cache_enabled_AtStartup()) {
DocAccessible* document = GetDocAccessible(aPresShell);
DocAccessible* document = aPresShell->GetDocAccessible();
if (document && document->IPCDoc()) {
AutoTArray<mozilla::a11y::CacheData, 1> data;
RefPtr<AccAttributes> fields = new AccAttributes();
@ -487,7 +487,7 @@ void nsAccessibilityService::NotifyOfResolutionChange(
void nsAccessibilityService::NotifyOfDevPixelRatioChange(
mozilla::PresShell* aPresShell, int32_t aAppUnitsPerDevPixel) {
if (StaticPrefs::accessibility_cache_enabled_AtStartup()) {
DocAccessible* document = GetDocAccessible(aPresShell);
DocAccessible* document = aPresShell->GetDocAccessible();
if (document && document->IPCDoc()) {
AutoTArray<mozilla::a11y::CacheData, 1> data;
RefPtr<AccAttributes> fields = new AccAttributes();