From 5d0ec492ca69854bb2afb1a8daf025100f801d6b Mon Sep 17 00:00:00 2001 From: troy Date: Tue, 12 May 1998 23:02:02 +0000 Subject: [PATCH] Added new member functions git-svn-id: svn://10.0.0.236/trunk@1478 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/layout/base/src/nsSpaceManager.cpp | 38 ++++++++++++++++++++-- mozilla/layout/base/src/nsSpaceManager.h | 15 ++++++--- mozilla/layout/generic/nsSpaceManager.cpp | 38 ++++++++++++++++++++-- mozilla/layout/generic/nsSpaceManager.h | 15 ++++++--- 4 files changed, 94 insertions(+), 12 deletions(-) diff --git a/mozilla/layout/base/src/nsSpaceManager.cpp b/mozilla/layout/base/src/nsSpaceManager.cpp index b9cc51b859b..fb50d54968b 100644 --- a/mozilla/layout/base/src/nsSpaceManager.cpp +++ b/mozilla/layout/base/src/nsSpaceManager.cpp @@ -203,6 +203,7 @@ PRInt32 SpaceManager::GetBandData(nscoord aYOffset, } } + NS_POSTCONDITION(aBandData.count > 0, "unexpected band data count"); return aBandData.count; } @@ -493,8 +494,10 @@ void SpaceManager::AddRectToBand(nsBandRect* aBand, // | R | // +-----+ // -void SpaceManager::AddRectRegion(const nsRect& aUnavailableSpace, nsIFrame* aFrame) +PRBool SpaceManager::AddRectRegion(nsIFrame* aFrame, const nsRect& aUnavailableSpace) { + NS_PRECONDITION(nsnull != aFrame, "null frame"); + // Convert from local to world coordinates nsRect rect(aUnavailableSpace.x + mX, aUnavailableSpace.y + mY, aUnavailableSpace.width, aUnavailableSpace.height); @@ -504,7 +507,7 @@ void SpaceManager::AddRectRegion(const nsRect& aUnavailableSpace, nsIFrame* aFra if ((0 == mRectArray.mCount) || (rect.y >= mRectArray.YMost())) { // Append a new bottommost band mRectArray.Append(rect, aFrame); - return; + return PR_TRUE; } // Examine each band looking for a band that intersects this rect @@ -590,6 +593,37 @@ void SpaceManager::AddRectRegion(const nsRect& aUnavailableSpace, nsIFrame* aFra } } } + + return PR_TRUE; +} + +PRBool SpaceManager::ReshapeRectRegion(nsIFrame* aFrame, const nsRect& aUnavailableSpace) +{ + NS_NOTYETIMPLEMENTED("offseting a region"); + return PR_FALSE; +} + +PRBool SpaceManager::OffsetRegion(nsIFrame* aFrame, nscoord dx, nscoord dy) +{ + NS_NOTYETIMPLEMENTED("offseting a region"); + return PR_FALSE; +} + +PRBool SpaceManager::RemoveRegion(nsIFrame* aFrame) +{ + PRBool result = PR_FALSE; + + // Walk the list of rects and remove those tagged with aFrame. + // XXX We need to properly handle overlapped rects + for (PRInt32 i = 0; i < mRectArray.mCount; i++) { + if (mRectArray.mRects[i].frame == aFrame) { + mRectArray.RemoveAt(i); + result = PR_TRUE; + } + } + + // XXX We should try and coalesce adjacent bands... + return result; } void SpaceManager::ClearRegions() diff --git a/mozilla/layout/base/src/nsSpaceManager.h b/mozilla/layout/base/src/nsSpaceManager.h index 0c01d5a5dcf..0f7d80f3343 100644 --- a/mozilla/layout/base/src/nsSpaceManager.h +++ b/mozilla/layout/base/src/nsSpaceManager.h @@ -33,14 +33,20 @@ public: virtual nsIFrame* GetFrame() const; - virtual void Translate(nscoord aDx, nscoord aDy); - virtual void GetTranslation(nscoord& aX, nscoord& aY) const; + virtual void Translate(nscoord aDx, nscoord aDy); + virtual void GetTranslation(nscoord& aX, nscoord& aY) const; virtual nscoord YMost() const; + virtual PRInt32 GetBandData(nscoord aYOffset, const nsSize& aMaxSize, nsBandData& aBandData) const; - virtual void AddRectRegion(const nsRect& aUnavailableSpace, nsIFrame* aFrame); - virtual void ClearRegions(); + + virtual PRBool AddRectRegion(nsIFrame* aFrame, const nsRect& aUnavailableSpace); + virtual PRBool ReshapeRectRegion(nsIFrame* aFrame, const nsRect& aUnavailableSpace); + virtual PRBool OffsetRegion(nsIFrame* aFrame, nscoord dx, nscoord dy); + virtual PRBool RemoveRegion(nsIFrame* aFrame); + + virtual void ClearRegions(); protected: struct nsBandRect : nsRect { @@ -73,6 +79,7 @@ protected: nsIFrame* const mFrame; // frame associated with the space manager nscoord mX, mY; // translation from local to global coordinate space RectArray mRectArray; // y-x banded array of rectangles of unavailable space + RectArray mEmptyRects; // list of empty height rects protected: PRBool GetNextBand(nsBandRect*& aRect, PRInt32& aIndex) const; diff --git a/mozilla/layout/generic/nsSpaceManager.cpp b/mozilla/layout/generic/nsSpaceManager.cpp index b9cc51b859b..fb50d54968b 100644 --- a/mozilla/layout/generic/nsSpaceManager.cpp +++ b/mozilla/layout/generic/nsSpaceManager.cpp @@ -203,6 +203,7 @@ PRInt32 SpaceManager::GetBandData(nscoord aYOffset, } } + NS_POSTCONDITION(aBandData.count > 0, "unexpected band data count"); return aBandData.count; } @@ -493,8 +494,10 @@ void SpaceManager::AddRectToBand(nsBandRect* aBand, // | R | // +-----+ // -void SpaceManager::AddRectRegion(const nsRect& aUnavailableSpace, nsIFrame* aFrame) +PRBool SpaceManager::AddRectRegion(nsIFrame* aFrame, const nsRect& aUnavailableSpace) { + NS_PRECONDITION(nsnull != aFrame, "null frame"); + // Convert from local to world coordinates nsRect rect(aUnavailableSpace.x + mX, aUnavailableSpace.y + mY, aUnavailableSpace.width, aUnavailableSpace.height); @@ -504,7 +507,7 @@ void SpaceManager::AddRectRegion(const nsRect& aUnavailableSpace, nsIFrame* aFra if ((0 == mRectArray.mCount) || (rect.y >= mRectArray.YMost())) { // Append a new bottommost band mRectArray.Append(rect, aFrame); - return; + return PR_TRUE; } // Examine each band looking for a band that intersects this rect @@ -590,6 +593,37 @@ void SpaceManager::AddRectRegion(const nsRect& aUnavailableSpace, nsIFrame* aFra } } } + + return PR_TRUE; +} + +PRBool SpaceManager::ReshapeRectRegion(nsIFrame* aFrame, const nsRect& aUnavailableSpace) +{ + NS_NOTYETIMPLEMENTED("offseting a region"); + return PR_FALSE; +} + +PRBool SpaceManager::OffsetRegion(nsIFrame* aFrame, nscoord dx, nscoord dy) +{ + NS_NOTYETIMPLEMENTED("offseting a region"); + return PR_FALSE; +} + +PRBool SpaceManager::RemoveRegion(nsIFrame* aFrame) +{ + PRBool result = PR_FALSE; + + // Walk the list of rects and remove those tagged with aFrame. + // XXX We need to properly handle overlapped rects + for (PRInt32 i = 0; i < mRectArray.mCount; i++) { + if (mRectArray.mRects[i].frame == aFrame) { + mRectArray.RemoveAt(i); + result = PR_TRUE; + } + } + + // XXX We should try and coalesce adjacent bands... + return result; } void SpaceManager::ClearRegions() diff --git a/mozilla/layout/generic/nsSpaceManager.h b/mozilla/layout/generic/nsSpaceManager.h index 0c01d5a5dcf..0f7d80f3343 100644 --- a/mozilla/layout/generic/nsSpaceManager.h +++ b/mozilla/layout/generic/nsSpaceManager.h @@ -33,14 +33,20 @@ public: virtual nsIFrame* GetFrame() const; - virtual void Translate(nscoord aDx, nscoord aDy); - virtual void GetTranslation(nscoord& aX, nscoord& aY) const; + virtual void Translate(nscoord aDx, nscoord aDy); + virtual void GetTranslation(nscoord& aX, nscoord& aY) const; virtual nscoord YMost() const; + virtual PRInt32 GetBandData(nscoord aYOffset, const nsSize& aMaxSize, nsBandData& aBandData) const; - virtual void AddRectRegion(const nsRect& aUnavailableSpace, nsIFrame* aFrame); - virtual void ClearRegions(); + + virtual PRBool AddRectRegion(nsIFrame* aFrame, const nsRect& aUnavailableSpace); + virtual PRBool ReshapeRectRegion(nsIFrame* aFrame, const nsRect& aUnavailableSpace); + virtual PRBool OffsetRegion(nsIFrame* aFrame, nscoord dx, nscoord dy); + virtual PRBool RemoveRegion(nsIFrame* aFrame); + + virtual void ClearRegions(); protected: struct nsBandRect : nsRect { @@ -73,6 +79,7 @@ protected: nsIFrame* const mFrame; // frame associated with the space manager nscoord mX, mY; // translation from local to global coordinate space RectArray mRectArray; // y-x banded array of rectangles of unavailable space + RectArray mEmptyRects; // list of empty height rects protected: PRBool GetNextBand(nsBandRect*& aRect, PRInt32& aIndex) const;