Bug 1448841 - Part 2: Only compute the highest z-index for overlay scrollbars. r=mstange
authorMatt Woodrow <mwoodrow@mozilla.com>
Thu, 29 Mar 2018 23:01:21 +1300
changeset 775153 f49364d5ebad1bdc8db3c3b7ef785335feefadc8
parent 775152 b895a035f5e355a3380d5fb147d091be1e4808a5
child 775154 130a8f287efe6f34a909090b3386fc72ebf4f358
push id104638
push userbmo:jlorenzo@mozilla.com
push dateFri, 30 Mar 2018 13:27:33 +0000
reviewersmstange
bugs1448841
milestone61.0a1
Bug 1448841 - Part 2: Only compute the highest z-index for overlay scrollbars. r=mstange MozReview-Commit-ID: KFw4dbdCHMf
layout/generic/nsGfxScrollFrame.cpp
--- a/layout/generic/nsGfxScrollFrame.cpp
+++ b/layout/generic/nsGfxScrollFrame.cpp
@@ -3042,16 +3042,17 @@ AppendInternalItemToTop(const nsDisplayL
   } else {
     aLists.Content()->AppendToTop(aItem);
   }
 }
 
 static const uint32_t APPEND_OWN_LAYER = 0x1;
 static const uint32_t APPEND_POSITIONED = 0x2;
 static const uint32_t APPEND_SCROLLBAR_CONTAINER = 0x4;
+static const uint32_t APPEND_OVERLAY = 0x8;
 
 static void
 AppendToTop(nsDisplayListBuilder* aBuilder, const nsDisplayListSet& aLists,
             nsDisplayList* aSource, nsIFrame* aSourceFrame, uint32_t aFlags)
 {
   if (aSource->IsEmpty())
     return;
 
@@ -3076,17 +3077,20 @@ AppendToTop(nsDisplayListBuilder* aBuild
   } else {
     newItem = MakeDisplayItem<nsDisplayWrapList>(aBuilder, aSourceFrame, aSource, asr);
   }
 
   if (aFlags & APPEND_POSITIONED) {
     // We want overlay scrollbars to always be on top of the scrolled content,
     // but we don't want them to unnecessarily cover overlapping elements from
     // outside our scroll frame.
-    int32_t zIndex = MaxZIndexInList(aLists.PositionedDescendants(), aBuilder);
+    int32_t zIndex = -1;
+    if (aFlags & APPEND_OVERLAY) {
+      zIndex = MaxZIndexInList(aLists.PositionedDescendants(), aBuilder);
+    }
     AppendInternalItemToTop(aLists, newItem, zIndex);
   } else {
     aLists.BorderBackground()->AppendToTop(newItem);
   }
 }
 
 struct HoveredStateComparator
 {
@@ -3195,16 +3199,19 @@ ScrollFrameHelper::AppendScrollPartsTo(n
     }
 
     if (createLayer) {
       appendToTopFlags |= APPEND_OWN_LAYER;
     }
     if (aPositioned) {
       appendToTopFlags |= APPEND_POSITIONED;
     }
+    if (overlayScrollbars) {
+      appendToTopFlags |= APPEND_OVERLAY;
+    }
 
     {
       nsDisplayListBuilder::AutoBuildingDisplayList
         buildingForChild(aBuilder, scrollParts[i],
                          visible + mOuter->GetOffsetTo(scrollParts[i]),
                          dirty + mOuter->GetOffsetTo(scrollParts[i]), true);
       nsDisplayListBuilder::AutoCurrentScrollbarInfoSetter
         infoSetter(aBuilder, scrollTargetId, flags, createLayer);