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

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

Issue 1868013002: Percent height in auto height containers no longer computes as auto (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@303728-6
Patch Set: Updated Created 4 years, 8 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/LayoutReplaced.cpp
diff --git a/third_party/WebKit/Source/core/layout/LayoutReplaced.cpp b/third_party/WebKit/Source/core/layout/LayoutReplaced.cpp
index bd27c594a47772ee24036d0e686671722edca626..a080e31cce3950ed7ee2f907244345ac7875f93f 100644
--- a/third_party/WebKit/Source/core/layout/LayoutReplaced.cpp
+++ b/third_party/WebKit/Source/core/layout/LayoutReplaced.cpp
@@ -564,7 +564,7 @@ LayoutUnit LayoutReplaced::computeReplacedLogicalWidth(ShouldComputePreferred sh
FloatSize constrainedSize = constrainIntrinsicSizeToMinMax(intrinsicSizingInfo);
if (style()->logicalWidth().isAuto()) {
- bool computedHeightIsAuto = hasAutoHeightOrContainingBlockWithAutoHeight();
+ bool computedHeightIsAuto = style()->logicalHeight().isAuto();
// If 'height' and 'width' both have computed values of 'auto' and the element also has an intrinsic width, then that intrinsic width is the used value of 'width'.
if (computedHeightIsAuto && intrinsicSizingInfo.hasWidth)
@@ -575,8 +575,10 @@ LayoutUnit LayoutReplaced::computeReplacedLogicalWidth(ShouldComputePreferred sh
// or if 'width' has a computed value of 'auto', 'height' has some other computed value, and the element does have an intrinsic ratio; then the used value
// of 'width' is: (used height) * (intrinsic ratio)
if ((computedHeightIsAuto && !intrinsicSizingInfo.hasWidth && intrinsicSizingInfo.hasHeight) || !computedHeightIsAuto) {
- LayoutUnit logicalHeight = computeReplacedLogicalHeight();
- return computeReplacedLogicalWidthRespectingMinMaxWidth(resolveWidthForRatio(logicalHeight, intrinsicSizingInfo.aspectRatio), shouldComputePreferred);
+ LayoutUnit estimatedUsedWidth = intrinsicSizingInfo.hasWidth ? LayoutUnit(constrainedSize.width()) : containingBlock()->availableLogicalWidth();
+ LayoutUnit logicalHeight = computeReplacedLogicalHeight(estimatedUsedWidth);
+ LayoutUnit width = computeReplacedLogicalWidthRespectingMinMaxWidth(resolveWidthForRatio(logicalHeight, intrinsicSizingInfo.aspectRatio), shouldComputePreferred);
+ return width;
cbiesinger 2016/04/15 21:44:39 I would merge this line with the previous one and
}
// If 'height' and 'width' both have computed values of 'auto' and the element has an intrinsic ratio but no intrinsic height or width, then the used value of
@@ -611,7 +613,7 @@ LayoutUnit LayoutReplaced::computeReplacedLogicalWidth(ShouldComputePreferred sh
return computeReplacedLogicalWidthRespectingMinMaxWidth(intrinsicLogicalWidth(), shouldComputePreferred);
}
-LayoutUnit LayoutReplaced::computeReplacedLogicalHeight() const
+LayoutUnit LayoutReplaced::computeReplacedLogicalHeight(LayoutUnit estimatedUsedWidth) const
{
// 10.5 Content height: the 'height' property: http://www.w3.org/TR/CSS21/visudet.html#propdef-height
if (hasReplacedLogicalHeight())
@@ -632,8 +634,10 @@ LayoutUnit LayoutReplaced::computeReplacedLogicalHeight() const
// Otherwise, if 'height' has a computed value of 'auto', and the element has an intrinsic ratio then the used value of 'height' is:
// (used width) / (intrinsic ratio)
- if (!intrinsicSizingInfo.aspectRatio.isEmpty())
- return computeReplacedLogicalHeightRespectingMinMaxHeight(resolveHeightForRatio(availableLogicalWidth(), intrinsicSizingInfo.aspectRatio));
+ if (!intrinsicSizingInfo.aspectRatio.isEmpty()) {
+ LayoutUnit usedWidth = estimatedUsedWidth ? estimatedUsedWidth : availableLogicalWidth();
+ return computeReplacedLogicalHeightRespectingMinMaxHeight(resolveHeightForRatio(usedWidth, intrinsicSizingInfo.aspectRatio));
+ }
// Otherwise, if 'height' has a computed value of 'auto', and the element has an intrinsic height, then that intrinsic height is the used value of 'height'.
if (intrinsicSizingInfo.hasHeight)
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutReplaced.h ('k') | third_party/WebKit/Source/core/layout/LayoutVideo.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698