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

Unified Diff: Source/WebCore/rendering/RenderBoxModelObject.cpp

Issue 10379031: Merge 114095 - Background width (or height) is wrong if width (or height) * zoom < 1. (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/1084/
Patch Set: Created 8 years, 7 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
« no previous file with comments | « Source/WebCore/platform/graphics/IntSize.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/WebCore/rendering/RenderBoxModelObject.cpp
===================================================================
--- Source/WebCore/rendering/RenderBoxModelObject.cpp (revision 116270)
+++ Source/WebCore/rendering/RenderBoxModelObject.cpp (working copy)
@@ -955,49 +955,45 @@
IntSize RenderBoxModelObject::calculateImageIntrinsicDimensions(StyleImage* image, const IntSize& positioningAreaSize) const
{
- int resolvedWidth = 0;
- int resolvedHeight = 0;
- FloatSize intrinsicRatio;
-
// A generated image without a fixed size, will always return the container size as intrinsic size.
- if (image->isGeneratedImage() && image->usesImageContainerSize()) {
- resolvedWidth = positioningAreaSize.width();
- resolvedHeight = positioningAreaSize.height();
- } else {
- Length intrinsicWidth;
- Length intrinsicHeight;
- image->computeIntrinsicDimensions(this, intrinsicWidth, intrinsicHeight, intrinsicRatio);
+ if (image->isGeneratedImage() && image->usesImageContainerSize())
+ return IntSize(positioningAreaSize.width(), positioningAreaSize.height());
- // Intrinsic dimensions expressed as percentages must be resolved relative to the dimensions of the rectangle
- // that establishes the coordinate system for the 'background-position' property.
+ Length intrinsicWidth;
+ Length intrinsicHeight;
+ FloatSize intrinsicRatio;
+ image->computeIntrinsicDimensions(this, intrinsicWidth, intrinsicHeight, intrinsicRatio);
- // FIXME: Remove unnecessary rounding when layout is off ints: webkit.org/b/63656
- if (intrinsicWidth.isPercent() && intrinsicHeight.isPercent() && intrinsicRatio.isEmpty()) {
- // Resolve width/height percentages against positioningAreaSize, only if no intrinsic ratio is provided.
- resolvedWidth = static_cast<int>(round(positioningAreaSize.width() * intrinsicWidth.percent() / 100));
- resolvedHeight = static_cast<int>(round(positioningAreaSize.height() * intrinsicHeight.percent() / 100));
- } else {
- if (intrinsicWidth.isFixed())
- resolvedWidth = static_cast<int>(intrinsicWidth.value() * style()->effectiveZoom());
- if (intrinsicHeight.isFixed())
- resolvedHeight = static_cast<int>(intrinsicHeight.value() * style()->effectiveZoom());
- }
+ // Intrinsic dimensions expressed as percentages must be resolved relative to the dimensions of the rectangle
+ // that establishes the coordinate system for the 'background-position' property.
+
+ // FIXME: Remove unnecessary rounding when layout is off ints: webkit.org/b/63656
+ if (intrinsicWidth.isPercent() && intrinsicHeight.isPercent() && intrinsicRatio.isEmpty()) {
+ // Resolve width/height percentages against positioningAreaSize, only if no intrinsic ratio is provided.
+ int resolvedWidth = static_cast<int>(round(positioningAreaSize.width() * intrinsicWidth.percent() / 100));
+ int resolvedHeight = static_cast<int>(round(positioningAreaSize.height() * intrinsicHeight.percent() / 100));
+ return IntSize(resolvedWidth, resolvedHeight);
}
- if (resolvedWidth > 0 && resolvedHeight > 0)
- return IntSize(resolvedWidth, resolvedHeight);
+ IntSize resolvedSize(intrinsicWidth.isFixed() ? intrinsicWidth.value() : 0, intrinsicHeight.isFixed() ? intrinsicHeight.value() : 0);
+ IntSize minimumSize(resolvedSize.width() > 0 ? 1 : 0, resolvedSize.height() > 0 ? 1 : 0);
+ resolvedSize.scale(style()->effectiveZoom());
+ resolvedSize.clampToMinimumSize(minimumSize);
+ if (!resolvedSize.isEmpty())
+ return resolvedSize;
+
// If the image has one of either an intrinsic width or an intrinsic height:
// * 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 ((resolvedWidth && !resolvedHeight) || (!resolvedWidth && resolvedHeight))
- return resolveAgainstIntrinsicWidthOrHeightAndRatio(positioningAreaSize, intrinsicRatio, resolvedWidth, resolvedHeight);
+ if (resolvedSize.width() > 0 || resolvedSize.height() > 0)
+ 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
// largest dimensions at that ratio such that neither dimension exceeds the dimensions of the rectangle that
// establishes the coordinate system for the 'background-position' property.
- if (!resolvedWidth && !resolvedHeight && !intrinsicRatio.isEmpty())
+ if (!intrinsicRatio.isEmpty())
return resolveAgainstIntrinsicRatio(positioningAreaSize, intrinsicRatio);
// If the image has no intrinsic ratio either, then the dimensions must be assumed to be the rectangle that
« no previous file with comments | « Source/WebCore/platform/graphics/IntSize.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698