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

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

Issue 2535173006: Percent height border-box content should get correct height in percent height cells (Closed)
Patch Set: bug 669867 Created 4 years 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
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 894f7d8e93f14ad42f8ad43f5a2f0513a35b4157..8f55e4b05398aecbe3fdd22a9b0ee81069807273 100644
--- a/third_party/WebKit/Source/core/layout/LayoutBox.cpp
+++ b/third_party/WebKit/Source/core/layout/LayoutBox.cpp
@@ -3185,19 +3185,19 @@ LayoutUnit LayoutBox::computePercentageLogicalHeight(
// always make ourselves be a percentage of the cell's current content
// height.
if (!cb->hasOverrideLogicalContentHeight()) {
- // Normally we would let the cell size intrinsically, but scrolling
- // overflow has to be treated differently, since WinIE lets scrolled
- // overflow regions shrink as needed.
- // While we can't get all cases right, we can at least detect when the
- // cell has a specified height or when the table has a specified height.
- // In these cases we want to initially have no size and allow the
- // flexing of the table or the cell to its specified height to cause us
- // to grow to fill the space. This could end up being wrong in some
- // cases, but it is preferable to the alternative (sizing intrinsically
- // and making the row end up too big).
+ // https://drafts.csswg.org/css-tables-3/#row-layout:
+ // For the purpose of calculating [the minimum height of a row],
+ // descendants of table cells whose height depends on percentages
+ // of their parent cell's height are considered to have an auto
+ // height if they have overflow set to visible or hidden or if
+ // they are replaced elements, and a 0px height if they have not.
LayoutTableCell* cell = toLayoutTableCell(cb);
+ bool treatAsReplaced = node() && node()->isElementNode() &&
eae 2016/12/12 19:55:19 Could you add a comment (or update the one above)
+ (toElement(node())->isFormControlElement() ||
+ isHTMLImageElement(toElement(node())));
+ bool isReplaced = isAtomicInlineLevel() || treatAsReplaced;
if (style()->overflowY() != OverflowVisible &&
- style()->overflowY() != OverflowHidden &&
+ style()->overflowY() != OverflowHidden && !isReplaced &&
(!cell->style()->logicalHeight().isAuto() ||
!cell->table()->style()->logicalHeight().isAuto()))
return LayoutUnit();
@@ -3218,16 +3218,17 @@ LayoutUnit LayoutBox::computePercentageLogicalHeight(
availableHeight += cb->paddingLogicalHeight();
LayoutUnit result = valueForLength(height, availableHeight);
- bool includeBorderPadding =
+ // |overrideLogicalContentHeight| is the maximum height made available by the
+ // cell to its percent height children when we decide they can determine the
+ // height of the cell. If the percent height child is box-sizing:content-box
+ // then we must subtract the border and padding from the cell's
+ // |availableHeight| (given by |overrideLogicalContentHeight|) to arrive
+ // at the child's computed height.
+ bool subtractBorderAndPadding =
isTable() || (cb->isTableCell() && !skippedAutoHeightContainingBlock &&
- cb->hasOverrideLogicalContentHeight());
-
- if (includeBorderPadding) {
- // FIXME: Table cells should default to box-sizing: border-box so we can
- // avoid this hack.
- // It is necessary to use the border-box to match WinIE's broken
- // box model. This is essential for sizing inside
- // table cells using percentage heights.
+ cb->hasOverrideLogicalContentHeight() &&
+ style()->boxSizing() == BoxSizingContentBox);
+ if (subtractBorderAndPadding) {
result -= borderAndPaddingLogicalHeight();
return std::max(LayoutUnit(), result);
}

Powered by Google App Engine
This is Rietveld 408576698