Fix for bug #7397. Changed space manager to allows negative values

for rect regions
This commit is contained in:
troy%netscape.com 1999-06-24 02:04:50 +00:00
Родитель ec259e33cb
Коммит c36412d39d
5 изменённых файлов: 33 добавлений и 60 удалений

Просмотреть файл

@ -101,7 +101,10 @@ public:
NS_IMETHOD GetTranslation(nscoord& aX, nscoord& aY) const = 0;
/**
* Returns the y-most of the bottommost band, or 0 if there are no bands.
* Returns the y-most of the bottommost band or 0 if there are no bands.
*
* @return NS_OK if there are bands and NS_COMFALSE if there are
* no bands
*/
NS_IMETHOD YMost(nscoord& aYMost) const = 0;
@ -133,16 +136,12 @@ public:
* Add a rectangular region of unavailable space. The space is relative to
* the local coordinate system.
*
* The region is tagged with a frame. When translated to world coordinates
* the origin of the rect MUST be within the defined coordinate space, i.e.
* the x-offset and y-offset must be >= 0
* The region is tagged with a frame
*
* @param aFrame the frame used to identify the region. Must not be NULL
* @param aUnavailableSpace the bounding rect of the unavailable space
* @return NS_OK if successful
* NS_ERROR_FAILURE if there is already a region tagged with aFrame
* NS_ERROR_INVALID_ARG if the rect translated to world coordinates
* is not within the defined coordinate space
*/
NS_IMETHOD AddRectRegion(nsIFrame* aFrame,
const nsRect& aUnavailableSpace) = 0;
@ -153,8 +152,7 @@ public:
* rect. You specify whether the width change applies to the left or right edge
*
* Returns NS_OK if successful, NS_ERROR_INVALID_ARG if there is no region
* tagged with aFrame, and NS_ERROR_FAILURE if the new offset when translated
* to world coordinates is outside the defined coordinate space
* tagged with aFrame
*/
enum AffectedEdge {LeftEdge, RightEdge};
NS_IMETHOD ResizeRectRegion(nsIFrame* aFrame,
@ -166,8 +164,7 @@ public:
* Offset the region associated with aFrame by the specified amount.
*
* Returns NS_OK if successful, NS_ERROR_INVALID_ARG if there is no region
* tagged with aFrame, and NS_ERROR_FAILURE if the new offset when translated
* to world coordinates is outside the defined coordinate space
* tagged with aFrame
*/
NS_IMETHOD OffsetRegion(nsIFrame* aFrame, nscoord dx, nscoord dy) = 0;

Просмотреть файл

@ -43,8 +43,10 @@ NS_RemoveFrameInfoEntries(PLHashEntry* he, PRIntn i, void* arg)
/////////////////////////////////////////////////////////////////////////////
// BandList
#define NSCOORD_MIN (-2147483647 - 1) /* minimum signed value */
nsSpaceManager::BandList::BandList()
: nsSpaceManager::BandRect(-1, -1, -1, -1, (nsIFrame*)nsnull)
: nsSpaceManager::BandRect(NSCOORD_MIN, NSCOORD_MIN, NSCOORD_MIN, NSCOORD_MIN, (nsIFrame*)nsnull)
{
PR_INIT_CLIST(this);
numFrames = 0;
@ -122,15 +124,20 @@ nsSpaceManager::GetTranslation(nscoord& aX, nscoord& aY) const
NS_IMETHODIMP
nsSpaceManager::YMost(nscoord& aYMost) const
{
nsresult result;
if (mBandList.IsEmpty()) {
aYMost = 0;
result = NS_COMFALSE;
} else {
BandRect* lastRect = mBandList.Tail();
aYMost = lastRect->bottom;
result = NS_OK;
}
return NS_OK;
return result;
}
/**
@ -266,8 +273,8 @@ nsSpaceManager::GetBandData(nscoord aYOffset,
// If there are no unavailable rects or the offset is below the bottommost
// band, then all the space is available
nscoord yMost;
YMost(yMost);
if (y >= yMost) {
if ((NS_COMFALSE == YMost(yMost)) || (y >= yMost)) {
// All the requested space is available
aBandData.count = 1;
aBandData.trapezoids[0] = nsRect(0, aYOffset, aMaxSize.width, aMaxSize.height);
@ -618,8 +625,7 @@ nsSpaceManager::InsertBandRect(BandRect* aBandRect)
// If there are no existing bands or this rect is below the bottommost
// band, then add a new band
nscoord yMost;
YMost(yMost);
if (aBandRect->top >= yMost) {
if ((NS_COMFALSE == YMost(yMost)) || (aBandRect->top >= yMost)) {
mBandList.Append(aBandRect);
return;
}
@ -725,12 +731,6 @@ nsSpaceManager::AddRectRegion(nsIFrame* aFrame, const nsRect& aUnavailableSpace)
nsRect rect(aUnavailableSpace.x + mX, aUnavailableSpace.y + mY,
aUnavailableSpace.width, aUnavailableSpace.height);
// Verify that the offset is within the defined coordinate space
if ((rect.x < 0) || (rect.y < 0)) {
NS_WARNING("invalid offset for rect region");
return NS_ERROR_INVALID_ARG;
}
// Create a frame info structure
frameInfo = CreateFrameInfo(aFrame, rect);
if (nsnull == frameInfo) {
@ -775,12 +775,6 @@ nsSpaceManager::ResizeRectRegion(nsIFrame* aFrame,
rect.x += aDeltaWidth;
}
// Verify that the offset is within the defined coordinate space
if ((rect.x < 0) || (rect.y < 0)) {
NS_WARNING("invalid offset when resizing rect region");
return NS_ERROR_FAILURE;
}
// For the time being just remove it and add it back in. Because
// AddRectRegion() operates relative to the local coordinate space,
// translate from world coordinates to the local coordinate space
@ -804,12 +798,6 @@ nsSpaceManager::OffsetRegion(nsIFrame* aFrame, nscoord aDx, nscoord aDy)
nsRect rect(frameInfo->rect);
rect.MoveBy(aDx, aDy);
// Verify that the offset is within the defined coordinate space
if ((rect.x < 0) || (rect.y < 0)) {
NS_WARNING("invalid offset when offseting rect region");
return NS_ERROR_FAILURE;
}
// For the time being just remove it and add it back in. Because
// AddRectRegion() operates relative to the local coordinate space,
// translate from world coordinates to the local coordinate space

Просмотреть файл

@ -132,7 +132,7 @@ public:
protected:
nsIFrame* const mFrame; // frame associated with the space manager
nscoord mX, mY; // translation from local to global coordinate space
BandList mBandList; // header for circular linked list of band rects
BandList mBandList; // header/sentinel for circular linked list of band rects
PLHashTable* mFrameInfoMap;
protected:

Просмотреть файл

@ -43,8 +43,10 @@ NS_RemoveFrameInfoEntries(PLHashEntry* he, PRIntn i, void* arg)
/////////////////////////////////////////////////////////////////////////////
// BandList
#define NSCOORD_MIN (-2147483647 - 1) /* minimum signed value */
nsSpaceManager::BandList::BandList()
: nsSpaceManager::BandRect(-1, -1, -1, -1, (nsIFrame*)nsnull)
: nsSpaceManager::BandRect(NSCOORD_MIN, NSCOORD_MIN, NSCOORD_MIN, NSCOORD_MIN, (nsIFrame*)nsnull)
{
PR_INIT_CLIST(this);
numFrames = 0;
@ -122,15 +124,20 @@ nsSpaceManager::GetTranslation(nscoord& aX, nscoord& aY) const
NS_IMETHODIMP
nsSpaceManager::YMost(nscoord& aYMost) const
{
nsresult result;
if (mBandList.IsEmpty()) {
aYMost = 0;
result = NS_COMFALSE;
} else {
BandRect* lastRect = mBandList.Tail();
aYMost = lastRect->bottom;
result = NS_OK;
}
return NS_OK;
return result;
}
/**
@ -266,8 +273,8 @@ nsSpaceManager::GetBandData(nscoord aYOffset,
// If there are no unavailable rects or the offset is below the bottommost
// band, then all the space is available
nscoord yMost;
YMost(yMost);
if (y >= yMost) {
if ((NS_COMFALSE == YMost(yMost)) || (y >= yMost)) {
// All the requested space is available
aBandData.count = 1;
aBandData.trapezoids[0] = nsRect(0, aYOffset, aMaxSize.width, aMaxSize.height);
@ -618,8 +625,7 @@ nsSpaceManager::InsertBandRect(BandRect* aBandRect)
// If there are no existing bands or this rect is below the bottommost
// band, then add a new band
nscoord yMost;
YMost(yMost);
if (aBandRect->top >= yMost) {
if ((NS_COMFALSE == YMost(yMost)) || (aBandRect->top >= yMost)) {
mBandList.Append(aBandRect);
return;
}
@ -725,12 +731,6 @@ nsSpaceManager::AddRectRegion(nsIFrame* aFrame, const nsRect& aUnavailableSpace)
nsRect rect(aUnavailableSpace.x + mX, aUnavailableSpace.y + mY,
aUnavailableSpace.width, aUnavailableSpace.height);
// Verify that the offset is within the defined coordinate space
if ((rect.x < 0) || (rect.y < 0)) {
NS_WARNING("invalid offset for rect region");
return NS_ERROR_INVALID_ARG;
}
// Create a frame info structure
frameInfo = CreateFrameInfo(aFrame, rect);
if (nsnull == frameInfo) {
@ -775,12 +775,6 @@ nsSpaceManager::ResizeRectRegion(nsIFrame* aFrame,
rect.x += aDeltaWidth;
}
// Verify that the offset is within the defined coordinate space
if ((rect.x < 0) || (rect.y < 0)) {
NS_WARNING("invalid offset when resizing rect region");
return NS_ERROR_FAILURE;
}
// For the time being just remove it and add it back in. Because
// AddRectRegion() operates relative to the local coordinate space,
// translate from world coordinates to the local coordinate space
@ -804,12 +798,6 @@ nsSpaceManager::OffsetRegion(nsIFrame* aFrame, nscoord aDx, nscoord aDy)
nsRect rect(frameInfo->rect);
rect.MoveBy(aDx, aDy);
// Verify that the offset is within the defined coordinate space
if ((rect.x < 0) || (rect.y < 0)) {
NS_WARNING("invalid offset when offseting rect region");
return NS_ERROR_FAILURE;
}
// For the time being just remove it and add it back in. Because
// AddRectRegion() operates relative to the local coordinate space,
// translate from world coordinates to the local coordinate space

Просмотреть файл

@ -132,7 +132,7 @@ public:
protected:
nsIFrame* const mFrame; // frame associated with the space manager
nscoord mX, mY; // translation from local to global coordinate space
BandList mBandList; // header for circular linked list of band rects
BandList mBandList; // header/sentinel for circular linked list of band rects
PLHashTable* mFrameInfoMap;
protected: