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

Unified Diff: third_party/WebKit/Source/core/layout/LayoutBoxModelObject.cpp

Issue 1456813002: Calculate Background Image Geometries using sub-pixel values (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: MOAR expectations Created 5 years 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: third_party/WebKit/Source/core/layout/LayoutBoxModelObject.cpp
diff --git a/third_party/WebKit/Source/core/layout/LayoutBoxModelObject.cpp b/third_party/WebKit/Source/core/layout/LayoutBoxModelObject.cpp
index 34c0b0792f4ba35358b9df99ac1b8106c46df1f8..4ea4eca5130f2aa11abd1e2e09214a9129b53d9d 100644
--- a/third_party/WebKit/Source/core/layout/LayoutBoxModelObject.cpp
+++ b/third_party/WebKit/Source/core/layout/LayoutBoxModelObject.cpp
@@ -688,60 +688,60 @@ LayoutUnit LayoutBoxModelObject::computedCSSPadding(const Length& padding) const
return minimumValueForLength(padding, w);
}
-static inline int resolveWidthForRatio(int height, const FloatSize& intrinsicRatio)
+static inline LayoutUnit resolveWidthForRatio(LayoutUnit height, const FloatSize& intrinsicRatio)
{
- return ceilf(height * intrinsicRatio.width() / intrinsicRatio.height());
+ return height * intrinsicRatio.width() / intrinsicRatio.height();
}
-static inline int resolveHeightForRatio(int width, const FloatSize& intrinsicRatio)
+static inline LayoutUnit resolveHeightForRatio(LayoutUnit width, const FloatSize& intrinsicRatio)
{
- return ceilf(width * intrinsicRatio.height() / intrinsicRatio.width());
+ return width * intrinsicRatio.height() / intrinsicRatio.width();
}
-static inline IntSize resolveAgainstIntrinsicWidthOrHeightAndRatio(const IntSize& size, const FloatSize& intrinsicRatio, int useWidth, int useHeight)
+static inline LayoutSize resolveAgainstIntrinsicWidthOrHeightAndRatio(const LayoutSize& size, const FloatSize& intrinsicRatio, LayoutUnit useWidth, LayoutUnit useHeight)
{
if (intrinsicRatio.isEmpty()) {
if (useWidth)
- return IntSize(useWidth, size.height());
- return IntSize(size.width(), useHeight);
+ return LayoutSize(useWidth, size.height());
+ return LayoutSize(size.width(), useHeight);
}
if (useWidth)
- return IntSize(useWidth, resolveHeightForRatio(useWidth, intrinsicRatio));
- return IntSize(resolveWidthForRatio(useHeight, intrinsicRatio), useHeight);
+ return LayoutSize(useWidth, resolveHeightForRatio(useWidth, intrinsicRatio));
+ return LayoutSize(resolveWidthForRatio(useHeight, intrinsicRatio), useHeight);
}
-static inline IntSize resolveAgainstIntrinsicRatio(const IntSize& size, const FloatSize& intrinsicRatio)
+static inline LayoutSize resolveAgainstIntrinsicRatio(const LayoutSize& size, const FloatSize& intrinsicRatio)
{
// Two possible solutions: (size.width(), solutionHeight) or (solutionWidth, size.height())
// "... must be assumed to be the largest dimensions..." = easiest answer: the rect with the largest surface area.
- int solutionWidth = resolveWidthForRatio(size.height(), intrinsicRatio);
- int solutionHeight = resolveHeightForRatio(size.width(), intrinsicRatio);
+ LayoutUnit solutionWidth = resolveWidthForRatio(size.height(), intrinsicRatio);
+ LayoutUnit solutionHeight = resolveHeightForRatio(size.width(), intrinsicRatio);
if (solutionWidth <= size.width()) {
if (solutionHeight <= size.height()) {
// If both solutions fit, choose the one covering the larger area.
- int areaOne = solutionWidth * size.height();
- int areaTwo = size.width() * solutionHeight;
+ LayoutUnit areaOne = solutionWidth * size.height();
+ LayoutUnit areaTwo = size.width() * solutionHeight;
if (areaOne < areaTwo)
- return IntSize(size.width(), solutionHeight);
- return IntSize(solutionWidth, size.height());
+ return LayoutSize(size.width(), solutionHeight);
+ return LayoutSize(solutionWidth, size.height());
}
// Only the first solution fits.
- return IntSize(solutionWidth, size.height());
+ return LayoutSize(solutionWidth, size.height());
}
// Only the second solution fits, assert that.
ASSERT(solutionHeight <= size.height());
- return IntSize(size.width(), solutionHeight);
+ return LayoutSize(size.width(), solutionHeight);
}
-IntSize LayoutBoxModelObject::calculateImageIntrinsicDimensions(StyleImage* image, const IntSize& positioningAreaSize, ScaleByEffectiveZoomOrNot shouldScaleOrNot) const
+LayoutSize LayoutBoxModelObject::calculateImageIntrinsicDimensions(StyleImage* image, const LayoutSize& positioningAreaSize, ScaleByEffectiveZoomOrNot shouldScaleOrNot) const
{
// A generated image without a fixed size, will always return the container size as intrinsic size.
if (image->isGeneratedImage() && image->usesImageContainerSize())
- return IntSize(positioningAreaSize.width(), positioningAreaSize.height());
+ return positioningAreaSize;
Length intrinsicWidth(Fixed);
Length intrinsicHeight(Fixed);
@@ -751,8 +751,9 @@ IntSize LayoutBoxModelObject::calculateImageIntrinsicDimensions(StyleImage* imag
ASSERT(intrinsicWidth.isFixed());
ASSERT(intrinsicHeight.isFixed());
- IntSize resolvedSize(intrinsicWidth.value(), intrinsicHeight.value());
- IntSize minimumSize(resolvedSize.width() > 0 ? 1 : 0, resolvedSize.height() > 0 ? 1 : 0);
+ LayoutSize resolvedSize(intrinsicWidth.value(), intrinsicHeight.value());
+ LayoutSize minimumSize(resolvedSize.width() > LayoutUnit() ? LayoutUnit(1) : LayoutUnit(),
+ resolvedSize.height() > LayoutUnit() ? LayoutUnit(1) : LayoutUnit());
if (shouldScaleOrNot == ScaleByEffectiveZoom)
resolvedSize.scale(style()->effectiveZoom());
resolvedSize.clampToMinimumSize(minimumSize);
@@ -764,7 +765,7 @@ IntSize LayoutBoxModelObject::calculateImageIntrinsicDimensions(StyleImage* imag
// * and an intrinsic aspect ratio, then the missing dimension is calculated from the given dimension and the ratio.
// * and no intrinsic aspect ratio, then the missing dimension is assumed to be the size of the rectangle that
// establishes the coordinate system for the 'background-position' property.
- if (resolvedSize.width() > 0 || resolvedSize.height() > 0)
+ if (resolvedSize.width() > LayoutUnit() || resolvedSize.height() > LayoutUnit())
return resolveAgainstIntrinsicWidthOrHeightAndRatio(positioningAreaSize, intrinsicRatio, resolvedSize.width(), resolvedSize.height());
// If the image has no intrinsic dimensions and has an intrinsic ratio the dimensions must be assumed to be the
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutBoxModelObject.h ('k') | third_party/WebKit/Source/core/layout/LayoutListMarker.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698