Closed Bug 1951573 Opened 1 year ago Closed 1 year ago

Unify the accessibility code to set the caret

Categories

(Core :: Disability Access APIs, task)

task

Tracking

()

RESOLVED FIXED
138 Branch
Tracking Status
firefox138 --- fixed

People

(Reporter: Jamie, Assigned: Jamie)

References

(Blocks 2 open bugs)

Details

Attachments

(5 files)

There are two very different accessibility code paths for setting the caret: HyperTextAccessible::SetCaretOffset (used by IA2 and ATK) and TextLeafRange::SetSelection (used by Mac and UIA). The former performs some additional tasks which the latter does not: focusing the control, scrolling the selection into view and updating DOM nsFocusmanager. I think we should unify these so that we have a single code path, with SetCaretOffset being mostly a wrapper around SetSelection.

I started working on this in bug 1950785, thinking this solved a real bug. It turns out that my testing was incorrect and the bug I thought I spotted actually doesn't exist. 😳 However, I still think it makes sense to do this and I suspect it will make weird bugs in this area easier to manage in future.

Previously, a caller had to first retrieve all selection ranges and then remove them individually.
This makes it awkward to perform a fairly common operation.

HyperTextAccessible::SetSelectionRange (used by SetCaretOffset) performed these tasks, but TextLeafRange::SetSelection didn't.
This meant that the behaviour when setting the caret or selection was different for different OS APIs: IA2 and ATK use HyperTextAccessible::SetCaretOffset, while Mac and UIA use TextLeafRange::SetSelection.
While we aren't aware of any specific bugs impacting users, this is confusing at best and might result in obscure bugs in future.
See the code comments for details.

TextLeafRange::SetSelection should now be the one place where all text selections are set.
Previously, we had a separate local implementation for SetCaretOffset which differed slightly from using TextLeafRange::SetSelection.
Now, these should be equivalent, so there's no need for this separate local implementation.

There were still some callers of SetSelectionRange, but these can now all be trivially converted to use SetSelectionBoundsAt (which calls TextLeafRange::SetSelection).

Pushed by jteh@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/f30edc52101d part 1: Make it possible to remove all existing selections when calling TextLeafRange::SetSelection. r=eeejay https://hg.mozilla.org/integration/autoland/rev/270f08d9691e part 2: Make TextLeafRange::SetSelection perform additional tasks to ensure the selection is set correctly. r=eeejay https://hg.mozilla.org/integration/autoland/rev/9e306ea56c79 part 3: Implement HyperTextAccessibleBase::SetCaretOffset using TextLeafRange::SetSelection. r=eeejay https://hg.mozilla.org/integration/autoland/rev/5f90dc08ec62 part 4: Remove HyperTextAccessible::SetSelectionRange. r=eeejay https://hg.mozilla.org/integration/autoland/rev/23a8b787c70c part 5: Add an additional Select() test for UIA which tests setting the caret in content which isn't editable. r=eeejay
Regressions: 1958766
Regressions: 1963996
Type: defect → task
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: