Bug 1450360 - Respect the z-index property set on scrollbars. r=mstange
☠☠ backed out by 1758267802e9 ☠ ☠
authorMatt Woodrow <mwoodrow@mozilla.com>
Mon, 02 Apr 2018 16:13:25 +1200
changeset 411291 924e90305946602f0befb853082da372e87f2c3d
parent 411290 a2cd9f565c9fd0682836114c01bc3135a092e58e
child 411292 0cb041700c38f2f2a436252de179ac8ed6f299f3
push id101607
push usermwoodrow@mozilla.com
push dateMon, 02 Apr 2018 04:14:38 +0000
treeherdermozilla-inbound@0cb041700c38 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmstange
bugs1450360
milestone61.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1450360 - Respect the z-index property set on scrollbars. r=mstange
layout/generic/nsGfxScrollFrame.cpp
--- a/layout/generic/nsGfxScrollFrame.cpp
+++ b/layout/generic/nsGfxScrollFrame.cpp
@@ -2993,34 +2993,38 @@ ScrollFrameHelper::ScrollToImpl(nsPoint 
   }
 
   nsCOMPtr<nsIDocShell> docShell = presContext->GetDocShell();
   if (docShell) {
     docShell->NotifyScrollObservers();
   }
 }
 
-static int32_t
+static Maybe<int32_t>
 MaxZIndexInList(nsDisplayList* aList, nsDisplayListBuilder* aBuilder)
 {
-  int32_t maxZIndex = -1;
+  Maybe<int32_t> maxZIndex = Nothing();
   for (nsDisplayItem* item = aList->GetBottom(); item; item = item->GetAbove()) {
-    maxZIndex = std::max(maxZIndex, item->ZIndex());
+    if (!maxZIndex) {
+      maxZIndex = Some(item->ZIndex());
+    } else {
+      maxZIndex = Some(std::max(maxZIndex.value(), item->ZIndex()));
+    }
   }
   return maxZIndex;
 }
 
 template<class T>
 static void
 AppendInternalItemToTop(const nsDisplayListSet& aLists,
                         T* aItem,
-                        int32_t aZIndex)
-{
-  if (aZIndex >= 0) {
-    aItem->SetOverrideZIndex(aZIndex);
+                        const Maybe<int32_t>& aZIndex)
+{
+  if (aZIndex) {
+    aItem->SetOverrideZIndex(aZIndex.value());
     aLists.PositionedDescendants()->AppendToTop(aItem);
   } else {
     aLists.Content()->AppendToTop(aItem);
   }
 }
 
 static const uint32_t APPEND_OWN_LAYER = 0x1;
 static const uint32_t APPEND_POSITIONED = 0x2;
@@ -3055,19 +3059,22 @@ 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 = -1;
+    Maybe<int32_t> zIndex = Nothing();
     if (aFlags & APPEND_OVERLAY) {
       zIndex = MaxZIndexInList(aLists.PositionedDescendants(), aBuilder);
+    } else if (aSourceFrame->StylePosition()->mZIndex.GetUnit() == eStyleUnit_Integer) {
+      zIndex = Some(aSourceFrame->StylePosition()->mZIndex.GetIntValue());
+
     }
     AppendInternalItemToTop(aLists, newItem, zIndex);
   } else {
     aLists.BorderBackground()->AppendToTop(newItem);
   }
 }
 
 struct HoveredStateComparator
@@ -3700,23 +3707,23 @@ ScrollFrameHelper::BuildDisplayList(nsDi
         ScrollbarStyles scrollbarStyles = GetScrollbarStylesFromFrame();
         if (scrollbarStyles.mOverscrollBehaviorX != StyleOverscrollBehavior::Auto ||
             scrollbarStyles.mOverscrollBehaviorY != StyleOverscrollBehavior::Auto) {
           info |= CompositorHitTestInfo::eRequiresTargetConfirmation;
         }
         nsDisplayCompositorHitTestInfo* hitInfo =
             MakeDisplayItem<nsDisplayCompositorHitTestInfo>(aBuilder, mScrolledFrame, info, 1,
                 Some(mScrollPort + aBuilder->ToReferenceFrame(mOuter)));
-        AppendInternalItemToTop(scrolledContent, hitInfo, INT32_MAX);
+        AppendInternalItemToTop(scrolledContent, hitInfo, Some(INT32_MAX));
       }
       if (aBuilder->IsBuildingLayerEventRegions()) {
         nsDisplayLayerEventRegions* inactiveRegionItem =
             MakeDisplayItem<nsDisplayLayerEventRegions>(aBuilder, mScrolledFrame, 1);
         inactiveRegionItem->AddInactiveScrollPort(mScrolledFrame, mScrollPort + aBuilder->ToReferenceFrame(mOuter));
-        AppendInternalItemToTop(scrolledContent, inactiveRegionItem, INT32_MAX);
+        AppendInternalItemToTop(scrolledContent, inactiveRegionItem, Some(INT32_MAX));
       }
     }
 
     if (aBuilder->ShouldBuildScrollInfoItemsForHoisting()) {
       aBuilder->AppendNewScrollInfoItemForHoisting(
         MakeDisplayItem<nsDisplayScrollInfoLayer>(aBuilder, mScrolledFrame,
                                                 mOuter));
     }