Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "core/paint/TableSectionPainter.h" | 5 #include "core/paint/TableSectionPainter.h" |
| 6 | 6 |
| 7 #include "core/layout/LayoutTableCell.h" | 7 #include "core/layout/LayoutTableCell.h" |
| 8 #include "core/layout/LayoutTableCol.h" | 8 #include "core/layout/LayoutTableCol.h" |
| 9 #include "core/layout/LayoutTableRow.h" | 9 #include "core/layout/LayoutTableRow.h" |
| 10 #include "core/paint/BoxClipper.h" | 10 #include "core/paint/BoxClipper.h" |
| 11 #include "core/paint/BoxPainter.h" | 11 #include "core/paint/BoxPainter.h" |
| 12 #include "core/paint/LayoutObjectDrawingRecorder.h" | 12 #include "core/paint/LayoutObjectDrawingRecorder.h" |
| 13 #include "core/paint/ObjectPainter.h" | 13 #include "core/paint/ObjectPainter.h" |
| 14 #include "core/paint/PaintInfo.h" | 14 #include "core/paint/PaintInfo.h" |
| 15 #include "core/paint/TableCellPainter.h" | 15 #include "core/paint/TableCellPainter.h" |
| 16 #include "core/paint/TableRowPainter.h" | 16 #include "core/paint/TableRowPainter.h" |
| 17 #include <algorithm> | 17 #include <algorithm> |
| 18 | 18 |
| 19 namespace blink { | 19 namespace blink { |
| 20 | 20 |
| 21 inline const LayoutTableCell* TableSectionPainter::primaryCellToPaint( | 21 inline const LayoutTableCell* TableSectionPainter::primaryCellToPaint( |
| 22 unsigned row, | 22 unsigned row, |
| 23 unsigned column, | 23 unsigned column, |
| 24 const CellSpan& dirtiedRows, | 24 const CellSpan& dirtiedRows, |
| 25 const CellSpan& dirtiedColumns) const { | 25 const CellSpan& dirtiedColumns) const { |
| 26 DCHECK(row >= dirtiedRows.start() && row < dirtiedRows.end()); | 26 DCHECK(row >= dirtiedRows.start() && row < dirtiedRows.end()); |
| 27 DCHECK(column >= dirtiedColumns.start() && column < dirtiedColumns.end()); | 27 DCHECK(column >= dirtiedColumns.start() && column < dirtiedColumns.end()); |
| 28 | 28 |
| 29 if (column >= m_layoutTableSection.numCols(row)) | |
| 30 return nullptr; | |
| 31 | |
| 29 const LayoutTableCell* cell = m_layoutTableSection.primaryCellAt(row, column); | 32 const LayoutTableCell* cell = m_layoutTableSection.primaryCellAt(row, column); |
| 30 if (!cell) | 33 if (!cell) |
| 31 return nullptr; | 34 return nullptr; |
| 32 // We have painted (row, column) when painting (row - 1, column). | 35 // We have painted (row, column) when painting (row - 1, column). |
| 33 if (row > dirtiedRows.start() && | 36 if (row > dirtiedRows.start() && |
| 37 column < m_layoutTableSection.numCols(row - 1) && | |
| 34 m_layoutTableSection.primaryCellAt(row - 1, column) == cell) | 38 m_layoutTableSection.primaryCellAt(row - 1, column) == cell) |
| 35 return nullptr; | 39 return nullptr; |
| 36 // We have painted (row, column) when painting (row, column -1). | 40 // We have painted (row, column) when painting (row, column -1). |
| 37 if (column > dirtiedColumns.start() && | 41 if (column > dirtiedColumns.start() && |
| 38 m_layoutTableSection.primaryCellAt(row, column - 1) == cell) | 42 m_layoutTableSection.primaryCellAt(row, column - 1) == cell) |
| 39 return nullptr; | 43 return nullptr; |
| 40 return cell; | 44 return cell; |
| 41 } | 45 } |
| 42 | 46 |
| 43 void TableSectionPainter::paintRepeatingHeaderGroup( | 47 void TableSectionPainter::paintRepeatingHeaderGroup( |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 182 CellSpan dirtiedColumns = | 186 CellSpan dirtiedColumns = |
| 183 m_layoutTableSection.dirtiedEffectiveColumns(tableAlignedRect); | 187 m_layoutTableSection.dirtiedEffectiveColumns(tableAlignedRect); |
| 184 | 188 |
| 185 if (dirtiedColumns.start() >= dirtiedColumns.end()) | 189 if (dirtiedColumns.start() >= dirtiedColumns.end()) |
| 186 return; | 190 return; |
| 187 | 191 |
| 188 // Collapsed borders are painted from the bottom right to the top left so that | 192 // Collapsed borders are painted from the bottom right to the top left so that |
| 189 // precedence due to cell position is respected. | 193 // precedence due to cell position is respected. |
| 190 for (unsigned r = dirtiedRows.end(); r > dirtiedRows.start(); r--) { | 194 for (unsigned r = dirtiedRows.end(); r > dirtiedRows.start(); r--) { |
| 191 unsigned row = r - 1; | 195 unsigned row = r - 1; |
| 196 unsigned nCols = m_layoutTableSection.numCols(row); | |
| 197 unsigned prevRowCols = | |
| 198 row > dirtiedRows.start() ? m_layoutTableSection.numCols(row - 1) : 0; | |
| 192 for (unsigned c = dirtiedColumns.end(); c > dirtiedColumns.start(); c--) { | 199 for (unsigned c = dirtiedColumns.end(); c > dirtiedColumns.start(); c--) { |
| 193 unsigned col = c - 1; | 200 unsigned col = c - 1; |
| 201 if (col >= nCols) | |
| 202 break; | |
|
mstensho (USE GERRIT)
2017/01/20 10:02:04
Did you mean "continue;"? We're walking backwards
a.suchit
2017/01/23 06:35:32
Yes, It should be continue. Thanks
Done.
| |
| 194 const LayoutTableCell* cell = | 203 const LayoutTableCell* cell = |
| 195 m_layoutTableSection.primaryCellAt(row, col); | 204 m_layoutTableSection.primaryCellAt(row, col); |
| 196 if (!cell || (row > dirtiedRows.start() && | 205 if (!cell || (row > dirtiedRows.start() && col < prevRowCols && |
| 197 m_layoutTableSection.primaryCellAt(row - 1, col) == cell) || | 206 m_layoutTableSection.primaryCellAt(row - 1, col) == cell) || |
| 198 (col > dirtiedColumns.start() && | 207 (col > dirtiedColumns.start() && |
| 199 m_layoutTableSection.primaryCellAt(row, col - 1) == cell)) | 208 m_layoutTableSection.primaryCellAt(row, col - 1) == cell)) |
| 200 continue; | 209 continue; |
| 201 LayoutPoint cellPoint = m_layoutTableSection.flipForWritingModeForChild( | 210 LayoutPoint cellPoint = m_layoutTableSection.flipForWritingModeForChild( |
| 202 cell, adjustedPaintOffset); | 211 cell, adjustedPaintOffset); |
| 203 TableCellPainter(*cell).paintCollapsedBorders(paintInfo, cellPoint, | 212 TableCellPainter(*cell).paintCollapsedBorders(paintInfo, cellPoint, |
| 204 currentBorderValue); | 213 currentBorderValue); |
| 205 } | 214 } |
| 206 } | 215 } |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 295 | 304 |
| 296 HashSet<LayoutTableCell*> spanningCells; | 305 HashSet<LayoutTableCell*> spanningCells; |
| 297 for (unsigned r = dirtiedRows.start(); r < dirtiedRows.end(); r++) { | 306 for (unsigned r = dirtiedRows.start(); r < dirtiedRows.end(); r++) { |
| 298 const LayoutTableRow* row = m_layoutTableSection.rowLayoutObjectAt(r); | 307 const LayoutTableRow* row = m_layoutTableSection.rowLayoutObjectAt(r); |
| 299 // TODO(crbug.com/577282): This painting order is inconsistent with other | 308 // TODO(crbug.com/577282): This painting order is inconsistent with other |
| 300 // outlines. | 309 // outlines. |
| 301 if (row && !row->hasSelfPaintingLayer() && | 310 if (row && !row->hasSelfPaintingLayer() && |
| 302 shouldPaintSelfOutline(paintInfoForDescendants.phase)) | 311 shouldPaintSelfOutline(paintInfoForDescendants.phase)) |
| 303 TableRowPainter(*row).paintOutline(paintInfoForDescendants, | 312 TableRowPainter(*row).paintOutline(paintInfoForDescendants, |
| 304 paintOffset); | 313 paintOffset); |
| 305 for (unsigned c = dirtiedColumns.start(); c < dirtiedColumns.end(); c++) { | 314 unsigned nCols = m_layoutTableSection.numCols(r); |
| 306 if (c >= m_layoutTableSection.numCols(r)) | 315 for (unsigned c = dirtiedColumns.start(); |
| 307 break; | 316 c < nCols && c < dirtiedColumns.end(); c++) { |
| 308 const LayoutTableSection::CellStruct& current = | 317 const LayoutTableSection::CellStruct& current = |
| 309 m_layoutTableSection.cellAt(r, c); | 318 m_layoutTableSection.cellAt(r, c); |
| 310 for (LayoutTableCell* cell : current.cells) { | 319 for (LayoutTableCell* cell : current.cells) { |
| 311 if (overflowingCells.contains(cell)) | 320 if (overflowingCells.contains(cell)) |
| 312 continue; | 321 continue; |
| 313 if (cell->rowSpan() > 1 || cell->colSpan() > 1) { | 322 if (cell->rowSpan() > 1 || cell->colSpan() > 1) { |
| 314 if (!spanningCells.add(cell).isNewEntry) | 323 if (!spanningCells.add(cell).isNewEntry) |
| 315 continue; | 324 continue; |
| 316 } | 325 } |
| 317 cells.push_back(cell); | 326 cells.push_back(cell); |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 405 m_layoutTableSection.styleRef()); | 414 m_layoutTableSection.styleRef()); |
| 406 } else { | 415 } else { |
| 407 // TODO(wangxianzhu): Calculate the inset shadow bounds by insetting | 416 // TODO(wangxianzhu): Calculate the inset shadow bounds by insetting |
| 408 // paintRect by half widths of collapsed borders. | 417 // paintRect by half widths of collapsed borders. |
| 409 BoxPainter::paintInsetBoxShadow(paintInfo, paintRect, | 418 BoxPainter::paintInsetBoxShadow(paintInfo, paintRect, |
| 410 m_layoutTableSection.styleRef()); | 419 m_layoutTableSection.styleRef()); |
| 411 } | 420 } |
| 412 } | 421 } |
| 413 | 422 |
| 414 } // namespace blink | 423 } // namespace blink |
| OLD | NEW |