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

Unified Diff: third_party/WebKit/Source/core/layout/LayoutBlockFlow.cpp

Issue 1908643003: Prioritize first-lines over orphans when deciding whether to propagate a strut. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/LayoutTests/fragmentation/block-with-float-and-1-orphaned-line-expected.txt ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/layout/LayoutBlockFlow.cpp
diff --git a/third_party/WebKit/Source/core/layout/LayoutBlockFlow.cpp b/third_party/WebKit/Source/core/layout/LayoutBlockFlow.cpp
index 8eb135ee1321d7e0af1339975e75480165e35f3a..41e68517f1d4ebfa8931d9935df53db3b1a21006 100644
--- a/third_party/WebKit/Source/core/layout/LayoutBlockFlow.cpp
+++ b/third_party/WebKit/Source/core/layout/LayoutBlockFlow.cpp
@@ -798,26 +798,37 @@ LayoutUnit LayoutBlockFlow::adjustBlockChildForPagination(LayoutUnit logicalTop,
static bool shouldSetStrutOnBlock(const LayoutBlockFlow& block, const RootInlineBox& lineBox, LayoutUnit lineLogicalOffset, int lineIndex, LayoutUnit pageLogicalHeight)
{
- bool wantsStrutOnBlock = false;
- if (!block.style()->hasAutoOrphans() && block.style()->orphans() >= lineIndex) {
- // Not enough orphans here. Push the entire block to the next column / page as an
- // attempt to better satisfy the orphans requirement.
- wantsStrutOnBlock = true;
- } else if (lineBox == block.firstRootBox() && lineLogicalOffset == block.borderAndPaddingBefore()) {
+ if (lineBox == block.firstRootBox()) {
// This is the first line in the block. We can take the whole block with us to the next page
// or column, rather than keeping a content-less portion of it in the previous one. Only do
// this if the line is flush with the content edge of the block, though. If it isn't, it
// means that the line was pushed downwards by preceding floats that didn't fit beside the
// line, and we don't want to move all that, since it has already been established that it
- // fits nicely where it is.
+ // fits nicely where it is. In this case we have a class "C" break point [1] in front of
+ // this line.
+ //
+ // [1] https://drafts.csswg.org/css-break/#possible-breaks
+ if (lineLogicalOffset > block.borderAndPaddingBefore())
+ return false;
+
LayoutUnit lineHeight = lineBox.lineBottomWithLeading() - lineBox.lineTopWithLeading();
LayoutUnit totalLogicalHeight = lineHeight + lineLogicalOffset.clampNegativeToZero();
// It's rather pointless to break before the block if the current line isn't going to
// fit in the same column or page, so check that as well.
- if (totalLogicalHeight <= pageLogicalHeight)
- wantsStrutOnBlock = true;
+ if (totalLogicalHeight > pageLogicalHeight)
+ return false;
+ } else {
+ if (block.style()->hasAutoOrphans() || lineIndex > block.style()->orphans())
+ return false;
+
+ // Not enough orphans here. Push the entire block to the next column / page as an attempt to
+ // better satisfy the orphans requirement.
+ //
+ // Note that we should ideally check if the first line in the block is flush with the
+ // content edge of the block here, because if it isn't, we should break at the class "C"
+ // break point in front of the first line, rather than before the entire block.
}
- return wantsStrutOnBlock && block.allowsPaginationStrut();
+ return block.allowsPaginationStrut();
}
void LayoutBlockFlow::adjustLinePositionForPagination(RootInlineBox& lineBox, LayoutUnit& delta)
« no previous file with comments | « third_party/WebKit/LayoutTests/fragmentation/block-with-float-and-1-orphaned-line-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698