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

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

Issue 2148513002: Calculate border-box dimensions correctly for cells (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@619509-2
Patch Set: bug 627305 Created 4 years, 5 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
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 1155 matching lines...) Expand 10 before | Expand all | Expand 10 after
1166 } 1166 }
1167 1167
1168 void LayoutBox::clearExtraInlineAndBlockOffests() 1168 void LayoutBox::clearExtraInlineAndBlockOffests()
1169 { 1169 {
1170 if (gExtraInlineOffsetMap) 1170 if (gExtraInlineOffsetMap)
1171 gExtraInlineOffsetMap->remove(this); 1171 gExtraInlineOffsetMap->remove(this);
1172 if (gExtraBlockOffsetMap) 1172 if (gExtraBlockOffsetMap)
1173 gExtraBlockOffsetMap->remove(this); 1173 gExtraBlockOffsetMap->remove(this);
1174 } 1174 }
1175 1175
1176 static LayoutUnit borderPaddingWidthForBoxSizing(const LayoutBox* box)
1177 {
1178 // This excludes intrinsic padding on cells. It includes width from collapse d borders.
1179 return box->computedCSSPaddingStart() + box->computedCSSPaddingEnd() + box-> borderStart() + box->borderEnd();
1180 }
1181
1182 static LayoutUnit borderPaddingHeightForBoxSizing(const LayoutBox* box)
1183 {
1184 // This excludes intrinsic padding on cells. It includes height from collaps ed borders.
1185 return box->computedCSSPaddingBefore() + box->computedCSSPaddingAfter() + bo x->borderBefore() + box->borderAfter();
1186 }
1187
1176 LayoutUnit LayoutBox::adjustBorderBoxLogicalWidthForBoxSizing(float width) const 1188 LayoutUnit LayoutBox::adjustBorderBoxLogicalWidthForBoxSizing(float width) const
1177 { 1189 {
1178 LayoutUnit bordersPlusPadding = borderAndPaddingLogicalWidth(); 1190 LayoutUnit bordersPlusPadding = borderPaddingWidthForBoxSizing(this);
1179 LayoutUnit result(width); 1191 LayoutUnit result(width);
1180 if (style()->boxSizing() == BoxSizingContentBox) 1192 if (style()->boxSizing() == BoxSizingContentBox)
1181 return result + bordersPlusPadding; 1193 return result + bordersPlusPadding;
1182 return std::max(result, bordersPlusPadding); 1194 return std::max(result, bordersPlusPadding);
1183 } 1195 }
1184 1196
1185 LayoutUnit LayoutBox::adjustBorderBoxLogicalHeightForBoxSizing(float height) con st 1197 LayoutUnit LayoutBox::adjustBorderBoxLogicalHeightForBoxSizing(float height) con st
1186 { 1198 {
1187 LayoutUnit bordersPlusPadding = borderAndPaddingLogicalHeight(); 1199 LayoutUnit bordersPlusPadding = borderPaddingHeightForBoxSizing(this);
1188 LayoutUnit result(height); 1200 LayoutUnit result(height);
1189 if (style()->boxSizing() == BoxSizingContentBox) 1201 if (style()->boxSizing() == BoxSizingContentBox)
1190 return result + bordersPlusPadding; 1202 return result + bordersPlusPadding;
1191 return std::max(result, bordersPlusPadding); 1203 return std::max(result, bordersPlusPadding);
1192 } 1204 }
1193 1205
1194 LayoutUnit LayoutBox::adjustContentBoxLogicalWidthForBoxSizing(float width) cons t 1206 LayoutUnit LayoutBox::adjustContentBoxLogicalWidthForBoxSizing(float width) cons t
1195 { 1207 {
1196 LayoutUnit result(width); 1208 LayoutUnit result(width);
1197 if (style()->boxSizing() == BoxSizingBorderBox) 1209 if (style()->boxSizing() == BoxSizingBorderBox)
1198 result -= borderAndPaddingLogicalWidth(); 1210 result -= borderPaddingWidthForBoxSizing(this);
1199 return std::max(LayoutUnit(), result); 1211 return std::max(LayoutUnit(), result);
1200 } 1212 }
1201 1213
1202 LayoutUnit LayoutBox::adjustContentBoxLogicalHeightForBoxSizing(float height) co nst 1214 LayoutUnit LayoutBox::adjustContentBoxLogicalHeightForBoxSizing(float height) co nst
1203 { 1215 {
1204 LayoutUnit result(height); 1216 LayoutUnit result(height);
1205 if (style()->boxSizing() == BoxSizingBorderBox) 1217 if (style()->boxSizing() == BoxSizingBorderBox)
1206 result -= borderAndPaddingLogicalHeight(); 1218 result -= borderPaddingHeightForBoxSizing(this);
1207 return std::max(LayoutUnit(), result); 1219 return std::max(LayoutUnit(), result);
1208 } 1220 }
1209 1221
1210 // Hit Testing 1222 // Hit Testing
1211 bool LayoutBox::nodeAtPoint(HitTestResult& result, const HitTestLocation& locati onInContainer, const LayoutPoint& accumulatedOffset, HitTestAction action) 1223 bool LayoutBox::nodeAtPoint(HitTestResult& result, const HitTestLocation& locati onInContainer, const LayoutPoint& accumulatedOffset, HitTestAction action)
1212 { 1224 {
1213 LayoutPoint adjustedLocation = accumulatedOffset + location(); 1225 LayoutPoint adjustedLocation = accumulatedOffset + location();
1214 1226
1215 if (!isLayoutView()) { 1227 if (!isLayoutView()) {
1216 // Check if we need to do anything at all. 1228 // Check if we need to do anything at all.
(...skipping 1513 matching lines...) Expand 10 before | Expand all | Expand 10 after
2730 } else if (stretchedFlexHeight != LayoutUnit(-1)) { 2742 } else if (stretchedFlexHeight != LayoutUnit(-1)) {
2731 availableHeight = stretchedFlexHeight; 2743 availableHeight = stretchedFlexHeight;
2732 } else if (hasOverrideContainingBlockLogicalHeight() && !isOutOfFlowPosition edWithSpecifiedHeight) { 2744 } else if (hasOverrideContainingBlockLogicalHeight() && !isOutOfFlowPosition edWithSpecifiedHeight) {
2733 availableHeight = overrideContainingBlockContentLogicalHeight(); 2745 availableHeight = overrideContainingBlockContentLogicalHeight();
2734 } else if (cb->isGridItem() && cb->hasOverrideLogicalContentHeight()) { 2746 } else if (cb->isGridItem() && cb->hasOverrideLogicalContentHeight()) {
2735 availableHeight = cb->overrideLogicalContentHeight(); 2747 availableHeight = cb->overrideLogicalContentHeight();
2736 } else if (cbstyle.logicalHeight().isFixed()) { 2748 } else if (cbstyle.logicalHeight().isFixed()) {
2737 LayoutUnit contentBoxHeight = cb->adjustContentBoxLogicalHeightForBoxSiz ing(cbstyle.logicalHeight().value()); 2749 LayoutUnit contentBoxHeight = cb->adjustContentBoxLogicalHeightForBoxSiz ing(cbstyle.logicalHeight().value());
2738 availableHeight = cb->constrainContentBoxLogicalHeightByMinMax( 2750 availableHeight = cb->constrainContentBoxLogicalHeightByMinMax(
2739 contentBoxHeight - cb->scrollbarLogicalHeight(), LayoutUnit(-1)).cla mpNegativeToZero(); 2751 contentBoxHeight - cb->scrollbarLogicalHeight(), LayoutUnit(-1)).cla mpNegativeToZero();
2740 if (cb->isTableCell())
2741 includeBorderPadding = true;
2742 } else if (cb->isTableCell()) { 2752 } else if (cb->isTableCell()) {
2743 if (!skippedAutoHeightContainingBlock) { 2753 if (!skippedAutoHeightContainingBlock) {
2744 // Table cells violate what the CSS spec says to do with heights. Ba sically we 2754 // Table cells violate what the CSS spec says to do with heights. Ba sically we
2745 // don't care if the cell specified a height or not. We just always make ourselves 2755 // don't care if the cell specified a height or not. We just always make ourselves
2746 // be a percentage of the cell's current content height. 2756 // be a percentage of the cell's current content height.
2747 if (!cb->hasOverrideLogicalContentHeight()) { 2757 if (!cb->hasOverrideLogicalContentHeight()) {
2748 // Normally we would let the cell size intrinsically, but scroll ing overflow has to be 2758 // Normally we would let the cell size intrinsically, but scroll ing overflow has to be
2749 // treated differently, since WinIE lets scrolled overflow regio ns shrink as needed. 2759 // treated differently, since WinIE lets scrolled overflow regio ns shrink as needed.
2750 // While we can't get all cases right, we can at least detect wh en the cell has a specified 2760 // While we can't get all cases right, we can at least detect wh en the cell has a specified
2751 // height or when the table has a specified height. In these cas es we want to initially have 2761 // height or when the table has a specified height. In these cas es we want to initially have
(...skipping 2174 matching lines...) Expand 10 before | Expand all | Expand 10 after
4926 m_rareData->m_snapAreas->remove(&snapArea); 4936 m_rareData->m_snapAreas->remove(&snapArea);
4927 } 4937 }
4928 } 4938 }
4929 4939
4930 SnapAreaSet* LayoutBox::snapAreas() const 4940 SnapAreaSet* LayoutBox::snapAreas() const
4931 { 4941 {
4932 return m_rareData ? m_rareData->m_snapAreas.get() : nullptr; 4942 return m_rareData ? m_rareData->m_snapAreas.get() : nullptr;
4933 } 4943 }
4934 4944
4935 } // namespace blink 4945 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/platform/linux/fast/table/dynamic-descendant-percentage-height-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698