| 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..ee496b206d6bc46739328cdfaffe5c3e5b3fc36d 100644
|
| --- a/third_party/WebKit/Source/core/layout/LayoutReplaced.cpp
|
| +++ b/third_party/WebKit/Source/core/layout/LayoutReplaced.cpp
|
| @@ -551,6 +551,21 @@ static inline LayoutUnit resolveHeightForRatio(LayoutUnit width, const FloatSize
|
| return LayoutUnit(width * aspectRatio.height() / aspectRatio.width());
|
| }
|
|
|
| +LayoutUnit LayoutReplaced::computeConstrainedLogicalWidth(ShouldComputePreferred shouldComputePreferred) const
|
| +{
|
| + if (shouldComputePreferred == ComputePreferred)
|
| + return computeReplacedLogicalWidthRespectingMinMaxWidth(LayoutUnit(), ComputePreferred);
|
| + // The aforementioned 'constraint equation' used for block-level, non-replaced elements in normal flow:
|
| + // 'margin-left' + 'border-left-width' + 'padding-left' + 'width' + 'padding-right' + 'border-right-width' + 'margin-right' = width of containing block
|
| + LayoutUnit logicalWidth = containingBlock()->availableLogicalWidth();
|
| +
|
| + // This solves above equation for 'width' (== logicalWidth).
|
| + LayoutUnit marginStart = minimumValueForLength(style()->marginStart(), logicalWidth);
|
| + LayoutUnit marginEnd = minimumValueForLength(style()->marginEnd(), logicalWidth);
|
| + logicalWidth = (logicalWidth - (marginStart + marginEnd + (size().width() - clientWidth()))).clampNegativeToZero();
|
| + return computeReplacedLogicalWidthRespectingMinMaxWidth(logicalWidth, shouldComputePreferred);
|
| +}
|
| +
|
| LayoutUnit LayoutReplaced::computeReplacedLogicalWidth(ShouldComputePreferred shouldComputePreferred) const
|
| {
|
| if (style()->logicalWidth().isSpecified() || style()->logicalWidth().isIntrinsic())
|
| @@ -564,7 +579,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,26 +590,16 @@ 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();
|
| + LayoutUnit estimatedUsedWidth = intrinsicSizingInfo.hasWidth ? LayoutUnit(constrainedSize.width()) : computeConstrainedLogicalWidth(shouldComputePreferred);
|
| + LayoutUnit logicalHeight = computeReplacedLogicalHeight(estimatedUsedWidth);
|
| return computeReplacedLogicalWidthRespectingMinMaxWidth(resolveWidthForRatio(logicalHeight, intrinsicSizingInfo.aspectRatio), shouldComputePreferred);
|
| }
|
|
|
| // 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
|
| // 'width' is undefined in CSS 2.1. However, it is suggested that, if the containing block's width does not itself depend on the replaced element's width, then
|
| // the used value of 'width' is calculated from the constraint equation used for block-level, non-replaced elements in normal flow.
|
| - if (computedHeightIsAuto && !intrinsicSizingInfo.hasWidth && !intrinsicSizingInfo.hasHeight) {
|
| - if (shouldComputePreferred == ComputePreferred)
|
| - return computeReplacedLogicalWidthRespectingMinMaxWidth(LayoutUnit(), ComputePreferred);
|
| - // The aforementioned 'constraint equation' used for block-level, non-replaced elements in normal flow:
|
| - // 'margin-left' + 'border-left-width' + 'padding-left' + 'width' + 'padding-right' + 'border-right-width' + 'margin-right' = width of containing block
|
| - LayoutUnit logicalWidth = containingBlock()->availableLogicalWidth();
|
| -
|
| - // This solves above equation for 'width' (== logicalWidth).
|
| - LayoutUnit marginStart = minimumValueForLength(style()->marginStart(), logicalWidth);
|
| - LayoutUnit marginEnd = minimumValueForLength(style()->marginEnd(), logicalWidth);
|
| - logicalWidth = (logicalWidth - (marginStart + marginEnd + (size().width() - clientWidth()))).clampNegativeToZero();
|
| - return computeReplacedLogicalWidthRespectingMinMaxWidth(logicalWidth, shouldComputePreferred);
|
| - }
|
| + if (computedHeightIsAuto && !intrinsicSizingInfo.hasWidth && !intrinsicSizingInfo.hasHeight)
|
| + return computeConstrainedLogicalWidth(shouldComputePreferred);
|
| }
|
|
|
| // Otherwise, if 'width' has a computed value of 'auto', and the element has an intrinsic width, then that intrinsic width is the used value of 'width'.
|
| @@ -611,7 +616,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 +637,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)
|
|
|