Skip to content

Gecko: Report label in browse mode if it isn't rendered anywhere else #7513

Merged
michaelDCurran merged 2 commits into
masterfrom
i4773
Sep 13, 2017
Merged

Gecko: Report label in browse mode if it isn't rendered anywhere else #7513
michaelDCurran merged 2 commits into
masterfrom
i4773

Conversation

@michaelDCurran

Copy link
Copy Markdown
Member

Link to issue number:

Partial fix for #4773

Summary of the issue:

Sometimes a web author will use aria-label on a node to convey screen-reader specific information, however the node also has useful and valid content itself (E.g. an edit field, or an iFrame).
NVDA already reports this label when moving to these controls with quick navigation or tabbing, but it should also report it when reading the control with the browse mode caret, as this label will not be rendered anywhere else.
Of course care must be taken to ensure this is in deed a label set by aria-label and not say a label from aria-labelledby or an associated html label tag. The one exception to this is if the associated label node is hidden from the screen.

Description of how this pull request fixes the issue:

In Firefox and other Mozilla Gecko products, we now convey to NVDA that these labels must always be reported, by exposing the 'alwaysReportName' attribute on these nodes from the vbufbackend.

Testing performed:

Tested browsers by arrowing up and down the page with NVDA's screen layout mode off, using the document from
sr_only_labels.html.txt

Known issues with pull request:

Note that it is not supported in other browsers because:

  • Chrome does not yet have a performant way of locating a node's label node (IAccessible2_2::RelationTargetsOfType should be implemented)
  • Edge has no means of asking a node if its name (label) has been explicitly set by the author
  • We are not expending any effort for Internet Explorer now, though PRs will be accepted from the community

Change log entry:

Bug fixes:
Accessible labels for controls in Mozilla Firefox are now more readily reported in browse mode when the label does not appear as content itself. (#4773)

…a node if the name was set explicitly, the name was not used for the content, and the name did not come from another visible label.

const bool isImgMap = role == ROLE_SYSTEM_GRAPHIC && childCount > 0;
// Whether the name of this node has been explicitly set (as opposed to calculated by descendant)
const bool nameIsExplicit = ((IA2AttribsMapIt = IA2AttribsMap.find(L"explicit-name")) != IA2AttribsMap.end() && IA2AttribsMapIt->second == L"true");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this would be clearer as two statements rather than nested parans. Eg:

IA2AttribsMapIt = IA2AttribsMap.find(L"explicit-name")
// Whether the name of this node has been explicitly set (as opposed to calculated by descendant)
const bool nameIsExplicit = IA2AttribsMapIt  != IA2AttribsMap.end() && IA2AttribsMapIt->second == L"true";

Also note that the outside parans are not necessary.

|| ((role == ROLE_SYSTEM_CHECKBUTTON || role == ROLE_SYSTEM_RADIOBUTTON) && !isLabelVisible(pacc));

|| role == ROLE_SYSTEM_LINK || role == ROLE_SYSTEM_PUSHBUTTON || role == IA2_ROLE_TOGGLE_BUTTON || role == ROLE_SYSTEM_MENUITEM || (role == ROLE_SYSTEM_GRAPHIC && !isImgMap) || (role == ROLE_SYSTEM_TEXT && !isEditable) || role == IA2_ROLE_HEADING || role == ROLE_SYSTEM_PAGETAB || role == ROLE_SYSTEM_BUTTONMENU;
// || ((role == ROLE_SYSTEM_CHECKBUTTON || role == ROLE_SYSTEM_RADIOBUTTON) && !labelVisible);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be commented out?

|| role == ROLE_SYSTEM_LINK || role == ROLE_SYSTEM_PUSHBUTTON || role == IA2_ROLE_TOGGLE_BUTTON || role == ROLE_SYSTEM_MENUITEM || (role == ROLE_SYSTEM_GRAPHIC && !isImgMap) || (role == ROLE_SYSTEM_TEXT && !isEditable) || role == IA2_ROLE_HEADING || role == ROLE_SYSTEM_PAGETAB || role == ROLE_SYSTEM_BUTTONMENU
|| ((role == ROLE_SYSTEM_CHECKBUTTON || role == ROLE_SYSTEM_RADIOBUTTON) && !isLabelVisible(pacc));

|| role == ROLE_SYSTEM_LINK || role == ROLE_SYSTEM_PUSHBUTTON || role == IA2_ROLE_TOGGLE_BUTTON || role == ROLE_SYSTEM_MENUITEM || (role == ROLE_SYSTEM_GRAPHIC && !isImgMap) || (role == ROLE_SYSTEM_TEXT && !isEditable) || role == IA2_ROLE_HEADING || role == ROLE_SYSTEM_PAGETAB || role == ROLE_SYSTEM_BUTTONMENU;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

my preference would be to put each of these or conditions onto their own line. This line is quite long at the moment!

// || ((role == ROLE_SYSTEM_CHECKBUTTON || role == ROLE_SYSTEM_RADIOBUTTON) && !labelVisible);
// Whether this node has a visible label somewhere else in the tree
const bool labelVisible = canDetectLabelVisibility // Not all browsers support getting a node's labelledBy node
&&nameIsExplicit&&name&&name[0] //this node must actually have an explicit name

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you put some spaces in here?
Why name[0]? I assume the intent is to check that this is not a zero length string? If so, could you make it clearer that that is the intent of this. It would be handy if there was a isNullOrEmpty function for BSTR*

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants