Reviewed by Maciej.
authorandersca <andersca@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 10 Aug 2007 01:04:14 +0000 (01:04 +0000)
committerandersca <andersca@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 10 Aug 2007 01:04:14 +0000 (01:04 +0000)
        <rdar://problem/5400029> iframes with an image src rarely load image

        Don't try to shrink standalone images in subframes. The resize event is not
        sent for subframes which screws up the shrink-to-fit logic.

        * loader/ImageDocument.cpp:
        (WebCore::ImageDocument::createDocumentStructure):
        (WebCore::ImageDocument::imageChanged):
        (WebCore::ImageDocument::shouldShrinkToFit):
        * loader/ImageDocument.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@24967 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebCore/ChangeLog
WebCore/loader/ImageDocument.cpp
WebCore/loader/ImageDocument.h

index 49dbadacb01fc0b0ba4750ba7d787d5d404a34f0..1d76fd9c6ce802cb19e82e09e4de924e29d8b03d 100644 (file)
@@ -1,3 +1,18 @@
+2007-08-09  Anders Carlsson  <andersca@apple.com>
+
+        Reviewed by Maciej.
+
+        <rdar://problem/5400029> iframes with an image src rarely load image
+        
+        Don't try to shrink standalone images in subframes. The resize event is not 
+        sent for subframes which screws up the shrink-to-fit logic.
+        
+        * loader/ImageDocument.cpp:
+        (WebCore::ImageDocument::createDocumentStructure):
+        (WebCore::ImageDocument::imageChanged):
+        (WebCore::ImageDocument::shouldShrinkToFit):
+        * loader/ImageDocument.h:
+
 2007-08-10  Holger Hans Peter Freyther  <zecke@selfish.org>
 
         Reviewed by Adam.
index 0dbef622446c081a7367219d46522e5467234149..842102e4546178c0f01f23e406f3ef49444e0eae 100644 (file)
@@ -159,7 +159,7 @@ void ImageDocument::createDocumentStructure()
     
     body->appendChild(imageElement, ec);
     
-    if (!frame()->page()->settings()->shrinksStandaloneImagesToFit())
+    if (!shouldShrinkToFit())
         return;
     
     // Add event listeners
@@ -226,7 +226,7 @@ void ImageDocument::imageChanged()
     
     m_imageSizeIsKnown = true;
     
-    if (!frame()->page()->settings()->shrinksStandaloneImagesToFit())
+    if (!shouldShrinkToFit())
         return;
     
     // Force resizing of the image
@@ -301,6 +301,12 @@ CachedImage* ImageDocument::cachedImage()
     return m_imageElement->cachedImage();
 }
 
+bool ImageDocument::shouldShrinkToFit() const
+{
+    return frame()->page()->settings()->shrinksStandaloneImagesToFit() &&
+        frame()->page()->mainFrame() == frame();
+}
+
 void ImageEventListener::handleEvent(Event* event, bool isWindowEvent)
 {
     if (event->type() == resizeEvent)
index aee2df35721e2dc09bbec10a399979d11826a1ea..0621cc9a604d98e1c684e67f665ea5c46ac8d6cd 100644 (file)
@@ -52,6 +52,7 @@ private:
     void resizeImageToFit();
     void restoreImageSize();
     bool imageFitsInWindow() const;
+    bool shouldShrinkToFit() const;
     float scale() const;
     
     HTMLImageElement* m_imageElement;