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" |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 26 if (!layout_table_section_.IsRepeatingHeaderGroup()) | 26 if (!layout_table_section_.IsRepeatingHeaderGroup()) |
| 27 return; | 27 return; |
| 28 | 28 |
| 29 LayoutTable* table = layout_table_section_.Table(); | 29 LayoutTable* table = layout_table_section_.Table(); |
| 30 LayoutPoint pagination_offset = paint_offset; | 30 LayoutPoint pagination_offset = paint_offset; |
| 31 LayoutUnit page_height = table->PageLogicalHeightForOffset(LayoutUnit()); | 31 LayoutUnit page_height = table->PageLogicalHeightForOffset(LayoutUnit()); |
| 32 | 32 |
| 33 LayoutUnit header_group_offset = table->BlockOffsetToFirstRepeatableHeader(); | 33 LayoutUnit header_group_offset = table->BlockOffsetToFirstRepeatableHeader(); |
| 34 // The header may have a pagination strut before it so we need to account for | 34 // The header may have a pagination strut before it so we need to account for |
| 35 // that when establishing its position. | 35 // that when establishing its position. |
| 36 LayoutUnit first_row_offset; | |
|
mstensho (USE GERRIT)
2017/05/08 13:56:00
Could you make "pagination" or at least "strut" pa
rhogan
2017/05/09 19:57:17
This isn't necessary anymore for some reason. ¯\_(
| |
| 36 if (LayoutTableRow* row = layout_table_section_.FirstRow()) | 37 if (LayoutTableRow* row = layout_table_section_.FirstRow()) |
| 37 header_group_offset += row->PaginationStrut(); | 38 first_row_offset = row->PaginationStrut(); |
| 39 header_group_offset += first_row_offset; | |
| 38 LayoutUnit offset_to_next_page = | 40 LayoutUnit offset_to_next_page = |
| 39 page_height - IntMod(header_group_offset, page_height); | 41 page_height - IntMod(header_group_offset, page_height); |
| 40 // Move paginationOffset to the top of the next page. | 42 // Move pagination_offset to the top of the next page. |
| 41 pagination_offset.Move(LayoutUnit(), offset_to_next_page); | 43 pagination_offset.Move(LayoutUnit(), offset_to_next_page); |
| 42 // Now move paginationOffset to the top of the page the cull rect starts on. | 44 // 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()) { | 45 if (paint_info.GetCullRect().rect_.Y() > pagination_offset.Y()) { |
| 44 pagination_offset.Move(LayoutUnit(), | 46 pagination_offset.Move(LayoutUnit(), |
| 45 page_height * ((paint_info.GetCullRect().rect_.Y() - | 47 page_height * ((paint_info.GetCullRect().rect_.Y() - |
| 46 pagination_offset.Y()) / | 48 pagination_offset.Y()) / |
| 47 page_height) | 49 page_height) |
| 48 .ToInt()); | 50 .ToInt()); |
| 49 } | 51 } |
| 50 | 52 |
| 51 // We only want to consider pages where we going to paint a row, so exclude | 53 // We only want to consider pages where we going to paint a row, so exclude |
| 52 // captions and border spacing from the table. | 54 // captions and border spacing from the table. |
| 53 LayoutRect sections_rect(LayoutPoint(), table->Size()); | 55 LayoutRect sections_rect(LayoutPoint(), table->Size()); |
| 54 table->SubtractCaptionRect(sections_rect); | 56 table->SubtractCaptionRect(sections_rect); |
| 55 LayoutUnit total_height_of_rows = | 57 LayoutUnit total_height_of_rows = |
| 56 sections_rect.Height() - table->VBorderSpacing(); | 58 sections_rect.Height() - table->VBorderSpacing(); |
| 57 LayoutUnit bottom_bound = | 59 LayoutUnit bottom_bound = |
| 58 std::min(LayoutUnit(paint_info.GetCullRect().rect_.MaxY()), | 60 std::min(LayoutUnit(paint_info.GetCullRect().rect_.MaxY()), |
| 59 paint_offset.Y() + total_height_of_rows); | 61 paint_offset.Y() - first_row_offset + total_height_of_rows); |
| 60 | 62 |
| 61 while (pagination_offset.Y() < bottom_bound) { | 63 while (pagination_offset.Y() < bottom_bound) { |
| 62 if (item_to_paint == kPaintCollapsedBorders) { | 64 if (item_to_paint == kPaintCollapsedBorders) { |
| 63 PaintCollapsedSectionBorders(paint_info, pagination_offset, | 65 PaintCollapsedSectionBorders(paint_info, pagination_offset, |
| 64 current_border_value); | 66 current_border_value); |
| 65 } else { | 67 } else { |
| 66 PaintSection(paint_info, pagination_offset); | 68 PaintSection(paint_info, pagination_offset); |
| 67 } | 69 } |
| 68 pagination_offset.Move(0, page_height.ToInt()); | 70 pagination_offset.Move(0, page_height.ToInt()); |
| 69 } | 71 } |
| 70 } | 72 } |
| 71 | 73 |
| 74 void TableSectionPainter::PaintRepeatingFooterGroup( | |
| 75 const PaintInfo& paint_info, | |
| 76 const LayoutPoint& paint_offset, | |
| 77 const CollapsedBorderValue& current_border_value, | |
| 78 ItemToPaint item_to_paint) { | |
| 79 if (!layout_table_section_.IsRepeatingFooterGroup()) | |
| 80 return; | |
| 81 LayoutTable* table = layout_table_section_.Table(); | |
| 82 LayoutRect sections_rect(LayoutPoint(), table->Size()); | |
| 83 // Include the top captions as we need top_offset to be | |
|
mstensho (USE GERRIT)
2017/05/08 13:56:00
Include, as in exclude from subtraction? How about
rhogan
2017/05/09 19:57:17
Done.
| |
| 84 // the offset from the top of table. | |
| 85 table->SubtractCaptionRect(sections_rect, true); | |
| 86 LayoutUnit total_height_of_rows = | |
| 87 sections_rect.Height() - table->OuterBorderBottom(); | |
| 88 // The footer section may be at the top of a page. | |
| 89 total_height_of_rows -= (layout_table_section_.LogicalHeight() - | |
| 90 layout_table_section_.FirstRow()->PaginationStrut()); | |
| 91 LayoutPoint top_offset = paint_offset; | |
| 92 top_offset.Move(0, -total_height_of_rows.ToInt()); | |
| 93 IntRect cull_rect = paint_info.GetCullRect().rect_; | |
| 94 cull_rect.Move(0, -total_height_of_rows.ToInt()); | |
| 95 for (unsigned page = 0; | |
| 96 page < table->PositionOfRepeatingFooterGroupOnPage().size(); page++) { | |
| 97 LayoutPoint pagination_offset = top_offset; | |
| 98 int footer_position = | |
| 99 table->GetPositionOfRepeatingFooterGroupOnPage(page).ToInt(); | |
|
mstensho (USE GERRIT)
2017/05/08 13:56:00
Since the whole vector has already been made acces
rhogan
2017/05/09 19:57:17
Done.
| |
| 100 if (!footer_position) | |
|
mstensho (USE GERRIT)
2017/05/08 13:56:00
When is it 0?
rhogan
2017/05/09 19:57:17
We don't repeat the footer on every page. For exam
| |
| 101 continue; | |
| 102 pagination_offset.Move(0, footer_position); | |
| 103 if (item_to_paint == kPaintCollapsedBorders) { | |
| 104 PaintCollapsedSectionBorders(paint_info, pagination_offset, | |
| 105 current_border_value); | |
| 106 } else { | |
| 107 PaintSection(paint_info, pagination_offset); | |
| 108 } | |
| 109 } | |
| 110 } | |
| 111 | |
| 72 void TableSectionPainter::Paint(const PaintInfo& paint_info, | 112 void TableSectionPainter::Paint(const PaintInfo& paint_info, |
| 73 const LayoutPoint& paint_offset) { | 113 const LayoutPoint& paint_offset) { |
| 74 ObjectPainter(layout_table_section_) | 114 ObjectPainter(layout_table_section_) |
| 75 .CheckPaintOffset(paint_info, paint_offset); | 115 .CheckPaintOffset(paint_info, paint_offset); |
| 76 PaintSection(paint_info, paint_offset); | 116 PaintSection(paint_info, paint_offset); |
| 77 LayoutTable* table = layout_table_section_.Table(); | 117 LayoutTable* table = layout_table_section_.Table(); |
| 78 if (table->Header() == layout_table_section_) | 118 if (table->Header() == layout_table_section_) { |
| 79 PaintRepeatingHeaderGroup(paint_info, paint_offset, CollapsedBorderValue(), | 119 PaintRepeatingHeaderGroup(paint_info, paint_offset, CollapsedBorderValue(), |
| 80 kPaintSection); | 120 kPaintSection); |
| 121 } else if (table->Footer() == layout_table_section_) { | |
| 122 PaintRepeatingFooterGroup(paint_info, paint_offset, CollapsedBorderValue(), | |
| 123 kPaintSection); | |
| 124 } | |
| 81 } | 125 } |
| 82 | 126 |
| 83 void TableSectionPainter::PaintSection(const PaintInfo& paint_info, | 127 void TableSectionPainter::PaintSection(const PaintInfo& paint_info, |
| 84 const LayoutPoint& paint_offset) { | 128 const LayoutPoint& paint_offset) { |
| 85 DCHECK(!layout_table_section_.NeedsLayout()); | 129 DCHECK(!layout_table_section_.NeedsLayout()); |
| 86 // avoid crashing on bugs that cause us to paint with dirty layout | 130 // avoid crashing on bugs that cause us to paint with dirty layout |
| 87 if (layout_table_section_.NeedsLayout()) | 131 if (layout_table_section_.NeedsLayout()) |
| 88 return; | 132 return; |
| 89 | 133 |
| 90 unsigned total_rows = layout_table_section_.NumRows(); | 134 unsigned total_rows = layout_table_section_.NumRows(); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 125 | 169 |
| 126 return elem1->AbsoluteColumnIndex() < elem2->AbsoluteColumnIndex(); | 170 return elem1->AbsoluteColumnIndex() < elem2->AbsoluteColumnIndex(); |
| 127 } | 171 } |
| 128 | 172 |
| 129 void TableSectionPainter::PaintCollapsedBorders( | 173 void TableSectionPainter::PaintCollapsedBorders( |
| 130 const PaintInfo& paint_info, | 174 const PaintInfo& paint_info, |
| 131 const LayoutPoint& paint_offset, | 175 const LayoutPoint& paint_offset, |
| 132 const CollapsedBorderValue& current_border_value) { | 176 const CollapsedBorderValue& current_border_value) { |
| 133 PaintCollapsedSectionBorders(paint_info, paint_offset, current_border_value); | 177 PaintCollapsedSectionBorders(paint_info, paint_offset, current_border_value); |
| 134 LayoutTable* table = layout_table_section_.Table(); | 178 LayoutTable* table = layout_table_section_.Table(); |
| 135 if (table->Header() == layout_table_section_) | 179 if (table->Header() == layout_table_section_) { |
| 136 PaintRepeatingHeaderGroup(paint_info, paint_offset, current_border_value, | 180 PaintRepeatingHeaderGroup(paint_info, paint_offset, current_border_value, |
| 137 kPaintCollapsedBorders); | 181 kPaintCollapsedBorders); |
| 182 } else if (table->Footer() == layout_table_section_) { | |
| 183 PaintRepeatingFooterGroup(paint_info, paint_offset, current_border_value, | |
| 184 kPaintCollapsedBorders); | |
| 185 } | |
| 138 } | 186 } |
| 139 | 187 |
| 140 void TableSectionPainter::PaintCollapsedSectionBorders( | 188 void TableSectionPainter::PaintCollapsedSectionBorders( |
| 141 const PaintInfo& paint_info, | 189 const PaintInfo& paint_info, |
| 142 const LayoutPoint& paint_offset, | 190 const LayoutPoint& paint_offset, |
| 143 const CollapsedBorderValue& current_border_value) { | 191 const CollapsedBorderValue& current_border_value) { |
| 144 if (!layout_table_section_.NumRows() || | 192 if (!layout_table_section_.NumRows() || |
| 145 !layout_table_section_.Table()->EffectiveColumns().size()) | 193 !layout_table_section_.Table()->EffectiveColumns().size()) |
| 146 return; | 194 return; |
| 147 | 195 |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 396 const PaintInfo& paint_info_for_cells, | 444 const PaintInfo& paint_info_for_cells, |
| 397 const LayoutPoint& paint_offset) { | 445 const LayoutPoint& paint_offset) { |
| 398 if (!cell.HasSelfPaintingLayer() && !cell.Row()->HasSelfPaintingLayer()) { | 446 if (!cell.HasSelfPaintingLayer() && !cell.Row()->HasSelfPaintingLayer()) { |
| 399 LayoutPoint cell_point = | 447 LayoutPoint cell_point = |
| 400 layout_table_section_.FlipForWritingModeForChild(&cell, paint_offset); | 448 layout_table_section_.FlipForWritingModeForChild(&cell, paint_offset); |
| 401 cell.Paint(paint_info_for_cells, cell_point); | 449 cell.Paint(paint_info_for_cells, cell_point); |
| 402 } | 450 } |
| 403 } | 451 } |
| 404 | 452 |
| 405 } // namespace blink | 453 } // namespace blink |
| OLD | NEW |