OLD | NEW |
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 Loading... |
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); |
3199 if (style()->overflowY() != EOverflow::Visible && | 3195 if (style()->overflowY() != EOverflow::Visible && |
3200 style()->overflowY() != EOverflow::Hidden && | 3196 style()->overflowY() != EOverflow::Hidden && |
| 3197 !shouldBeConsideredAsReplaced() && |
3201 (!cell->style()->logicalHeight().isAuto() || | 3198 (!cell->style()->logicalHeight().isAuto() || |
3202 !cell->table()->style()->logicalHeight().isAuto())) | 3199 !cell->table()->style()->logicalHeight().isAuto())) |
3203 return LayoutUnit(); | 3200 return LayoutUnit(); |
3204 return LayoutUnit(-1); | 3201 return LayoutUnit(-1); |
3205 } | 3202 } |
3206 availableHeight = cb->overrideLogicalContentHeight(); | 3203 availableHeight = cb->overrideLogicalContentHeight(); |
3207 } | 3204 } |
3208 } else { | 3205 } else { |
3209 availableHeight = cb->availableLogicalHeightForPercentageComputation(); | 3206 availableHeight = cb->availableLogicalHeightForPercentageComputation(); |
3210 } | 3207 } |
3211 | 3208 |
3212 if (availableHeight == -1) | 3209 if (availableHeight == -1) |
3213 return availableHeight; | 3210 return availableHeight; |
3214 | 3211 |
3215 availableHeight -= rootMarginBorderPaddingHeight; | 3212 availableHeight -= rootMarginBorderPaddingHeight; |
3216 | 3213 |
3217 if (isTable() && isOutOfFlowPositioned()) | 3214 if (isTable() && isOutOfFlowPositioned()) |
3218 availableHeight += cb->paddingLogicalHeight(); | 3215 availableHeight += cb->paddingLogicalHeight(); |
3219 | 3216 |
3220 LayoutUnit result = valueForLength(height, availableHeight); | 3217 LayoutUnit result = valueForLength(height, availableHeight); |
3221 bool includeBorderPadding = | 3218 // |overrideLogicalContentHeight| is the maximum height made available by the |
| 3219 // cell to its percent height children when we decide they can determine the |
| 3220 // height of the cell. If the percent height child is box-sizing:content-box |
| 3221 // then we must subtract the border and padding from the cell's |
| 3222 // |availableHeight| (given by |overrideLogicalContentHeight|) to arrive |
| 3223 // at the child's computed height. |
| 3224 bool subtractBorderAndPadding = |
3222 isTable() || (cb->isTableCell() && !skippedAutoHeightContainingBlock && | 3225 isTable() || (cb->isTableCell() && !skippedAutoHeightContainingBlock && |
3223 cb->hasOverrideLogicalContentHeight()); | 3226 cb->hasOverrideLogicalContentHeight() && |
3224 | 3227 style()->boxSizing() == BoxSizingContentBox); |
3225 if (includeBorderPadding) { | 3228 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(); | 3229 result -= borderAndPaddingLogicalHeight(); |
3232 return std::max(LayoutUnit(), result); | 3230 return std::max(LayoutUnit(), result); |
3233 } | 3231 } |
3234 return result; | 3232 return result; |
3235 } | 3233 } |
3236 | 3234 |
3237 LayoutUnit LayoutBox::computeReplacedLogicalWidth( | 3235 LayoutUnit LayoutBox::computeReplacedLogicalWidth( |
3238 ShouldComputePreferred shouldComputePreferred) const { | 3236 ShouldComputePreferred shouldComputePreferred) const { |
3239 return computeReplacedLogicalWidthRespectingMinMaxWidth( | 3237 return computeReplacedLogicalWidthRespectingMinMaxWidth( |
3240 computeReplacedLogicalWidthUsing(MainOrPreferredSize, | 3238 computeReplacedLogicalWidthUsing(MainOrPreferredSize, |
(...skipping 1424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4665 // Floating objects don't shrink. Objects that don't avoid floats don't | 4663 // Floating objects don't shrink. Objects that don't avoid floats don't |
4666 // shrink. | 4664 // shrink. |
4667 if (isInline() || !avoidsFloats() || isFloating()) | 4665 if (isInline() || !avoidsFloats() || isFloating()) |
4668 return false; | 4666 return false; |
4669 | 4667 |
4670 // Only auto width objects can possibly shrink to avoid floats. | 4668 // Only auto width objects can possibly shrink to avoid floats. |
4671 return style()->width().isAuto(); | 4669 return style()->width().isAuto(); |
4672 } | 4670 } |
4673 | 4671 |
4674 DISABLE_CFI_PERF | 4672 DISABLE_CFI_PERF |
4675 static bool shouldBeConsideredAsReplaced(Node* node) { | 4673 bool LayoutBox::shouldBeConsideredAsReplaced() const { |
4676 // Checkboxes and radioboxes are not isAtomicInlineLevel() nor do they have | 4674 // Checkboxes and radioboxes are not isAtomicInlineLevel() nor do they have |
4677 // their own layoutObject in which to override avoidFloats(). | 4675 // their own layoutObject in which to override avoidFloats(). |
| 4676 if (isAtomicInlineLevel()) |
| 4677 return true; |
| 4678 Node* node = this->node(); |
4678 return node && node->isElementNode() && | 4679 return node && node->isElementNode() && |
4679 (toElement(node)->isFormControlElement() || | 4680 (toElement(node)->isFormControlElement() || |
4680 isHTMLImageElement(toElement(node))); | 4681 isHTMLImageElement(toElement(node))); |
4681 } | 4682 } |
4682 | 4683 |
4683 DISABLE_CFI_PERF | 4684 DISABLE_CFI_PERF |
4684 bool LayoutBox::avoidsFloats() const { | 4685 bool LayoutBox::avoidsFloats() const { |
4685 return isAtomicInlineLevel() || shouldBeConsideredAsReplaced(node()) || | 4686 return shouldBeConsideredAsReplaced() || hasOverflowClip() || isHR() || |
4686 hasOverflowClip() || isHR() || isLegend() || isWritingModeRoot() || | 4687 isLegend() || isWritingModeRoot() || isFlexItemIncludingDeprecated() || |
4687 isFlexItemIncludingDeprecated() || style()->containsPaint() || | 4688 style()->containsPaint() || style()->containsLayout(); |
4688 style()->containsLayout(); | |
4689 } | 4689 } |
4690 | 4690 |
4691 bool LayoutBox::hasNonCompositedScrollbars() const { | 4691 bool LayoutBox::hasNonCompositedScrollbars() const { |
4692 if (PaintLayerScrollableArea* scrollableArea = this->getScrollableArea()) { | 4692 if (PaintLayerScrollableArea* scrollableArea = this->getScrollableArea()) { |
4693 if (scrollableArea->hasHorizontalScrollbar() && | 4693 if (scrollableArea->hasHorizontalScrollbar() && |
4694 !scrollableArea->layerForHorizontalScrollbar()) | 4694 !scrollableArea->layerForHorizontalScrollbar()) |
4695 return true; | 4695 return true; |
4696 if (scrollableArea->hasVerticalScrollbar() && | 4696 if (scrollableArea->hasVerticalScrollbar() && |
4697 !scrollableArea->layerForVerticalScrollbar()) | 4697 !scrollableArea->layerForVerticalScrollbar()) |
4698 return true; | 4698 return true; |
(...skipping 961 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5660 block->adjustChildDebugRect(rect); | 5660 block->adjustChildDebugRect(rect); |
5661 | 5661 |
5662 return rect; | 5662 return rect; |
5663 } | 5663 } |
5664 | 5664 |
5665 bool LayoutBox::shouldClipOverflow() const { | 5665 bool LayoutBox::shouldClipOverflow() const { |
5666 return hasOverflowClip() || styleRef().containsPaint() || hasControlClip(); | 5666 return hasOverflowClip() || styleRef().containsPaint() || hasControlClip(); |
5667 } | 5667 } |
5668 | 5668 |
5669 } // namespace blink | 5669 } // namespace blink |
OLD | NEW |