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

Propagate aria-readonly value to grid cells

Bug: 748247
Change-Id: I7e3a45368e71e1b3cb038b16ec6639af13a1370c
Reviewed-on: https://chromium-review.googlesource.com/596771
Commit-Queue: Aaron Leventhal <aleventhal@chromium.org>
Reviewed-by: default avatarDominic Mazzoni <dmazzoni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#491608}
parent 4308d4c6
<!DOCTYPE HTML>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
<div role="grid" id="grid-readonly-undefined">
<div role="row">
<div id="cell-undef-undef" role="gridcell">X</div>
<div id="cell-undef-true" role="gridcell" aria-readonly="true">X</div>
<div id="cell-undef-false" role="gridcell" aria-readonly="false">X</div>
</div>
</div>
<div role="grid" id="grid-readonly-true" aria-readonly="true">
<div role="row">
<div id="cell-true-undef" role="gridcell">X</div>
<div id="cell-true-false" role="gridcell" aria-readonly="false">X</div>
</div>
</div>
<div role="grid" id="grid-readonly-false" aria-readonly="false">
<div role="row">
<div id="cell-false-undef" role="gridcell">X</div>
<div id="cell-false-true" role="gridcell" aria-readonly="true">X</div>
</div>
</div>
<div role="treegrid" id="treegrid-readonly-true" aria-readonly="true">
<div role="row">
<div id="treegrid-cell-true-undef" role="gridcell">X</div>
</div>
</div>
<script>
function axElementById(id) {
return accessibilityController.accessibleElementById(id);
}
test(function(t) {
var cell = axElementById("cell-undef-undef");
assert_equals(cell.restriction, "none");
}, "readonly=false on cell where readonly is undefined on grid+cell");
test(function(t) {
var cell = axElementById("cell-undef-true");
assert_equals(cell.restriction, "readOnly");
}, "readonly=true on a cell");
test(function(t) {
var cell = axElementById("cell-undef-false");
assert_equals(cell.restriction, "none");
}, "readonly=false on a cell");
test(function(t) {
var cell = axElementById("cell-true-undef");
assert_equals(cell.restriction, "readOnly");
}, "Propagation of readonly=true from grid to cells");
test(function(t) {
var cell = axElementById("cell-true-false");
assert_equals(cell.restriction, "none");
}, "Cell readonly=false overrides propagation of grid readonly=true");
test(function(t) {
var cell = axElementById("cell-false-undef");
assert_equals(cell.restriction, "none");
}, "Propagation of readonly=false from grid to cells");
test(function(t) {
var cell = axElementById("cell-false-true");
assert_equals(cell.restriction, "readOnly");
}, "Cell readonly=true overrides propagation of grid readonly=false");
test(function(t) {
var cell = axElementById("treegrid-cell-true-undef");
assert_equals(cell.restriction, "readOnly");
}, "Propagation of readonly=true in a readonly treegrid");
</script>
......@@ -134,4 +134,22 @@ AccessibilityRole AXARIAGridCell::ScanToDecideHeaderRole() {
return kCellRole;
}
AXRestriction AXARIAGridCell::Restriction() const {
const AXRestriction cell_restriction = AXLayoutObject::Restriction();
// Specified gridcell restriction or local ARIA markup takes precedence.
if (cell_restriction != kNone || HasAttribute(HTMLNames::aria_readonlyAttr) ||
HasAttribute(HTMLNames::aria_disabledAttr))
return cell_restriction;
// Gridcell does not have it's own ARIA input restriction, so
// fall back on parent grid's readonly state.
// See ARIA specification regarding grid/treegrid and readonly.
const AXObject* container = ParentTable();
const bool is_in_readonly_grid = container &&
(container->RoleValue() == kGridRole ||
container->RoleValue() == kTreeGridRole) &&
container->Restriction() == kReadOnly;
return is_in_readonly_grid ? kReadOnly : kNone;
}
} // namespace blink
......@@ -50,6 +50,7 @@ class AXARIAGridCell final : public AXTableCell {
// fills in the start location and column span of cell
void ColumnIndexRange(std::pair<unsigned, unsigned>& column_range) override;
AccessibilityRole ScanToDecideHeaderRole() final;
AXRestriction Restriction() const final;
bool CanSetSelectedAttribute() const final {
return Restriction() != kDisabled;
}
......
......@@ -1306,6 +1306,7 @@ bool AXNodeObject::CanSupportAriaReadOnly() const {
case kCellRole:
case kCheckBoxRole:
case kColorWellRole:
case kColumnHeaderRole:
case kComboBoxRole:
case kDateRole:
case kDateTimeRole:
......@@ -1317,12 +1318,14 @@ bool AXNodeObject::CanSupportAriaReadOnly() const {
case kMenuItemRadioRole:
case kPopUpButtonRole:
case kRadioGroupRole:
case kRowHeaderRole:
case kSearchBoxRole:
case kSliderRole:
case kSpinButtonRole:
case kSwitchRole:
case kTextFieldRole:
case kToggleButtonRole:
case kTreeGridRole:
return true;
default:
break;
......
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