Bug 1232939 - Ensure the opaque region of a fixed background layer is correctly clipped. r=mstange, a=sledru
authorBotond Ballo <botond@mozilla.com>
Wed, 06 Jan 2016 13:48:37 -0500
changeset 298316 e4e34060f38271a3c47d5b49b29ac437fb8e0ad6
parent 298315 60681827670839a14e3700482e7275d87bc3ccb1
child 298317 69c01f698fd008e5af45d49ecfcbe2accc3af2f9
push id8909
push userryanvm@gmail.com
push dateMon, 11 Jan 2016 18:38:52 +0000
treeherdermozilla-aurora@69c01f698fd0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmstange, sledru
bugs1232939
milestone45.0a2
Bug 1232939 - Ensure the opaque region of a fixed background layer is correctly clipped. r=mstange, a=sledru
layout/base/FrameLayerBuilder.cpp
layout/reftests/backgrounds/fixed-bg-border-radius-ref.html
layout/reftests/backgrounds/fixed-bg-border-radius.html
layout/reftests/backgrounds/reftest.list
--- a/layout/base/FrameLayerBuilder.cpp
+++ b/layout/base/FrameLayerBuilder.cpp
@@ -3190,16 +3190,28 @@ void ContainerState::FinishPaintedLayerD
 
   if (!layer) {
     // We couldn't optimize to an image layer or a color layer above.
     layer = data->mLayer;
     layer->SetClipRect(Nothing());
     FLB_LOG_PAINTED_LAYER_DECISION(data, "  Selected painted layer=%p\n", layer.get());
   }
 
+  // If the layer is a fixed background layer, the clip on the fixed background
+  // display item was not applied to the opaque region in
+  // ContainerState::ComputeOpaqueRect(), but was saved in data->mItemClip.
+  // Apply it to the opaque region now. Note that it's important to do this
+  // before the opaque region is propagated to the NewLayerEntry below.
+  if (data->mSingleItemFixedToViewport && data->mItemClip.HasClip()) {
+    nsRect clipRect = data->mItemClip.GetClipRect();
+    nsRect insideRoundedCorners = data->mItemClip.ApproximateIntersectInward(clipRect);
+    nsIntRect insideRoundedCornersScaled = ScaleToInsidePixels(insideRoundedCorners);
+    data->mOpaqueRegion.AndWith(insideRoundedCornersScaled);
+  }
+
   if (mLayerBuilder->IsBuildingRetainedLayers()) {
     newLayerEntry->mVisibleRegion = data->mVisibleRegion;
     newLayerEntry->mOpaqueRegion = data->mOpaqueRegion;
     newLayerEntry->mHideAllLayersBelow = data->mHideAllLayersBelow;
     newLayerEntry->mOpaqueForAnimatedGeometryRootParent = data->mOpaqueForAnimatedGeometryRootParent;
   } else {
     SetOuterVisibleRegionForLayer(layer, data->mVisibleRegion);
   }
new file mode 100644
--- /dev/null
+++ b/layout/reftests/backgrounds/fixed-bg-border-radius-ref.html
@@ -0,0 +1,21 @@
+<!DOCTYPE html>
+<html>
+<style>
+body { 
+  height: 100%;
+  width: 100%;
+  background: red url('../bugs/repeatable-diagonal-gradient.png') no-repeat;
+  margin: 0px;
+  overflow: hidden;
+}
+div { 
+  height:200px;
+  width: 1020px;
+  background: url('../bugs/repeatable-diagonal-gradient.png') no-repeat;
+  border-radius: 25px;
+}
+</style>
+<body>
+<div >
+</div>
+</body></html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/backgrounds/fixed-bg-border-radius.html
@@ -0,0 +1,21 @@
+<!DOCTYPE html>
+<html>
+<style>
+body { 
+  height: 100%;
+  width: 100%;
+  background: red url('../bugs/repeatable-diagonal-gradient.png') no-repeat fixed;
+  margin: 0px;
+  overflow: hidden;
+}
+div { 
+  height:200px;
+  width: 1020px;
+  background: url('../bugs/repeatable-diagonal-gradient.png') no-repeat fixed;
+  border-radius: 25px;
+}
+</style>
+<body>
+<div >
+</div>
+</body></html>
--- a/layout/reftests/backgrounds/reftest.list
+++ b/layout/reftests/backgrounds/reftest.list
@@ -117,16 +117,17 @@ random-if(OSX==1010) == background-size-
 # algorithm dependencies (at least assuming the sampling algorithm in use
 # doesn't sample too far astray from the boundaries).
 fails == background-size-zoom-repeat.html background-size-zoom-repeat-ref.html
 
 # -moz-default-background-color and -moz-default-color (bug 591341)
 == background-moz-default-background-color.html background-moz-default-background-color-ref.html
 
 random-if(B2G||Mulet) == fixed-bg-with-transform-outside-viewport-1.html fixed-bg-with-transform-outside-viewport-ref.html # Initial mulet triage: parity with B2G/B2G Desktop
+fuzzy(2,83) == fixed-bg-border-radius.html fixed-bg-border-radius-ref.html
 
 HTTP == root-background-1.html root-background-ref.html
 HTTP != root-background-1.html about:blank
 
 random-if(B2G||Mulet) == really-big-background.html really-big-background-ref.html # Initial mulet triage: parity with B2G/B2G Desktop
 == body-background.html body-background-ref.html
 == table-background.html table-background-ref.html
 == table-background-print.html table-background-print-ref.html