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 2452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2463 // A positioned element that specified both top/bottom or that specifies hei
ght should be treated as though it has a height | 2463 // A positioned element that specified both top/bottom or that specifies hei
ght should be treated as though it has a height |
2464 // explicitly specified that can be used for any percentage computations. | 2464 // explicitly specified that can be used for any percentage computations. |
2465 bool isOutOfFlowPositionedWithSpecifiedHeight = cb->isOutOfFlowPositioned()
&& (!cbstyle.logicalHeight().isAuto() || (!cbstyle.logicalTop().isAuto() && !cbs
tyle.logicalBottom().isAuto())); | 2465 bool isOutOfFlowPositionedWithSpecifiedHeight = cb->isOutOfFlowPositioned()
&& (!cbstyle.logicalHeight().isAuto() || (!cbstyle.logicalTop().isAuto() && !cbs
tyle.logicalBottom().isAuto())); |
2466 | 2466 |
2467 bool includeBorderPadding = isTable(); | 2467 bool includeBorderPadding = isTable(); |
2468 | 2468 |
2469 if (isHorizontalWritingMode() != cb->isHorizontalWritingMode()) { | 2469 if (isHorizontalWritingMode() != cb->isHorizontalWritingMode()) { |
2470 availableHeight = containingBlockChild->containingBlockLogicalWidthForCo
ntent(); | 2470 availableHeight = containingBlockChild->containingBlockLogicalWidthForCo
ntent(); |
2471 } else if (hasOverrideContainingBlockLogicalHeight()) { | 2471 } else if (hasOverrideContainingBlockLogicalHeight()) { |
2472 availableHeight = overrideContainingBlockContentLogicalHeight(); | 2472 availableHeight = overrideContainingBlockContentLogicalHeight(); |
2473 } else if (cbstyle.logicalHeight().isFixed()) { | |
2474 LayoutUnit contentBoxHeight = cb->adjustContentBoxLogicalHeightForBoxSiz
ing(cbstyle.logicalHeight().value()); | |
2475 availableHeight = std::max(LayoutUnit(), cb->constrainContentBoxLogicalH
eightByMinMax(contentBoxHeight - cb->scrollbarLogicalHeight(), -1)); | |
2476 if (cb->isTableCell()) { | |
2477 includeBorderPadding = true; | |
2478 // We're sizing content to the height from the cell's style so don't
involve the intrinsic padding used to align the content. | |
2479 availableHeight -= cb->computedCSSPaddingBefore() + cb->computedCSSP
addingAfter() + cb->borderBefore() + cb->borderAfter(); | |
2480 } | |
2481 } else if (cb->isTableCell()) { | 2473 } else if (cb->isTableCell()) { |
2482 if (!skippedAutoHeightContainingBlock) { | 2474 if (!skippedAutoHeightContainingBlock) { |
2483 // Table cells violate what the CSS spec says to do with heights. Ba
sically we | 2475 // Table cells violate what the CSS spec says to do with heights. Ba
sically we |
2484 // don't care if the cell specified a height or not. We just always
make ourselves | 2476 // don't care if the cell specified a height or not. We just always
make ourselves |
2485 // be a percentage of the cell's current content height. | 2477 // be a percentage of the cell's current content height. |
2486 if (!cb->hasOverrideHeight()) { | 2478 if (!cb->hasOverrideHeight()) { |
2487 // Normally we would let the cell size intrinsically, but scroll
ing overflow has to be | 2479 // Normally we would let the cell size intrinsically, but scroll
ing overflow has to be |
2488 // treated differently, since WinIE lets scrolled overflow regio
ns shrink as needed. | 2480 // treated differently, since WinIE lets scrolled overflow regio
ns shrink as needed. |
2489 // While we can't get all cases right, we can at least detect wh
en the cell has a specified | 2481 // While we can't get all cases right, we can at least detect wh
en the cell has a specified |
2490 // height or when the table has a specified height. In these cas
es we want to initially have | 2482 // height or when the table has a specified height. In these cas
es we want to initially have |
2491 // no size and allow the flexing of the table or the cell to its
specified height to cause us | 2483 // no size and allow the flexing of the table or the cell to its
specified height to cause us |
2492 // to grow to fill the space. This could end up being wrong in s
ome cases, but it is | 2484 // to grow to fill the space. This could end up being wrong in s
ome cases, but it is |
2493 // preferable to the alternative (sizing intrinsically and makin
g the row end up too big). | 2485 // preferable to the alternative (sizing intrinsically and makin
g the row end up too big). |
2494 LayoutTableCell* cell = toLayoutTableCell(cb); | 2486 LayoutTableCell* cell = toLayoutTableCell(cb); |
2495 if (scrollsOverflowY() && (!cell->style()->logicalHeight().isAut
o() || !cell->table()->style()->logicalHeight().isAuto())) | 2487 if (scrollsOverflowY() && (!cell->style()->logicalHeight().isAut
o() || !cell->table()->style()->logicalHeight().isAuto())) |
2496 return LayoutUnit(); | 2488 return LayoutUnit(); |
2497 return -1; | 2489 return -1; |
2498 } | 2490 } |
2499 availableHeight = cb->overrideLogicalContentHeight(); | 2491 availableHeight = cb->overrideLogicalContentHeight(); |
2500 includeBorderPadding = true; | 2492 includeBorderPadding = true; |
2501 } | 2493 } |
| 2494 } else if (cbstyle.logicalHeight().isFixed()) { |
| 2495 LayoutUnit contentBoxHeight = cb->adjustContentBoxLogicalHeightForBoxSiz
ing(cbstyle.logicalHeight().value()); |
| 2496 availableHeight = std::max(LayoutUnit(), cb->constrainContentBoxLogicalH
eightByMinMax(contentBoxHeight - cb->scrollbarLogicalHeight(), -1)); |
2502 } else if (cbstyle.logicalHeight().isPercent() && !isOutOfFlowPositionedWith
SpecifiedHeight) { | 2497 } else if (cbstyle.logicalHeight().isPercent() && !isOutOfFlowPositionedWith
SpecifiedHeight) { |
2503 // We need to recur and compute the percentage height for our containing
block. | 2498 // We need to recur and compute the percentage height for our containing
block. |
2504 LayoutUnit heightWithScrollbar = cb->computePercentageLogicalHeight(cbst
yle.logicalHeight()); | 2499 LayoutUnit heightWithScrollbar = cb->computePercentageLogicalHeight(cbst
yle.logicalHeight()); |
2505 if (heightWithScrollbar != -1) { | 2500 if (heightWithScrollbar != -1) { |
2506 LayoutUnit contentBoxHeightWithScrollbar = cb->adjustContentBoxLogic
alHeightForBoxSizing(heightWithScrollbar); | 2501 LayoutUnit contentBoxHeightWithScrollbar = cb->adjustContentBoxLogic
alHeightForBoxSizing(heightWithScrollbar); |
2507 // We need to adjust for min/max height because this method does not | 2502 // We need to adjust for min/max height because this method does not |
2508 // handle the min/max of the current block, its caller does. So the | 2503 // handle the min/max of the current block, its caller does. So the |
2509 // return value from the recursive call will not have been adjusted | 2504 // return value from the recursive call will not have been adjusted |
2510 // yet. | 2505 // yet. |
2511 LayoutUnit contentBoxHeight = cb->constrainContentBoxLogicalHeightBy
MinMax(contentBoxHeightWithScrollbar - cb->scrollbarLogicalHeight(), -1); | 2506 LayoutUnit contentBoxHeight = cb->constrainContentBoxLogicalHeightBy
MinMax(contentBoxHeightWithScrollbar - cb->scrollbarLogicalHeight(), -1); |
(...skipping 12 matching lines...) Expand all Loading... |
2524 if (availableHeight == -1) | 2519 if (availableHeight == -1) |
2525 return availableHeight; | 2520 return availableHeight; |
2526 | 2521 |
2527 availableHeight -= rootMarginBorderPaddingHeight; | 2522 availableHeight -= rootMarginBorderPaddingHeight; |
2528 | 2523 |
2529 if (isTable() && isOutOfFlowPositioned()) | 2524 if (isTable() && isOutOfFlowPositioned()) |
2530 availableHeight += cb->paddingLogicalHeight(); | 2525 availableHeight += cb->paddingLogicalHeight(); |
2531 | 2526 |
2532 LayoutUnit result = valueForLength(height, availableHeight); | 2527 LayoutUnit result = valueForLength(height, availableHeight); |
2533 if (includeBorderPadding) { | 2528 if (includeBorderPadding) { |
2534 // TODO(rhogan) crbug.com/467378: Doing this for content inside tables c
ells is wrong, it should fill | 2529 // FIXME: Table cells should default to box-sizing: border-box so we can
avoid this hack. |
2535 // whatever height the cell makes available. | 2530 // It is necessary to use the border-box to match WinIE's broken |
| 2531 // box model. This is essential for sizing inside |
| 2532 // table cells using percentage heights. |
2536 result -= borderAndPaddingLogicalHeight(); | 2533 result -= borderAndPaddingLogicalHeight(); |
2537 return std::max(LayoutUnit(), result); | 2534 return std::max(LayoutUnit(), result); |
2538 } | 2535 } |
2539 return result; | 2536 return result; |
2540 } | 2537 } |
2541 | 2538 |
2542 LayoutUnit LayoutBox::computeReplacedLogicalWidth(ShouldComputePreferred shouldC
omputePreferred) const | 2539 LayoutUnit LayoutBox::computeReplacedLogicalWidth(ShouldComputePreferred shouldC
omputePreferred) const |
2543 { | 2540 { |
2544 return computeReplacedLogicalWidthRespectingMinMaxWidth(computeReplacedLogic
alWidthUsing(style()->logicalWidth()), shouldComputePreferred); | 2541 return computeReplacedLogicalWidthRespectingMinMaxWidth(computeReplacedLogic
alWidthUsing(style()->logicalWidth()), shouldComputePreferred); |
2545 } | 2542 } |
(...skipping 2107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4653 computedValues.m_margins.m_end = marginEnd(); | 4650 computedValues.m_margins.m_end = marginEnd(); |
4654 | 4651 |
4655 setLogicalTop(oldLogicalTop); | 4652 setLogicalTop(oldLogicalTop); |
4656 setLogicalWidth(oldLogicalWidth); | 4653 setLogicalWidth(oldLogicalWidth); |
4657 setLogicalLeft(oldLogicalLeft); | 4654 setLogicalLeft(oldLogicalLeft); |
4658 setMarginLeft(oldMarginLeft); | 4655 setMarginLeft(oldMarginLeft); |
4659 setMarginRight(oldMarginRight); | 4656 setMarginRight(oldMarginRight); |
4660 } | 4657 } |
4661 | 4658 |
4662 } // namespace blink | 4659 } // namespace blink |
OLD | NEW |