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

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

Issue 2296883002: Revert "Percent height content should respect the fixed height of its containing cell" (Closed)
Patch Set: Revert "Calculate border-box dimensions correctly for cells" Created 4 years, 3 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
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutBlock.cpp ('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 1248 matching lines...) Expand 10 before | Expand all | Expand 10 after
1259 } 1259 }
1260 1260
1261 void LayoutBox::clearExtraInlineAndBlockOffests() 1261 void LayoutBox::clearExtraInlineAndBlockOffests()
1262 { 1262 {
1263 if (gExtraInlineOffsetMap) 1263 if (gExtraInlineOffsetMap)
1264 gExtraInlineOffsetMap->remove(this); 1264 gExtraInlineOffsetMap->remove(this);
1265 if (gExtraBlockOffsetMap) 1265 if (gExtraBlockOffsetMap)
1266 gExtraBlockOffsetMap->remove(this); 1266 gExtraBlockOffsetMap->remove(this);
1267 } 1267 }
1268 1268
1269 static LayoutUnit borderPaddingWidthForBoxSizing(const LayoutBox* box)
1270 {
1271 // This excludes intrinsic padding on cells. It includes width from collapse d borders.
1272 return box->computedCSSPaddingStart() + box->computedCSSPaddingEnd() + box-> borderStart() + box->borderEnd();
1273 }
1274
1275 static LayoutUnit borderPaddingHeightForBoxSizing(const LayoutBox* box)
1276 {
1277 // This excludes intrinsic padding on cells. It includes height from collaps ed borders.
1278 return box->computedCSSPaddingBefore() + box->computedCSSPaddingAfter() + bo x->borderBefore() + box->borderAfter();
1279 }
1280
1281 LayoutUnit LayoutBox::adjustBorderBoxLogicalWidthForBoxSizing(float width) const 1269 LayoutUnit LayoutBox::adjustBorderBoxLogicalWidthForBoxSizing(float width) const
1282 { 1270 {
1283 LayoutUnit bordersPlusPadding = borderPaddingWidthForBoxSizing(this); 1271 LayoutUnit bordersPlusPadding = borderAndPaddingLogicalWidth();
1284 LayoutUnit result(width); 1272 LayoutUnit result(width);
1285 if (style()->boxSizing() == BoxSizingContentBox) 1273 if (style()->boxSizing() == BoxSizingContentBox)
1286 return result + bordersPlusPadding; 1274 return result + bordersPlusPadding;
1287 return std::max(result, bordersPlusPadding); 1275 return std::max(result, bordersPlusPadding);
1288 } 1276 }
1289 1277
1290 LayoutUnit LayoutBox::adjustBorderBoxLogicalHeightForBoxSizing(float height) con st 1278 LayoutUnit LayoutBox::adjustBorderBoxLogicalHeightForBoxSizing(float height) con st
1291 { 1279 {
1292 LayoutUnit bordersPlusPadding = borderPaddingHeightForBoxSizing(this); 1280 LayoutUnit bordersPlusPadding = borderAndPaddingLogicalHeight();
1293 LayoutUnit result(height); 1281 LayoutUnit result(height);
1294 if (style()->boxSizing() == BoxSizingContentBox) 1282 if (style()->boxSizing() == BoxSizingContentBox)
1295 return result + bordersPlusPadding; 1283 return result + bordersPlusPadding;
1296 return std::max(result, bordersPlusPadding); 1284 return std::max(result, bordersPlusPadding);
1297 } 1285 }
1298 1286
1299 LayoutUnit LayoutBox::adjustContentBoxLogicalWidthForBoxSizing(float width) cons t 1287 LayoutUnit LayoutBox::adjustContentBoxLogicalWidthForBoxSizing(float width) cons t
1300 { 1288 {
1301 LayoutUnit result(width); 1289 LayoutUnit result(width);
1302 if (style()->boxSizing() == BoxSizingBorderBox) 1290 if (style()->boxSizing() == BoxSizingBorderBox)
1303 result -= borderPaddingWidthForBoxSizing(this); 1291 result -= borderAndPaddingLogicalWidth();
1304 return std::max(LayoutUnit(), result); 1292 return std::max(LayoutUnit(), result);
1305 } 1293 }
1306 1294
1307 LayoutUnit LayoutBox::adjustContentBoxLogicalHeightForBoxSizing(float height) co nst 1295 LayoutUnit LayoutBox::adjustContentBoxLogicalHeightForBoxSizing(float height) co nst
1308 { 1296 {
1309 LayoutUnit result(height); 1297 LayoutUnit result(height);
1310 if (style()->boxSizing() == BoxSizingBorderBox) 1298 if (style()->boxSizing() == BoxSizingBorderBox)
1311 result -= borderPaddingHeightForBoxSizing(this); 1299 result -= borderAndPaddingLogicalHeight();
1312 return std::max(LayoutUnit(), result); 1300 return std::max(LayoutUnit(), result);
1313 } 1301 }
1314 1302
1315 // Hit Testing 1303 // Hit Testing
1316 bool LayoutBox::nodeAtPoint(HitTestResult& result, const HitTestLocation& locati onInContainer, const LayoutPoint& accumulatedOffset, HitTestAction action) 1304 bool LayoutBox::nodeAtPoint(HitTestResult& result, const HitTestLocation& locati onInContainer, const LayoutPoint& accumulatedOffset, HitTestAction action)
1317 { 1305 {
1318 LayoutPoint adjustedLocation = accumulatedOffset + location(); 1306 LayoutPoint adjustedLocation = accumulatedOffset + location();
1319 1307
1320 if (!isLayoutView()) { 1308 if (!isLayoutView()) {
1321 // Check if we need to do anything at all. 1309 // Check if we need to do anything at all.
(...skipping 1504 matching lines...) Expand 10 before | Expand all | Expand 10 after
2826 containingBlockChild = cb; 2814 containingBlockChild = cb;
2827 cb = cb->containingBlock(); 2815 cb = cb->containingBlock();
2828 } 2816 }
2829 cb->addPercentHeightDescendant(const_cast<LayoutBox*>(this)); 2817 cb->addPercentHeightDescendant(const_cast<LayoutBox*>(this));
2830 2818
2831 LayoutUnit availableHeight; 2819 LayoutUnit availableHeight;
2832 if (isHorizontalWritingMode() != cb->isHorizontalWritingMode()) { 2820 if (isHorizontalWritingMode() != cb->isHorizontalWritingMode()) {
2833 availableHeight = containingBlockChild->containingBlockLogicalWidthForCo ntent(); 2821 availableHeight = containingBlockChild->containingBlockLogicalWidthForCo ntent();
2834 } else if (hasOverrideContainingBlockLogicalHeight()) { 2822 } else if (hasOverrideContainingBlockLogicalHeight()) {
2835 availableHeight = overrideContainingBlockContentLogicalHeight(); 2823 availableHeight = overrideContainingBlockContentLogicalHeight();
2836 } else if (!cb->styleRef().logicalHeight().isFixed() && cb->isTableCell()) { 2824 } else if (cb->isTableCell()) {
2837 if (!skippedAutoHeightContainingBlock) { 2825 if (!skippedAutoHeightContainingBlock) {
2838 // Table cells violate what the CSS spec says to do with heights. Ba sically we 2826 // Table cells violate what the CSS spec says to do with heights. Ba sically we
2839 // don't care if the cell specified a height or not. We just always make ourselves 2827 // don't care if the cell specified a height or not. We just always make ourselves
2840 // be a percentage of the cell's current content height. 2828 // be a percentage of the cell's current content height.
2841 if (!cb->hasOverrideLogicalContentHeight()) { 2829 if (!cb->hasOverrideLogicalContentHeight()) {
2842 // Normally we would let the cell size intrinsically, but scroll ing overflow has to be 2830 // Normally we would let the cell size intrinsically, but scroll ing overflow has to be
2843 // treated differently, since WinIE lets scrolled overflow regio ns shrink as needed. 2831 // treated differently, since WinIE lets scrolled overflow regio ns shrink as needed.
2844 // While we can't get all cases right, we can at least detect wh en the cell has a specified 2832 // While we can't get all cases right, we can at least detect wh en the cell has a specified
2845 // height or when the table has a specified height. In these cas es we want to initially have 2833 // height or when the table has a specified height. In these cas es we want to initially have
2846 // no size and allow the flexing of the table or the cell to its specified height to cause us 2834 // no size and allow the flexing of the table or the cell to its specified height to cause us
(...skipping 13 matching lines...) Expand all
2860 if (availableHeight == -1) 2848 if (availableHeight == -1)
2861 return availableHeight; 2849 return availableHeight;
2862 2850
2863 availableHeight -= rootMarginBorderPaddingHeight; 2851 availableHeight -= rootMarginBorderPaddingHeight;
2864 2852
2865 if (isTable() && isOutOfFlowPositioned()) 2853 if (isTable() && isOutOfFlowPositioned())
2866 availableHeight += cb->paddingLogicalHeight(); 2854 availableHeight += cb->paddingLogicalHeight();
2867 2855
2868 LayoutUnit result = valueForLength(height, availableHeight); 2856 LayoutUnit result = valueForLength(height, availableHeight);
2869 bool includeBorderPadding = isTable() 2857 bool includeBorderPadding = isTable()
2870 || (cb->isTableCell() && !cb->styleRef().logicalHeight().isFixed() && !s kippedAutoHeightContainingBlock && cb->hasOverrideLogicalContentHeight()); 2858 || (cb->isTableCell() && !skippedAutoHeightContainingBlock && cb->hasOve rrideLogicalContentHeight());
2871 2859
2872 if (includeBorderPadding) { 2860 if (includeBorderPadding) {
2873 // TODO(rhogan) crbug.com/467378: Doing this for content inside tables c ells is wrong, it should fill 2861 // FIXME: Table cells should default to box-sizing: border-box so we can avoid this hack.
2874 // whatever height the cell makes available. 2862 // It is necessary to use the border-box to match WinIE's broken
2863 // box model. This is essential for sizing inside
2864 // table cells using percentage heights.
2875 result -= borderAndPaddingLogicalHeight(); 2865 result -= borderAndPaddingLogicalHeight();
2876 return std::max(LayoutUnit(), result); 2866 return std::max(LayoutUnit(), result);
2877 } 2867 }
2878 return result; 2868 return result;
2879 } 2869 }
2880 2870
2881 LayoutUnit LayoutBox::computeReplacedLogicalWidth(ShouldComputePreferred shouldC omputePreferred) const 2871 LayoutUnit LayoutBox::computeReplacedLogicalWidth(ShouldComputePreferred shouldC omputePreferred) const
2882 { 2872 {
2883 return computeReplacedLogicalWidthRespectingMinMaxWidth(computeReplacedLogic alWidthUsing(MainOrPreferredSize, style()->logicalWidth()), shouldComputePreferr ed); 2873 return computeReplacedLogicalWidthRespectingMinMaxWidth(computeReplacedLogic alWidthUsing(MainOrPreferredSize, style()->logicalWidth()), shouldComputePreferr ed);
2884 } 2874 }
(...skipping 1942 matching lines...) Expand 10 before | Expand all | Expand 10 after
4827 m_rareData->m_snapAreas->remove(&snapArea); 4817 m_rareData->m_snapAreas->remove(&snapArea);
4828 } 4818 }
4829 } 4819 }
4830 4820
4831 SnapAreaSet* LayoutBox::snapAreas() const 4821 SnapAreaSet* LayoutBox::snapAreas() const
4832 { 4822 {
4833 return m_rareData ? m_rareData->m_snapAreas.get() : nullptr; 4823 return m_rareData ? m_rareData->m_snapAreas.get() : nullptr;
4834 } 4824 }
4835 4825
4836 } // namespace blink 4826 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutBlock.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698