Bug 1284350 - Revert "Bug 1269934 - Handle visible frame sets more generically in PresShell. r=mstange". a=lizzard
☠☠ backed out by ab6b685c5249 ☠ ☠
authorSeth Fowler <mark.seth.fowler@gmail.com>
Fri, 08 Jul 2016 17:55:03 -0700
changeset 339878 682c936d70b3e26a375137363b1c5a8c8b413d35
parent 339877 095bb628a66a10a1ef2108702f026ba521131de5
child 339879 2c640e291b419748c2a499fcda77bd9765c9f757
push id6249
push userjlund@mozilla.com
push dateMon, 01 Aug 2016 13:59:36 +0000
treeherdermozilla-beta@bad9d4f5bf7e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmstange, lizzard
bugs1284350, 1269934
milestone49.0a2
Bug 1284350 - Revert "Bug 1269934 - Handle visible frame sets more generically in PresShell. r=mstange". a=lizzard This reverts commit 95a35f5c34c35325dc3627173767e8448bc2ddec.
dom/base/nsImageLoadingContent.cpp
layout/base/nsIPresShell.h
layout/base/nsPresShell.cpp
layout/base/nsPresShell.h
layout/generic/nsFrame.cpp
--- a/dom/base/nsImageLoadingContent.cpp
+++ b/dom/base/nsImageLoadingContent.cpp
@@ -286,17 +286,17 @@ nsImageLoadingContent::OnUnlockedDraw()
     return;
   }
 
   nsIPresShell* presShell = presContext->PresShell();
   if (!presShell) {
     return;
   }
 
