Closed Bug 1522383 Opened 10 months ago Closed 3 months ago

Name not calculated from contents for <td> beneath role="grid"


(Core :: Disability Access APIs, defect, P2)




Tracking Status
firefox70 --- verified


(Reporter: Jamie, Assigned: mislam)


(Blocks 1 open bug)


(Whiteboard: [lang=c++])


(1 file)


  1. Open this test case: data:text/html,<table role="grid"><tr><td>foo</td></tr></table>
  2. Right click on the cell and select Inspect Accessibility Properties.
  3. Check the name.
    Expected: "foo"
    Actual: null

If you put role="gridcell" on the td, it works as expected, since gridcell supports name from contents. However, the HTML AAM spec says that a td with an ancestor table with role="grid" should be mapped to ARIA role gridcell:
That means the gridcell rules apply here; i.e. that we should do name from contents.

Note that td in a table role="table" maps to role="cell" and the spec requires name from contents for role "cell" as well:
That means we need the same thing for role="table".

Interestingly, we're failing to do name from contents even if you explicitly specify role="cell" on the td.

It may be worth considering just always doing name from contents for td elements. Chrome does this already. It makes some sense: why do name from contents for role="cell" but not for td? It'd also be a lot simpler to implement, since we can just tweak the Gecko cell role, rather than special casing for ARIA tables and grids.

This was reported by the JAWS vendor. It shows up in a W3C example here:

The CELL role needs to be changed so that it uses eNameFromSubtreeRule instead of eNameFromSubtreeIfReqRule:

Mentor: jteh
Whiteboard: [lang=c++]

Based on bug 1568360 (tr elements getting excessively long names in the case of layout tables), I don't think we want to tweak the Gecko CELL role as I originally suggested. However, some spec discussion in that bug raises an interesting question:
Should the tr and td elements here get a name calculated for them? Yes, they have an ancestor with role="grid". However, as discussed in bug 1568360 comment 5, the spec states:

5.12.1 tr, td, th Elements Accessible Name Computation

  1. If the table element has an aria-label or an aria-labelledby attribute the accessible name is to be calculated using the algorithm defined in Accessible Name and Description: Computation and API Mappings 1.1.
  2. Otherwise use the title attribute.
  3. If none of the above yield a usable text string there is no accessible name.

So which name computation requirements take precedence here: the td rule above or the implicit gridcell role? in bug 1568360, we went with the td rule. But to make the W3C example referenced in comment 1 work, we'd have to take the implicit gridcell role rule.

Scott, can you shed any light on this?

Removing mentor until we clear this up.

Mentor: jteh
Flags: needinfo?(scottaohara)

Hey there.

So two things here.

  1. I still need to revise 5.12.1 to separate out tr from td/th. Hopefully will get that done sooner than later.
  2. For this particular issue/example, because the table role has been changed to a grid, the TDs should implicitly be gridcells, so rules for that role would apply instead of the default HTML element expectations.

Hoping that helps clarify.

Flags: needinfo?(scottaohara)

Let's just deal with the implicit gridcell case here.

ARIA gridcell gets mapped to Gecko role GRID_CELL, which calculates name from subtree. However, we don't have logic to map the implicit gridcell case.

This can probably be done in Accessible::ARIATransformRole. If the role is CELL, get the table (Accessible::AsTableCell, TableCellAccessible::Table). If the table has ARIA role grid (Accessible::IsARIARole), return GRID_CELL.
Add test in accessible/tests/mochitest/role/test_aria.html.

Assignee: nobody → mislam

For this piece of code:

<div id="crazy_grid2" role="grid">
    <table role="presentation">
      <tr role="row">
        <td id="ct_cell1">cell1</td>
        <td role="gridcell">cell2</td>

should ct_cell1 have an implicit gridcell role?

Flags: needinfo?(jteh)

Eek. That's tricky. I can't see anything in the spec which suggests it should. On the other hand, intuitively, it makes sense that it does. I don't think that behaviour violates the spec at least, so I'd probably just update the test.

Flags: needinfo?(jteh)
Pushed by
Assign gridcell role to cells inside a table with grid role, r=Jamie
Closed: 3 months ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla70
Flags: qe-verify+

Reproduced the issue with Firefox 66.0a1 (20190123165704) on Windows 10x64. The issue is verified with Firefox 70.0b9 (20190923154733) on Windows 10x64.

Flags: qe-verify+
You need to log in before you can comment on or make changes to this bug.