Commit c7caba01 authored by Aaron Leventhal's avatar Aaron Leventhal Committed by Commit Bot

Expose some tables with CSS display rules as data tables

For <table style="display:foo">, do not immediately assume it is
for layout, just because there is no table layout interface.

A follow-up CL will transform IsDataTable() to rely much more on
DOM interfaces, rather than layout interfaces.

Bug: 1011067

Change-Id: Iebb6224d311f09b1b3bf6e6aa08efbe7393b42d2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2079267
Auto-Submit: Aaron Leventhal <aleventhal@chromium.org>
Reviewed-by: default avatarDominic Mazzoni <dmazzoni@chromium.org>
Commit-Queue: Aaron Leventhal <aleventhal@chromium.org>
Cr-Commit-Position: refs/heads/master@{#746392}
parent e4b2ee78
......@@ -288,6 +288,11 @@ IN_PROC_BROWSER_TEST_P(DumpAccessibilityTreeTest,
RunCSSTest(FILE_PATH_LITERAL("table-display-other.html"));
}
IN_PROC_BROWSER_TEST_P(DumpAccessibilityTreeTest,
AccessibilityCSSDataTableDisplayOther) {
RunCSSTest(FILE_PATH_LITERAL("table-data-display-other.html"));
}
IN_PROC_BROWSER_TEST_P(DumpAccessibilityTreeTest, AccessibilityCSSTransform) {
RunCSSTest(FILE_PATH_LITERAL("transform.html"));
}
......
rootWebArea
++genericContainer ignored
++++table tableRowCount=2 tableColumnCount=3
++++++rowGroup ignored
++++++++row tableRowIndex=0
++++++++++columnHeader name='1' tableCellColumnIndex=0 tableCellRowIndex=0
++++++++++++staticText name='1'
++++++++++++++inlineTextBox name='1'
++++++++++columnHeader name='2' tableCellColumnIndex=1 tableCellRowIndex=0
++++++++++++staticText name='2'
++++++++++++++inlineTextBox name='2'
++++++++++columnHeader name='3' tableCellColumnIndex=2 tableCellRowIndex=0
++++++++++++staticText name='3'
++++++++++++++inlineTextBox name='3'
++++++rowGroup ignored
++++++++row tableRowIndex=1
++++++++++cell name='a' tableCellColumnIndex=0 tableCellRowIndex=1
++++++++++++staticText name='a'
++++++++++++++inlineTextBox name='a'
++++++++++cell name='b' tableCellColumnIndex=1 tableCellRowIndex=1
++++++++++++staticText name='b'
++++++++++++++inlineTextBox name='b'
++++++++++cell name='c' tableCellColumnIndex=2 tableCellRowIndex=1
++++++++++++staticText name='c'
++++++++++++++inlineTextBox name='c'
<!--
@BLINK-ALLOW:tableColumnCount*
@BLINK-ALLOW:tableRowCount*
@BLINK-ALLOW:table*Index*
-->
<!-- Ensure that a table with display styles and other semantic table markup
is still exposed as a data table.. -->
<style>
table, thead, tbody, tr, td { display: flex; }
</style>
<table>
<thead>
<tr>
<th>1</th>
<th>2</th>
<th>3</th>
</tr>
</thead>
<tbody>
<tr>
<td>a</td>
<td>b</td>
<td>c</td>
</tr>
</tbody>
</table>
......@@ -2436,27 +2436,17 @@ bool AXLayoutObject::IsDataTable() const {
if (HasAOMPropertyOrARIAAttribute(AOMStringProperty::kRole, role))
return true;
if (!layout_object_->IsTable())
return false;
// When a section of the document is contentEditable, all tables should be
// treated as data tables, otherwise users may not be able to work with rich
// text editors that allow creating and editing tables.
if (GetNode() && HasEditableStyle(*GetNode()))
return true;
// If there's no node, it's definitely a layout table. This happens
// when table CSS styles are used without a complete table DOM structure.
LayoutNGTableInterface* table =
ToInterface<LayoutNGTableInterface>(layout_object_);
table->RecalcSectionsIfNeeded();
Node* table_node = layout_object_->GetNode();
// This employs a heuristic to determine if this table should appear.
// Only "data" tables should be exposed as tables.
// Unfortunately, there is no good way to determine the difference
// between a "layout" table and a "data" table.
auto* table_element = DynamicTo<HTMLTableElement>(table_node);
auto* table_element = DynamicTo<HTMLTableElement>(GetNode());
if (!table_element)
return false;
......@@ -2474,6 +2464,23 @@ bool AXLayoutObject::IsDataTable() const {
if (Traversal<HTMLTableColElement>::FirstChild(*table_element))
return true;
// Everything from here forward uses cell style info, but only if a CSS table.
// If this code is reached for a <table> with another display type, consider
// this to be a layout table.
// TODO(accessibility) consider rewriting the following cell inspection code
// using purely DOM methods, such as table->rows()->Item(index)->cells().
if (!layout_object_->IsTable())
return false;
// If there's no node, it's definitely a layout table. This happens
// when table CSS styles are used without a complete table DOM structure.
LayoutNGTableInterface* table =
ToInterface<LayoutNGTableInterface>(layout_object_);
table->RecalcSectionsIfNeeded();
Node* table_node = layout_object_->GetNode();
if (!table_node)
return false;
// go through the cell's and check for tell-tale signs of "data" table status
// cells have borders, or use attributes like headers, abbr, scope or axis
table->RecalcSectionsIfNeeded();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment