Chromium Code Reviews| 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 = std::max(LayoutUnit(), cb->constrainContentBoxLogicalH eightByMinMax(contentBoxHeight - cb->scrollbarLogicalHeight(), LayoutUnit(-1))); | |
|
eae
2016/06/02 22:50:34
Please wrap this line. Also consider using clampNe
| |
| 2759 if (cb->isTableCell()) { | |
| 2760 includeBorderPadding = true; | |
| 2761 // We're sizing content to the height from the cell's style so don't involve the intrinsic padding used to align the content. | |
| 2762 availableHeight -= cb->computedCSSPaddingBefore() + cb->computedCSSP addingAfter() + cb->borderBefore() + cb->borderAfter(); | |
| 2763 } | |
| 2756 } else if (cb->isTableCell()) { | 2764 } else if (cb->isTableCell()) { |
| 2757 if (!skippedAutoHeightContainingBlock) { | 2765 if (!skippedAutoHeightContainingBlock) { |
| 2758 // Table cells violate what the CSS spec says to do with heights. Ba sically we | 2766 // 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 | 2767 // 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. | 2768 // be a percentage of the cell's current content height. |
| 2761 if (!cb->hasOverrideLogicalContentHeight()) { | 2769 if (!cb->hasOverrideLogicalContentHeight()) { |
| 2762 // Normally we would let the cell size intrinsically, but scroll ing overflow has to be | 2770 // 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. | 2771 // 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 | 2772 // 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 | 2773 // 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 | 2774 // 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 | 2775 // 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). | 2776 // preferable to the alternative (sizing intrinsically and makin g the row end up too big). |
| 2769 LayoutTableCell* cell = toLayoutTableCell(cb); | 2777 LayoutTableCell* cell = toLayoutTableCell(cb); |
| 2770 if (scrollsOverflowY() && (!cell->style()->logicalHeight().isAut o() || !cell->table()->style()->logicalHeight().isAuto())) | 2778 if (scrollsOverflowY() && (!cell->style()->logicalHeight().isAut o() || !cell->table()->style()->logicalHeight().isAuto())) |
| 2771 return LayoutUnit(); | 2779 return LayoutUnit(); |
| 2772 return LayoutUnit(-1); | 2780 return LayoutUnit(-1); |
| 2773 } | 2781 } |
| 2774 availableHeight = cb->overrideLogicalContentHeight(); | 2782 availableHeight = cb->overrideLogicalContentHeight(); |
| 2775 includeBorderPadding = true; | 2783 includeBorderPadding = true; |
| 2776 } | 2784 } |
| 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) { | 2785 } else if (cbstyle.logicalHeight().hasPercent() && !isOutOfFlowPositionedWit hSpecifiedHeight) { |
| 2781 // We need to recur and compute the percentage height for our containing block. | 2786 // We need to recur and compute the percentage height for our containing block. |
| 2782 LayoutUnit heightWithScrollbar = cb->computePercentageLogicalHeight(cbst yle.logicalHeight()); | 2787 LayoutUnit heightWithScrollbar = cb->computePercentageLogicalHeight(cbst yle.logicalHeight()); |
| 2783 if (heightWithScrollbar != -1) { | 2788 if (heightWithScrollbar != -1) { |
| 2784 LayoutUnit contentBoxHeightWithScrollbar = cb->adjustContentBoxLogic alHeightForBoxSizing(heightWithScrollbar); | 2789 LayoutUnit contentBoxHeightWithScrollbar = cb->adjustContentBoxLogic alHeightForBoxSizing(heightWithScrollbar); |
| 2785 // We need to adjust for min/max height because this method does not | 2790 // 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 | 2791 // 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 | 2792 // return value from the recursive call will not have been adjusted |
| 2788 // yet. | 2793 // yet. |
| 2789 LayoutUnit contentBoxHeight = cb->constrainContentBoxLogicalHeightBy MinMax(contentBoxHeightWithScrollbar - cb->scrollbarLogicalHeight(), LayoutUnit( -1)); | 2794 LayoutUnit contentBoxHeight = cb->constrainContentBoxLogicalHeightBy MinMax(contentBoxHeightWithScrollbar - cb->scrollbarLogicalHeight(), LayoutUnit( -1)); |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 2802 if (availableHeight == -1) | 2807 if (availableHeight == -1) |
| 2803 return availableHeight; | 2808 return availableHeight; |
| 2804 | 2809 |
| 2805 availableHeight -= rootMarginBorderPaddingHeight; | 2810 availableHeight -= rootMarginBorderPaddingHeight; |
| 2806 | 2811 |
| 2807 if (isTable() && isOutOfFlowPositioned()) | 2812 if (isTable() && isOutOfFlowPositioned()) |
| 2808 availableHeight += cb->paddingLogicalHeight(); | 2813 availableHeight += cb->paddingLogicalHeight(); |
| 2809 | 2814 |
| 2810 LayoutUnit result = valueForLength(height, availableHeight); | 2815 LayoutUnit result = valueForLength(height, availableHeight); |
| 2811 if (includeBorderPadding) { | 2816 if (includeBorderPadding) { |
| 2812 // FIXME: Table cells should default to box-sizing: border-box so we can avoid this hack. | 2817 // 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 | 2818 // whatever height the cell makes available. |
| 2814 // box model. This is essential for sizing inside | |
| 2815 // table cells using percentage heights. | |
| 2816 result -= borderAndPaddingLogicalHeight(); | 2819 result -= borderAndPaddingLogicalHeight(); |
| 2817 return std::max(LayoutUnit(), result); | 2820 return std::max(LayoutUnit(), result); |
| 2818 } | 2821 } |
| 2819 return result; | 2822 return result; |
| 2820 } | 2823 } |
| 2821 | 2824 |
| 2822 LayoutUnit LayoutBox::computeReplacedLogicalWidth(ShouldComputePreferred shouldC omputePreferred) const | 2825 LayoutUnit LayoutBox::computeReplacedLogicalWidth(ShouldComputePreferred shouldC omputePreferred) const |
| 2823 { | 2826 { |
| 2824 return computeReplacedLogicalWidthRespectingMinMaxWidth(computeReplacedLogic alWidthUsing(MainOrPreferredSize, style()->logicalWidth()), shouldComputePreferr ed); | 2827 return computeReplacedLogicalWidthRespectingMinMaxWidth(computeReplacedLogic alWidthUsing(MainOrPreferredSize, style()->logicalWidth()), shouldComputePreferr ed); |
| 2825 } | 2828 } |
| (...skipping 2111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4937 m_rareData->m_snapAreas->remove(&snapArea); | 4940 m_rareData->m_snapAreas->remove(&snapArea); |
| 4938 } | 4941 } |
| 4939 } | 4942 } |
| 4940 | 4943 |
| 4941 SnapAreaSet* LayoutBox::snapAreas() const | 4944 SnapAreaSet* LayoutBox::snapAreas() const |
| 4942 { | 4945 { |
| 4943 return m_rareData ? m_rareData->m_snapAreas.get() : nullptr; | 4946 return m_rareData ? m_rareData->m_snapAreas.get() : nullptr; |
| 4944 } | 4947 } |
| 4945 | 4948 |
| 4946 } // namespace blink | 4949 } // namespace blink |
| OLD | NEW |