Chromium Code Reviews| 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) { |