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 04c701c370f4fcc0f87c82d3f54ac3fae6a5d6d9..a46051ae99e14ff2d40693c6eb8b561cd9ddf298 100644 |
--- a/third_party/WebKit/Source/core/layout/LayoutBlock.cpp |
+++ b/third_party/WebKit/Source/core/layout/LayoutBlock.cpp |
@@ -1872,4 +1872,56 @@ void LayoutBlock::checkPositionedObjectsNeedLayout() |
#endif |
+LayoutUnit LayoutBlock::availableLogicalHeightForPercentageComputation(const LayoutBlock& block) |
jfernandez
2016/07/22 11:26:37
Shouldn't be const ?
Manuel Rego
2016/07/22 13:05:37
It's static so you cannot modify anything,
but onc
|
+{ |
+ LayoutUnit availableHeight(-1); |
+ |
+ const ComputedStyle& style = block.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 = block.isOutOfFlowPositioned() && (!style.logicalHeight().isAuto() || (!style.logicalTop().isAuto() && !style.logicalBottom().isAuto())); |
+ |
+ LayoutUnit stretchedFlexHeight(-1); |
+ if (block.isFlexItem()) |
+ stretchedFlexHeight = toLayoutFlexibleBox(block.parent())->childLogicalHeightForPercentageResolution(block); |
+ |
+ if (stretchedFlexHeight != LayoutUnit(-1)) { |
+ availableHeight = stretchedFlexHeight; |
+ } else if (block.isGridItem() && block.hasOverrideLogicalContentHeight()) { |
+ availableHeight = block.overrideLogicalContentHeight(); |
+ } else if (style.logicalHeight().isFixed()) { |
+ LayoutUnit contentBoxHeight = block.adjustContentBoxLogicalHeightForBoxSizing(style.logicalHeight().value()); |
+ availableHeight = block.constrainContentBoxLogicalHeightByMinMax( |
+ contentBoxHeight - block.scrollbarLogicalHeight(), LayoutUnit(-1)).clampNegativeToZero(); |
+ } else if (style.logicalHeight().hasPercent() && !isOutOfFlowPositionedWithSpecifiedHeight) { |
+ // We need to recur and compute the percentage height for our containing block. |
jfernandez
2016/07/22 11:26:37
I don't understand this comment. Could you please
Manuel Rego
2016/07/22 13:05:37
This comment was already in computePercentageLogic
|
+ LayoutUnit heightWithScrollbar = block.computePercentageLogicalHeight(style.logicalHeight()); |
+ if (heightWithScrollbar != -1) { |
+ LayoutUnit contentBoxHeightWithScrollbar = block.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 = block.constrainContentBoxLogicalHeightByMinMax(contentBoxHeightWithScrollbar - block.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; |
+ block.computeLogicalHeight(block.logicalHeight(), LayoutUnit(), computedValues); |
+ availableHeight = computedValues.m_extent - block.borderAndPaddingLogicalHeight() - block.scrollbarLogicalHeight(); |
+ } else if (block.isLayoutView()) { |
+ availableHeight = toLayoutView(block).viewLogicalHeightForPercentages(); |
+ } |
+ |
+ return availableHeight; |
+} |
+ |
+bool LayoutBlock::hasDefiniteLogicalHeight() const |
+{ |
+ return availableLogicalHeightForPercentageComputation(*this) != LayoutUnit(-1); |
+} |
+ |
} // namespace blink |