Closed Bug 1776928 Opened 2 years ago Closed 2 years ago

[HCM] Avoid backplating whitespace?

Categories

(Core :: Layout, task)

task

Tracking

()

RESOLVED FIXED
106 Branch
Accessibility Severity s3
Tracking Status
firefox106 --- fixed

People

(Reporter: morgan, Assigned: nlapre)

Details

(Keywords: access)

Attachments

(2 files)

This is an issue with various google apps, and I'm not sure it's within our ability to fix but flagging here in case it is:

STR:

  1. Open a google sheet
  2. Enable HCM (about:preferences > manage colors > always)
  3. View the "share" button in the upper right corner of the sheet

Expected: The share icon and text is unobstructed
Actual: A rectangle partially obscures the button content

It looks like google is using a single space in the span that defines the share button, for some reason. And because it's technically text, we backplate it. Is there a way for us to not backplate content that is only whitespace without moving to a "backplate by word" model where we break on every space (which I don't think we should do)?

Attached image share button example

Probably around here we could maybe check nsTextFrame::IsEmpty or so?

Taking this to save it for a new hire starting in August

Assignee: nobody → mreschenberg
Assignee: mreschenberg → nlapre

Here's a minimal reproducer that doesn't require going through google apps (paste into the address bar to view):

data:text/html,<svg width="20" height="20"><circle cx="10" cy="10" r="10" fill="white" /></svg><span style="display:inline-block; position:relative; left:-10px;">&nbsp;</span>

Importantly, the google apps are using &nbsp; rather than a conventional space. This type of space just so happens to be excluded from the checks in nsTextFrame::IsEmpty (which relies on IsAllWhitespace, defined here). So, nsTextFrame::IsEmpty sees &nbsp; as non-whitespace. However, we don't even get that far in IsEmpty; instead, we end up failing the check here and returning false before even reaching the invocation of IsAllWhitespace. If you're curious, at the time of failure mState is

NS_FRAME_SIMPLE_DISPLAYLIST | NS_STATE_IS_HORIZONTAL | NS_STATE_MENU_HAS_POPUP_LIST | NS_STATE_BOX_WRAPS_KIDS_IN_BLOCK | NS_STATE_IS_DIRECTION_NORMAL | NS_STATE_FLEX_IS_EMULATING_LEGACY_BOX | TEXT_NO_RENDERED_GLYPHS

according to Visual Studio. It's unclear to me how that's failing, since the check is against TEXT_ISNOT_ONLY_WHITESPACE, but there you have it.

Morgan suggested looking at the text node sitting in the text frame's mContent and checking that whitespace manually, which works. I'm planning to push a changeset with that strategy for discussion soon.

Some sites use text content that consists entirely of whitespace, which can
lead to unexpected rendering in High Contrast Mode - namely, backplating of
invisible characters. This commit adds logic that detects text nodes consisting
entirely of whitespace and reports their text area as 0. This commit also adds
a test for the behavior, and modifies an existing test to reflect the new
behavior.

Pushed by nlapre@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/13ec2080e98a avoid backplating text that is entirely whitespace in HCM, r=morgan
Status: NEW → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → 106 Branch
Accessibility Severity: --- → s3
Whiteboard: [access-s3]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: