Bug 1395151 - Don't apply ancestors' opacity if the opacity item has an async opacity animation. r?birtles,mattwoodrow draft
authorHiroyuki Ikezoe <hikezoe@mozilla.com>
Mon, 23 Oct 2017 19:26:40 +0900
changeset 684642 ccf57932ef372ba00f2082b66a151c6e37e4e628
parent 684511 ce1a86d3b4db161c95d1147676bbed839d7a4732
child 736929 0a81cc6825e47de002362f63ef1fd6e60c905779
push id85686
push userhikezoe@mozilla.com
push dateMon, 23 Oct 2017 10:27:01 +0000
reviewersbirtles, mattwoodrow
bugs1395151
milestone58.0a1
Bug 1395151 - Don't apply ancestors' opacity if the opacity item has an async opacity animation. r?birtles,mattwoodrow MozReview-Commit-ID: KsxukpGrH6P
layout/painting/nsDisplayList.cpp
layout/reftests/css-animations/opacity-animation-in-fixed-opacity-parent-ref.html
layout/reftests/css-animations/opacity-animation-in-fixed-opacity-parent.html
layout/reftests/css-animations/reftest.list
--- a/layout/painting/nsDisplayList.cpp
+++ b/layout/painting/nsDisplayList.cpp
@@ -6044,17 +6044,18 @@ nsDisplayOpacity::ApplyOpacity(nsDisplay
   NS_ASSERTION(CanApplyOpacity(), "ApplyOpacity should be allowed");
   mOpacity = mOpacity * aOpacity;
   IntersectClip(aBuilder, aClip);
 }
 
 bool
 nsDisplayOpacity::CanApplyOpacity() const
 {
-  return true;
+  return !EffectCompositor::HasAnimationsForCompositor(mFrame,
+                                                       eCSSProperty_opacity);
 }
 
 /**
  * Recursively iterates through |aList| and collects at most |aMaxChildCount|
  * display item pointers to items that return true for CanApplyOpacity().
  * The item pointers are added to |aArray|.
  *
  * LayerEventRegions and WrapList items are ignored.
new file mode 100644
--- /dev/null
+++ b/layout/reftests/css-animations/opacity-animation-in-fixed-opacity-parent-ref.html
@@ -0,0 +1,31 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
+  <title>Testcase, bug 1395151</title>
+  <style type="text/css">
+.ok {
+  background : #0f0;
+  height     : 40px;
+  width      : 40px;
+}
+.error {
+  opacity : .001;
+  height  : 100%;
+  width   : 100%;
+}
+.error > span {
+  background : #f00;
+  content    : "";
+  display    : block;
+  height     : 100%;
+  width      : 100%;
+}
+  </style>
+</head>
+<body>
+<div class="ok">
+  <div class="error"><span></span></div>
+</div>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/css-animations/opacity-animation-in-fixed-opacity-parent.html
@@ -0,0 +1,48 @@
+<!DOCTYPE html>
+<html class="reftest-wait reftest-no-flush">
+<head>
+  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
+  <title>Testcase, bug 1395151</title>
+  <style type="text/css">
+@keyframes test-anim {
+  from { opacity : 1 }
+  to   { opacity : 1 }
+}
+
+.ok {
+  background : #0f0;
+  height     : 40px;
+  width      : 40px;
+}
+
+.error {
+  opacity : .001;
+  height     : 100%;
+  width      : 100%;
+}
+
+.error > span {
+  animation  : test-anim 1s linear infinite;
+  background : #f00;
+  content    : "";
+  display    : block;
+  height     : 100%;
+  width      : 100%;
+}
+  </style>
+</head>
+<body>
+<div class="ok">
+  <div class="error"><span></span></div>
+</div>
+<script>
+document.addEventListener('MozReftestInvalidate', () => {
+  requestAnimationFrame(() => {
+    requestAnimationFrame(() => {
+      document.documentElement.classList.remove('reftest-wait');
+    });
+  });
+}, false);
+</script>
+</body>
+</html>
--- a/layout/reftests/css-animations/reftest.list
+++ b/layout/reftests/css-animations/reftest.list
@@ -61,8 +61,10 @@ fails-if(layerChecksEnabled) == backgrou
 == reframe-and-animation-starts-at-the-same-time.html reframe-and-animation-starts-at-the-same-time-ref.html
 == change-animation-name-to-none-in-rule.html change-animation-name-in-rule-ref.html
 == change-animation-name-to-other-in-rule.html change-animation-name-in-rule-ref.html
 == change-animation-name-to-non-existent-in-rule.html change-animation-name-in-rule-ref.html
 == no-style-sharing-with-animations.html no-style-sharing-with-animations-ref.html
 
 == continuation-opacity.html continuation-opacity-ref.html
 == ib-split-sibling-opacity.html about:blank
+
+== opacity-animation-in-fixed-opacity-parent.html opacity-animation-in-fixed-opacity-parent-ref.html