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 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 if (Traversal<HTMLTableColElement>::firstChild(*tableElement)) | 157 if (Traversal<HTMLTableColElement>::firstChild(*tableElement)) |
158 return true; | 158 return true; |
159 | 159 |
160 // go through the cell's and check for tell-tale signs of "data" table status | 160 // go through the cell's and check for tell-tale signs of "data" table status |
161 // cells have borders, or use attributes like headers, abbr, scope or axis | 161 // cells have borders, or use attributes like headers, abbr, scope or axis |
162 table->recalcSectionsIfNeeded(); | 162 table->recalcSectionsIfNeeded(); |
163 LayoutTableSection* firstBody = table->firstBody(); | 163 LayoutTableSection* firstBody = table->firstBody(); |
164 if (!firstBody) | 164 if (!firstBody) |
165 return false; | 165 return false; |
166 | 166 |
167 int numCols = firstBody->numEffectiveColumns(); | 167 int numColsInFirstBody = firstBody->numEffectiveColumns(); |
168 int numRows = firstBody->numRows(); | 168 int numRows = firstBody->numRows(); |
169 | 169 |
170 // If there's only one cell, it's not a good AXTable candidate. | 170 // If there's only one cell, it's not a good AXTable candidate. |
171 if (numRows == 1 && numCols == 1) | 171 if (numRows == 1 && numColsInFirstBody == 1) |
172 return false; | 172 return false; |
173 | 173 |
174 // If there are at least 20 rows, we'll call it a data table. | 174 // If there are at least 20 rows, we'll call it a data table. |
175 if (numRows >= 20) | 175 if (numRows >= 20) |
176 return true; | 176 return true; |
177 | 177 |
178 // Store the background color of the table to check against cell's background | 178 // Store the background color of the table to check against cell's background |
179 // colors. | 179 // colors. |
180 const ComputedStyle* tableStyle = table->style(); | 180 const ComputedStyle* tableStyle = table->style(); |
181 if (!tableStyle) | 181 if (!tableStyle) |
(...skipping 14 matching lines...) Expand all Loading... |
196 unsigned cellsWithBottomBorder = 0; | 196 unsigned cellsWithBottomBorder = 0; |
197 unsigned cellsWithLeftBorder = 0; | 197 unsigned cellsWithLeftBorder = 0; |
198 unsigned cellsWithRightBorder = 0; | 198 unsigned cellsWithRightBorder = 0; |
199 | 199 |
200 Color alternatingRowColors[5]; | 200 Color alternatingRowColors[5]; |
201 int alternatingRowColorCount = 0; | 201 int alternatingRowColorCount = 0; |
202 | 202 |
203 int headersInFirstColumnCount = 0; | 203 int headersInFirstColumnCount = 0; |
204 for (int row = 0; row < numRows; ++row) { | 204 for (int row = 0; row < numRows; ++row) { |
205 int headersInFirstRowCount = 0; | 205 int headersInFirstRowCount = 0; |
206 for (int col = 0; col < numCols; ++col) { | 206 int nCols = firstBody->numCols(row); |
| 207 for (int col = 0; col < nCols; ++col) { |
207 LayoutTableCell* cell = firstBody->primaryCellAt(row, col); | 208 LayoutTableCell* cell = firstBody->primaryCellAt(row, col); |
208 if (!cell) | 209 if (!cell) |
209 continue; | 210 continue; |
210 Node* cellNode = cell->node(); | 211 Node* cellNode = cell->node(); |
211 if (!cellNode) | 212 if (!cellNode) |
212 continue; | 213 continue; |
213 | 214 |
214 if (cell->size().width() < 1 || cell->size().height() < 1) | 215 if (cell->size().width() < 1 || cell->size().height() < 1) |
215 continue; | 216 continue; |
216 | 217 |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
284 const ComputedStyle* rowComputedStyle = layoutRow->style(); | 285 const ComputedStyle* rowComputedStyle = layoutRow->style(); |
285 if (!rowComputedStyle) | 286 if (!rowComputedStyle) |
286 continue; | 287 continue; |
287 Color rowColor = | 288 Color rowColor = |
288 rowComputedStyle->visitedDependentColor(CSSPropertyBackgroundColor); | 289 rowComputedStyle->visitedDependentColor(CSSPropertyBackgroundColor); |
289 alternatingRowColors[alternatingRowColorCount] = rowColor; | 290 alternatingRowColors[alternatingRowColorCount] = rowColor; |
290 alternatingRowColorCount++; | 291 alternatingRowColorCount++; |
291 } | 292 } |
292 } | 293 } |
293 | 294 |
294 if (!row && headersInFirstRowCount == numCols && numCols > 1) | 295 if (!row && headersInFirstRowCount == numColsInFirstBody && |
| 296 numColsInFirstBody > 1) |
295 return true; | 297 return true; |
296 } | 298 } |
297 | 299 |
298 if (headersInFirstColumnCount == numRows && numRows > 1) | 300 if (headersInFirstColumnCount == numRows && numRows > 1) |
299 return true; | 301 return true; |
300 | 302 |
301 // if there is less than two valid cells, it's not a data table | 303 // if there is less than two valid cells, it's not a data table |
302 if (validCellCount <= 1) | 304 if (validCellCount <= 1) |
303 return false; | 305 return false; |
304 | 306 |
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
604 } | 606 } |
605 | 607 |
606 DEFINE_TRACE(AXTable) { | 608 DEFINE_TRACE(AXTable) { |
607 visitor->trace(m_rows); | 609 visitor->trace(m_rows); |
608 visitor->trace(m_columns); | 610 visitor->trace(m_columns); |
609 visitor->trace(m_headerContainer); | 611 visitor->trace(m_headerContainer); |
610 AXLayoutObject::trace(visitor); | 612 AXLayoutObject::trace(visitor); |
611 } | 613 } |
612 | 614 |
613 } // namespace blink | 615 } // namespace blink |
OLD | NEW |