OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 1997 Martin Jones (mjones@kde.org) | 2 * Copyright (C) 1997 Martin Jones (mjones@kde.org) |
3 * (C) 1997 Torben Weis (weis@kde.org) | 3 * (C) 1997 Torben Weis (weis@kde.org) |
4 * (C) 1998 Waldo Bastian (bastian@kde.org) | 4 * (C) 1998 Waldo Bastian (bastian@kde.org) |
5 * (C) 1999 Lars Knoll (knoll@kde.org) | 5 * (C) 1999 Lars Knoll (knoll@kde.org) |
6 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 6 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
7 * Copyright (C) 2003, 2004, 2005, 2006, 2008, 2009, 2010, 2013 Apple Inc. | 7 * Copyright (C) 2003, 2004, 2005, 2006, 2008, 2009, 2010, 2013 Apple Inc. |
8 * All rights reserved. | 8 * All rights reserved. |
9 * Copyright (C) 2006 Alexey Proskuryakov (ap@nypop.com) | 9 * Copyright (C) 2006 Alexey Proskuryakov (ap@nypop.com) |
10 * | 10 * |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
251 table()->effectiveColumns(); | 251 table()->effectiveColumns(); |
252 unsigned insertionRow = row->rowIndex(); | 252 unsigned insertionRow = row->rowIndex(); |
253 | 253 |
254 // ### mozilla still seems to do the old HTML way, even for strict DTD | 254 // ### mozilla still seems to do the old HTML way, even for strict DTD |
255 // (see the annotation on table cell layouting in the CSS specs and the | 255 // (see the annotation on table cell layouting in the CSS specs and the |
256 // testcase below: | 256 // testcase below: |
257 // <TABLE border> | 257 // <TABLE border> |
258 // <TR><TD>1 <TD rowspan="2">2 <TD>3 <TD>4 | 258 // <TR><TD>1 <TD rowspan="2">2 <TD>3 <TD>4 |
259 // <TR><TD colspan="2">5 | 259 // <TR><TD colspan="2">5 |
260 // </TABLE> | 260 // </TABLE> |
261 while (m_cCol < numCols(insertionRow) && | 261 unsigned nCols = numCols(insertionRow); |
262 (cellAt(insertionRow, m_cCol).hasCells() || | 262 while (m_cCol < nCols && (cellAt(insertionRow, m_cCol).hasCells() || |
263 cellAt(insertionRow, m_cCol).inColSpan)) | 263 cellAt(insertionRow, m_cCol).inColSpan)) |
264 m_cCol++; | 264 m_cCol++; |
265 | 265 |
266 updateLogicalHeightForCell(m_grid[insertionRow], cell); | 266 updateLogicalHeightForCell(m_grid[insertionRow], cell); |
267 | 267 |
268 ensureRows(insertionRow + rSpan); | 268 ensureRows(insertionRow + rSpan); |
269 | 269 |
270 m_grid[insertionRow].rowLayoutObject = row; | 270 m_grid[insertionRow].rowLayoutObject = row; |
271 | 271 |
272 unsigned col = m_cCol; | 272 unsigned col = m_cCol; |
273 // tell the cell where it is | 273 // tell the cell where it is |
274 bool inColSpan = false; | 274 bool inColSpan = false; |
| 275 unsigned colSize = columns.size(); |
275 while (cSpan) { | 276 while (cSpan) { |
276 unsigned currentSpan; | 277 unsigned currentSpan; |
277 if (m_cCol >= columns.size()) { | 278 if (m_cCol >= colSize) { |
278 table()->appendEffectiveColumn(cSpan); | 279 table()->appendEffectiveColumn(cSpan); |
279 currentSpan = cSpan; | 280 currentSpan = cSpan; |
280 } else { | 281 } else { |
281 if (cSpan < columns[m_cCol].span) | 282 if (cSpan < columns[m_cCol].span) |
282 table()->splitEffectiveColumn(m_cCol, cSpan); | 283 table()->splitEffectiveColumn(m_cCol, cSpan); |
283 currentSpan = columns[m_cCol].span; | 284 currentSpan = columns[m_cCol].span; |
284 } | 285 } |
285 for (unsigned r = 0; r < rSpan; r++) { | 286 for (unsigned r = 0; r < rSpan; r++) { |
286 ensureCols(insertionRow + r, m_cCol + 1); | 287 ensureCols(insertionRow + r, m_cCol + 1); |
287 CellStruct& c = cellAt(insertionRow + r, m_cCol); | 288 CellStruct& c = cellAt(insertionRow + r, m_cCol); |
(...skipping 857 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1145 } | 1146 } |
1146 rowLayoutObject->setLogicalHeight(rowLogicalHeight); | 1147 rowLayoutObject->setLogicalHeight(rowLogicalHeight); |
1147 rowLayoutObject->updateLayerTransformAfterLayout(); | 1148 rowLayoutObject->updateLayerTransformAfterLayout(); |
1148 } | 1149 } |
1149 } | 1150 } |
1150 | 1151 |
1151 // Vertically align and flex the cells in each row. | 1152 // Vertically align and flex the cells in each row. |
1152 for (unsigned r = 0; r < totalRows; r++) { | 1153 for (unsigned r = 0; r < totalRows; r++) { |
1153 LayoutTableRow* rowLayoutObject = m_grid[r].rowLayoutObject; | 1154 LayoutTableRow* rowLayoutObject = m_grid[r].rowLayoutObject; |
1154 | 1155 |
1155 for (unsigned c = 0; c < numCols(r); c++) { | 1156 unsigned nCols = numCols(r); |
| 1157 for (unsigned c = 0; c < nCols; c++) { |
1156 CellStruct& cs = cellAt(r, c); | 1158 CellStruct& cs = cellAt(r, c); |
1157 LayoutTableCell* cell = cs.primaryCell(); | 1159 LayoutTableCell* cell = cs.primaryCell(); |
1158 | 1160 |
1159 if (!cell || cs.inColSpan) | 1161 if (!cell || cs.inColSpan) |
1160 continue; | 1162 continue; |
1161 | 1163 |
1162 if (cell->rowIndex() != r) | 1164 if (cell->rowIndex() != r) |
1163 continue; // Rowspanned cells are handled in the first row they occur. | 1165 continue; // Rowspanned cells are handled in the first row they occur. |
1164 | 1166 |
1165 int rHeight; | 1167 int rHeight; |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1265 : gMaxAllowedOverflowingCellRatioForFastPaintPath * totalCellsCount; | 1267 : gMaxAllowedOverflowingCellRatioForFastPaintPath * totalCellsCount; |
1266 | 1268 |
1267 m_overflow.reset(); | 1269 m_overflow.reset(); |
1268 m_overflowingCells.clear(); | 1270 m_overflowingCells.clear(); |
1269 m_forceSlowPaintPathWithOverflowingCell = false; | 1271 m_forceSlowPaintPathWithOverflowingCell = false; |
1270 #if DCHECK_IS_ON() | 1272 #if DCHECK_IS_ON() |
1271 bool hasOverflowingCell = false; | 1273 bool hasOverflowingCell = false; |
1272 #endif | 1274 #endif |
1273 // Now that our height has been determined, add in overflow from cells. | 1275 // Now that our height has been determined, add in overflow from cells. |
1274 for (unsigned r = 0; r < totalRows; r++) { | 1276 for (unsigned r = 0; r < totalRows; r++) { |
1275 for (unsigned c = 0; c < numCols(r); c++) { | 1277 unsigned nCols = numCols(r); |
| 1278 for (unsigned c = 0; c < nCols; c++) { |
1276 CellStruct& cs = cellAt(r, c); | 1279 CellStruct& cs = cellAt(r, c); |
1277 LayoutTableCell* cell = cs.primaryCell(); | 1280 LayoutTableCell* cell = cs.primaryCell(); |
1278 if (!cell || cs.inColSpan) | 1281 if (!cell || cs.inColSpan) |
1279 continue; | 1282 continue; |
1280 if (r < totalRows - 1 && cell == primaryCellAt(r + 1, c)) | 1283 if (r < totalRows - 1 && cell == primaryCellAt(r + 1, c)) |
1281 continue; | 1284 continue; |
1282 addOverflowFromChild(cell); | 1285 addOverflowFromChild(cell); |
1283 #if DCHECK_IS_ON() | 1286 #if DCHECK_IS_ON() |
1284 hasOverflowingCell |= cell->hasVisualOverflow(); | 1287 hasOverflowingCell |= cell->hasVisualOverflow(); |
1285 #endif | 1288 #endif |
(...skipping 20 matching lines...) Expand all Loading... |
1306 clearChildNeedsOverflowRecalcAfterStyleChange(); | 1309 clearChildNeedsOverflowRecalcAfterStyleChange(); |
1307 unsigned totalRows = m_grid.size(); | 1310 unsigned totalRows = m_grid.size(); |
1308 bool childrenOverflowChanged = false; | 1311 bool childrenOverflowChanged = false; |
1309 for (unsigned r = 0; r < totalRows; r++) { | 1312 for (unsigned r = 0; r < totalRows; r++) { |
1310 LayoutTableRow* rowLayouter = rowLayoutObjectAt(r); | 1313 LayoutTableRow* rowLayouter = rowLayoutObjectAt(r); |
1311 if (!rowLayouter || | 1314 if (!rowLayouter || |
1312 !rowLayouter->childNeedsOverflowRecalcAfterStyleChange()) | 1315 !rowLayouter->childNeedsOverflowRecalcAfterStyleChange()) |
1313 continue; | 1316 continue; |
1314 rowLayouter->clearChildNeedsOverflowRecalcAfterStyleChange(); | 1317 rowLayouter->clearChildNeedsOverflowRecalcAfterStyleChange(); |
1315 bool rowChildrenOverflowChanged = false; | 1318 bool rowChildrenOverflowChanged = false; |
1316 for (unsigned c = 0; c < numCols(r); c++) { | 1319 unsigned nCols = numCols(r); |
| 1320 for (unsigned c = 0; c < nCols; c++) { |
1317 CellStruct& cs = cellAt(r, c); | 1321 CellStruct& cs = cellAt(r, c); |
1318 LayoutTableCell* cell = cs.primaryCell(); | 1322 LayoutTableCell* cell = cs.primaryCell(); |
1319 if (!cell || cs.inColSpan || !cell->needsOverflowRecalcAfterStyleChange()) | 1323 if (!cell || cs.inColSpan || !cell->needsOverflowRecalcAfterStyleChange()) |
1320 continue; | 1324 continue; |
1321 rowChildrenOverflowChanged |= cell->recalcOverflowAfterStyleChange(); | 1325 rowChildrenOverflowChanged |= cell->recalcOverflowAfterStyleChange(); |
1322 } | 1326 } |
1323 if (rowChildrenOverflowChanged) | 1327 if (rowChildrenOverflowChanged) |
1324 rowLayouter->computeOverflow(); | 1328 rowLayouter->computeOverflow(); |
1325 childrenOverflowChanged |= rowChildrenOverflowChanged; | 1329 childrenOverflowChanged |= rowChildrenOverflowChanged; |
1326 } | 1330 } |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1359 const BorderValue& rb = side == BorderBefore | 1363 const BorderValue& rb = side == BorderBefore |
1360 ? firstRow()->style()->borderBefore() | 1364 ? firstRow()->style()->borderBefore() |
1361 : lastRow()->style()->borderAfter(); | 1365 : lastRow()->style()->borderAfter(); |
1362 if (rb.style() == BorderStyleHidden) | 1366 if (rb.style() == BorderStyleHidden) |
1363 return -1; | 1367 return -1; |
1364 if (rb.style() > BorderStyleHidden && rb.width() > borderWidth) | 1368 if (rb.style() > BorderStyleHidden && rb.width() > borderWidth) |
1365 borderWidth = rb.width(); | 1369 borderWidth = rb.width(); |
1366 | 1370 |
1367 bool allHidden = true; | 1371 bool allHidden = true; |
1368 unsigned r = side == BorderBefore ? 0 : m_grid.size() - 1; | 1372 unsigned r = side == BorderBefore ? 0 : m_grid.size() - 1; |
1369 for (unsigned c = 0; c < numCols(r); c++) { | 1373 unsigned nCols = numCols(r); |
| 1374 for (unsigned c = 0; c < nCols; c++) { |
1370 const CellStruct& current = cellAt(r, c); | 1375 const CellStruct& current = cellAt(r, c); |
1371 if (current.inColSpan || !current.hasCells()) | 1376 if (current.inColSpan || !current.hasCells()) |
1372 continue; | 1377 continue; |
1373 const ComputedStyle& primaryCellStyle = current.primaryCell()->styleRef(); | 1378 const ComputedStyle& primaryCellStyle = current.primaryCell()->styleRef(); |
1374 // FIXME: Make this work with perpendicular and flipped cells. | 1379 // FIXME: Make this work with perpendicular and flipped cells. |
1375 const BorderValue& cb = side == BorderBefore | 1380 const BorderValue& cb = side == BorderBefore |
1376 ? primaryCellStyle.borderBefore() | 1381 ? primaryCellStyle.borderBefore() |
1377 : primaryCellStyle.borderAfter(); | 1382 : primaryCellStyle.borderAfter(); |
1378 // FIXME: Don't repeat for the same col group | 1383 // FIXME: Don't repeat for the same col group |
1379 LayoutTableCol* col = | 1384 LayoutTableCol* col = |
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1680 void LayoutTableSection::setNeedsCellRecalc() { | 1685 void LayoutTableSection::setNeedsCellRecalc() { |
1681 m_needsCellRecalc = true; | 1686 m_needsCellRecalc = true; |
1682 if (LayoutTable* t = table()) | 1687 if (LayoutTable* t = table()) |
1683 t->setNeedsSectionRecalc(); | 1688 t->setNeedsSectionRecalc(); |
1684 } | 1689 } |
1685 | 1690 |
1686 unsigned LayoutTableSection::numEffectiveColumns() const { | 1691 unsigned LayoutTableSection::numEffectiveColumns() const { |
1687 unsigned result = 0; | 1692 unsigned result = 0; |
1688 | 1693 |
1689 for (unsigned r = 0; r < m_grid.size(); ++r) { | 1694 for (unsigned r = 0; r < m_grid.size(); ++r) { |
1690 for (unsigned c = result; c < numCols(r); ++c) { | 1695 unsigned nCols = numCols(r); |
| 1696 for (unsigned c = result; c < nCols; ++c) { |
1691 const CellStruct& cell = cellAt(r, c); | 1697 const CellStruct& cell = cellAt(r, c); |
1692 if (cell.hasCells() || cell.inColSpan) | 1698 if (cell.hasCells() || cell.inColSpan) |
1693 result = c; | 1699 result = c; |
1694 } | 1700 } |
1695 } | 1701 } |
1696 | 1702 |
1697 return result + 1; | 1703 return result + 1; |
1698 } | 1704 } |
1699 | 1705 |
1700 const BorderValue& LayoutTableSection::borderAdjoiningStartCell( | 1706 const BorderValue& LayoutTableSection::borderAdjoiningStartCell( |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1798 LayoutRect hitTestRect = LayoutRect(locationInContainer.boundingBox()); | 1804 LayoutRect hitTestRect = LayoutRect(locationInContainer.boundingBox()); |
1799 hitTestRect.moveBy(-adjustedLocation); | 1805 hitTestRect.moveBy(-adjustedLocation); |
1800 | 1806 |
1801 LayoutRect tableAlignedRect = | 1807 LayoutRect tableAlignedRect = |
1802 logicalRectForWritingModeAndDirection(hitTestRect); | 1808 logicalRectForWritingModeAndDirection(hitTestRect); |
1803 CellSpan rowSpan = spannedRows(tableAlignedRect); | 1809 CellSpan rowSpan = spannedRows(tableAlignedRect); |
1804 CellSpan columnSpan = spannedEffectiveColumns(tableAlignedRect); | 1810 CellSpan columnSpan = spannedEffectiveColumns(tableAlignedRect); |
1805 | 1811 |
1806 // Now iterate over the spanned rows and columns. | 1812 // Now iterate over the spanned rows and columns. |
1807 for (unsigned hitRow = rowSpan.start(); hitRow < rowSpan.end(); ++hitRow) { | 1813 for (unsigned hitRow = rowSpan.start(); hitRow < rowSpan.end(); ++hitRow) { |
1808 for (unsigned hitColumn = columnSpan.start(); hitColumn < columnSpan.end(); | 1814 unsigned nCols = numCols(hitRow); |
1809 ++hitColumn) { | 1815 for (unsigned hitColumn = columnSpan.start(); |
1810 if (hitColumn >= numCols(hitRow)) | 1816 hitColumn < nCols && hitColumn < columnSpan.end(); ++hitColumn) { |
1811 break; | |
1812 | |
1813 CellStruct& current = cellAt(hitRow, hitColumn); | 1817 CellStruct& current = cellAt(hitRow, hitColumn); |
1814 | 1818 |
1815 // If the cell is empty, there's nothing to do | 1819 // If the cell is empty, there's nothing to do |
1816 if (!current.hasCells()) | 1820 if (!current.hasCells()) |
1817 continue; | 1821 continue; |
1818 | 1822 |
1819 for (unsigned i = current.cells.size(); i;) { | 1823 for (unsigned i = current.cells.size(); i;) { |
1820 --i; | 1824 --i; |
1821 LayoutTableCell* cell = current.cells[i]; | 1825 LayoutTableCell* cell = current.cells[i]; |
1822 LayoutPoint cellPoint = | 1826 LayoutPoint cellPoint = |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2071 // the header in all columns. | 2075 // the header in all columns. |
2072 // Note that this is in flow thread coordinates, not visual coordinates. The | 2076 // Note that this is in flow thread coordinates, not visual coordinates. The |
2073 // enclosing LayoutFlowThread will convert to visual coordinates. | 2077 // enclosing LayoutFlowThread will convert to visual coordinates. |
2074 if (table()->header() == this && isRepeatingHeaderGroup()) | 2078 if (table()->header() == this && isRepeatingHeaderGroup()) |
2075 rect.setHeight(table()->logicalHeight()); | 2079 rect.setHeight(table()->logicalHeight()); |
2076 return LayoutTableBoxComponent::mapToVisualRectInAncestorSpace(ancestor, rect, | 2080 return LayoutTableBoxComponent::mapToVisualRectInAncestorSpace(ancestor, rect, |
2077 flags); | 2081 flags); |
2078 } | 2082 } |
2079 | 2083 |
2080 } // namespace blink | 2084 } // namespace blink |
OLD | NEW |