Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(168)

Side by Side Diff: Source/core/layout/LayoutBox.cpp

Issue 992483002: Percent height content should respect the fixed height of its containing cell (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: UPdated Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « LayoutTests/platform/win/fast/block/basic/quirk-percent-height-table-cell-expected.png ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 }
2473 } else if (cb->isTableCell()) { 2481 } else if (cb->isTableCell()) {
2474 if (!skippedAutoHeightContainingBlock) { 2482 if (!skippedAutoHeightContainingBlock) {
2475 // Table cells violate what the CSS spec says to do with heights. Ba sically we 2483 // Table cells violate what the CSS spec says to do with heights. Ba sically we
2476 // don't care if the cell specified a height or not. We just always make ourselves 2484 // don't care if the cell specified a height or not. We just always make ourselves
2477 // be a percentage of the cell's current content height. 2485 // be a percentage of the cell's current content height.
2478 if (!cb->hasOverrideHeight()) { 2486 if (!cb->hasOverrideHeight()) {
2479 // Normally we would let the cell size intrinsically, but scroll ing overflow has to be 2487 // Normally we would let the cell size intrinsically, but scroll ing overflow has to be
2480 // treated differently, since WinIE lets scrolled overflow regio ns shrink as needed. 2488 // treated differently, since WinIE lets scrolled overflow regio ns shrink as needed.
2481 // While we can't get all cases right, we can at least detect wh en the cell has a specified 2489 // While we can't get all cases right, we can at least detect wh en the cell has a specified
2482 // height or when the table has a specified height. In these cas es we want to initially have 2490 // height or when the table has a specified height. In these cas es we want to initially have
2483 // no size and allow the flexing of the table or the cell to its specified height to cause us 2491 // no size and allow the flexing of the table or the cell to its specified height to cause us
2484 // to grow to fill the space. This could end up being wrong in s ome cases, but it is 2492 // to grow to fill the space. This could end up being wrong in s ome cases, but it is
2485 // preferable to the alternative (sizing intrinsically and makin g the row end up too big). 2493 // preferable to the alternative (sizing intrinsically and makin g the row end up too big).
2486 LayoutTableCell* cell = toLayoutTableCell(cb); 2494 LayoutTableCell* cell = toLayoutTableCell(cb);
2487 if (scrollsOverflowY() && (!cell->style()->logicalHeight().isAut o() || !cell->table()->style()->logicalHeight().isAuto())) 2495 if (scrollsOverflowY() && (!cell->style()->logicalHeight().isAut o() || !cell->table()->style()->logicalHeight().isAuto()))
2488 return LayoutUnit(); 2496 return LayoutUnit();
2489 return -1; 2497 return -1;
2490 } 2498 }
2491 availableHeight = cb->overrideLogicalContentHeight(); 2499 availableHeight = cb->overrideLogicalContentHeight();
2492 includeBorderPadding = true; 2500 includeBorderPadding = true;
2493 } 2501 }
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));
2497 } else if (cbstyle.logicalHeight().isPercent() && !isOutOfFlowPositionedWith SpecifiedHeight) { 2502 } else if (cbstyle.logicalHeight().isPercent() && !isOutOfFlowPositionedWith SpecifiedHeight) {
2498 // We need to recur and compute the percentage height for our containing block. 2503 // We need to recur and compute the percentage height for our containing block.
2499 LayoutUnit heightWithScrollbar = cb->computePercentageLogicalHeight(cbst yle.logicalHeight()); 2504 LayoutUnit heightWithScrollbar = cb->computePercentageLogicalHeight(cbst yle.logicalHeight());
2500 if (heightWithScrollbar != -1) { 2505 if (heightWithScrollbar != -1) {
2501 LayoutUnit contentBoxHeightWithScrollbar = cb->adjustContentBoxLogic alHeightForBoxSizing(heightWithScrollbar); 2506 LayoutUnit contentBoxHeightWithScrollbar = cb->adjustContentBoxLogic alHeightForBoxSizing(heightWithScrollbar);
2502 // We need to adjust for min/max height because this method does not 2507 // We need to adjust for min/max height because this method does not
2503 // handle the min/max of the current block, its caller does. So the 2508 // handle the min/max of the current block, its caller does. So the
2504 // return value from the recursive call will not have been adjusted 2509 // return value from the recursive call will not have been adjusted
2505 // yet. 2510 // yet.
2506 LayoutUnit contentBoxHeight = cb->constrainContentBoxLogicalHeightBy MinMax(contentBoxHeightWithScrollbar - cb->scrollbarLogicalHeight(), -1); 2511 LayoutUnit contentBoxHeight = cb->constrainContentBoxLogicalHeightBy MinMax(contentBoxHeightWithScrollbar - cb->scrollbarLogicalHeight(), -1);
(...skipping 12 matching lines...) Expand all
2519 if (availableHeight == -1) 2524 if (availableHeight == -1)
2520 return availableHeight; 2525 return availableHeight;
2521 2526
2522 availableHeight -= rootMarginBorderPaddingHeight; 2527 availableHeight -= rootMarginBorderPaddingHeight;
2523 2528
2524 if (isTable() && isOutOfFlowPositioned()) 2529 if (isTable() && isOutOfFlowPositioned())
2525 availableHeight += cb->paddingLogicalHeight(); 2530 availableHeight += cb->paddingLogicalHeight();
2526 2531
2527 LayoutUnit result = valueForLength(height, availableHeight); 2532 LayoutUnit result = valueForLength(height, availableHeight);
2528 if (includeBorderPadding) { 2533 if (includeBorderPadding) {
2529 // FIXME: Table cells should default to box-sizing: border-box so we can avoid this hack. 2534 // TODO(rhogan) crbug.com/467378: Doing this for content inside tables c ells is wrong, it should fill
2530 // It is necessary to use the border-box to match WinIE's broken 2535 // whatever height the cell makes available.
2531 // box model. This is essential for sizing inside
2532 // table cells using percentage heights.
2533 result -= borderAndPaddingLogicalHeight(); 2536 result -= borderAndPaddingLogicalHeight();
2534 return std::max(LayoutUnit(), result); 2537 return std::max(LayoutUnit(), result);
2535 } 2538 }
2536 return result; 2539 return result;
2537 } 2540 }
2538 2541
2539 LayoutUnit LayoutBox::computeReplacedLogicalWidth(ShouldComputePreferred shouldC omputePreferred) const 2542 LayoutUnit LayoutBox::computeReplacedLogicalWidth(ShouldComputePreferred shouldC omputePreferred) const
2540 { 2543 {
2541 return computeReplacedLogicalWidthRespectingMinMaxWidth(computeReplacedLogic alWidthUsing(style()->logicalWidth()), shouldComputePreferred); 2544 return computeReplacedLogicalWidthRespectingMinMaxWidth(computeReplacedLogic alWidthUsing(style()->logicalWidth()), shouldComputePreferred);
2542 } 2545 }
(...skipping 2107 matching lines...) Expand 10 before | Expand all | Expand 10 after
4650 computedValues.m_margins.m_end = marginEnd(); 4653 computedValues.m_margins.m_end = marginEnd();
4651 4654
4652 setLogicalTop(oldLogicalTop); 4655 setLogicalTop(oldLogicalTop);
4653 setLogicalWidth(oldLogicalWidth); 4656 setLogicalWidth(oldLogicalWidth);
4654 setLogicalLeft(oldLogicalLeft); 4657 setLogicalLeft(oldLogicalLeft);
4655 setMarginLeft(oldMarginLeft); 4658 setMarginLeft(oldMarginLeft);
4656 setMarginRight(oldMarginRight); 4659 setMarginRight(oldMarginRight);
4657 } 4660 }
4658 4661
4659 } // namespace blink 4662 } // namespace blink
OLDNEW
« no previous file with comments | « LayoutTests/platform/win/fast/block/basic/quirk-percent-height-table-cell-expected.png ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698