Skip to content

Report author-provided accessible labels in Chrome that are not visible elsewhere on the page#8352

Merged
michaelDCurran merged 4 commits into
masterfrom
i4773_withChrome
Jun 25, 2018
Merged

Report author-provided accessible labels in Chrome that are not visible elsewhere on the page#8352
michaelDCurran merged 4 commits into
masterfrom
i4773_withChrome

Conversation

@michaelDCurran

Copy link
Copy Markdown
Member

This is a follow-on from pr #7513. This was originally fixed for Firefox but not Chrome, as chrome did not yet implement the necessary APIs. Now it does, this standardizes the code to use a technique supported by both browsers.

Link to issue number:

Fixes #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 Chrome 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 Firefox and Chrome browsers by arrowing up and down the page with NVDA's screen layout mode off, using the document from
sr_only_labels.html.txt
Note: the needed functionality was introduced to Chrome in version 66.

Known issues with pull request:

This is now implemented for Firefox and Chrome, but
it is not supported in other browsers because:

  • 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 Google Chrome are now more readily reported in browse mode when the label does not appear as content itself. (#4773)

…_2::relationTargetsOfType rather than the custom navdirRelation constant (specific to Firefox), so that issue #4773 is also fixed for Chrome, not just Firefox.
@michaelDCurran michaelDCurran requested a review from feerrenrut June 1, 2018 04:50
IAccessible2* targetAcc;
CComQIPtr<IAccessible2_2> pacc2_2=pacc2;
if(!pacc2_2) return false;
IUnknown** ppUnk=NULL;

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.

Can you use nullptr here instead please.

res = target.pdispVal->QueryInterface(IID_IAccessible2, (void**)&targetAcc);
VariantClear(&target);
if (res != S_OK)
res=pacc2_2->get_relationTargetsOfType(IA2_RELATION_LABELLED_BY,1,&ppUnk,&nTargets);

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.

Might as well declare and initialise res on the one line. I.e. put HRESULT before the res

// 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, and not be just an empty string
const bool labelVisible = nameIsExplicit && name && name[0] //this node must actually have an explicit name, and not be just an empty string

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.

Do we care what character name[0] is? If it is required to be visible, do we need to test that it is not a "non-printable" character?

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 question is still valid, even though github has hidden it.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I believe what we have is correct, as if nameIsExplicit, then the author has provided some kind of accessible label, and if it contains anything (even a space) clearly they are wanting to inforce the content, E.g. overriding existing descendant content with a space.

// then ensure that the label is always reported along withe the node
// We must exclude tables from this though as table summaries / captions are handled very specifically
if(canDetectLabelVisibility&&nameIsExplicit&&!nameIsContent&&(role!=ROLE_SYSTEM_TABLE)&&!labelVisible) {
if(nameIsExplicit&&!nameIsContent&&(role!=ROLE_SYSTEM_TABLE)&&!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.

I understand this is consistent with the style of the rest of the file, however I would find this much easier to read with spaces around the boolean operators.

@@ -552,14 +558,13 @@ VBufStorage_fieldNode_t* GeckoVBufBackend_t::fillVBuf(IAccessible2* pacc,
|| role == ROLE_SYSTEM_BUTTONMENU
|| ((role == ROLE_SYSTEM_CHECKBUTTON || role == ROLE_SYSTEM_RADIOBUTTON) && !isLabelVisible(pacc));

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.

isLabelVisible() is called here and on line 563. I wonder if this is intentional, should the bool labelVisible which is created at line 561 be used instead?

michaelDCurran added a commit that referenced this pull request Jun 7, 2018
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.

Report label in browse mode if it isn't rendered anywhere else (e.g. aria-label)

3 participants