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 2255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2266 LayoutUnit logicalWidthResult = fillAvailableMeasure(availableLogicalWidth, marginStart, marginEnd); | 2266 LayoutUnit logicalWidthResult = fillAvailableMeasure(availableLogicalWidth, marginStart, marginEnd); |
2267 | 2267 |
2268 if (shrinkToAvoidFloats() && cb->isRenderBlockFlow() && toRenderBlockFlow(cb )->containsFloats()) | 2268 if (shrinkToAvoidFloats() && cb->isRenderBlockFlow() && toRenderBlockFlow(cb )->containsFloats()) |
2269 logicalWidthResult = std::min(logicalWidthResult, shrinkLogicalWidthToAv oidFloats(marginStart, marginEnd, toRenderBlockFlow(cb))); | 2269 logicalWidthResult = std::min(logicalWidthResult, shrinkLogicalWidthToAv oidFloats(marginStart, marginEnd, toRenderBlockFlow(cb))); |
2270 | 2270 |
2271 if (widthType == MainOrPreferredSize && sizesLogicalWidthToFitContent(logica lWidth)) | 2271 if (widthType == MainOrPreferredSize && sizesLogicalWidthToFitContent(logica lWidth)) |
2272 return std::max(minPreferredLogicalWidth(), std::min(maxPreferredLogical Width(), logicalWidthResult)); | 2272 return std::max(minPreferredLogicalWidth(), std::min(maxPreferredLogical Width(), logicalWidthResult)); |
2273 return logicalWidthResult; | 2273 return logicalWidthResult; |
2274 } | 2274 } |
2275 | 2275 |
2276 static bool columnFlexItemHasStretchAlignment(const RenderObject* flexitem) | 2276 static bool flexItemHasStretchAlignment(const RenderObject* flexitem) |
2277 { | 2277 { |
2278 RenderObject* parent = flexitem->parent(); | 2278 RenderObject* parent = flexitem->parent(); |
2279 // auto margins mean we don't stretch. Note that this function will only be used for | 2279 // auto margins mean we don't stretch. |
2280 // widths, so we don't have to check marginBefore/marginAfter. | 2280 if (parent->style()->isColumnFlexDirection()) { |
2281 ASSERT(parent->style()->isColumnFlexDirection()); | 2281 if (flexitem->style()->marginStart().isAuto() || flexitem->style()->marg inEnd().isAuto()) |
2282 if (flexitem->style()->marginStart().isAuto() || flexitem->style()->marginEn d().isAuto()) | 2282 return false; |
2283 return false; | 2283 } else { |
2284 if (flexitem->style()->marginBefore().isAuto() || flexitem->style()->mar ginAfter().isAuto()) | |
ojan
2014/08/28 03:23:09
I think you just want this. You don't need the isC
harpreet.sk
2014/08/28 14:30:19
I tried removing it but because of it following la
| |
2285 return false; | |
2286 } | |
2284 return flexitem->style()->alignSelf() == ItemPositionStretch || (flexitem->s tyle()->alignSelf() == ItemPositionAuto && parent->style()->alignItems() == Item PositionStretch); | 2287 return flexitem->style()->alignSelf() == ItemPositionStretch || (flexitem->s tyle()->alignSelf() == ItemPositionAuto && parent->style()->alignItems() == Item PositionStretch); |
2285 } | 2288 } |
2286 | 2289 |
2287 static bool isStretchingColumnFlexItem(const RenderObject* flexitem) | 2290 static bool isStretchingColumnFlexItem(const RenderObject* flexitem) |
2288 { | 2291 { |
2289 RenderObject* parent = flexitem->parent(); | 2292 RenderObject* parent = flexitem->parent(); |
2290 if (parent->isDeprecatedFlexibleBox() && parent->style()->boxOrient() == VER TICAL && parent->style()->boxAlign() == BSTRETCH) | 2293 if (parent->isDeprecatedFlexibleBox() && parent->style()->boxOrient() == VER TICAL && parent->style()->boxAlign() == BSTRETCH) |
2291 return true; | 2294 return true; |
2292 | 2295 |
2293 // We don't stretch multiline flexboxes because they need to apply line spac ing (align-content) first. | 2296 // We don't stretch multiline flexboxes because they need to apply line spac ing (align-content) first. |
2294 if (parent->isFlexibleBox() && parent->style()->flexWrap() == FlexNoWrap && parent->style()->isColumnFlexDirection() && columnFlexItemHasStretchAlignment(fl exitem)) | 2297 if (parent->isFlexibleBox() && parent->style()->flexWrap() == FlexNoWrap && parent->style()->isColumnFlexDirection() && flexItemHasStretchAlignment(flexitem )) |
2295 return true; | 2298 return true; |
2296 return false; | 2299 return false; |
2297 } | 2300 } |
2298 | 2301 |
2299 bool RenderBox::sizesLogicalWidthToFitContent(const Length& logicalWidth) const | 2302 bool RenderBox::sizesLogicalWidthToFitContent(const Length& logicalWidth) const |
2300 { | 2303 { |
2301 // Marquees in WinIE are like a mixture of blocks and inline-blocks. They s ize as though they're blocks, | 2304 // Marquees in WinIE are like a mixture of blocks and inline-blocks. They s ize as though they're blocks, |
2302 // but they allow text to sit on the same line as the marquee. | 2305 // but they allow text to sit on the same line as the marquee. |
2303 if (isFloating() || (isInlineBlockOrInlineTable() && !isMarquee())) | 2306 if (isFloating() || (isInlineBlockOrInlineTable() && !isMarquee())) |
2304 return true; | 2307 return true; |
(...skipping 12 matching lines...) Expand all Loading... | |
2317 return true; | 2320 return true; |
2318 } | 2321 } |
2319 | 2322 |
2320 // Flexible box items should shrink wrap, so we lay them out at their intrin sic widths. | 2323 // Flexible box items should shrink wrap, so we lay them out at their intrin sic widths. |
2321 // In the case of columns that have a stretch alignment, we go ahead and lay out at the | 2324 // In the case of columns that have a stretch alignment, we go ahead and lay out at the |
2322 // stretched size to avoid an extra layout when applying alignment. | 2325 // stretched size to avoid an extra layout when applying alignment. |
2323 if (parent()->isFlexibleBox()) { | 2326 if (parent()->isFlexibleBox()) { |
2324 // For multiline columns, we need to apply align-content first, so we ca n't stretch now. | 2327 // For multiline columns, we need to apply align-content first, so we ca n't stretch now. |
2325 if (!parent()->style()->isColumnFlexDirection() || parent()->style()->fl exWrap() != FlexNoWrap) | 2328 if (!parent()->style()->isColumnFlexDirection() || parent()->style()->fl exWrap() != FlexNoWrap) |
2326 return true; | 2329 return true; |
2327 if (!columnFlexItemHasStretchAlignment(this)) | 2330 if (!flexItemHasStretchAlignment(this)) |
2328 return true; | 2331 return true; |
2329 } | 2332 } |
2330 | 2333 |
2331 // Flexible horizontal boxes lay out children at their intrinsic widths. Al so vertical boxes | 2334 // Flexible horizontal boxes lay out children at their intrinsic widths. Al so vertical boxes |
2332 // that don't stretch their kids lay out their children at their intrinsic w idths. | 2335 // that don't stretch their kids lay out their children at their intrinsic w idths. |
2333 // FIXME: Think about block-flow here. | 2336 // FIXME: Think about block-flow here. |
2334 // https://bugs.webkit.org/show_bug.cgi?id=46473 | 2337 // https://bugs.webkit.org/show_bug.cgi?id=46473 |
2335 if (parent()->isDeprecatedFlexibleBox() && (parent()->style()->boxOrient() = = HORIZONTAL || parent()->style()->boxAlign() != BSTRETCH)) | 2338 if (parent()->isDeprecatedFlexibleBox() && (parent()->style()->boxOrient() = = HORIZONTAL || parent()->style()->boxAlign() != BSTRETCH)) |
2336 return true; | 2339 return true; |
2337 | 2340 |
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2621 cb->addPercentHeightDescendant(const_cast<RenderBox*>(this)); | 2624 cb->addPercentHeightDescendant(const_cast<RenderBox*>(this)); |
2622 | 2625 |
2623 RenderStyle* cbstyle = cb->style(); | 2626 RenderStyle* cbstyle = cb->style(); |
2624 | 2627 |
2625 // A positioned element that specified both top/bottom or that specifies hei ght should be treated as though it has a height | 2628 // A positioned element that specified both top/bottom or that specifies hei ght should be treated as though it has a height |
2626 // explicitly specified that can be used for any percentage computations. | 2629 // explicitly specified that can be used for any percentage computations. |
2627 bool isOutOfFlowPositionedWithSpecifiedHeight = cb->isOutOfFlowPositioned() && (!cbstyle->logicalHeight().isAuto() || (!cbstyle->logicalTop().isAuto() && !c bstyle->logicalBottom().isAuto())); | 2630 bool isOutOfFlowPositionedWithSpecifiedHeight = cb->isOutOfFlowPositioned() && (!cbstyle->logicalHeight().isAuto() || (!cbstyle->logicalTop().isAuto() && !c bstyle->logicalBottom().isAuto())); |
2628 | 2631 |
2629 bool includeBorderPadding = isTable(); | 2632 bool includeBorderPadding = isTable(); |
2630 | 2633 |
2631 if (isHorizontalWritingMode() != cb->isHorizontalWritingMode()) | 2634 if (isHorizontalWritingMode() != cb->isHorizontalWritingMode()) { |
2632 availableHeight = containingBlockChild->containingBlockLogicalWidthForCo ntent(); | 2635 availableHeight = containingBlockChild->containingBlockLogicalWidthForCo ntent(); |
2633 else if (hasOverrideContainingBlockLogicalHeight()) | 2636 } else if (hasOverrideContainingBlockLogicalHeight()) { |
2634 availableHeight = overrideContainingBlockContentLogicalHeight(); | 2637 availableHeight = overrideContainingBlockContentLogicalHeight(); |
2635 else if (cb->isTableCell()) { | 2638 } else if (cb->isFlexItem() && flexItemHasStretchAlignment(cb) && cb->hasOve rrideHeight()) { |
2639 availableHeight = cb->overrideLogicalContentHeight(); | |
2640 } else if (cb->isTableCell()) { | |
2636 if (!skippedAutoHeightContainingBlock) { | 2641 if (!skippedAutoHeightContainingBlock) { |
2637 // Table cells violate what the CSS spec says to do with heights. Ba sically we | 2642 // Table cells violate what the CSS spec says to do with heights. Ba sically we |
2638 // don't care if the cell specified a height or not. We just always make ourselves | 2643 // don't care if the cell specified a height or not. We just always make ourselves |
2639 // be a percentage of the cell's current content height. | 2644 // be a percentage of the cell's current content height. |
2640 if (!cb->hasOverrideHeight()) { | 2645 if (!cb->hasOverrideHeight()) { |
2641 // Normally we would let the cell size intrinsically, but scroll ing overflow has to be | 2646 // Normally we would let the cell size intrinsically, but scroll ing overflow has to be |
2642 // treated differently, since WinIE lets scrolled overflow regio ns shrink as needed. | 2647 // treated differently, since WinIE lets scrolled overflow regio ns shrink as needed. |
2643 // While we can't get all cases right, we can at least detect wh en the cell has a specified | 2648 // While we can't get all cases right, we can at least detect wh en the cell has a specified |
2644 // height or when the table has a specified height. In these cas es we want to initially have | 2649 // height or when the table has a specified height. In these cas es we want to initially have |
2645 // no size and allow the flexing of the table or the cell to its specified height to cause us | 2650 // 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... | |
4772 RenderBox::BoxDecorationData::BoxDecorationData(const RenderStyle& style) | 4777 RenderBox::BoxDecorationData::BoxDecorationData(const RenderStyle& style) |
4773 { | 4778 { |
4774 backgroundColor = style.visitedDependentColor(CSSPropertyBackgroundColor); | 4779 backgroundColor = style.visitedDependentColor(CSSPropertyBackgroundColor); |
4775 hasBackground = backgroundColor.alpha() || style.hasBackgroundImage(); | 4780 hasBackground = backgroundColor.alpha() || style.hasBackgroundImage(); |
4776 ASSERT(hasBackground == style.hasBackground()); | 4781 ASSERT(hasBackground == style.hasBackground()); |
4777 hasBorder = style.hasBorder(); | 4782 hasBorder = style.hasBorder(); |
4778 hasAppearance = style.hasAppearance(); | 4783 hasAppearance = style.hasAppearance(); |
4779 } | 4784 } |
4780 | 4785 |
4781 } // namespace blink | 4786 } // namespace blink |
OLD | NEW |