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" |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 layout_table_section_.DirtiedRowsAndEffectiveColumns( | 145 layout_table_section_.DirtiedRowsAndEffectiveColumns( |
146 table_aligned_rect, dirtied_rows, dirtied_columns); | 146 table_aligned_rect, dirtied_rows, dirtied_columns); |
147 | 147 |
148 if (dirtied_columns.Start() >= dirtied_columns.End()) | 148 if (dirtied_columns.Start() >= dirtied_columns.End()) |
149 return; | 149 return; |
150 | 150 |
151 // Collapsed borders are painted from the bottom right to the top left so that | 151 // Collapsed borders are painted from the bottom right to the top left so that |
152 // precedence due to cell position is respected. | 152 // precedence due to cell position is respected. |
153 for (unsigned r = dirtied_rows.End(); r > dirtied_rows.Start(); r--) { | 153 for (unsigned r = dirtied_rows.End(); r > dirtied_rows.Start(); r--) { |
154 unsigned row = r - 1; | 154 unsigned row = r - 1; |
155 unsigned n_cols = layout_table_section_.NumCols(row); | 155 unsigned n_cols = layout_table_section_.NumEffectiveColumns(row); |
156 for (unsigned c = std::min(dirtied_columns.End(), n_cols); | 156 for (unsigned c = std::min(dirtied_columns.End(), n_cols); |
157 c > dirtied_columns.Start(); c--) { | 157 c > dirtied_columns.Start(); c--) { |
158 unsigned col = c - 1; | 158 unsigned col = c - 1; |
159 if (const LayoutTableCell* cell = | 159 if (const LayoutTableCell* cell = |
160 layout_table_section_.OriginatingCellAt(row, col)) { | 160 layout_table_section_.OriginatingCellAt(row, col)) { |
161 LayoutPoint cell_point = | 161 LayoutPoint cell_point = |
162 layout_table_section_.FlipForWritingModeForChild( | 162 layout_table_section_.FlipForWritingModeForChild( |
163 cell, adjusted_paint_offset); | 163 cell, adjusted_paint_offset); |
164 TableCellPainter(*cell).PaintCollapsedBorders(paint_info, cell_point, | 164 TableCellPainter(*cell).PaintCollapsedBorders(paint_info, cell_point, |
165 current_border_value); | 165 current_border_value); |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
250 HashSet<const LayoutTableCell*> spanning_cells; | 250 HashSet<const LayoutTableCell*> spanning_cells; |
251 for (unsigned r = dirtied_rows.Start(); r < dirtied_rows.End(); r++) { | 251 for (unsigned r = dirtied_rows.Start(); r < dirtied_rows.End(); r++) { |
252 const LayoutTableRow* row = layout_table_section_.RowLayoutObjectAt(r); | 252 const LayoutTableRow* row = layout_table_section_.RowLayoutObjectAt(r); |
253 // TODO(crbug.com/577282): This painting order is inconsistent with other | 253 // TODO(crbug.com/577282): This painting order is inconsistent with other |
254 // outlines. | 254 // outlines. |
255 if (row && !row->HasSelfPaintingLayer() && | 255 if (row && !row->HasSelfPaintingLayer() && |
256 ShouldPaintSelfOutline(paint_info_for_descendants.phase)) { | 256 ShouldPaintSelfOutline(paint_info_for_descendants.phase)) { |
257 TableRowPainter(*row).PaintOutline(paint_info_for_descendants, | 257 TableRowPainter(*row).PaintOutline(paint_info_for_descendants, |
258 paint_offset); | 258 paint_offset); |
259 } | 259 } |
260 unsigned n_cols = layout_table_section_.NumCols(r); | 260 unsigned n_cols = layout_table_section_.NumEffectiveColumns(r); |
261 for (unsigned c = dirtied_columns.Start(); | 261 for (unsigned c = dirtied_columns.Start(); |
262 c < n_cols && c < dirtied_columns.End(); c++) { | 262 c < n_cols && c < dirtied_columns.End(); c++) { |
263 if (const auto* cell = layout_table_section_.OriginatingCellAt(r, c)) { | 263 if (const auto* cell = layout_table_section_.OriginatingCellAt(r, c)) { |
264 if (!overflowing_cells.Contains(cell)) | 264 if (!overflowing_cells.Contains(cell)) |
265 cells.push_back(cell); | 265 cells.push_back(cell); |
266 } | 266 } |
267 } | 267 } |
268 } | 268 } |
269 | 269 |
270 // Sort the dirty cells by paint order. | 270 // Sort the dirty cells by paint order. |
271 std::sort(cells.begin(), cells.end(), LayoutTableCell::CompareInDOMOrder); | 271 std::sort(cells.begin(), cells.end(), LayoutTableCell::CompareInDOMOrder); |
272 for (const auto* cell : cells) | 272 for (const auto* cell : cells) |
273 PaintCell(*cell, paint_info_for_descendants, paint_offset); | 273 PaintCell(*cell, paint_info_for_descendants, paint_offset); |
274 } | 274 } |
275 } | 275 } |
276 | 276 |
277 void TableSectionPainter::PaintBoxDecorationBackground( | 277 void TableSectionPainter::PaintBoxDecorationBackground( |
278 const PaintInfo& paint_info, | 278 const PaintInfo& paint_info, |
279 const LayoutPoint& paint_offset, | 279 const LayoutPoint& paint_offset, |
280 const CellSpan& dirtied_rows, | 280 const CellSpan& dirtied_rows, |
281 const CellSpan& dirtied_columns) { | 281 const CellSpan& dirtied_columns) { |
282 bool may_have_background = layout_table_section_.Table()->HasColElements() || | 282 bool may_have_background = |
283 layout_table_section_.StyleRef().HasBackground(); | 283 layout_table_section_.Table()->HasColOrColGroups() || |
| 284 layout_table_section_.StyleRef().HasBackground(); |
284 bool has_box_shadow = layout_table_section_.StyleRef().BoxShadow(); | 285 bool has_box_shadow = layout_table_section_.StyleRef().BoxShadow(); |
285 if (!may_have_background && !has_box_shadow) | 286 if (!may_have_background && !has_box_shadow) |
286 return; | 287 return; |
287 | 288 |
288 PaintResult paint_result = | 289 PaintResult paint_result = |
289 dirtied_columns == layout_table_section_.FullTableEffectiveColumnSpan() && | 290 dirtied_columns == layout_table_section_.FullTableEffectiveColumnSpan() && |
290 dirtied_rows == layout_table_section_.FullSectionRowSpan() | 291 dirtied_rows == layout_table_section_.FullSectionRowSpan() |
291 ? kFullyPainted | 292 ? kFullyPainted |
292 : kMayBeClippedByPaintDirtyRect; | 293 : kMayBeClippedByPaintDirtyRect; |
293 layout_table_section_.GetMutableForPainting().UpdatePaintResult( | 294 layout_table_section_.GetMutableForPainting().UpdatePaintResult( |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
333 const LayoutTableCell& cell, | 334 const LayoutTableCell& cell, |
334 const PaintInfo& paint_info_for_cells, | 335 const PaintInfo& paint_info_for_cells, |
335 const LayoutPoint& paint_offset) { | 336 const LayoutPoint& paint_offset) { |
336 LayoutPoint cell_point = | 337 LayoutPoint cell_point = |
337 layout_table_section_.FlipForWritingModeForChild(&cell, paint_offset); | 338 layout_table_section_.FlipForWritingModeForChild(&cell, paint_offset); |
338 | 339 |
339 // We need to handle painting a stack of backgrounds. This stack (from bottom | 340 // We need to handle painting a stack of backgrounds. This stack (from bottom |
340 // to top) consists of the column group, column, row group, row, and then the | 341 // to top) consists of the column group, column, row group, row, and then the |
341 // cell. | 342 // cell. |
342 | 343 |
343 LayoutTable::ColAndColGroup col_and_col_group = | 344 auto col_and_col_group = cell.GetColAndColGroup(); |
344 layout_table_section_.Table()->ColElementAtAbsoluteColumn( | |
345 cell.AbsoluteColumnIndex()); | |
346 LayoutTableCol* column = col_and_col_group.col; | 345 LayoutTableCol* column = col_and_col_group.col; |
347 LayoutTableCol* column_group = col_and_col_group.colgroup; | 346 LayoutTableCol* column_group = col_and_col_group.colgroup; |
348 TableCellPainter table_cell_painter(cell); | 347 TableCellPainter table_cell_painter(cell); |
349 | 348 |
350 // Column groups and columns first. | 349 // Column groups and columns first. |
351 // FIXME: Columns and column groups do not currently support opacity, and they | 350 // FIXME: Columns and column groups do not currently support opacity, and they |
352 // are being painted "too late" in the stack, since we have already opened a | 351 // are being painted "too late" in the stack, since we have already opened a |
353 // transparency layer (potentially) for the table row group. Note that we | 352 // transparency layer (potentially) for the table row group. Note that we |
354 // deliberately ignore whether or not the cell has a layer, since these | 353 // deliberately ignore whether or not the cell has a layer, since these |
355 // backgrounds paint "behind" the cell. | 354 // backgrounds paint "behind" the cell. |
(...skipping 17 matching lines...) Expand all Loading... |
373 const PaintInfo& paint_info_for_cells, | 372 const PaintInfo& paint_info_for_cells, |
374 const LayoutPoint& paint_offset) { | 373 const LayoutPoint& paint_offset) { |
375 if (!cell.HasSelfPaintingLayer() && !cell.Row()->HasSelfPaintingLayer()) { | 374 if (!cell.HasSelfPaintingLayer() && !cell.Row()->HasSelfPaintingLayer()) { |
376 LayoutPoint cell_point = | 375 LayoutPoint cell_point = |
377 layout_table_section_.FlipForWritingModeForChild(&cell, paint_offset); | 376 layout_table_section_.FlipForWritingModeForChild(&cell, paint_offset); |
378 cell.Paint(paint_info_for_cells, cell_point); | 377 cell.Paint(paint_info_for_cells, cell_point); |
379 } | 378 } |
380 } | 379 } |
381 | 380 |
382 } // namespace blink | 381 } // namespace blink |
OLD | NEW |