Title: [102176] branches/safari-534.53-branch/Source/WebCore

Diff

Modified: branches/safari-534.53-branch/Source/WebCore/ChangeLog (102175 => 102176)


--- branches/safari-534.53-branch/Source/WebCore/ChangeLog	2011-12-06 21:54:02 UTC (rev 102175)
+++ branches/safari-534.53-branch/Source/WebCore/ChangeLog	2011-12-06 21:58:16 UTC (rev 102176)
@@ -1,5 +1,30 @@
 2011-12-06  Lucas Forschler  <[email protected]>
 
+    Merge 95103
+
+    2011-09-14  Beth Dakin  <[email protected]>
+
+            https://bugs.webkit.org/show_bug.cgi?id=68054
+            Return an image scale factor as well as an Image* from CachedImage::brokenImage()
+
+            Reviewed by Darin Adler.
+
+            CachedImage::brokenImage() now returns a pair<Image*, float> where the float 
+            represents the image's scale factor. This is important because currently, the 
+            broken image will either be only 1x or 2x, but a deviceScaleFactor could 
+            theoretically be something different (1.5, 3, etc). So it is not safe to assume 
+            that the image's scale factor is equivalent to the deviceScaleFactor, and 
+            hardcoding 2 for now is lame.
+            * loader/cache/CachedImage.cpp:
+            (WebCore::CachedImage::brokenImage):
+            (WebCore::CachedImage::image):
+            * loader/cache/CachedImage.h:
+            * rendering/RenderImage.cpp:
+            (WebCore::RenderImage::imageSizeForError):
+            (WebCore::RenderImage::paintReplaced):
+
+2011-12-06  Lucas Forschler  <[email protected]>
+
     Merge 95099
 
     2011-09-14  David Hyatt  <[email protected]>

Modified: branches/safari-534.53-branch/Source/WebCore/loader/cache/CachedImage.cpp (102175 => 102176)


--- branches/safari-534.53-branch/Source/WebCore/loader/cache/CachedImage.cpp	2011-12-06 21:54:02 UTC (rev 102175)
+++ branches/safari-534.53-branch/Source/WebCore/loader/cache/CachedImage.cpp	2011-12-06 21:58:16 UTC (rev 102176)
@@ -113,15 +113,15 @@
         m_decodedDataDeletionTimer.startOneShot(interval);
 }
 
-Image* CachedImage::brokenImage(float deviceScaleFactor) const
+pair<Image*, float> CachedImage::brokenImage(float deviceScaleFactor) const
 {
     if (deviceScaleFactor >= 2) {
         DEFINE_STATIC_LOCAL(Image*, brokenImageHiRes, (Image::loadPlatformResource("missingImage@2x").leakRef()));
-        return brokenImageHiRes;
+        return make_pair(brokenImageHiRes, 2);
     }
 
     DEFINE_STATIC_LOCAL(Image*, brokenImageLoRes, (Image::loadPlatformResource("missingImage").leakRef()));
-    return brokenImageLoRes;
+    return make_pair(brokenImageLoRes, 1);
 }
 
 bool CachedImage::willPaintBrokenImage() const
@@ -137,7 +137,7 @@
         // Returning the 1x broken image is non-ideal, but we cannot reliably access the appropriate
         // deviceScaleFactor from here. It is critical that callers use CachedImage::brokenImage() 
         // when they need the real, deviceScaleFactor-appropriate broken image icon. 
-        return brokenImage(1);
+        return brokenImage(1).first;
     }
 
     if (m_image)

Modified: branches/safari-534.53-branch/Source/WebCore/loader/cache/CachedImage.h (102175 => 102176)


--- branches/safari-534.53-branch/Source/WebCore/loader/cache/CachedImage.h	2011-12-06 21:54:02 UTC (rev 102175)
+++ branches/safari-534.53-branch/Source/WebCore/loader/cache/CachedImage.h	2011-12-06 21:58:16 UTC (rev 102176)
@@ -47,7 +47,7 @@
     Image* image() const; // Returns the nullImage() if the image is not available yet.
     bool hasImage() const { return m_image.get(); }
 
-    Image* brokenImage(float deviceScaleFactor) const;
+    std::pair<Image*, float> brokenImage(float deviceScaleFactor) const; // Returns an image and the image's resolution scale factor.
     bool willPaintBrokenImage() const; 
 
     bool canRender(float multiplier) const { return !errorOccurred() && !imageSize(multiplier).isEmpty(); }

Modified: branches/safari-534.53-branch/Source/WebCore/rendering/RenderImage.cpp (102175 => 102176)


--- branches/safari-534.53-branch/Source/WebCore/rendering/RenderImage.cpp	2011-12-06 21:54:02 UTC (rev 102175)
+++ branches/safari-534.53-branch/Source/WebCore/rendering/RenderImage.cpp	2011-12-06 21:58:16 UTC (rev 102176)
@@ -88,16 +88,9 @@
     IntSize imageSize;
     if (newImage->willPaintBrokenImage()) {
         float deviceScaleFactor = Page::deviceScaleFactor(frame());
-        imageSize = newImage->brokenImage(deviceScaleFactor)->size();
-        if (deviceScaleFactor >= 2) {
-            // It is important to scale by 0.5 instead of the deviceScaleFactor because the
-            // high resolution broken image artwork is actually a 2x image. We should 
-            // consider adding functionality to Image to ask about the image's resolution,
-            // and then we could scale by 1 / resolution. This is a solution that would
-            // scale better since this hardcoded number will have to change if we ever get
-            // artwork at other, higher resolutions. 
-            imageSize.scale(0.5f);
-        }
+        pair<Image*, float> brokenImageAndImageScaleFactor = newImage->brokenImage(deviceScaleFactor);
+        imageSize = brokenImageAndImageScaleFactor.first->size();
+        imageSize.scale(1 / brokenImageAndImageScaleFactor.second);
     } else
         imageSize = newImage->image()->size();
 
@@ -283,10 +276,10 @@
             if (m_imageResource->errorOccurred() && !image->isNull() && usableWidth >= image->width() && usableHeight >= image->height()) {
                 float deviceScaleFactor = Page::deviceScaleFactor(frame());
                 // Call brokenImage() explicitly to ensure we get the broken image icon at the appropriate resolution.
-                image = m_imageResource->cachedImage()->brokenImage(deviceScaleFactor);
+                pair<Image*, float> brokenImageAndImageScaleFactor = m_imageResource->cachedImage()->brokenImage(deviceScaleFactor);
+                image = brokenImageAndImageScaleFactor.first;
                 IntSize imageSize = image->size();
-                if (deviceScaleFactor >= 2)
-                    imageSize.scale(0.5f);
+                imageSize.scale(1 / brokenImageAndImageScaleFactor.second);
                 // Center the error image, accounting for border and padding.
                 int centerX = (usableWidth - imageSize.width()) / 2; 
                 if (centerX < 0)
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to