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

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

Issue 2356183002: Stay put at the top of the current page when inserting a forced break. (Closed)
Patch Set: Created 4 years, 3 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/Source/core/layout/LayoutBlock.cpp ('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 95ce2b15625130b5d768b377ee5d82c82c072180..c2738e0066e18ad8548e69d7a2b8d0f61af20661 100644
--- a/third_party/WebKit/Source/core/layout/LayoutBlockFlow.cpp
+++ b/third_party/WebKit/Source/core/layout/LayoutBlockFlow.cpp
@@ -1452,7 +1452,7 @@ LayoutUnit LayoutBlockFlow::collapseMargins(LayoutBox& child, MarginInfo& margin
LayoutState* layoutState = view()->layoutState();
if (layoutState->isPaginated() && isPageLogicalHeightKnown(beforeCollapseLogicalTop) && logicalTop > beforeCollapseLogicalTop) {
LayoutUnit oldLogicalTop = logicalTop;
- logicalTop = std::min(logicalTop, nextPageLogicalTop(beforeCollapseLogicalTop, AssociateWithLatterPage));
+ logicalTop = std::min(logicalTop, nextPageLogicalTop(beforeCollapseLogicalTop));
setLogicalHeight(logicalHeight() + (logicalTop - oldLogicalTop));
}
@@ -1677,7 +1677,7 @@ LayoutUnit LayoutBlockFlow::estimateLogicalTopPosition(LayoutBox& child, const B
// page.
LayoutState* layoutState = view()->layoutState();
if (layoutState->isPaginated() && isPageLogicalHeightKnown(logicalHeight()) && logicalTopEstimate > logicalHeight())
- logicalTopEstimate = std::min(logicalTopEstimate, nextPageLogicalTop(logicalHeight(), AssociateWithLatterPage));
+ logicalTopEstimate = std::min(logicalTopEstimate, nextPageLogicalTop(logicalHeight()));
logicalTopEstimate += getClearDelta(&child, logicalTopEstimate);
@@ -1887,13 +1887,19 @@ bool LayoutBlockFlow::mustSeparateMarginAfterForChild(const LayoutBox& child) co
LayoutUnit LayoutBlockFlow::applyForcedBreak(LayoutUnit logicalOffset, EBreak breakValue)
{
+ if (!isForcedFragmentainerBreakValue(breakValue))
+ return logicalOffset;
// TODO(mstensho): honor breakValue. There are different types of forced breaks. We currently
// just assume that we want to break to the top of the next fragmentainer of the fragmentation
// context we're in. However, we may want to find the next left or right page - even if we're
// inside a multicol container when printing.
- if (isForcedFragmentainerBreakValue(breakValue))
- return nextPageLogicalTop(logicalOffset, AssociateWithFormerPage);
- return logicalOffset;
+ LayoutUnit pageLogicalHeight = pageLogicalHeightForOffset(logicalOffset);
+ if (!pageLogicalHeight)
+ return logicalOffset; // Page height is still unknown, so we cannot insert forced breaks.
+ LayoutUnit remainingLogicalHeight = pageRemainingLogicalHeightForOffset(logicalOffset, AssociateWithLatterPage);
+ if (remainingLogicalHeight == pageLogicalHeight)
+ return logicalOffset; // Don't break if we're already at the block start of a fragmentainer.
+ return logicalOffset + remainingLogicalHeight;
}
void LayoutBlockFlow::setBreakBefore(EBreak breakValue)
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutBlock.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698