Bug 458969: dead stuff in nsSpaceManager r+sr=dbaron
authorTaras Glek <tglek@mozilla.com>
Tue, 14 Oct 2008 11:59:29 -0700
changeset 20483 4d78262505d706efa80926d23baf9d674c0d3d55
parent 20478 a043e83d291f9b2b12dd6d6ecfccc9649dd2ddf6
child 20484 f57be2771480e5a3372e05a15e63d9f05ae40907
push id2898
push usertglek@mozilla.com
push dateTue, 14 Oct 2008 19:18:51 +0000
treeherderautoland@4d78262505d7 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs458969
milestone1.9.1b2pre
Bug 458969: dead stuff in nsSpaceManager r+sr=dbaron
layout/generic/nsBlockFrame.cpp
layout/generic/nsSpaceManager.cpp
layout/generic/nsSpaceManager.h
--- a/layout/generic/nsBlockFrame.cpp
+++ b/layout/generic/nsBlockFrame.cpp
@@ -899,17 +899,17 @@ nsBlockFrame::Reflow(nsPresContext*     
   nsAutoSpaceManager autoSpaceManager(const_cast<nsHTMLReflowState &>(aReflowState));
 
   // XXXldb If we start storing the space manager in the frame rather
   // than keeping it around only during reflow then we should create it
   // only when there are actually floats to manage.  Otherwise things
   // like tables will gain significant bloat.
   PRBool needSpaceManager = nsBlockFrame::BlockNeedsSpaceManager(this);
   if (needSpaceManager)
-    autoSpaceManager.CreateSpaceManagerFor(aPresContext, this);
+    autoSpaceManager.CreateSpaceManager(aPresContext);
 
   // OK, some lines may be reflowed. Blow away any saved line cursor because
   // we may invalidate the nondecreasing combinedArea.y/yMost invariant,
   // and we may even delete the line with the line cursor.
   ClearLineCursor();
 
   if (IsFrameTreeTooDeep(aReflowState, aMetrics)) {
 #ifdef DEBUG_kipp
--- a/layout/generic/nsSpaceManager.cpp
+++ b/layout/generic/nsSpaceManager.cpp
@@ -102,19 +102,18 @@ static void
 PSArenaFreeCB(size_t aSize, void* aPtr, void* aClosure)
 {
   static_cast<nsIPresShell*>(aClosure)->FreeFrame(aSize, aPtr);
 }
 
 /////////////////////////////////////////////////////////////////////////////
 // nsSpaceManager
 
-nsSpaceManager::nsSpaceManager(nsIPresShell* aPresShell, nsIFrame* aFrame)
-  : mFrame(aFrame),
-    mLowestTop(NSCOORD_MIN),
+nsSpaceManager::nsSpaceManager(nsIPresShell* aPresShell)
+  : mLowestTop(NSCOORD_MIN),
     mFloatDamage(PSArenaAllocCB, PSArenaFreeCB, aPresShell),
     mHaveCachedLeftYMost(PR_TRUE),
     mHaveCachedRightYMost(PR_TRUE),
     mMaximalLeftYMost(nscoord_MIN),
     mMaximalRightYMost(nscoord_MIN),
     mCachedBandPosition(nsnull)
 {
   MOZ_COUNT_CTOR(nsSpaceManager);
@@ -191,27 +190,16 @@ void nsSpaceManager::Shutdown()
       nsMemory::Free(spaceManager);
   }
 
   // Disable further caching.
   sCachedSpaceManagerCount = -1;
 }
 
 PRBool
-nsSpaceManager::XMost(nscoord& aXMost) const
-{
-  nscoord xMost = 0;
-  for (FrameInfo* fi = mFrameInfoMap; fi; fi = fi->mNext) {
-    xMost = PR_MAX(xMost, fi->mRect.XMost());
-  }
-  aXMost = xMost;
-  return !mBandList.IsEmpty();
-}
-
-PRBool
 nsSpaceManager::YMost(nscoord& aYMost) const
 {
   PRBool result;
 
   if (mBandList.IsEmpty()) {
     aYMost = 0;
     result = PR_FALSE;
 
@@ -1028,26 +1016,16 @@ nsSpaceManager::RemoveRegion(nsIFrame* a
     }
   }
 
   DestroyFrameInfo(frameInfo);
   return NS_OK;
 }
 
 void
-nsSpaceManager::ClearRegions()
-{
-  ClearFrameInfo();
-  mBandList.Clear();
-  mLowestTop = NSCOORD_MIN;
-  mHaveCachedLeftYMost = mHaveCachedRightYMost = PR_TRUE;
-  mMaximalLeftYMost = mMaximalRightYMost = nscoord_MIN;
-}
-
-void
 nsSpaceManager::PushState(SavedState* aState)
 {
   NS_PRECONDITION(aState, "Need a place to save state");
 
   // This is a cheap push implementation, which
   // only saves the (x,y) and last frame in the mFrameInfoMap
   // which is enough info to get us back to where we should be
   // when pop is called.
@@ -1134,26 +1112,16 @@ DebugListSpaceManager(nsSpaceManager *aS
 }
 
 nsresult
 nsSpaceManager::List(FILE* out)
 {
   nsAutoString tmp;
 
   fprintf(out, "SpaceManager@%p", this);
-  if (mFrame) {
-    nsIFrameDebug*  frameDebug;
-
-    if (NS_SUCCEEDED(mFrame->QueryInterface(NS_GET_IID(nsIFrameDebug), (void**)&frameDebug))) {
-      frameDebug->GetFrameName(tmp);
-      fprintf(out, " frame=");
-      fputs(NS_LossyConvertUTF16toASCII(tmp).get(), out);
-      fprintf(out, "@%p", mFrame);
-    }
-  }
   fprintf(out, " xy=%d,%d <\n", mX, mY);
   if (mBandList.IsEmpty()) {
     fprintf(out, "  no bands\n");
   }
   else {
     BandRect* band = mBandList.Head();
     do {
       PRInt32 const n = band->mFrames.Count();
@@ -1486,22 +1454,22 @@ nsAutoSpaceManager::~nsAutoSpaceManager(
 #ifdef DEBUG
     if (mOwns)
 #endif
       delete mNew;
   }
 }
 
 nsresult
-nsAutoSpaceManager::CreateSpaceManagerFor(nsPresContext *aPresContext, nsIFrame *aFrame)
+nsAutoSpaceManager::CreateSpaceManager(nsPresContext *aPresContext)
 {
   // Create a new space manager and install it in the reflow
   // state. `Remember' the old space manager so we can restore it
   // later.
-  mNew = new nsSpaceManager(aPresContext->PresShell(), aFrame);
+  mNew = new nsSpaceManager(aPresContext->PresShell());
   if (! mNew)
     return NS_ERROR_OUT_OF_MEMORY;
 
 #ifdef NOISY_SPACEMANAGER
   printf("constructed new space manager %p (replacing %p)\n",
          mNew, mReflowState.mSpaceManager);
 #endif
 
--- a/layout/generic/nsSpaceManager.h
+++ b/layout/generic/nsSpaceManager.h
@@ -136,61 +136,42 @@ inline PRBool nsBandTrapezoid::EqualGeom
 struct nsBandData {
   PRInt32 mCount; // [out] actual number of trapezoids in the band data
   PRInt32 mSize; // [in] the size of the array (number of trapezoids)
   nsBandTrapezoid* mTrapezoids; // [out] array of length 'size'
 };
 
 /**
  * Class for dealing with bands of available space. The space manager
- * defines a coordinate space with an origin at (0, 0) that grows down
- * and to the right.
+ * defines a coordinate space (relative to the frame that created the
+ * space manager) with an origin at (0, 0) that grows down and to the
+ * right.
  */
 class nsSpaceManager {
 public:
-  nsSpaceManager(nsIPresShell* aPresShell, nsIFrame* aFrame);
+  nsSpaceManager(nsIPresShell* aPresShell);
   ~nsSpaceManager();
 
   void* operator new(size_t aSize) CPP_THROW_NEW;
   void operator delete(void* aPtr, size_t aSize);
 
   static void Shutdown();
-
-  /*
-   * Get the frame that's associated with the space manager. This frame
-   * created the space manager, and the world coordinate space is
-   * relative to this frame.
-   *
-   * You can use QueryInterface() on this frame to get any additional
-   * interfaces.
-   */
-  nsIFrame* GetFrame() const { return mFrame; }
-
   /**
    * Translate the current origin by the specified (dx, dy). This
    * creates a new local coordinate space relative to the current
    * coordinate space.
    */
   void Translate(nscoord aDx, nscoord aDy) { mX += aDx; mY += aDy; }
 
   /**
    * Returns the current translation from local coordinate space to
    * world coordinate space. This represents the accumulated calls to
    * Translate().
    */
   void GetTranslation(nscoord& aX, nscoord& aY) const { aX = mX; aY = mY; }
-
-  /**
-   * Returns the x-most rect in the space manager, or 0 if there are no
-   * rects.
-   *
-   * @return  PR_TRUE if there are bands and PR_FALSE if there are no bands
-   */
-  PRBool XMost(nscoord& aXMost) const;
-
   /**
    * Returns the y-most of the bottommost band or 0 if there are no bands.
    *
    * @return  PR_TRUE if there are bands and PR_FALSE if there are no bands
    */
   PRBool YMost(nscoord& aYMost) const;
 
   /**
@@ -269,21 +250,16 @@ public:
     nscoord mMaximalLeftYMost;
     nscoord mMaximalRightYMost;
     PRPackedBool mHaveCachedLeftYMost;
     PRPackedBool mHaveCachedRightYMost;
     
     friend class nsSpaceManager;
   };
 
-  /**
-   * Clears the list of regions representing the unavailable space.
-   */
-  void ClearRegions();
-
   PRBool HasAnyFloats() { return mFrameInfoMap != nsnull; }
 
   /**
    * Methods for dealing with the propagation of float damage during
    * reflow.
    */
   PRBool HasFloatDamage()
   {
@@ -414,17 +390,16 @@ public:
     // Operations
     void      Append(BandRect* aBandRect) {PR_APPEND_LINK(aBandRect, this);}
 
     // Remove and delete all the band rects in the list
     void      Clear();
   };
 
 protected:
-  nsIFrame* const mFrame;     // frame associated with the space manager
   nscoord         mX, mY;     // translation from local to global coordinate space
   BandList        mBandList;  // header/sentinel for circular linked list of band rects
   nscoord         mLowestTop;  // the lowest *top*
   FrameInfo*      mFrameInfoMap;
   nsIntervalSet   mFloatDamage;
   PRPackedBool    mHaveCachedLeftYMost; // If true, mMaximalLeftYMost is set
   PRPackedBool    mHaveCachedRightYMost; // If true, mMaximalRightYMost is set
   nscoord         mMaximalLeftYMost;  // The maximal YMost of our FrameInfo
@@ -441,17 +416,16 @@ protected:
   BandRect*       mCachedBandPosition;
 
 protected:
   FrameInfo* GetFrameInfoFor(nsIFrame* aFrame);
   FrameInfo* CreateFrameInfo(nsIFrame* aFrame, const nsRect& aRect);
   void       DestroyFrameInfo(FrameInfo*);
 
   void       ClearFrameInfo();
-  void       ClearBandRects();
 
   BandRect*  GetNextBand(const BandRect* aBandRect) const;
   BandRect*  GetPrevBand(const BandRect* aBandRect) const;
   void       DivideBand(BandRect* aBand, nscoord aBottom);
   PRBool     CanJoinBands(BandRect* aBand, BandRect* aPrevBand);
   PRBool     JoinBands(BandRect* aBand, BandRect* aPrevBand);
   void       AddRectToBand(BandRect* aBand, BandRect* aBandRect);
   void       InsertBandRect(BandRect* aBandRect);
@@ -503,18 +477,17 @@ public:
   ~nsAutoSpaceManager();
 
   /**
    * Create a new space manager for the specified frame. This will
    * `remember' the old space manager, and install the new space
    * manager in the reflow state.
    */
   nsresult
-  CreateSpaceManagerFor(nsPresContext *aPresContext,
-                        nsIFrame *aFrame);
+  CreateSpaceManager(nsPresContext *aPresContext);
 
 #ifdef DEBUG
   /**
    * `Orphan' any space manager that the nsAutoSpaceManager created;
    * i.e., make it so that we don't destroy the space manager when we
    * go out of scope.
    */
   void DebugOrphanSpaceManager() { mOwns = PR_FALSE; }