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 1205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1216 } | 1216 } |
1217 | 1217 |
1218 void LayoutBox::clearExtraInlineAndBlockOffests() | 1218 void LayoutBox::clearExtraInlineAndBlockOffests() |
1219 { | 1219 { |
1220 if (gExtraInlineOffsetMap) | 1220 if (gExtraInlineOffsetMap) |
1221 gExtraInlineOffsetMap->remove(this); | 1221 gExtraInlineOffsetMap->remove(this); |
1222 if (gExtraBlockOffsetMap) | 1222 if (gExtraBlockOffsetMap) |
1223 gExtraBlockOffsetMap->remove(this); | 1223 gExtraBlockOffsetMap->remove(this); |
1224 } | 1224 } |
1225 | 1225 |
1226 static LayoutUnit borderPaddingWidthForBoxSizing(const LayoutBox* box) | |
1227 { | |
1228 // This excludes intrinsic padding on cells. It includes width from collapse
d borders. | |
1229 return box->computedCSSPaddingStart() + box->computedCSSPaddingEnd() + box->
borderStart() + box->borderEnd(); | |
1230 } | |
1231 | |
1232 static LayoutUnit borderPaddingHeightForBoxSizing(const LayoutBox* box) | |
1233 { | |
1234 // This excludes intrinsic padding on cells. It includes height from collaps
ed borders. | |
1235 return box->computedCSSPaddingBefore() + box->computedCSSPaddingAfter() + bo
x->borderBefore() + box->borderAfter(); | |
1236 } | |
1237 | |
1238 LayoutUnit LayoutBox::adjustBorderBoxLogicalWidthForBoxSizing(float width) const | 1226 LayoutUnit LayoutBox::adjustBorderBoxLogicalWidthForBoxSizing(float width) const |
1239 { | 1227 { |
1240 LayoutUnit bordersPlusPadding = borderPaddingWidthForBoxSizing(this); | 1228 LayoutUnit bordersPlusPadding = borderAndPaddingLogicalWidth(); |
1241 LayoutUnit result(width); | 1229 LayoutUnit result(width); |
1242 if (style()->boxSizing() == BoxSizingContentBox) | 1230 if (style()->boxSizing() == BoxSizingContentBox) |
1243 return result + bordersPlusPadding; | 1231 return result + bordersPlusPadding; |
1244 return std::max(result, bordersPlusPadding); | 1232 return std::max(result, bordersPlusPadding); |
1245 } | 1233 } |
1246 | 1234 |
1247 LayoutUnit LayoutBox::adjustBorderBoxLogicalHeightForBoxSizing(float height) con
st | 1235 LayoutUnit LayoutBox::adjustBorderBoxLogicalHeightForBoxSizing(float height) con
st |
1248 { | 1236 { |
1249 LayoutUnit bordersPlusPadding = borderPaddingHeightForBoxSizing(this); | 1237 LayoutUnit bordersPlusPadding = borderAndPaddingLogicalHeight(); |
1250 LayoutUnit result(height); | 1238 LayoutUnit result(height); |
1251 if (style()->boxSizing() == BoxSizingContentBox) | 1239 if (style()->boxSizing() == BoxSizingContentBox) |
1252 return result + bordersPlusPadding; | 1240 return result + bordersPlusPadding; |
1253 return std::max(result, bordersPlusPadding); | 1241 return std::max(result, bordersPlusPadding); |
1254 } | 1242 } |
1255 | 1243 |
1256 LayoutUnit LayoutBox::adjustContentBoxLogicalWidthForBoxSizing(float width) cons
t | 1244 LayoutUnit LayoutBox::adjustContentBoxLogicalWidthForBoxSizing(float width) cons
t |
1257 { | 1245 { |
1258 LayoutUnit result(width); | 1246 LayoutUnit result(width); |
1259 if (style()->boxSizing() == BoxSizingBorderBox) | 1247 if (style()->boxSizing() == BoxSizingBorderBox) |
1260 result -= borderPaddingWidthForBoxSizing(this); | 1248 result -= borderAndPaddingLogicalWidth(); |
1261 return std::max(LayoutUnit(), result); | 1249 return std::max(LayoutUnit(), result); |
1262 } | 1250 } |
1263 | 1251 |
1264 LayoutUnit LayoutBox::adjustContentBoxLogicalHeightForBoxSizing(float height) co
nst | 1252 LayoutUnit LayoutBox::adjustContentBoxLogicalHeightForBoxSizing(float height) co
nst |
1265 { | 1253 { |
1266 LayoutUnit result(height); | 1254 LayoutUnit result(height); |
1267 if (style()->boxSizing() == BoxSizingBorderBox) | 1255 if (style()->boxSizing() == BoxSizingBorderBox) |
1268 result -= borderPaddingHeightForBoxSizing(this); | 1256 result -= borderAndPaddingLogicalHeight(); |
1269 return std::max(LayoutUnit(), result); | 1257 return std::max(LayoutUnit(), result); |
1270 } | 1258 } |
1271 | 1259 |
1272 // Hit Testing | 1260 // Hit Testing |
1273 bool LayoutBox::nodeAtPoint(HitTestResult& result, const HitTestLocation& locati
onInContainer, const LayoutPoint& accumulatedOffset, HitTestAction action) | 1261 bool LayoutBox::nodeAtPoint(HitTestResult& result, const HitTestLocation& locati
onInContainer, const LayoutPoint& accumulatedOffset, HitTestAction action) |
1274 { | 1262 { |
1275 LayoutPoint adjustedLocation = accumulatedOffset + location(); | 1263 LayoutPoint adjustedLocation = accumulatedOffset + location(); |
1276 | 1264 |
1277 if (!isLayoutView()) { | 1265 if (!isLayoutView()) { |
1278 // Check if we need to do anything at all. | 1266 // Check if we need to do anything at all. |
(...skipping 1527 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2806 stretchedFlexHeight = toLayoutFlexibleBox(cb->parent())->childLogicalHei
ghtForPercentageResolution(*cb); | 2794 stretchedFlexHeight = toLayoutFlexibleBox(cb->parent())->childLogicalHei
ghtForPercentageResolution(*cb); |
2807 | 2795 |
2808 if (isHorizontalWritingMode() != cb->isHorizontalWritingMode()) { | 2796 if (isHorizontalWritingMode() != cb->isHorizontalWritingMode()) { |
2809 availableHeight = containingBlockChild->containingBlockLogicalWidthForCo
ntent(); | 2797 availableHeight = containingBlockChild->containingBlockLogicalWidthForCo
ntent(); |
2810 } else if (stretchedFlexHeight != LayoutUnit(-1)) { | 2798 } else if (stretchedFlexHeight != LayoutUnit(-1)) { |
2811 availableHeight = stretchedFlexHeight; | 2799 availableHeight = stretchedFlexHeight; |
2812 } else if (hasOverrideContainingBlockLogicalHeight() && !isOutOfFlowPosition
edWithSpecifiedHeight) { | 2800 } else if (hasOverrideContainingBlockLogicalHeight() && !isOutOfFlowPosition
edWithSpecifiedHeight) { |
2813 availableHeight = overrideContainingBlockContentLogicalHeight(); | 2801 availableHeight = overrideContainingBlockContentLogicalHeight(); |
2814 } else if (cb->isGridItem() && cb->hasOverrideLogicalContentHeight()) { | 2802 } else if (cb->isGridItem() && cb->hasOverrideLogicalContentHeight()) { |
2815 availableHeight = cb->overrideLogicalContentHeight(); | 2803 availableHeight = cb->overrideLogicalContentHeight(); |
2816 } else if (cbstyle.logicalHeight().isFixed()) { | |
2817 LayoutUnit contentBoxHeight = cb->adjustContentBoxLogicalHeightForBoxSiz
ing(cbstyle.logicalHeight().value()); | |
2818 availableHeight = cb->constrainContentBoxLogicalHeightByMinMax( | |
2819 contentBoxHeight - cb->scrollbarLogicalHeight(), LayoutUnit(-1)).cla
mpNegativeToZero(); | |
2820 } else if (cb->isTableCell()) { | 2804 } else if (cb->isTableCell()) { |
2821 if (!skippedAutoHeightContainingBlock) { | 2805 if (!skippedAutoHeightContainingBlock) { |
2822 // Table cells violate what the CSS spec says to do with heights. Ba
sically we | 2806 // Table cells violate what the CSS spec says to do with heights. Ba
sically we |
2823 // don't care if the cell specified a height or not. We just always
make ourselves | 2807 // don't care if the cell specified a height or not. We just always
make ourselves |
2824 // be a percentage of the cell's current content height. | 2808 // be a percentage of the cell's current content height. |
2825 if (!cb->hasOverrideLogicalContentHeight()) { | 2809 if (!cb->hasOverrideLogicalContentHeight()) { |
2826 // Normally we would let the cell size intrinsically, but scroll
ing overflow has to be | 2810 // Normally we would let the cell size intrinsically, but scroll
ing overflow has to be |
2827 // treated differently, since WinIE lets scrolled overflow regio
ns shrink as needed. | 2811 // treated differently, since WinIE lets scrolled overflow regio
ns shrink as needed. |
2828 // While we can't get all cases right, we can at least detect wh
en the cell has a specified | 2812 // While we can't get all cases right, we can at least detect wh
en the cell has a specified |
2829 // height or when the table has a specified height. In these cas
es we want to initially have | 2813 // height or when the table has a specified height. In these cas
es we want to initially have |
2830 // no size and allow the flexing of the table or the cell to its
specified height to cause us | 2814 // no size and allow the flexing of the table or the cell to its
specified height to cause us |
2831 // to grow to fill the space. This could end up being wrong in s
ome cases, but it is | 2815 // to grow to fill the space. This could end up being wrong in s
ome cases, but it is |
2832 // preferable to the alternative (sizing intrinsically and makin
g the row end up too big). | 2816 // preferable to the alternative (sizing intrinsically and makin
g the row end up too big). |
2833 LayoutTableCell* cell = toLayoutTableCell(cb); | 2817 LayoutTableCell* cell = toLayoutTableCell(cb); |
2834 if (scrollsOverflowY() && (!cell->style()->logicalHeight().isAut
o() || !cell->table()->style()->logicalHeight().isAuto())) | 2818 if (scrollsOverflowY() && (!cell->style()->logicalHeight().isAut
o() || !cell->table()->style()->logicalHeight().isAuto())) |
2835 return LayoutUnit(); | 2819 return LayoutUnit(); |
2836 return LayoutUnit(-1); | 2820 return LayoutUnit(-1); |
2837 } | 2821 } |
2838 availableHeight = cb->overrideLogicalContentHeight(); | 2822 availableHeight = cb->overrideLogicalContentHeight(); |
2839 includeBorderPadding = true; | 2823 includeBorderPadding = true; |
2840 } | 2824 } |
| 2825 } else if (cbstyle.logicalHeight().isFixed()) { |
| 2826 LayoutUnit contentBoxHeight = cb->adjustContentBoxLogicalHeightForBoxSiz
ing(LayoutUnit(cbstyle.logicalHeight().value())); |
| 2827 availableHeight = std::max(LayoutUnit(), cb->constrainContentBoxLogicalH
eightByMinMax(contentBoxHeight - cb->scrollbarLogicalHeight(), LayoutUnit(-1))); |
2841 } else if (cbstyle.logicalHeight().hasPercent() && !isOutOfFlowPositionedWit
hSpecifiedHeight) { | 2828 } else if (cbstyle.logicalHeight().hasPercent() && !isOutOfFlowPositionedWit
hSpecifiedHeight) { |
2842 // We need to recur and compute the percentage height for our containing
block. | 2829 // We need to recur and compute the percentage height for our containing
block. |
2843 LayoutUnit heightWithScrollbar = cb->computePercentageLogicalHeight(cbst
yle.logicalHeight()); | 2830 LayoutUnit heightWithScrollbar = cb->computePercentageLogicalHeight(cbst
yle.logicalHeight()); |
2844 if (heightWithScrollbar != -1) { | 2831 if (heightWithScrollbar != -1) { |
2845 LayoutUnit contentBoxHeightWithScrollbar = cb->adjustContentBoxLogic
alHeightForBoxSizing(heightWithScrollbar); | 2832 LayoutUnit contentBoxHeightWithScrollbar = cb->adjustContentBoxLogic
alHeightForBoxSizing(heightWithScrollbar); |
2846 // We need to adjust for min/max height because this method does not | 2833 // We need to adjust for min/max height because this method does not |
2847 // handle the min/max of the current block, its caller does. So the | 2834 // handle the min/max of the current block, its caller does. So the |
2848 // return value from the recursive call will not have been adjusted | 2835 // return value from the recursive call will not have been adjusted |
2849 // yet. | 2836 // yet. |
2850 LayoutUnit contentBoxHeight = cb->constrainContentBoxLogicalHeightBy
MinMax(contentBoxHeightWithScrollbar - cb->scrollbarLogicalHeight(), LayoutUnit(
-1)); | 2837 LayoutUnit contentBoxHeight = cb->constrainContentBoxLogicalHeightBy
MinMax(contentBoxHeightWithScrollbar - cb->scrollbarLogicalHeight(), LayoutUnit(
-1)); |
(...skipping 12 matching lines...) Expand all Loading... |
2863 if (availableHeight == -1) | 2850 if (availableHeight == -1) |
2864 return availableHeight; | 2851 return availableHeight; |
2865 | 2852 |
2866 availableHeight -= rootMarginBorderPaddingHeight; | 2853 availableHeight -= rootMarginBorderPaddingHeight; |
2867 | 2854 |
2868 if (isTable() && isOutOfFlowPositioned()) | 2855 if (isTable() && isOutOfFlowPositioned()) |
2869 availableHeight += cb->paddingLogicalHeight(); | 2856 availableHeight += cb->paddingLogicalHeight(); |
2870 | 2857 |
2871 LayoutUnit result = valueForLength(height, availableHeight); | 2858 LayoutUnit result = valueForLength(height, availableHeight); |
2872 if (includeBorderPadding) { | 2859 if (includeBorderPadding) { |
2873 // TODO(rhogan) crbug.com/467378: Doing this for content inside tables c
ells is wrong, it should fill | 2860 // FIXME: Table cells should default to box-sizing: border-box so we can
avoid this hack. |
2874 // whatever height the cell makes available. | 2861 // It is necessary to use the border-box to match WinIE's broken |
| 2862 // box model. This is essential for sizing inside |
| 2863 // table cells using percentage heights. |
2875 result -= borderAndPaddingLogicalHeight(); | 2864 result -= borderAndPaddingLogicalHeight(); |
2876 return std::max(LayoutUnit(), result); | 2865 return std::max(LayoutUnit(), result); |
2877 } | 2866 } |
2878 return result; | 2867 return result; |
2879 } | 2868 } |
2880 | 2869 |
2881 LayoutUnit LayoutBox::computeReplacedLogicalWidth(ShouldComputePreferred shouldC
omputePreferred) const | 2870 LayoutUnit LayoutBox::computeReplacedLogicalWidth(ShouldComputePreferred shouldC
omputePreferred) const |
2882 { | 2871 { |
2883 return computeReplacedLogicalWidthRespectingMinMaxWidth(computeReplacedLogic
alWidthUsing(MainOrPreferredSize, style()->logicalWidth()), shouldComputePreferr
ed); | 2872 return computeReplacedLogicalWidthRespectingMinMaxWidth(computeReplacedLogic
alWidthUsing(MainOrPreferredSize, style()->logicalWidth()), shouldComputePreferr
ed); |
2884 } | 2873 } |
(...skipping 1940 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4825 m_rareData->m_snapAreas->remove(&snapArea); | 4814 m_rareData->m_snapAreas->remove(&snapArea); |
4826 } | 4815 } |
4827 } | 4816 } |
4828 | 4817 |
4829 SnapAreaSet* LayoutBox::snapAreas() const | 4818 SnapAreaSet* LayoutBox::snapAreas() const |
4830 { | 4819 { |
4831 return m_rareData ? m_rareData->m_snapAreas.get() : nullptr; | 4820 return m_rareData ? m_rareData->m_snapAreas.get() : nullptr; |
4832 } | 4821 } |
4833 | 4822 |
4834 } // namespace blink | 4823 } // namespace blink |
OLD | NEW |