Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: third_party/WebKit/Source/core/layout/LayoutBox.cpp

Issue 1971053003: Use new intrinsic content height when computing min-height: min-content (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review comment Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 639 matching lines...) Expand 10 before | Expand all | Expand 10 after
650 LayoutUnit LayoutBox::constrainContentBoxLogicalHeightByMinMax(LayoutUnit logica lHeight, LayoutUnit intrinsicContentHeight) const 650 LayoutUnit LayoutBox::constrainContentBoxLogicalHeightByMinMax(LayoutUnit logica lHeight, LayoutUnit intrinsicContentHeight) const
651 { 651 {
652 // If the min/max height and logical height are both percentages we take adv antage of already knowing the current resolved percentage height 652 // If the min/max height and logical height are both percentages we take adv antage of already knowing the current resolved percentage height
653 // to avoid recursing up through our containing blocks again to determine it . 653 // to avoid recursing up through our containing blocks again to determine it .
654 const ComputedStyle& styleToUse = styleRef(); 654 const ComputedStyle& styleToUse = styleRef();
655 if (!styleToUse.logicalMaxHeight().isMaxSizeNone()) { 655 if (!styleToUse.logicalMaxHeight().isMaxSizeNone()) {
656 if (styleToUse.logicalMaxHeight().type() == Percent && styleToUse.logica lHeight().type() == Percent) { 656 if (styleToUse.logicalMaxHeight().type() == Percent && styleToUse.logica lHeight().type() == Percent) {
657 LayoutUnit availableLogicalHeight(logicalHeight / styleToUse.logical Height().value() * 100); 657 LayoutUnit availableLogicalHeight(logicalHeight / styleToUse.logical Height().value() * 100);
658 logicalHeight = std::min(logicalHeight, valueForLength(styleToUse.lo gicalMaxHeight(), availableLogicalHeight)); 658 logicalHeight = std::min(logicalHeight, valueForLength(styleToUse.lo gicalMaxHeight(), availableLogicalHeight));
659 } else { 659 } else {
660 LayoutUnit maxHeight(computeContentLogicalHeight(MaxSize, styleToUse .logicalMaxHeight(), LayoutUnit(-1))); 660 LayoutUnit maxHeight(computeContentLogicalHeight(MaxSize, styleToUse .logicalMaxHeight(), intrinsicContentHeight));
661 if (maxHeight != -1) 661 if (maxHeight != -1)
662 logicalHeight = std::min(logicalHeight, maxHeight); 662 logicalHeight = std::min(logicalHeight, maxHeight);
663 } 663 }
664 } 664 }
665 665
666 if (styleToUse.logicalMinHeight().type() == Percent && styleToUse.logicalHei ght().type() == Percent) { 666 if (styleToUse.logicalMinHeight().type() == Percent && styleToUse.logicalHei ght().type() == Percent) {
667 LayoutUnit availableLogicalHeight(logicalHeight / styleToUse.logicalHeig ht().value() * 100); 667 LayoutUnit availableLogicalHeight(logicalHeight / styleToUse.logicalHeig ht().value() * 100);
668 logicalHeight = std::max(logicalHeight, valueForLength(styleToUse.logica lMinHeight(), availableLogicalHeight)); 668 logicalHeight = std::max(logicalHeight, valueForLength(styleToUse.logica lMinHeight(), availableLogicalHeight));
669 } else { 669 } else {
670 logicalHeight = std::max(logicalHeight, computeContentLogicalHeight(MinS ize, styleToUse.logicalMinHeight(), intrinsicContentHeight)); 670 logicalHeight = std::max(logicalHeight, computeContentLogicalHeight(MinS ize, styleToUse.logicalMinHeight(), intrinsicContentHeight));
(...skipping 1995 matching lines...) Expand 10 before | Expand all | Expand 10 after
2666 return std::max(LayoutUnit(), adjustContentBoxLogicalHeightForBoxSizing(heig htIncludingScrollbar) - scrollbarLogicalHeight()); 2666 return std::max(LayoutUnit(), adjustContentBoxLogicalHeightForBoxSizing(heig htIncludingScrollbar) - scrollbarLogicalHeight());
2667 } 2667 }
2668 2668
2669 LayoutUnit LayoutBox::computeIntrinsicLogicalContentHeightUsing(const Length& lo gicalHeightLength, LayoutUnit intrinsicContentHeight, LayoutUnit borderAndPaddin g) const 2669 LayoutUnit LayoutBox::computeIntrinsicLogicalContentHeightUsing(const Length& lo gicalHeightLength, LayoutUnit intrinsicContentHeight, LayoutUnit borderAndPaddin g) const
2670 { 2670 {
2671 // FIXME(cbiesinger): The css-sizing spec is considering changing what min-c ontent/max-content should resolve to. 2671 // FIXME(cbiesinger): The css-sizing spec is considering changing what min-c ontent/max-content should resolve to.
2672 // If that happens, this code will have to change. 2672 // If that happens, this code will have to change.
2673 if (logicalHeightLength.isMinContent() || logicalHeightLength.isMaxContent() || logicalHeightLength.isFitContent()) { 2673 if (logicalHeightLength.isMinContent() || logicalHeightLength.isMaxContent() || logicalHeightLength.isFitContent()) {
2674 if (isAtomicInlineLevel()) 2674 if (isAtomicInlineLevel())
2675 return intrinsicSize().height(); 2675 return intrinsicSize().height();
2676 if (m_intrinsicContentLogicalHeight != -1)
2677 return m_intrinsicContentLogicalHeight;
2678 return intrinsicContentHeight; 2676 return intrinsicContentHeight;
2679 } 2677 }
2680 if (logicalHeightLength.isFillAvailable()) 2678 if (logicalHeightLength.isFillAvailable())
2681 return containingBlock()->availableLogicalHeight(ExcludeMarginBorderPadd ing) - borderAndPadding; 2679 return containingBlock()->availableLogicalHeight(ExcludeMarginBorderPadd ing) - borderAndPadding;
2682 ASSERT_NOT_REACHED(); 2680 ASSERT_NOT_REACHED();
2683 return LayoutUnit(); 2681 return LayoutUnit();
2684 } 2682 }
2685 2683
2686 LayoutUnit LayoutBox::computeContentAndScrollbarLogicalHeightUsing(SizeType heig htType, const Length& height, LayoutUnit intrinsicContentHeight) const 2684 LayoutUnit LayoutBox::computeContentAndScrollbarLogicalHeightUsing(SizeType heig htType, const Length& height, LayoutUnit intrinsicContentHeight) const
2687 { 2685 {
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
2979 case FillAvailable: 2977 case FillAvailable:
2980 return adjustContentBoxLogicalHeightForBoxSizing(computeIntrinsicLogical ContentHeightUsing(logicalHeight, intrinsicLogicalHeight(), borderAndPaddingHeig ht())); 2978 return adjustContentBoxLogicalHeightForBoxSizing(computeIntrinsicLogical ContentHeightUsing(logicalHeight, intrinsicLogicalHeight(), borderAndPaddingHeig ht()));
2981 default: 2979 default:
2982 return intrinsicLogicalHeight(); 2980 return intrinsicLogicalHeight();
2983 } 2981 }
2984 } 2982 }
2985 2983
2986 LayoutUnit LayoutBox::availableLogicalHeight(AvailableLogicalHeightType heightTy pe) const 2984 LayoutUnit LayoutBox::availableLogicalHeight(AvailableLogicalHeightType heightTy pe) const
2987 { 2985 {
2988 // http://www.w3.org/TR/CSS2/visudet.html#propdef-height - We are interested in the content height. 2986 // http://www.w3.org/TR/CSS2/visudet.html#propdef-height - We are interested in the content height.
2987 // FIXME: Should we pass intrinsicContentLogicalHeight() instead of -1 here?
2989 return constrainContentBoxLogicalHeightByMinMax(availableLogicalHeightUsing( style()->logicalHeight(), heightType), LayoutUnit(-1)); 2988 return constrainContentBoxLogicalHeightByMinMax(availableLogicalHeightUsing( style()->logicalHeight(), heightType), LayoutUnit(-1));
2990 } 2989 }
2991 2990
2992 LayoutUnit LayoutBox::availableLogicalHeightUsing(const Length& h, AvailableLogi calHeightType heightType) const 2991 LayoutUnit LayoutBox::availableLogicalHeightUsing(const Length& h, AvailableLogi calHeightType heightType) const
2993 { 2992 {
2994 if (isLayoutView()) { 2993 if (isLayoutView()) {
2995 return LayoutUnit(isHorizontalWritingMode() 2994 return LayoutUnit(isHorizontalWritingMode()
2996 ? toLayoutView(this)->frameView()->visibleContentSize().height() 2995 ? toLayoutView(this)->frameView()->visibleContentSize().height()
2997 : toLayoutView(this)->frameView()->visibleContentSize().width()); 2996 : toLayoutView(this)->frameView()->visibleContentSize().width());
2998 } 2997 }
2999 2998
3000 // We need to stop here, since we don't want to increase the height of the t able 2999 // We need to stop here, since we don't want to increase the height of the t able
3001 // artificially. We're going to rely on this cell getting expanded to some new 3000 // artificially. We're going to rely on this cell getting expanded to some new
3002 // height, and then when we lay out again we'll use the calculation below. 3001 // height, and then when we lay out again we'll use the calculation below.
3003 if (isTableCell() && (h.isAuto() || h.hasPercent())) { 3002 if (isTableCell() && (h.isAuto() || h.hasPercent())) {
3004 if (hasOverrideLogicalContentHeight()) 3003 if (hasOverrideLogicalContentHeight())
3005 return overrideLogicalContentHeight(); 3004 return overrideLogicalContentHeight();
3006 return logicalHeight() - borderAndPaddingLogicalHeight(); 3005 return logicalHeight() - borderAndPaddingLogicalHeight();
3007 } 3006 }
3008 3007
3009 if (h.hasPercent() && isOutOfFlowPositioned()) { 3008 if (h.hasPercent() && isOutOfFlowPositioned()) {
3010 // FIXME: This is wrong if the containingBlock has a perpendicular writi ng mode. 3009 // FIXME: This is wrong if the containingBlock has a perpendicular writi ng mode.
3011 LayoutUnit availableHeight = containingBlockLogicalHeightForPositioned(c ontainingBlock()); 3010 LayoutUnit availableHeight = containingBlockLogicalHeightForPositioned(c ontainingBlock());
3012 return adjustContentBoxLogicalHeightForBoxSizing(valueForLength(h, avail ableHeight)); 3011 return adjustContentBoxLogicalHeightForBoxSizing(valueForLength(h, avail ableHeight));
3013 } 3012 }
3014 3013
3014 // FIXME: Should we pass intrinsicContentLogicalHeight() instead of -1 here?
3015 LayoutUnit heightIncludingScrollbar = computeContentAndScrollbarLogicalHeigh tUsing(MainOrPreferredSize, h, LayoutUnit(-1)); 3015 LayoutUnit heightIncludingScrollbar = computeContentAndScrollbarLogicalHeigh tUsing(MainOrPreferredSize, h, LayoutUnit(-1));
3016 if (heightIncludingScrollbar != -1) 3016 if (heightIncludingScrollbar != -1)
3017 return std::max(LayoutUnit(), adjustContentBoxLogicalHeightForBoxSizing( heightIncludingScrollbar) - scrollbarLogicalHeight()); 3017 return std::max(LayoutUnit(), adjustContentBoxLogicalHeightForBoxSizing( heightIncludingScrollbar) - scrollbarLogicalHeight());
3018 3018
3019 // FIXME: Check logicalTop/logicalBottom here to correctly handle vertical w riting-mode. 3019 // FIXME: Check logicalTop/logicalBottom here to correctly handle vertical w riting-mode.
3020 // https://bugs.webkit.org/show_bug.cgi?id=46500 3020 // https://bugs.webkit.org/show_bug.cgi?id=46500
3021 if (isLayoutBlock() && isOutOfFlowPositioned() && style()->height().isAuto() && !(style()->top().isAuto() || style()->bottom().isAuto())) { 3021 if (isLayoutBlock() && isOutOfFlowPositioned() && style()->height().isAuto() && !(style()->top().isAuto() || style()->bottom().isAuto())) {
3022 LayoutBlock* block = const_cast<LayoutBlock*>(toLayoutBlock(this)); 3022 LayoutBlock* block = const_cast<LayoutBlock*>(toLayoutBlock(this));
3023 LogicalExtentComputedValues computedValues; 3023 LogicalExtentComputedValues computedValues;
3024 block->computeLogicalHeight(block->logicalHeight(), LayoutUnit(), comput edValues); 3024 block->computeLogicalHeight(block->logicalHeight(), LayoutUnit(), comput edValues);
(...skipping 1923 matching lines...) Expand 10 before | Expand all | Expand 10 after
4948 m_rareData->m_snapAreas->remove(&snapArea); 4948 m_rareData->m_snapAreas->remove(&snapArea);
4949 } 4949 }
4950 } 4950 }
4951 4951
4952 SnapAreaSet* LayoutBox::snapAreas() const 4952 SnapAreaSet* LayoutBox::snapAreas() const
4953 { 4953 {
4954 return m_rareData ? m_rareData->m_snapAreas.get() : nullptr; 4954 return m_rareData ? m_rareData->m_snapAreas.get() : nullptr;
4955 } 4955 }
4956 4956
4957 } // namespace blink 4957 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698