Bug 988511 - Allow fixed position items to fully occlude displayport items. r=tn
authorChris Lord <chrislord.net@gmail.com>
Fri, 06 Jun 2014 12:00:34 +0100
changeset 206422 843c1dbab9d6bd14e609e42d3e25ad2e6c0f6b3a
parent 206421 d15632d881261b2d3a6225b30c4e84c0cb0eb5a9
child 206423 f74d791a1904c1af513ed71d1d943333a07c6541
push id3741
push userasasaki@mozilla.com
push dateMon, 21 Jul 2014 20:25:18 +0000
treeherdermozilla-beta@4d6f46f5af68 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstn
bugs988511
milestone32.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 988511 - Allow fixed position items to fully occlude displayport items. r=tn We don't allow fixed position items to occlude display-ports, but we should if they fully occlude the scroll-position scroll clamping port of the displayport frame.
layout/base/nsDisplayList.cpp
--- a/layout/base/nsDisplayList.cpp
+++ b/layout/base/nsDisplayList.cpp
@@ -1176,26 +1176,40 @@ nsDisplayList::ComputeVisibilityForSubli
       // If we're in a displayport, we need to make sure that fixed position
       // items do not subtract from the visible region, as async scrolling
       // may expose these occluded areas.
       // If the item is fixed pos in the same document as the displayport
       // then don't let it occlude this list. The only other case possible
       // is that the fixed pos content is in a child document, in which it
       // would scroll with the rest of the content.
       bool occlude = true;
+      nsIPresShell* presShell = nullptr;
       if (aDisplayPortFrame && item->IsInFixedPos()) {
         if (item->Frame()->PresContext() == aDisplayPortFrame->PresContext()) {
           occlude = false;
+          presShell = aDisplayPortFrame->PresContext()->PresShell();
         }
       }
 
+      nsRegion opaque = TreatAsOpaque(item, aBuilder);
       if (occlude) {
-        nsRegion opaque = TreatAsOpaque(item, aBuilder);
         // Subtract opaque item from the visible region
         aBuilder->SubtractFromVisibleRegion(aVisibleRegion, opaque);
+      } else if (presShell &&
+                 presShell->IsScrollPositionClampingScrollPortSizeSet() &&
+                 !opaque.IsEmpty()) {
+        // We make an exception if the fixed position item would fully occlude
+        // the scroll position clamping scroll-port. In that case, it's very
+        // unlikely that it will become visible via async scrolling, so we let
+        // it occlude.
+        nsRect scrollClampingScrollPort(nsPoint(0, 0),
+          presShell->GetScrollPositionClampingScrollPortSize());
+        if (opaque.Contains(scrollClampingScrollPort)) {
+          aVisibleRegion->SetEmpty();
+        }
       }
 
       if (aBuilder->NeedToForceTransparentSurfaceForItem(item) ||
           (list && list->NeedsTransparentSurface())) {
         forceTransparentSurface = true;
       }
     }
     AppendToBottom(item);