Bug 1232939 - Ensure the opaque region of a fixed background layer is correctly clipped. r=mstange
--- a/layout/base/FrameLayerBuilder.cpp
+++ b/layout/base/FrameLayerBuilder.cpp
@@ -3193,16 +3193,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