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 void TableSectionPainter::PaintRepeatingFooterGroup( | |
|
mstensho (USE GERRIT)
2017/04/24 11:57:16
Please match the order of declaration. There Paint
| |
| 22 const PaintInfo& paint_info, | |
| 23 const LayoutPoint& paint_offset, | |
| 24 const CollapsedBorderValue& current_border_value, | |
| 25 ItemToPaint item_to_paint) { | |
| 26 if (!layout_table_section_.IsRepeatingFooterGroup()) | |
| 27 return; | |
| 28 LayoutTable* table = layout_table_section_.Table(); | |
| 29 LayoutRect sections_rect(LayoutPoint(), table->Size()); | |
| 30 table->SubtractCaptionRect(sections_rect, true); | |
|
mstensho (USE GERRIT)
2017/04/24 11:57:16
Why do we want to keep the top captions?
| |
| 31 LayoutUnit total_height_of_rows = | |
| 32 sections_rect.Height() - table->OuterBorderAfter(); | |
|
mstensho (USE GERRIT)
2017/04/24 11:57:16
Mixing physical (Height()) and logical (OuterBorde
| |
| 33 total_height_of_rows -= (layout_table_section_.LogicalHeight() - | |
| 34 layout_table_section_.FirstRow()->PaginationStrut()); | |
|
mstensho (USE GERRIT)
2017/04/24 11:57:16
Will there ever be a pagination strut here? Seems
| |
| 35 LayoutPoint top_offset = paint_offset; | |
| 36 top_offset.Move(0, -total_height_of_rows.ToInt()); | |
| 37 IntRect cull_rect = paint_info.GetCullRect().rect_; | |
| 38 cull_rect.Move(0, -total_height_of_rows.ToInt()); | |
| 39 for (unsigned page = 0; | |
| 40 page < table->PositionOfRepeatingFooterGroupOnPage().size(); page++) { | |
| 41 LayoutPoint pagination_offset = top_offset; | |
| 42 int footer_position = | |
| 43 table->GetPositionOfRepeatingFooterGroupOnPage(page).ToInt(); | |
| 44 if (!footer_position) | |
| 45 continue; | |
| 46 pagination_offset.Move(0, footer_position); | |
| 47 if (item_to_paint == kPaintCollapsedBorders) { | |
| 48 PaintCollapsedSectionBorders(paint_info, pagination_offset, | |
| 49 current_border_value); | |
| 50 } else { | |
| 51 PaintSection(paint_info, pagination_offset); | |
| 52 } | |
| 53 } | |
| 54 } | |
| 55 | |
| 21 void TableSectionPainter::PaintRepeatingHeaderGroup( | 56 void TableSectionPainter::PaintRepeatingHeaderGroup( |
| 22 const PaintInfo& paint_info, | 57 const PaintInfo& paint_info, |
| 23 const LayoutPoint& paint_offset, | 58 const LayoutPoint& paint_offset, |
| 24 const CollapsedBorderValue& current_border_value, | 59 const CollapsedBorderValue& current_border_value, |
| 25 ItemToPaint item_to_paint) { | 60 ItemToPaint item_to_paint) { |
| 26 if (!layout_table_section_.IsRepeatingHeaderGroup()) | 61 if (!layout_table_section_.IsRepeatingHeaderGroup()) |
| 27 return; | 62 return; |
| 28 | 63 |
| 29 LayoutTable* table = layout_table_section_.Table(); | 64 LayoutTable* table = layout_table_section_.Table(); |
| 30 LayoutPoint pagination_offset = paint_offset; | 65 LayoutPoint pagination_offset = paint_offset; |
| 31 LayoutUnit page_height = table->PageLogicalHeightForOffset(LayoutUnit()); | 66 LayoutUnit page_height = table->PageLogicalHeightForOffset(LayoutUnit()); |
| 32 | 67 |
| 33 LayoutUnit header_group_offset = table->BlockOffsetToFirstRepeatableHeader(); | 68 LayoutUnit header_group_offset = table->BlockOffsetToFirstRepeatableHeader(); |
| 34 // The header may have a pagination strut before it so we need to account for | 69 // The header may have a pagination strut before it so we need to account for |
| 35 // that when establishing its position. | 70 // that when establishing its position. |
| 71 LayoutUnit first_row_offset; | |
| 36 if (LayoutTableRow* row = layout_table_section_.FirstRow()) | 72 if (LayoutTableRow* row = layout_table_section_.FirstRow()) |
| 37 header_group_offset += row->PaginationStrut(); | 73 first_row_offset = row->PaginationStrut(); |
| 74 header_group_offset += first_row_offset; | |
| 38 LayoutUnit offset_to_next_page = | 75 LayoutUnit offset_to_next_page = |
| 39 page_height - IntMod(header_group_offset, page_height); | 76 page_height - IntMod(header_group_offset, page_height); |
| 40 // Move paginationOffset to the top of the next page. | 77 // Move pagination_offset to the top of the next page. |
| 41 pagination_offset.Move(LayoutUnit(), offset_to_next_page); | 78 pagination_offset.Move(LayoutUnit(), offset_to_next_page); |
| 42 // Now move paginationOffset to the top of the page the cull rect starts on. | 79 // Now move pagination_offset to the top of the page the cull rect starts on. |
| 43 if (paint_info.GetCullRect().rect_.Y() > pagination_offset.Y()) { | 80 if (paint_info.GetCullRect().rect_.Y() > pagination_offset.Y()) { |
| 44 pagination_offset.Move(LayoutUnit(), | 81 pagination_offset.Move(LayoutUnit(), |
| 45 page_height * ((paint_info.GetCullRect().rect_.Y() - | 82 page_height * ((paint_info.GetCullRect().rect_.Y() - |
| 46 pagination_offset.Y()) / | 83 pagination_offset.Y()) / |
| 47 page_height) | 84 page_height) |
| 48 .ToInt()); | 85 .ToInt()); |
| 49 } | 86 } |
| 50 | 87 |
| 51 // We only want to consider pages where we going to paint a row, so exclude | 88 // We only want to consider pages where we going to paint a row, so exclude |
| 52 // captions and border spacing from the table. | 89 // captions and border spacing from the table. |
| 53 LayoutRect sections_rect(LayoutPoint(), table->Size()); | 90 LayoutRect sections_rect(LayoutPoint(), table->Size()); |
| 54 table->SubtractCaptionRect(sections_rect); | 91 table->SubtractCaptionRect(sections_rect); |
| 55 LayoutUnit total_height_of_rows = | 92 LayoutUnit total_height_of_rows = |
| 56 sections_rect.Height() - table->VBorderSpacing(); | 93 sections_rect.Height() - table->VBorderSpacing(); |
| 57 LayoutUnit bottom_bound = | 94 LayoutUnit bottom_bound = |
| 58 std::min(LayoutUnit(paint_info.GetCullRect().rect_.MaxY()), | 95 std::min(LayoutUnit(paint_info.GetCullRect().rect_.MaxY()), |
| 59 paint_offset.Y() + total_height_of_rows); | 96 (paint_offset.Y() - first_row_offset) + total_height_of_rows); |
|
mstensho (USE GERRIT)
2017/04/24 11:57:16
No need for the parentheses.
| |
| 60 | 97 |
| 61 while (pagination_offset.Y() < bottom_bound) { | 98 while (pagination_offset.Y() < bottom_bound) { |
| 62 if (item_to_paint == kPaintCollapsedBorders) { | 99 if (item_to_paint == kPaintCollapsedBorders) { |
| 63 PaintCollapsedSectionBorders(paint_info, pagination_offset, | 100 PaintCollapsedSectionBorders(paint_info, pagination_offset, |
| 64 current_border_value); | 101 current_border_value); |
| 65 } else { | 102 } else { |
| 66 PaintSection(paint_info, pagination_offset); | 103 PaintSection(paint_info, pagination_offset); |
| 67 } | 104 } |
| 68 pagination_offset.Move(0, page_height.ToInt()); | 105 pagination_offset.Move(0, page_height.ToInt()); |
| 69 } | 106 } |
| 70 } | 107 } |
| 71 | 108 |
| 72 void TableSectionPainter::Paint(const PaintInfo& paint_info, | 109 void TableSectionPainter::Paint(const PaintInfo& paint_info, |
| 73 const LayoutPoint& paint_offset) { | 110 const LayoutPoint& paint_offset) { |
| 74 ObjectPainter(layout_table_section_) | 111 ObjectPainter(layout_table_section_) |
| 75 .CheckPaintOffset(paint_info, paint_offset); | 112 .CheckPaintOffset(paint_info, paint_offset); |
| 76 PaintSection(paint_info, paint_offset); | 113 PaintSection(paint_info, paint_offset); |
| 77 LayoutTable* table = layout_table_section_.Table(); | 114 LayoutTable* table = layout_table_section_.Table(); |
| 78 if (table->Header() == layout_table_section_) | 115 if (table->Header() == layout_table_section_) |
| 79 PaintRepeatingHeaderGroup(paint_info, paint_offset, CollapsedBorderValue(), | 116 PaintRepeatingHeaderGroup(paint_info, paint_offset, CollapsedBorderValue(), |
| 80 kPaintSection); | 117 kPaintSection); |
| 118 if (table->Footer() == layout_table_section_) { | |
|
mstensho (USE GERRIT)
2017/04/24 11:57:16
else if
| |
| 119 PaintRepeatingFooterGroup(paint_info, paint_offset, CollapsedBorderValue(), | |
| 120 kPaintSection); | |
| 121 } | |
| 81 } | 122 } |
| 82 | 123 |
| 83 void TableSectionPainter::PaintSection(const PaintInfo& paint_info, | 124 void TableSectionPainter::PaintSection(const PaintInfo& paint_info, |
| 84 const LayoutPoint& paint_offset) { | 125 const LayoutPoint& paint_offset) { |
| 85 DCHECK(!layout_table_section_.NeedsLayout()); | 126 DCHECK(!layout_table_section_.NeedsLayout()); |
| 86 // avoid crashing on bugs that cause us to paint with dirty layout | 127 // avoid crashing on bugs that cause us to paint with dirty layout |
| 87 if (layout_table_section_.NeedsLayout()) | 128 if (layout_table_section_.NeedsLayout()) |
| 88 return; | 129 return; |
| 89 | 130 |
| 90 unsigned total_rows = layout_table_section_.NumRows(); | 131 unsigned total_rows = layout_table_section_.NumRows(); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 128 | 169 |
| 129 void TableSectionPainter::PaintCollapsedBorders( | 170 void TableSectionPainter::PaintCollapsedBorders( |
| 130 const PaintInfo& paint_info, | 171 const PaintInfo& paint_info, |
| 131 const LayoutPoint& paint_offset, | 172 const LayoutPoint& paint_offset, |
| 132 const CollapsedBorderValue& current_border_value) { | 173 const CollapsedBorderValue& current_border_value) { |
| 133 PaintCollapsedSectionBorders(paint_info, paint_offset, current_border_value); | 174 PaintCollapsedSectionBorders(paint_info, paint_offset, current_border_value); |
| 134 LayoutTable* table = layout_table_section_.Table(); | 175 LayoutTable* table = layout_table_section_.Table(); |
| 135 if (table->Header() == layout_table_section_) | 176 if (table->Header() == layout_table_section_) |
| 136 PaintRepeatingHeaderGroup(paint_info, paint_offset, current_border_value, | 177 PaintRepeatingHeaderGroup(paint_info, paint_offset, current_border_value, |
| 137 kPaintCollapsedBorders); | 178 kPaintCollapsedBorders); |
| 179 if (table->Footer() == layout_table_section_) { | |
|
mstensho (USE GERRIT)
2017/04/24 11:57:16
else if
| |
| 180 PaintRepeatingFooterGroup(paint_info, paint_offset, current_border_value, | |
| 181 kPaintCollapsedBorders); | |
| 182 } | |
| 138 } | 183 } |
| 139 | 184 |
| 140 void TableSectionPainter::PaintCollapsedSectionBorders( | 185 void TableSectionPainter::PaintCollapsedSectionBorders( |
| 141 const PaintInfo& paint_info, | 186 const PaintInfo& paint_info, |
| 142 const LayoutPoint& paint_offset, | 187 const LayoutPoint& paint_offset, |
| 143 const CollapsedBorderValue& current_border_value) { | 188 const CollapsedBorderValue& current_border_value) { |
| 144 if (!layout_table_section_.NumRows() || | 189 if (!layout_table_section_.NumRows() || |
| 145 !layout_table_section_.Table()->EffectiveColumns().size()) | 190 !layout_table_section_.Table()->EffectiveColumns().size()) |
| 146 return; | 191 return; |
| 147 | 192 |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 396 const PaintInfo& paint_info_for_cells, | 441 const PaintInfo& paint_info_for_cells, |
| 397 const LayoutPoint& paint_offset) { | 442 const LayoutPoint& paint_offset) { |
| 398 if (!cell.HasSelfPaintingLayer() && !cell.Row()->HasSelfPaintingLayer()) { | 443 if (!cell.HasSelfPaintingLayer() && !cell.Row()->HasSelfPaintingLayer()) { |
| 399 LayoutPoint cell_point = | 444 LayoutPoint cell_point = |
| 400 layout_table_section_.FlipForWritingModeForChild(&cell, paint_offset); | 445 layout_table_section_.FlipForWritingModeForChild(&cell, paint_offset); |
| 401 cell.Paint(paint_info_for_cells, cell_point); | 446 cell.Paint(paint_info_for_cells, cell_point); |
| 402 } | 447 } |
| 403 } | 448 } |
| 404 | 449 |
| 405 } // namespace blink | 450 } // namespace blink |
| OLD | NEW |