Commit cd0d9861 authored by Dominic Mazzoni's avatar Dominic Mazzoni Committed by Commit Bot

Update an entire table when part of it changes.

Otherwise rows and cells aren't renumbered properly. We can possibly make
this more efficient in the future by only computing cell row and column
indexes downstream, but for now this is necessary.

Bug: 864012
Change-Id: I270481c78ee6e10bdf0140c5f4d221af3918c0fc
Reviewed-on: https://chromium-review.googlesource.com/1142392
Commit-Queue: Dominic Mazzoni <dmazzoni@chromium.org>
Reviewed-by: default avatarAlice Boxhall <aboxhall@chromium.org>
Cr-Commit-Position: refs/heads/master@{#576423}
parent 20ad9fdd
......@@ -557,6 +557,11 @@ IN_PROC_BROWSER_TEST_F(DumpAccessibilityTreeTest, AccessibilityAriaGrid) {
RunAriaTest(FILE_PATH_LITERAL("aria-grid.html"));
}
IN_PROC_BROWSER_TEST_F(DumpAccessibilityTreeTest,
AccessibilityAriaGridDynamicAddRow) {
RunAriaTest(FILE_PATH_LITERAL("aria-grid-dynamic-add-row.html"));
}
IN_PROC_BROWSER_TEST_F(DumpAccessibilityTreeTest,
AccessibilityAriaGridExtraWrapElems) {
RunAriaTest(FILE_PATH_LITERAL("aria-grid-extra-wrap-elems.html"));
......
......@@ -31,6 +31,7 @@
#include "ui/accessibility/ax_enum_util.h"
#include "ui/accessibility/ax_event.h"
#include "ui/accessibility/ax_node.h"
#include "ui/accessibility/ax_role_properties.h"
using blink::WebAXObject;
using blink::WebDocument;
......@@ -457,8 +458,20 @@ void RenderAccessibilityImpl::SendPendingAccessibilityEvents() {
block.AccessibilityIsIgnored())) {
block = block.ParentObject();
}
if (!block.IsDetached() && !block.Equals(obj)) {
if (!block.IsDetached() && !block.Equals(obj))
serializer_.DeleteClientSubtree(block);
// Whenever there's a change within a table, invalidate the
// whole table so that row and cell indexes are recomputed.
ax::mojom::Role role = AXRoleFromBlink(obj.Role());
if (ui::IsTableLikeRole(role) || role == ax::mojom::Role::kRow ||
ui::IsCellOrTableHeaderRole(role)) {
auto table = obj;
while (!table.IsDetached() &&
!ui::IsTableLikeRole(AXRoleFromBlink(table.Role())))
table = table.ParentObject();
if (!table.IsDetached())
serializer_.DeleteClientSubtree(table);
}
VLOG(1) << "Accessibility event: " << ui::ToString(event.event_type)
......
rootWebArea
++grid
++++row
++++++columnHeader name='Turtle' tableCellRowIndex=0
++++++columnHeader name='Weapon' tableCellRowIndex=0
++++row
++++++cell name='Donatello' tableCellRowIndex=1
++++++cell name='Bo' tableCellRowIndex=1
++++row
++++++cell name='Leonardo' tableCellRowIndex=2
++++++cell name='Twin Katana' tableCellRowIndex=2
++++row
++++++cell name='Michelangelo' tableCellRowIndex=3
++++++cell name='Nunchaku' tableCellRowIndex=3
++++row
++++++cell name='Raphael' tableCellRowIndex=4
++++++cell name='Sai' tableCellRowIndex=4
<!--
@BLINK-ALLOW:tableCellRowIndex*
@BLINK-DENY:*selected*
@WAIT-FOR:Leonardo
-->
<!DOCTYPE html>
<html>
<body>
<div role="grid">
<div role="row">
<span role="columnheader" aria-label="Turtle"></span>
<span role="columnheader" aria-label="Weapon"></span>
</div>
<div id="rowgroup" role="rowgroup">
<div role="row">
<span role="gridcell" aria-label="Donatello"></span>
<span role="gridcell" aria-label="Bo"></span>
</div>
<div role="row">
<span role="gridcell" aria-label="Michelangelo"></span>
<span role="gridcell" aria-label="Nunchaku"></span>
</div>
<div role="row">
<span role="gridcell" aria-label="Raphael"></span>
<span role="gridcell" aria-label="Sai"></span>
</div>
</div>
</div>
<script>
window.setTimeout(function() {
var row = document.createElement('div');
row.setAttribute('role', 'row');
row.innerHTML = '<span role="gridcell" aria-label="Leonardo"></span>' +
'<span role="gridcell" aria-label="Twin Katana"></span>';
var rowgroup = document.getElementById('rowgroup');
rowgroup.insertBefore(row,
rowgroup.firstElementChild.nextElementSibling);
}, 500);
</script>
</body>
</html>
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