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

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

Issue 1980603002: Use new intrinsic content height when computing min-height: min-content (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2704
Patch Set: 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 602 matching lines...) Expand 10 before | Expand all | Expand 10 after
613 LayoutUnit LayoutBox::constrainContentBoxLogicalHeightByMinMax(LayoutUnit logica lHeight, LayoutUnit intrinsicContentHeight) const 613 LayoutUnit LayoutBox::constrainContentBoxLogicalHeightByMinMax(LayoutUnit logica lHeight, LayoutUnit intrinsicContentHeight) const
614 { 614 {
615 // If the min/max height and logical height are both percentages we take adv antage of already knowing the current resolved percentage height 615 // If the min/max height and logical height are both percentages we take adv antage of already knowing the current resolved percentage height
616 // to avoid recursing up through our containing blocks again to determine it . 616 // to avoid recursing up through our containing blocks again to determine it .
617 const ComputedStyle& styleToUse = styleRef(); 617 const ComputedStyle& styleToUse = styleRef();
618 if (!styleToUse.logicalMaxHeight().isMaxSizeNone()) { 618 if (!styleToUse.logicalMaxHeight().isMaxSizeNone()) {
619 if (styleToUse.logicalMaxHeight().type() == Percent && styleToUse.logica lHeight().type() == Percent) { 619 if (styleToUse.logicalMaxHeight().type() == Percent && styleToUse.logica lHeight().type() == Percent) {
620 LayoutUnit availableLogicalHeight(logicalHeight / styleToUse.logical Height().value() * 100); 620 LayoutUnit availableLogicalHeight(logicalHeight / styleToUse.logical Height().value() * 100);
621 logicalHeight = std::min(logicalHeight, valueForLength(styleToUse.lo gicalMaxHeight(), availableLogicalHeight)); 621 logicalHeight = std::min(logicalHeight, valueForLength(styleToUse.lo gicalMaxHeight(), availableLogicalHeight));
622 } else { 622 } else {
623 LayoutUnit maxHeight(computeContentLogicalHeight(MaxSize, styleToUse .logicalMaxHeight(), LayoutUnit(-1))); 623 LayoutUnit maxHeight(computeContentLogicalHeight(MaxSize, styleToUse .logicalMaxHeight(), intrinsicContentHeight));
624 if (maxHeight != -1) 624 if (maxHeight != -1)
625 logicalHeight = std::min(logicalHeight, maxHeight); 625 logicalHeight = std::min(logicalHeight, maxHeight);
626 } 626 }
627 } 627 }
628 628
629 if (styleToUse.logicalMinHeight().type() == Percent && styleToUse.logicalHei ght().type() == Percent) { 629 if (styleToUse.logicalMinHeight().type() == Percent && styleToUse.logicalHei ght().type() == Percent) {
630 LayoutUnit availableLogicalHeight(logicalHeight / styleToUse.logicalHeig ht().value() * 100); 630 LayoutUnit availableLogicalHeight(logicalHeight / styleToUse.logicalHeig ht().value() * 100);
631 logicalHeight = std::max(logicalHeight, valueForLength(styleToUse.logica lMinHeight(), availableLogicalHeight)); 631 logicalHeight = std::max(logicalHeight, valueForLength(styleToUse.logica lMinHeight(), availableLogicalHeight));
632 } else { 632 } else {
633 logicalHeight = std::max(logicalHeight, computeContentLogicalHeight(MinS ize, styleToUse.logicalMinHeight(), intrinsicContentHeight)); 633 logicalHeight = std::max(logicalHeight, computeContentLogicalHeight(MinS ize, styleToUse.logicalMinHeight(), intrinsicContentHeight));
(...skipping 1938 matching lines...) Expand 10 before | Expand all | Expand 10 after
2572 return std::max(LayoutUnit(), adjustContentBoxLogicalHeightForBoxSizing(heig htIncludingScrollbar) - scrollbarLogicalHeight()); 2572 return std::max(LayoutUnit(), adjustContentBoxLogicalHeightForBoxSizing(heig htIncludingScrollbar) - scrollbarLogicalHeight());
2573 } 2573 }
2574 2574
2575 LayoutUnit LayoutBox::computeIntrinsicLogicalContentHeightUsing(const Length& lo gicalHeightLength, LayoutUnit intrinsicContentHeight, LayoutUnit borderAndPaddin g) const 2575 LayoutUnit LayoutBox::computeIntrinsicLogicalContentHeightUsing(const Length& lo gicalHeightLength, LayoutUnit intrinsicContentHeight, LayoutUnit borderAndPaddin g) const
2576 { 2576 {
2577 // FIXME(cbiesinger): The css-sizing spec is considering changing what min-c ontent/max-content should resolve to. 2577 // FIXME(cbiesinger): The css-sizing spec is considering changing what min-c ontent/max-content should resolve to.
2578 // If that happens, this code will have to change. 2578 // If that happens, this code will have to change.
2579 if (logicalHeightLength.isMinContent() || logicalHeightLength.isMaxContent() || logicalHeightLength.isFitContent()) { 2579 if (logicalHeightLength.isMinContent() || logicalHeightLength.isMaxContent() || logicalHeightLength.isFitContent()) {
2580 if (isAtomicInlineLevel()) 2580 if (isAtomicInlineLevel())
2581 return intrinsicSize().height(); 2581 return intrinsicSize().height();
2582 if (m_intrinsicContentLogicalHeight != -1)
2583 return m_intrinsicContentLogicalHeight;
2584 return intrinsicContentHeight; 2582 return intrinsicContentHeight;
2585 } 2583 }
2586 if (logicalHeightLength.isFillAvailable()) 2584 if (logicalHeightLength.isFillAvailable())
2587 return containingBlock()->availableLogicalHeight(ExcludeMarginBorderPadd ing) - borderAndPadding; 2585 return containingBlock()->availableLogicalHeight(ExcludeMarginBorderPadd ing) - borderAndPadding;
2588 ASSERT_NOT_REACHED(); 2586 ASSERT_NOT_REACHED();
2589 return LayoutUnit(); 2587 return LayoutUnit();
2590 } 2588 }
2591 2589
2592 LayoutUnit LayoutBox::computeContentAndScrollbarLogicalHeightUsing(SizeType heig htType, const Length& height, LayoutUnit intrinsicContentHeight) const 2590 LayoutUnit LayoutBox::computeContentAndScrollbarLogicalHeightUsing(SizeType heig htType, const Length& height, LayoutUnit intrinsicContentHeight) const
2593 { 2591 {
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
2885 case FillAvailable: 2883 case FillAvailable:
2886 return adjustContentBoxLogicalHeightForBoxSizing(computeIntrinsicLogical ContentHeightUsing(logicalHeight, intrinsicLogicalHeight(), borderAndPaddingHeig ht())); 2884 return adjustContentBoxLogicalHeightForBoxSizing(computeIntrinsicLogical ContentHeightUsing(logicalHeight, intrinsicLogicalHeight(), borderAndPaddingHeig ht()));
2887 default: 2885 default:
2888 return intrinsicLogicalHeight(); 2886 return intrinsicLogicalHeight();
2889 } 2887 }
2890 } 2888 }
2891 2889
2892 LayoutUnit LayoutBox::availableLogicalHeight(AvailableLogicalHeightType heightTy pe) const 2890 LayoutUnit LayoutBox::availableLogicalHeight(AvailableLogicalHeightType heightTy pe) const
2893 { 2891 {
2894 // http://www.w3.org/TR/CSS2/visudet.html#propdef-height - We are interested in the content height. 2892 // http://www.w3.org/TR/CSS2/visudet.html#propdef-height - We are interested in the content height.
2893 // FIXME: Should we pass intrinsicContentLogicalHeight() instead of -1 here?
2895 return constrainContentBoxLogicalHeightByMinMax(availableLogicalHeightUsing( style()->logicalHeight(), heightType), LayoutUnit(-1)); 2894 return constrainContentBoxLogicalHeightByMinMax(availableLogicalHeightUsing( style()->logicalHeight(), heightType), LayoutUnit(-1));
2896 } 2895 }
2897 2896
2898 LayoutUnit LayoutBox::availableLogicalHeightUsing(const Length& h, AvailableLogi calHeightType heightType) const 2897 LayoutUnit LayoutBox::availableLogicalHeightUsing(const Length& h, AvailableLogi calHeightType heightType) const
2899 { 2898 {
2900 if (isLayoutView()) { 2899 if (isLayoutView()) {
2901 return LayoutUnit(isHorizontalWritingMode() 2900 return LayoutUnit(isHorizontalWritingMode()
2902 ? toLayoutView(this)->frameView()->visibleContentSize().height() 2901 ? toLayoutView(this)->frameView()->visibleContentSize().height()
2903 : toLayoutView(this)->frameView()->visibleContentSize().width()); 2902 : toLayoutView(this)->frameView()->visibleContentSize().width());
2904 } 2903 }
2905 2904
2906 // We need to stop here, since we don't want to increase the height of the t able 2905 // We need to stop here, since we don't want to increase the height of the t able
2907 // artificially. We're going to rely on this cell getting expanded to some new 2906 // artificially. We're going to rely on this cell getting expanded to some new
2908 // height, and then when we lay out again we'll use the calculation below. 2907 // height, and then when we lay out again we'll use the calculation below.
2909 if (isTableCell() && (h.isAuto() || h.hasPercent())) { 2908 if (isTableCell() && (h.isAuto() || h.hasPercent())) {
2910 if (hasOverrideLogicalContentHeight()) 2909 if (hasOverrideLogicalContentHeight())
2911 return overrideLogicalContentHeight(); 2910 return overrideLogicalContentHeight();
2912 return logicalHeight() - borderAndPaddingLogicalHeight(); 2911 return logicalHeight() - borderAndPaddingLogicalHeight();
2913 } 2912 }
2914 2913
2915 if (h.hasPercent() && isOutOfFlowPositioned()) { 2914 if (h.hasPercent() && isOutOfFlowPositioned()) {
2916 // FIXME: This is wrong if the containingBlock has a perpendicular writi ng mode. 2915 // FIXME: This is wrong if the containingBlock has a perpendicular writi ng mode.
2917 LayoutUnit availableHeight = containingBlockLogicalHeightForPositioned(c ontainingBlock()); 2916 LayoutUnit availableHeight = containingBlockLogicalHeightForPositioned(c ontainingBlock());
2918 return adjustContentBoxLogicalHeightForBoxSizing(valueForLength(h, avail ableHeight)); 2917 return adjustContentBoxLogicalHeightForBoxSizing(valueForLength(h, avail ableHeight));
2919 } 2918 }
2920 2919
2920 // FIXME: Should we pass intrinsicContentLogicalHeight() instead of -1 here?
2921 LayoutUnit heightIncludingScrollbar = computeContentAndScrollbarLogicalHeigh tUsing(MainOrPreferredSize, h, LayoutUnit(-1)); 2921 LayoutUnit heightIncludingScrollbar = computeContentAndScrollbarLogicalHeigh tUsing(MainOrPreferredSize, h, LayoutUnit(-1));
2922 if (heightIncludingScrollbar != -1) 2922 if (heightIncludingScrollbar != -1)
2923 return std::max(LayoutUnit(), adjustContentBoxLogicalHeightForBoxSizing( heightIncludingScrollbar) - scrollbarLogicalHeight()); 2923 return std::max(LayoutUnit(), adjustContentBoxLogicalHeightForBoxSizing( heightIncludingScrollbar) - scrollbarLogicalHeight());
2924 2924
2925 // FIXME: Check logicalTop/logicalBottom here to correctly handle vertical w riting-mode. 2925 // FIXME: Check logicalTop/logicalBottom here to correctly handle vertical w riting-mode.
2926 // https://bugs.webkit.org/show_bug.cgi?id=46500 2926 // https://bugs.webkit.org/show_bug.cgi?id=46500
2927 if (isLayoutBlock() && isOutOfFlowPositioned() && style()->height().isAuto() && !(style()->top().isAuto() || style()->bottom().isAuto())) { 2927 if (isLayoutBlock() && isOutOfFlowPositioned() && style()->height().isAuto() && !(style()->top().isAuto() || style()->bottom().isAuto())) {
2928 LayoutBlock* block = const_cast<LayoutBlock*>(toLayoutBlock(this)); 2928 LayoutBlock* block = const_cast<LayoutBlock*>(toLayoutBlock(this));
2929 LogicalExtentComputedValues computedValues; 2929 LogicalExtentComputedValues computedValues;
2930 block->computeLogicalHeight(block->logicalHeight(), LayoutUnit(), comput edValues); 2930 block->computeLogicalHeight(block->logicalHeight(), LayoutUnit(), comput edValues);
(...skipping 1806 matching lines...) Expand 10 before | Expand all | Expand 10 after
4737 4737
4738 void LayoutBox::clearPercentHeightDescendants() 4738 void LayoutBox::clearPercentHeightDescendants()
4739 { 4739 {
4740 for (LayoutObject* curr = slowFirstChild(); curr; curr = curr->nextInPreOrde r(this)) { 4740 for (LayoutObject* curr = slowFirstChild(); curr; curr = curr->nextInPreOrde r(this)) {
4741 if (curr->isBox()) 4741 if (curr->isBox())
4742 toLayoutBox(curr)->removeFromPercentHeightContainer(); 4742 toLayoutBox(curr)->removeFromPercentHeightContainer();
4743 } 4743 }
4744 } 4744 }
4745 4745
4746 } // namespace blink 4746 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698