| 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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 | 84 |
| 85 bool AXTableCell::isTableCell() const | 85 bool AXTableCell::isTableCell() const |
| 86 { | 86 { |
| 87 AXObject* parent = parentObjectUnignored(); | 87 AXObject* parent = parentObjectUnignored(); |
| 88 if (!parent || !parent->isTableRow()) | 88 if (!parent || !parent->isTableRow()) |
| 89 return false; | 89 return false; |
| 90 | 90 |
| 91 return true; | 91 return true; |
| 92 } | 92 } |
| 93 | 93 |
| 94 static AccessibilityRole decideRoleFromSibling(Node* siblingNode) |
| 95 { |
| 96 if (!siblingNode) |
| 97 return CellRole; |
| 98 if (siblingNode->hasTagName(thTag)) |
| 99 return ColumnHeaderRole; |
| 100 if (siblingNode->hasTagName(tdTag)) |
| 101 return RowHeaderRole; |
| 102 return CellRole; |
| 103 } |
| 104 |
| 105 AccessibilityRole AXTableCell::scanToDecideHeaderRole() |
| 106 { |
| 107 Node* node = m_renderer ? m_renderer->node() : 0; |
| 108 if (!node || !node->hasTagName(thTag)) |
| 109 return CellRole; |
| 110 |
| 111 // Check scope attribute first. |
| 112 const AtomicString& scope = getAttribute(scopeAttr); |
| 113 if (equalIgnoringCase(scope, "row")) |
| 114 return RowHeaderRole; |
| 115 if (equalIgnoringCase(scope, "col")) |
| 116 return ColumnHeaderRole; |
| 117 |
| 118 // Check the previous cell and the next cell |
| 119 RenderTableCell* renderCell = toRenderTableCell(m_renderer); |
| 120 AccessibilityRole headerRole = CellRole; |
| 121 |
| 122 // if header is preceded by header cells then it's a column header, |
| 123 // if it is preceded by cells then it's a row header. |
| 124 if (RenderTableCell* cell = renderCell->previousCell()) { |
| 125 Node* siblingNode = cell->node(); |
| 126 headerRole = decideRoleFromSibling(siblingNode); |
| 127 if (headerRole != CellRole) |
| 128 return headerRole; |
| 129 } |
| 130 // if header is followed by header cells then it's a column header, |
| 131 // if it is followed by cells then it's a row header. |
| 132 if (RenderTableCell* cell = renderCell->nextCell()) { |
| 133 Node* siblingNode = cell->node(); |
| 134 headerRole = decideRoleFromSibling(siblingNode); |
| 135 } |
| 136 return headerRole; |
| 137 } |
| 138 |
| 94 AccessibilityRole AXTableCell::determineAccessibilityRole() | 139 AccessibilityRole AXTableCell::determineAccessibilityRole() |
| 95 { | 140 { |
| 96 if (!isTableCell()) | 141 if (!isTableCell()) |
| 97 return AXRenderObject::determineAccessibilityRole(); | 142 return AXRenderObject::determineAccessibilityRole(); |
| 98 | 143 |
| 99 return CellRole; | 144 return scanToDecideHeaderRole(); |
| 100 } | 145 } |
| 101 | 146 |
| 102 void AXTableCell::rowIndexRange(pair<unsigned, unsigned>& rowRange) | 147 void AXTableCell::rowIndexRange(pair<unsigned, unsigned>& rowRange) |
| 103 { | 148 { |
| 104 if (!m_renderer || !m_renderer->isTableCell()) | 149 if (!m_renderer || !m_renderer->isTableCell()) |
| 105 return; | 150 return; |
| 106 | 151 |
| 107 RenderTableCell* renderCell = toRenderTableCell(m_renderer); | 152 RenderTableCell* renderCell = toRenderTableCell(m_renderer); |
| 108 rowRange.first = renderCell->rowIndex(); | 153 rowRange.first = renderCell->rowIndex(); |
| 109 rowRange.second = renderCell->rowSpan(); | 154 rowRange.second = renderCell->rowSpan(); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 return 0; | 213 return 0; |
| 169 | 214 |
| 170 Node* cellElement = headerCell->node(); | 215 Node* cellElement = headerCell->node(); |
| 171 if (!cellElement || !cellElement->hasTagName(thTag)) | 216 if (!cellElement || !cellElement->hasTagName(thTag)) |
| 172 return 0; | 217 return 0; |
| 173 | 218 |
| 174 return axObjectCache()->getOrCreate(headerCell); | 219 return axObjectCache()->getOrCreate(headerCell); |
| 175 } | 220 } |
| 176 | 221 |
| 177 } // namespace blink | 222 } // namespace blink |
| OLD | NEW |