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

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

Issue 1393673004: Factor out the actual break checking from apply{After,Before}Break(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 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/LayoutBox.h ('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/LayoutBox.cpp
diff --git a/third_party/WebKit/Source/core/layout/LayoutBox.cpp b/third_party/WebKit/Source/core/layout/LayoutBox.cpp
index 44a9fa50f91c898bf44d533514833b1e572e60fe..6edc2d36c4f440de142283a88f0d9595b4d089cd 100644
--- a/third_party/WebKit/Source/core/layout/LayoutBox.cpp
+++ b/third_party/WebKit/Source/core/layout/LayoutBox.cpp
@@ -1779,6 +1779,46 @@ void LayoutBox::setPaginationStrut(LayoutUnit strut)
ensureRareData().m_paginationStrut = strut;
}
+static bool isForcedBreakAllowed(const LayoutBox* child)
+{
+ // We currently only support forced breaks on in-flow block level elements, which is the minimum
+ // requirement according to the spec.
+ if (child->isInline() || child->isFloatingOrOutOfFlowPositioned())
+ return false;
+ const LayoutBlock* curr = child->containingBlock();
+ if (!curr || !curr->isLayoutBlockFlow())
+ return false;
+ const LayoutView* layoutView = child->view();
+ while (curr && curr != layoutView) {
+ if (curr->isLayoutFlowThread())
+ return true;
+ if (curr->isFloatingOrOutOfFlowPositioned())
+ return false;
+ curr = curr->containingBlock();
+ }
+ return true;
+}
+
+bool LayoutBox::hasForcedBreakBefore() const
+{
+ LayoutFlowThread* flowThread = flowThreadContainingBlock();
+ bool checkColumnBreaks = flowThread;
+ bool checkPageBreaks = !checkColumnBreaks && view()->layoutState()->pageLogicalHeight(); // TODO(mstensho): Once columns can print, we have to check this.
leviw_travelin_and_unemployed 2015/10/08 08:29:14 Can you toss these TODO's on a different line?
+ bool checkBeforeAlways = (checkColumnBreaks && style()->columnBreakBefore() == PBALWAYS)
+ || (checkPageBreaks && style()->pageBreakBefore() == PBALWAYS);
+ return checkBeforeAlways && isForcedBreakAllowed(this);
+}
+
+bool LayoutBox::hasForcedBreakAfter() const
+{
+ LayoutFlowThread* flowThread = flowThreadContainingBlock();
+ bool checkColumnBreaks = flowThread;
+ bool checkPageBreaks = !checkColumnBreaks && view()->layoutState()->pageLogicalHeight(); // TODO(mstensho): Once columns can print, we have to check this.
leviw_travelin_and_unemployed 2015/10/08 08:29:14 Same as above.
+ bool checkAfterAlways = (checkColumnBreaks && style()->columnBreakAfter() == PBALWAYS)
leviw_travelin_and_unemployed 2015/10/08 08:29:14 We should really rename these enums, unless we wan
+ || (checkPageBreaks && style()->pageBreakAfter() == PBALWAYS);
+ return checkAfterAlways && isForcedBreakAllowed(this);
+}
+
LayoutRect LayoutBox::clippedOverflowRectForPaintInvalidation(const LayoutBoxModelObject* paintInvalidationContainer, const PaintInvalidationState* paintInvalidationState) const
{
if (style()->visibility() != VISIBLE) {
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutBox.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698