Incorrect embedded SVG image sizing on first load
authorfmalita@chromium.org <fmalita@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 22 Oct 2012 14:10:18 +0000 (14:10 +0000)
committerfmalita@chromium.org <fmalita@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 22 Oct 2012 14:10:18 +0000 (14:10 +0000)
https://bugs.webkit.org/show_bug.cgi?id=99489

Reviewed by Nikolas Zimmermann.

Source/WebCore:

RenderSVGImage::updateImageViewport() must be called after the image loader is finished,
to ensure that a SVGImageCache::SizeAndScalesMap entry is created even if layout has
already been performed.

Test: svg/custom/svg-image-initial-size.html

* rendering/svg/RenderSVGImage.cpp:
(WebCore::RenderSVGImage::imageChanged):

LayoutTests:

* svg/custom/svg-image-initial-size-expected.html: Added.
* svg/custom/svg-image-initial-size.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/svg/custom/svg-image-initial-size-expected.html [new file with mode: 0644]
LayoutTests/svg/custom/svg-image-initial-size.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/rendering/svg/RenderSVGImage.cpp

index 766b4f8047bfe98d9f91943700e8e879c7b2a8bd..9c739a1c45140bb068a8ec9ad39dfd1863e7cc6f 100644 (file)
@@ -1,3 +1,13 @@
+2012-10-22  Florin Malita  <fmalita@chromium.org>
+
+        Incorrect embedded SVG image sizing on first load
+        https://bugs.webkit.org/show_bug.cgi?id=99489
+
+        Reviewed by Nikolas Zimmermann.
+
+        * svg/custom/svg-image-initial-size-expected.html: Added.
+        * svg/custom/svg-image-initial-size.html: Added.
+
 2012-10-22  Christophe Dumez  <christophe.dumez@intel.com>
 
         [EFL][WK2] Skip plugins/npruntime/remove-property.html
 2012-10-22  Christophe Dumez  <christophe.dumez@intel.com>
 
         [EFL][WK2] Skip plugins/npruntime/remove-property.html
diff --git a/LayoutTests/svg/custom/svg-image-initial-size-expected.html b/LayoutTests/svg/custom/svg-image-initial-size-expected.html
new file mode 100644 (file)
index 0000000..73030f6
--- /dev/null
@@ -0,0 +1,8 @@
+<!DOCTYPE html>
+<html>
+  <body style="margin: 0px; padding: 0px;">
+    <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="600" height="600">
+      <rect width="500px" height="500px" fill="green"/>
+    </svg>
+  </body>
+</html>
diff --git a/LayoutTests/svg/custom/svg-image-initial-size.html b/LayoutTests/svg/custom/svg-image-initial-size.html
new file mode 100644 (file)
index 0000000..206784f
--- /dev/null
@@ -0,0 +1,15 @@
+<!DOCTYPE html>
+<html>
+  <!-- Test for https://bugs.webkit.org/show_bug.cgi?id=99489 -->
+  <body style="margin: 0px; padding: 0px;">
+    <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="600" height="600">
+      <g transform="scale(5)">
+        <image id="img" width="100px" height="100px" xlink:href="data:image/svg+xml,
+          <svg xmlns='http://www.w3.org/2000/svg'>
+            <rect width='100' height='100' fill='green'/>
+          </svg>
+          "/>
+      </g>
+    </svg>
+  </body>
+</html>
index 820680b03eaa177a0249182d8019793a3529ddf4..8e3676b4099ffef8c2790bad0fb788ccb24947af 100644 (file)
@@ -1,3 +1,19 @@
+2012-10-22  Florin Malita  <fmalita@chromium.org>
+
+        Incorrect embedded SVG image sizing on first load
+        https://bugs.webkit.org/show_bug.cgi?id=99489
+
+        Reviewed by Nikolas Zimmermann.
+
+        RenderSVGImage::updateImageViewport() must be called after the image loader is finished,
+        to ensure that a SVGImageCache::SizeAndScalesMap entry is created even if layout has
+        already been performed.
+
+        Test: svg/custom/svg-image-initial-size.html
+
+        * rendering/svg/RenderSVGImage.cpp:
+        (WebCore::RenderSVGImage::imageChanged):
+
 2012-10-22  Keishi Hattori  <keishi@webkit.org>
 
         Remove monthFormatInLDML
 2012-10-22  Keishi Hattori  <keishi@webkit.org>
 
         Remove monthFormatInLDML
index 5487b5e16b68446454f2f279739b24e6f2de86bb..47947e12cb03cd460d32e886d9ca4c0d3888788a 100644 (file)
@@ -179,6 +179,11 @@ void RenderSVGImage::imageChanged(WrappedImagePtr, const IntRect*)
     // Eventually notify parent resources, that we've changed.
     RenderSVGResource::markForLayoutAndParentResourceInvalidation(this, false);
 
     // Eventually notify parent resources, that we've changed.
     RenderSVGResource::markForLayoutAndParentResourceInvalidation(this, false);
 
+    // Update the SVGImageCache sizeAndScales entry in case image loading finished after layout.
+    // (https://bugs.webkit.org/show_bug.cgi?id=99489)
+    m_objectBoundingBox = FloatRect();
+    updateImageViewport();
+
     repaint();
 }
 
     repaint();
 }