Closed Bug 1816601 Opened 2 years ago Closed 2 years ago

[CTW] Consider emulating HyperTextAccessible::OffsetAtPoint returning 0 even if offset 0 isn't at the given point

Categories

(Core :: Disability Access APIs, enhancement)

enhancement

Tracking

()

RESOLVED FIXED
112 Branch
Tracking Status
firefox111 --- fixed
firefox112 --- fixed

People

(Reporter: Jamie, Assigned: Jamie)

References

Details

(Whiteboard: [ctw-m5])

Attachments

(1 file)

Spun off bug 1809082 comment 3.

data:text/html,<button><div style="display: flex;"><div style="width: 100px; background-color: red;" role="none"></div>test

If you mouse over the red area, Firefox without cache + NVDA reports "test", but Firefox with cache does not. If you mouse over the text, "test" is reported regardless of the cache. Chromium browsers are consistent with Firefox with cache.

Although this intuitively seems like ideal behaviour in Firefox without cache, it's actually due to a bug which is fixed by CTW . NVDA mouse tracking is designed to read text, not controls. It asks for the character at the position of the mouse. Firefox without cache incorrectly reports the first character, when in reality, there is no character there (because it's not text). The same behaviour can be observed in other browsers too. Perhaps NVDA should report the control if there is no character directly under the mouse, but it doesn't at this stage.

I think this behaviour without the cache occurs because of this code in HyperTextAccessible::OffsetAtPoint. If the point is smaller (both x and y) than the child's width/height, we assume we've found the right frame. We do call nsIFrame::GetContentOffsetsFromPointExternal to get the offset, but I'm guessing it must return 0 as well, though I haven't verified that. There does seem to be some fuzziness in layout when querying a point near the edge of a frame which might explain this.

This fuzziness is clearly biased to the top left. Otherwise, the point would always be larger than the width/height of all frames, so we'd keep searching.

The question is whether we want to emulate this bug with CTW. Doing that would mean that hit testing an icon that isn't in the a11y tree and is positioned to the left of text will report the text. Also, it will work around LinkedIn's awful pattern of hiding the visual text with ARIA and having a visually hidden alternative right next to it:

data:text/html,<a href="https://example.com/"><span aria-hidden="true">aria-hidden</span><span style="display: block; position: absolute; clip: rect(0 0 0 0); width: 1px; height: 1px; overflow: hidden;">visually-hidden</span></a>

If we are going to do this, we'll need to do it in HyperTextAccessibleBase. TextLeafPoint isn't inherently restricted to containers like HyperText is, so it's more difficult to fuzz in that case. Also, we should probably keep the TextLeafPoint API fairly clean and restrict the hacks to higher level callers. :)

Blocks: a11y-ctw-text, 1809082
No longer blocks: a11y-ctw
No longer depends on: 1809082

We should be able to implement this bug by replacing this block with something like this:

if (coords < point.CharBounds().TopLeft()) {
  // Appropriate comment about this horrible hack here
  return 0;
}

This perpetuates a bug in (local) HyperTextAccessible that some users have unfortunately come to rely on.

Assignee: nobody → jteh
Status: NEW → ASSIGNED
Pushed by jteh@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/95d948d14dfe HyperTextAccessibleBase::OffsetAtPoint: Return 0 if the point is within the container but before the rect at offset 0. r=nlapre
Pushed by jteh@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/fbb7ce70797d HyperTextAccessibleBase::OffsetAtPoint: Return 0 if the point is within the container but before the rect at offset 0. r=nlapre
Flags: needinfo?(jteh)
Status: ASSIGNED → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → 112 Branch
Whiteboard: [ctw-m5]

Comment on attachment 9317612 [details]
Bug 1816601: HyperTextAccessibleBase::OffsetAtPoint: Return 0 if the point is within the container but before the rect at offset 0.

Beta/Release Uplift Approval Request

  • User impact if declined: Screen readers won't report content under the mouse correctly in some cases when the accessibility cache is enabled via a release experiment.
  • Is this code covered by automated tests?: Yes
  • Has the fix been verified in Nightly?: Yes
  • Needs manual test from QE?: No
  • If yes, steps to reproduce:
  • List of other uplifts needed: None
  • Risk to taking this patch: Low
  • Why is the change risky/not risky? (and alternatives if risky): Covered by tests. Only impacts screen coordinates reported to accessibility clients when the accessibility cache is enabled.
  • String changes made/needed:
  • Is Android affected?: No
Attachment #9317612 - Flags: approval-mozilla-beta?

Comment on attachment 9317612 [details]
Bug 1816601: HyperTextAccessibleBase::OffsetAtPoint: Return 0 if the point is within the container but before the rect at offset 0.

Approved for 111.0b5

Attachment #9317612 - Flags: approval-mozilla-beta? → approval-mozilla-beta+
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: