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

Side by Side Diff: Source/core/rendering/RenderBox.cpp

Issue 331203002: Blink doesn't honor percent heights on children of "align-self:stretch" flex items in a fixed-height (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 2 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
« no previous file with comments | « Source/core/rendering/RenderBox.h ('k') | Source/core/rendering/RenderFlexibleBox.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 2009 matching lines...) Expand 10 before | Expand all | Expand 10 after
2020 LayoutUnit logicalWidthResult = fillAvailableMeasure(availableLogicalWidth, marginStart, marginEnd); 2020 LayoutUnit logicalWidthResult = fillAvailableMeasure(availableLogicalWidth, marginStart, marginEnd);
2021 2021
2022 if (shrinkToAvoidFloats() && cb->isRenderBlockFlow() && toRenderBlockFlow(cb )->containsFloats()) 2022 if (shrinkToAvoidFloats() && cb->isRenderBlockFlow() && toRenderBlockFlow(cb )->containsFloats())
2023 logicalWidthResult = std::min(logicalWidthResult, shrinkLogicalWidthToAv oidFloats(marginStart, marginEnd, toRenderBlockFlow(cb))); 2023 logicalWidthResult = std::min(logicalWidthResult, shrinkLogicalWidthToAv oidFloats(marginStart, marginEnd, toRenderBlockFlow(cb)));
2024 2024
2025 if (widthType == MainOrPreferredSize && sizesLogicalWidthToFitContent(logica lWidth)) 2025 if (widthType == MainOrPreferredSize && sizesLogicalWidthToFitContent(logica lWidth))
2026 return std::max(minPreferredLogicalWidth(), std::min(maxPreferredLogical Width(), logicalWidthResult)); 2026 return std::max(minPreferredLogicalWidth(), std::min(maxPreferredLogical Width(), logicalWidthResult));
2027 return logicalWidthResult; 2027 return logicalWidthResult;
2028 } 2028 }
2029 2029
2030 static bool columnFlexItemHasStretchAlignment(const RenderObject* flexitem) 2030 static bool flexItemHasStretchAlignment(const RenderObject* flexitem)
2031 { 2031 {
2032 RenderObject* parent = flexitem->parent(); 2032 RenderObject* parent = flexitem->parent();
2033 // auto margins mean we don't stretch. Note that this function will only be used for 2033 // auto margins mean we don't stretch.
2034 // widths, so we don't have to check marginBefore/marginAfter. 2034 if (parent->style()->isColumnFlexDirection()) {
2035 ASSERT(parent->style()->isColumnFlexDirection()); 2035 if (flexitem->style()->marginStart().isAuto() || flexitem->style()->marg inEnd().isAuto())
2036 if (flexitem->style()->marginStart().isAuto() || flexitem->style()->marginEn d().isAuto()) 2036 return false;
2037 return false; 2037 } else {
2038 if (flexitem->style()->marginBefore().isAuto() || flexitem->style()->mar ginAfter().isAuto())
2039 return false;
2040 }
2038 return flexitem->style()->alignSelf() == ItemPositionStretch || (flexitem->s tyle()->alignSelf() == ItemPositionAuto && parent->style()->alignItems() == Item PositionStretch); 2041 return flexitem->style()->alignSelf() == ItemPositionStretch || (flexitem->s tyle()->alignSelf() == ItemPositionAuto && parent->style()->alignItems() == Item PositionStretch);
2039 } 2042 }
2040 2043
2041 static bool isStretchingColumnFlexItem(const RenderObject* flexitem) 2044 static bool isStretchingColumnFlexItem(const RenderObject* flexitem)
2042 { 2045 {
2043 RenderObject* parent = flexitem->parent(); 2046 RenderObject* parent = flexitem->parent();
2044 if (parent->isDeprecatedFlexibleBox() && parent->style()->boxOrient() == VER TICAL && parent->style()->boxAlign() == BSTRETCH) 2047 if (parent->isDeprecatedFlexibleBox() && parent->style()->boxOrient() == VER TICAL && parent->style()->boxAlign() == BSTRETCH)
2045 return true; 2048 return true;
2046 2049
2047 // We don't stretch multiline flexboxes because they need to apply line spac ing (align-content) first. 2050 // We don't stretch multiline flexboxes because they need to apply line spac ing (align-content) first.
2048 if (parent->isFlexibleBox() && parent->style()->flexWrap() == FlexNoWrap && parent->style()->isColumnFlexDirection() && columnFlexItemHasStretchAlignment(fl exitem)) 2051 if (parent->isFlexibleBox() && parent->style()->flexWrap() == FlexNoWrap && parent->style()->isColumnFlexDirection() && flexItemHasStretchAlignment(flexitem ))
2049 return true; 2052 return true;
2050 return false; 2053 return false;
2051 } 2054 }
2052 2055
2053 bool RenderBox::sizesLogicalWidthToFitContent(const Length& logicalWidth) const 2056 bool RenderBox::sizesLogicalWidthToFitContent(const Length& logicalWidth) const
2054 { 2057 {
2055 // Marquees in WinIE are like a mixture of blocks and inline-blocks. They s ize as though they're blocks, 2058 // Marquees in WinIE are like a mixture of blocks and inline-blocks. They s ize as though they're blocks,
2056 // but they allow text to sit on the same line as the marquee. 2059 // but they allow text to sit on the same line as the marquee.
2057 if (isFloating() || (isInlineBlockOrInlineTable() && !isMarquee())) 2060 if (isFloating() || (isInlineBlockOrInlineTable() && !isMarquee()))
2058 return true; 2061 return true;
(...skipping 12 matching lines...) Expand all
2071 return true; 2074 return true;
2072 } 2075 }
2073 2076
2074 // Flexible box items should shrink wrap, so we lay them out at their intrin sic widths. 2077 // Flexible box items should shrink wrap, so we lay them out at their intrin sic widths.
2075 // In the case of columns that have a stretch alignment, we go ahead and lay out at the 2078 // In the case of columns that have a stretch alignment, we go ahead and lay out at the
2076 // stretched size to avoid an extra layout when applying alignment. 2079 // stretched size to avoid an extra layout when applying alignment.
2077 if (parent()->isFlexibleBox()) { 2080 if (parent()->isFlexibleBox()) {
2078 // For multiline columns, we need to apply align-content first, so we ca n't stretch now. 2081 // For multiline columns, we need to apply align-content first, so we ca n't stretch now.
2079 if (!parent()->style()->isColumnFlexDirection() || parent()->style()->fl exWrap() != FlexNoWrap) 2082 if (!parent()->style()->isColumnFlexDirection() || parent()->style()->fl exWrap() != FlexNoWrap)
2080 return true; 2083 return true;
2081 if (!columnFlexItemHasStretchAlignment(this)) 2084 if (!flexItemHasStretchAlignment(this))
2082 return true; 2085 return true;
2083 } 2086 }
2084 2087
2085 // Flexible horizontal boxes lay out children at their intrinsic widths. Al so vertical boxes 2088 // Flexible horizontal boxes lay out children at their intrinsic widths. Al so vertical boxes
2086 // that don't stretch their kids lay out their children at their intrinsic w idths. 2089 // that don't stretch their kids lay out their children at their intrinsic w idths.
2087 // FIXME: Think about block-flow here. 2090 // FIXME: Think about block-flow here.
2088 // https://bugs.webkit.org/show_bug.cgi?id=46473 2091 // https://bugs.webkit.org/show_bug.cgi?id=46473
2089 if (parent()->isDeprecatedFlexibleBox() && (parent()->style()->boxOrient() = = HORIZONTAL || parent()->style()->boxAlign() != BSTRETCH)) 2092 if (parent()->isDeprecatedFlexibleBox() && (parent()->style()->boxOrient() = = HORIZONTAL || parent()->style()->boxAlign() != BSTRETCH))
2090 return true; 2093 return true;
2091 2094
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
2375 cb->addPercentHeightDescendant(const_cast<RenderBox*>(this)); 2378 cb->addPercentHeightDescendant(const_cast<RenderBox*>(this));
2376 2379
2377 RenderStyle* cbstyle = cb->style(); 2380 RenderStyle* cbstyle = cb->style();
2378 2381
2379 // A positioned element that specified both top/bottom or that specifies hei ght should be treated as though it has a height 2382 // A positioned element that specified both top/bottom or that specifies hei ght should be treated as though it has a height
2380 // explicitly specified that can be used for any percentage computations. 2383 // explicitly specified that can be used for any percentage computations.
2381 bool isOutOfFlowPositionedWithSpecifiedHeight = cb->isOutOfFlowPositioned() && (!cbstyle->logicalHeight().isAuto() || (!cbstyle->logicalTop().isAuto() && !c bstyle->logicalBottom().isAuto())); 2384 bool isOutOfFlowPositionedWithSpecifiedHeight = cb->isOutOfFlowPositioned() && (!cbstyle->logicalHeight().isAuto() || (!cbstyle->logicalTop().isAuto() && !c bstyle->logicalBottom().isAuto()));
2382 2385
2383 bool includeBorderPadding = isTable(); 2386 bool includeBorderPadding = isTable();
2384 2387
2385 if (isHorizontalWritingMode() != cb->isHorizontalWritingMode()) 2388 if (isHorizontalWritingMode() != cb->isHorizontalWritingMode()) {
2386 availableHeight = containingBlockChild->containingBlockLogicalWidthForCo ntent(); 2389 availableHeight = containingBlockChild->containingBlockLogicalWidthForCo ntent();
2387 else if (hasOverrideContainingBlockLogicalHeight()) 2390 } else if (hasOverrideContainingBlockLogicalHeight()) {
2388 availableHeight = overrideContainingBlockContentLogicalHeight(); 2391 availableHeight = overrideContainingBlockContentLogicalHeight();
2389 else if (cb->isTableCell()) { 2392 } else if (cb->isFlexItem() && flexItemHasStretchAlignment(cb) && cb->hasOve rrideHeight()) {
2393 availableHeight = cb->overrideLogicalContentHeight();
2394 } else if (cb->isTableCell()) {
2390 if (!skippedAutoHeightContainingBlock) { 2395 if (!skippedAutoHeightContainingBlock) {
2391 // Table cells violate what the CSS spec says to do with heights. Ba sically we 2396 // Table cells violate what the CSS spec says to do with heights. Ba sically we
2392 // don't care if the cell specified a height or not. We just always make ourselves 2397 // don't care if the cell specified a height or not. We just always make ourselves
2393 // be a percentage of the cell's current content height. 2398 // be a percentage of the cell's current content height.
2394 if (!cb->hasOverrideHeight()) { 2399 if (!cb->hasOverrideHeight()) {
2395 // Normally we would let the cell size intrinsically, but scroll ing overflow has to be 2400 // Normally we would let the cell size intrinsically, but scroll ing overflow has to be
2396 // treated differently, since WinIE lets scrolled overflow regio ns shrink as needed. 2401 // treated differently, since WinIE lets scrolled overflow regio ns shrink as needed.
2397 // While we can't get all cases right, we can at least detect wh en the cell has a specified 2402 // While we can't get all cases right, we can at least detect wh en the cell has a specified
2398 // height or when the table has a specified height. In these cas es we want to initially have 2403 // height or when the table has a specified height. In these cas es we want to initially have
2399 // no size and allow the flexing of the table or the cell to its specified height to cause us 2404 // no size and allow the flexing of the table or the cell to its specified height to cause us
(...skipping 2123 matching lines...) Expand 10 before | Expand all | Expand 10 after
4523 ASSERT(style()->hasBackground() || style()->hasBoxDecorations()); 4528 ASSERT(style()->hasBackground() || style()->hasBoxDecorations());
4524 4529
4525 if (m_rareData && m_rareData->m_previousBorderBoxSize.width() != -1) 4530 if (m_rareData && m_rareData->m_previousBorderBoxSize.width() != -1)
4526 return m_rareData->m_previousBorderBoxSize; 4531 return m_rareData->m_previousBorderBoxSize;
4527 4532
4528 // We didn't save the old border box size because it was the same as the siz e of oldBounds. 4533 // We didn't save the old border box size because it was the same as the siz e of oldBounds.
4529 return previousBoundsSize; 4534 return previousBoundsSize;
4530 } 4535 }
4531 4536
4532 } // namespace blink 4537 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/rendering/RenderBox.h ('k') | Source/core/rendering/RenderFlexibleBox.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698