Bug 1512754 - Don't apply opacity to background color display items if the background-color is going to be animated on the compositor. r=birtles
authorHiroyuki Ikezoe <hikezoe@mozilla.com>
Tue, 11 Dec 2018 06:55:02 +0000
changeset 449771 0132b59bb0937c3bc2e8ee7c04b8127726c0b768
parent 449770 33aef5ce7c6ca80365e3f7297c29f0a81d62e6f2
child 449772 f02989fbbd6b4c9785fedcfeda17c9ffd837ecc7
child 449924 47a9fa92ae6123219b1edc92b44e4b80db62472d
push id35185
push userncsoregi@mozilla.com
push dateTue, 11 Dec 2018 09:38:01 +0000
treeherdermozilla-central@0132b59bb093 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbirtles
bugs1512754, 1395151
milestone66.0a1
first release with
nightly linux32
0132b59bb093 / 66.0a1 / 20181211093801 / files
nightly linux64
0132b59bb093 / 66.0a1 / 20181211093801 / files
nightly mac
0132b59bb093 / 66.0a1 / 20181211093801 / files
nightly win32
0132b59bb093 / 66.0a1 / 20181211093801 / files
nightly win64
0132b59bb093 / 66.0a1 / 20181211093801 / files
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
releases
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1512754 - Don't apply opacity to background color display items if the background-color is going to be animated on the compositor. r=birtles We need to do the same thing what we did for opacity display items in bug 1395151. Differential Revision: https://phabricator.services.mozilla.com/D14051
layout/painting/nsDisplayList.cpp
layout/reftests/css-transitions/background-color-with-opacity-ref.html
layout/reftests/css-transitions/background-color-with-opacity.html
layout/reftests/css-transitions/reftest.list
--- a/layout/painting/nsDisplayList.cpp
+++ b/layout/painting/nsDisplayList.cpp
@@ -4504,17 +4504,22 @@ bool nsDisplayImageContainer::CanOptimiz
 void nsDisplayBackgroundColor::ApplyOpacity(nsDisplayListBuilder* aBuilder,
                                             float aOpacity,
                                             const DisplayItemClipChain* aClip) {
   NS_ASSERTION(CanApplyOpacity(), "ApplyOpacity should be allowed");
   mColor.a = mColor.a * aOpacity;
   IntersectClip(aBuilder, aClip, false);
 }
 
-bool nsDisplayBackgroundColor::CanApplyOpacity() const { return true; }
+bool nsDisplayBackgroundColor::CanApplyOpacity() const {
+  // Don't apply opacity if the background color is animated since the color is
+  // going to be changed on the compositor.
+  return !EffectCompositor::HasAnimationsForCompositor(
+      mFrame, eCSSProperty_background_color);
+}
 
 LayerState nsDisplayBackgroundColor::GetLayerState(
     nsDisplayListBuilder* aBuilder, LayerManager* aManager,
     const ContainerLayerParameters& aParameters) {
   StyleGeometryBox clip =
       mBackgroundStyle->StyleBackground()->mImage.mLayers[0].mClip;
   if (ForceActiveLayers() && clip != StyleGeometryBox::Text) {
     return LAYER_ACTIVE;
new file mode 100644
--- /dev/null
+++ b/layout/reftests/css-transitions/background-color-with-opacity-ref.html
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html>
+<style>
+#target {
+  background-color: green;
+  width: 100px;
+  height: 100px;
+  opacity: 0.5;
+}
+</style>
+<div id="target"></div>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/css-transitions/background-color-with-opacity.html
@@ -0,0 +1,24 @@
+<!DOCTYPE html>
+<html class="reftest-wait reftest-no-flush">
+<style>
+#target {
+  background-color: green;
+  width: 100px;
+  height: 100px;
+  transition: background-color 100s steps(1, end);
+  opacity: 0.5;
+}
+#target.hover {
+  background-color: white;
+}
+</style>
+<div id="target"></div>
+<script>
+document.addEventListener('MozReftestInvalidate', () => {
+  target.className = 'hover';
+  target.addEventListener('transitionstart', () => {
+    document.documentElement.classList.remove('reftest-wait');
+  });
+}, false);
+</script>
+</html>
--- a/layout/reftests/css-transitions/reftest.list
+++ b/layout/reftests/css-transitions/reftest.list
@@ -1,8 +1,9 @@
+fuzzy-if((OSX&&!webrender)||(/^Windows\x20NT\x206\.1/.test(http.oscpu)&&!gpuProcess&&layersGPUAccelerated),1-1,10000-10000) == background-color-with-opacity.html background-color-with-opacity-ref.html
 == transitions-inline-already-wrapped-1.html transitions-inline-ref.html
 == transitions-inline-already-wrapped-2.html transitions-inline-ref.html
 == transitions-inline-rewrap-1.html transitions-inline-ref.html
 == transitions-inline-rewrap-2.html transitions-inline-ref.html
 == stacking-context-opacity-lose-to-animation.html stacking-context-transition-ref.html
 == stacking-context-transform-lose-to-animation.html stacking-context-transition-ref.html
 == stacking-context-opacity-wins-over-important-style.html stacking-context-transition-ref.html
 == stacking-context-transform-wins-over-important-style.html stacking-context-transition-ref.html