Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 101 | 101 |
| 102 bool AXTableCell::isTableCell() const | 102 bool AXTableCell::isTableCell() const |
| 103 { | 103 { |
| 104 AXObject* parent = parentObjectUnignored(); | 104 AXObject* parent = parentObjectUnignored(); |
| 105 if (!parent || !parent->isTableRow()) | 105 if (!parent || !parent->isTableRow()) |
| 106 return false; | 106 return false; |
| 107 | 107 |
| 108 return true; | 108 return true; |
| 109 } | 109 } |
| 110 | 110 |
| 111 static AccessibilityRole decideRoleFromSibling(Node* siblingNode) | 111 static AccessibilityRole decideRoleFromSibling(LayoutTableCell* cell) |
|
dmazzoni
2015/03/16 15:12:16
I like naming the argument "sibling", so maybe sib
| |
| 112 { | 112 { |
| 113 if (!siblingNode) | 113 if (!cell) |
| 114 return CellRole; | 114 return CellRole; |
| 115 if (siblingNode->hasTagName(thTag)) | 115 |
| 116 return ColumnHeaderRole; | 116 if (Node* siblingNode = cell->node()) { |
|
dmazzoni
2015/03/16 15:12:16
I think you need extra parentheses otherwise some
| |
| 117 if (siblingNode->hasTagName(tdTag)) | 117 if (siblingNode->hasTagName(thTag)) |
| 118 return RowHeaderRole; | 118 return ColumnHeaderRole; |
| 119 if (siblingNode->hasTagName(tdTag)) | |
| 120 return RowHeaderRole; | |
| 121 } | |
| 122 | |
| 119 return CellRole; | 123 return CellRole; |
| 120 } | 124 } |
| 121 | 125 |
| 122 AccessibilityRole AXTableCell::scanToDecideHeaderRole() | 126 AccessibilityRole AXTableCell::scanToDecideHeaderRole() |
| 123 { | 127 { |
| 124 if (!isTableHeaderCell()) | 128 if (!isTableHeaderCell()) |
| 125 return CellRole; | 129 return CellRole; |
| 126 | 130 |
| 127 // Check scope attribute first. | 131 // Check scope attribute first. |
| 128 if (isRowHeaderCell()) | 132 if (isRowHeaderCell()) |
| 129 return RowHeaderRole; | 133 return RowHeaderRole; |
| 130 | 134 |
| 131 if (isColumnHeaderCell()) | 135 if (isColumnHeaderCell()) |
| 132 return ColumnHeaderRole; | 136 return ColumnHeaderRole; |
| 133 | 137 |
| 134 // Check the previous cell and the next cell on the same row. | 138 // Check the previous cell and the next cell on the same row. |
| 135 LayoutTableCell* layoutCell = toLayoutTableCell(m_layoutObject); | 139 LayoutTableCell* layoutCell = toLayoutTableCell(m_layoutObject); |
| 136 AccessibilityRole headerRole = CellRole; | 140 AccessibilityRole headerRole = CellRole; |
| 137 | 141 |
| 138 // if header is preceded by header cells on the same row, then it is a | 142 // if header is preceded by header cells on the same row, then it is a |
| 139 // column header. If it is preceded by other cells then it's a row header. | 143 // column header. If it is preceded by other cells then it's a row header. |
| 140 if (LayoutTableCell* cell = layoutCell->previousCell()) { | 144 if ((headerRole = decideRoleFromSibling(layoutCell->previousCell())) != Cell Role) |
| 141 Node* siblingNode = cell->node(); | 145 return headerRole; |
| 142 headerRole = decideRoleFromSibling(siblingNode); | 146 |
| 143 if (headerRole != CellRole) | |
| 144 return headerRole; | |
| 145 } | |
| 146 // if header is followed by header cells on the same row, then it is a | 147 // if header is followed by header cells on the same row, then it is a |
| 147 // column header. If it is followed by other cells then it's a row header. | 148 // column header. If it is followed by other cells then it's a row header. |
| 148 if (LayoutTableCell* cell = layoutCell->nextCell()) { | 149 if ((headerRole = decideRoleFromSibling(layoutCell->nextCell())) != CellRole ) |
| 149 Node* siblingNode = cell->node(); | 150 return headerRole; |
| 150 headerRole = decideRoleFromSibling(siblingNode); | 151 |
| 151 if (headerRole != CellRole) | |
| 152 return headerRole; | |
| 153 } | |
| 154 // If there are no other cells on that row, then it is a column header. | 152 // If there are no other cells on that row, then it is a column header. |
| 155 return ColumnHeaderRole; | 153 return ColumnHeaderRole; |
| 156 } | 154 } |
| 157 | 155 |
| 158 AccessibilityRole AXTableCell::determineAccessibilityRole() | 156 AccessibilityRole AXTableCell::determineAccessibilityRole() |
| 159 { | 157 { |
| 160 if (!isTableCell()) | 158 if (!isTableCell()) |
| 161 return AXLayoutObject::determineAccessibilityRole(); | 159 return AXLayoutObject::determineAccessibilityRole(); |
| 162 | 160 |
| 163 return scanToDecideHeaderRole(); | 161 return scanToDecideHeaderRole(); |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 251 return 0; | 249 return 0; |
| 252 | 250 |
| 253 Node* cellElement = headerCell->node(); | 251 Node* cellElement = headerCell->node(); |
| 254 if (!cellElement || !cellElement->hasTagName(thTag)) | 252 if (!cellElement || !cellElement->hasTagName(thTag)) |
| 255 return 0; | 253 return 0; |
| 256 | 254 |
| 257 return axObjectCache()->getOrCreate(headerCell); | 255 return axObjectCache()->getOrCreate(headerCell); |
| 258 } | 256 } |
| 259 | 257 |
| 260 } // namespace blink | 258 } // namespace blink |
| OLD | NEW |