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. All rights reserv
ed. | 6 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserv
ed. |
7 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved. | 7 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved. |
8 * | 8 * |
9 * This library is free software; you can redistribute it and/or | 9 * This library is free software; you can redistribute it and/or |
10 * modify it under the terms of the GNU Library General Public | 10 * modify it under the terms of the GNU Library General Public |
(...skipping 2735 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2746 LayoutUnit stretchedFlexHeight(-1); | 2746 LayoutUnit stretchedFlexHeight(-1); |
2747 if (cb->isFlexItem()) | 2747 if (cb->isFlexItem()) |
2748 stretchedFlexHeight = toLayoutFlexibleBox(cb->parent())->childLogicalHei
ghtForPercentageResolution(*cb); | 2748 stretchedFlexHeight = toLayoutFlexibleBox(cb->parent())->childLogicalHei
ghtForPercentageResolution(*cb); |
2749 | 2749 |
2750 if (isHorizontalWritingMode() != cb->isHorizontalWritingMode()) { | 2750 if (isHorizontalWritingMode() != cb->isHorizontalWritingMode()) { |
2751 availableHeight = containingBlockChild->containingBlockLogicalWidthForCo
ntent(); | 2751 availableHeight = containingBlockChild->containingBlockLogicalWidthForCo
ntent(); |
2752 } else if (stretchedFlexHeight != LayoutUnit(-1)) { | 2752 } else if (stretchedFlexHeight != LayoutUnit(-1)) { |
2753 availableHeight = stretchedFlexHeight; | 2753 availableHeight = stretchedFlexHeight; |
2754 } else if (hasOverrideContainingBlockLogicalHeight()) { | 2754 } else if (hasOverrideContainingBlockLogicalHeight()) { |
2755 availableHeight = overrideContainingBlockContentLogicalHeight(); | 2755 availableHeight = overrideContainingBlockContentLogicalHeight(); |
| 2756 } else if (cbstyle.logicalHeight().isFixed()) { |
| 2757 LayoutUnit contentBoxHeight = cb->adjustContentBoxLogicalHeightForBoxSiz
ing(cbstyle.logicalHeight().value()); |
| 2758 availableHeight = cb->constrainContentBoxLogicalHeightByMinMax( |
| 2759 contentBoxHeight - cb->scrollbarLogicalHeight(), LayoutUnit(-1)).cla
mpNegativeToZero(); |
| 2760 if (cb->isTableCell()) { |
| 2761 includeBorderPadding = true; |
| 2762 // We're sizing content to the height from the cell's style so don't
involve the intrinsic padding used to align the content. |
| 2763 availableHeight -= cb->computedCSSPaddingBefore() + cb->computedCSSP
addingAfter() + cb->borderBefore() + cb->borderAfter(); |
| 2764 } |
2756 } else if (cb->isTableCell()) { | 2765 } else if (cb->isTableCell()) { |
2757 if (!skippedAutoHeightContainingBlock) { | 2766 if (!skippedAutoHeightContainingBlock) { |
2758 // Table cells violate what the CSS spec says to do with heights. Ba
sically we | 2767 // Table cells violate what the CSS spec says to do with heights. Ba
sically we |
2759 // don't care if the cell specified a height or not. We just always
make ourselves | 2768 // don't care if the cell specified a height or not. We just always
make ourselves |
2760 // be a percentage of the cell's current content height. | 2769 // be a percentage of the cell's current content height. |
2761 if (!cb->hasOverrideLogicalContentHeight()) { | 2770 if (!cb->hasOverrideLogicalContentHeight()) { |
2762 // Normally we would let the cell size intrinsically, but scroll
ing overflow has to be | 2771 // Normally we would let the cell size intrinsically, but scroll
ing overflow has to be |
2763 // treated differently, since WinIE lets scrolled overflow regio
ns shrink as needed. | 2772 // treated differently, since WinIE lets scrolled overflow regio
ns shrink as needed. |
2764 // While we can't get all cases right, we can at least detect wh
en the cell has a specified | 2773 // While we can't get all cases right, we can at least detect wh
en the cell has a specified |
2765 // height or when the table has a specified height. In these cas
es we want to initially have | 2774 // height or when the table has a specified height. In these cas
es we want to initially have |
2766 // no size and allow the flexing of the table or the cell to its
specified height to cause us | 2775 // no size and allow the flexing of the table or the cell to its
specified height to cause us |
2767 // to grow to fill the space. This could end up being wrong in s
ome cases, but it is | 2776 // to grow to fill the space. This could end up being wrong in s
ome cases, but it is |
2768 // preferable to the alternative (sizing intrinsically and makin
g the row end up too big). | 2777 // preferable to the alternative (sizing intrinsically and makin
g the row end up too big). |
2769 LayoutTableCell* cell = toLayoutTableCell(cb); | 2778 LayoutTableCell* cell = toLayoutTableCell(cb); |
2770 if (scrollsOverflowY() && (!cell->style()->logicalHeight().isAut
o() || !cell->table()->style()->logicalHeight().isAuto())) | 2779 if (scrollsOverflowY() && (!cell->style()->logicalHeight().isAut
o() || !cell->table()->style()->logicalHeight().isAuto())) |
2771 return LayoutUnit(); | 2780 return LayoutUnit(); |
2772 return LayoutUnit(-1); | 2781 return LayoutUnit(-1); |
2773 } | 2782 } |
2774 availableHeight = cb->overrideLogicalContentHeight(); | 2783 availableHeight = cb->overrideLogicalContentHeight(); |
2775 includeBorderPadding = true; | 2784 includeBorderPadding = true; |
2776 } | 2785 } |
2777 } else if (cbstyle.logicalHeight().isFixed()) { | |
2778 LayoutUnit contentBoxHeight = cb->adjustContentBoxLogicalHeightForBoxSiz
ing(LayoutUnit(cbstyle.logicalHeight().value())); | |
2779 availableHeight = std::max(LayoutUnit(), cb->constrainContentBoxLogicalH
eightByMinMax(contentBoxHeight - cb->scrollbarLogicalHeight(), LayoutUnit(-1))); | |
2780 } else if (cbstyle.logicalHeight().hasPercent() && !isOutOfFlowPositionedWit
hSpecifiedHeight) { | 2786 } else if (cbstyle.logicalHeight().hasPercent() && !isOutOfFlowPositionedWit
hSpecifiedHeight) { |
2781 // We need to recur and compute the percentage height for our containing
block. | 2787 // We need to recur and compute the percentage height for our containing
block. |
2782 LayoutUnit heightWithScrollbar = cb->computePercentageLogicalHeight(cbst
yle.logicalHeight()); | 2788 LayoutUnit heightWithScrollbar = cb->computePercentageLogicalHeight(cbst
yle.logicalHeight()); |
2783 if (heightWithScrollbar != -1) { | 2789 if (heightWithScrollbar != -1) { |
2784 LayoutUnit contentBoxHeightWithScrollbar = cb->adjustContentBoxLogic
alHeightForBoxSizing(heightWithScrollbar); | 2790 LayoutUnit contentBoxHeightWithScrollbar = cb->adjustContentBoxLogic
alHeightForBoxSizing(heightWithScrollbar); |
2785 // We need to adjust for min/max height because this method does not | 2791 // We need to adjust for min/max height because this method does not |
2786 // handle the min/max of the current block, its caller does. So the | 2792 // handle the min/max of the current block, its caller does. So the |
2787 // return value from the recursive call will not have been adjusted | 2793 // return value from the recursive call will not have been adjusted |
2788 // yet. | 2794 // yet. |
2789 LayoutUnit contentBoxHeight = cb->constrainContentBoxLogicalHeightBy
MinMax(contentBoxHeightWithScrollbar - cb->scrollbarLogicalHeight(), LayoutUnit(
-1)); | 2795 LayoutUnit contentBoxHeight = cb->constrainContentBoxLogicalHeightBy
MinMax(contentBoxHeightWithScrollbar - cb->scrollbarLogicalHeight(), LayoutUnit(
-1)); |
(...skipping 12 matching lines...) Expand all Loading... |
2802 if (availableHeight == -1) | 2808 if (availableHeight == -1) |
2803 return availableHeight; | 2809 return availableHeight; |
2804 | 2810 |
2805 availableHeight -= rootMarginBorderPaddingHeight; | 2811 availableHeight -= rootMarginBorderPaddingHeight; |
2806 | 2812 |
2807 if (isTable() && isOutOfFlowPositioned()) | 2813 if (isTable() && isOutOfFlowPositioned()) |
2808 availableHeight += cb->paddingLogicalHeight(); | 2814 availableHeight += cb->paddingLogicalHeight(); |
2809 | 2815 |
2810 LayoutUnit result = valueForLength(height, availableHeight); | 2816 LayoutUnit result = valueForLength(height, availableHeight); |
2811 if (includeBorderPadding) { | 2817 if (includeBorderPadding) { |
2812 // FIXME: Table cells should default to box-sizing: border-box so we can
avoid this hack. | 2818 // TODO(rhogan) crbug.com/467378: Doing this for content inside tables c
ells is wrong, it should fill |
2813 // It is necessary to use the border-box to match WinIE's broken | 2819 // whatever height the cell makes available. |
2814 // box model. This is essential for sizing inside | |
2815 // table cells using percentage heights. | |
2816 result -= borderAndPaddingLogicalHeight(); | 2820 result -= borderAndPaddingLogicalHeight(); |
2817 return std::max(LayoutUnit(), result); | 2821 return std::max(LayoutUnit(), result); |
2818 } | 2822 } |
2819 return result; | 2823 return result; |
2820 } | 2824 } |
2821 | 2825 |
2822 LayoutUnit LayoutBox::computeReplacedLogicalWidth(ShouldComputePreferred shouldC
omputePreferred) const | 2826 LayoutUnit LayoutBox::computeReplacedLogicalWidth(ShouldComputePreferred shouldC
omputePreferred) const |
2823 { | 2827 { |
2824 return computeReplacedLogicalWidthRespectingMinMaxWidth(computeReplacedLogic
alWidthUsing(MainOrPreferredSize, style()->logicalWidth()), shouldComputePreferr
ed); | 2828 return computeReplacedLogicalWidthRespectingMinMaxWidth(computeReplacedLogic
alWidthUsing(MainOrPreferredSize, style()->logicalWidth()), shouldComputePreferr
ed); |
2825 } | 2829 } |
(...skipping 2111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4937 m_rareData->m_snapAreas->remove(&snapArea); | 4941 m_rareData->m_snapAreas->remove(&snapArea); |
4938 } | 4942 } |
4939 } | 4943 } |
4940 | 4944 |
4941 SnapAreaSet* LayoutBox::snapAreas() const | 4945 SnapAreaSet* LayoutBox::snapAreas() const |
4942 { | 4946 { |
4943 return m_rareData ? m_rareData->m_snapAreas.get() : nullptr; | 4947 return m_rareData ? m_rareData->m_snapAreas.get() : nullptr; |
4944 } | 4948 } |
4945 | 4949 |
4946 } // namespace blink | 4950 } // namespace blink |
OLD | NEW |