Chromium Code Reviews| 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 e9d007419042c786cccfc583a3b5e339e3730c45..7fc961829af984d54d976e06f32377ff975b45fd 100644 |
| --- a/third_party/WebKit/Source/core/layout/LayoutBlockFlow.cpp |
| +++ b/third_party/WebKit/Source/core/layout/LayoutBlockFlow.cpp |
| @@ -41,6 +41,7 @@ |
| #include "core/layout/LayoutMultiColumnFlowThread.h" |
| #include "core/layout/LayoutMultiColumnSpannerPlaceholder.h" |
| #include "core/layout/LayoutPagedFlowThread.h" |
| +#include "core/layout/LayoutTableCell.h" |
| #include "core/layout/LayoutText.h" |
| #include "core/layout/LayoutView.h" |
| #include "core/layout/TextAutosizer.h" |
| @@ -720,10 +721,13 @@ LayoutUnit LayoutBlockFlow::adjustBlockChildForPagination(LayoutUnit logicalTop, |
| return newLogicalTop; |
| } |
| -static bool shouldSetStrutOnBlock(const LayoutBlockFlow& block, const RootInlineBox& lineBox, LayoutUnit lineLogicalOffset, int lineIndex, LayoutUnit pageLogicalHeight) |
| +static bool shouldSetStrutOnBlock(const LayoutBlockFlow& block, const RootInlineBox& lineBox, LayoutUnit lineLogicalOffset, int lineIndex, LayoutUnit pageLogicalHeight, LayoutUnit remainingLogicalHeight) |
| { |
| bool wantsStrutOnBlock = false; |
| - if (!block.style()->hasAutoOrphans() && block.style()->orphans() >= lineIndex) { |
| + // We avoid letting table cells straddle a page boundary unless the cell is taller than the page. |
| + if (block.isTableCell() && toLayoutTableCell(block).table()->vBorderSpacing() + block.logicalHeight() + remainingLogicalHeight < pageLogicalHeight) { |
|
mstensho (USE GERRIT)
2016/02/29 09:46:47
I'm sorry, but this just looks like a hack. While
|
| + wantsStrutOnBlock = true; |
| + } else if (!block.style()->hasAutoOrphans() && block.style()->orphans() >= lineIndex) { |
| // Not enough orphans here. Push the entire block to the next column / page as an |
| // attempt to better satisfy the orphans requirement. |
| wantsStrutOnBlock = true; |
| @@ -789,7 +793,7 @@ void LayoutBlockFlow::adjustLinePositionForPagination(RootInlineBox& lineBox, La |
| clearShouldBreakAtLineToAvoidWidow(); |
| setDidBreakAtLineToAvoidWidow(); |
| } |
| - if (shouldSetStrutOnBlock(*this, lineBox, logicalOffset, lineIndex, pageLogicalHeight)) { |
| + if (shouldSetStrutOnBlock(*this, lineBox, logicalOffset, lineIndex, pageLogicalHeight, remainingLogicalHeight)) { |
| // 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 |
| @@ -813,7 +817,7 @@ void LayoutBlockFlow::adjustLinePositionForPagination(RootInlineBox& lineBox, La |
| // case it's a float) margin, we may want to set a strut on the block, so that everything |
| // ends up in the next column or page. Setting a strut on the block is also important when |
| // it comes to satisfying orphan requirements. |
| - if (shouldSetStrutOnBlock(*this, lineBox, logicalOffset, lineIndex, pageLogicalHeight)) { |
| + if (shouldSetStrutOnBlock(*this, lineBox, logicalOffset, lineIndex, pageLogicalHeight, remainingLogicalHeight)) { |
| LayoutUnit strut = logicalOffset + marginBeforeIfFloating(); |
| setPaginationStrutPropagatedFromChild(strut); |
| } |
| @@ -2678,6 +2682,9 @@ bool LayoutBlockFlow::allowsPaginationStrut() const |
| // previous one. But currently we have no mechanism in place to handle this. |
| return false; |
| } |
| + if (isTableCell()) |
| + return true; |
| + |
| LayoutBlock* containingBlock = this->containingBlock(); |
| return containingBlock && containingBlock->isLayoutBlockFlow(); |
| } |