Backed out changeset 253e90f0ccf3 (bug 1541021) for mochitest failures on test_bounds.html
authorNarcis Beleuzu <nbeleuzu@mozilla.com>
Sun, 07 Apr 2019 19:50:14 +0300
changeset 468302 1c0ed04569945302bf7d99ca5c8787623adfbbb6
parent 468301 253e90f0ccf31bf505eff30de9f200a718298d99
child 468303 427b854cdb1c47ce6a643f83245914d66dca4382
child 468309 990ff091adb3fbaf6b1c024b49e24824f558ec5e
push id112701
push userncsoregi@mozilla.com
push dateSun, 07 Apr 2019 21:52:00 +0000
treeherdermozilla-inbound@1c0ed0456994 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1541021
milestone68.0a1
backs out253e90f0ccf31bf505eff30de9f200a718298d99
first release with
nightly linux32
1c0ed0456994 / 68.0a1 / 20190407214820 / files
nightly linux64
1c0ed0456994 / 68.0a1 / 20190407214820 / files
nightly mac
1c0ed0456994 / 68.0a1 / 20190407214820 / files
nightly win32
1c0ed0456994 / 68.0a1 / 20190407214820 / files
nightly win64
1c0ed0456994 / 68.0a1 / 20190407214820 / files
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
releases
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Backed out changeset 253e90f0ccf3 (bug 1541021) for mochitest failures on test_bounds.html
dom/svg/test/bounds-helper.svg
dom/svg/test/test_bounds.html
layout/svg/nsSVGUtils.cpp
--- a/dom/svg/test/bounds-helper.svg
+++ b/dom/svg/test/bounds-helper.svg
@@ -1,14 +1,13 @@
 <?xml version="1.0"?>
 <svg xmlns="http://www.w3.org/2000/svg" width="750"
      xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1">
   <style type="text/css">
 text { font: 20px monospace; }
-#css-trans-rect-2 { transform: scaleX(2) }
   </style>
 
 <g id="g">
   <svg id="svg1" x="10" y="10" width="25" height="30"/>
   <svg id="svg2" width="1" height="1" overflow="visible">
     <rect width="2" height="2" fill="yellow"/>
   </svg>
   <svg id="svg3" width="1" height="1" overflow="hidden">
@@ -67,12 +66,10 @@ text { font: 20px monospace; }
           transform="rotate(-45 0 50)" />
   </marker>
   <line id="shapeWithMarker1" x1="160" y1="130" x2="170" y2="130"
         stroke="black" stroke-width="3" marker-end="url(#marker1)"/>
 
   <line id="rotatedLine1" x1="160" y1="150" x2="180" y2="170"
         stroke="darkmagenta" stroke-width="10"
         transform="rotate(-45 160 150)" />
-
-  <rect id="css-trans-rect-2" x="5" y="5" width="6" height="6"></rect>
 </g>
 </svg>
--- a/dom/svg/test/test_bounds.html
+++ b/dom/svg/test/test_bounds.html
@@ -2,39 +2,31 @@
 <html xmlns="http://www.w3.org/1999/xhtml">
 <!--
 https://bugzilla.mozilla.org/show_bug.cgi?id=463934
 -->
 <head>
   <title>Test for Bug 463934</title>
   <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
-  <style>
-    #css-trans-rect-1 {
-      transform: scaleX(2)
-    }
-  </style>
 </head>
 <body>
 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=463934">Mozilla Bug 463934</a>
 <p id="display"></p>
 <div id="content">
   <svg id="outer-1" xmlns="http://www.w3.org/2000/svg" width="30" height="30"></svg>
   <svg id="outer-2" xmlns="http://www.w3.org/2000/svg" width="30" height="30"
        style="padding: 10px;">
   </svg>
   <svg id="outer-3" xmlns="http://www.w3.org/2000/svg" width="30" height="30"
        style="border: 10px solid black;">
   </svg>
   <svg id="outer-4" xmlns="http://www.w3.org/2000/svg" width="30" height="30"
        style="border: 10px solid black; padding: 10px">
   </svg>
-  <svg id="outer-5" xmlns="http://www.w3.org/2000/svg" width="30" height="30">
-    <rect id="css-trans-rect-1" width="6" height="6"></rect>
-  </svg>
 </div>
 
 <iframe id="svg" src="bounds-helper.svg"></iframe>
 
 <pre id="test">
 <script class="testbody" type="application/javascript">
 SimpleTest.waitForExplicitFinish();
 
