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