Title: [132731] trunk
- Revision
- 132731
- Author
- le...@chromium.org
- Date
- 2012-10-27 10:18:12 -0700 (Sat, 27 Oct 2012)
Log Message
Background images can incorrectly repeat with sub-pixel layout
https://bugs.webkit.org/show_bug.cgi?id=94622
Reviewed by Emil A Eklund.
Source/WebCore:
Attempting to better match author expectations when painting tiled background images. When under
the effects of zoom with sub-pixel layout enabled, the drawn size of a rendered element can
differ depending on its location. This change looks at the size of the scaled tiled background
image size, and either ceils or floors that value depending on if tiling that value will
result in us being one pixel or less short of covering the background size. This is a heuristic,
as sub-pixel/zooming isn't specced.
Test: fast/sub-pixel/scaled-background-image.html
* rendering/RenderBoxModelObject.cpp:
(WebCore::applySubPixelHeuristicForTileSize):
(WebCore):
(WebCore::RenderBoxModelObject::calculateFillTileSize):
LayoutTests:
* fast/sub-pixel/scaled-background-image-expected.html: Added.
* fast/sub-pixel/scaled-background-image.html: Added.
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (132730 => 132731)
--- trunk/LayoutTests/ChangeLog 2012-10-27 17:15:47 UTC (rev 132730)
+++ trunk/LayoutTests/ChangeLog 2012-10-27 17:18:12 UTC (rev 132731)
@@ -1,3 +1,13 @@
+2012-10-27 Levi Weintraub <le...@chromium.org>
+
+ Background images can incorrectly repeat with sub-pixel layout
+ https://bugs.webkit.org/show_bug.cgi?id=94622
+
+ Reviewed by Emil A Eklund.
+
+ * fast/sub-pixel/scaled-background-image-expected.html: Added.
+ * fast/sub-pixel/scaled-background-image.html: Added.
+
2012-10-26 Balazs Kelemen <kbal...@webkit.org>
[Qt] Pixel tests need rebaseline
Added: trunk/LayoutTests/fast/sub-pixel/scaled-background-image-expected.html (0 => 132731)
--- trunk/LayoutTests/fast/sub-pixel/scaled-background-image-expected.html (rev 0)
+++ trunk/LayoutTests/fast/sub-pixel/scaled-background-image-expected.html 2012-10-27 17:18:12 UTC (rev 132731)
@@ -0,0 +1,18 @@
+<html>
+<head>
+<style type="text/css">
+.norepeat {
+ background: url(../images/resources/exif-orientation-7-rl.jpg);
+ border: 5px solid black;
+ margin: 5px;
+ background-size: 124px 63px;
+ width: 124px;
+ height: 63px;
+}
+</style>
+<body>
+<div class="norepeat"></div>
+<p>This tests that we don't tile background images that are sufficiently close to the renderer size. The background image
+above should not repeat. See <a href="" 94622</a>.</p>
+</body>
+</html>
Added: trunk/LayoutTests/fast/sub-pixel/scaled-background-image.html (0 => 132731)
--- trunk/LayoutTests/fast/sub-pixel/scaled-background-image.html (rev 0)
+++ trunk/LayoutTests/fast/sub-pixel/scaled-background-image.html 2012-10-27 17:18:12 UTC (rev 132731)
@@ -0,0 +1,19 @@
+<html>
+<head>
+<style type="text/css">
+.norepeat {
+ background: url(../images/resources/exif-orientation-7-rl.jpg);
+ zoom: 1.25;
+ background-size: 99px 50px;
+ border: 4px solid black;
+ margin: 4px;
+ width: 99px;
+ height: 50px;
+}
+</style>
+<body>
+<div class="norepeat"></div>
+<p>This tests that we don't tile background images that are sufficiently close to the renderer size. The background image
+above should not repeat. See <a href="" 94622</a>.</p>
+</body>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (132730 => 132731)
--- trunk/Source/WebCore/ChangeLog 2012-10-27 17:15:47 UTC (rev 132730)
+++ trunk/Source/WebCore/ChangeLog 2012-10-27 17:18:12 UTC (rev 132731)
@@ -1,3 +1,24 @@
+2012-10-27 Levi Weintraub <le...@chromium.org>
+
+ Background images can incorrectly repeat with sub-pixel layout
+ https://bugs.webkit.org/show_bug.cgi?id=94622
+
+ Reviewed by Emil A Eklund.
+
+ Attempting to better match author expectations when painting tiled background images. When under
+ the effects of zoom with sub-pixel layout enabled, the drawn size of a rendered element can
+ differ depending on its location. This change looks at the size of the scaled tiled background
+ image size, and either ceils or floors that value depending on if tiling that value will
+ result in us being one pixel or less short of covering the background size. This is a heuristic,
+ as sub-pixel/zooming isn't specced.
+
+ Test: fast/sub-pixel/scaled-background-image.html
+
+ * rendering/RenderBoxModelObject.cpp:
+ (WebCore::applySubPixelHeuristicForTileSize):
+ (WebCore):
+ (WebCore::RenderBoxModelObject::calculateFillTileSize):
+
2012-10-27 Sheriff Bot <webkit.review....@gmail.com>
Unreviewed, rolling out r132725.
Modified: trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp (132730 => 132731)
--- trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp 2012-10-27 17:15:47 UTC (rev 132730)
+++ trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp 2012-10-27 17:18:12 UTC (rev 132731)
@@ -1046,6 +1046,12 @@
return positioningAreaSize;
}
+static inline void applySubPixelHeuristicForTileSize(LayoutSize& tileSize, const IntSize& positioningAreaSize)
+{
+ tileSize.setWidth(positioningAreaSize.width() - tileSize.width() <= 1 ? tileSize.width().ceil() : tileSize.width().floor());
+ tileSize.setHeight(positioningAreaSize.height() - tileSize.height() <= 1 ? tileSize.height().ceil() : tileSize.height().floor());
+}
+
IntSize RenderBoxModelObject::calculateFillTileSize(const FillLayer* fillLayer, const IntSize& positioningAreaSize) const
{
StyleImage* image = fillLayer->image();
@@ -1056,37 +1062,38 @@
RenderView* renderView = view();
switch (type) {
case SizeLength: {
- int w = positioningAreaSize.width();
- int h = positioningAreaSize.height();
+ LayoutSize tileSize = positioningAreaSize;
Length layerWidth = fillLayer->size().size.width();
Length layerHeight = fillLayer->size().size.height();
if (layerWidth.isFixed())
- w = layerWidth.value();
+ tileSize.setWidth(layerWidth.value());
else if (layerWidth.isPercent() || layerHeight.isViewportPercentage())
- w = valueForLength(layerWidth, positioningAreaSize.width(), renderView);
+ tileSize.setWidth(valueForLength(layerWidth, positioningAreaSize.width(), renderView));
if (layerHeight.isFixed())
- h = layerHeight.value();
+ tileSize.setHeight(layerHeight.value());
else if (layerHeight.isPercent() || layerHeight.isViewportPercentage())
- h = valueForLength(layerHeight, positioningAreaSize.height(), renderView);
-
+ tileSize.setHeight(valueForLength(layerHeight, positioningAreaSize.height(), renderView));
+
+ applySubPixelHeuristicForTileSize(tileSize, positioningAreaSize);
+
// If one of the values is auto we have to use the appropriate
// scale to maintain our aspect ratio.
if (layerWidth.isAuto() && !layerHeight.isAuto()) {
if (imageIntrinsicSize.height())
- w = imageIntrinsicSize.width() * h / imageIntrinsicSize.height();
+ tileSize.setWidth(imageIntrinsicSize.width() * tileSize.height() / imageIntrinsicSize.height());
} else if (!layerWidth.isAuto() && layerHeight.isAuto()) {
if (imageIntrinsicSize.width())
- h = imageIntrinsicSize.height() * w / imageIntrinsicSize.width();
+ tileSize.setHeight(imageIntrinsicSize.height() * tileSize.width() / imageIntrinsicSize.width());
} else if (layerWidth.isAuto() && layerHeight.isAuto()) {
// If both width and height are auto, use the image's intrinsic size.
- w = imageIntrinsicSize.width();
- h = imageIntrinsicSize.height();
+ tileSize = imageIntrinsicSize;
}
- return IntSize(max(0, w), max(0, h));
+ tileSize.clampNegativeToZero();
+ return flooredIntSize(tileSize);
}
case SizeNone: {
// If both values are ‘auto’ then the intrinsic width and/or height of the image should be used, if any.
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-changes