Adding support in line layout for the CSS "direction" property.

This commit is contained in:
nisheeth%netscape.com 1999-05-08 00:48:39 +00:00
parent 1f0eea254c
commit aa6ad6f2fe
4 changed files with 34 additions and 0 deletions

View File

@ -250,6 +250,7 @@ nsLineLayout::BeginLineReflow(nscoord aX, nscoord aY,
break;
}
psd->mDirection = mBlockReflowState->mStyleDisplay->mDirection;
psd->mChangedFrameDirection = PR_FALSE;
}
void
@ -461,6 +462,7 @@ nsLineLayout::BeginSpan(nsIFrame* aFrame,
break;
}
psd->mDirection = aSpanReflowState->mStyleDisplay->mDirection;
psd->mChangedFrameDirection = PR_FALSE;
// Switch to new span
mCurrentSpan = psd;
@ -1900,6 +1902,20 @@ nsLineLayout::HorizontalAlignFrames(nsRect& aLineBounds, PRBool aAllowJustify)
pfd = pfd->mNext;
}
}
if (NS_STYLE_DIRECTION_RTL == psd->mDirection && !psd->mChangedFrameDirection) {
psd->mChangedFrameDirection = PR_TRUE;
/* Assume that all frames have been right aligned.*/
PerFrameData* pfd = psd->mFirstFrame;
PRUint32 maxX = psd->mRightEdge;
while (nsnull != pfd) {
pfd->mBounds.x = maxX - pfd->mBounds.width;
pfd->mFrame->SetRect(pfd->mBounds);
maxX = pfd->mBounds.x;
pfd = pfd->mNext;
}
}
}
}

View File

@ -296,6 +296,7 @@ public:
const nsHTMLReflowState* mReflowState;
PRBool mNoWrap;
PRUint8 mDirection;
PRBool mChangedFrameDirection;
nscoord mLeftEdge;
nscoord mX;

View File

@ -250,6 +250,7 @@ nsLineLayout::BeginLineReflow(nscoord aX, nscoord aY,
break;
}
psd->mDirection = mBlockReflowState->mStyleDisplay->mDirection;
psd->mChangedFrameDirection = PR_FALSE;
}
void
@ -461,6 +462,7 @@ nsLineLayout::BeginSpan(nsIFrame* aFrame,
break;
}
psd->mDirection = aSpanReflowState->mStyleDisplay->mDirection;
psd->mChangedFrameDirection = PR_FALSE;
// Switch to new span
mCurrentSpan = psd;
@ -1900,6 +1902,20 @@ nsLineLayout::HorizontalAlignFrames(nsRect& aLineBounds, PRBool aAllowJustify)
pfd = pfd->mNext;
}
}
if (NS_STYLE_DIRECTION_RTL == psd->mDirection && !psd->mChangedFrameDirection) {
psd->mChangedFrameDirection = PR_TRUE;
/* Assume that all frames have been right aligned.*/
PerFrameData* pfd = psd->mFirstFrame;
PRUint32 maxX = psd->mRightEdge;
while (nsnull != pfd) {
pfd->mBounds.x = maxX - pfd->mBounds.width;
pfd->mFrame->SetRect(pfd->mBounds);
maxX = pfd->mBounds.x;
pfd = pfd->mNext;
}
}
}
}

View File

@ -296,6 +296,7 @@ public:
const nsHTMLReflowState* mReflowState;
PRBool mNoWrap;
PRUint8 mDirection;
PRBool mChangedFrameDirection;
nscoord mLeftEdge;
nscoord mX;