Chromium Code Reviews| Index: Source/core/rendering/RenderReplaced.cpp |
| diff --git a/Source/core/rendering/RenderReplaced.cpp b/Source/core/rendering/RenderReplaced.cpp |
| index ff3d1914139ba5229ff8146dc5c2672e517372c0..3fafb8aab3585af11676d56975f6a89be7be80b8 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 |
|
ojan
2013/08/09 23:27:26
I don't think we typically use pointers to LayoutS
mstensho (USE GERRIT)
2013/08/12 13:39:11
But it's an optional parameter, currently only spe
ojan
2013/08/12 17:25:57
Ah right. Nevermind. What you have here is fine.
|
| +{ |
| + 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(finalRect.size().fitToAspectRatio(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 |
|
ojan
2013/08/09 23:27:26
This should be:
// FIXME: This is where...
mstensho (USE GERRIT)
2013/08/12 13:39:11
Done.
|
| + // 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. |