Bug 1440177 - Part 7: Don't allocate new clips when flattening nsDisplayOpacity. r=mstange
☠☠ backed out by 13adabb75562 ☠ ☠
authorMatt Woodrow <mwoodrow@mozilla.com>
Fri, 02 Mar 2018 10:06:13 +1300
changeset 762387 d83a1820b2f22263888e082911615e0c5dd4288f
parent 762386 a77d06b2cf03b3b8824130a1e32c0b09d3ec138c
child 762388 13adabb755622b9cb85f76e2e15808e64296c412
push id101169
push userluca.greco@alcacoop.it
push dateFri, 02 Mar 2018 12:32:00 +0000
reviewersmstange
bugs1440177
milestone60.0a1
Bug 1440177 - Part 7: Don't allocate new clips when flattening nsDisplayOpacity. r=mstange Combing the two clips as-is should always be correct, and since they're frequently identical, we can usually make IntersectClip a no-op. MozReview-Commit-ID: EKHdPogzd3t
layout/painting/nsDisplayList.cpp
--- a/layout/painting/nsDisplayList.cpp
+++ b/layout/painting/nsDisplayList.cpp
@@ -3291,17 +3291,17 @@ FindCommonAncestorClipForIntersection(co
   return nullptr;
 }
 
 void
 nsDisplayItem::IntersectClip(nsDisplayListBuilder* aBuilder,
                              const DisplayItemClipChain* aOther,
                              bool aStore)
 {
-  if (!aOther) {
+  if (!aOther || mClipChain == aOther) {
     return;
   }
 
   // aOther might be a reference to a clip on the stack. We need to make sure
   // that CreateClipChainIntersection will allocate the actual intersected
   // clip in the builder's arena, so for the mClipChain == nullptr case,
   // we supply nullptr as the common ancestor so that CreateClipChainIntersection
   // clones the whole chain.
@@ -6708,31 +6708,18 @@ nsDisplayOpacity::ShouldFlattenAway(nsDi
   for (size_t i = 0; i < childCount; i++) {
     for (size_t j = i+1; j < childCount; j++) {
       if (children[i].bounds.Intersects(children[j].bounds)) {
         return false;
       }
     }
   }
 
-  // When intersecting the children's clip, only intersect with the clip for
-  // our ASR and not with the whole clip chain, because the rest of the clip
-  // chain is usually already set on the children. In fact, opacity items
-  // usually never have their own clip because during display item creation
-  // time we propagated the clip to our contents, so maybe we should just
-  // remove the clip parameter from ApplyOpacity completely.
-  const DisplayItemClipChain* clip = nullptr;
-
-  if (mClip) {
-    clip = aBuilder->AllocateDisplayItemClipChain(*mClip, mActiveScrolledRoot,
-                                                  nullptr);
-  }
-
   for (uint32_t i = 0; i < childCount; i++) {
-    children[i].item->ApplyOpacity(aBuilder, mOpacity, clip);
+    children[i].item->ApplyOpacity(aBuilder, mOpacity, mClipChain);
   }
 
   return true;
 }
 
 nsDisplayItem::LayerState
 nsDisplayOpacity::GetLayerState(nsDisplayListBuilder* aBuilder,
                                 LayerManager* aManager,