mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-08 19:04:45 +00:00
Allow floats to be placed on the current line even after nonzero-width inline content has been placed. Fixes an Acid3 layout bug. r+sr=dbaron
This commit is contained in:
parent
3b0423c3b4
commit
4188aa979e
@ -5620,28 +5620,14 @@ nsBlockFrame::DeleteNextInFlowChild(nsPresContext* aPresContext,
|
|||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
// Float support
|
// Float support
|
||||||
|
|
||||||
nsresult
|
nsRect
|
||||||
nsBlockFrame::ReflowFloat(nsBlockReflowState& aState,
|
nsBlockFrame::ComputeFloatAvailableSpace(nsBlockReflowState& aState,
|
||||||
nsPlaceholderFrame* aPlaceholder,
|
nsIFrame* aFloatFrame)
|
||||||
nsMargin& aFloatMargin,
|
|
||||||
nsReflowStatus& aReflowStatus)
|
|
||||||
{
|
{
|
||||||
// Reflow the float.
|
|
||||||
nsIFrame* floatFrame = aPlaceholder->GetOutOfFlowFrame();
|
|
||||||
aReflowStatus = NS_FRAME_COMPLETE;
|
|
||||||
|
|
||||||
#ifdef NOISY_FLOAT
|
|
||||||
printf("Reflow Float %p in parent %p, availSpace(%d,%d,%d,%d)\n",
|
|
||||||
aPlaceholder->GetOutOfFlowFrame(), this,
|
|
||||||
aState.mAvailSpaceRect.x, aState.mAvailSpaceRect.y,
|
|
||||||
aState.mAvailSpaceRect.width, aState.mAvailSpaceRect.height
|
|
||||||
);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Compute the available width. By default, assume the width of the
|
// Compute the available width. By default, assume the width of the
|
||||||
// containing block.
|
// containing block.
|
||||||
nscoord availWidth;
|
nscoord availWidth;
|
||||||
const nsStyleDisplay* floatDisplay = floatFrame->GetStyleDisplay();
|
const nsStyleDisplay* floatDisplay = aFloatFrame->GetStyleDisplay();
|
||||||
|
|
||||||
if (NS_STYLE_DISPLAY_TABLE != floatDisplay->mDisplay ||
|
if (NS_STYLE_DISPLAY_TABLE != floatDisplay->mDisplay ||
|
||||||
eCompatibility_NavQuirks != aState.mPresContext->CompatibilityMode() ) {
|
eCompatibility_NavQuirks != aState.mPresContext->CompatibilityMode() ) {
|
||||||
@ -5667,12 +5653,47 @@ nsBlockFrame::ReflowFloat(nsBlockReflowState& aState,
|
|||||||
? NS_UNCONSTRAINEDSIZE
|
? NS_UNCONSTRAINEDSIZE
|
||||||
: PR_MAX(0, aState.mContentArea.height - contentYOffset);
|
: PR_MAX(0, aState.mContentArea.height - contentYOffset);
|
||||||
|
|
||||||
nsRect availSpace(aState.BorderPadding().left,
|
return nsRect(aState.BorderPadding().left,
|
||||||
aState.BorderPadding().top,
|
aState.BorderPadding().top,
|
||||||
availWidth, availHeight);
|
availWidth, availHeight);
|
||||||
|
}
|
||||||
|
|
||||||
|
nscoord
|
||||||
|
nsBlockFrame::ComputeFloatWidth(nsBlockReflowState& aState,
|
||||||
|
nsPlaceholderFrame* aPlaceholder)
|
||||||
|
{
|
||||||
|
// Reflow the float.
|
||||||
|
nsIFrame* floatFrame = aPlaceholder->GetOutOfFlowFrame();
|
||||||
|
|
||||||
|
nsRect availSpace = ComputeFloatAvailableSpace(aState, floatFrame);
|
||||||
|
|
||||||
|
nsHTMLReflowState floatRS(aState.mPresContext, aState.mReflowState,
|
||||||
|
floatFrame,
|
||||||
|
nsSize(availSpace.width, availSpace.height));
|
||||||
|
return floatRS.ComputedWidth() + floatRS.mComputedBorderPadding.LeftRight() +
|
||||||
|
floatRS.mComputedMargin.LeftRight();
|
||||||
|
}
|
||||||
|
|
||||||
|
nsresult
|
||||||
|
nsBlockFrame::ReflowFloat(nsBlockReflowState& aState,
|
||||||
|
nsPlaceholderFrame* aPlaceholder,
|
||||||
|
nsMargin& aFloatMargin,
|
||||||
|
nsReflowStatus& aReflowStatus)
|
||||||
|
{
|
||||||
|
// Reflow the float.
|
||||||
|
nsIFrame* floatFrame = aPlaceholder->GetOutOfFlowFrame();
|
||||||
|
aReflowStatus = NS_FRAME_COMPLETE;
|
||||||
|
|
||||||
|
#ifdef NOISY_FLOAT
|
||||||
|
printf("Reflow Float %p in parent %p, availSpace(%d,%d,%d,%d)\n",
|
||||||
|
aPlaceholder->GetOutOfFlowFrame(), this,
|
||||||
|
aState.mAvailSpaceRect.x, aState.mAvailSpaceRect.y,
|
||||||
|
aState.mAvailSpaceRect.width, aState.mAvailSpaceRect.height
|
||||||
|
);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
nsRect availSpace = ComputeFloatAvailableSpace(aState, floatFrame);
|
||||||
|
|
||||||
// construct the html reflow state for the float. ReflowBlock will
|
|
||||||
// initialize it.
|
|
||||||
nsHTMLReflowState floatRS(aState.mPresContext, aState.mReflowState,
|
nsHTMLReflowState floatRS(aState.mPresContext, aState.mReflowState,
|
||||||
floatFrame,
|
floatFrame,
|
||||||
nsSize(availSpace.width, availSpace.height));
|
nsSize(availSpace.width, availSpace.height));
|
||||||
@ -5709,7 +5730,8 @@ nsBlockFrame::ReflowFloat(nsBlockReflowState& aState,
|
|||||||
|
|
||||||
// An incomplete reflow status means we should split the float
|
// An incomplete reflow status means we should split the float
|
||||||
// if the height is constrained (bug 145305).
|
// if the height is constrained (bug 145305).
|
||||||
if (NS_FRAME_IS_NOT_COMPLETE(aReflowStatus) && (NS_UNCONSTRAINEDSIZE == availHeight))
|
if (NS_FRAME_IS_NOT_COMPLETE(aReflowStatus) &&
|
||||||
|
(NS_UNCONSTRAINEDSIZE == availSpace.height))
|
||||||
aReflowStatus = NS_FRAME_COMPLETE;
|
aReflowStatus = NS_FRAME_COMPLETE;
|
||||||
|
|
||||||
//XXXfr Floats can't be overflow incomplete yet
|
//XXXfr Floats can't be overflow incomplete yet
|
||||||
|
@ -517,6 +517,12 @@ protected:
|
|||||||
nsIFrame* aFrame,
|
nsIFrame* aFrame,
|
||||||
LineReflowStatus* aLineReflowStatus);
|
LineReflowStatus* aLineReflowStatus);
|
||||||
|
|
||||||
|
// Compute the available width for a float.
|
||||||
|
nsRect ComputeFloatAvailableSpace(nsBlockReflowState& aState,
|
||||||
|
nsIFrame* aFloatFrame);
|
||||||
|
// Computes the border-box width of the float
|
||||||
|
nscoord ComputeFloatWidth(nsBlockReflowState& aState,
|
||||||
|
nsPlaceholderFrame* aPlaceholder);
|
||||||
// An incomplete aReflowStatus indicates the float should be split
|
// An incomplete aReflowStatus indicates the float should be split
|
||||||
// but only if the available height is constrained.
|
// but only if the available height is constrained.
|
||||||
nsresult ReflowFloat(nsBlockReflowState& aState,
|
nsresult ReflowFloat(nsBlockReflowState& aState,
|
||||||
|
@ -533,6 +533,7 @@ nsBlockReflowState::IsImpactedByFloat() const
|
|||||||
PRBool
|
PRBool
|
||||||
nsBlockReflowState::InitFloat(nsLineLayout& aLineLayout,
|
nsBlockReflowState::InitFloat(nsLineLayout& aLineLayout,
|
||||||
nsPlaceholderFrame* aPlaceholder,
|
nsPlaceholderFrame* aPlaceholder,
|
||||||
|
nscoord aAvailableWidth,
|
||||||
nsReflowStatus& aReflowStatus)
|
nsReflowStatus& aReflowStatus)
|
||||||
{
|
{
|
||||||
// Set the geometric parent of the float
|
// Set the geometric parent of the float
|
||||||
@ -541,7 +542,8 @@ nsBlockReflowState::InitFloat(nsLineLayout& aLineLayout,
|
|||||||
|
|
||||||
// Then add the float to the current line and place it when
|
// Then add the float to the current line and place it when
|
||||||
// appropriate
|
// appropriate
|
||||||
return AddFloat(aLineLayout, aPlaceholder, PR_TRUE, aReflowStatus);
|
return AddFloat(aLineLayout, aPlaceholder, PR_TRUE,
|
||||||
|
aAvailableWidth, aReflowStatus);
|
||||||
}
|
}
|
||||||
|
|
||||||
// This is called by the line layout's AddFloat method when a
|
// This is called by the line layout's AddFloat method when a
|
||||||
@ -558,6 +560,7 @@ PRBool
|
|||||||
nsBlockReflowState::AddFloat(nsLineLayout& aLineLayout,
|
nsBlockReflowState::AddFloat(nsLineLayout& aLineLayout,
|
||||||
nsPlaceholderFrame* aPlaceholder,
|
nsPlaceholderFrame* aPlaceholder,
|
||||||
PRBool aInitialReflow,
|
PRBool aInitialReflow,
|
||||||
|
nscoord aAvailableWidth,
|
||||||
nsReflowStatus& aReflowStatus)
|
nsReflowStatus& aReflowStatus)
|
||||||
{
|
{
|
||||||
NS_PRECONDITION(mBlock->end_lines() != mCurrentLine, "null ptr");
|
NS_PRECONDITION(mBlock->end_lines() != mCurrentLine, "null ptr");
|
||||||
@ -571,7 +574,12 @@ nsBlockReflowState::AddFloat(nsLineLayout& aLineLayout,
|
|||||||
|
|
||||||
// Now place the float immediately if possible. Otherwise stash it
|
// Now place the float immediately if possible. Otherwise stash it
|
||||||
// away in mPendingFloats and place it later.
|
// away in mPendingFloats and place it later.
|
||||||
if (aLineLayout.CanPlaceFloatNow()) {
|
// If one or more floats has already been pushed to the next line,
|
||||||
|
// don't let this one go on the current line, since that would violate
|
||||||
|
// float ordering.
|
||||||
|
if (mBelowCurrentLineFloats.IsEmpty() &&
|
||||||
|
(aLineLayout.CanPlaceFloatNow() ||
|
||||||
|
mBlock->ComputeFloatWidth(*this, aPlaceholder) <= aAvailableWidth)) {
|
||||||
// Because we are in the middle of reflowing a placeholder frame
|
// Because we are in the middle of reflowing a placeholder frame
|
||||||
// within a line (and possibly nested in an inline frame or two
|
// within a line (and possibly nested in an inline frame or two
|
||||||
// that's a child of our block) we need to restore the space
|
// that's a child of our block) we need to restore the space
|
||||||
@ -594,10 +602,9 @@ nsBlockReflowState::AddFloat(nsLineLayout& aLineLayout,
|
|||||||
if (forceFit || (placed && !NS_FRAME_IS_TRUNCATED(aReflowStatus))) {
|
if (forceFit || (placed && !NS_FRAME_IS_TRUNCATED(aReflowStatus))) {
|
||||||
// Pass on updated available space to the current inline reflow engine
|
// Pass on updated available space to the current inline reflow engine
|
||||||
GetAvailableSpace(mY, forceFit);
|
GetAvailableSpace(mY, forceFit);
|
||||||
aLineLayout.UpdateBand(mAvailSpaceRect.x + BorderPadding().left, mY,
|
nsRect availSpace(nsPoint(mAvailSpaceRect.x + BorderPadding().left, mY),
|
||||||
mAvailSpaceRect.width,
|
mAvailSpaceRect.Size());
|
||||||
mAvailSpaceRect.height,
|
aLineLayout.UpdateBand(availSpace, isLeftFloat,
|
||||||
isLeftFloat,
|
|
||||||
aPlaceholder->GetOutOfFlowFrame());
|
aPlaceholder->GetOutOfFlowFrame());
|
||||||
|
|
||||||
// Record this float in the current-line list
|
// Record this float in the current-line list
|
||||||
|
@ -94,10 +94,12 @@ public:
|
|||||||
*/
|
*/
|
||||||
PRBool InitFloat(nsLineLayout& aLineLayout,
|
PRBool InitFloat(nsLineLayout& aLineLayout,
|
||||||
nsPlaceholderFrame* aPlaceholderFrame,
|
nsPlaceholderFrame* aPlaceholderFrame,
|
||||||
|
nscoord aAvailableWidth,
|
||||||
nsReflowStatus& aReflowStatus);
|
nsReflowStatus& aReflowStatus);
|
||||||
PRBool AddFloat(nsLineLayout& aLineLayout,
|
PRBool AddFloat(nsLineLayout& aLineLayout,
|
||||||
nsPlaceholderFrame* aPlaceholderFrame,
|
nsPlaceholderFrame* aPlaceholderFrame,
|
||||||
PRBool aInitialReflow,
|
PRBool aInitialReflow,
|
||||||
|
nscoord aAvailableWidth,
|
||||||
nsReflowStatus& aReflowStatus);
|
nsReflowStatus& aReflowStatus);
|
||||||
PRBool CanPlaceFloat(const nsSize& aFloatSize, PRUint8 aFloats, PRBool aForceFit);
|
PRBool CanPlaceFloat(const nsSize& aFloatSize, PRUint8 aFloats, PRBool aForceFit);
|
||||||
PRBool FlowAndPlaceFloat(nsFloatCache* aFloatCache,
|
PRBool FlowAndPlaceFloat(nsFloatCache* aFloatCache,
|
||||||
|
@ -203,7 +203,6 @@ nsLineLayout::BeginLineReflow(nscoord aX, nscoord aY,
|
|||||||
|
|
||||||
SetFlag(LL_FIRSTLETTERSTYLEOK, PR_FALSE);
|
SetFlag(LL_FIRSTLETTERSTYLEOK, PR_FALSE);
|
||||||
SetFlag(LL_ISTOPOFPAGE, aIsTopOfPage);
|
SetFlag(LL_ISTOPOFPAGE, aIsTopOfPage);
|
||||||
SetFlag(LL_UPDATEDBAND, PR_FALSE);
|
|
||||||
mPlacedFloats = 0;
|
mPlacedFloats = 0;
|
||||||
SetFlag(LL_IMPACTEDBYFLOATS, aImpactedByFloats);
|
SetFlag(LL_IMPACTEDBYFLOATS, aImpactedByFloats);
|
||||||
mTotalPlacedFrames = 0;
|
mTotalPlacedFrames = 0;
|
||||||
@ -291,89 +290,85 @@ nsLineLayout::EndLineReflow()
|
|||||||
// per-span mLeftEdge?
|
// per-span mLeftEdge?
|
||||||
|
|
||||||
void
|
void
|
||||||
nsLineLayout::UpdateBand(nscoord aX, nscoord aY,
|
nsLineLayout::UpdateBand(const nsRect& aNewAvailSpace,
|
||||||
nscoord aWidth, nscoord aHeight,
|
|
||||||
PRBool aPlacedLeftFloat,
|
PRBool aPlacedLeftFloat,
|
||||||
nsIFrame* aFloatFrame)
|
nsIFrame* aFloatFrame)
|
||||||
{
|
{
|
||||||
#ifdef REALLY_NOISY_REFLOW
|
#ifdef REALLY_NOISY_REFLOW
|
||||||
printf("nsLL::UpdateBand %d, %d, %d, %d, frame=%p placedLeft=%s\n will set mImpacted to PR_TRUE\n",
|
printf("nsLL::UpdateBand %d, %d, %d, %d, frame=%p placedLeft=%s\n will set mImpacted to PR_TRUE\n",
|
||||||
aX, aY, aWidth, aHeight, aFloatFrame, aPlacedLeftFloat?"true":"false");
|
aNewAvailSpace.x, aNewAvailSpace.y,
|
||||||
|
aNewAvailSpace.width, aNewAvailSpace.height,
|
||||||
|
aFloatFrame, aPlacedLeftFloat?"true":"false");
|
||||||
#endif
|
#endif
|
||||||
PerSpanData* psd = mRootSpan;
|
|
||||||
NS_PRECONDITION(psd->mX == psd->mLeftEdge, "update-band called late");
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
if ((aWidth != NS_UNCONSTRAINEDSIZE) && CRAZY_WIDTH(aWidth)) {
|
if ((aNewAvailSpace.width != NS_UNCONSTRAINEDSIZE) && CRAZY_WIDTH(aNewAvailSpace.width)) {
|
||||||
nsFrame::ListTag(stdout, mBlockReflowState->frame);
|
nsFrame::ListTag(stdout, mBlockReflowState->frame);
|
||||||
printf(": UpdateBand: bad caller: width WAS %d(0x%x)\n",
|
printf(": UpdateBand: bad caller: width WAS %d(0x%x)\n",
|
||||||
aWidth, aWidth);
|
aNewAvailSpace.width, aNewAvailSpace.width);
|
||||||
}
|
}
|
||||||
if ((aHeight != NS_UNCONSTRAINEDSIZE) && CRAZY_HEIGHT(aHeight)) {
|
if ((aNewAvailSpace.height != NS_UNCONSTRAINEDSIZE) && CRAZY_HEIGHT(aNewAvailSpace.height)) {
|
||||||
nsFrame::ListTag(stdout, mBlockReflowState->frame);
|
nsFrame::ListTag(stdout, mBlockReflowState->frame);
|
||||||
printf(": UpdateBand: bad caller: height WAS %d(0x%x)\n",
|
printf(": UpdateBand: bad caller: height WAS %d(0x%x)\n",
|
||||||
aHeight, aHeight);
|
aNewAvailSpace.height, aNewAvailSpace.height);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Compute the difference between last times width and the new width
|
// Compute the difference between last times width and the new width
|
||||||
NS_ASSERTION(psd->mRightEdge != NS_UNCONSTRAINEDSIZE &&
|
NS_ASSERTION(mRootSpan->mRightEdge != NS_UNCONSTRAINEDSIZE &&
|
||||||
aWidth != NS_UNCONSTRAINEDSIZE,
|
aNewAvailSpace.width != NS_UNCONSTRAINEDSIZE,
|
||||||
"shouldn't use unconstrained widths anymore");
|
"shouldn't use unconstrained widths anymore");
|
||||||
nscoord deltaWidth = aWidth - (psd->mRightEdge - psd->mLeftEdge);
|
// The root span's mLeftEdge moves to aX
|
||||||
|
nscoord deltaX = aNewAvailSpace.x - mRootSpan->mLeftEdge;
|
||||||
|
// The width of all spans changes by this much (the root span's
|
||||||
|
// mRightEdge moves to aX + aWidth, its new width is aWidth)
|
||||||
|
nscoord deltaWidth = aNewAvailSpace.width - (mRootSpan->mRightEdge - mRootSpan->mLeftEdge);
|
||||||
#ifdef NOISY_REFLOW
|
#ifdef NOISY_REFLOW
|
||||||
nsFrame::ListTag(stdout, mBlockReflowState->frame);
|
nsFrame::ListTag(stdout, mBlockReflowState->frame);
|
||||||
printf(": UpdateBand: %d,%d,%d,%d deltaWidth=%d %s float\n",
|
printf(": UpdateBand: %d,%d,%d,%d deltaWidth=%d deltaX=%d %s float\n",
|
||||||
aX, aY, aWidth, aHeight, deltaWidth,
|
aNewAvailSpace.x, aNewAvailSpace.y,
|
||||||
|
aNewAvailSpace.width, aNewAvailSpace.height, deltaWidth, deltaX,
|
||||||
aPlacedLeftFloat ? "left" : "right");
|
aPlacedLeftFloat ? "left" : "right");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
psd->mLeftEdge = aX;
|
// Update the root span position
|
||||||
psd->mX = aX;
|
mRootSpan->mLeftEdge += deltaX;
|
||||||
psd->mRightEdge = aX + aWidth;
|
mRootSpan->mRightEdge += deltaX;
|
||||||
mTopEdge = aY;
|
mRootSpan->mX += deltaX;
|
||||||
SetFlag(LL_UPDATEDBAND, PR_TRUE);
|
|
||||||
|
// Now update the right edges of the open spans to account for any
|
||||||
|
// change in available space width
|
||||||
|
for (PerSpanData* psd = mCurrentSpan; psd; psd = psd->mParent) {
|
||||||
|
psd->mRightEdge += deltaWidth;
|
||||||
|
psd->mContainsFloat = PR_TRUE;
|
||||||
|
NS_ASSERTION(psd->mX <= psd->mRightEdge,
|
||||||
|
"We placed a float where there was no room!");
|
||||||
|
#ifdef NOISY_REFLOW
|
||||||
|
printf(" span %p: oldRightEdge=%d newRightEdge=%d\n",
|
||||||
|
psd, psd->mRightEdge - deltaRightEdge, psd->mRightEdge);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
NS_ASSERTION(mRootSpan->mContainsFloat &&
|
||||||
|
mRootSpan->mLeftEdge == aNewAvailSpace.x &&
|
||||||
|
mRootSpan->mRightEdge == aNewAvailSpace.XMost(),
|
||||||
|
"root span was updated incorrectly?");
|
||||||
|
|
||||||
|
// Update frame bounds
|
||||||
|
// Note: Only adjust the outermost frames (the ones that are direct
|
||||||
|
// children of the block), not the ones in the child spans. The reason
|
||||||
|
// is simple: the frames in the spans have coordinates local to their
|
||||||
|
// parent therefore they are moved when their parent span is moved.
|
||||||
|
if (deltaX != 0) {
|
||||||
|
for (PerFrameData* pfd = mRootSpan->mFirstFrame; pfd; pfd = pfd->mNext) {
|
||||||
|
pfd->mBounds.x += deltaX;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
mTopEdge = aNewAvailSpace.y;
|
||||||
mPlacedFloats |= (aPlacedLeftFloat ? PLACED_LEFT : PLACED_RIGHT);
|
mPlacedFloats |= (aPlacedLeftFloat ? PLACED_LEFT : PLACED_RIGHT);
|
||||||
SetFlag(LL_IMPACTEDBYFLOATS, PR_TRUE);
|
SetFlag(LL_IMPACTEDBYFLOATS, PR_TRUE);
|
||||||
|
|
||||||
SetFlag(LL_LASTFLOATWASLETTERFRAME,
|
SetFlag(LL_LASTFLOATWASLETTERFRAME,
|
||||||
nsGkAtoms::letterFrame == aFloatFrame->GetType());
|
nsGkAtoms::letterFrame == aFloatFrame->GetType());
|
||||||
|
|
||||||
// Now update all of the open spans...
|
|
||||||
mRootSpan->mContainsFloat = PR_TRUE; // make sure mRootSpan gets updated too
|
|
||||||
psd = mCurrentSpan;
|
|
||||||
while (psd != mRootSpan) {
|
|
||||||
NS_ASSERTION(nsnull != psd, "null ptr");
|
|
||||||
if (nsnull == psd) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
NS_ASSERTION(psd->mX == psd->mLeftEdge, "bad float placement");
|
|
||||||
psd->mRightEdge += deltaWidth;
|
|
||||||
psd->mContainsFloat = PR_TRUE;
|
|
||||||
#ifdef NOISY_REFLOW
|
|
||||||
printf(" span %p: oldRightEdge=%d newRightEdge=%d\n",
|
|
||||||
psd, psd->mRightEdge - deltaWidth, psd->mRightEdge);
|
|
||||||
#endif
|
|
||||||
psd = psd->mParent;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Note: Only adjust the outermost frames (the ones that are direct
|
|
||||||
// children of the block), not the ones in the child spans. The reason
|
|
||||||
// is simple: the frames in the spans have coordinates local to their
|
|
||||||
// parent therefore they are moved when their parent span is moved.
|
|
||||||
void
|
|
||||||
nsLineLayout::UpdateFrames()
|
|
||||||
{
|
|
||||||
NS_ASSERTION(nsnull != mRootSpan, "UpdateFrames with no active spans");
|
|
||||||
|
|
||||||
PerSpanData* psd = mRootSpan;
|
|
||||||
if (PLACED_LEFT & mPlacedFloats) {
|
|
||||||
PerFrameData* pfd = psd->mFirstFrame;
|
|
||||||
while (nsnull != pfd) {
|
|
||||||
pfd->mBounds.x = psd->mX;
|
|
||||||
pfd = pfd->mNext;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
@ -879,13 +874,14 @@ nsLineLayout::ReflowFrame(nsIFrame* aFrame,
|
|||||||
nsIFrame* outOfFlowFrame = nsLayoutUtils::GetFloatFromPlaceholder(aFrame);
|
nsIFrame* outOfFlowFrame = nsLayoutUtils::GetFloatFromPlaceholder(aFrame);
|
||||||
if (outOfFlowFrame) {
|
if (outOfFlowFrame) {
|
||||||
nsPlaceholderFrame* placeholder = static_cast<nsPlaceholderFrame*>(aFrame);
|
nsPlaceholderFrame* placeholder = static_cast<nsPlaceholderFrame*>(aFrame);
|
||||||
|
nscoord availableWidth = psd->mRightEdge - psd->mX;
|
||||||
// XXXldb What is this test supposed to be?
|
// XXXldb What is this test supposed to be?
|
||||||
if (!NS_SUBTREE_DIRTY(aFrame)) {
|
if (!NS_SUBTREE_DIRTY(aFrame)) {
|
||||||
// incremental reflow of child
|
// incremental reflow of child
|
||||||
placedFloat = InitFloat(placeholder, aReflowStatus);
|
placedFloat = InitFloat(placeholder, availableWidth, aReflowStatus);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
placedFloat = AddFloat(placeholder, aReflowStatus);
|
placedFloat = AddFloat(placeholder, availableWidth, aReflowStatus);
|
||||||
}
|
}
|
||||||
NS_ASSERTION(!(outOfFlowFrame->GetType() == nsGkAtoms::letterFrame &&
|
NS_ASSERTION(!(outOfFlowFrame->GetType() == nsGkAtoms::letterFrame &&
|
||||||
GetFirstLetterStyleOK()),
|
GetFirstLetterStyleOK()),
|
||||||
@ -1311,13 +1307,6 @@ nsLineLayout::PlaceFrame(PerFrameData* pfd, nsHTMLReflowMetrics& aMetrics)
|
|||||||
else
|
else
|
||||||
pfd->mAscent = aMetrics.ascent;
|
pfd->mAscent = aMetrics.ascent;
|
||||||
|
|
||||||
// If the band was updated during the reflow of that frame then we
|
|
||||||
// need to adjust any prior frames that were reflowed.
|
|
||||||
if (GetFlag(LL_UPDATEDBAND) && InBlockContext()) {
|
|
||||||
UpdateFrames();
|
|
||||||
SetFlag(LL_UPDATEDBAND, PR_FALSE);
|
|
||||||
}
|
|
||||||
|
|
||||||
PRBool ltr = (NS_STYLE_DIRECTION_LTR == pfd->mFrame->GetStyleVisibility()->mDirection);
|
PRBool ltr = (NS_STYLE_DIRECTION_LTR == pfd->mFrame->GetStyleVisibility()->mDirection);
|
||||||
// Advance to next X coordinate
|
// Advance to next X coordinate
|
||||||
psd->mX = pfd->mBounds.XMost() + (ltr ? pfd->mMargin.right : pfd->mMargin.left);
|
psd->mX = pfd->mBounds.XMost() + (ltr ? pfd->mMargin.right : pfd->mMargin.left);
|
||||||
|
@ -88,7 +88,17 @@ public:
|
|||||||
|
|
||||||
void EndLineReflow();
|
void EndLineReflow();
|
||||||
|
|
||||||
void UpdateBand(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight,
|
/**
|
||||||
|
* Called when a float has been placed. This method updates the
|
||||||
|
* inline frame and span data to account for any change in positions
|
||||||
|
* due to available space for the line boxes changing.
|
||||||
|
* @param aX/aY/aWidth/aHeight are the new available
|
||||||
|
* space rectangle, relative to the containing block.
|
||||||
|
* @param aPlacedLeftFloat whether we placed a left float or a right
|
||||||
|
* float to trigger the available space change
|
||||||
|
* @param aFloatFrame the float frame that was placed.
|
||||||
|
*/
|
||||||
|
void UpdateBand(const nsRect& aNewAvailableSpace,
|
||||||
PRBool aPlacedLeftFloat,
|
PRBool aPlacedLeftFloat,
|
||||||
nsIFrame* aFloatFrame);
|
nsIFrame* aFloatFrame);
|
||||||
|
|
||||||
@ -201,12 +211,17 @@ public:
|
|||||||
//----------------------------------------
|
//----------------------------------------
|
||||||
// Inform the line-layout about the presence of a floating frame
|
// Inform the line-layout about the presence of a floating frame
|
||||||
// XXX get rid of this: use get-frame-type?
|
// XXX get rid of this: use get-frame-type?
|
||||||
PRBool InitFloat(nsPlaceholderFrame* aFrame, nsReflowStatus& aReflowStatus) {
|
PRBool InitFloat(nsPlaceholderFrame* aFrame,
|
||||||
return mBlockRS->InitFloat(*this, aFrame, aReflowStatus);
|
nscoord aAvailableWidth,
|
||||||
|
nsReflowStatus& aReflowStatus) {
|
||||||
|
return mBlockRS->InitFloat(*this, aFrame, aAvailableWidth, aReflowStatus);
|
||||||
}
|
}
|
||||||
|
|
||||||
PRBool AddFloat(nsPlaceholderFrame* aFrame, nsReflowStatus& aReflowStatus) {
|
PRBool AddFloat(nsPlaceholderFrame* aFrame,
|
||||||
return mBlockRS->AddFloat(*this, aFrame, PR_FALSE, aReflowStatus);
|
nscoord aAvailableWidth,
|
||||||
|
nsReflowStatus& aReflowStatus) {
|
||||||
|
return mBlockRS->AddFloat(*this, aFrame, PR_FALSE,
|
||||||
|
aAvailableWidth, aReflowStatus);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetTrimmableWidth(nscoord aTrimmableWidth) {
|
void SetTrimmableWidth(nscoord aTrimmableWidth) {
|
||||||
@ -532,8 +547,6 @@ protected:
|
|||||||
void PlaceFrame(PerFrameData* pfd,
|
void PlaceFrame(PerFrameData* pfd,
|
||||||
nsHTMLReflowMetrics& aMetrics);
|
nsHTMLReflowMetrics& aMetrics);
|
||||||
|
|
||||||
void UpdateFrames();
|
|
||||||
|
|
||||||
void VerticalAlignFrames(PerSpanData* psd);
|
void VerticalAlignFrames(PerSpanData* psd);
|
||||||
|
|
||||||
void PlaceTopBottomFrames(PerSpanData* psd,
|
void PlaceTopBottomFrames(PerSpanData* psd,
|
||||||
|
@ -14,7 +14,6 @@ function boom()
|
|||||||
</script>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
<body onload="boom();">
|
<body onload="boom();">
|
||||||
<xul:box class="base" id="x" style="height:2em;">Hello</xul:box>
|
<xul:box class="base" id="x" style="height:2em;">Hello</xul:box>Kitty
|
||||||
Kitty
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
.orange { background: orange }
|
.orange { background: orange }
|
||||||
</style></head>
|
</style></head>
|
||||||
<body>
|
<body>
|
||||||
The orange box should only be as wide as its text.
|
The orange box should only be as wide as its text.<br>
|
||||||
<div class="float orange">foo</div>
|
<div class="float orange">foo</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
19
layout/reftests/bugs/50630-1-ref.html
Normal file
19
layout/reftests/bugs/50630-1-ref.html
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
<!DOCTYPE HTML>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<style>
|
||||||
|
.left { float:left; }
|
||||||
|
.right { float:right; }
|
||||||
|
.left, .right { width:50px; height:50px; background:yellow; }
|
||||||
|
p { overflow:auto; }
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body style="width:400px;">
|
||||||
|
<p><span class="left"></span>HelloKitty
|
||||||
|
<p><span class="right"></span>HelloKitty
|
||||||
|
<p dir="rtl"><span class="left"></span>HelloKitty
|
||||||
|
<p dir="rtl"><span class="right"></span>HelloKitty
|
||||||
|
<p style="text-align:right;"><span class="left"></span>HelloKitty
|
||||||
|
<p style="text-align:right;"><span class="right"></span>HelloKitty
|
||||||
|
</body>
|
||||||
|
</html>
|
19
layout/reftests/bugs/50630-1a.html
Normal file
19
layout/reftests/bugs/50630-1a.html
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
<!DOCTYPE HTML>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<style>
|
||||||
|
.left { float:left; }
|
||||||
|
.right { float:right; }
|
||||||
|
.left, .right { width:50px; height:50px; background:yellow; }
|
||||||
|
p { overflow:auto; }
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body style="width:400px;">
|
||||||
|
<p>Hello<span class="left"></span>Kitty
|
||||||
|
<p>Hello<span class="right"></span>Kitty
|
||||||
|
<p dir="rtl">Hello<span class="left"></span>Kitty
|
||||||
|
<p dir="rtl">Hello<span class="right"></span>Kitty
|
||||||
|
<p style="text-align:right;">Hello<span class="left"></span>Kitty
|
||||||
|
<p style="text-align:right;">Hello<span class="right"></span>Kitty
|
||||||
|
</body>
|
||||||
|
</html>
|
19
layout/reftests/bugs/50630-1b.html
Normal file
19
layout/reftests/bugs/50630-1b.html
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
<!DOCTYPE HTML>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<style>
|
||||||
|
.left { float:left; }
|
||||||
|
.right { float:right; }
|
||||||
|
.left, .right { width:50px; height:50px; background:yellow; }
|
||||||
|
p { overflow:auto; }
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body style="width:400px">
|
||||||
|
<p><span>Hello<span class="left"></span></span>Kitty
|
||||||
|
<p><span>Hello<span class="right"></span></span>Kitty
|
||||||
|
<p dir="rtl"><span>Hello<span class="left"></span></span>Kitty
|
||||||
|
<p dir="rtl"><span>Hello<span class="right"></span></span>Kitty
|
||||||
|
<p style="text-align:right;"><span>Hello<span class="left"></span></span>Kitty
|
||||||
|
<p style="text-align:right;"><span>Hello<span class="right"></span></span>Kitty
|
||||||
|
</body>
|
||||||
|
</html>
|
19
layout/reftests/bugs/50630-1c.html
Normal file
19
layout/reftests/bugs/50630-1c.html
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
<!DOCTYPE HTML>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<style>
|
||||||
|
.left { float:left; }
|
||||||
|
.right { float:right; }
|
||||||
|
.left, .right { width:50px; height:50px; background:yellow; }
|
||||||
|
p { overflow:auto; }
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body style="width:400px;">
|
||||||
|
<p>Hello<span><span class="left"></span>Kitty</span>
|
||||||
|
<p>Hello<span><span class="right"></span>Kitty</span>
|
||||||
|
<p dir="rtl">Hello<span><span class="left"></span>Kitty</span>
|
||||||
|
<p dir="rtl">Hello<span><span class="right"></span>Kitty</span>
|
||||||
|
<p style="text-align:right;">Hello<span><span class="left"></span>Kitty</span>
|
||||||
|
<p style="text-align:right;">Hello<span><span class="right"></span>Kitty</span>
|
||||||
|
</body>
|
||||||
|
</html>
|
17
layout/reftests/bugs/50630-2-ref.html
Normal file
17
layout/reftests/bugs/50630-2-ref.html
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
<html>
|
||||||
|
<body style="width:400px;">
|
||||||
|
<div style="float:left; width:200px; height:100px; background:yellow;"></div>
|
||||||
|
Hello
|
||||||
|
<table style="width:200px;"><tr><td>
|
||||||
|
This is some very long text. This is some very long text.
|
||||||
|
This is some very long text. This is some very long text.
|
||||||
|
This is some very long text. This is some very long text.
|
||||||
|
This is some very long text. This is some very long text.
|
||||||
|
This is some very long text. This is some very long text.
|
||||||
|
This is some very long text. This is some very long text.
|
||||||
|
This is some very long text. This is some very long text.
|
||||||
|
This is some very long text. This is some very long text.
|
||||||
|
This is some very long text. This is some very long text.
|
||||||
|
</table>
|
||||||
|
</body>
|
||||||
|
</html>
|
17
layout/reftests/bugs/50630-2.html
Normal file
17
layout/reftests/bugs/50630-2.html
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
<html>
|
||||||
|
<body style="width:400px;">
|
||||||
|
<div style="float:left; width:200px; height:100px; background:yellow;"></div>
|
||||||
|
Hello
|
||||||
|
<table style="float:left;"><tr><td>
|
||||||
|
This is some very long text. This is some very long text.
|
||||||
|
This is some very long text. This is some very long text.
|
||||||
|
This is some very long text. This is some very long text.
|
||||||
|
This is some very long text. This is some very long text.
|
||||||
|
This is some very long text. This is some very long text.
|
||||||
|
This is some very long text. This is some very long text.
|
||||||
|
This is some very long text. This is some very long text.
|
||||||
|
This is some very long text. This is some very long text.
|
||||||
|
This is some very long text. This is some very long text.
|
||||||
|
</table>
|
||||||
|
</body>
|
||||||
|
</html>
|
10
layout/reftests/bugs/50630-3-ref.html
Normal file
10
layout/reftests/bugs/50630-3-ref.html
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<!DOCTYPE HTML>
|
||||||
|
<html>
|
||||||
|
<body style="width:100px; font-size:5px;">
|
||||||
|
<!-- Check that we don't allow floats to reorder -->
|
||||||
|
H
|
||||||
|
<div style="background:blue; width:100px; height:100px;"></div>
|
||||||
|
<div style="background:yellow; width:30px; height:30px; float:left;"></div>
|
||||||
|
<div style="background:yellow; width:30px; height:30px; float:right;"></div>
|
||||||
|
</body>
|
||||||
|
</html>
|
10
layout/reftests/bugs/50630-3.html
Normal file
10
layout/reftests/bugs/50630-3.html
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<!DOCTYPE HTML>
|
||||||
|
<html>
|
||||||
|
<body style="width:100px; font-size:5px;">
|
||||||
|
<!-- Check that we don't allow floats to reorder -->
|
||||||
|
H
|
||||||
|
<div style="background:blue; width:100px; height:100px; float:left;"></div>
|
||||||
|
<div style="background:yellow; width:30px; height:30px; float:left;"></div>
|
||||||
|
<div style="background:yellow; width:30px; height:30px; float:right;"></div>
|
||||||
|
</body>
|
||||||
|
</html>
|
8
layout/reftests/bugs/50630-4-ref.html
Normal file
8
layout/reftests/bugs/50630-4-ref.html
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
<!DOCTYPE HTML>
|
||||||
|
<html>
|
||||||
|
<body style="width:200px; font-size:5px;">
|
||||||
|
<div style="background:green; width:100px; height:100px; float:left;"></div>
|
||||||
|
H<br>
|
||||||
|
<div style="background:blue; width:100px; height:100px; float:left;"></div>
|
||||||
|
</body>
|
||||||
|
</html>
|
10
layout/reftests/bugs/50630-4-ref2.html
Normal file
10
layout/reftests/bugs/50630-4-ref2.html
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<!DOCTYPE HTML>
|
||||||
|
<html>
|
||||||
|
<body style="width:200px; font-size:5px;">
|
||||||
|
<div style="position:absolute; background:green; width:100px; height:100px;"></div>
|
||||||
|
<div style="position:relative; left:100px; width:100px; height:100px;">
|
||||||
|
H
|
||||||
|
<div style="background:blue; width:100px; height:100px;"></div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
10
layout/reftests/bugs/50630-4.html
Normal file
10
layout/reftests/bugs/50630-4.html
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<!DOCTYPE HTML>
|
||||||
|
<html>
|
||||||
|
<body style="width:200px; font-size:5px;">
|
||||||
|
<!-- Check that we're actually taking inline content already in the line into account
|
||||||
|
when we check whether the blue float fits -->
|
||||||
|
<div style="background:green; width:100px; height:100px; float:left;"></div>
|
||||||
|
H
|
||||||
|
<div style="background:blue; width:100px; height:100px; float:left;"></div>
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -57,6 +57,13 @@ fails == 25888-3r.html 25888-3r-ref.html # bug 25888
|
|||||||
!= 40596-1h.html 40596-1-ref.html
|
!= 40596-1h.html 40596-1-ref.html
|
||||||
== 40596-1i.html 40596-1-ref.html
|
== 40596-1i.html 40596-1-ref.html
|
||||||
!= 40596-1j.html 40596-1-ref.html
|
!= 40596-1j.html 40596-1-ref.html
|
||||||
|
== 50630-1a.html 50630-1-ref.html
|
||||||
|
== 50630-1b.html 50630-1-ref.html
|
||||||
|
== 50630-1c.html 50630-1-ref.html
|
||||||
|
== 50630-2.html 50630-2-ref.html
|
||||||
|
== 50630-3.html 50630-3-ref.html
|
||||||
|
== 50630-4.html 50630-4-ref.html
|
||||||
|
== 50630-4.html 50630-4-ref2.html
|
||||||
== 84400-1.html 84400-1-ref.html
|
== 84400-1.html 84400-1-ref.html
|
||||||
== 84400-2.html 84400-2-ref.html
|
== 84400-2.html 84400-2-ref.html
|
||||||
== 97777-1.html 97777-1-ref.html
|
== 97777-1.html 97777-1-ref.html
|
||||||
|
Loading…
Reference in New Issue
Block a user