Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(725)

Side by Side Diff: third_party/WebKit/Source/core/layout/LayoutBlockFlow.cpp

Issue 2584143003: Repeat footers in paginated context (Closed)
Patch Set: bug 656232 Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 1121 matching lines...) Expand 10 before | Expand all | Expand 10 after
1132 line_box.SetIsFirstAfterPageBreak(false); 1132 line_box.SetIsFirstAfterPageBreak(false);
1133 LayoutState* layout_state = View()->GetLayoutState(); 1133 LayoutState* layout_state = View()->GetLayoutState();
1134 if (!layout_state->IsPaginated()) 1134 if (!layout_state->IsPaginated())
1135 return; 1135 return;
1136 if (!IsPageLogicalHeightKnown()) 1136 if (!IsPageLogicalHeightKnown())
1137 return; 1137 return;
1138 LayoutUnit page_logical_height = PageLogicalHeightForOffset(logical_offset); 1138 LayoutUnit page_logical_height = PageLogicalHeightForOffset(logical_offset);
1139 LayoutUnit remaining_logical_height = PageRemainingLogicalHeightForOffset( 1139 LayoutUnit remaining_logical_height = PageRemainingLogicalHeightForOffset(
1140 logical_offset, kAssociateWithLatterPage); 1140 logical_offset, kAssociateWithLatterPage);
1141 int line_index = LineCount(&line_box); 1141 int line_index = LineCount(&line_box);
1142 if (remaining_logical_height < line_height || 1142 // We need to detect if we overlap a repeating footer and if so take the
1143 // full remaining logical height as our strut to the next page.
1144 LayoutUnit remaining_logical_height_including_footer =
1145 remaining_logical_height - layout_state->HeightOffsetForTableFooters();
1146 if (remaining_logical_height_including_footer < line_height ||
1143 (ShouldBreakAtLineToAvoidWidow() && 1147 (ShouldBreakAtLineToAvoidWidow() &&
1144 LineBreakToAvoidWidow() == line_index)) { 1148 LineBreakToAvoidWidow() == line_index)) {
1145 LayoutUnit pagination_strut = CalculatePaginationStrutToFitContent( 1149 LayoutUnit pagination_strut = CalculatePaginationStrutToFitContent(
1146 logical_offset, remaining_logical_height, line_height); 1150 logical_offset, remaining_logical_height, line_height);
1147 LayoutUnit new_logical_offset = logical_offset + pagination_strut; 1151 LayoutUnit new_logical_offset = logical_offset + pagination_strut;
1148 // Moving to a different page or column may mean that its height is 1152 // Moving to a different page or column may mean that its height is
1149 // different. 1153 // different.
1150 page_logical_height = PageLogicalHeightForOffset(new_logical_offset); 1154 page_logical_height = PageLogicalHeightForOffset(new_logical_offset);
1151 if (line_height > page_logical_height) { 1155 if (line_height > page_logical_height) {
1152 // Too tall to fit in one page / column. Give up. Don't push to the next 1156 // Too tall to fit in one page / column. Give up. Don't push to the next
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
1239 return logical_offset; 1243 return logical_offset;
1240 LayoutUnit child_logical_height = LogicalHeightForChild(child); 1244 LayoutUnit child_logical_height = LogicalHeightForChild(child);
1241 // Floats' margins do not collapse with page or column boundaries. 1245 // Floats' margins do not collapse with page or column boundaries.
1242 if (child.IsFloating()) 1246 if (child.IsFloating())
1243 child_logical_height += 1247 child_logical_height +=
1244 MarginBeforeForChild(child) + MarginAfterForChild(child); 1248 MarginBeforeForChild(child) + MarginAfterForChild(child);
1245 if (!IsPageLogicalHeightKnown()) 1249 if (!IsPageLogicalHeightKnown())
1246 return logical_offset; 1250 return logical_offset;
1247 LayoutUnit remaining_logical_height = PageRemainingLogicalHeightForOffset( 1251 LayoutUnit remaining_logical_height = PageRemainingLogicalHeightForOffset(
1248 logical_offset, kAssociateWithLatterPage); 1252 logical_offset, kAssociateWithLatterPage);
1249 if (remaining_logical_height >= child_logical_height) 1253 LayoutUnit remaining_logical_height_including_footer =
1254 remaining_logical_height -
1255 View()->GetLayoutState()->HeightOffsetForTableFooters();
1256 if (remaining_logical_height_including_footer >= child_logical_height)
mstensho (USE GERRIT) 2017/07/17 10:38:08 Why can't PageRemainingLogicalHeightForOffset() do
rhogan 2017/07/24 18:56:06 Because, as well as deciding whether the line or b
mstensho (USE GERRIT) 2017/07/25 08:59:32 Ah, true. PageRemainingLogicalHeightForOffset() s
1250 return logical_offset; // It fits fine where it is. No need to break. 1257 return logical_offset; // It fits fine where it is. No need to break.
1251 LayoutUnit pagination_strut = CalculatePaginationStrutToFitContent( 1258 LayoutUnit pagination_strut = CalculatePaginationStrutToFitContent(
1252 logical_offset, remaining_logical_height, child_logical_height); 1259 logical_offset, remaining_logical_height, child_logical_height);
1253 if (pagination_strut == remaining_logical_height && 1260 if (pagination_strut == remaining_logical_height &&
1254 remaining_logical_height == PageLogicalHeightForOffset(logical_offset)) { 1261 remaining_logical_height == PageLogicalHeightForOffset(logical_offset)) {
1255 // Don't break if we were at the top of a page, and we failed to fit the 1262 // Don't break if we were at the top of a page, and we failed to fit the
1256 // content completely. No point in leaving a page completely blank. 1263 // content completely. No point in leaving a page completely blank.
1257 return logical_offset; 1264 return logical_offset;
1258 } 1265 }
1259 1266
(...skipping 3493 matching lines...) Expand 10 before | Expand all | Expand 10 after
4753 return LayoutBlock::DeprecatedInvalidatePaint(paint_invalidation_state); 4760 return LayoutBlock::DeprecatedInvalidatePaint(paint_invalidation_state);
4754 } 4761 }
4755 4762
4756 void LayoutBlockFlow::InvalidateDisplayItemClients( 4763 void LayoutBlockFlow::InvalidateDisplayItemClients(
4757 PaintInvalidationReason invalidation_reason) const { 4764 PaintInvalidationReason invalidation_reason) const {
4758 BlockFlowPaintInvalidator(*this).InvalidateDisplayItemClients( 4765 BlockFlowPaintInvalidator(*this).InvalidateDisplayItemClients(
4759 invalidation_reason); 4766 invalidation_reason);
4760 } 4767 }
4761 4768
4762 } // namespace blink 4769 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698