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

Side by Side 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com) 4 * (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com)
5 * (C) 2005, 2006 Samuel Weinig (sam.weinig@gmail.com) 5 * (C) 2005, 2006 Samuel Weinig (sam.weinig@gmail.com)
6 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. 6 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc.
7 * All rights reserved. 7 * All rights reserved.
8 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved. 8 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved.
9 * 9 *
10 * This library is free software; you can redistribute it and/or 10 * This library is free software; you can redistribute it and/or
(...skipping 3167 matching lines...) Expand 10 before | Expand all | Expand 10 after
3178 containingBlockChild->containingBlockLogicalWidthForContent(); 3178 containingBlockChild->containingBlockLogicalWidthForContent();
3179 } else if (hasOverrideContainingBlockLogicalHeight()) { 3179 } else if (hasOverrideContainingBlockLogicalHeight()) {
3180 availableHeight = overrideContainingBlockContentLogicalHeight(); 3180 availableHeight = overrideContainingBlockContentLogicalHeight();
3181 } else if (cb->isTableCell()) { 3181 } else if (cb->isTableCell()) {
3182 if (!skippedAutoHeightContainingBlock) { 3182 if (!skippedAutoHeightContainingBlock) {
3183 // Table cells violate what the CSS spec says to do with heights. 3183 // Table cells violate what the CSS spec says to do with heights.
3184 // Basically we don't care if the cell specified a height or not. We just 3184 // Basically we don't care if the cell specified a height or not. We just
3185 // always make ourselves be a percentage of the cell's current content 3185 // always make ourselves be a percentage of the cell's current content
3186 // height. 3186 // height.
3187 if (!cb->hasOverrideLogicalContentHeight()) { 3187 if (!cb->hasOverrideLogicalContentHeight()) {
3188 // Normally we would let the cell size intrinsically, but scrolling 3188 // https://drafts.csswg.org/css-tables-3/#row-layout:
3189 // overflow has to be treated differently, since WinIE lets scrolled 3189 // For the purpose of calculating [the minimum height of a row],
3190 // overflow regions shrink as needed. 3190 // descendants of table cells whose height depends on percentages
3191 // While we can't get all cases right, we can at least detect when the 3191 // of their parent cell's height are considered to have an auto
3192 // cell has a specified height or when the table has a specified height. 3192 // height if they have overflow set to visible or hidden or if
3193 // In these cases we want to initially have no size and allow the 3193 // they are replaced elements, and a 0px height if they have not.
3194 // flexing of the table or the cell to its specified height to cause us
3195 // to grow to fill the space. This could end up being wrong in some
3196 // cases, but it is preferable to the alternative (sizing intrinsically
3197 // and making the row end up too big).
3198 LayoutTableCell* cell = toLayoutTableCell(cb); 3194 LayoutTableCell* cell = toLayoutTableCell(cb);
3195 bool treatAsReplaced = node() && node()->isElementNode() &&
eae 2016/12/12 19:55:19 Could you add a comment (or update the one above)
3196 (toElement(node())->isFormControlElement() ||
3197 isHTMLImageElement(toElement(node())));
3198 bool isReplaced = isAtomicInlineLevel() || treatAsReplaced;
3199 if (style()->overflowY() != OverflowVisible && 3199 if (style()->overflowY() != OverflowVisible &&
3200 style()->overflowY() != OverflowHidden && 3200 style()->overflowY() != OverflowHidden && !isReplaced &&
3201 (!cell->style()->logicalHeight().isAuto() || 3201 (!cell->style()->logicalHeight().isAuto() ||
3202 !cell->table()->style()->logicalHeight().isAuto())) 3202 !cell->table()->style()->logicalHeight().isAuto()))
3203 return LayoutUnit(); 3203 return LayoutUnit();
3204 return LayoutUnit(-1); 3204 return LayoutUnit(-1);
3205 } 3205 }
3206 availableHeight = cb->overrideLogicalContentHeight(); 3206 availableHeight = cb->overrideLogicalContentHeight();
3207 } 3207 }
3208 } else { 3208 } else {
3209 availableHeight = cb->availableLogicalHeightForPercentageComputation(); 3209 availableHeight = cb->availableLogicalHeightForPercentageComputation();
3210 } 3210 }
3211 3211
3212 if (availableHeight == -1) 3212 if (availableHeight == -1)
3213 return availableHeight; 3213 return availableHeight;
3214 3214
3215 availableHeight -= rootMarginBorderPaddingHeight; 3215 availableHeight -= rootMarginBorderPaddingHeight;
3216 3216
3217 if (isTable() && isOutOfFlowPositioned()) 3217 if (isTable() && isOutOfFlowPositioned())
3218 availableHeight += cb->paddingLogicalHeight(); 3218 availableHeight += cb->paddingLogicalHeight();
3219 3219
3220 LayoutUnit result = valueForLength(height, availableHeight); 3220 LayoutUnit result = valueForLength(height, availableHeight);
3221 bool includeBorderPadding = 3221 // |overrideLogicalContentHeight| is the maximum height made available by the
3222 // cell to its percent height children when we decide they can determine the
3223 // height of the cell. If the percent height child is box-sizing:content-box
3224 // then we must subtract the border and padding from the cell's
3225 // |availableHeight| (given by |overrideLogicalContentHeight|) to arrive
3226 // at the child's computed height.
3227 bool subtractBorderAndPadding =
3222 isTable() || (cb->isTableCell() && !skippedAutoHeightContainingBlock && 3228 isTable() || (cb->isTableCell() && !skippedAutoHeightContainingBlock &&
3223 cb->hasOverrideLogicalContentHeight()); 3229 cb->hasOverrideLogicalContentHeight() &&
3224 3230 style()->boxSizing() == BoxSizingContentBox);
3225 if (includeBorderPadding) { 3231 if (subtractBorderAndPadding) {
3226 // FIXME: Table cells should default to box-sizing: border-box so we can
3227 // avoid this hack.
3228 // It is necessary to use the border-box to match WinIE's broken
3229 // box model. This is essential for sizing inside
3230 // table cells using percentage heights.
3231 result -= borderAndPaddingLogicalHeight(); 3232 result -= borderAndPaddingLogicalHeight();
3232 return std::max(LayoutUnit(), result); 3233 return std::max(LayoutUnit(), result);
3233 } 3234 }
3234 return result; 3235 return result;
3235 } 3236 }
3236 3237
3237 LayoutUnit LayoutBox::computeReplacedLogicalWidth( 3238 LayoutUnit LayoutBox::computeReplacedLogicalWidth(
3238 ShouldComputePreferred shouldComputePreferred) const { 3239 ShouldComputePreferred shouldComputePreferred) const {
3239 return computeReplacedLogicalWidthRespectingMinMaxWidth( 3240 return computeReplacedLogicalWidthRespectingMinMaxWidth(
3240 computeReplacedLogicalWidthUsing(MainOrPreferredSize, 3241 computeReplacedLogicalWidthUsing(MainOrPreferredSize,
(...skipping 2411 matching lines...) Expand 10 before | Expand all | Expand 10 after
5652 LayoutRect rect = frameRect(); 5653 LayoutRect rect = frameRect();
5653 5654
5654 LayoutBlock* block = containingBlock(); 5655 LayoutBlock* block = containingBlock();
5655 if (block) 5656 if (block)
5656 block->adjustChildDebugRect(rect); 5657 block->adjustChildDebugRect(rect);
5657 5658
5658 return rect; 5659 return rect;
5659 } 5660 }
5660 5661
5661 } // namespace blink 5662 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698