Bug 1454653 - Do not skip transparent items in ContainerState::FindOpaqueBackgroundColorInLayer() draft
authorMiko Mynttinen <mikokm@gmail.com>
Mon, 23 Apr 2018 17:33:16 +0200
changeset 786569 5ea549a68372bcb4287fd4925da930a6dd57149c
parent 784946 8ed49dd81059dfdd876cf62ad5def1cfa56ffbbf
push id107522
push userbmo:mikokm@gmail.com
push dateMon, 23 Apr 2018 15:46:18 +0000
bugs1454653
milestone61.0a1
Bug 1454653 - Do not skip transparent items in ContainerState::FindOpaqueBackgroundColorInLayer() MozReview-Commit-ID: NGnL8r9x0U
layout/painting/FrameLayerBuilder.cpp
layout/reftests/layers/opacity-background-1-ref.html
layout/reftests/layers/opacity-background-1.html
layout/reftests/layers/reftest.list
--- a/layout/painting/FrameLayerBuilder.cpp
+++ b/layout/painting/FrameLayerBuilder.cpp
@@ -2730,20 +2730,18 @@ ContainerState::FindOpaqueBackgroundColo
   *aOutIntersectsLayer = true;
 
   // Scan the candidate's display items.
   nsIntRect deviceRect = aRect;
   nsRect appUnitRect = ToAppUnits(deviceRect, mAppUnitsPerDevPixel);
   appUnitRect.ScaleInverseRoundOut(mParameters.mXScale, mParameters.mYScale);
 
   for (auto& assignedItem : Reversed(aData->mAssignedDisplayItems)) {
-    if (assignedItem.mType != DisplayItemEntryType::ITEM ||
-        assignedItem.mHasOpacity) {
-      // |assignedItem| is either an effect marker, or within a flatten opacity
-      // group. In both cases, there is no opaque area.
+    if (assignedItem.mType != DisplayItemEntryType::ITEM) {
+      // |assignedItem| is an effect marker.
       continue;
     }
 
     nsDisplayItem* item = assignedItem.mItem;
     bool snap;
     nsRect bounds = item->GetBounds(mBuilder, &snap);
     if (snap && mSnappingEnabled) {
       nsIntRect snappedBounds = ScaleToNearestPixels(bounds);
@@ -2769,19 +2767,23 @@ ContainerState::FindOpaqueBackgroundColo
 
     if (assignedItem.mClip.IsRectAffectedByClip(deviceRect,
                                                 mParameters.mXScale,
                                                 mParameters.mYScale,
                                                 mAppUnitsPerDevPixel)) {
       return NS_RGBA(0,0,0,0);
     }
 
-    Maybe<nscolor> color = item->IsUniform(mBuilder);
-    if (color && NS_GET_A(*color) == 255)
-      return *color;
+    if (!assignedItem.mHasOpacity) {
+      Maybe<nscolor> color = item->IsUniform(mBuilder);
+
+      if (color && NS_GET_A(*color) == 255) {
+        return *color;
+      }
+    }
 
     return NS_RGBA(0,0,0,0);
   }
 
   *aOutIntersectsLayer = false;
   return NS_RGBA(0,0,0,0);
 }
 
new file mode 100644
--- /dev/null
+++ b/layout/reftests/layers/opacity-background-1-ref.html
@@ -0,0 +1,55 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta http-equiv="content-type" content="text/html; charset=UTF-8">
+<meta charset="utf-8">
+
+<style>
+.main {
+    top: 0px;
+    left: 0px;
+    width: 100px;
+    height: 100px;
+    position: absolute;
+    background-color: red;
+}
+
+.background {
+    background-color: white;
+    position: absolute;
+    top: 0px;
+    left: 0px;
+    height: 100%;
+    width: 100%;
+    opacity: 0.9;
+}
+
+.container {
+    position: absolute;
+    top: 0px;
+    left: 0px;
+    height: 100%;
+    width: 100%;
+    overflow: scroll;
+}
+
+.message {
+    position: absolute;
+    top: 0px;
+    left: 0px;
+    width: 101%;
+    height: 101%;
+}
+</style>
+</head>
+
+<body>
+<div class="main">
+    <div class="background"></div>
+    <div class="container">
+        <div class="message">foo</div>
+    </div>
+</div>
+
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/layers/opacity-background-1.html
@@ -0,0 +1,55 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta http-equiv="content-type" content="text/html; charset=UTF-8">
+<meta charset="utf-8">
+
+<style>
+.main {
+    top: 0px;
+    left: 0px;
+    width: 100px;
+    height: 100px;
+    position: absolute;
+    background-color: red;
+}
+
+.background {
+    background: linear-gradient(#ffffff, #ffffff);
+    position: absolute;
+    top: 0px;
+    left: 0px;
+    height: 100%;
+    width: 100%;
+    opacity: 0.9;
+}
+
+.container {
+    position: absolute;
+    top: 0px;
+    left: 0px;
+    height: 100%;
+    width: 100%;
+    overflow: scroll;
+}
+
+.message {
+    position: absolute;
+    top: 0px;
+    left: 0px;
+    width: 101%;
+    height: 101%;
+}
+</style>
+</head>
+
+<body>
+<div class="main">
+    <div class="background"></div>
+    <div class="container">
+        <div class="message">foo</div>
+    </div>
+</div>
+
+</body>
+</html>
--- a/layout/reftests/layers/reftest.list
+++ b/layout/reftests/layers/reftest.list
@@ -33,8 +33,10 @@ skip-if(!asyncPan) == fixed-pos-scrolled
 # These tests check whether the GPU process is working. We expect it to work if:
 #   E10S is enabled, and
 #   Direct2D 1.1 works (as a proxy for Windows 7 SP1 + Platform Update or higher), OR
 #   The GPU process has been forced on.
 # If these conditions are met, but the GPU process is not on, these tests will turn on
 # and compare false.
 skip-if(!browserIsRemote||!d2d||gpuProcess) == data:text/plain,FAIL about:blank
 skip-if(!gpuProcessForceEnabled||gpuProcess) == data:text/plain,FAIL about:blank
+
+== opacity-background-1.html opacity-background-1-ref.html