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 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 | 175 |
176 // If there's only one cell, it's not a good AXTable candidate. | 176 // If there's only one cell, it's not a good AXTable candidate. |
177 if (numRows == 1 && numCols == 1) | 177 if (numRows == 1 && numCols == 1) |
178 return false; | 178 return false; |
179 | 179 |
180 // If there are at least 20 rows, we'll call it a data table. | 180 // If there are at least 20 rows, we'll call it a data table. |
181 if (numRows >= 20) | 181 if (numRows >= 20) |
182 return true; | 182 return true; |
183 | 183 |
184 // Store the background color of the table to check against cell's backgroun
d colors. | 184 // Store the background color of the table to check against cell's backgroun
d colors. |
185 const LayoutStyle* tableStyle = table->style(); | 185 const ComputedStyle* tableStyle = table->style(); |
186 if (!tableStyle) | 186 if (!tableStyle) |
187 return false; | 187 return false; |
188 Color tableBGColor = tableStyle->visitedDependentColor(CSSPropertyBackground
Color); | 188 Color tableBGColor = tableStyle->visitedDependentColor(CSSPropertyBackground
Color); |
189 | 189 |
190 // check enough of the cells to find if the table matches our criteria | 190 // check enough of the cells to find if the table matches our criteria |
191 // Criteria: | 191 // Criteria: |
192 // 1) must have at least one valid cell (and) | 192 // 1) must have at least one valid cell (and) |
193 // 2) at least half of cells have borders (or) | 193 // 2) at least half of cells have borders (or) |
194 // 3) at least half of cells have different bg colors than the table, and
there is cell spacing | 194 // 3) at least half of cells have different bg colors than the table, and
there is cell spacing |
195 unsigned validCellCount = 0; | 195 unsigned validCellCount = 0; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 headersInFirstColumnCount++; | 230 headersInFirstColumnCount++; |
231 | 231 |
232 // in this case, the developer explicitly assigned a "data" table at
tribute | 232 // in this case, the developer explicitly assigned a "data" table at
tribute |
233 if (isHTMLTableCellElement(*cellNode)) { | 233 if (isHTMLTableCellElement(*cellNode)) { |
234 HTMLTableCellElement& cellElement = toHTMLTableCellElement(*cell
Node); | 234 HTMLTableCellElement& cellElement = toHTMLTableCellElement(*cell
Node); |
235 if (!cellElement.headers().isEmpty() || !cellElement.abbr().isEm
pty() | 235 if (!cellElement.headers().isEmpty() || !cellElement.abbr().isEm
pty() |
236 || !cellElement.axis().isEmpty() || !cellElement.scope().isE
mpty()) | 236 || !cellElement.axis().isEmpty() || !cellElement.scope().isE
mpty()) |
237 return true; | 237 return true; |
238 } | 238 } |
239 | 239 |
240 const LayoutStyle* layoutStyle = cell->style(); | 240 const ComputedStyle* computedStyle = cell->style(); |
241 if (!layoutStyle) | 241 if (!computedStyle) |
242 continue; | 242 continue; |
243 | 243 |
244 // If the empty-cells style is set, we'll call it a data table. | 244 // If the empty-cells style is set, we'll call it a data table. |
245 if (layoutStyle->emptyCells() == HIDE) | 245 if (computedStyle->emptyCells() == HIDE) |
246 return true; | 246 return true; |
247 | 247 |
248 // If a cell has matching bordered sides, call it a (fully) bordered
cell. | 248 // If a cell has matching bordered sides, call it a (fully) bordered
cell. |
249 if ((cell->borderTop() > 0 && cell->borderBottom() > 0) | 249 if ((cell->borderTop() > 0 && cell->borderBottom() > 0) |
250 || (cell->borderLeft() > 0 && cell->borderRight() > 0)) | 250 || (cell->borderLeft() > 0 && cell->borderRight() > 0)) |
251 borderedCellCount++; | 251 borderedCellCount++; |
252 | 252 |
253 // Also keep track of each individual border, so we can catch tables
where most | 253 // Also keep track of each individual border, so we can catch tables
where most |
254 // cells have a bottom border, for example. | 254 // cells have a bottom border, for example. |
255 if (cell->borderTop() > 0) | 255 if (cell->borderTop() > 0) |
256 cellsWithTopBorder++; | 256 cellsWithTopBorder++; |
257 if (cell->borderBottom() > 0) | 257 if (cell->borderBottom() > 0) |
258 cellsWithBottomBorder++; | 258 cellsWithBottomBorder++; |
259 if (cell->borderLeft() > 0) | 259 if (cell->borderLeft() > 0) |
260 cellsWithLeftBorder++; | 260 cellsWithLeftBorder++; |
261 if (cell->borderRight() > 0) | 261 if (cell->borderRight() > 0) |
262 cellsWithRightBorder++; | 262 cellsWithRightBorder++; |
263 | 263 |
264 // If the cell has a different color from the table and there is cel
l spacing, | 264 // If the cell has a different color from the table and there is cel
l spacing, |
265 // then it is probably a data table cell (spacing and colors take th
e place of borders). | 265 // then it is probably a data table cell (spacing and colors take th
e place of borders). |
266 Color cellColor = layoutStyle->visitedDependentColor(CSSPropertyBack
groundColor); | 266 Color cellColor = computedStyle->visitedDependentColor(CSSPropertyBa
ckgroundColor); |
267 if (table->hBorderSpacing() > 0 && table->vBorderSpacing() > 0 | 267 if (table->hBorderSpacing() > 0 && table->vBorderSpacing() > 0 |
268 && tableBGColor != cellColor && cellColor.alpha() != 1) | 268 && tableBGColor != cellColor && cellColor.alpha() != 1) |
269 backgroundDifferenceCellCount++; | 269 backgroundDifferenceCellCount++; |
270 | 270 |
271 // If we've found 10 "good" cells, we don't need to keep searching. | 271 // If we've found 10 "good" cells, we don't need to keep searching. |
272 if (borderedCellCount >= 10 || backgroundDifferenceCellCount >= 10) | 272 if (borderedCellCount >= 10 || backgroundDifferenceCellCount >= 10) |
273 return true; | 273 return true; |
274 | 274 |
275 // For the first 5 rows, cache the background color so we can check
if this table has zebra-striped rows. | 275 // For the first 5 rows, cache the background color so we can check
if this table has zebra-striped rows. |
276 if (row < 5 && row == alternatingRowColorCount) { | 276 if (row < 5 && row == alternatingRowColorCount) { |
277 LayoutObject* layoutRow = cell->parent(); | 277 LayoutObject* layoutRow = cell->parent(); |
278 if (!layoutRow || !layoutRow->isBoxModelObject() || !toLayoutBox
ModelObject(layoutRow)->isTableRow()) | 278 if (!layoutRow || !layoutRow->isBoxModelObject() || !toLayoutBox
ModelObject(layoutRow)->isTableRow()) |
279 continue; | 279 continue; |
280 const LayoutStyle* rowLayoutStyle = layoutRow->style(); | 280 const ComputedStyle* rowComputedStyle = layoutRow->style(); |
281 if (!rowLayoutStyle) | 281 if (!rowComputedStyle) |
282 continue; | 282 continue; |
283 Color rowColor = rowLayoutStyle->visitedDependentColor(CSSProper
tyBackgroundColor); | 283 Color rowColor = rowComputedStyle->visitedDependentColor(CSSProp
ertyBackgroundColor); |
284 alternatingRowColors[alternatingRowColorCount] = rowColor; | 284 alternatingRowColors[alternatingRowColorCount] = rowColor; |
285 alternatingRowColorCount++; | 285 alternatingRowColorCount++; |
286 } | 286 } |
287 } | 287 } |
288 | 288 |
289 if (!row && headersInFirstRowCount == numCols && numCols > 1) | 289 if (!row && headersInFirstRowCount == numCols && numCols > 1) |
290 return true; | 290 return true; |
291 } | 291 } |
292 | 292 |
293 if (headersInFirstColumnCount == numRows && numRows > 1) | 293 if (headersInFirstColumnCount == numRows && numRows > 1) |
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
586 } | 586 } |
587 | 587 |
588 // try the standard | 588 // try the standard |
589 if (title.isEmpty()) | 589 if (title.isEmpty()) |
590 title = AXLayoutObject::title(mode); | 590 title = AXLayoutObject::title(mode); |
591 | 591 |
592 return title; | 592 return title; |
593 } | 593 } |
594 | 594 |
595 } // namespace blink | 595 } // namespace blink |
OLD | NEW |