| Index: Source/core/rendering/RenderReplaced.cpp
|
| diff --git a/Source/core/rendering/RenderReplaced.cpp b/Source/core/rendering/RenderReplaced.cpp
|
| index ff3d1914139ba5229ff8146dc5c2672e517372c0..9ca06dc6eef8bf3c517af8c1a15a45703bf48b9b 100644
|
| --- a/Source/core/rendering/RenderReplaced.cpp
|
| +++ b/Source/core/rendering/RenderReplaced.cpp
|
| @@ -311,6 +311,42 @@ void RenderReplaced::computeAspectRatioInformationForRenderBox(RenderBox* conten
|
| }
|
| }
|
|
|
| +LayoutRect RenderReplaced::replacedContentRect(const LayoutSize* overriddenIntrinsicSize) const
|
| +{
|
| + LayoutRect contentRect = contentBoxRect();
|
| + EObjectFit objectFit = style()->objectFit();
|
| + if (objectFit == ObjectFitFill)
|
| + return contentRect;
|
| +
|
| + LayoutSize intrinsicSize = overriddenIntrinsicSize ? *overriddenIntrinsicSize : this->intrinsicSize();
|
| + if (!intrinsicSize.width() || !intrinsicSize.height())
|
| + return contentRect;
|
| +
|
| + LayoutRect finalRect = contentRect;
|
| + switch (objectFit) {
|
| + case ObjectFitContain:
|
| + case ObjectFitScaleDown:
|
| + case ObjectFitCover:
|
| + finalRect.setSize(fitLayoutSizeToAspectRatio(finalRect.size(), intrinsicSize, objectFit == ObjectFitCover ? AspectRatioFitGrow : AspectRatioFitShrink));
|
| + if (objectFit != ObjectFitScaleDown || finalRect.width() <= intrinsicSize.width())
|
| + break;
|
| + // fall through
|
| + case ObjectFitNone:
|
| + finalRect.setSize(intrinsicSize);
|
| + break;
|
| + case ObjectFitFill:
|
| + ASSERT_NOT_REACHED();
|
| + }
|
| +
|
| + // This is where object-position should be taken into account, but since it's not implemented
|
| + // yet, assume the initial value of "50% 50%".
|
| + LayoutUnit xOffset = (contentRect.width() - finalRect.width()) / 2;
|
| + LayoutUnit yOffset = (contentRect.height() - finalRect.height()) / 2;
|
| + finalRect.move(xOffset, yOffset);
|
| +
|
| + return finalRect;
|
| +}
|
| +
|
| void RenderReplaced::computeIntrinsicRatioInformation(FloatSize& intrinsicSize, double& intrinsicRatio, bool& isPercentageIntrinsicSize) const
|
| {
|
| // If there's an embeddedContentBox() of a remote, referenced document available, this code-path should never be used.
|
|
|