@@ -70,20 +62,16 @@ function runTest() {
   bounds = document.getElementById("outer-3").getBoundingClientRect();
   is(bounds.width, 50, "outer-svg 3 getBoundingClientRect().width");
   is(bounds.height, 50, "outer-svg 3 getBoundingClientRect().height");
 
   bounds = document.getElementById("outer-4").getBoundingClientRect();
   is(bounds.width, 70, "outer-svg 4 getBoundingClientRect().width");
   is(bounds.height, 70, "outer-svg 4 getBoundingClientRect().height");
 
-  bounds = document.getElementById("css-trans-rect-1").getBoundingClientRect();
-  is(bounds.width, 12, "css-trans-rect getBoundingClientRect().width");
-  is(bounds.height, 6, "css-trans-rect getBoundingClientRect().height");
-
   var doc = $("svg").contentWindow.document;
 
   var svg1Bounds = doc.getElementById("svg1").getBoundingClientRect();
   is(svg1Bounds.left, 10, "svg1.getBoundingClientRect().left");
   is(svg1Bounds.top, 10, "svg1.getBoundingClientRect().top");
   is(svg1Bounds.width, 25, "svg1.getBoundingClientRect().width");
   is(svg1Bounds.height, 30, "svg1.getBoundingClientRect().height");
 
@@ -286,23 +274,16 @@ function runTest() {
     "rotatedLine1Bounds.left");
   isWithAbsTolerance(rotatedLine1Bounds.top, 145, 0.1,
     "rotatedLine1Bounds.top");
   isWithAbsTolerance(rotatedLine1Bounds.width, Math.SQRT2 * 20, 0.1,
     "rotatedLine1Bounds.width");
   isWithAbsTolerance(rotatedLine1Bounds.height, 10, 0.1,
     "rotatedLine1Bounds.height");
 
-  var cssTransRect2Bounds =
-    doc.getElementById("css-trans-rect-2").getBoundingClientRect();
-  is(cssTransRect2Bounds.left, 10, "cssTransRect2Bounds.left");
-  is(cssTransRect2Bounds.top, 5, "cssTransRect2Bounds.top");
-  is(cssTransRect2Bounds.width, 12, "cssTransRect2Bounds.width");
-  is(cssTransRect2Bounds.height, 6, "cssTransRect2Bounds.height");
-
   SimpleTest.finish();
 }
 
 window.addEventListener("load", runTest);
 </script>
 </pre>
 </body>
 </html>
--- a/layout/svg/nsSVGUtils.cpp
+++ b/layout/svg/nsSVGUtils.cpp
@@ -316,38 +316,22 @@ nsIFrame* nsSVGUtils::GetOuterSVGFrameAn
   }
 
   if (aFrame->GetStateBits() & NS_FRAME_IS_NONDISPLAY) {
     *aRect = nsRect(0, 0, 0, 0);
   } else {
     uint32_t flags =
         nsSVGUtils::eForGetClientRects | nsSVGUtils::eBBoxIncludeFill |
         nsSVGUtils::eBBoxIncludeStroke | nsSVGUtils::eBBoxIncludeMarkers;
-
-    auto ctm =
-        nsLayoutUtils::GetTransformToAncestor(aFrame, outer, 0, nullptr);
-
-    float appUnitsPerDevPixel = aFrame->PresContext()->AppUnitsPerDevPixel();
-    float initPositionX =
-              NSAppUnitsToFloatPixels(aFrame->GetPosition().x, appUnitsPerDevPixel),
-          initPositionY =
-              NSAppUnitsToFloatPixels(aFrame->GetPosition().y, appUnitsPerDevPixel);
-
-    Matrix mm;
-    ctm.CanDraw2D(&mm);
-    gfxMatrix m = ThebesMatrix(mm);
-
-    // Both nsSVGUtils::GetBBox and nsLayoutUtils::GetTransformToAncestor
-    // will count this displacement, we should remove it here to avoid
-    // double-counting.
-    m = m.PreTranslate(-initPositionX, -initPositionY);
-
+    gfxMatrix m = nsSVGUtils::GetUserToCanvasTM(aFrame);
     SVGBBox bbox = nsSVGUtils::GetBBox(aFrame, flags, &m);
-    *aRect = nsLayoutUtils::RoundGfxRectToAppRect(
+    nsRect bounds = nsLayoutUtils::RoundGfxRectToAppRect(
         bbox, aFrame->PresContext()->AppUnitsPerDevPixel());
+    nsMargin bp = outer->GetUsedBorderAndPadding();
+    *aRect = bounds + nsPoint(bp.left, bp.top);
   }
 
   return outer;
 }
 
 gfxMatrix nsSVGUtils::GetCanvasTM(nsIFrame* aFrame) {
   // XXX yuck, we really need a common interface for GetCanvasTM