Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(243)

Side by Side Diff: third_party/WebKit/Source/modules/accessibility/AXTableRow.cpp

Issue 2539503003: ARIA 1.1: implementation for aria-col-* and aria-row-*. (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2008 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 29 matching lines...) Expand all
40 AXObjectCacheImpl& axObjectCache) 40 AXObjectCacheImpl& axObjectCache)
41 : AXLayoutObject(layoutObject, axObjectCache) {} 41 : AXLayoutObject(layoutObject, axObjectCache) {}
42 42
43 AXTableRow::~AXTableRow() {} 43 AXTableRow::~AXTableRow() {}
44 44
45 AXTableRow* AXTableRow::create(LayoutObject* layoutObject, 45 AXTableRow* AXTableRow::create(LayoutObject* layoutObject,
46 AXObjectCacheImpl& axObjectCache) { 46 AXObjectCacheImpl& axObjectCache) {
47 return new AXTableRow(layoutObject, axObjectCache); 47 return new AXTableRow(layoutObject, axObjectCache);
48 } 48 }
49 49
50 AccessibilityRole AXTableRow::determineAccessibilityRole() { 50 void AXTableRow::addChildren()
51 {
52 AXLayoutObject::addChildren();
53 int colIndex = ariaColumnIndex();
aboxhall 2016/11/29 17:36:54 An explanation of what is going on here would be h
dmazzoni 2016/11/30 22:48:17 I added a comment to clarify. It's so you don't ne
54 if (!colIndex)
55 return;
56
57 unsigned index = 0;
58 for (const auto& cell : children()) {
59 if (cell->isTableCell())
60 toAXTableCell(cell.get())->setARIAColIndexFromRow(colIndex + index);
61 index++;
62 }
63 }
64
65 AccessibilityRole AXTableRow::determineAccessibilityRole()
66 {
51 if (!isTableRow()) 67 if (!isTableRow())
52 return AXLayoutObject::determineAccessibilityRole(); 68 return AXLayoutObject::determineAccessibilityRole();
aboxhall 2016/11/29 17:36:54 Formatting weirdness?
dmazzoni 2016/11/30 22:48:17 Done.
53 69
54 if ((m_ariaRole = determineAriaRoleAttribute()) != UnknownRole) 70 if ((m_ariaRole = determineAriaRoleAttribute()) != UnknownRole)
55 return m_ariaRole; 71 return m_ariaRole;
56 72
57 return RowRole; 73 return RowRole;
58 } 74 }
59 75
60 bool AXTableRow::isTableRow() const { 76 bool AXTableRow::isTableRow() const {
61 AXObject* table = parentTable(); 77 AXObject* table = parentTable();
62 if (!table || !table->isAXTable()) 78 if (!table || !table->isAXTable())
(...skipping 26 matching lines...) Expand all
89 105
90 AXObject* AXTableRow::headerObject() { 106 AXObject* AXTableRow::headerObject() {
91 AXObjectVector headers; 107 AXObjectVector headers;
92 headerObjectsForRow(headers); 108 headerObjectsForRow(headers);
93 if (!headers.size()) 109 if (!headers.size())
94 return 0; 110 return 0;
95 111
96 return headers[0].get(); 112 return headers[0].get();
97 } 113 }
98 114
115 unsigned AXTableRow::ariaColumnIndex() const
116 {
117 const AtomicString& colIndexValue = getAttribute(aria_colindexAttr);
118 if (colIndexValue.toInt() >= 1)
119 return colIndexValue.toInt();
120
121 return 0;
122 }
123
124 unsigned AXTableRow::ariaRowIndex() const
125 {
126 const AtomicString& rowIndexValue = getAttribute(aria_rowindexAttr);
127 if (rowIndexValue.toInt() >= 1)
128 return rowIndexValue.toInt();
129
130 return 0;
131 }
132
99 void AXTableRow::headerObjectsForRow(AXObjectVector& headers) { 133 void AXTableRow::headerObjectsForRow(AXObjectVector& headers) {
100 if (!m_layoutObject || !m_layoutObject->isTableRow()) 134 if (!m_layoutObject || !m_layoutObject->isTableRow())
101 return; 135 return;
102 136
103 for (const auto& cell : children()) { 137 for (const auto& cell : children()) {
104 if (!cell->isTableCell()) 138 if (!cell->isTableCell())
105 continue; 139 continue;
106 140
107 if (toAXTableCell(cell.get())->scanToDecideHeaderRole() == RowHeaderRole) 141 if (toAXTableCell(cell.get())->scanToDecideHeaderRole() == RowHeaderRole)
108 headers.append(cell); 142 headers.append(cell);
109 } 143 }
110 } 144 }
111 145
112 } // namespace blink 146 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698