Bug 1897349: Don't update CSS pseudo-element TextLeafAccessibles if there is CSS content alt text. r=eeejay

When we create a TextLeafAccessible for a CSS pseudo-element, we already use the alt text if present.
However, it seems layout sometimes re-renders the text of pseudo-elements.
Previously, a11y would update the text in this case like it would for any other TextLeafAccessible, thus overwriting the alt text with the text rendered by layout.
To fix this, we now skip updating text if CSS alt text is present.

Differential Revision: https://phabricator.services.mozilla.com/D211139
This commit is contained in:
James Teh
2024-05-22 22:14:33 +00:00
parent 5b78ce676b
commit 5b0958aae4

View File

@@ -5,6 +5,7 @@
#include "NotificationController.h"
#include "CssAltContent.h"
#include "DocAccessible-inl.h"
#include "DocAccessibleChild.h"
#include "LocalAccessible-inl.h"
@@ -823,6 +824,14 @@ void NotificationController::WillRefresh(mozilla::TimeStamp aTime) {
}
#endif
if (CssAltContent(textNode)) {
// A11y doesn't care about the text rendered by layout if there is CSS
// content alt text. We skip this here rather than when the update is
// queued because the TextLeafAccessible might not exist yet and we
// might need to create it below.
continue;
}
TextUpdater::Run(mDocument, textAcc->AsTextLeaf(), text.mString);
continue;
}