-  presShell->MarkFrameVisible(frame, VisibilityCounter::IN_DISPLAYPORT);
+  presShell->MarkFrameVisibleInDisplayPort(frame);
 }
 
 nsresult
 nsImageLoadingContent::OnImageIsAnimated(imgIRequest *aRequest)
 {
   bool* requestFlag = GetRegisteredFlagForRequest(aRequest);
   if (requestFlag) {
     nsLayoutUtils::RegisterImageRequest(GetFramePresContext(),
--- a/layout/base/nsIPresShell.h
+++ b/layout/base/nsIPresShell.h
@@ -42,17 +42,16 @@
 #include "nsWeakReference.h"
 #include <stdio.h> // for FILE definition
 #include "nsChangeHint.h"
 #include "nsRefPtrHashtable.h"
 #include "nsClassHashtable.h"
 #include "nsPresArena.h"
 #include "nsMargin.h"
 #include "nsFrameState.h"
-#include "Visibility.h"
 
 #ifdef MOZ_B2G
 #include "nsIHardwareKeyHandler.h"
 #endif
 
 class nsDocShell;
 class nsIDocument;
 class nsIFrame;
@@ -181,17 +180,16 @@ enum nsRectVisibility {
 class nsIPresShell : public nsISupports
 {
 public:
   NS_DECLARE_STATIC_IID_ACCESSOR(NS_IPRESSHELL_IID)
 
 protected:
   typedef mozilla::layers::LayerManager LayerManager;
   typedef mozilla::gfx::SourceSurface SourceSurface;
-  using VisibilityCounter = mozilla::VisibilityCounter;
 
   enum eRenderFlag {
     STATE_IGNORING_VIEWPORT_SCROLLING = 0x1,
     STATE_DRAWWINDOW_NOT_FLUSHING = 0x2
   };
   typedef uint8_t RenderFlags; // for storing the above flags
 
 public:
@@ -1585,21 +1583,21 @@ public:
   virtual void ScheduleApproximateFrameVisibilityUpdateNow() = 0;
 
   /// Clears the current list of approximately visible frames on this pres shell
   /// and replaces it with frames that are in the display list @aList.
   virtual void RebuildApproximateFrameVisibilityDisplayList(const nsDisplayList& aList) = 0;
   virtual void RebuildApproximateFrameVisibility(nsRect* aRect = nullptr,
                                                  bool aRemoveOnly = false) = 0;
 
-  /// Adds @aFrame to the visible frames set specified by @aCounter.
-  /// VisibilityCounter::MAY_BECOME_VISIBLE is not a valid argument.
-  virtual void MarkFrameVisible(nsIFrame* aFrame, VisibilityCounter aCounter) = 0;
+  /// Adds @aFrame to the list of frames which were visible within the
+  /// displayport during the last paint.
+  virtual void MarkFrameVisibleInDisplayPort(nsIFrame* aFrame) = 0;
 
-  /// Marks @aFrame nonvisible and removes it from all sets of visible frames.
+  /// Marks @aFrame nonvisible and removes it from all lists of visible frames.
   virtual void MarkFrameNonvisible(nsIFrame* aFrame) = 0;
 
   /// Whether we should assume all frames are visible.
   virtual bool AssumeAllFramesVisible() = 0;
 
 
   /**
    * Returns whether the document's style set's rule processor for the
--- a/layout/base/nsPresShell.cpp
+++ b/layout/base/nsPresShell.cpp
@@ -5758,17 +5758,19 @@ PresShell::AddFrameToVisibleRegions(nsIF
   nsLayoutUtils::TransformResult result =
     nsLayoutUtils::TransformRect(aFrame,
                                  scrollableFrame->GetScrolledFrame(),
                                  frameRectInScrolledFrameSpace);
   if (result != nsLayoutUtils::TransformResult::TRANSFORM_SUCCEEDED) {
     return;
   }
 
-  VisibleRegions& regions = mVisibleRegions->ForCounter(aForCounter);
+  VisibleRegions& regions = aForCounter == VisibilityCounter::MAY_BECOME_VISIBLE
+                          ? mVisibleRegions->mApproximate
+                          : mVisibleRegions->mInDisplayPort;
   CSSIntRegion* regionForView = regions.LookupOrAdd(viewID);
   MOZ_ASSERT(regionForView);
 
   regionForView->OrWith(CSSPixel::FromAppUnitsRounded(frameRectInScrolledFrameSpace));
 }
 
 /* static */ void
 PresShell::MarkFramesInListApproximatelyVisible(const nsDisplayList& aList)
@@ -5829,17 +5831,19 @@ PresShell::InitVisibleRegionsIfVisualiza
       !gfxPrefs::APZMinimapVisibilityEnabled()) {
     mVisibleRegions = nullptr;
     return;
   }
 
   if (mVisibleRegions) {
     // Clear the regions we're about to update. We don't want to clear both,
     // or the two visibility tracking methods will interfere with each other.
-    VisibleRegions& regions = mVisibleRegions->ForCounter(aForCounter);
+    VisibleRegions& regions = aForCounter == VisibilityCounter::MAY_BECOME_VISIBLE
+                            ? mVisibleRegions->mApproximate
+                            : mVisibleRegions->mInDisplayPort;
     regions.Clear();
     return;
   }
 
   mVisibleRegions = MakeUnique<VisibleRegionsContainer>();
 }
 
 void
@@ -6180,51 +6184,45 @@ PresShell::ScheduleApproximateFrameVisib
   RefPtr<nsRunnableMethod<PresShell> > ev =
     NewRunnableMethod(this, &PresShell::UpdateApproximateFrameVisibility);
   if (NS_SUCCEEDED(NS_DispatchToCurrentThread(ev))) {
     mUpdateApproximateFrameVisibilityEvent = ev;
   }
 }
 
 void
-PresShell::MarkFrameVisible(nsIFrame* aFrame, VisibilityCounter aCounter)
-{
-  MOZ_ASSERT(aCounter != VisibilityCounter::MAY_BECOME_VISIBLE,
-             "MAY_BECOME_VISIBLE should only be managed from within PresShell");
-
+PresShell::MarkFrameVisibleInDisplayPort(nsIFrame* aFrame)
+{
   if (!aFrame->TrackingVisibility()) {
     return;
   }
 
   if (AssumeAllFramesVisible()) {
-    // Force to maximum visibility (IN_DISPLAYPORT) regardless of aCounter's value.
     if (aFrame->GetVisibility() != Visibility::IN_DISPLAYPORT) {
       aFrame->IncVisibilityCount(VisibilityCounter::IN_DISPLAYPORT);
     }
     return;
   }
 
 #ifdef DEBUG
   // Make sure it's in this pres shell.
   nsCOMPtr<nsIContent> content = aFrame->GetContent();
   if (content) {
     PresShell* shell = static_cast<PresShell*>(content->OwnerDoc()->GetShell());
     MOZ_ASSERT(!shell || shell == this, "wrong shell");
   }
 #endif
 
-  VisibleFrames& frameSet = VisibleFramesForCounter(aCounter);
-
-  if (!frameSet.Contains(aFrame)) {
+  if (!mInDisplayPortFrames.Contains(aFrame)) {
     MOZ_ASSERT(!AssumeAllFramesVisible());
-    frameSet.PutEntry(aFrame);
-    aFrame->IncVisibilityCount(aCounter);
-  }
-
-  AddFrameToVisibleRegions(aFrame, aCounter);
+    mInDisplayPortFrames.PutEntry(aFrame);
+    aFrame->IncVisibilityCount(VisibilityCounter::IN_DISPLAYPORT);
+  }
+
+  AddFrameToVisibleRegions(aFrame, VisibilityCounter::IN_DISPLAYPORT);
 }
 
 static void
 RemoveFrameFromVisibleSet(nsIFrame* aFrame,
                           VisibleFrames& aSet,
                           VisibilityCounter aCounter)
 {
   uint32_t count = aSet.Count();
--- a/layout/base/nsPresShell.h
+++ b/layout/base/nsPresShell.h
@@ -33,16 +33,17 @@
 #include "nsRefreshDriver.h"
 #include "TouchManager.h"
 #include "mozilla/Attributes.h"
 #include "mozilla/EventForwards.h"
 #include "mozilla/MemoryReporting.h"
 #include "mozilla/StyleSetHandle.h"
 #include "mozilla/UniquePtr.h"
 #include "MobileViewportManager.h"
+#include "Visibility.h"
 #include "ZoomConstraintsClient.h"
 
 class nsRange;
 
 struct RangePaintInfo;
 struct nsCallbackEventRequest;
 #ifdef MOZ_REFLOW_PERF
 class ReflowCountMgr;
@@ -400,17 +401,17 @@ public:
 
   void ScheduleApproximateFrameVisibilityUpdateSoon() override;
   void ScheduleApproximateFrameVisibilityUpdateNow() override;
 
   void RebuildApproximateFrameVisibilityDisplayList(const nsDisplayList& aList) override;
   void RebuildApproximateFrameVisibility(nsRect* aRect = nullptr,
                                          bool aRemoveOnly = false) override;
 
-  void MarkFrameVisible(nsIFrame* aFrame, VisibilityCounter aCounter) override;
+  void MarkFrameVisibleInDisplayPort(nsIFrame* aFrame) override;
   void MarkFrameNonvisible(nsIFrame* aFrame) override;
 
   bool AssumeAllFramesVisible() override;
 
 
   virtual void RecordShadowStyleChange(mozilla::dom::ShadowRoot* aShadowRoot) override;
 
   virtual void DispatchAfterKeyboardEvent(nsINode* aTarget,
@@ -784,43 +785,25 @@ protected:
 
   void InitVisibleRegionsIfVisualizationEnabled(VisibilityCounter aForCounter);
   void AddFrameToVisibleRegions(nsIFrame* aFrame, VisibilityCounter aForCounter);
   void NotifyCompositorOfVisibleRegionsChange();
 
   nsRevocableEventPtr<nsRunnableMethod<PresShell>> mUpdateApproximateFrameVisibilityEvent;
   nsRevocableEventPtr<nsRunnableMethod<PresShell>> mNotifyCompositorOfVisibleRegionsChangeEvent;
 
-  VisibleFrames& VisibleFramesForCounter(VisibilityCounter aCounter)
-  {
-    switch (aCounter)
-    {
-      case VisibilityCounter::MAY_BECOME_VISIBLE: return mApproximatelyVisibleFrames;
-      case VisibilityCounter::IN_DISPLAYPORT:     return mInDisplayPortFrames;
-    }
-  }
-
   // A set of frames that were visible or could be visible soon at the time
   // that we last did an approximate frame visibility update.
   VisibleFrames mApproximatelyVisibleFrames;
 
   // A set of frames that were visible in the displayport the last time we painted.
   VisibleFrames mInDisplayPortFrames;
 
   struct VisibleRegionsContainer
   {
-    VisibleRegions& ForCounter(VisibilityCounter aCounter)
-    {
-      switch (aCounter)
-      {
-        case VisibilityCounter::MAY_BECOME_VISIBLE: return mApproximate;
-        case VisibilityCounter::IN_DISPLAYPORT:     return mInDisplayPort;
-      }
-    }
-
     // The approximately visible regions calculated during the last update to
     // approximate frame visibility.
     VisibleRegions mApproximate;
 
     // The in-displayport visible regions calculated during the last paint.
     VisibleRegions mInDisplayPort;
   };
 
--- a/layout/generic/nsFrame.cpp
+++ b/layout/generic/nsFrame.cpp
@@ -1508,17 +1508,17 @@ void
 nsIFrame::UpdateVisibilitySynchronously()
 {
   nsIPresShell* presShell = PresContext()->PresShell();
   if (!presShell) {
     return;
   }
 
   if (presShell->AssumeAllFramesVisible()) {
-    presShell->MarkFrameVisible(this, VisibilityCounter::IN_DISPLAYPORT);
+    presShell->MarkFrameVisibleInDisplayPort(this);
     return;
   }
 
   bool visible = true;
   nsIFrame* f = GetParent();
   nsRect rect = GetRectRelativeToSelf();
   nsIFrame* rectFrame = this;
   while (f) {
@@ -1549,17 +1549,17 @@ nsIFrame::UpdateVisibilitySynchronously(
       if (parent && parent->PresContext()->IsChrome()) {
         break;
       }
     }
     f = parent;
   }
 
   if (visible) {
-    presShell->MarkFrameVisible(this, VisibilityCounter::IN_DISPLAYPORT);
+    presShell->MarkFrameVisibleInDisplayPort(this);
   } else {
     presShell->MarkFrameNonvisible(this);
   }
 }
 
 void
 nsIFrame::EnableVisibilityTracking()
 {
@@ -2751,17 +2751,17 @@ nsIFrame::BuildDisplayListForChild(nsDis
       !PresContext()->GetTheme()->WidgetIsContainer(ourDisp->mAppearance))
     return;
 
   // Since we're now sure that we're adding this frame to the display list
   // (which means we're painting it, modulo occlusion), mark it as visible
   // within the displayport.
   if (aBuilder->IsPaintingToWindow() && child->TrackingVisibility()) {
     nsIPresShell* shell = child->PresContext()->PresShell();
-    shell->MarkFrameVisible(child, VisibilityCounter::IN_DISPLAYPORT);
+    shell->MarkFrameVisibleInDisplayPort(child);
   }
 
   // Child is composited if it's transformed, partially transparent, or has
   // SVG effects or a blend mode..
   const nsStyleDisplay* disp = child->StyleDisplay();
   const nsStyleEffects* effects = child->StyleEffects();
   const nsStylePosition* pos = child->StylePosition();
   bool isVisuallyAtomic = child->HasOpacity()