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

Side by Side Diff: Source/modules/accessibility/AXTableCell.cpp

Issue 903833003: Return table headers from the table cell level. Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 10 months 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
« no previous file with comments | « Source/modules/accessibility/AXTableCell.h ('k') | Source/web/WebAXObject.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 13 matching lines...) Expand all
24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */ 27 */
28 28
29 #include "config.h" 29 #include "config.h"
30 #include "modules/accessibility/AXTableCell.h" 30 #include "modules/accessibility/AXTableCell.h"
31 31
32 #include "core/layout/LayoutTableCell.h" 32 #include "core/layout/LayoutTableCell.h"
33 #include "modules/accessibility/AXObjectCacheImpl.h" 33 #include "modules/accessibility/AXObjectCacheImpl.h"
34 34 #include "modules/accessibility/AXTable.h"
35 35
36 namespace blink { 36 namespace blink {
37 37
38 using namespace HTMLNames; 38 using namespace HTMLNames;
39 39
40 AXTableCell::AXTableCell(RenderObject* renderer, AXObjectCacheImpl* axObjectCach e) 40 AXTableCell::AXTableCell(RenderObject* renderer, AXObjectCacheImpl* axObjectCach e)
41 : AXRenderObject(renderer, axObjectCache) 41 : AXRenderObject(renderer, axObjectCache)
42 { 42 {
43 } 43 }
44 44
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 } 153 }
154 154
155 AccessibilityRole AXTableCell::determineAccessibilityRole() 155 AccessibilityRole AXTableCell::determineAccessibilityRole()
156 { 156 {
157 if (!isTableCell()) 157 if (!isTableCell())
158 return AXRenderObject::determineAccessibilityRole(); 158 return AXRenderObject::determineAccessibilityRole();
159 159
160 return scanToDecideHeaderRole(); 160 return scanToDecideHeaderRole();
161 } 161 }
162 162
163 void AXTableCell::rowHeadersForCell(AccessibilityChildrenVector& headers)
164 {
165 AXObject* parent = parentTable();
166 if (!parent || !parent->isAXTable())
167 return;
168
169 AXTable* parentTable = toAXTable(parent);
170
171 pair<unsigned, unsigned> rowRange;
172 rowIndexRange(rowRange);
173
174 pair<unsigned, unsigned> columnRange;
175 columnIndexRange(columnRange);
176
177 for (unsigned i = 0; i < columnRange.first; i++) {
178 AXTableCell* cell = parentTable->cellForColumnAndRow(i, rowRange.first);
179 if (!cell || !cell->isTableCell() || cell == this)
180 continue;
181 if (cell->scanToDecideHeaderRole() == RowHeaderRole)
182 headers.append(cell);
183 }
184 }
185
186 void AXTableCell::columnHeadersForCell(AccessibilityChildrenVector& headers)
187 {
188 AXObject* parent = parentTable();
189 if (!parent || !parent->isAXTable())
190 return;
191
192 AXTable* parentTable = toAXTable(parent);
193
194 pair<unsigned, unsigned> rowRange;
195 rowIndexRange(rowRange);
196
197 pair<unsigned, unsigned> columnRange;
198 columnIndexRange(columnRange);
199
200 for (unsigned i = 0; i < rowRange.first; i++) {
201 AXTableCell* cell = parentTable->cellForColumnAndRow(columnRange.first, i);
202 if (!cell || !cell->isTableCell() || headers.contains(cell) || cell == t his)
203 continue;
204 if (cell->scanToDecideHeaderRole() == ColumnHeaderRole)
205 headers.append(cell);
206 }
207 }
208
163 void AXTableCell::rowIndexRange(pair<unsigned, unsigned>& rowRange) 209 void AXTableCell::rowIndexRange(pair<unsigned, unsigned>& rowRange)
164 { 210 {
165 if (!m_renderer || !m_renderer->isTableCell()) 211 if (!m_renderer || !m_renderer->isTableCell())
166 return; 212 return;
167 213
168 LayoutTableCell* layoutCell = toLayoutTableCell(m_renderer); 214 LayoutTableCell* layoutCell = toLayoutTableCell(m_renderer);
169 rowRange.first = layoutCell->rowIndex(); 215 rowRange.first = layoutCell->rowIndex();
170 rowRange.second = layoutCell->rowSpan(); 216 rowRange.second = layoutCell->rowSpan();
171 217
172 // since our table might have multiple sections, we have to offset our row a ppropriately 218 // since our table might have multiple sections, we have to offset our row a ppropriately
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 return 0; 294 return 0;
249 295
250 Node* cellElement = headerCell->node(); 296 Node* cellElement = headerCell->node();
251 if (!cellElement || !cellElement->hasTagName(thTag)) 297 if (!cellElement || !cellElement->hasTagName(thTag))
252 return 0; 298 return 0;
253 299
254 return axObjectCache()->getOrCreate(headerCell); 300 return axObjectCache()->getOrCreate(headerCell);
255 } 301 }
256 302
257 } // namespace blink 303 } // namespace blink
OLDNEW
« no previous file with comments | « Source/modules/accessibility/AXTableCell.h ('k') | Source/web/WebAXObject.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698