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

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

Issue 1602773005: Respect break-inside:avoid on table rows (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Updated Created 4 years, 7 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: third_party/WebKit/Source/core/layout/LayoutBox.cpp
diff --git a/third_party/WebKit/Source/core/layout/LayoutBox.cpp b/third_party/WebKit/Source/core/layout/LayoutBox.cpp
index ffbe2f18715c4a113784f356381cfaaaeb5d4743..6db2cea6a4f3996d9bc4011380f32718ad99a124 100644
--- a/third_party/WebKit/Source/core/layout/LayoutBox.cpp
+++ b/third_party/WebKit/Source/core/layout/LayoutBox.cpp
@@ -4736,4 +4736,55 @@ void LayoutBox::clearPercentHeightDescendants()
}
}
+LayoutUnit LayoutBox::pageLogicalHeightForOffset(LayoutUnit offset) const
+{
+ LayoutView* layoutView = view();
+ LayoutFlowThread* flowThread = flowThreadContainingBlock();
+ if (!flowThread)
+ return layoutView->layoutState()->pageLogicalHeight();
+ return flowThread->pageLogicalHeightForOffset(offset + offsetFromLogicalTopOfFirstPage());
+}
+
+LayoutUnit LayoutBox::pageRemainingLogicalHeightForOffset(LayoutUnit offset, PageBoundaryRule pageBoundaryRule) const
+{
+ LayoutView* layoutView = view();
+ offset += offsetFromLogicalTopOfFirstPage();
+
+ LayoutFlowThread* flowThread = flowThreadContainingBlock();
+ if (!flowThread) {
+ LayoutUnit pageLogicalHeight = layoutView->layoutState()->pageLogicalHeight();
+ LayoutUnit remainingHeight = pageLogicalHeight - intMod(offset, pageLogicalHeight);
+ if (pageBoundaryRule == AssociateWithFormerPage) {
+ // An offset exactly at a page boundary will act as being part of the former page in
+ // question (i.e. no remaining space), rather than being part of the latter (i.e. one
+ // whole page length of remaining space).
+ remainingHeight = intMod(remainingHeight, pageLogicalHeight);
+ }
+ return remainingHeight;
+ }
+
+ return flowThread->pageRemainingLogicalHeightForOffset(offset, pageBoundaryRule);
+}
+
+LayoutUnit LayoutBox::calculatePaginationStrutToFitContent(LayoutUnit offset, LayoutUnit strutToNextPage, LayoutUnit contentLogicalHeight) const
+{
+ ASSERT(strutToNextPage == pageRemainingLogicalHeightForOffset(offset, AssociateWithLatterPage));
+ LayoutUnit nextPageLogicalTop = offset + strutToNextPage;
+ if (pageLogicalHeightForOffset(nextPageLogicalTop) >= contentLogicalHeight)
+ return strutToNextPage; // Content fits just fine in the next page or column.
+
+ // Moving to the top of the next page or column doesn't result in enough space for the content
+ // that we're trying to fit. If we're in a nested fragmentation context, we may find enough
+ // space if we move to a column further ahead, by effectively breaking to the next outer
+ // fragmentainer.
+ LayoutFlowThread* flowThread = flowThreadContainingBlock();
+ if (!flowThread) {
+ // If there's no flow thread, we're not nested. All pages have the same height. Give up.
+ return strutToNextPage;
+ }
+ // Start searching for a suitable offset at the top of the next page or column.
+ LayoutUnit flowThreadOffset = offsetFromLogicalTopOfFirstPage() + nextPageLogicalTop;
+ return strutToNextPage + flowThread->nextLogicalTopForUnbreakableContent(flowThreadOffset, contentLogicalHeight) - flowThreadOffset;
+}
+
} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutBox.h ('k') | third_party/WebKit/Source/core/layout/LayoutTableSection.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698