Bug 1248913 - Make nsDisplayBlendContainer active or inactive based on its contents. r?mattwoodrow draft
authorMarkus Stange <mstange@themasta.com>
Tue, 08 Mar 2016 14:39:07 -0500
changeset 338213 fa8e9484e9153162f49bccbf178a1f00c88d2210
parent 338212 6c4eaddc442bba642cbda41426a848be490cf8dc
child 515761 ba39e04b981d625baf398592c15f9e0c166a7fd6
push id12468
push usermstange@themasta.com
push dateTue, 08 Mar 2016 19:59:01 +0000
reviewersmattwoodrow
bugs1248913
milestone47.0a1
Bug 1248913 - Make nsDisplayBlendContainer active or inactive based on its contents. r?mattwoodrow MozReview-Commit-ID: GN0084Rrmlm
layout/base/nsDisplayList.cpp
--- a/layout/base/nsDisplayList.cpp
+++ b/layout/base/nsDisplayList.cpp
@@ -4012,16 +4012,25 @@ RequiredLayerStateForChildren(nsDisplayL
   LayerState result = LAYER_INACTIVE;
   for (nsDisplayItem* i = aList.GetBottom(); i; i = i->GetAbove()) {
     if (result == LAYER_INACTIVE &&
         i->GetAnimatedGeometryRoot() != aExpectedAnimatedGeometryRootForChildren) {
       result = LAYER_ACTIVE;
     }
 
     LayerState state = i->GetLayerState(aBuilder, aManager, aParameters);
+    if (state == LAYER_ACTIVE && i->GetType() == nsDisplayItem::TYPE_BLEND_MODE) {
+      // nsDisplayBlendMode always returns LAYER_ACTIVE to ensure that the
+      // blending operation happens in the intermediate surface of its parent
+      // display item (usually an nsDisplayBlendContainer). But this does not
+      // mean that it needs all its ancestor display items to become active.
+      // So we ignore its layer state and look at its children instead.
+      state = RequiredLayerStateForChildren(aBuilder, aManager, aParameters,
+        *i->GetSameCoordinateSystemChildren(), i->GetAnimatedGeometryRoot());
+    }
     if ((state == LAYER_ACTIVE || state == LAYER_ACTIVE_FORCE) &&
         state > result) {
       result = state;
     }
     if (state == LAYER_ACTIVE_EMPTY && state > result) {
       result = LAYER_ACTIVE_FORCE;
     }
     if (state == LAYER_NONE) {
@@ -4453,17 +4462,17 @@ nsDisplayBlendContainer::BuildLayer(nsDi
   return container.forget();
 }
 
 LayerState
 nsDisplayBlendContainer::GetLayerState(nsDisplayListBuilder* aBuilder,
                                        LayerManager* aManager,
                                        const ContainerLayerParameters& aParameters)
 {
-  return mozilla::LAYER_ACTIVE;
+  return RequiredLayerStateForChildren(aBuilder, aManager, aParameters, mList, GetAnimatedGeometryRoot());
 }
 
 bool nsDisplayBlendContainer::TryMerge(nsDisplayItem* aItem) {
   if (aItem->GetType() != TYPE_BLEND_CONTAINER)
     return false;
   // items for the same content element should be merged into a single
   // compositing group
   // aItem->GetUnderlyingFrame() returns non-null because it's nsDisplayOpacity