Bug 1440177 - Part 7: Don't allocate new clips when flattening nsDisplayOpacity. r?mstange draft
authorMatt Woodrow <mwoodrow@mozilla.com>
Fri, 02 Mar 2018 11:19:17 +1300
changeset 762226 5a59913b34bc4855876a8ec9ac058446d6711a5f
parent 762225 f119175e79ca494d12ec5ba49e20b12c9e03ada4
push id101106
push usermwoodrow@mozilla.com
push dateThu, 01 Mar 2018 22:19:48 +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: 3xxMyZjwPvJ
layout/painting/nsDisplayList.cpp
--- a/layout/painting/nsDisplayList.cpp
+++ b/layout/painting/nsDisplayList.cpp
@@ -3290,17 +3290,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.
@@ -6707,31 +6707,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,