Changed the space manager interface to return trapezoids instead
of rects git-svn-id: svn://10.0.0.236/trunk@418 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -20,10 +20,10 @@
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "nsCoord.h"
|
||||
#include "nsRect.h"
|
||||
|
||||
class nsIFrame;
|
||||
struct nsPoint;
|
||||
struct nsRect;
|
||||
class nsVoidArray;
|
||||
struct nsSize;
|
||||
|
||||
// IID for the nsISpaceManager interface {17C8FB50-BE96-11d1-80B5-00805F8A274D}
|
||||
@@ -32,13 +32,41 @@ struct nsSize;
|
||||
{0x80, 0xb5, 0x0, 0x80, 0x5f, 0x8a, 0x27, 0x4d}}
|
||||
|
||||
/**
|
||||
* Structure used for returning the available space in a band.
|
||||
* Information about a particular trapezoid within a band. The space described
|
||||
* by the trapezoid is in one of three states:
|
||||
* <ul>
|
||||
* <li>available
|
||||
* <li>occupied by one frame
|
||||
* <li>occupied by more than one frame
|
||||
* </ul>
|
||||
*/
|
||||
struct nsBandTrapezoid {
|
||||
enum State {smAvailable, smOccupied, smOccupiedMultiple};
|
||||
|
||||
nscoord yTop, yBottom; // horizontal top and bottom coordinates
|
||||
nscoord xTopLeft, xBottomLeft;
|
||||
nscoord xTopRight, xBottomRight;
|
||||
State state; // state of the space
|
||||
union {
|
||||
nsIFrame* frame; // frame occupying the space
|
||||
const nsVoidArray* frames; // list of frames occupying the space
|
||||
};
|
||||
|
||||
// Get the height of the trapezoid
|
||||
nscoord GetHeight() {return yBottom - yTop;}
|
||||
|
||||
// Get the bouding rect of the trapezoid
|
||||
void GetRect(nsRect& aRect);
|
||||
};
|
||||
|
||||
/**
|
||||
* Structure used for describing the space within a band.
|
||||
* @see #GetBandData()
|
||||
*/
|
||||
struct nsBandData {
|
||||
PRInt32 count; // 'out' parameter. Actual number of rects in the band data
|
||||
PRInt32 size; // 'in' parameter. The size of the array
|
||||
nsRect* rects; // 'out' parameter. Array of length 'size'
|
||||
PRInt32 count; // 'out' parameter. Actual number of trapezoids in the band data
|
||||
PRInt32 size; // 'in' parameter. The size of the array
|
||||
nsBandTrapezoid* trapezoids; // 'out' parameter. Array of length 'size'
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -108,4 +136,12 @@ public:
|
||||
virtual void ClearRegions() = 0;
|
||||
};
|
||||
|
||||
void inline nsBandTrapezoid::GetRect(nsRect& aRect)
|
||||
{
|
||||
aRect.x = PR_MIN(xTopLeft, xBottomLeft);
|
||||
aRect.y = yTop;
|
||||
aRect.width = PR_MAX(xTopRight, xBottomRight) - aRect.x;
|
||||
aRect.height = yBottom - yTop;
|
||||
}
|
||||
|
||||
#endif /* nsISpaceManager_h___ */
|
||||
|
||||
@@ -450,25 +450,30 @@ nsContainerFrame::ReflowChild(nsIFrame* aKidFrame,
|
||||
// XXX In order to do this efficiently we should move all this code to
|
||||
// nsBlockFrame since it already has band data, and it's probably the only
|
||||
// one who calls this routine anyway
|
||||
nsBandData bandData;
|
||||
nsRect rects[7];
|
||||
nsRect* availRect = rects;
|
||||
nsSize availSize = aMaxSize;
|
||||
nsBandData bandData;
|
||||
nsBandTrapezoid trapezoids[7];
|
||||
nsBandTrapezoid* availSpace = trapezoids;
|
||||
nsSize availSize = aMaxSize;
|
||||
|
||||
bandData.rects = rects;
|
||||
bandData.trapezoids = trapezoids;
|
||||
bandData.size = 7;
|
||||
aSpaceManager->GetBandData(0, aMaxSize, bandData);
|
||||
|
||||
// If there's more than one rect than figure out which one determines the
|
||||
// If there's more than one trapezoid then figure out which one determines the
|
||||
// available reflow area
|
||||
if (bandData.count == 2) {
|
||||
nsRect r0, r1;
|
||||
|
||||
trapezoids[0].GetRect(r0);
|
||||
trapezoids[1].GetRect(r1);
|
||||
|
||||
// Either a left or right floater. Use whichever space is larger
|
||||
if (rects[1].width > rects[0].width) {
|
||||
availRect = &rects[1];
|
||||
if (r1.width > r0.width) {
|
||||
availSpace = &trapezoids[1];
|
||||
}
|
||||
} else if (bandData.count == 3) {
|
||||
// Assume there are floaters on the left and right, and use the middle rect
|
||||
availRect = &rects[1];
|
||||
availSpace = &trapezoids[1];
|
||||
}
|
||||
|
||||
// Does the child frame want to do continuation-based runaround?
|
||||
@@ -477,13 +482,17 @@ nsContainerFrame::ReflowChild(nsIFrame* aKidFrame,
|
||||
aKidFrame->IsSplittable(isSplittable);
|
||||
if (isSplittable == frSplittableNonRectangular) {
|
||||
// Reduce the max height to the band height.
|
||||
availSize.height = availRect->height;
|
||||
availSize.height = availSpace->yBottom - availSpace->yTop;
|
||||
}
|
||||
|
||||
// Get the bounding rect of the available trapezoid
|
||||
nsRect rect;
|
||||
|
||||
availSpace->GetRect(rect);
|
||||
if (aMaxSize.width != NS_UNCONSTRAINEDSIZE) {
|
||||
if ((availRect->x > 0) || (availRect->XMost() < aMaxSize.width)) {
|
||||
if ((rect.x > 0) || (rect.XMost() < aMaxSize.width)) {
|
||||
// There are left/right floaters.
|
||||
availSize.width = availRect->width;
|
||||
availSize.width = rect.width;
|
||||
}
|
||||
|
||||
// Reduce the available width by the kid's left/right margin
|
||||
@@ -493,7 +502,7 @@ nsContainerFrame::ReflowChild(nsIFrame* aKidFrame,
|
||||
// Does the child frame support interface nsIRunaround?
|
||||
if (NS_OK == aKidFrame->QueryInterface(kIRunaroundIID, (void**)&reflowRunaround)) {
|
||||
// Yes, the child frame wants to interact directly with the space manager.
|
||||
nscoord tx = availRect->x + aKidMol->margin.left;
|
||||
nscoord tx = rect.x + aKidMol->margin.left;
|
||||
|
||||
// Translate the local coordinate space to the current left edge plus any
|
||||
// left margin the child wants
|
||||
@@ -501,7 +510,7 @@ nsContainerFrame::ReflowChild(nsIFrame* aKidFrame,
|
||||
|
||||
reflowRunaround->ResizeReflow(aPresContext, aSpaceManager, availSize,
|
||||
aDesiredRect, aMaxElementSize, status);
|
||||
aDesiredRect.x += availRect->x;
|
||||
aDesiredRect.x += rect.x;
|
||||
|
||||
// Translate back
|
||||
aSpaceManager->Translate(-tx, 0);
|
||||
@@ -514,7 +523,7 @@ nsContainerFrame::ReflowChild(nsIFrame* aKidFrame,
|
||||
aMaxElementSize, status);
|
||||
|
||||
// Return the desired rect
|
||||
aDesiredRect.x = availRect->x;
|
||||
aDesiredRect.x = rect.x;
|
||||
aDesiredRect.y = 0;
|
||||
aDesiredRect.width = desiredSize.width;
|
||||
aDesiredRect.height = desiredSize.height;
|
||||
|
||||
@@ -76,15 +76,15 @@ PRInt32 SpaceManager::GetBandAvailableSpace(const nsRect* aBand,
|
||||
const nsSize& aMaxSize,
|
||||
nsBandData& aAvailableSpace) const
|
||||
{
|
||||
PRInt32 numRects = LengthOfBand(aBand, aIndex);
|
||||
nscoord localY = aY - mY;
|
||||
nscoord height = PR_MIN(aBand->YMost() - aY, aMaxSize.height);
|
||||
nsRect* rect = aAvailableSpace.rects;
|
||||
nscoord rightEdge = mX + aMaxSize.width;
|
||||
PRInt32 numRects = LengthOfBand(aBand, aIndex);
|
||||
nscoord localY = aY - mY;
|
||||
nscoord height = PR_MIN(aBand->YMost() - aY, aMaxSize.height);
|
||||
nsBandTrapezoid* trapezoid = aAvailableSpace.trapezoids;
|
||||
nscoord rightEdge = mX + aMaxSize.width;
|
||||
|
||||
// Initialize the band data
|
||||
aAvailableSpace.count = 0;
|
||||
rect->x = mX;
|
||||
trapezoid->xTopLeft = mX;
|
||||
|
||||
// Skip any rectangles that are to the left of the local coordinate space
|
||||
while (numRects > 0) {
|
||||
@@ -99,32 +99,49 @@ PRInt32 SpaceManager::GetBandAvailableSpace(const nsRect* aBand,
|
||||
|
||||
// Process all the remaining rectangles that are within the clip width
|
||||
while ((numRects > 0) && (aBand->x < rightEdge)) {
|
||||
if (aBand->x > rect->x) {
|
||||
if (aBand->x > trapezoid->xTopLeft) {
|
||||
// We found some available space
|
||||
rect->width = aBand->x - rect->x;
|
||||
rect->x -= mX; // convert from world to local coordinates
|
||||
rect->y = localY;
|
||||
rect->height = height;
|
||||
trapezoid->xTopRight = trapezoid->xBottomRight = aBand->x;
|
||||
|
||||
// Convert from world to local coordinates
|
||||
trapezoid->xTopLeft -= mX;
|
||||
trapezoid->xTopRight -= mX;
|
||||
trapezoid->xBottomLeft = trapezoid->xTopLeft;
|
||||
trapezoid->xBottomRight = trapezoid->xTopRight;
|
||||
|
||||
trapezoid->yTop = localY;
|
||||
trapezoid->yBottom = localY + height;
|
||||
trapezoid->state = nsBandTrapezoid::smAvailable;
|
||||
trapezoid->frame = nsnull;
|
||||
|
||||
// Move to the next output rect
|
||||
rect++;
|
||||
trapezoid++;
|
||||
aAvailableSpace.count++;
|
||||
}
|
||||
|
||||
rect->x = aBand->XMost();
|
||||
trapezoid->xTopLeft = aBand->XMost();
|
||||
|
||||
// Move to the next rect in the band
|
||||
numRects--;
|
||||
aBand++;
|
||||
}
|
||||
|
||||
// No more rects left in the band. If we haven't yet reached the right edge
|
||||
// No more rects left in the band. If we haven't yet reached the right edge,
|
||||
// then all the remaining space is available
|
||||
if (rect->x < rightEdge) {
|
||||
rect->width = rightEdge - rect->x;
|
||||
rect->x -= mX; // convert from world to local coordinates
|
||||
rect->y = localY;
|
||||
rect->height = height;
|
||||
if (trapezoid->xTopLeft < rightEdge) {
|
||||
trapezoid->xTopRight = rightEdge;
|
||||
|
||||
// Convert from world to local coordinates
|
||||
trapezoid->xTopLeft -= mX;
|
||||
trapezoid->xTopRight -= mX;
|
||||
trapezoid->xBottomLeft = trapezoid->xTopLeft;
|
||||
trapezoid->xBottomRight = trapezoid->xTopRight;
|
||||
|
||||
trapezoid->yTop = localY;
|
||||
trapezoid->yBottom = localY + height;
|
||||
trapezoid->state = nsBandTrapezoid::smAvailable;
|
||||
trapezoid->frame = nsnull;
|
||||
|
||||
aAvailableSpace.count++;
|
||||
}
|
||||
|
||||
@@ -142,10 +159,15 @@ PRInt32 SpaceManager::GetBandData(nscoord aYOffset,
|
||||
// band then all the space is available
|
||||
if ((0 == mRectArray.mCount) || (y >= mRectArray.YMost())) {
|
||||
aAvailableSpace.count = 1;
|
||||
aAvailableSpace.rects[0].x = 0;
|
||||
aAvailableSpace.rects[0].y = aYOffset;
|
||||
aAvailableSpace.rects[0].width = aMaxSize.width;
|
||||
aAvailableSpace.rects[0].height = aMaxSize.height;
|
||||
|
||||
nsBandTrapezoid& trapezoid = aAvailableSpace.trapezoids[0];
|
||||
|
||||
trapezoid.xTopLeft = trapezoid.xBottomLeft = 0;
|
||||
trapezoid.yTop = aYOffset;
|
||||
trapezoid.xTopRight = trapezoid.xBottomRight = aMaxSize.width;
|
||||
trapezoid.yBottom = aYOffset + aMaxSize.height;
|
||||
trapezoid.state = nsBandTrapezoid::smAvailable;
|
||||
trapezoid.frame = nsnull;
|
||||
} else {
|
||||
// Find the first band that contains the y-offset or is below the y-offset
|
||||
nsRect* band = mRectArray.mRects;
|
||||
@@ -153,11 +175,14 @@ PRInt32 SpaceManager::GetBandData(nscoord aYOffset,
|
||||
for (PRInt32 i = 0; i < mRectArray.mCount; ) {
|
||||
if (band->y > y) {
|
||||
// The band is below the y-offset
|
||||
aAvailableSpace.count = 1;
|
||||
aAvailableSpace.rects[0].x = 0;
|
||||
aAvailableSpace.rects[0].y = aYOffset;
|
||||
aAvailableSpace.rects[0].width = aMaxSize.width;
|
||||
aAvailableSpace.rects[0].height = PR_MIN(band->y - y, aMaxSize.height);
|
||||
nsBandTrapezoid& trapezoid = aAvailableSpace.trapezoids[0];
|
||||
|
||||
trapezoid.xTopLeft = trapezoid.xBottomLeft = 0;
|
||||
trapezoid.yTop = aYOffset;
|
||||
trapezoid.xTopRight = trapezoid.xBottomRight = aMaxSize.width;
|
||||
trapezoid.yBottom = aYOffset + PR_MIN(band->y - y, aMaxSize.height);
|
||||
trapezoid.state = nsBandTrapezoid::smAvailable;
|
||||
trapezoid.frame = nsnull;
|
||||
break;
|
||||
} else if (y < band->YMost()) {
|
||||
// The band contains the y-offset
|
||||
|
||||
@@ -50,9 +50,9 @@ static NS_DEFINE_IID(kStyleMoleculeSID, NS_STYLEMOLECULE_SID);
|
||||
static NS_DEFINE_IID(kStyleFontSID, NS_STYLEFONT_SID);
|
||||
|
||||
struct BlockBandData : public nsBandData {
|
||||
nsRect data[5];
|
||||
nsBandTrapezoid data[5];
|
||||
|
||||
BlockBandData() {size = 5; rects = data;}
|
||||
BlockBandData() {size = 5; trapezoids = data;}
|
||||
};
|
||||
|
||||
// XXX Bugs
|
||||
@@ -352,13 +352,13 @@ void nsBlockFrame::PlaceBelowCurrentLineFloaters(nsIPresContext* aCX,
|
||||
NS_RELEASE(styleContext);
|
||||
|
||||
floater->GetRect(region);
|
||||
region.y = mCurrentState->currentBand->rects[0].y;
|
||||
region.y = mCurrentState->currentBand->trapezoids[0].yTop;
|
||||
|
||||
if (NS_STYLE_FLOAT_LEFT == mol->floats) {
|
||||
region.x = mCurrentState->currentBand->rects[0].x;
|
||||
region.x = mCurrentState->currentBand->trapezoids[0].xTopLeft;
|
||||
} else {
|
||||
NS_ASSERTION(NS_STYLE_FLOAT_RIGHT == mol->floats, "bad float type");
|
||||
region.x = mCurrentState->currentBand->rects[0].XMost() - region.width;
|
||||
region.x = mCurrentState->currentBand->trapezoids[0].xTopRight - region.width;
|
||||
}
|
||||
|
||||
// XXX Don't forget the floater's margins...
|
||||
@@ -655,9 +655,9 @@ void nsBlockFrame::GetAvailSize(nsSize& aResult,
|
||||
aResult.width = NS_UNCONSTRAINEDSIZE;
|
||||
} else if (aIsInline) {
|
||||
if (NS_STYLE_DIRECTION_LTR == aState.mol->direction) {
|
||||
aResult.width = aState.currentBand->rects[0].XMost() - aState.x;
|
||||
aResult.width = aState.currentBand->trapezoids[0].xTopRight - aState.x;
|
||||
} else {
|
||||
aResult.width = aState.x - aState.currentBand->rects[0].x;
|
||||
aResult.width = aState.x - aState.currentBand->trapezoids[0].xTopLeft;
|
||||
}
|
||||
} else {
|
||||
// It's a block. Don't adjust for the left/right margin here. That happens
|
||||
@@ -750,17 +750,21 @@ void nsBlockFrame::GetAvailableSpaceBand(nsBlockReflowState& aState, nscoord aY)
|
||||
// If there are three rects then let's assume that there are floaters on the
|
||||
// left and right and that only the middle rect is available
|
||||
if (aState.currentBand->count == 3) {
|
||||
aState.currentBand->rects[0] = aState.currentBand->rects[1];
|
||||
aState.currentBand->trapezoids[0] = aState.currentBand->trapezoids[1];
|
||||
} else {
|
||||
nsRect r0, r1;
|
||||
|
||||
// There are two rects. That means either a left or right floater. Just use
|
||||
// whichever space is larger.
|
||||
if (aState.currentBand->rects[1].width > aState.currentBand->rects[0].width) {
|
||||
aState.currentBand->rects[0] = aState.currentBand->rects[1];
|
||||
aState.currentBand->trapezoids[0].GetRect(r0);
|
||||
aState.currentBand->trapezoids[1].GetRect(r1);
|
||||
if (r1.width > r0.width) {
|
||||
aState.currentBand->trapezoids[0] = aState.currentBand->trapezoids[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
aState.spaceManager->Translate(-aState.borderPadding.left, 0);
|
||||
aState.x = aState.currentBand->rects[0].x;
|
||||
aState.x = aState.currentBand->trapezoids[0].xTopLeft;
|
||||
}
|
||||
|
||||
void nsBlockFrame::ClearFloaters(nsBlockReflowState& aState, PRUint32 aClear)
|
||||
@@ -777,24 +781,31 @@ getBand:
|
||||
aState.spaceManager->GetBandData(y, aState.availSize, *aState.currentBand);
|
||||
|
||||
if (aState.currentBand->count == 1) {
|
||||
if (aState.currentBand->rects[0].width != aState.availSize.width) {
|
||||
nsRect rect;
|
||||
|
||||
aState.currentBand->trapezoids[0].GetRect(rect);
|
||||
if (rect.width != aState.availSize.width) {
|
||||
// Some of the space is taken up by floaters
|
||||
if (aState.currentBand->rects[0].x > 0) {
|
||||
if (rect.x > 0) {
|
||||
isLeftFloater = PR_TRUE;
|
||||
}
|
||||
|
||||
if (aState.currentBand->rects[0].XMost() < aState.availSize.width) {
|
||||
if (rect.XMost() < aState.availSize.width) {
|
||||
isRightFloater = PR_TRUE;
|
||||
}
|
||||
}
|
||||
} else if (aState.currentBand->count == 2) {
|
||||
if (aState.currentBand->rects[0].width > aState.currentBand->rects[1].width) {
|
||||
nsRect r0, r1;
|
||||
|
||||
aState.currentBand->trapezoids[0].GetRect(r0);
|
||||
aState.currentBand->trapezoids[1].GetRect(r1);
|
||||
if (r0.width > r1.width) {
|
||||
isRightFloater = PR_TRUE;
|
||||
} else {
|
||||
isLeftFloater = PR_TRUE;
|
||||
|
||||
// There may also be a right floater
|
||||
if (aState.currentBand->rects[1].XMost() < aState.availSize.width) {
|
||||
if (r1.XMost() < aState.availSize.width) {
|
||||
isRightFloater = PR_TRUE;
|
||||
}
|
||||
}
|
||||
@@ -806,13 +817,13 @@ getBand:
|
||||
|
||||
if (isLeftFloater) {
|
||||
if ((aClear == NS_STYLE_CLEAR_LEFT) || (aClear == NS_STYLE_CLEAR_BOTH)) {
|
||||
aState.y += aState.currentBand->rects[0].height;
|
||||
aState.y += aState.currentBand->trapezoids[0].GetHeight();
|
||||
goto getBand;
|
||||
}
|
||||
}
|
||||
if (isRightFloater) {
|
||||
if ((aClear == NS_STYLE_CLEAR_RIGHT) || (aClear == NS_STYLE_CLEAR_BOTH)) {
|
||||
aState.y += aState.currentBand->rects[0].height;
|
||||
aState.y += aState.currentBand->trapezoids[0].GetHeight();
|
||||
goto getBand;
|
||||
}
|
||||
}
|
||||
@@ -1954,13 +1965,13 @@ void nsBlockFrame::PlaceFloater(nsIPresContext* aCX,
|
||||
nsRect region;
|
||||
|
||||
aFloater->GetRect(region);
|
||||
region.y = mCurrentState->currentBand->rects[0].y;
|
||||
region.y = mCurrentState->currentBand->trapezoids[0].yTop;
|
||||
|
||||
if (NS_STYLE_FLOAT_LEFT == mol->floats) {
|
||||
region.x = mCurrentState->currentBand->rects[0].x;
|
||||
region.x = mCurrentState->currentBand->trapezoids[0].xTopLeft;
|
||||
} else {
|
||||
NS_ASSERTION(NS_STYLE_FLOAT_RIGHT == mol->floats, "bad float type");
|
||||
region.x = mCurrentState->currentBand->rects[0].XMost() - region.width;
|
||||
region.x = mCurrentState->currentBand->trapezoids[0].xTopRight - region.width;
|
||||
}
|
||||
|
||||
// XXX Don't forget the floater's margins...
|
||||
|
||||
@@ -50,9 +50,9 @@ static NS_DEFINE_IID(kStyleMoleculeSID, NS_STYLEMOLECULE_SID);
|
||||
static NS_DEFINE_IID(kStyleFontSID, NS_STYLEFONT_SID);
|
||||
|
||||
struct BlockBandData : public nsBandData {
|
||||
nsRect data[5];
|
||||
nsBandTrapezoid data[5];
|
||||
|
||||
BlockBandData() {size = 5; rects = data;}
|
||||
BlockBandData() {size = 5; trapezoids = data;}
|
||||
};
|
||||
|
||||
// XXX Bugs
|
||||
@@ -352,13 +352,13 @@ void nsBlockFrame::PlaceBelowCurrentLineFloaters(nsIPresContext* aCX,
|
||||
NS_RELEASE(styleContext);
|
||||
|
||||
floater->GetRect(region);
|
||||
region.y = mCurrentState->currentBand->rects[0].y;
|
||||
region.y = mCurrentState->currentBand->trapezoids[0].yTop;
|
||||
|
||||
if (NS_STYLE_FLOAT_LEFT == mol->floats) {
|
||||
region.x = mCurrentState->currentBand->rects[0].x;
|
||||
region.x = mCurrentState->currentBand->trapezoids[0].xTopLeft;
|
||||
} else {
|
||||
NS_ASSERTION(NS_STYLE_FLOAT_RIGHT == mol->floats, "bad float type");
|
||||
region.x = mCurrentState->currentBand->rects[0].XMost() - region.width;
|
||||
region.x = mCurrentState->currentBand->trapezoids[0].xTopRight - region.width;
|
||||
}
|
||||
|
||||
// XXX Don't forget the floater's margins...
|
||||
@@ -655,9 +655,9 @@ void nsBlockFrame::GetAvailSize(nsSize& aResult,
|
||||
aResult.width = NS_UNCONSTRAINEDSIZE;
|
||||
} else if (aIsInline) {
|
||||
if (NS_STYLE_DIRECTION_LTR == aState.mol->direction) {
|
||||
aResult.width = aState.currentBand->rects[0].XMost() - aState.x;
|
||||
aResult.width = aState.currentBand->trapezoids[0].xTopRight - aState.x;
|
||||
} else {
|
||||
aResult.width = aState.x - aState.currentBand->rects[0].x;
|
||||
aResult.width = aState.x - aState.currentBand->trapezoids[0].xTopLeft;
|
||||
}
|
||||
} else {
|
||||
// It's a block. Don't adjust for the left/right margin here. That happens
|
||||
@@ -750,17 +750,21 @@ void nsBlockFrame::GetAvailableSpaceBand(nsBlockReflowState& aState, nscoord aY)
|
||||
// If there are three rects then let's assume that there are floaters on the
|
||||
// left and right and that only the middle rect is available
|
||||
if (aState.currentBand->count == 3) {
|
||||
aState.currentBand->rects[0] = aState.currentBand->rects[1];
|
||||
aState.currentBand->trapezoids[0] = aState.currentBand->trapezoids[1];
|
||||
} else {
|
||||
nsRect r0, r1;
|
||||
|
||||
// There are two rects. That means either a left or right floater. Just use
|
||||
// whichever space is larger.
|
||||
if (aState.currentBand->rects[1].width > aState.currentBand->rects[0].width) {
|
||||
aState.currentBand->rects[0] = aState.currentBand->rects[1];
|
||||
aState.currentBand->trapezoids[0].GetRect(r0);
|
||||
aState.currentBand->trapezoids[1].GetRect(r1);
|
||||
if (r1.width > r0.width) {
|
||||
aState.currentBand->trapezoids[0] = aState.currentBand->trapezoids[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
aState.spaceManager->Translate(-aState.borderPadding.left, 0);
|
||||
aState.x = aState.currentBand->rects[0].x;
|
||||
aState.x = aState.currentBand->trapezoids[0].xTopLeft;
|
||||
}
|
||||
|
||||
void nsBlockFrame::ClearFloaters(nsBlockReflowState& aState, PRUint32 aClear)
|
||||
@@ -777,24 +781,31 @@ getBand:
|
||||
aState.spaceManager->GetBandData(y, aState.availSize, *aState.currentBand);
|
||||
|
||||
if (aState.currentBand->count == 1) {
|
||||
if (aState.currentBand->rects[0].width != aState.availSize.width) {
|
||||
nsRect rect;
|
||||
|
||||
aState.currentBand->trapezoids[0].GetRect(rect);
|
||||
if (rect.width != aState.availSize.width) {
|
||||
// Some of the space is taken up by floaters
|
||||
if (aState.currentBand->rects[0].x > 0) {
|
||||
if (rect.x > 0) {
|
||||
isLeftFloater = PR_TRUE;
|
||||
}
|
||||
|
||||
if (aState.currentBand->rects[0].XMost() < aState.availSize.width) {
|
||||
if (rect.XMost() < aState.availSize.width) {
|
||||
isRightFloater = PR_TRUE;
|
||||
}
|
||||
}
|
||||
} else if (aState.currentBand->count == 2) {
|
||||
if (aState.currentBand->rects[0].width > aState.currentBand->rects[1].width) {
|
||||
nsRect r0, r1;
|
||||
|
||||
aState.currentBand->trapezoids[0].GetRect(r0);
|
||||
aState.currentBand->trapezoids[1].GetRect(r1);
|
||||
if (r0.width > r1.width) {
|
||||
isRightFloater = PR_TRUE;
|
||||
} else {
|
||||
isLeftFloater = PR_TRUE;
|
||||
|
||||
// There may also be a right floater
|
||||
if (aState.currentBand->rects[1].XMost() < aState.availSize.width) {
|
||||
if (r1.XMost() < aState.availSize.width) {
|
||||
isRightFloater = PR_TRUE;
|
||||
}
|
||||
}
|
||||
@@ -806,13 +817,13 @@ getBand:
|
||||
|
||||
if (isLeftFloater) {
|
||||
if ((aClear == NS_STYLE_CLEAR_LEFT) || (aClear == NS_STYLE_CLEAR_BOTH)) {
|
||||
aState.y += aState.currentBand->rects[0].height;
|
||||
aState.y += aState.currentBand->trapezoids[0].GetHeight();
|
||||
goto getBand;
|
||||
}
|
||||
}
|
||||
if (isRightFloater) {
|
||||
if ((aClear == NS_STYLE_CLEAR_RIGHT) || (aClear == NS_STYLE_CLEAR_BOTH)) {
|
||||
aState.y += aState.currentBand->rects[0].height;
|
||||
aState.y += aState.currentBand->trapezoids[0].GetHeight();
|
||||
goto getBand;
|
||||
}
|
||||
}
|
||||
@@ -1954,13 +1965,13 @@ void nsBlockFrame::PlaceFloater(nsIPresContext* aCX,
|
||||
nsRect region;
|
||||
|
||||
aFloater->GetRect(region);
|
||||
region.y = mCurrentState->currentBand->rects[0].y;
|
||||
region.y = mCurrentState->currentBand->trapezoids[0].yTop;
|
||||
|
||||
if (NS_STYLE_FLOAT_LEFT == mol->floats) {
|
||||
region.x = mCurrentState->currentBand->rects[0].x;
|
||||
region.x = mCurrentState->currentBand->trapezoids[0].xTopLeft;
|
||||
} else {
|
||||
NS_ASSERTION(NS_STYLE_FLOAT_RIGHT == mol->floats, "bad float type");
|
||||
region.x = mCurrentState->currentBand->rects[0].XMost() - region.width;
|
||||
region.x = mCurrentState->currentBand->trapezoids[0].xTopRight - region.width;
|
||||
}
|
||||
|
||||
// XXX Don't forget the floater's margins...
|
||||
|
||||
@@ -50,9 +50,9 @@ static NS_DEFINE_IID(kStyleMoleculeSID, NS_STYLEMOLECULE_SID);
|
||||
static NS_DEFINE_IID(kStyleFontSID, NS_STYLEFONT_SID);
|
||||
|
||||
struct BlockBandData : public nsBandData {
|
||||
nsRect data[5];
|
||||
nsBandTrapezoid data[5];
|
||||
|
||||
BlockBandData() {size = 5; rects = data;}
|
||||
BlockBandData() {size = 5; trapezoids = data;}
|
||||
};
|
||||
|
||||
// XXX Bugs
|
||||
@@ -352,13 +352,13 @@ void nsBlockFrame::PlaceBelowCurrentLineFloaters(nsIPresContext* aCX,
|
||||
NS_RELEASE(styleContext);
|
||||
|
||||
floater->GetRect(region);
|
||||
region.y = mCurrentState->currentBand->rects[0].y;
|
||||
region.y = mCurrentState->currentBand->trapezoids[0].yTop;
|
||||
|
||||
if (NS_STYLE_FLOAT_LEFT == mol->floats) {
|
||||
region.x = mCurrentState->currentBand->rects[0].x;
|
||||
region.x = mCurrentState->currentBand->trapezoids[0].xTopLeft;
|
||||
} else {
|
||||
NS_ASSERTION(NS_STYLE_FLOAT_RIGHT == mol->floats, "bad float type");
|
||||
region.x = mCurrentState->currentBand->rects[0].XMost() - region.width;
|
||||
region.x = mCurrentState->currentBand->trapezoids[0].xTopRight - region.width;
|
||||
}
|
||||
|
||||
// XXX Don't forget the floater's margins...
|
||||
@@ -655,9 +655,9 @@ void nsBlockFrame::GetAvailSize(nsSize& aResult,
|
||||
aResult.width = NS_UNCONSTRAINEDSIZE;
|
||||
} else if (aIsInline) {
|
||||
if (NS_STYLE_DIRECTION_LTR == aState.mol->direction) {
|
||||
aResult.width = aState.currentBand->rects[0].XMost() - aState.x;
|
||||
aResult.width = aState.currentBand->trapezoids[0].xTopRight - aState.x;
|
||||
} else {
|
||||
aResult.width = aState.x - aState.currentBand->rects[0].x;
|
||||
aResult.width = aState.x - aState.currentBand->trapezoids[0].xTopLeft;
|
||||
}
|
||||
} else {
|
||||
// It's a block. Don't adjust for the left/right margin here. That happens
|
||||
@@ -750,17 +750,21 @@ void nsBlockFrame::GetAvailableSpaceBand(nsBlockReflowState& aState, nscoord aY)
|
||||
// If there are three rects then let's assume that there are floaters on the
|
||||
// left and right and that only the middle rect is available
|
||||
if (aState.currentBand->count == 3) {
|
||||
aState.currentBand->rects[0] = aState.currentBand->rects[1];
|
||||
aState.currentBand->trapezoids[0] = aState.currentBand->trapezoids[1];
|
||||
} else {
|
||||
nsRect r0, r1;
|
||||
|
||||
// There are two rects. That means either a left or right floater. Just use
|
||||
// whichever space is larger.
|
||||
if (aState.currentBand->rects[1].width > aState.currentBand->rects[0].width) {
|
||||
aState.currentBand->rects[0] = aState.currentBand->rects[1];
|
||||
aState.currentBand->trapezoids[0].GetRect(r0);
|
||||
aState.currentBand->trapezoids[1].GetRect(r1);
|
||||
if (r1.width > r0.width) {
|
||||
aState.currentBand->trapezoids[0] = aState.currentBand->trapezoids[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
aState.spaceManager->Translate(-aState.borderPadding.left, 0);
|
||||
aState.x = aState.currentBand->rects[0].x;
|
||||
aState.x = aState.currentBand->trapezoids[0].xTopLeft;
|
||||
}
|
||||
|
||||
void nsBlockFrame::ClearFloaters(nsBlockReflowState& aState, PRUint32 aClear)
|
||||
@@ -777,24 +781,31 @@ getBand:
|
||||
aState.spaceManager->GetBandData(y, aState.availSize, *aState.currentBand);
|
||||
|
||||
if (aState.currentBand->count == 1) {
|
||||
if (aState.currentBand->rects[0].width != aState.availSize.width) {
|
||||
nsRect rect;
|
||||
|
||||
aState.currentBand->trapezoids[0].GetRect(rect);
|
||||
if (rect.width != aState.availSize.width) {
|
||||
// Some of the space is taken up by floaters
|
||||
if (aState.currentBand->rects[0].x > 0) {
|
||||
if (rect.x > 0) {
|
||||
isLeftFloater = PR_TRUE;
|
||||
}
|
||||
|
||||
if (aState.currentBand->rects[0].XMost() < aState.availSize.width) {
|
||||
if (rect.XMost() < aState.availSize.width) {
|
||||
isRightFloater = PR_TRUE;
|
||||
}
|
||||
}
|
||||
} else if (aState.currentBand->count == 2) {
|
||||
if (aState.currentBand->rects[0].width > aState.currentBand->rects[1].width) {
|
||||
nsRect r0, r1;
|
||||
|
||||
aState.currentBand->trapezoids[0].GetRect(r0);
|
||||
aState.currentBand->trapezoids[1].GetRect(r1);
|
||||
if (r0.width > r1.width) {
|
||||
isRightFloater = PR_TRUE;
|
||||
} else {
|
||||
isLeftFloater = PR_TRUE;
|
||||
|
||||
// There may also be a right floater
|
||||
if (aState.currentBand->rects[1].XMost() < aState.availSize.width) {
|
||||
if (r1.XMost() < aState.availSize.width) {
|
||||
isRightFloater = PR_TRUE;
|
||||
}
|
||||
}
|
||||
@@ -806,13 +817,13 @@ getBand:
|
||||
|
||||
if (isLeftFloater) {
|
||||
if ((aClear == NS_STYLE_CLEAR_LEFT) || (aClear == NS_STYLE_CLEAR_BOTH)) {
|
||||
aState.y += aState.currentBand->rects[0].height;
|
||||
aState.y += aState.currentBand->trapezoids[0].GetHeight();
|
||||
goto getBand;
|
||||
}
|
||||
}
|
||||
if (isRightFloater) {
|
||||
if ((aClear == NS_STYLE_CLEAR_RIGHT) || (aClear == NS_STYLE_CLEAR_BOTH)) {
|
||||
aState.y += aState.currentBand->rects[0].height;
|
||||
aState.y += aState.currentBand->trapezoids[0].GetHeight();
|
||||
goto getBand;
|
||||
}
|
||||
}
|
||||
@@ -1954,13 +1965,13 @@ void nsBlockFrame::PlaceFloater(nsIPresContext* aCX,
|
||||
nsRect region;
|
||||
|
||||
aFloater->GetRect(region);
|
||||
region.y = mCurrentState->currentBand->rects[0].y;
|
||||
region.y = mCurrentState->currentBand->trapezoids[0].yTop;
|
||||
|
||||
if (NS_STYLE_FLOAT_LEFT == mol->floats) {
|
||||
region.x = mCurrentState->currentBand->rects[0].x;
|
||||
region.x = mCurrentState->currentBand->trapezoids[0].xTopLeft;
|
||||
} else {
|
||||
NS_ASSERTION(NS_STYLE_FLOAT_RIGHT == mol->floats, "bad float type");
|
||||
region.x = mCurrentState->currentBand->rects[0].XMost() - region.width;
|
||||
region.x = mCurrentState->currentBand->trapezoids[0].xTopRight - region.width;
|
||||
}
|
||||
|
||||
// XXX Don't forget the floater's margins...
|
||||
|
||||
@@ -76,15 +76,15 @@ PRInt32 SpaceManager::GetBandAvailableSpace(const nsRect* aBand,
|
||||
const nsSize& aMaxSize,
|
||||
nsBandData& aAvailableSpace) const
|
||||
{
|
||||
PRInt32 numRects = LengthOfBand(aBand, aIndex);
|
||||
nscoord localY = aY - mY;
|
||||
nscoord height = PR_MIN(aBand->YMost() - aY, aMaxSize.height);
|
||||
nsRect* rect = aAvailableSpace.rects;
|
||||
nscoord rightEdge = mX + aMaxSize.width;
|
||||
PRInt32 numRects = LengthOfBand(aBand, aIndex);
|
||||
nscoord localY = aY - mY;
|
||||
nscoord height = PR_MIN(aBand->YMost() - aY, aMaxSize.height);
|
||||
nsBandTrapezoid* trapezoid = aAvailableSpace.trapezoids;
|
||||
nscoord rightEdge = mX + aMaxSize.width;
|
||||
|
||||
// Initialize the band data
|
||||
aAvailableSpace.count = 0;
|
||||
rect->x = mX;
|
||||
trapezoid->xTopLeft = mX;
|
||||
|
||||
// Skip any rectangles that are to the left of the local coordinate space
|
||||
while (numRects > 0) {
|
||||
@@ -99,32 +99,49 @@ PRInt32 SpaceManager::GetBandAvailableSpace(const nsRect* aBand,
|
||||
|
||||
// Process all the remaining rectangles that are within the clip width
|
||||
while ((numRects > 0) && (aBand->x < rightEdge)) {
|
||||
if (aBand->x > rect->x) {
|
||||
if (aBand->x > trapezoid->xTopLeft) {
|
||||
// We found some available space
|
||||
rect->width = aBand->x - rect->x;
|
||||
rect->x -= mX; // convert from world to local coordinates
|
||||
rect->y = localY;
|
||||
rect->height = height;
|
||||
trapezoid->xTopRight = trapezoid->xBottomRight = aBand->x;
|
||||
|
||||
// Convert from world to local coordinates
|
||||
trapezoid->xTopLeft -= mX;
|
||||
trapezoid->xTopRight -= mX;
|
||||
trapezoid->xBottomLeft = trapezoid->xTopLeft;
|
||||
trapezoid->xBottomRight = trapezoid->xTopRight;
|
||||
|
||||
trapezoid->yTop = localY;
|
||||
trapezoid->yBottom = localY + height;
|
||||
trapezoid->state = nsBandTrapezoid::smAvailable;
|
||||
trapezoid->frame = nsnull;
|
||||
|
||||
// Move to the next output rect
|
||||
rect++;
|
||||
trapezoid++;
|
||||
aAvailableSpace.count++;
|
||||
}
|
||||
|
||||
rect->x = aBand->XMost();
|
||||
trapezoid->xTopLeft = aBand->XMost();
|
||||
|
||||
// Move to the next rect in the band
|
||||
numRects--;
|
||||
aBand++;
|
||||
}
|
||||
|
||||
// No more rects left in the band. If we haven't yet reached the right edge
|
||||
// No more rects left in the band. If we haven't yet reached the right edge,
|
||||
// then all the remaining space is available
|
||||
if (rect->x < rightEdge) {
|
||||
rect->width = rightEdge - rect->x;
|
||||
rect->x -= mX; // convert from world to local coordinates
|
||||
rect->y = localY;
|
||||
rect->height = height;
|
||||
if (trapezoid->xTopLeft < rightEdge) {
|
||||
trapezoid->xTopRight = rightEdge;
|
||||
|
||||
// Convert from world to local coordinates
|
||||
trapezoid->xTopLeft -= mX;
|
||||
trapezoid->xTopRight -= mX;
|
||||
trapezoid->xBottomLeft = trapezoid->xTopLeft;
|
||||
trapezoid->xBottomRight = trapezoid->xTopRight;
|
||||
|
||||
trapezoid->yTop = localY;
|
||||
trapezoid->yBottom = localY + height;
|
||||
trapezoid->state = nsBandTrapezoid::smAvailable;
|
||||
trapezoid->frame = nsnull;
|
||||
|
||||
aAvailableSpace.count++;
|
||||
}
|
||||
|
||||
@@ -142,10 +159,15 @@ PRInt32 SpaceManager::GetBandData(nscoord aYOffset,
|
||||
// band then all the space is available
|
||||
if ((0 == mRectArray.mCount) || (y >= mRectArray.YMost())) {
|
||||
aAvailableSpace.count = 1;
|
||||
aAvailableSpace.rects[0].x = 0;
|
||||
aAvailableSpace.rects[0].y = aYOffset;
|
||||
aAvailableSpace.rects[0].width = aMaxSize.width;
|
||||
aAvailableSpace.rects[0].height = aMaxSize.height;
|
||||
|
||||
nsBandTrapezoid& trapezoid = aAvailableSpace.trapezoids[0];
|
||||
|
||||
trapezoid.xTopLeft = trapezoid.xBottomLeft = 0;
|
||||
trapezoid.yTop = aYOffset;
|
||||
trapezoid.xTopRight = trapezoid.xBottomRight = aMaxSize.width;
|
||||
trapezoid.yBottom = aYOffset + aMaxSize.height;
|
||||
trapezoid.state = nsBandTrapezoid::smAvailable;
|
||||
trapezoid.frame = nsnull;
|
||||
} else {
|
||||
// Find the first band that contains the y-offset or is below the y-offset
|
||||
nsRect* band = mRectArray.mRects;
|
||||
@@ -153,11 +175,14 @@ PRInt32 SpaceManager::GetBandData(nscoord aYOffset,
|
||||
for (PRInt32 i = 0; i < mRectArray.mCount; ) {
|
||||
if (band->y > y) {
|
||||
// The band is below the y-offset
|
||||
aAvailableSpace.count = 1;
|
||||
aAvailableSpace.rects[0].x = 0;
|
||||
aAvailableSpace.rects[0].y = aYOffset;
|
||||
aAvailableSpace.rects[0].width = aMaxSize.width;
|
||||
aAvailableSpace.rects[0].height = PR_MIN(band->y - y, aMaxSize.height);
|
||||
nsBandTrapezoid& trapezoid = aAvailableSpace.trapezoids[0];
|
||||
|
||||
trapezoid.xTopLeft = trapezoid.xBottomLeft = 0;
|
||||
trapezoid.yTop = aYOffset;
|
||||
trapezoid.xTopRight = trapezoid.xBottomRight = aMaxSize.width;
|
||||
trapezoid.yBottom = aYOffset + PR_MIN(band->y - y, aMaxSize.height);
|
||||
trapezoid.state = nsBandTrapezoid::smAvailable;
|
||||
trapezoid.frame = nsnull;
|
||||
break;
|
||||
} else if (y < band->YMost()) {
|
||||
// The band contains the y-offset
|
||||
|
||||
@@ -50,9 +50,9 @@ static NS_DEFINE_IID(kStyleMoleculeSID, NS_STYLEMOLECULE_SID);
|
||||
static NS_DEFINE_IID(kStyleFontSID, NS_STYLEFONT_SID);
|
||||
|
||||
struct BlockBandData : public nsBandData {
|
||||
nsRect data[5];
|
||||
nsBandTrapezoid data[5];
|
||||
|
||||
BlockBandData() {size = 5; rects = data;}
|
||||
BlockBandData() {size = 5; trapezoids = data;}
|
||||
};
|
||||
|
||||
// XXX Bugs
|
||||
@@ -352,13 +352,13 @@ void nsBlockFrame::PlaceBelowCurrentLineFloaters(nsIPresContext* aCX,
|
||||
NS_RELEASE(styleContext);
|
||||
|
||||
floater->GetRect(region);
|
||||
region.y = mCurrentState->currentBand->rects[0].y;
|
||||
region.y = mCurrentState->currentBand->trapezoids[0].yTop;
|
||||
|
||||
if (NS_STYLE_FLOAT_LEFT == mol->floats) {
|
||||
region.x = mCurrentState->currentBand->rects[0].x;
|
||||
region.x = mCurrentState->currentBand->trapezoids[0].xTopLeft;
|
||||
} else {
|
||||
NS_ASSERTION(NS_STYLE_FLOAT_RIGHT == mol->floats, "bad float type");
|
||||
region.x = mCurrentState->currentBand->rects[0].XMost() - region.width;
|
||||
region.x = mCurrentState->currentBand->trapezoids[0].xTopRight - region.width;
|
||||
}
|
||||
|
||||
// XXX Don't forget the floater's margins...
|
||||
@@ -655,9 +655,9 @@ void nsBlockFrame::GetAvailSize(nsSize& aResult,
|
||||
aResult.width = NS_UNCONSTRAINEDSIZE;
|
||||
} else if (aIsInline) {
|
||||
if (NS_STYLE_DIRECTION_LTR == aState.mol->direction) {
|
||||
aResult.width = aState.currentBand->rects[0].XMost() - aState.x;
|
||||
aResult.width = aState.currentBand->trapezoids[0].xTopRight - aState.x;
|
||||
} else {
|
||||
aResult.width = aState.x - aState.currentBand->rects[0].x;
|
||||
aResult.width = aState.x - aState.currentBand->trapezoids[0].xTopLeft;
|
||||
}
|
||||
} else {
|
||||
// It's a block. Don't adjust for the left/right margin here. That happens
|
||||
@@ -750,17 +750,21 @@ void nsBlockFrame::GetAvailableSpaceBand(nsBlockReflowState& aState, nscoord aY)
|
||||
// If there are three rects then let's assume that there are floaters on the
|
||||
// left and right and that only the middle rect is available
|
||||
if (aState.currentBand->count == 3) {
|
||||
aState.currentBand->rects[0] = aState.currentBand->rects[1];
|
||||
aState.currentBand->trapezoids[0] = aState.currentBand->trapezoids[1];
|
||||
} else {
|
||||
nsRect r0, r1;
|
||||
|
||||
// There are two rects. That means either a left or right floater. Just use
|
||||
// whichever space is larger.
|
||||
if (aState.currentBand->rects[1].width > aState.currentBand->rects[0].width) {
|
||||
aState.currentBand->rects[0] = aState.currentBand->rects[1];
|
||||
aState.currentBand->trapezoids[0].GetRect(r0);
|
||||
aState.currentBand->trapezoids[1].GetRect(r1);
|
||||
if (r1.width > r0.width) {
|
||||
aState.currentBand->trapezoids[0] = aState.currentBand->trapezoids[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
aState.spaceManager->Translate(-aState.borderPadding.left, 0);
|
||||
aState.x = aState.currentBand->rects[0].x;
|
||||
aState.x = aState.currentBand->trapezoids[0].xTopLeft;
|
||||
}
|
||||
|
||||
void nsBlockFrame::ClearFloaters(nsBlockReflowState& aState, PRUint32 aClear)
|
||||
@@ -777,24 +781,31 @@ getBand:
|
||||
aState.spaceManager->GetBandData(y, aState.availSize, *aState.currentBand);
|
||||
|
||||
if (aState.currentBand->count == 1) {
|
||||
if (aState.currentBand->rects[0].width != aState.availSize.width) {
|
||||
nsRect rect;
|
||||
|
||||
aState.currentBand->trapezoids[0].GetRect(rect);
|
||||
if (rect.width != aState.availSize.width) {
|
||||
// Some of the space is taken up by floaters
|
||||
if (aState.currentBand->rects[0].x > 0) {
|
||||
if (rect.x > 0) {
|
||||
isLeftFloater = PR_TRUE;
|
||||
}
|
||||
|
||||
if (aState.currentBand->rects[0].XMost() < aState.availSize.width) {
|
||||
if (rect.XMost() < aState.availSize.width) {
|
||||
isRightFloater = PR_TRUE;
|
||||
}
|
||||
}
|
||||
} else if (aState.currentBand->count == 2) {
|
||||
if (aState.currentBand->rects[0].width > aState.currentBand->rects[1].width) {
|
||||
nsRect r0, r1;
|
||||
|
||||
aState.currentBand->trapezoids[0].GetRect(r0);
|
||||
aState.currentBand->trapezoids[1].GetRect(r1);
|
||||
if (r0.width > r1.width) {
|
||||
isRightFloater = PR_TRUE;
|
||||
} else {
|
||||
isLeftFloater = PR_TRUE;
|
||||
|
||||
// There may also be a right floater
|
||||
if (aState.currentBand->rects[1].XMost() < aState.availSize.width) {
|
||||
if (r1.XMost() < aState.availSize.width) {
|
||||
isRightFloater = PR_TRUE;
|
||||
}
|
||||
}
|
||||
@@ -806,13 +817,13 @@ getBand:
|
||||
|
||||
if (isLeftFloater) {
|
||||
if ((aClear == NS_STYLE_CLEAR_LEFT) || (aClear == NS_STYLE_CLEAR_BOTH)) {
|
||||
aState.y += aState.currentBand->rects[0].height;
|
||||
aState.y += aState.currentBand->trapezoids[0].GetHeight();
|
||||
goto getBand;
|
||||
}
|
||||
}
|
||||
if (isRightFloater) {
|
||||
if ((aClear == NS_STYLE_CLEAR_RIGHT) || (aClear == NS_STYLE_CLEAR_BOTH)) {
|
||||
aState.y += aState.currentBand->rects[0].height;
|
||||
aState.y += aState.currentBand->trapezoids[0].GetHeight();
|
||||
goto getBand;
|
||||
}
|
||||
}
|
||||
@@ -1954,13 +1965,13 @@ void nsBlockFrame::PlaceFloater(nsIPresContext* aCX,
|
||||
nsRect region;
|
||||
|
||||
aFloater->GetRect(region);
|
||||
region.y = mCurrentState->currentBand->rects[0].y;
|
||||
region.y = mCurrentState->currentBand->trapezoids[0].yTop;
|
||||
|
||||
if (NS_STYLE_FLOAT_LEFT == mol->floats) {
|
||||
region.x = mCurrentState->currentBand->rects[0].x;
|
||||
region.x = mCurrentState->currentBand->trapezoids[0].xTopLeft;
|
||||
} else {
|
||||
NS_ASSERTION(NS_STYLE_FLOAT_RIGHT == mol->floats, "bad float type");
|
||||
region.x = mCurrentState->currentBand->rects[0].XMost() - region.width;
|
||||
region.x = mCurrentState->currentBand->trapezoids[0].xTopRight - region.width;
|
||||
}
|
||||
|
||||
// XXX Don't forget the floater's margins...
|
||||
|
||||
@@ -50,9 +50,9 @@ static NS_DEFINE_IID(kStyleMoleculeSID, NS_STYLEMOLECULE_SID);
|
||||
static NS_DEFINE_IID(kStyleFontSID, NS_STYLEFONT_SID);
|
||||
|
||||
struct BlockBandData : public nsBandData {
|
||||
nsRect data[5];
|
||||
nsBandTrapezoid data[5];
|
||||
|
||||
BlockBandData() {size = 5; rects = data;}
|
||||
BlockBandData() {size = 5; trapezoids = data;}
|
||||
};
|
||||
|
||||
// XXX Bugs
|
||||
@@ -352,13 +352,13 @@ void nsBlockFrame::PlaceBelowCurrentLineFloaters(nsIPresContext* aCX,
|
||||
NS_RELEASE(styleContext);
|
||||
|
||||
floater->GetRect(region);
|
||||
region.y = mCurrentState->currentBand->rects[0].y;
|
||||
region.y = mCurrentState->currentBand->trapezoids[0].yTop;
|
||||
|
||||
if (NS_STYLE_FLOAT_LEFT == mol->floats) {
|
||||
region.x = mCurrentState->currentBand->rects[0].x;
|
||||
region.x = mCurrentState->currentBand->trapezoids[0].xTopLeft;
|
||||
} else {
|
||||
NS_ASSERTION(NS_STYLE_FLOAT_RIGHT == mol->floats, "bad float type");
|
||||
region.x = mCurrentState->currentBand->rects[0].XMost() - region.width;
|
||||
region.x = mCurrentState->currentBand->trapezoids[0].xTopRight - region.width;
|
||||
}
|
||||
|
||||
// XXX Don't forget the floater's margins...
|
||||
@@ -655,9 +655,9 @@ void nsBlockFrame::GetAvailSize(nsSize& aResult,
|
||||
aResult.width = NS_UNCONSTRAINEDSIZE;
|
||||
} else if (aIsInline) {
|
||||
if (NS_STYLE_DIRECTION_LTR == aState.mol->direction) {
|
||||
aResult.width = aState.currentBand->rects[0].XMost() - aState.x;
|
||||
aResult.width = aState.currentBand->trapezoids[0].xTopRight - aState.x;
|
||||
} else {
|
||||
aResult.width = aState.x - aState.currentBand->rects[0].x;
|
||||
aResult.width = aState.x - aState.currentBand->trapezoids[0].xTopLeft;
|
||||
}
|
||||
} else {
|
||||
// It's a block. Don't adjust for the left/right margin here. That happens
|
||||
@@ -750,17 +750,21 @@ void nsBlockFrame::GetAvailableSpaceBand(nsBlockReflowState& aState, nscoord aY)
|
||||
// If there are three rects then let's assume that there are floaters on the
|
||||
// left and right and that only the middle rect is available
|
||||
if (aState.currentBand->count == 3) {
|
||||
aState.currentBand->rects[0] = aState.currentBand->rects[1];
|
||||
aState.currentBand->trapezoids[0] = aState.currentBand->trapezoids[1];
|
||||
} else {
|
||||
nsRect r0, r1;
|
||||
|
||||
// There are two rects. That means either a left or right floater. Just use
|
||||
// whichever space is larger.
|
||||
if (aState.currentBand->rects[1].width > aState.currentBand->rects[0].width) {
|
||||
aState.currentBand->rects[0] = aState.currentBand->rects[1];
|
||||
aState.currentBand->trapezoids[0].GetRect(r0);
|
||||
aState.currentBand->trapezoids[1].GetRect(r1);
|
||||
if (r1.width > r0.width) {
|
||||
aState.currentBand->trapezoids[0] = aState.currentBand->trapezoids[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
aState.spaceManager->Translate(-aState.borderPadding.left, 0);
|
||||
aState.x = aState.currentBand->rects[0].x;
|
||||
aState.x = aState.currentBand->trapezoids[0].xTopLeft;
|
||||
}
|
||||
|
||||
void nsBlockFrame::ClearFloaters(nsBlockReflowState& aState, PRUint32 aClear)
|
||||
@@ -777,24 +781,31 @@ getBand:
|
||||
aState.spaceManager->GetBandData(y, aState.availSize, *aState.currentBand);
|
||||
|
||||
if (aState.currentBand->count == 1) {
|
||||
if (aState.currentBand->rects[0].width != aState.availSize.width) {
|
||||
nsRect rect;
|
||||
|
||||
aState.currentBand->trapezoids[0].GetRect(rect);
|
||||
if (rect.width != aState.availSize.width) {
|
||||
// Some of the space is taken up by floaters
|
||||
if (aState.currentBand->rects[0].x > 0) {
|
||||
if (rect.x > 0) {
|
||||
isLeftFloater = PR_TRUE;
|
||||
}
|
||||
|
||||
if (aState.currentBand->rects[0].XMost() < aState.availSize.width) {
|
||||
if (rect.XMost() < aState.availSize.width) {
|
||||
isRightFloater = PR_TRUE;
|
||||
}
|
||||
}
|
||||
} else if (aState.currentBand->count == 2) {
|
||||
if (aState.currentBand->rects[0].width > aState.currentBand->rects[1].width) {
|
||||
nsRect r0, r1;
|
||||
|
||||
aState.currentBand->trapezoids[0].GetRect(r0);
|
||||
aState.currentBand->trapezoids[1].GetRect(r1);
|
||||
if (r0.width > r1.width) {
|
||||
isRightFloater = PR_TRUE;
|
||||
} else {
|
||||
isLeftFloater = PR_TRUE;
|
||||
|
||||
// There may also be a right floater
|
||||
if (aState.currentBand->rects[1].XMost() < aState.availSize.width) {
|
||||
if (r1.XMost() < aState.availSize.width) {
|
||||
isRightFloater = PR_TRUE;
|
||||
}
|
||||
}
|
||||
@@ -806,13 +817,13 @@ getBand:
|
||||
|
||||
if (isLeftFloater) {
|
||||
if ((aClear == NS_STYLE_CLEAR_LEFT) || (aClear == NS_STYLE_CLEAR_BOTH)) {
|
||||
aState.y += aState.currentBand->rects[0].height;
|
||||
aState.y += aState.currentBand->trapezoids[0].GetHeight();
|
||||
goto getBand;
|
||||
}
|
||||
}
|
||||
if (isRightFloater) {
|
||||
if ((aClear == NS_STYLE_CLEAR_RIGHT) || (aClear == NS_STYLE_CLEAR_BOTH)) {
|
||||
aState.y += aState.currentBand->rects[0].height;
|
||||
aState.y += aState.currentBand->trapezoids[0].GetHeight();
|
||||
goto getBand;
|
||||
}
|
||||
}
|
||||
@@ -1954,13 +1965,13 @@ void nsBlockFrame::PlaceFloater(nsIPresContext* aCX,
|
||||
nsRect region;
|
||||
|
||||
aFloater->GetRect(region);
|
||||
region.y = mCurrentState->currentBand->rects[0].y;
|
||||
region.y = mCurrentState->currentBand->trapezoids[0].yTop;
|
||||
|
||||
if (NS_STYLE_FLOAT_LEFT == mol->floats) {
|
||||
region.x = mCurrentState->currentBand->rects[0].x;
|
||||
region.x = mCurrentState->currentBand->trapezoids[0].xTopLeft;
|
||||
} else {
|
||||
NS_ASSERTION(NS_STYLE_FLOAT_RIGHT == mol->floats, "bad float type");
|
||||
region.x = mCurrentState->currentBand->rects[0].XMost() - region.width;
|
||||
region.x = mCurrentState->currentBand->trapezoids[0].xTopRight - region.width;
|
||||
}
|
||||
|
||||
// XXX Don't forget the floater's margins...
|
||||
|
||||
@@ -50,9 +50,9 @@ static NS_DEFINE_IID(kStyleMoleculeSID, NS_STYLEMOLECULE_SID);
|
||||
static NS_DEFINE_IID(kStyleFontSID, NS_STYLEFONT_SID);
|
||||
|
||||
struct BlockBandData : public nsBandData {
|
||||
nsRect data[5];
|
||||
nsBandTrapezoid data[5];
|
||||
|
||||
BlockBandData() {size = 5; rects = data;}
|
||||
BlockBandData() {size = 5; trapezoids = data;}
|
||||
};
|
||||
|
||||
// XXX Bugs
|
||||
@@ -352,13 +352,13 @@ void nsBlockFrame::PlaceBelowCurrentLineFloaters(nsIPresContext* aCX,
|
||||
NS_RELEASE(styleContext);
|
||||
|
||||
floater->GetRect(region);
|
||||
region.y = mCurrentState->currentBand->rects[0].y;
|
||||
region.y = mCurrentState->currentBand->trapezoids[0].yTop;
|
||||
|
||||
if (NS_STYLE_FLOAT_LEFT == mol->floats) {
|
||||
region.x = mCurrentState->currentBand->rects[0].x;
|
||||
region.x = mCurrentState->currentBand->trapezoids[0].xTopLeft;
|
||||
} else {
|
||||
NS_ASSERTION(NS_STYLE_FLOAT_RIGHT == mol->floats, "bad float type");
|
||||
region.x = mCurrentState->currentBand->rects[0].XMost() - region.width;
|
||||
region.x = mCurrentState->currentBand->trapezoids[0].xTopRight - region.width;
|
||||
}
|
||||
|
||||
// XXX Don't forget the floater's margins...
|
||||
@@ -655,9 +655,9 @@ void nsBlockFrame::GetAvailSize(nsSize& aResult,
|
||||
aResult.width = NS_UNCONSTRAINEDSIZE;
|
||||
} else if (aIsInline) {
|
||||
if (NS_STYLE_DIRECTION_LTR == aState.mol->direction) {
|
||||
aResult.width = aState.currentBand->rects[0].XMost() - aState.x;
|
||||
aResult.width = aState.currentBand->trapezoids[0].xTopRight - aState.x;
|
||||
} else {
|
||||
aResult.width = aState.x - aState.currentBand->rects[0].x;
|
||||
aResult.width = aState.x - aState.currentBand->trapezoids[0].xTopLeft;
|
||||
}
|
||||
} else {
|
||||
// It's a block. Don't adjust for the left/right margin here. That happens
|
||||
@@ -750,17 +750,21 @@ void nsBlockFrame::GetAvailableSpaceBand(nsBlockReflowState& aState, nscoord aY)
|
||||
// If there are three rects then let's assume that there are floaters on the
|
||||
// left and right and that only the middle rect is available
|
||||
if (aState.currentBand->count == 3) {
|
||||
aState.currentBand->rects[0] = aState.currentBand->rects[1];
|
||||
aState.currentBand->trapezoids[0] = aState.currentBand->trapezoids[1];
|
||||
} else {
|
||||
nsRect r0, r1;
|
||||
|
||||
// There are two rects. That means either a left or right floater. Just use
|
||||
// whichever space is larger.
|
||||
if (aState.currentBand->rects[1].width > aState.currentBand->rects[0].width) {
|
||||
aState.currentBand->rects[0] = aState.currentBand->rects[1];
|
||||
aState.currentBand->trapezoids[0].GetRect(r0);
|
||||
aState.currentBand->trapezoids[1].GetRect(r1);
|
||||
if (r1.width > r0.width) {
|
||||
aState.currentBand->trapezoids[0] = aState.currentBand->trapezoids[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
aState.spaceManager->Translate(-aState.borderPadding.left, 0);
|
||||
aState.x = aState.currentBand->rects[0].x;
|
||||
aState.x = aState.currentBand->trapezoids[0].xTopLeft;
|
||||
}
|
||||
|
||||
void nsBlockFrame::ClearFloaters(nsBlockReflowState& aState, PRUint32 aClear)
|
||||
@@ -777,24 +781,31 @@ getBand:
|
||||
aState.spaceManager->GetBandData(y, aState.availSize, *aState.currentBand);
|
||||
|
||||
if (aState.currentBand->count == 1) {
|
||||
if (aState.currentBand->rects[0].width != aState.availSize.width) {
|
||||
nsRect rect;
|
||||
|
||||
aState.currentBand->trapezoids[0].GetRect(rect);
|
||||
if (rect.width != aState.availSize.width) {
|
||||
// Some of the space is taken up by floaters
|
||||
if (aState.currentBand->rects[0].x > 0) {
|
||||
if (rect.x > 0) {
|
||||
isLeftFloater = PR_TRUE;
|
||||
}
|
||||
|
||||
if (aState.currentBand->rects[0].XMost() < aState.availSize.width) {
|
||||
if (rect.XMost() < aState.availSize.width) {
|
||||
isRightFloater = PR_TRUE;
|
||||
}
|
||||
}
|
||||
} else if (aState.currentBand->count == 2) {
|
||||
if (aState.currentBand->rects[0].width > aState.currentBand->rects[1].width) {
|
||||
nsRect r0, r1;
|
||||
|
||||
aState.currentBand->trapezoids[0].GetRect(r0);
|
||||
aState.currentBand->trapezoids[1].GetRect(r1);
|
||||
if (r0.width > r1.width) {
|
||||
isRightFloater = PR_TRUE;
|
||||
} else {
|
||||
isLeftFloater = PR_TRUE;
|
||||
|
||||
// There may also be a right floater
|
||||
if (aState.currentBand->rects[1].XMost() < aState.availSize.width) {
|
||||
if (r1.XMost() < aState.availSize.width) {
|
||||
isRightFloater = PR_TRUE;
|
||||
}
|
||||
}
|
||||
@@ -806,13 +817,13 @@ getBand:
|
||||
|
||||
if (isLeftFloater) {
|
||||
if ((aClear == NS_STYLE_CLEAR_LEFT) || (aClear == NS_STYLE_CLEAR_BOTH)) {
|
||||
aState.y += aState.currentBand->rects[0].height;
|
||||
aState.y += aState.currentBand->trapezoids[0].GetHeight();
|
||||
goto getBand;
|
||||
}
|
||||
}
|
||||
if (isRightFloater) {
|
||||
if ((aClear == NS_STYLE_CLEAR_RIGHT) || (aClear == NS_STYLE_CLEAR_BOTH)) {
|
||||
aState.y += aState.currentBand->rects[0].height;
|
||||
aState.y += aState.currentBand->trapezoids[0].GetHeight();
|
||||
goto getBand;
|
||||
}
|
||||
}
|
||||
@@ -1954,13 +1965,13 @@ void nsBlockFrame::PlaceFloater(nsIPresContext* aCX,
|
||||
nsRect region;
|
||||
|
||||
aFloater->GetRect(region);
|
||||
region.y = mCurrentState->currentBand->rects[0].y;
|
||||
region.y = mCurrentState->currentBand->trapezoids[0].yTop;
|
||||
|
||||
if (NS_STYLE_FLOAT_LEFT == mol->floats) {
|
||||
region.x = mCurrentState->currentBand->rects[0].x;
|
||||
region.x = mCurrentState->currentBand->trapezoids[0].xTopLeft;
|
||||
} else {
|
||||
NS_ASSERTION(NS_STYLE_FLOAT_RIGHT == mol->floats, "bad float type");
|
||||
region.x = mCurrentState->currentBand->rects[0].XMost() - region.width;
|
||||
region.x = mCurrentState->currentBand->trapezoids[0].xTopRight - region.width;
|
||||
}
|
||||
|
||||
// XXX Don't forget the floater's margins...
|
||||
|
||||
Reference in New Issue
Block a user