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 2222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2233 LayoutUnit logicalWidthResult = fillAvailableMeasure(availableLogicalWidth,
marginStart, marginEnd); | 2233 LayoutUnit logicalWidthResult = fillAvailableMeasure(availableLogicalWidth,
marginStart, marginEnd); |
2234 | 2234 |
2235 if (shrinkToAvoidFloats() && cb->isRenderBlockFlow() && toRenderBlockFlow(cb
)->containsFloats()) | 2235 if (shrinkToAvoidFloats() && cb->isRenderBlockFlow() && toRenderBlockFlow(cb
)->containsFloats()) |
2236 logicalWidthResult = std::min(logicalWidthResult, shrinkLogicalWidthToAv
oidFloats(marginStart, marginEnd, toRenderBlockFlow(cb))); | 2236 logicalWidthResult = std::min(logicalWidthResult, shrinkLogicalWidthToAv
oidFloats(marginStart, marginEnd, toRenderBlockFlow(cb))); |
2237 | 2237 |
2238 if (widthType == MainOrPreferredSize && sizesLogicalWidthToFitContent(logica
lWidth)) | 2238 if (widthType == MainOrPreferredSize && sizesLogicalWidthToFitContent(logica
lWidth)) |
2239 return std::max(minPreferredLogicalWidth(), std::min(maxPreferredLogical
Width(), logicalWidthResult)); | 2239 return std::max(minPreferredLogicalWidth(), std::min(maxPreferredLogical
Width(), logicalWidthResult)); |
2240 return logicalWidthResult; | 2240 return logicalWidthResult; |
2241 } | 2241 } |
2242 | 2242 |
2243 static bool columnFlexItemHasStretchAlignment(const RenderObject* flexitem) | 2243 static bool flexItemHasStretchAlignment(const RenderObject* flexitem) |
2244 { | 2244 { |
2245 RenderObject* parent = flexitem->parent(); | 2245 RenderObject* parent = flexitem->parent(); |
2246 // auto margins mean we don't stretch. Note that this function will only be
used for | 2246 // auto margins mean we don't stretch. |
2247 // widths, so we don't have to check marginBefore/marginAfter. | 2247 if (parent->style()->isColumnFlexDirection()) { |
2248 ASSERT(parent->style()->isColumnFlexDirection()); | 2248 if (flexitem->style()->marginStart().isAuto() || flexitem->style()->marg
inEnd().isAuto()) |
2249 if (flexitem->style()->marginStart().isAuto() || flexitem->style()->marginEn
d().isAuto()) | 2249 return false; |
2250 return false; | 2250 } else { |
| 2251 if (flexitem->style()->marginBefore().isAuto() || flexitem->style()->mar
ginAfter().isAuto()) |
| 2252 return false; |
| 2253 } |
2251 return flexitem->style()->alignSelf() == ItemPositionStretch || (flexitem->s
tyle()->alignSelf() == ItemPositionAuto && parent->style()->alignItems() == Item
PositionStretch); | 2254 return flexitem->style()->alignSelf() == ItemPositionStretch || (flexitem->s
tyle()->alignSelf() == ItemPositionAuto && parent->style()->alignItems() == Item
PositionStretch); |
2252 } | 2255 } |
2253 | 2256 |
2254 static bool isStretchingColumnFlexItem(const RenderObject* flexitem) | 2257 static bool isStretchingColumnFlexItem(const RenderObject* flexitem) |
2255 { | 2258 { |
2256 RenderObject* parent = flexitem->parent(); | 2259 RenderObject* parent = flexitem->parent(); |
2257 if (parent->isDeprecatedFlexibleBox() && parent->style()->boxOrient() == VER
TICAL && parent->style()->boxAlign() == BSTRETCH) | 2260 if (parent->isDeprecatedFlexibleBox() && parent->style()->boxOrient() == VER
TICAL && parent->style()->boxAlign() == BSTRETCH) |
2258 return true; | 2261 return true; |
2259 | 2262 |
2260 // We don't stretch multiline flexboxes because they need to apply line spac
ing (align-content) first. | 2263 // We don't stretch multiline flexboxes because they need to apply line spac
ing (align-content) first. |
2261 if (parent->isFlexibleBox() && parent->style()->flexWrap() == FlexNoWrap &&
parent->style()->isColumnFlexDirection() && columnFlexItemHasStretchAlignment(fl
exitem)) | 2264 if (parent->isFlexibleBox() && parent->style()->flexWrap() == FlexNoWrap &&
parent->style()->isColumnFlexDirection() && flexItemHasStretchAlignment(flexitem
)) |
2262 return true; | 2265 return true; |
2263 return false; | 2266 return false; |
2264 } | 2267 } |
2265 | 2268 |
2266 bool RenderBox::sizesLogicalWidthToFitContent(const Length& logicalWidth) const | 2269 bool RenderBox::sizesLogicalWidthToFitContent(const Length& logicalWidth) const |
2267 { | 2270 { |
2268 // Marquees in WinIE are like a mixture of blocks and inline-blocks. They s
ize as though they're blocks, | 2271 // Marquees in WinIE are like a mixture of blocks and inline-blocks. They s
ize as though they're blocks, |
2269 // but they allow text to sit on the same line as the marquee. | 2272 // but they allow text to sit on the same line as the marquee. |
2270 if (isFloating() || (isInlineBlockOrInlineTable() && !isMarquee())) | 2273 if (isFloating() || (isInlineBlockOrInlineTable() && !isMarquee())) |
2271 return true; | 2274 return true; |
(...skipping 12 matching lines...) Expand all Loading... |
2284 return true; | 2287 return true; |
2285 } | 2288 } |
2286 | 2289 |
2287 // Flexible box items should shrink wrap, so we lay them out at their intrin
sic widths. | 2290 // Flexible box items should shrink wrap, so we lay them out at their intrin
sic widths. |
2288 // In the case of columns that have a stretch alignment, we go ahead and lay
out at the | 2291 // In the case of columns that have a stretch alignment, we go ahead and lay
out at the |
2289 // stretched size to avoid an extra layout when applying alignment. | 2292 // stretched size to avoid an extra layout when applying alignment. |
2290 if (parent()->isFlexibleBox()) { | 2293 if (parent()->isFlexibleBox()) { |
2291 // For multiline columns, we need to apply align-content first, so we ca
n't stretch now. | 2294 // For multiline columns, we need to apply align-content first, so we ca
n't stretch now. |
2292 if (!parent()->style()->isColumnFlexDirection() || parent()->style()->fl
exWrap() != FlexNoWrap) | 2295 if (!parent()->style()->isColumnFlexDirection() || parent()->style()->fl
exWrap() != FlexNoWrap) |
2293 return true; | 2296 return true; |
2294 if (!columnFlexItemHasStretchAlignment(this)) | 2297 if (!flexItemHasStretchAlignment(this)) |
2295 return true; | 2298 return true; |
2296 } | 2299 } |
2297 | 2300 |
2298 // Flexible horizontal boxes lay out children at their intrinsic widths. Al
so vertical boxes | 2301 // Flexible horizontal boxes lay out children at their intrinsic widths. Al
so vertical boxes |
2299 // that don't stretch their kids lay out their children at their intrinsic w
idths. | 2302 // that don't stretch their kids lay out their children at their intrinsic w
idths. |
2300 // FIXME: Think about block-flow here. | 2303 // FIXME: Think about block-flow here. |
2301 // https://bugs.webkit.org/show_bug.cgi?id=46473 | 2304 // https://bugs.webkit.org/show_bug.cgi?id=46473 |
2302 if (parent()->isDeprecatedFlexibleBox() && (parent()->style()->boxOrient() =
= HORIZONTAL || parent()->style()->boxAlign() != BSTRETCH)) | 2305 if (parent()->isDeprecatedFlexibleBox() && (parent()->style()->boxOrient() =
= HORIZONTAL || parent()->style()->boxAlign() != BSTRETCH)) |
2303 return true; | 2306 return true; |
2304 | 2307 |
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2588 cb->addPercentHeightDescendant(const_cast<RenderBox*>(this)); | 2591 cb->addPercentHeightDescendant(const_cast<RenderBox*>(this)); |
2589 | 2592 |
2590 RenderStyle* cbstyle = cb->style(); | 2593 RenderStyle* cbstyle = cb->style(); |
2591 | 2594 |
2592 // A positioned element that specified both top/bottom or that specifies hei
ght should be treated as though it has a height | 2595 // A positioned element that specified both top/bottom or that specifies hei
ght should be treated as though it has a height |
2593 // explicitly specified that can be used for any percentage computations. | 2596 // explicitly specified that can be used for any percentage computations. |
2594 bool isOutOfFlowPositionedWithSpecifiedHeight = cb->isOutOfFlowPositioned()
&& (!cbstyle->logicalHeight().isAuto() || (!cbstyle->logicalTop().isAuto() && !c
bstyle->logicalBottom().isAuto())); | 2597 bool isOutOfFlowPositionedWithSpecifiedHeight = cb->isOutOfFlowPositioned()
&& (!cbstyle->logicalHeight().isAuto() || (!cbstyle->logicalTop().isAuto() && !c
bstyle->logicalBottom().isAuto())); |
2595 | 2598 |
2596 bool includeBorderPadding = isTable(); | 2599 bool includeBorderPadding = isTable(); |
2597 | 2600 |
2598 if (isHorizontalWritingMode() != cb->isHorizontalWritingMode()) | 2601 if (isHorizontalWritingMode() != cb->isHorizontalWritingMode()) { |
2599 availableHeight = containingBlockChild->containingBlockLogicalWidthForCo
ntent(); | 2602 availableHeight = containingBlockChild->containingBlockLogicalWidthForCo
ntent(); |
2600 else if (hasOverrideContainingBlockLogicalHeight()) | 2603 } else if (hasOverrideContainingBlockLogicalHeight()) { |
2601 availableHeight = overrideContainingBlockContentLogicalHeight(); | 2604 availableHeight = overrideContainingBlockContentLogicalHeight(); |
2602 else if (cb->isTableCell()) { | 2605 } else if (cb->isFlexItem() && flexItemHasStretchAlignment(cb) && cb->hasOve
rrideHeight()) { |
| 2606 availableHeight = cb->overrideLogicalContentHeight(); |
| 2607 } else if (cb->isTableCell()) { |
2603 if (!skippedAutoHeightContainingBlock) { | 2608 if (!skippedAutoHeightContainingBlock) { |
2604 // Table cells violate what the CSS spec says to do with heights. Ba
sically we | 2609 // Table cells violate what the CSS spec says to do with heights. Ba
sically we |
2605 // don't care if the cell specified a height or not. We just always
make ourselves | 2610 // don't care if the cell specified a height or not. We just always
make ourselves |
2606 // be a percentage of the cell's current content height. | 2611 // be a percentage of the cell's current content height. |
2607 if (!cb->hasOverrideHeight()) { | 2612 if (!cb->hasOverrideHeight()) { |
2608 // Normally we would let the cell size intrinsically, but scroll
ing overflow has to be | 2613 // Normally we would let the cell size intrinsically, but scroll
ing overflow has to be |
2609 // treated differently, since WinIE lets scrolled overflow regio
ns shrink as needed. | 2614 // treated differently, since WinIE lets scrolled overflow regio
ns shrink as needed. |
2610 // While we can't get all cases right, we can at least detect wh
en the cell has a specified | 2615 // While we can't get all cases right, we can at least detect wh
en the cell has a specified |
2611 // height or when the table has a specified height. In these cas
es we want to initially have | 2616 // height or when the table has a specified height. In these cas
es we want to initially have |
2612 // no size and allow the flexing of the table or the cell to its
specified height to cause us | 2617 // no size and allow the flexing of the table or the cell to its
specified height to cause us |
(...skipping 2126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4739 RenderBox::BoxDecorationData::BoxDecorationData(const RenderStyle& style) | 4744 RenderBox::BoxDecorationData::BoxDecorationData(const RenderStyle& style) |
4740 { | 4745 { |
4741 backgroundColor = style.visitedDependentColor(CSSPropertyBackgroundColor); | 4746 backgroundColor = style.visitedDependentColor(CSSPropertyBackgroundColor); |
4742 hasBackground = backgroundColor.alpha() || style.hasBackgroundImage(); | 4747 hasBackground = backgroundColor.alpha() || style.hasBackgroundImage(); |
4743 ASSERT(hasBackground == style.hasBackground()); | 4748 ASSERT(hasBackground == style.hasBackground()); |
4744 hasBorder = style.hasBorder(); | 4749 hasBorder = style.hasBorder(); |
4745 hasAppearance = style.hasAppearance(); | 4750 hasAppearance = style.hasAppearance(); |
4746 } | 4751 } |
4747 | 4752 |
4748 } // namespace blink | 4753 } // namespace blink |
OLD | NEW |