Bug 942451 - preserveApectRatio changes on SVG images do not cause a repaint. r=jwatt, a=lsblakk
authorRobert Longson <longsonr@gmail.com>
Sun, 24 Nov 2013 19:50:45 +0000
changeset 166599 b241eaa5d3b83f6c0f30f699ba1f5be0d6acf902
parent 166598 6c018c4f2eaedec9601ce9244d868b28a6b1e646
child 166600 1e7e095cfcf4e21ac5bfdf2788d4fa48c97185d9
push id3066
push userakeybl@mozilla.com
push dateMon, 09 Dec 2013 19:58:46 +0000
treeherdermozilla-beta@a31a0dce83aa [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjwatt, lsblakk
bugs942451
milestone27.0a2
Bug 942451 - preserveApectRatio changes on SVG images do not cause a repaint. r=jwatt, a=lsblakk
layout/reftests/svg/image/image-preserveAspectRatio-05.svg
layout/reftests/svg/image/reftest.list
layout/svg/nsSVGImageFrame.cpp
new file mode 100644
--- /dev/null
+++ b/layout/reftests/svg/image/image-preserveAspectRatio-05.svg
@@ -0,0 +1,41 @@
+<!--
+     Any copyright is dedicated to the Public Domain.
+     http://creativecommons.org/publicdomain/zero/1.0/
+-->
+<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" class="reftest-wait">
+
+  <title>Testing that dynamic changes to preserveAspectRatio cause a reflow</title>
+  <script>
+<![CDATA[
+
+function doTest() {
+  var i1 = document.getElementById("i1");
+  i1.preserveAspectRatio.baseVal.align =
+    SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_XMIDYMID;
+  var i2 = document.getElementById("i2");
+  i2.preserveAspectRatio.baseVal.align =
+    SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_NONE;
+  document.documentElement.removeAttribute("class");
+}
+
+document.addEventListener("MozReftestInvalidate", doTest, false);
+setTimeout(doTest, 4000); // fallback for running outside reftest
+
+]]>
+  </script>
+
+   <rect width="100%" height="100%" fill="lime"/>
+
+   <!-- this image is a 1x1 red gif -->
+   <image id="i1" preserveAspectRatio="none" x="50" y="50" width="200" height="300"
+          style="image-rendering: optimizeSpeed;"
+          xlink:href="data:image/gif,GIF87a%01%00%01%00%80%01%00%FF%00%00%FF%FF%FF%2C%00%00%00%00%01%00%01%00%00%02%02D%01%00%3B"/>
+  <!-- exactly cover the image if it had preserveAspectRatio="xMidYMid" -->
+  <rect x="50" y="100" width="200" height="200" fill="lime"/>
+
+  <rect x="300" y="100" width="200" height="300" fill="red"/>
+  <!-- and this one is a 1x1 lime PNG -->
+  <!-- which would cover the red rect if it had preserveAspectRatio="none" -->
+  <image id="i2" x="300" y="100" width="200" height="300" preserveAspectRatio="xMidYMid" xlink:href="data:image/png,%89PNG%0D%0A%1A%0A%00%00%00%0DIHDR%00%00%00%01%00%00%00%01%08%02%00%00%00%90wS%DE%00%00%00%01sRGB%00%AE%CE%1C%E9%00%00%00%0CIDAT%08%D7c%60%F8%CF%00%00%02%02%01%00%AA*%9E'%00%00%00%00IEND%AEB%60%82" />
+
+</svg>
--- a/layout/reftests/svg/image/reftest.list
+++ b/layout/reftests/svg/image/reftest.list
@@ -33,8 +33,9 @@ fuzzy-if(Android,4,34) == image-opacity-
 
 # Tests for <image> with preserveAspectRatio
 skip-if(B2G) == image-preserveAspectRatio-01-raster.svg image-preserveAspectRatio-01-ref.svg # bug 773482
 skip-if(B2G) == image-preserveAspectRatio-01-svg.svg    image-preserveAspectRatio-01-ref.svg # bug 773482
 skip-if(B2G) == image-preserveAspectRatio-02-raster.svg image-preserveAspectRatio-02-ref.svg # bug 773482
 skip-if(B2G) == image-preserveAspectRatio-02-svg.svg    image-preserveAspectRatio-02-ref.svg # bug 773482
 skip-if(B2G) == image-preserveAspectRatio-03.svg        image-preserveAspectRatio-03-ref.svg # bug 773482
 skip-if(B2G) == image-preserveAspectRatio-04.svg        image-preserveAspectRatio-04-ref.svg # bug 773482
+== image-preserveAspectRatio-05.svg ../pass.svg
--- a/layout/svg/nsSVGImageFrame.cpp
+++ b/layout/svg/nsSVGImageFrame.cpp
@@ -190,18 +190,21 @@ nsSVGImageFrame::AttributeChanged(int32_
         aAttribute == nsGkAtoms::y ||
         aAttribute == nsGkAtoms::width ||
         aAttribute == nsGkAtoms::height) {
       nsSVGEffects::InvalidateRenderingObservers(this);
       nsSVGUtils::ScheduleReflowSVG(this);
       return NS_OK;
     }
     else if (aAttribute == nsGkAtoms::preserveAspectRatio) {
-      // Don't invalidate (the layers code does that).
-      SchedulePaint();
+      // We don't paint the content of the image using display lists, therefore
+      // we have to invalidate for this children-only transform changes since
+      // there is no layer tree to notice that the transform changed and
+      // recomposite.
+      InvalidateFrame();
       return NS_OK;
     }
   }
   if (aNameSpaceID == kNameSpaceID_XLink &&
       aAttribute == nsGkAtoms::href) {
 
     // Prevent setting image.src by exiting early
     if (nsContentUtils::IsImageSrcSetDisabled()) {