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

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

Issue 2392353002: Move table cell height flexing into a separate method. (Closed)
Patch Set: Created 4 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/LayoutTableSection.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/LayoutTableSection.cpp
diff --git a/third_party/WebKit/Source/core/layout/LayoutTableSection.cpp b/third_party/WebKit/Source/core/layout/LayoutTableSection.cpp
index 94d4263d1d2d338a29a17a9e2ea44cd9f0a5dbd5..92276e205ca1bb27e1ecd5295c512f501b667dc8 100644
--- a/third_party/WebKit/Source/core/layout/LayoutTableSection.cpp
+++ b/third_party/WebKit/Source/core/layout/LayoutTableSection.cpp
@@ -1133,61 +1133,7 @@ void LayoutTableSection::layoutRows() {
int rHeight =
m_rowPos[rowIndex + cell->rowSpan()] - m_rowPos[rowIndex] - vspacing;
- // Force percent height children to lay themselves out again.
- // This will cause these children to grow to fill the cell.
- // FIXME: There is still more work to do here to fully match WinIE (should
- // it become necessary to do so). In quirks mode, WinIE behaves like we
- // do, but it will clip the cells that spill out of the table section. In
- // strict mode, Mozilla and WinIE both regrow the table to accommodate the
- // new height of the cell (thus letting the percentages cause growth one
- // time only). We may also not be handling row-spanning cells correctly.
- //
- // Note also the oddity where replaced elements always flex, and yet blocks/tables do
- // not necessarily flex. WinIE is crazy and inconsistent, and we can't hope to
- // match the behavior perfectly, but we'll continue to refine it as we discover new
- // bugs. :)
- bool cellChildrenFlex = false;
- bool flexAllChildren = cell->style()->logicalHeight().isFixed() ||
- (!table()->style()->logicalHeight().isAuto() &&
- rHeight != cell->logicalHeight());
-
- for (LayoutObject* child = cell->firstChild(); child;
- child = child->nextSibling()) {
- if (!child->isText() &&
- child->style()->logicalHeight().isPercentOrCalc() &&
- (flexAllChildren || shouldFlexCellChild(child)) &&
- (!child->isTable() || toLayoutTable(child)->hasSections())) {
- cellChildrenFlex = true;
- break;
- }
- }
-
- if (!cellChildrenFlex) {
- if (TrackedLayoutBoxListHashSet* percentHeightDescendants =
- cell->percentHeightDescendants()) {
- for (auto* descendant : *percentHeightDescendants) {
- if (flexAllChildren || shouldFlexCellChild(descendant)) {
- cellChildrenFlex = true;
- break;
- }
- }
- }
- }
-
- if (cellChildrenFlex) {
- // Alignment within a cell is based off the calculated
- // height, which becomes irrelevant once the cell has
- // been resized based off its percentage.
- cell->setOverrideLogicalContentHeightFromRowHeight(LayoutUnit(rHeight));
- cell->forceChildLayout();
-
- // If the baseline moved, we may have to update the data for our row. Find out the new baseline.
- if (cell->isBaselineAligned()) {
- int baseline = cell->cellBaselinePosition();
- if (baseline > cell->borderBefore() + cell->paddingBefore())
- m_grid[r].baseline = std::max(m_grid[r].baseline, baseline);
- }
- }
+ relayoutCellIfFlexed(*cell, r, rHeight);
SubtreeLayoutScope layouter(*cell);
cell->computeIntrinsicPadding(rHeight, layouter);
@@ -1900,6 +1846,66 @@ void LayoutTableSection::setLogicalPositionForCell(
cell->setLogicalLocation(cellLocation);
}
+void LayoutTableSection::relayoutCellIfFlexed(LayoutTableCell& cell,
+ int rowIndex,
+ int rowHeight) {
+ // Force percent height children to lay themselves out again.
+ // This will cause these children to grow to fill the cell.
+ // FIXME: There is still more work to do here to fully match WinIE (should
+ // it become necessary to do so). In quirks mode, WinIE behaves like we
+ // do, but it will clip the cells that spill out of the table section. In
+ // strict mode, Mozilla and WinIE both regrow the table to accommodate the
+ // new height of the cell (thus letting the percentages cause growth one
+ // time only). We may also not be handling row-spanning cells correctly.
+ //
+ // Note also the oddity where replaced elements always flex, and yet
+ // blocks/tables do not necessarily flex. WinIE is crazy and inconsistent,
+ // and we can't hope to match the behavior perfectly, but we'll continue to
+ // refine it as we discover new bugs. :)
+ bool cellChildrenFlex = false;
+ bool flexAllChildren = cell.style()->logicalHeight().isFixed() ||
+ (!table()->style()->logicalHeight().isAuto() &&
+ rowHeight != cell.logicalHeight());
+
+ for (LayoutObject* child = cell.firstChild(); child;
+ child = child->nextSibling()) {
+ if (!child->isText() && child->style()->logicalHeight().isPercentOrCalc() &&
+ (flexAllChildren || shouldFlexCellChild(child)) &&
+ (!child->isTable() || toLayoutTable(child)->hasSections())) {
+ cellChildrenFlex = true;
+ break;
+ }
+ }
+
+ if (!cellChildrenFlex) {
+ if (TrackedLayoutBoxListHashSet* percentHeightDescendants =
+ cell.percentHeightDescendants()) {
+ for (auto* descendant : *percentHeightDescendants) {
+ if (flexAllChildren || shouldFlexCellChild(descendant)) {
+ cellChildrenFlex = true;
+ break;
+ }
+ }
+ }
+ }
+
+ if (!cellChildrenFlex)
+ return;
+
+ // Alignment within a cell is based off the calculated height, which becomes
+ // irrelevant once the cell has been resized based off its percentage.
+ cell.setOverrideLogicalContentHeightFromRowHeight(LayoutUnit(rowHeight));
+ cell.forceChildLayout();
+
+ // If the baseline moved, we may have to update the data for our row. Find
+ // out the new baseline.
+ if (cell.isBaselineAligned()) {
+ int baseline = cell.cellBaselinePosition();
+ if (baseline > cell.borderBefore() + cell.paddingBefore())
+ m_grid[rowIndex].baseline = std::max(m_grid[rowIndex].baseline, baseline);
+ }
+}
+
bool LayoutTableSection::isRepeatingHeaderGroup() const {
if (getPaginationBreakability() == LayoutBox::AllowAnyBreaks)
return false;
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutTableSection.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698