Closed Bug 1966812 Opened 4 months ago Closed 2 months ago

Support getting character bounds for end of line insertion point

Categories

(Core :: Disability Access APIs, defect)

defect

Tracking

()

RESOLVED FIXED
142 Branch
Tracking Status
firefox142 --- fixed

People

(Reporter: Jamie, Assigned: eeejay, NeedInfo)

References

(Blocks 3 open bugs)

Details

Attachments

(1 file)

Some accessibility clients (e.g. Windows Text Cursor Indicator) need to be able to retrieve the rectangle for the character at the caret. In bug 1951833, I'm fixing this for line feed characters. However, TextLeafPoint::CharBounds doesn't properly support this for the end of line insertion point; i.e. when mIsEndOfLineInsertionPoint is true. Text Cursor Indicator seems to cope without this, but we should probably support it for completeness and/or better accuracy.

I think we can do this by getting the previous character's rectangle and then returning (prevX + prevW, prevY, 1, 1) or similar.

Blocks: boundsa11y

We're actually going to need this for UIA. STR:

  1. Enable Windows Text Cursor Indicator.
  2. Open this:
    data:text/html,<textarea>a%0A%0A</textarea>
  3. Move to the final (blank) line.
    • Expected: The Windows Text Cursor Indicator moves to the final line.
    • Actual: Firefox's text insertion cursor moves to the final line. However, the Windows Text Cursor Indicator is on the first blank line.
Blocks: uia
Severity: -- → S3
Type: enhancement → defect

I think we can do this by getting the previous character's rectangle and then returning (prevX + prevW, prevY, 1, 1) or similar.

That won't work for comment 1; that'll just result in the same problem. We need some way of getting the coordinates of the actual caret in this case. We do have HyperTextAccessible::GetCaretRect and we do send that to the parent process with caret events, but it's a bit messy for various reasons.

(In reply to James Teh [:Jamie] from comment #2)

We need some way of getting the coordinates of the actual caret in this case.

It'd be better if we could get the coordinates for where the caret would be if it landed here, since the caret might have actually moved somewhere else since this point was created. I'm not sure if that's possible though.

Eitan, based on our chat, are you planning to work on this? Totally fine either way. I just want to know so I don't put time into it if you're already on it (or will be soon).

Flags: needinfo?(eitan)
Blocks: uiatext
No longer blocks: uia

(In reply to James Teh [:Jamie] from comment #3)

It'd be better if we could get the coordinates for where the caret would be if it landed [at the end of line insertion point], since the caret might have actually moved somewhere else since this point was created.

When mIsEndOfLineInsertionPoint is true, we could perhaps:

  1. If mOffset < TextLength(mAcc), Use (prevX + prevW, prevY, 1, 1) as suggested in comment 0.
  2. If mOffset == TextLength(mAcc), get the bounds of mAcc and use (accW - 1, accH - 1, 1, 1). That covers comment 1 (the line feed at end of input case). We could further restrict this so that we only do it if the character at mOffset - 1 is a line feed if that makes more sense.

I'm working on this, yes :)

Note, I'm not changing the width of the caret to align to the start of the character because it would be wrong for vertical or rtl text.

Flags: needinfo?(eitan)
Assignee: nobody → eitan

Per discussion with Eitan, we think the best thing to do here is to use the caret rect if mIsEndOfLineInsertionPoint && this == TextLeafPoint::GetCaret(mAcc). That means we need to cache the caret rect on the DocAccessibleParent and unify the way we query the caret rect.

I didn't do this unification in bug 1828295 because HyperTextAccessible::GetCaretRect takes a widget, which is weird for RemoteAccessible. It does this because Windows needs to set up the system caret in the correct OS widget (HWND) and pop-ups have separate OS widgets. However, it just occurred to me that RemoteAccessible::GetCaretRect can just return the widget for OuterDocOfRemoteAccessible(). That also means we can unify Windows AccessibleWrap::UpdateSystemCaretFor, since the unified GetCaretRect can return both a rect and a widget in all cases.

See Also: → 1828295

Moved GetCaretRect to HyperTextAccessibleBase. I could see this living
in TextLeafPoint, but it is a bit confusing when a point is a caret and
when it is a simple offset. I think we would need to either add an
mIsCaret field to the class, or have a special static CaretBounds
method.

Blocks: 1976137
Pushed by amarc@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/83bc2bce51a8 https://hg.mozilla.org/integration/autoland/rev/ae6f4a626e90 Revert "Bug 1966812 - Cache rect bounds in DocAccessibleParent. r=Jamie" for causing ba failures @ browser_caret_rect.js

Backed out for causing ba failures @ browser_caret_rect.js

Flags: needinfo?(eitan)
Blocks: 1977507
Status: NEW → RESOLVED
Closed: 2 months ago
Resolution: --- → FIXED
Target Milestone: --- → 142 Branch
Regressions: 1977544
QA Whiteboard: [qa-triage-done-c143/b142]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: