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

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

Issue 1277613004: A line that doesn't fit in a column shouldn't pull preceding floats to the next column. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 4 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
Index: Source/core/layout/LayoutBlockFlow.cpp
diff --git a/Source/core/layout/LayoutBlockFlow.cpp b/Source/core/layout/LayoutBlockFlow.cpp
index 2318e6c9ea19f7e7a9a3e50e027107ba06936955..cb5fd36327d94a14d684da0d80ef435084120eab 100644
--- a/Source/core/layout/LayoutBlockFlow.cpp
+++ b/Source/core/layout/LayoutBlockFlow.cpp
@@ -774,15 +774,42 @@ void LayoutBlockFlow::adjustLinePositionForPagination(RootInlineBox& lineBox, La
int lineIndex = lineCount(&lineBox);
if (remainingLogicalHeight < lineHeight || (shouldBreakAtLineToAvoidWidow() && lineBreakToAvoidWidow() == lineIndex)) {
+ // We need to insert a break now, either because there's no room for the line in the
+ // current column / page, or because we have determined that we need a break to satisfy
+ // widow requirements.
if (shouldBreakAtLineToAvoidWidow() && lineBreakToAvoidWidow() == lineIndex) {
clearShouldBreakAtLineToAvoidWidow();
setDidBreakAtLineToAvoidWidow();
}
- LayoutUnit totalLogicalHeight = lineHeight + std::max<LayoutUnit>(0, logicalOffset);
- LayoutUnit pageLogicalHeightAtNewOffset = pageLogicalHeightForOffset(logicalOffset + remainingLogicalHeight);
setPageBreak(logicalOffset, lineHeight - remainingLogicalHeight);
- if (((lineBox == firstRootBox() && totalLogicalHeight < pageLogicalHeightAtNewOffset) || (!style()->hasAutoOrphans() && style()->orphans() >= lineIndex))
- && !isOutOfFlowPositioned() && !isTableCell()) {
+ // Decide whether to insert the break before the current line, or before the entire block.
+ bool wantsStrutOnBlock = false;
+ if (!style()->hasAutoOrphans() && style()->orphans() >= lineIndex) {
leviw_travelin_and_unemployed 2015/08/10 19:46:19 It may be worth extracting this if/else block (det
mstensho (USE GERRIT) 2015/08/10 20:14:45 Done. That helper function got some papayawhip-co
+ // 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 == firstRootBox() && logicalOffset == borderAndPaddingBefore()) {
+ // 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.
+ LayoutUnit totalLogicalHeight = lineHeight + std::max<LayoutUnit>(0, logicalOffset);
+ LayoutUnit pageLogicalHeightAtNewOffset = pageLogicalHeightForOffset(logicalOffset + remainingLogicalHeight);
+ // 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 < pageLogicalHeightAtNewOffset)
+ wantsStrutOnBlock = true;
+ }
+ // If we want to break before the block, one final check is needed, since some block object
+ // types cannot handle struts.
+ if (wantsStrutOnBlock && !isOutOfFlowPositioned() && !isTableCell()) {
+ // Note that when setting the strut on a block, it may be propagated to parent blocks
+ // later on, if a block's logical top is flush with that of its parent. We don't want
+ // content-less portions (struts) at the beginning of a block before a break, if it can
+ // be avoided. After all, that's the reason for setting struts on blocks and not lines
+ // in the first place.
setPaginationStrut(remainingLogicalHeight + std::max<LayoutUnit>(0, logicalOffset));
} else {
delta += remainingLogicalHeight;

Powered by Google App Engine
This is Rietveld 408576698