Closed Bug 1776416 Opened 3 years ago Closed 3 years ago

Consider not diffing text for text events inside editable text

Categories

(Core :: Disability Access APIs, enhancement)

enhancement

Tracking

()

RESOLVED FIXED
107 Branch
Tracking Status
firefox107 --- fixed

People

(Reporter: Jamie, Assigned: nlapre)

References

(Blocks 1 open bug)

Details

(Keywords: papercut, parity-chrome)

Attachments

(1 file)

When a text node changes, we currently diff the text and fire events only for the changed portions. While this makes some sense, it can lead to some confusing results for live regions. For example:
data:text/html,<div id="live" aria-live="polite">text</div><button onclick="live.firstChild.textContent = 'testing';">change</button>
If you load this with Firefox + NVDA and press the button, NVDA will say "s, ing". While it's correct strictly speaking, since "te" and "t" remained the same and "s" and "ing" were added, it doesn't make sense from the user's perspective.

To make things more confusing, if you change textContent on an element (replacing the text node) instead, we don't diff:
data:text/html,<div id="live" aria-live="polite">text</div><button onclick="live.textContent = 'testing';">change</button>
For this example, NVDA says "testing" as you'd expect.
It's pretty confusing for authors that these two techniques yield such different results. In Chrome, these cases are the same: entire text node, no diffing.

Calculating these diffs is also not super efficient; see bug 675685. This isn't a problem we've hit in the wild as far as I know, but any efficiency gains are a good thing for code like this.

It's possible that some clients rely on this diffing to detect inserted/removed text while editing. Chrome deals with this by diffing for editable text, but assuming the entire text node for non-editable. I think we should do the same.

Originally reported as NVDA issue: https://github.com/nvaccess/nvda/issues/13834

The diffing I'm talking about happens in mozilla::a11y::TextUpdater::DoUpdate. As for detecting whether something is editable, see mozilla::a11y::HyperTextAccessible::NativeState.

Assignee: nobody → nlapre

Diffing text can make for confusing screen reader readouts in live regions. To
address this, this revision causes gecko to avoid sending update events for
solely the diff. Instead, gecko will now send a text update event that causes
us to re-read the entire text node. This brings us in line with Chrome.
Notably, if the text is editable, we'll continue to diff as usual to avoid
clients reading too much text on each edit.

Pushed by nlapre@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/8c2161244f8f Do not diff hypertext if not editable, r=Jamie
Status: NEW → RESOLVED
Closed: 3 years ago
Resolution: --- → FIXED
Target Milestone: --- → 107 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: