Bug 1466638 - Implement support for ContainerLayerParameters::mOffset in nsDisplayImageContainer. r?mstange draft
authorMatt Woodrow <mwoodrow@mozilla.com>
Mon, 09 Jul 2018 16:11:08 +1200
changeset 815524 58689fec70396b117138ddc2c33c5b7c265dc0e1
parent 815500 b0111088608390a0ab4baa3727e5e6fb06cd9f31
push id115527
push usermwoodrow@mozilla.com
push dateMon, 09 Jul 2018 04:11:40 +0000
reviewersmstange
bugs1466638
milestone63.0a1
Bug 1466638 - Implement support for ContainerLayerParameters::mOffset in nsDisplayImageContainer. r?mstange This gets set to a non-zero value when we have an inactive ContainerLayer ancestor (filter in this case). The current code assumes we'd never call BuildLayer on an image when that happen, but we force the pseudo-active state here because background-position is animated (all properties have a transition). MozReview-Commit-ID: 6pL8EJTNgWy
layout/base/crashtests/1466638.html
layout/base/crashtests/crashtests.list
layout/painting/nsDisplayList.cpp
layout/reftests/bugs/1466638-1-ref.html
layout/reftests/bugs/1466638-1.html
layout/reftests/bugs/reftest.list
new file mode 100644
--- /dev/null
+++ b/layout/base/crashtests/1466638.html
@@ -0,0 +1,13 @@
+<style>
+#a {
+  -webkit-transition: all 44s linear;
+  filter: contrast(0.052452386);
+}
+</style>
+<script>
+function go() {
+  a.style.setProperty("background", "url(data:i;base64,R0lGODlhEAAQAMQAAORHHOVSKudfOulrSOp3WOyDZu6QdvCchPGolfO0o/XBs/fNwfjZ0frl3/zy7////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAkAABAALAAAAAAQABAAAA) no-repeat scroll right")
+}
+</script>
+<body onload=go()>
+<label id="a">#y
--- a/layout/base/crashtests/crashtests.list
+++ b/layout/base/crashtests/crashtests.list
@@ -539,11 +539,12 @@ load 1453196.html
 load 1453342.html
 load 1453702.html
 pref(dom.webcomponents.shadowdom.enabled,true) load 1461749.html
 load 1461812.html
 load 1462412.html
 load 1463940.html
 pref(dom.webcomponents.shadowdom.enabled,true) HTTP load 1464641.html
 load 1464737.html
+load 1466638.html
 load 1467688.html
 load 1467964.html
 load 1469354.html
--- a/layout/painting/nsDisplayList.cpp
+++ b/layout/painting/nsDisplayList.cpp
@@ -4578,22 +4578,16 @@ nsDisplayImageContainer::ConfigureLayer(
   NS_ASSERTION(imageWidth != 0 && imageHeight != 0, "Invalid image size!");
 
   if (imageWidth > 0 && imageHeight > 0) {
     // We're actually using the ImageContainer. Let our frame know that it
     // should consider itself to have painted successfully.
     UpdateDrawResult(ImgDrawResult::SUCCESS);
   }
 
-  // XXX(seth): Right now we ignore aParameters.Scale() and
-  // aParameters.Offset(), because FrameLayerBuilder already applies
-  // aParameters.Scale() via the layer's post-transform, and
-  // aParameters.Offset() is always zero.
-  MOZ_ASSERT(aParameters.Offset() == LayerIntPoint(0,0));
-
   // It's possible (for example, due to downscale-during-decode) that the
   // ImageContainer this ImageLayer is holding has a different size from the
   // intrinsic size of the image. For this reason we compute the transform using
   // the ImageContainer's size rather than the image's intrinsic size.
   // XXX(seth): In reality, since the size of the ImageContainer may change
   // asynchronously, this is not enough. Bug 1183378 will provide a more
   // complete fix, but this solution is safe in more cases than simply relying
   // on the intrinsic size.
@@ -4601,17 +4595,18 @@ nsDisplayImageContainer::ConfigureLayer(
                         ? aLayer->GetContainer()->GetCurrentSize()
                         : IntSize(imageWidth, imageHeight);
 
   const int32_t factor = mFrame->PresContext()->AppUnitsPerDevPixel();
   const LayoutDeviceRect destRect(
     LayoutDeviceIntRect::FromAppUnitsToNearest(GetDestRect(), factor));
 
   const LayoutDevicePoint p = destRect.TopLeft();
-  Matrix transform = Matrix::Translation(p.x, p.y);
+  Matrix transform = Matrix::Translation(p.x + aParameters.mOffset.x,
+                                         p.y + aParameters.mOffset.y);
   transform.PreScale(destRect.width / containerSize.width,
                      destRect.height / containerSize.height);
   aLayer->SetBaseTransform(gfx::Matrix4x4::From2D(transform));
 }
 
 already_AddRefed<ImageContainer>
 nsDisplayImageContainer::GetContainer(LayerManager* aManager,
                                       nsDisplayListBuilder *aBuilder)
new file mode 100644
--- /dev/null
+++ b/layout/reftests/bugs/1466638-1-ref.html
@@ -0,0 +1,20 @@
+<!DOCTYPE html>
+<html>
+<style>
+@keyframes holdBackgroundPosition {
+  from,to { background-position-x: 50%; }
+}
+#test {
+  height: 100px;
+  width: 100px;
+  background-repeat: no-repeat;
+  background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABkAAAAZCAMAAADzN3VRAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAAZQTFRF/wAAAAAAQaMSAwAAABJJREFUeNpiYBgFo2AwAIAAAwACigABtnCV2AAAAABJRU5ErkJggg==); /* a 25x25 px red box */
+  animation: holdBackgroundPosition 100s infinite;
+}
+#wrapper {
+  opacity: 0.5;
+}
+</style>
+<div id="wrapper">
+<div id="test"></div>
+</div>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/bugs/1466638-1.html
@@ -0,0 +1,20 @@
+<!DOCTYPE html>
+<html>
+<style>
+@keyframes holdBackgroundPosition {
+  from,to { background-position-x: 50%; }
+}
+#test {
+  height: 100px;
+  width: 100px;
+  background-repeat: no-repeat;
+  background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABkAAAAZCAMAAADzN3VRAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAAZQTFRF/wAAAAAAQaMSAwAAABJJREFUeNpiYBgFo2AwAIAAAwACigABtnCV2AAAAABJRU5ErkJggg==); /* a 25x25 px red box */
+  animation: holdBackgroundPosition 100s infinite;
+}
+#wrapper {
+  filter: opacity(0.5);
+}
+</style>
+<div id="wrapper">
+<div id="test"></div>
+</div>
--- a/layout/reftests/bugs/reftest.list
+++ b/layout/reftests/bugs/reftest.list
@@ -2072,8 +2072,9 @@ fuzzy(74,2234) random-if(webrender) == 1
 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
 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
+fuzzy(1,625) == 1466638-1.html 1466638-1-ref.html