Index: Source/core/rendering/RenderReplaced.cpp |
diff --git a/Source/core/rendering/RenderReplaced.cpp b/Source/core/rendering/RenderReplaced.cpp |
index 900fa7d50acfd333c8436bdb3f51a0418793d2c9..f83db589eb6935e7a2c50338f03efd3d26c52779 100644 |
--- a/Source/core/rendering/RenderReplaced.cpp |
+++ b/Source/core/rendering/RenderReplaced.cpp |
@@ -316,7 +316,7 @@ LayoutRect RenderReplaced::replacedContentRect(const LayoutSize* overriddenIntri |
LayoutRect contentRect = contentBoxRect(); |
ObjectFit objectFit = style()->objectFit(); |
- if (objectFit == ObjectFitFill) { |
+ if (objectFit == ObjectFitFill && style()->objectPosition() == RenderStyle::initialObjectPosition()) { |
if (!isVideo() || RuntimeEnabledFeatures::objectFitPositionEnabled()) |
return contentRect; |
objectFit = ObjectFitContain; |
@@ -339,13 +339,13 @@ LayoutRect RenderReplaced::replacedContentRect(const LayoutSize* overriddenIntri |
finalRect.setSize(intrinsicSize); |
break; |
case ObjectFitFill: |
+ break; |
+ default: |
ASSERT_NOT_REACHED(); |
} |
- // FIXME: 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; |
+ LayoutUnit xOffset = minimumValueForLength(style()->objectPosition().x(), contentRect.width() - finalRect.width(), view()); |
+ LayoutUnit yOffset = minimumValueForLength(style()->objectPosition().y(), contentRect.height() - finalRect.height(), view()); |
finalRect.move(xOffset, yOffset); |
return finalRect; |