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 2274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2285 if (logicalWidth.isIntrinsic()) | 2285 if (logicalWidth.isIntrinsic()) |
2286 return computeIntrinsicLogicalWidthUsing(logicalWidth, availableLogicalW
idth, borderAndPaddingLogicalWidth()); | 2286 return computeIntrinsicLogicalWidthUsing(logicalWidth, availableLogicalW
idth, borderAndPaddingLogicalWidth()); |
2287 | 2287 |
2288 LayoutUnit marginStart = 0; | 2288 LayoutUnit marginStart = 0; |
2289 LayoutUnit marginEnd = 0; | 2289 LayoutUnit marginEnd = 0; |
2290 LayoutUnit logicalWidthResult = fillAvailableMeasure(availableLogicalWidth,
marginStart, marginEnd); | 2290 LayoutUnit logicalWidthResult = fillAvailableMeasure(availableLogicalWidth,
marginStart, marginEnd); |
2291 | 2291 |
2292 if (shrinkToAvoidFloats() && cb->containsFloats()) | 2292 if (shrinkToAvoidFloats() && cb->containsFloats()) |
2293 logicalWidthResult = min(logicalWidthResult, shrinkLogicalWidthToAvoidFl
oats(marginStart, marginEnd, toRenderBlockFlow(cb))); | 2293 logicalWidthResult = min(logicalWidthResult, shrinkLogicalWidthToAvoidFl
oats(marginStart, marginEnd, toRenderBlockFlow(cb))); |
2294 | 2294 |
2295 if (widthType == MainOrPreferredSize && sizesLogicalWidthToFitContent(widthT
ype)) | 2295 if (widthType == MainOrPreferredSize && sizesLogicalWidthToFitContent(logica
lWidth)) |
2296 return max(minPreferredLogicalWidth(), min(maxPreferredLogicalWidth(), l
ogicalWidthResult)); | 2296 return max(minPreferredLogicalWidth(), min(maxPreferredLogicalWidth(), l
ogicalWidthResult)); |
2297 return logicalWidthResult; | 2297 return logicalWidthResult; |
2298 } | 2298 } |
2299 | 2299 |
2300 static bool columnFlexItemHasStretchAlignment(const RenderObject* flexitem) | 2300 static bool columnFlexItemHasStretchAlignment(const RenderObject* flexitem) |
2301 { | 2301 { |
2302 RenderObject* parent = flexitem->parent(); | 2302 RenderObject* parent = flexitem->parent(); |
2303 // auto margins mean we don't stretch. Note that this function will only be
used for | 2303 // auto margins mean we don't stretch. Note that this function will only be
used for |
2304 // widths, so we don't have to check marginBefore/marginAfter. | 2304 // widths, so we don't have to check marginBefore/marginAfter. |
2305 ASSERT(parent->style()->isColumnFlexDirection()); | 2305 ASSERT(parent->style()->isColumnFlexDirection()); |
2306 if (flexitem->style()->marginStart().isAuto() || flexitem->style()->marginEn
d().isAuto()) | 2306 if (flexitem->style()->marginStart().isAuto() || flexitem->style()->marginEn
d().isAuto()) |
2307 return false; | 2307 return false; |
2308 return flexitem->style()->alignSelf() == ItemPositionStretch || (flexitem->s
tyle()->alignSelf() == ItemPositionAuto && parent->style()->alignItems() == Item
PositionStretch); | 2308 return flexitem->style()->alignSelf() == ItemPositionStretch || (flexitem->s
tyle()->alignSelf() == ItemPositionAuto && parent->style()->alignItems() == Item
PositionStretch); |
2309 } | 2309 } |
2310 | 2310 |
2311 static bool isStretchingColumnFlexItem(const RenderObject* flexitem) | 2311 static bool isStretchingColumnFlexItem(const RenderObject* flexitem) |
2312 { | 2312 { |
2313 RenderObject* parent = flexitem->parent(); | 2313 RenderObject* parent = flexitem->parent(); |
2314 if (parent->isDeprecatedFlexibleBox() && parent->style()->boxOrient() == VER
TICAL && parent->style()->boxAlign() == BSTRETCH) | 2314 if (parent->isDeprecatedFlexibleBox() && parent->style()->boxOrient() == VER
TICAL && parent->style()->boxAlign() == BSTRETCH) |
2315 return true; | 2315 return true; |
2316 | 2316 |
2317 // We don't stretch multiline flexboxes because they need to apply line spac
ing (align-content) first. | 2317 // We don't stretch multiline flexboxes because they need to apply line spac
ing (align-content) first. |
2318 if (parent->isFlexibleBox() && parent->style()->flexWrap() == FlexNoWrap &&
parent->style()->isColumnFlexDirection() && columnFlexItemHasStretchAlignment(fl
exitem)) | 2318 if (parent->isFlexibleBox() && parent->style()->flexWrap() == FlexNoWrap &&
parent->style()->isColumnFlexDirection() && columnFlexItemHasStretchAlignment(fl
exitem)) |
2319 return true; | 2319 return true; |
2320 return false; | 2320 return false; |
2321 } | 2321 } |
2322 | 2322 |
2323 bool RenderBox::sizesLogicalWidthToFitContent(SizeType widthType) const | 2323 bool RenderBox::sizesLogicalWidthToFitContent(const Length& logicalWidth) const |
2324 { | 2324 { |
2325 // Marquees in WinIE are like a mixture of blocks and inline-blocks. They s
ize as though they're blocks, | 2325 // Marquees in WinIE are like a mixture of blocks and inline-blocks. They s
ize as though they're blocks, |
2326 // but they allow text to sit on the same line as the marquee. | 2326 // but they allow text to sit on the same line as the marquee. |
2327 if (isFloating() || (isInlineBlockOrInlineTable() && !isMarquee())) | 2327 if (isFloating() || (isInlineBlockOrInlineTable() && !isMarquee())) |
2328 return true; | 2328 return true; |
2329 | 2329 |
2330 // This code may look a bit strange. Basically width:intrinsic should clamp
the size when testing both | |
2331 // min-width and width. max-width is only clamped if it is also intrinsic. | |
2332 Length logicalWidth = (widthType == MaxSize) ? style()->logicalMaxWidth() :
style()->logicalWidth(); | |
2333 if (logicalWidth.type() == Intrinsic) | 2330 if (logicalWidth.type() == Intrinsic) |
2334 return true; | 2331 return true; |
2335 | 2332 |
2336 // Children of a horizontal marquee do not fill the container by default. | 2333 // Children of a horizontal marquee do not fill the container by default. |
2337 // FIXME: Need to deal with MAUTO value properly. It could be vertical. | 2334 // FIXME: Need to deal with MAUTO value properly. It could be vertical. |
2338 // FIXME: Think about block-flow here. Need to find out how marquee directi
on relates to | 2335 // FIXME: Think about block-flow here. Need to find out how marquee directi
on relates to |
2339 // block-flow (as well as how marquee overflow should relate to block flow). | 2336 // block-flow (as well as how marquee overflow should relate to block flow). |
2340 // https://bugs.webkit.org/show_bug.cgi?id=46472 | 2337 // https://bugs.webkit.org/show_bug.cgi?id=46472 |
2341 if (parent()->isMarquee()) { | 2338 if (parent()->isMarquee()) { |
2342 EMarqueeDirection dir = parent()->style()->marqueeDirection(); | 2339 EMarqueeDirection dir = parent()->style()->marqueeDirection(); |
(...skipping 16 matching lines...) Expand all Loading... |
2359 // that don't stretch their kids lay out their children at their intrinsic w
idths. | 2356 // that don't stretch their kids lay out their children at their intrinsic w
idths. |
2360 // FIXME: Think about block-flow here. | 2357 // FIXME: Think about block-flow here. |
2361 // https://bugs.webkit.org/show_bug.cgi?id=46473 | 2358 // https://bugs.webkit.org/show_bug.cgi?id=46473 |
2362 if (parent()->isDeprecatedFlexibleBox() && (parent()->style()->boxOrient() =
= HORIZONTAL || parent()->style()->boxAlign() != BSTRETCH)) | 2359 if (parent()->isDeprecatedFlexibleBox() && (parent()->style()->boxOrient() =
= HORIZONTAL || parent()->style()->boxAlign() != BSTRETCH)) |
2363 return true; | 2360 return true; |
2364 | 2361 |
2365 // Button, input, select, textarea, and legend treat width value of 'auto' a
s 'intrinsic' unless it's in a | 2362 // Button, input, select, textarea, and legend treat width value of 'auto' a
s 'intrinsic' unless it's in a |
2366 // stretching column flexbox. | 2363 // stretching column flexbox. |
2367 // FIXME: Think about block-flow here. | 2364 // FIXME: Think about block-flow here. |
2368 // https://bugs.webkit.org/show_bug.cgi?id=46473 | 2365 // https://bugs.webkit.org/show_bug.cgi?id=46473 |
2369 if (logicalWidth.type() == Auto && !isStretchingColumnFlexItem(this) && auto
WidthShouldFitContent()) | 2366 if (logicalWidth.isAuto() && !isStretchingColumnFlexItem(this) && autoWidthS
houldFitContent()) |
2370 return true; | 2367 return true; |
2371 | 2368 |
2372 if (isHorizontalWritingMode() != containingBlock()->isHorizontalWritingMode(
)) | 2369 if (isHorizontalWritingMode() != containingBlock()->isHorizontalWritingMode(
)) |
2373 return true; | 2370 return true; |
2374 | 2371 |
2375 return false; | 2372 return false; |
2376 } | 2373 } |
2377 | 2374 |
2378 bool RenderBox::autoWidthShouldFitContent() const | 2375 bool RenderBox::autoWidthShouldFitContent() const |
2379 { | 2376 { |
(...skipping 2283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4663 return 0; | 4660 return 0; |
4664 | 4661 |
4665 if (!layoutState && !flowThreadContainingBlock()) | 4662 if (!layoutState && !flowThreadContainingBlock()) |
4666 return 0; | 4663 return 0; |
4667 | 4664 |
4668 RenderBlock* containerBlock = containingBlock(); | 4665 RenderBlock* containerBlock = containingBlock(); |
4669 return containerBlock->offsetFromLogicalTopOfFirstPage() + logicalTop(); | 4666 return containerBlock->offsetFromLogicalTopOfFirstPage() + logicalTop(); |
4670 } | 4667 } |
4671 | 4668 |
4672 } // namespace WebCore | 4669 } // namespace WebCore |
OLD | NEW |