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 2678 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2689 // objects, such as table-cells, will be treated just as if they were non-an onymous. | 2689 // objects, such as table-cells, will be treated just as if they were non-an onymous. |
2690 if (containingBlock->isAnonymous()) { | 2690 if (containingBlock->isAnonymous()) { |
2691 EDisplay display = containingBlock->styleRef().display(); | 2691 EDisplay display = containingBlock->styleRef().display(); |
2692 return display == BLOCK || display == INLINE_BLOCK; | 2692 return display == BLOCK || display == INLINE_BLOCK; |
2693 } | 2693 } |
2694 | 2694 |
2695 // For quirks mode, we skip most auto-height containing blocks when computin g percentages. | 2695 // For quirks mode, we skip most auto-height containing blocks when computin g percentages. |
2696 return document().inQuirksMode() && !containingBlock->isTableCell() && !cont ainingBlock->isOutOfFlowPositioned() && !containingBlock->isLayoutGrid() && cont ainingBlock->style()->logicalHeight().isAuto(); | 2696 return document().inQuirksMode() && !containingBlock->isTableCell() && !cont ainingBlock->isOutOfFlowPositioned() && !containingBlock->isLayoutGrid() && cont ainingBlock->style()->logicalHeight().isAuto(); |
2697 } | 2697 } |
2698 | 2698 |
2699 LayoutUnit LayoutBox::computePercentageLogicalHeight(const Length& height) const | 2699 LayoutUnit LayoutBox::availableLogicalHeightForPercentageComputation(const Layou tBlock* cb, bool skippedAutoHeightContainingBlock, bool scrollsOverflowY) |
jfernandez
2016/07/18 06:13:24
I find it weird how we use the skippedAutoHeightCo
svillar
2016/07/18 08:43:30
Agree with jfernandez, this is related to the fact
Manuel Rego
2016/07/19 13:12:32
Yeah, I've redo the patch and have removed the boo
| |
2700 { | 2700 { |
2701 LayoutUnit availableHeight(-1); | 2701 LayoutUnit availableHeight = LayoutUnit(-1); |
2702 | |
2703 bool skippedAutoHeightContainingBlock = false; | |
2704 LayoutBlock* cb = containingBlock(); | |
2705 const LayoutBox* containingBlockChild = this; | |
2706 LayoutUnit rootMarginBorderPaddingHeight; | |
2707 while (!cb->isLayoutView() && skipContainingBlockForPercentHeightCalculation (cb)) { | |
2708 if (cb->isBody() || cb->isDocumentElement()) | |
2709 rootMarginBorderPaddingHeight += cb->marginBefore() + cb->marginAfte r() + cb->borderAndPaddingLogicalHeight(); | |
2710 skippedAutoHeightContainingBlock = true; | |
2711 containingBlockChild = cb; | |
2712 cb = cb->containingBlock(); | |
2713 } | |
2714 cb->addPercentHeightDescendant(const_cast<LayoutBox*>(this)); | |
2715 | 2702 |
2716 const ComputedStyle& cbstyle = cb->styleRef(); | 2703 const ComputedStyle& cbstyle = cb->styleRef(); |
2717 | 2704 |
2718 // A positioned element that specified both top/bottom or that specifies hei ght should be treated as though it has a height | 2705 // A positioned element that specified both top/bottom or that specifies hei ght should be treated as though it has a height |
2719 // explicitly specified that can be used for any percentage computations. | 2706 // explicitly specified that can be used for any percentage computations. |
2720 bool isOutOfFlowPositionedWithSpecifiedHeight = cb->isOutOfFlowPositioned() && (!cbstyle.logicalHeight().isAuto() || (!cbstyle.logicalTop().isAuto() && !cbs tyle.logicalBottom().isAuto())); | 2707 bool isOutOfFlowPositionedWithSpecifiedHeight = cb->isOutOfFlowPositioned() && (!cbstyle.logicalHeight().isAuto() || (!cbstyle.logicalTop().isAuto() && !cbs tyle.logicalBottom().isAuto())); |
2721 | 2708 |
2722 bool includeBorderPadding = isTable(); | |
2723 | |
2724 LayoutUnit stretchedFlexHeight(-1); | 2709 LayoutUnit stretchedFlexHeight(-1); |
2725 if (cb->isFlexItem()) | 2710 if (cb->isFlexItem()) |
2726 stretchedFlexHeight = toLayoutFlexibleBox(cb->parent())->childLogicalHei ghtForPercentageResolution(*cb); | 2711 stretchedFlexHeight = toLayoutFlexibleBox(cb->parent())->childLogicalHei ghtForPercentageResolution(*cb); |
2727 | 2712 |
2728 if (isHorizontalWritingMode() != cb->isHorizontalWritingMode()) { | 2713 if (stretchedFlexHeight != LayoutUnit(-1)) { |
2729 availableHeight = containingBlockChild->containingBlockLogicalWidthForCo ntent(); | |
2730 } else if (stretchedFlexHeight != LayoutUnit(-1)) { | |
2731 availableHeight = stretchedFlexHeight; | 2714 availableHeight = stretchedFlexHeight; |
2732 } else if (hasOverrideContainingBlockLogicalHeight() && !isOutOfFlowPosition edWithSpecifiedHeight) { | |
2733 availableHeight = overrideContainingBlockContentLogicalHeight(); | |
2734 } else if (cb->isGridItem() && cb->hasOverrideLogicalContentHeight()) { | 2715 } else if (cb->isGridItem() && cb->hasOverrideLogicalContentHeight()) { |
2735 availableHeight = cb->overrideLogicalContentHeight(); | 2716 availableHeight = cb->overrideLogicalContentHeight(); |
2736 } else if (cbstyle.logicalHeight().isFixed()) { | 2717 } else if (cbstyle.logicalHeight().isFixed()) { |
2737 LayoutUnit contentBoxHeight = cb->adjustContentBoxLogicalHeightForBoxSiz ing(cbstyle.logicalHeight().value()); | 2718 LayoutUnit contentBoxHeight = cb->adjustContentBoxLogicalHeightForBoxSiz ing(cbstyle.logicalHeight().value()); |
2738 availableHeight = cb->constrainContentBoxLogicalHeightByMinMax( | 2719 availableHeight = cb->constrainContentBoxLogicalHeightByMinMax( |
2739 contentBoxHeight - cb->scrollbarLogicalHeight(), LayoutUnit(-1)).cla mpNegativeToZero(); | 2720 contentBoxHeight - cb->scrollbarLogicalHeight(), LayoutUnit(-1)).cla mpNegativeToZero(); |
2740 if (cb->isTableCell()) | |
2741 includeBorderPadding = true; | |
2742 } else if (cb->isTableCell()) { | 2721 } else if (cb->isTableCell()) { |
2743 if (!skippedAutoHeightContainingBlock) { | 2722 if (!skippedAutoHeightContainingBlock) { |
2744 // Table cells violate what the CSS spec says to do with heights. Ba sically we | 2723 // Table cells violate what the CSS spec says to do with heights. Ba sically we |
2745 // don't care if the cell specified a height or not. We just always make ourselves | 2724 // don't care if the cell specified a height or not. We just always make ourselves |
2746 // be a percentage of the cell's current content height. | 2725 // be a percentage of the cell's current content height. |
2747 if (!cb->hasOverrideLogicalContentHeight()) { | 2726 if (!cb->hasOverrideLogicalContentHeight()) { |
2748 // Normally we would let the cell size intrinsically, but scroll ing overflow has to be | 2727 // Normally we would let the cell size intrinsically, but scroll ing overflow has to be |
2749 // treated differently, since WinIE lets scrolled overflow regio ns shrink as needed. | 2728 // treated differently, since WinIE lets scrolled overflow regio ns shrink as needed. |
2750 // While we can't get all cases right, we can at least detect wh en the cell has a specified | 2729 // While we can't get all cases right, we can at least detect wh en the cell has a specified |
2751 // height or when the table has a specified height. In these cas es we want to initially have | 2730 // height or when the table has a specified height. In these cas es we want to initially have |
2752 // no size and allow the flexing of the table or the cell to its specified height to cause us | 2731 // no size and allow the flexing of the table or the cell to its specified height to cause us |
2753 // to grow to fill the space. This could end up being wrong in s ome cases, but it is | 2732 // to grow to fill the space. This could end up being wrong in s ome cases, but it is |
2754 // preferable to the alternative (sizing intrinsically and makin g the row end up too big). | 2733 // preferable to the alternative (sizing intrinsically and makin g the row end up too big). |
2755 LayoutTableCell* cell = toLayoutTableCell(cb); | 2734 const LayoutTableCell* cell = toLayoutTableCell(cb); |
jfernandez
2016/07/18 06:13:24
Why do you need the cell to be const here ?
Manuel Rego
2016/07/19 13:12:32
This was not needed, just slipped into the patch.
| |
2756 if (scrollsOverflowY() && (!cell->style()->logicalHeight().isAut o() || !cell->table()->style()->logicalHeight().isAuto())) | 2735 if (scrollsOverflowY && (!cell->style()->logicalHeight().isAuto( ) || !cell->table()->style()->logicalHeight().isAuto())) |
2757 return LayoutUnit(); | 2736 return LayoutUnit(); |
2758 return LayoutUnit(-1); | 2737 return LayoutUnit(-1); |
2759 } | 2738 } |
2760 availableHeight = cb->overrideLogicalContentHeight(); | 2739 availableHeight = cb->overrideLogicalContentHeight(); |
2761 includeBorderPadding = true; | |
2762 } | 2740 } |
2763 } else if (cbstyle.logicalHeight().hasPercent() && !isOutOfFlowPositionedWit hSpecifiedHeight) { | 2741 } else if (cbstyle.logicalHeight().hasPercent() && !isOutOfFlowPositionedWit hSpecifiedHeight) { |
2764 // We need to recur and compute the percentage height for our containing block. | 2742 // We need to recur and compute the percentage height for our containing block. |
2765 LayoutUnit heightWithScrollbar = cb->computePercentageLogicalHeight(cbst yle.logicalHeight()); | 2743 LayoutUnit heightWithScrollbar = cb->computePercentageLogicalHeight(cbst yle.logicalHeight()); |
2766 if (heightWithScrollbar != -1) { | 2744 if (heightWithScrollbar != -1) { |
2767 LayoutUnit contentBoxHeightWithScrollbar = cb->adjustContentBoxLogic alHeightForBoxSizing(heightWithScrollbar); | 2745 LayoutUnit contentBoxHeightWithScrollbar = cb->adjustContentBoxLogic alHeightForBoxSizing(heightWithScrollbar); |
2768 // We need to adjust for min/max height because this method does not | 2746 // We need to adjust for min/max height because this method does not |
2769 // handle the min/max of the current block, its caller does. So the | 2747 // handle the min/max of the current block, its caller does. So the |
2770 // return value from the recursive call will not have been adjusted | 2748 // return value from the recursive call will not have been adjusted |
2771 // yet. | 2749 // yet. |
2772 LayoutUnit contentBoxHeight = cb->constrainContentBoxLogicalHeightBy MinMax(contentBoxHeightWithScrollbar - cb->scrollbarLogicalHeight(), LayoutUnit( -1)); | 2750 LayoutUnit contentBoxHeight = cb->constrainContentBoxLogicalHeightBy MinMax(contentBoxHeightWithScrollbar - cb->scrollbarLogicalHeight(), LayoutUnit( -1)); |
2773 availableHeight = std::max(LayoutUnit(), contentBoxHeight); | 2751 availableHeight = std::max(LayoutUnit(), contentBoxHeight); |
2774 } | 2752 } |
2775 } else if (isOutOfFlowPositionedWithSpecifiedHeight) { | 2753 } else if (isOutOfFlowPositionedWithSpecifiedHeight) { |
2776 // Don't allow this to affect the block' size() member variable, since t his | 2754 // Don't allow this to affect the block' size() member variable, since t his |
2777 // can get called while the block is still laying out its kids. | 2755 // can get called while the block is still laying out its kids. |
2778 LogicalExtentComputedValues computedValues; | 2756 LogicalExtentComputedValues computedValues; |
2779 cb->computeLogicalHeight(cb->logicalHeight(), LayoutUnit(), computedValu es); | 2757 cb->computeLogicalHeight(cb->logicalHeight(), LayoutUnit(), computedValu es); |
2780 availableHeight = computedValues.m_extent - cb->borderAndPaddingLogicalH eight() - cb->scrollbarLogicalHeight(); | 2758 availableHeight = computedValues.m_extent - cb->borderAndPaddingLogicalH eight() - cb->scrollbarLogicalHeight(); |
2781 } else if (cb->isLayoutView()) { | 2759 } else if (cb->isLayoutView()) { |
2782 availableHeight = view()->viewLogicalHeightForPercentages(); | 2760 availableHeight = toLayoutView(cb)->viewLogicalHeightForPercentages(); |
svillar
2016/07/18 08:43:30
why this?
Manuel Rego
2016/07/19 13:12:32
This was because it's a static method so I couldn'
| |
2783 } | 2761 } |
2784 | 2762 |
2785 if (availableHeight == -1) | 2763 if (availableHeight == -1) |
2786 return availableHeight; | 2764 return availableHeight; |
2765 | |
2766 return availableHeight; | |
2767 } | |
2768 | |
2769 LayoutUnit LayoutBox::computePercentageLogicalHeight(const Length& height) const | |
2770 { | |
2771 LayoutBlock* cb = containingBlock(); | |
2772 const LayoutBox* containingBlockChild = this; | |
2773 bool skippedAutoHeightContainingBlock = false; | |
2774 LayoutUnit rootMarginBorderPaddingHeight; | |
2775 while (!cb->isLayoutView() && skipContainingBlockForPercentHeightCalculation (cb)) { | |
2776 if (cb->isBody() || cb->isDocumentElement()) | |
2777 rootMarginBorderPaddingHeight += cb->marginBefore() + cb->marginAfte r() + cb->borderAndPaddingLogicalHeight(); | |
2778 skippedAutoHeightContainingBlock = true; | |
2779 containingBlockChild = cb; | |
2780 cb = cb->containingBlock(); | |
2781 } | |
2782 cb->addPercentHeightDescendant(const_cast<LayoutBox*>(this)); | |
2783 | |
2784 LayoutUnit availableHeight; | |
2785 if (isHorizontalWritingMode() != cb->isHorizontalWritingMode()) | |
2786 availableHeight = containingBlockChild->containingBlockLogicalWidthForCo ntent(); | |
2787 else if (isGridItem() && hasOverrideContainingBlockLogicalHeight()) | |
2788 availableHeight = overrideContainingBlockContentLogicalHeight(); | |
jfernandez
2016/07/18 06:13:24
I guess this is new logic. I'd rather do it in a d
svillar
2016/07/18 08:43:30
I think that's a good idea. First the refactoring,
Manuel Rego
2016/07/19 13:12:32
This is not exactly new logic. There were some sim
| |
2789 else | |
2790 availableHeight = availableLogicalHeightForPercentageComputation(cb, ski ppedAutoHeightContainingBlock, scrollsOverflowY()); | |
2791 | |
2792 if (availableHeight == -1) | |
2793 return availableHeight; | |
2787 | 2794 |
2788 availableHeight -= rootMarginBorderPaddingHeight; | 2795 availableHeight -= rootMarginBorderPaddingHeight; |
2789 | 2796 |
2790 if (isTable() && isOutOfFlowPositioned()) | 2797 if (isTable() && isOutOfFlowPositioned()) |
2791 availableHeight += cb->paddingLogicalHeight(); | 2798 availableHeight += cb->paddingLogicalHeight(); |
2792 | 2799 |
2793 LayoutUnit result = valueForLength(height, availableHeight); | 2800 LayoutUnit result = valueForLength(height, availableHeight); |
2801 bool includeBorderPadding = isTable() || (cb->isTableCell() && (cb->styleRef ().logicalHeight().isFixed() || (!skippedAutoHeightContainingBlock && cb->hasOve rrideLogicalContentHeight()))); | |
2794 if (includeBorderPadding) { | 2802 if (includeBorderPadding) { |
2795 // TODO(rhogan) crbug.com/467378: Doing this for content inside tables c ells is wrong, it should fill | 2803 // TODO(rhogan) crbug.com/467378: Doing this for content inside tables c ells is wrong, it should fill |
2796 // whatever height the cell makes available. | 2804 // whatever height the cell makes available. |
2797 result -= borderAndPaddingLogicalHeight(); | 2805 result -= borderAndPaddingLogicalHeight(); |
2798 return std::max(LayoutUnit(), result); | 2806 return std::max(LayoutUnit(), result); |
2799 } | 2807 } |
2800 return result; | 2808 return result; |
2801 } | 2809 } |
2802 | 2810 |
2803 LayoutUnit LayoutBox::computeReplacedLogicalWidth(ShouldComputePreferred shouldC omputePreferred) const | 2811 LayoutUnit LayoutBox::computeReplacedLogicalWidth(ShouldComputePreferred shouldC omputePreferred) const |
(...skipping 2122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4926 m_rareData->m_snapAreas->remove(&snapArea); | 4934 m_rareData->m_snapAreas->remove(&snapArea); |
4927 } | 4935 } |
4928 } | 4936 } |
4929 | 4937 |
4930 SnapAreaSet* LayoutBox::snapAreas() const | 4938 SnapAreaSet* LayoutBox::snapAreas() const |
4931 { | 4939 { |
4932 return m_rareData ? m_rareData->m_snapAreas.get() : nullptr; | 4940 return m_rareData ? m_rareData->m_snapAreas.get() : nullptr; |
4933 } | 4941 } |
4934 | 4942 |
4935 } // namespace blink | 4943 } // namespace blink |
OLD | NEW |