Bug 1266161 - Make DrawForcedBackgroundColor fill the entire draw region, not just the layer's visible region. r?mattwoodrow draft
authorMarkus Stange <mstange@themasta.com>
Fri, 06 May 2016 13:53:56 -0400
changeset 364442 68a3a5730d85fe923fe44e22237d2daae7877f16
parent 364142 a140a93f02f79effe0d945a24b3d730b1fcf25dd
child 520288 2793544a202663f13909d93fd8dbdfc8ad496677
push id17460
push usermstange@themasta.com
push dateFri, 06 May 2016 17:54:16 +0000
reviewersmattwoodrow
bugs1266161
milestone49.0a1
Bug 1266161 - Make DrawForcedBackgroundColor fill the entire draw region, not just the layer's visible region. r?mattwoodrow We need to do this because the entire draw region will be added to the layer's valid region after drawing. If there are parts in the valid region that are not in the visible region, we still need those parts to have valid content, because in a later frame the visible region may grow to include those parts. MozReview-Commit-ID: 6zESYbPAmrx
layout/base/FrameLayerBuilder.cpp
layout/reftests/layers/forced-bg-color-outside-visible-region-ref.html
layout/reftests/layers/forced-bg-color-outside-visible-region.html
layout/reftests/layers/reftest.list
--- a/layout/base/FrameLayerBuilder.cpp
+++ b/layout/base/FrameLayerBuilder.cpp
@@ -5587,23 +5587,22 @@ ShouldDrawRectsSeparately(DrawTarget* aD
       aClip == DrawRegionClip::NONE) {
     return false;
   }
 
   return !aDrawTarget->SupportsRegionClipping();
 }
 
 static void DrawForcedBackgroundColor(DrawTarget& aDrawTarget,
-                                      Layer* aLayer, nscolor
-                                      aBackgroundColor)
+                                      const IntRect& aBounds,
+                                      nscolor aBackgroundColor)
 {
   if (NS_GET_A(aBackgroundColor) > 0) {
-    LayerIntRect r = aLayer->GetVisibleRegion().GetBounds();
     ColorPattern color(ToDeviceColor(aBackgroundColor));
-    aDrawTarget.FillRect(Rect(r.x, r.y, r.width, r.height), color);
+    aDrawTarget.FillRect(Rect(aBounds), color);
   }
 }
 
 /*
  * A note on residual transforms:
  *
  * In a transformed subtree we sometimes apply the PaintedLayer's
  * "residual transform" when drawing content into the PaintedLayer.
@@ -5668,17 +5667,17 @@ FrameLayerBuilder::DrawPaintedLayer(Pain
   bool shouldDrawRectsSeparately =
     ShouldDrawRectsSeparately(&aDrawTarget, aClip);
 
   if (!shouldDrawRectsSeparately) {
     if (aClip == DrawRegionClip::DRAW) {
       gfxUtils::ClipToRegion(aContext, aRegionToDraw);
     }
 
-    DrawForcedBackgroundColor(aDrawTarget, aLayer,
+    DrawForcedBackgroundColor(aDrawTarget, aRegionToDraw.GetBounds(),
                               userData->mForcedBackgroundColor);
   }
 
   if (NS_GET_A(userData->mFontSmoothingBackgroundColor) > 0) {
     aContext->SetFontSmoothingBackgroundColor(
       Color::FromABGR(userData->mFontSmoothingBackgroundColor));
   }
 
@@ -5707,17 +5706,17 @@ FrameLayerBuilder::DrawPaintedLayer(Pain
   if (shouldDrawRectsSeparately) {
     for (auto iter = aRegionToDraw.RectIter(); !iter.Done(); iter.Next()) {
       const nsIntRect& iterRect = iter.Get();
       gfxContextAutoSaveRestore save(aContext);
       aContext->NewPath();
       aContext->Rectangle(ThebesRect(iterRect));
       aContext->Clip();
 
-      DrawForcedBackgroundColor(aDrawTarget, aLayer,
+      DrawForcedBackgroundColor(aDrawTarget, iterRect,
                                 userData->mForcedBackgroundColor);
 
       // Apply the residual transform if it has been enabled, to ensure that
       // snapping when we draw into aContext exactly matches the ideal transform.
       // See above for why this is OK.
       aContext->SetMatrix(
         aContext->CurrentMatrix().Translate(aLayer->GetResidualTranslation() - gfxPoint(offset.x, offset.y)).
                                   Scale(userData->mXScale, userData->mYScale));
new file mode 100644
--- /dev/null
+++ b/layout/reftests/layers/forced-bg-color-outside-visible-region-ref.html
@@ -0,0 +1,39 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>Bug 1266161 - Reference</title>
+
+<style type="text/css">
+
+html, body {
+  margin: 0;
+}
+
+#scrollbox {
+  overflow: auto;
+  height: 500px;
+  width: 500px;
+}
+
+#scrolled {
+  height: 1201px;
+}
+
+</style>
+
+<div id="wrapper">
+
+  <div id="scrollbox">
+
+    <div id="scrolled">
+    </div>
+
+  </div>
+
+</div>
+
+<script>
+
+var scrollbox = document.getElementById("scrollbox");
+scrollbox.scrollTop = 80;
+
+</script>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/layers/forced-bg-color-outside-visible-region.html
@@ -0,0 +1,105 @@
+<!DOCTYPE html>
+<html lang="en" class="reftest-wait" reftest-async-scroll>
+<meta charset="utf-8">
+<title>Bug 1266161 - Black boxes during scrolling</title>
+
+<style type="text/css">
+
+html, body {
+  margin: 0;
+  height: 100%;
+}
+
+body {
+  outline: 2px solid white;
+}
+
+#scrollbox {
+  overflow: auto;
+  will-change: transform, scroll-position;
+  height: 500px;
+  width: 500px;
+}
+
+#scrolled {
+  padding-top: 1px;
+  height: 1200px;
+}
+
+p {
+  height: 20px;
+  background: white;
+  margin-top: 16px;
+}
+
+span, em {
+  display: block;
+  background: white;
+  width: 134px;
+  height: 14px;
+  margin-top: 32px;
+}
+
+em {
+  width: 10px;
+}
+
+</style>
+
+<div id="scrollbox"
+   reftest-displayport-x="0"
+   reftest-displayport-y="0"
+   reftest-displayport-w="500"
+   reftest-displayport-h="500">
+
+  <div id="scrolled">
+    <p></p>
+    <p></p>
+    <p></p>
+    <span style="margin-top: 48px"></span>
+    <span style="margin-top: 64px"></span>
+    <span style="margin-top: 96px"></span>
+    <span style="margin-top: 96px"></span>
+    <em></em>
+    <span></span>
+    <span></span>
+    <span></span>
+    <span></span>
+    <span></span>
+    <span></span>
+    <span></span>
+    <span></span>
+    <span></span>
+    <span></span>
+    <span></span>
+    <span></span>
+    <span></span>
+  </div>
+
+</div>
+
+<script>
+
+var scrollbox = document.getElementById("scrollbox");
+
+var pos = [ 170, 100, 248, 182, 130, 80 ];
+
+var i = 0;
+function scrollToNextPos() {
+  scrollbox.scrollTop = pos[i++];
+}
+
+scrollToNextPos();
+
+window.addEventListener("MozReftestInvalidate", function () {
+  requestAnimationFrame(function scrollAndScheduleNext() {
+    scrollToNextPos();
+    if (i < pos.length) {
+      requestAnimationFrame(scrollAndScheduleNext);
+    } else {
+      document.documentElement.className = "";
+    }
+  });
+});
+
+</script>
--- a/layout/reftests/layers/reftest.list
+++ b/layout/reftests/layers/reftest.list
@@ -15,8 +15,9 @@ skip != pull-background-animated-positio
 skip-if(!asyncPan) != pull-background-displayport-1.html about:blank
 skip-if(!asyncPan) != pull-background-displayport-2.html about:blank
 skip-if(!asyncPan) != pull-background-displayport-3.html about:blank # fails with non-overlay scrollbars and event regions due to bug 1148515
 skip-if(!asyncPan) != pull-background-displayport-4.html about:blank # fails with non-overlay scrollbars and event regions due to bug 1148515
 skip-if(!asyncPan) != pull-background-displayport-5.html about:blank
 skip-if(!asyncPan) != pull-background-displayport-6.html about:blank # fails with non-overlay scrollbars and event regions due to bug 1148515
 fuzzy(2,30150) == opacity-blending.html opacity-blending-ref.html
 fuzzy(16,5) == mask-layer-transform.html mask-layer-transform-ref.html
+fuzzy-if(gtkWidget,1,17) == forced-bg-color-outside-visible-region.html forced-bg-color-outside-visible-region-ref.html