Bug 1456111 - Make sure an empty pixel rectangle gets converted to an empty app unit rectangle, regardless of scale factor. r=tnikkel
☠☠ backed out by b9d4c093a6ab ☠ ☠
authorMatt Woodrow <mwoodrow@mozilla.com>
Thu, 21 Jun 2018 15:34:25 +1200
changeset 477461 97d67e0eaccff918811b6f76fdf8c331bacf143e
parent 477460 dff46afaa69c7b7d4a53d2d7728346d016b78adb
child 477462 b9d4c093a6abdcc289c1bf1f51e242a7c360f56b
push id9385
push userdluca@mozilla.com
push dateFri, 22 Jun 2018 15:47:18 +0000
treeherdermozilla-beta@82a9a1027e2b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstnikkel
bugs1456111
milestone62.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1456111 - Make sure an empty pixel rectangle gets converted to an empty app unit rectangle, regardless of scale factor. r=tnikkel MozReview-Commit-ID: 1S59BARsMzZ
layout/base/nsLayoutUtils.cpp
layout/reftests/bugs/1456111-1.html
layout/reftests/bugs/reftest.list
--- a/layout/base/nsLayoutUtils.cpp
+++ b/layout/base/nsLayoutUtils.cpp
@@ -2310,32 +2310,40 @@ static void ConstrainToCoordValues(gfxFl
     aStart -= excess;
     aSize = nscoord_MIN;
   }
 }
 
 nsRect
 nsLayoutUtils::RoundGfxRectToAppRect(const Rect &aRect, float aFactor)
 {
+  if (aRect.IsEmpty()) {
+    return nsRect();
+  }
+
   /* Get a new Rect whose units are app units by scaling by the specified factor. */
   Rect scaledRect = aRect;
   scaledRect.ScaleRoundOut(aFactor);
 
   /* We now need to constrain our results to the max and min values for coords. */
   ConstrainToCoordValues(scaledRect.x, scaledRect.width);
   ConstrainToCoordValues(scaledRect.y, scaledRect.height);
 
   /* Now typecast everything back.  This is guaranteed to be safe. */
   return nsRect(nscoord(scaledRect.X()), nscoord(scaledRect.Y()),
                 nscoord(scaledRect.Width()), nscoord(scaledRect.Height()));
 }
 
 nsRect
 nsLayoutUtils::RoundGfxRectToAppRect(const gfxRect &aRect, float aFactor)
 {
+  if (aRect.IsEmpty()) {
+    return nsRect();
+  }
+
   /* Get a new gfxRect whose units are app units by scaling by the specified factor. */
   gfxRect scaledRect = aRect;
   scaledRect.ScaleRoundOut(aFactor);
 
   /* We now need to constrain our results to the max and min values for coords. */
   ConstrainToCoordValues(scaledRect.x, scaledRect.width);
   ConstrainToCoordValues(scaledRect.y, scaledRect.height);
 
@@ -3466,16 +3474,17 @@ nsresult
 nsLayoutUtils::PaintFrame(gfxContext* aRenderingContext, nsIFrame* aFrame,
                           const nsRegion& aDirtyRegion, nscolor aBackstop,
                           nsDisplayListBuilderMode aBuilderMode,
                           PaintFrameFlags aFlags)
 {
   AUTO_PROFILER_LABEL("nsLayoutUtils::PaintFrame", GRAPHICS);
   typedef RetainedDisplayListBuilder::PartialUpdateResult PartialUpdateResult;
 
+
 #ifdef MOZ_DUMP_PAINTING
   if (!gPaintCountStack) {
     gPaintCountStack = new nsTArray<int>();
     ClearOnShutdown(&gPaintCountStack);
 
     gPaintCountStack->AppendElement(0);
   }
   ++gPaintCountStack->LastElement();
new file mode 100644
--- /dev/null
+++ b/layout/reftests/bugs/1456111-1.html
@@ -0,0 +1,14 @@
+<!DOCTYPE html>
+<html reftest-zoom="0.9" class="reftest-wait">
+<meta charset="utf-8">
+<body>
+  <div id="transformed" style="width:200px; height:200px; background-color:red; transform:scale(2)"></div>
+</body>
+<script>
+  function doTest() {
+    document.getElementById("transformed").style.transform = "scale(0)";
+    document.documentElement.removeAttribute("class");
+  }
+  window.addEventListener("MozReftestInvalidate", doTest);
+</script>
+</html>
--- a/layout/reftests/bugs/reftest.list
+++ b/layout/reftests/bugs/reftest.list
@@ -2070,10 +2070,11 @@ test-pref(font.size.systemFontScale,200)
 == 1424798-1.html 1424798-ref.html
 fuzzy(74,2234) random-if(webrender) == 1425243-1.html 1425243-1-ref.html
 fuzzy-if(Android,66,574) fuzzy-if(d2d,89,777) fuzzy-if(!Android&&!d2d,1,31219) == 1425243-2.html 1425243-2-ref.html
 == 1430869.html 1430869-ref.html
 == 1432541.html 1432541-ref.html
 pref(layout.css.moz-document.url-prefix-hack.enabled,true) == 1446470.html 1035091-ref.html
 pref(layout.css.moz-document.url-prefix-hack.enabled,false) == 1446470-2.html 1035091-ref.html
 test-pref(layout.css.prefixes.gradients,false) == 1451874.html 1451874-ref.html
+== 1456111-1.html about:blank
 fuzzy-if(!(webrender&&gtkWidget),1-2,17500-17500) == 1412375.html 1412375-ref.html
 test-pref(layout.css.contain.enabled,false) == 1466008.html 1466008-ref.html