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

Unified Diff: Source/core/rendering/RenderReplaced.cpp

Issue 22839023: Add support for the object-position CSS property. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 years, 4 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: Source/core/rendering/RenderReplaced.cpp
diff --git a/Source/core/rendering/RenderReplaced.cpp b/Source/core/rendering/RenderReplaced.cpp
index cf65f2f4a844a792be83d2a5fdb7ee432be1f4ed..158da9025cfb32fe783c7a71804d2e68dd5eb411 100644
--- a/Source/core/rendering/RenderReplaced.cpp
+++ b/Source/core/rendering/RenderReplaced.cpp
@@ -315,7 +315,7 @@ LayoutRect RenderReplaced::replacedContentRect(const LayoutSize* overriddenIntri
{
LayoutRect contentRect = contentBoxRect();
ObjectFit objectFit = style()->objectFit();
- if (objectFit == ObjectFitFill)
+ if (objectFit == ObjectFitFill && style()->objectPosition() == RenderStyle::initialObjectPosition())
return contentRect;
LayoutSize intrinsicSize = overriddenIntrinsicSize ? *overriddenIntrinsicSize : this->intrinsicSize();
@@ -335,13 +335,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;

Powered by Google App Engine
This is Rietveld 408576698