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

Unified Diff: third_party/WebKit/Source/core/layout/LayoutBlock.cpp

Issue 2154593003: [css-grid] Fix indefinite height detection (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Check skipContainingBlockForPercentHeightCalculation() Created 4 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/layout/LayoutBlock.cpp
diff --git a/third_party/WebKit/Source/core/layout/LayoutBlock.cpp b/third_party/WebKit/Source/core/layout/LayoutBlock.cpp
index 292d67a8febf18d5182fcefba20c846be7d62692..ea218e10a88b90d646da2eca5412298912696344 100644
--- a/third_party/WebKit/Source/core/layout/LayoutBlock.cpp
+++ b/third_party/WebKit/Source/core/layout/LayoutBlock.cpp
@@ -1877,4 +1877,59 @@ void LayoutBlock::checkPositionedObjectsNeedLayout()
#endif
+LayoutUnit LayoutBlock::availableLogicalHeightForPercentageComputation() const
+{
+ LayoutUnit availableHeight(-1);
+
+ // For anonymous blocks that are skipped during percentage height calculation, we consider them to have an indefinite height.
+ if (skipContainingBlockForPercentHeightCalculation(this))
+ return availableHeight;
+
+ const ComputedStyle& style = styleRef();
+
+ // A positioned element that specified both top/bottom or that specifies height should be treated as though it has a height
+ // explicitly specified that can be used for any percentage computations.
+ bool isOutOfFlowPositionedWithSpecifiedHeight = isOutOfFlowPositioned() && (!style.logicalHeight().isAuto() || (!style.logicalTop().isAuto() && !style.logicalBottom().isAuto()));
+
+ LayoutUnit stretchedFlexHeight(-1);
+ if (isFlexItem())
+ stretchedFlexHeight = toLayoutFlexibleBox(parent())->childLogicalHeightForPercentageResolution(*this);
+
+ if (stretchedFlexHeight != LayoutUnit(-1)) {
+ availableHeight = stretchedFlexHeight;
+ } else if (isGridItem() && hasOverrideLogicalContentHeight()) {
+ availableHeight = overrideLogicalContentHeight();
+ } else if (style.logicalHeight().isFixed()) {
+ LayoutUnit contentBoxHeight = adjustContentBoxLogicalHeightForBoxSizing(style.logicalHeight().value());
+ availableHeight = constrainContentBoxLogicalHeightByMinMax(
+ contentBoxHeight - scrollbarLogicalHeight(), LayoutUnit(-1)).clampNegativeToZero();
+ } else if (style.logicalHeight().hasPercent() && !isOutOfFlowPositionedWithSpecifiedHeight) {
+ LayoutUnit heightWithScrollbar = computePercentageLogicalHeight(style.logicalHeight());
+ if (heightWithScrollbar != -1) {
+ LayoutUnit contentBoxHeightWithScrollbar = adjustContentBoxLogicalHeightForBoxSizing(heightWithScrollbar);
+ // We need to adjust for min/max height because this method does not
+ // handle the min/max of the current block, its caller does. So the
+ // return value from the recursive call will not have been adjusted
+ // yet.
+ LayoutUnit contentBoxHeight = constrainContentBoxLogicalHeightByMinMax(contentBoxHeightWithScrollbar - scrollbarLogicalHeight(), LayoutUnit(-1));
+ availableHeight = std::max(LayoutUnit(), contentBoxHeight);
+ }
+ } else if (isOutOfFlowPositionedWithSpecifiedHeight) {
+ // Don't allow this to affect the block' size() member variable, since this
+ // can get called while the block is still laying out its kids.
+ LogicalExtentComputedValues computedValues;
+ computeLogicalHeight(logicalHeight(), LayoutUnit(), computedValues);
+ availableHeight = computedValues.m_extent - borderAndPaddingLogicalHeight() - scrollbarLogicalHeight();
+ } else if (isLayoutView()) {
+ availableHeight = view()->viewLogicalHeightForPercentages();
+ }
+
+ return availableHeight;
+}
+
+bool LayoutBlock::hasDefiniteLogicalHeight() const
+{
+ return availableLogicalHeightForPercentageComputation() != LayoutUnit(-1);
+}
+
} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutBlock.h ('k') | third_party/WebKit/Source/core/layout/LayoutBlockFlow.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698