Chromium Code Reviews| Index: third_party/WebKit/Source/core/layout/LayoutTable.cpp |
| diff --git a/third_party/WebKit/Source/core/layout/LayoutTable.cpp b/third_party/WebKit/Source/core/layout/LayoutTable.cpp |
| index c497b9f0b7e9942f166ea2cf6e0efa119e756892..431b273c49d5e5bb637b7364d6a6721ac9157e46 100644 |
| --- a/third_party/WebKit/Source/core/layout/LayoutTable.cpp |
| +++ b/third_party/WebKit/Source/core/layout/LayoutTable.cpp |
| @@ -66,7 +66,8 @@ LayoutTable::LayoutTable(Element* element) |
| m_hSpacing(0), |
| m_vSpacing(0), |
| m_borderStart(0), |
| - m_borderEnd(0) { |
| + m_borderEnd(0), |
| + m_oldAvailableLogicalHeight(0) { |
|
mstensho (USE GERRIT)
2017/02/20 13:01:31
No need (actually surprisingly expensive if you do
|
| ASSERT(!childrenInline()); |
| m_effectiveColumnPositions.fill(0, 1); |
| } |
| @@ -445,18 +446,22 @@ void LayoutTable::layoutCaption(LayoutTableCaption& caption, |
| void LayoutTable::layoutSection(LayoutTableSection& section, |
| SubtreeLayoutScope& layouter, |
| - LayoutUnit logicalLeft) { |
| + LayoutUnit logicalLeft, |
| + TableHeightChangingValue tableHeightChanging) { |
| section.setLogicalLocation(LayoutPoint(logicalLeft, logicalHeight())); |
| if (m_columnLogicalWidthChanged) |
| layouter.setChildNeedsLayout(§ion); |
| if (!section.needsLayout()) |
| markChildForPaginationRelayoutIfNeeded(section, layouter); |
| - section.layoutIfNeeded(); |
| - int sectionLogicalHeight = section.calcRowLogicalHeight(); |
| - section.setLogicalHeight(LayoutUnit(sectionLogicalHeight)); |
| + bool neededLayout = section.needsLayout(); |
| + if (neededLayout) |
| + section.layout(); |
| + if (neededLayout || tableHeightChanging == TableHeightChanging) |
| + section.setLogicalHeight(LayoutUnit(section.calcRowLogicalHeight())); |
| + |
| if (view()->layoutState()->isPaginated()) |
| updateFragmentationInfoForChild(section); |
| - setLogicalHeight(logicalHeight() + sectionLogicalHeight); |
| + setLogicalHeight(logicalHeight() + section.logicalHeight()); |
| } |
| LayoutUnit LayoutTable::logicalHeightFromStyle() const { |
| @@ -501,8 +506,8 @@ void LayoutTable::distributeExtraLogicalHeight(int extraLogicalHeight) { |
| extraLogicalHeight -= |
| section->distributeExtraLogicalHeightToRows(extraLogicalHeight); |
| - // FIXME: We really would like to enable this ASSERT to ensure that all the |
| - // extra space has been distributed. |
| + // crbug.com/690087: We really would like to enable this ASSERT to ensure that |
| + // all the extra space has been distributed. |
| // However our current distribution algorithm does not round properly and thus |
| // we can have some remaining height. |
| // ASSERT(!topSection() || !extraLogicalHeight); |
| @@ -623,10 +628,19 @@ void LayoutTable::layout() { |
| sectionLogicalLeft += |
| style()->isLeftToRightDirection() ? paddingStart() : paddingEnd(); |
| } |
| + LayoutUnit currentAvailableLogicalHeight = |
| + availableLogicalHeight(IncludeMarginBorderPadding); |
| + TableHeightChangingValue tableHeightChanging = |
| + m_oldAvailableLogicalHeight && |
| + m_oldAvailableLogicalHeight != currentAvailableLogicalHeight |
| + ? TableHeightChanging |
| + : TableHeightNotChanging; |
| + m_oldAvailableLogicalHeight = currentAvailableLogicalHeight; |
| // Lay out table header group. |
| if (LayoutTableSection* section = header()) { |
| - layoutSection(*section, layouter, sectionLogicalLeft); |
| + layoutSection(*section, layouter, sectionLogicalLeft, |
| + tableHeightChanging); |
| if (state.isPaginated()) { |
| // If the repeating header group allows at least one row of content, |
| // then store the offset for other sections to offset their rows |
| @@ -651,7 +665,8 @@ void LayoutTable::layout() { |
| if (child->isTableSection()) { |
| if (child != header() && child != footer()) { |
| LayoutTableSection& section = *toLayoutTableSection(child); |
| - layoutSection(section, layouter, sectionLogicalLeft); |
| + layoutSection(section, layouter, sectionLogicalLeft, |
| + tableHeightChanging); |
| } |
| } else if (child->isLayoutTableCol()) { |
| child->layoutIfNeeded(); |
| @@ -661,8 +676,10 @@ void LayoutTable::layout() { |
| } |
| // Lay out table footer. |
| - if (LayoutTableSection* section = footer()) |
| - layoutSection(*section, layouter, sectionLogicalLeft); |
| + if (LayoutTableSection* section = footer()) { |
| + layoutSection(*section, layouter, sectionLogicalLeft, |
| + tableHeightChanging); |
| + } |
| setLogicalHeight(tableBoxLogicalTop + borderAndPaddingBefore); |