Round image sizes when zooming
https://bugs.webkit.org/show_bug.cgi?id=98205

Reviewed by Eric Seidel.

Source/WebCore: 

We currently floor image sizes when zooming which can result in
images being rendered at one pixel less than the actual size.
This is especially likely to happen for very large images.

Test: fast/sub-pixel/zoomed-image-tiles.html

* loader/cache/CachedImage.cpp:
(WebCore::CachedImage::imageSizeForRenderer):

LayoutTests: 

Add test for zoomed large image tiles.

* fast/images/zoomed-img-size.html:
* fast/sub-pixel/zoomed-image-tiles-expected.html: Added.
* fast/sub-pixel/zoomed-image-tiles.html: Added.
* platform/chromium-linux/svg/zoom/page/zoom-svg-through-object-with-absolute-size-2-expected.png:
* platform/chromium-linux/svg/zoom/page/zoom-svg-through-object-with-absolute-size-2-expected.txt:
* platform/chromium-linux/svg/zoom/page/zoom-svg-through-object-with-absolute-size-expected.png:
* platform/chromium-linux/svg/zoom/page/zoom-svg-through-object-with-absolute-size-expected.txt:
* platform/chromium-linux/svg/zoom/page/zoom-svg-through-object-with-percentage-size-expected.png:
* platform/chromium-linux/svg/zoom/page/zoom-svg-through-object-with-percentage-size-expected.txt:
* platform/chromium/fast/images/zoomed-img-size-expected.txt: Added.
* platform/gtk/TestExpectations:
* platform/mac-lion/TestExpectations:
* platform/mac-snowleopard/TestExpectations:
* platform/mac-wk2/TestExpectations:
* platform/mac/TestExpectations:
* platform/qt-4.8/TestExpectations:
* platform/qt/TestExpectations:
* platform/win-wk2/TestExpectations:
* platform/win-xp/TestExpectations:
* platform/win/TestExpectations:
* platform/wincairo/TestExpectations:
* platform/wk2/TestExpectations:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@130329 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog
index 5b006be..5384fae 100644
--- a/Source/WebCore/ChangeLog
+++ b/Source/WebCore/ChangeLog
@@ -1,3 +1,19 @@
+2012-10-03  Emil A Eklund  <eae@chromium.org>
+
+        Round image sizes when zooming
+        https://bugs.webkit.org/show_bug.cgi?id=98205
+
+        Reviewed by Eric Seidel.
+
+        We currently floor image sizes when zooming which can result in
+        images being rendered at one pixel less than the actual size.
+        This is especially likely to happen for very large images.
+
+        Test: fast/sub-pixel/zoomed-image-tiles.html
+
+        * loader/cache/CachedImage.cpp:
+        (WebCore::CachedImage::imageSizeForRenderer):
+
 2012-10-03  Hugo Parente Lima  <hugo.lima@openbossa.org>
 
         [WK2] PageViewportController.cpp is supposed to be a generic WebKit2 file but only works with Qt port.
diff --git a/Source/WebCore/loader/cache/CachedImage.cpp b/Source/WebCore/loader/cache/CachedImage.cpp
index 41075a7..bee9695 100644
--- a/Source/WebCore/loader/cache/CachedImage.cpp
+++ b/Source/WebCore/loader/cache/CachedImage.cpp
@@ -263,7 +263,12 @@
     float widthScale = m_image->hasRelativeWidth() ? 1.0f : multiplier;
     float heightScale = m_image->hasRelativeHeight() ? 1.0f : multiplier;
     IntSize minimumSize(imageSize.width() > 0 ? 1 : 0, imageSize.height() > 0 ? 1 : 0);
+#if ENABLE(SUBPIXEL_LAYOUT)
+    imageSize.setWidth(lroundf(imageSize.width() * widthScale));
+    imageSize.setHeight(lroundf(imageSize.height() * heightScale));
+#else
     imageSize.scale(widthScale, heightScale);
+#endif
     imageSize.clampToMinimumSize(minimumSize);
     return imageSize;
 }