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 19 matching lines...) Expand all Loading... |
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 if (LayoutTableRow* row = layout_table_section_.FirstRow()) | 36 if (LayoutTableRow* row = layout_table_section_.FirstRow()) |
37 header_group_offset += row->PaginationStrut(); | 37 header_group_offset += row->PaginationStrut(); |
38 LayoutUnit offset_to_next_page = | 38 LayoutUnit offset_to_next_page = |
39 page_height - IntMod(header_group_offset, page_height); | 39 page_height - IntMod(header_group_offset, page_height); |
40 // Move paginationOffset to the top of the next page. | 40 // Move pagination_offset to the top of the next page. |
41 pagination_offset.Move(LayoutUnit(), offset_to_next_page); | 41 pagination_offset.Move(LayoutUnit(), offset_to_next_page); |
42 // Now move paginationOffset to the top of the page the cull rect starts on. | 42 // 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()) { | 43 if (paint_info.GetCullRect().rect_.Y() > pagination_offset.Y()) { |
44 pagination_offset.Move(LayoutUnit(), | 44 pagination_offset.Move(LayoutUnit(), |
45 page_height * ((paint_info.GetCullRect().rect_.Y() - | 45 page_height * ((paint_info.GetCullRect().rect_.Y() - |
46 pagination_offset.Y()) / | 46 pagination_offset.Y()) / |
47 page_height) | 47 page_height) |
48 .ToInt()); | 48 .ToInt()); |
49 } | 49 } |
50 | 50 |
51 // We only want to consider pages where we going to paint a row, so exclude | 51 // We only want to consider pages where we going to paint a row, so exclude |
52 // captions and border spacing from the table. | 52 // captions and border spacing from the table. |
53 LayoutRect sections_rect(LayoutPoint(), table->Size()); | 53 LayoutRect sections_rect(LayoutPoint(), table->Size()); |
54 table->SubtractCaptionRect(sections_rect); | 54 table->SubtractCaptionRect(sections_rect); |
55 LayoutUnit total_height_of_rows = | 55 LayoutUnit total_height_of_rows = |
56 sections_rect.Height() - table->VBorderSpacing(); | 56 sections_rect.Height() - table->VBorderSpacing(); |
57 LayoutUnit bottom_bound = | 57 LayoutUnit bottom_bound = |
58 std::min(LayoutUnit(paint_info.GetCullRect().rect_.MaxY()), | 58 std::min(LayoutUnit(paint_info.GetCullRect().rect_.MaxY()), |
59 paint_offset.Y() + total_height_of_rows); | 59 paint_offset.Y() + total_height_of_rows); |
60 | 60 |
61 while (pagination_offset.Y() < bottom_bound) { | 61 while (pagination_offset.Y() < bottom_bound) { |
62 if (item_to_paint == kPaintCollapsedBorders) { | 62 if (item_to_paint == kPaintCollapsedBorders) { |
63 PaintCollapsedSectionBorders(paint_info, pagination_offset, | 63 PaintCollapsedSectionBorders(paint_info, pagination_offset, |
64 current_border_value); | 64 current_border_value); |
65 } else { | 65 } else { |
66 PaintSection(paint_info, pagination_offset); | 66 PaintSection(paint_info, pagination_offset); |
67 } | 67 } |
68 pagination_offset.Move(0, page_height.ToInt()); | 68 pagination_offset.Move(0, page_height.ToInt()); |
69 } | 69 } |
70 } | 70 } |
71 | 71 |
| 72 void TableSectionPainter::PaintRepeatingFooterGroup( |
| 73 const PaintInfo& paint_info, |
| 74 const LayoutPoint& paint_offset, |
| 75 const CollapsedBorderValue& current_border_value, |
| 76 ItemToPaint item_to_paint) { |
| 77 if (!layout_table_section_.IsRepeatingFooterGroup()) |
| 78 return; |
| 79 LayoutTable* table = layout_table_section_.Table(); |
| 80 LayoutRect sections_rect(LayoutPoint(), table->Size()); |
| 81 // Keep the top captions as we need top_offset to be |
| 82 // the offset from the top of table. |
| 83 table->SubtractCaptionRect(sections_rect, LayoutTable::BottomCaptionsOnly); |
| 84 LayoutUnit total_height_of_rows = |
| 85 sections_rect.Height() - table->OuterBorderBottom(); |
| 86 // The footer section may be at the top of a page. |
| 87 total_height_of_rows -= (layout_table_section_.LogicalHeight() - |
| 88 layout_table_section_.FirstRow()->PaginationStrut()); |
| 89 LayoutPoint top_offset = paint_offset; |
| 90 top_offset.Move(LayoutUnit(), -total_height_of_rows); |
| 91 IntRect cull_rect = paint_info.GetCullRect().rect_; |
| 92 cull_rect.Move(0, -total_height_of_rows.ToInt()); |
| 93 for (unsigned page = 0; page < table->PagesWithRepeatingFooters(); page++) { |
| 94 LayoutPoint pagination_offset = top_offset; |
| 95 LayoutUnit footer_position = |
| 96 table->GetPositionOfRepeatingFooterGroupOnPage(page); |
| 97 if (!footer_position) |
| 98 continue; |
| 99 pagination_offset.Move(LayoutUnit(), footer_position); |
| 100 if (item_to_paint == kPaintCollapsedBorders) { |
| 101 PaintCollapsedSectionBorders(paint_info, pagination_offset, |
| 102 current_border_value); |
| 103 } else { |
| 104 PaintSection(paint_info, pagination_offset); |
| 105 } |
| 106 } |
| 107 } |
| 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 } else if (table->Footer() == layout_table_section_) { |
| 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 | 166 |
126 return elem1->AbsoluteColumnIndex() < elem2->AbsoluteColumnIndex(); | 167 return elem1->AbsoluteColumnIndex() < elem2->AbsoluteColumnIndex(); |
127 } | 168 } |
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 } else if (table->Footer() == layout_table_section_) { |
| 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 |