| 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 3147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3158 containingBlockChild->containingBlockLogicalWidthForContent(); | 3158 containingBlockChild->containingBlockLogicalWidthForContent(); |
| 3159 } else if (hasOverrideContainingBlockLogicalHeight()) { | 3159 } else if (hasOverrideContainingBlockLogicalHeight()) { |
| 3160 availableHeight = overrideContainingBlockContentLogicalHeight(); | 3160 availableHeight = overrideContainingBlockContentLogicalHeight(); |
| 3161 } else if (cb->isTableCell()) { | 3161 } else if (cb->isTableCell()) { |
| 3162 if (!skippedAutoHeightContainingBlock) { | 3162 if (!skippedAutoHeightContainingBlock) { |
| 3163 // Table cells violate what the CSS spec says to do with heights. | 3163 // Table cells violate what the CSS spec says to do with heights. |
| 3164 // Basically we don't care if the cell specified a height or not. We just | 3164 // Basically we don't care if the cell specified a height or not. We just |
| 3165 // always make ourselves be a percentage of the cell's current content | 3165 // always make ourselves be a percentage of the cell's current content |
| 3166 // height. | 3166 // height. |
| 3167 if (!cb->hasOverrideLogicalContentHeight()) { | 3167 if (!cb->hasOverrideLogicalContentHeight()) { |
| 3168 // Normally we would let the cell size intrinsically, but scrolling | 3168 // https://drafts.csswg.org/css-tables-3/#row-layout: |
| 3169 // overflow has to be treated differently, since WinIE lets scrolled | 3169 // For the purpose of calculating [the minimum height of a row], |
| 3170 // overflow regions shrink as needed. | 3170 // descendants of table cells whose height depends on percentages |
| 3171 // While we can't get all cases right, we can at least detect when the | 3171 // of their parent cell's height are considered to have an auto |
| 3172 // cell has a specified height or when the table has a specified height. | 3172 // height if they have overflow set to visible or hidden or if |
| 3173 // In these cases we want to initially have no size and allow the | 3173 // they are replaced elements, and a 0px height if they have not. |
| 3174 // flexing of the table or the cell to its specified height to cause us | |
| 3175 // to grow to fill the space. This could end up being wrong in some | |
| 3176 // cases, but it is preferable to the alternative (sizing intrinsically | |
| 3177 // and making the row end up too big). | |
| 3178 LayoutTableCell* cell = toLayoutTableCell(cb); | 3174 LayoutTableCell* cell = toLayoutTableCell(cb); |
| 3179 if (style()->overflowY() != OverflowVisible && | 3175 if (style()->overflowY() != OverflowVisible && |
| 3180 style()->overflowY() != OverflowHidden && | 3176 style()->overflowY() != OverflowHidden && |
| 3177 !shouldBeConsideredAsReplaced() && |
| 3181 (!cell->style()->logicalHeight().isAuto() || | 3178 (!cell->style()->logicalHeight().isAuto() || |
| 3182 !cell->table()->style()->logicalHeight().isAuto())) | 3179 !cell->table()->style()->logicalHeight().isAuto())) |
| 3183 return LayoutUnit(); | 3180 return LayoutUnit(); |
| 3184 return LayoutUnit(-1); | 3181 return LayoutUnit(-1); |
| 3185 } | 3182 } |
| 3186 availableHeight = cb->overrideLogicalContentHeight(); | 3183 availableHeight = cb->overrideLogicalContentHeight(); |
| 3187 } | 3184 } |
| 3188 } else { | 3185 } else { |
| 3189 availableHeight = cb->availableLogicalHeightForPercentageComputation(); | 3186 availableHeight = cb->availableLogicalHeightForPercentageComputation(); |
| 3190 } | 3187 } |
| 3191 | 3188 |
| 3192 if (availableHeight == -1) | 3189 if (availableHeight == -1) |
| 3193 return availableHeight; | 3190 return availableHeight; |
| 3194 | 3191 |
| 3195 availableHeight -= rootMarginBorderPaddingHeight; | 3192 availableHeight -= rootMarginBorderPaddingHeight; |
| 3196 | 3193 |
| 3197 if (isTable() && isOutOfFlowPositioned()) | 3194 if (isTable() && isOutOfFlowPositioned()) |
| 3198 availableHeight += cb->paddingLogicalHeight(); | 3195 availableHeight += cb->paddingLogicalHeight(); |
| 3199 | 3196 |
| 3200 LayoutUnit result = valueForLength(height, availableHeight); | 3197 LayoutUnit result = valueForLength(height, availableHeight); |
| 3201 bool includeBorderPadding = | 3198 // |overrideLogicalContentHeight| is the maximum height made available by the |
| 3199 // cell to its percent height children when we decide they can determine the |
| 3200 // height of the cell. If the percent height child is box-sizing:content-box |
| 3201 // then we must subtract the border and padding from the cell's |
| 3202 // |availableHeight| (given by |overrideLogicalContentHeight|) to arrive |
| 3203 // at the child's computed height. |
| 3204 bool subtractBorderAndPadding = |
| 3202 isTable() || (cb->isTableCell() && !skippedAutoHeightContainingBlock && | 3205 isTable() || (cb->isTableCell() && !skippedAutoHeightContainingBlock && |
| 3203 cb->hasOverrideLogicalContentHeight()); | 3206 cb->hasOverrideLogicalContentHeight() && |
| 3204 | 3207 style()->boxSizing() == BoxSizingContentBox); |
| 3205 if (includeBorderPadding) { | 3208 if (subtractBorderAndPadding) { |
| 3206 // FIXME: Table cells should default to box-sizing: border-box so we can | |
| 3207 // avoid this hack. | |
| 3208 // It is necessary to use the border-box to match WinIE's broken | |
| 3209 // box model. This is essential for sizing inside | |
| 3210 // table cells using percentage heights. | |
| 3211 result -= borderAndPaddingLogicalHeight(); | 3209 result -= borderAndPaddingLogicalHeight(); |
| 3212 return std::max(LayoutUnit(), result); | 3210 return std::max(LayoutUnit(), result); |
| 3213 } | 3211 } |
| 3214 return result; | 3212 return result; |
| 3215 } | 3213 } |
| 3216 | 3214 |
| 3217 LayoutUnit LayoutBox::computeReplacedLogicalWidth( | 3215 LayoutUnit LayoutBox::computeReplacedLogicalWidth( |
| 3218 ShouldComputePreferred shouldComputePreferred) const { | 3216 ShouldComputePreferred shouldComputePreferred) const { |
| 3219 return computeReplacedLogicalWidthRespectingMinMaxWidth( | 3217 return computeReplacedLogicalWidthRespectingMinMaxWidth( |
| 3220 computeReplacedLogicalWidthUsing(MainOrPreferredSize, | 3218 computeReplacedLogicalWidthUsing(MainOrPreferredSize, |
| (...skipping 1423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4644 bool LayoutBox::shrinkToAvoidFloats() const { | 4642 bool LayoutBox::shrinkToAvoidFloats() const { |
| 4645 // Floating objects don't shrink. Objects that don't avoid floats don't | 4643 // Floating objects don't shrink. Objects that don't avoid floats don't |
| 4646 // shrink. | 4644 // shrink. |
| 4647 if (isInline() || !avoidsFloats() || isFloating()) | 4645 if (isInline() || !avoidsFloats() || isFloating()) |
| 4648 return false; | 4646 return false; |
| 4649 | 4647 |
| 4650 // Only auto width objects can possibly shrink to avoid floats. | 4648 // Only auto width objects can possibly shrink to avoid floats. |
| 4651 return style()->width().isAuto(); | 4649 return style()->width().isAuto(); |
| 4652 } | 4650 } |
| 4653 | 4651 |
| 4654 static bool shouldBeConsideredAsReplaced(Node* node) { | 4652 DISABLE_CFI_PERF |
| 4653 bool LayoutBox::shouldBeConsideredAsReplaced() const { |
| 4655 // Checkboxes and radioboxes are not isAtomicInlineLevel() nor do they have | 4654 // Checkboxes and radioboxes are not isAtomicInlineLevel() nor do they have |
| 4656 // their own layoutObject in which to override avoidFloats(). | 4655 // their own layoutObject in which to override avoidFloats(). |
| 4656 if (isAtomicInlineLevel()) |
| 4657 return true; |
| 4658 Node* node = this->node(); |
| 4657 return node && node->isElementNode() && | 4659 return node && node->isElementNode() && |
| 4658 (toElement(node)->isFormControlElement() || | 4660 (toElement(node)->isFormControlElement() || |
| 4659 isHTMLImageElement(toElement(node))); | 4661 isHTMLImageElement(toElement(node))); |
| 4660 } | 4662 } |
| 4661 | 4663 |
| 4662 DISABLE_CFI_PERF | 4664 DISABLE_CFI_PERF |
| 4663 bool LayoutBox::avoidsFloats() const { | 4665 bool LayoutBox::avoidsFloats() const { |
| 4664 return isAtomicInlineLevel() || shouldBeConsideredAsReplaced(node()) || | 4666 return shouldBeConsideredAsReplaced() || hasOverflowClip() || isHR() || |
| 4665 hasOverflowClip() || isHR() || isLegend() || isWritingModeRoot() || | 4667 isLegend() || isWritingModeRoot() || isFlexItemIncludingDeprecated() || |
| 4666 isFlexItemIncludingDeprecated() || style()->containsPaint() || | 4668 style()->containsPaint() || style()->containsLayout(); |
| 4667 style()->containsLayout(); | |
| 4668 } | 4669 } |
| 4669 | 4670 |
| 4670 bool LayoutBox::hasNonCompositedScrollbars() const { | 4671 bool LayoutBox::hasNonCompositedScrollbars() const { |
| 4671 if (PaintLayerScrollableArea* scrollableArea = this->getScrollableArea()) { | 4672 if (PaintLayerScrollableArea* scrollableArea = this->getScrollableArea()) { |
| 4672 if (scrollableArea->hasHorizontalScrollbar() && | 4673 if (scrollableArea->hasHorizontalScrollbar() && |
| 4673 !scrollableArea->layerForHorizontalScrollbar()) | 4674 !scrollableArea->layerForHorizontalScrollbar()) |
| 4674 return true; | 4675 return true; |
| 4675 if (scrollableArea->hasVerticalScrollbar() && | 4676 if (scrollableArea->hasVerticalScrollbar() && |
| 4676 !scrollableArea->layerForVerticalScrollbar()) | 4677 !scrollableArea->layerForVerticalScrollbar()) |
| 4677 return true; | 4678 return true; |
| (...skipping 936 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5614 LayoutRect rect = frameRect(); | 5615 LayoutRect rect = frameRect(); |
| 5615 | 5616 |
| 5616 LayoutBlock* block = containingBlock(); | 5617 LayoutBlock* block = containingBlock(); |
| 5617 if (block) | 5618 if (block) |
| 5618 block->adjustChildDebugRect(rect); | 5619 block->adjustChildDebugRect(rect); |
| 5619 | 5620 |
| 5620 return rect; | 5621 return rect; |
| 5621 } | 5622 } |
| 5622 | 5623 |
| 5623 } // namespace blink | 5624 } // namespace blink |
| OLD | NEW |