From 4e92a7e798f27e8786bf67bab638720217407474 Mon Sep 17 00:00:00 2001 From: "nisheeth%netscape.com" Date: Sat, 8 May 1999 00:48:39 +0000 Subject: [PATCH] Adding support in line layout for the CSS "direction" property. git-svn-id: svn://10.0.0.236/trunk@30798 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/layout/generic/nsLineLayout.cpp | 16 ++++++++++++++++ mozilla/layout/generic/nsLineLayout.h | 1 + mozilla/layout/html/base/src/nsLineLayout.cpp | 16 ++++++++++++++++ mozilla/layout/html/base/src/nsLineLayout.h | 1 + 4 files changed, 34 insertions(+) diff --git a/mozilla/layout/generic/nsLineLayout.cpp b/mozilla/layout/generic/nsLineLayout.cpp index 8a2a32da27f..0a3fdfea9f8 100644 --- a/mozilla/layout/generic/nsLineLayout.cpp +++ b/mozilla/layout/generic/nsLineLayout.cpp @@ -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; + } + } } } diff --git a/mozilla/layout/generic/nsLineLayout.h b/mozilla/layout/generic/nsLineLayout.h index 8c2ade7c60f..d1b5636dcf6 100644 --- a/mozilla/layout/generic/nsLineLayout.h +++ b/mozilla/layout/generic/nsLineLayout.h @@ -296,6 +296,7 @@ public: const nsHTMLReflowState* mReflowState; PRBool mNoWrap; PRUint8 mDirection; + PRBool mChangedFrameDirection; nscoord mLeftEdge; nscoord mX; diff --git a/mozilla/layout/html/base/src/nsLineLayout.cpp b/mozilla/layout/html/base/src/nsLineLayout.cpp index 8a2a32da27f..0a3fdfea9f8 100644 --- a/mozilla/layout/html/base/src/nsLineLayout.cpp +++ b/mozilla/layout/html/base/src/nsLineLayout.cpp @@ -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; + } + } } } diff --git a/mozilla/layout/html/base/src/nsLineLayout.h b/mozilla/layout/html/base/src/nsLineLayout.h index 8c2ade7c60f..d1b5636dcf6 100644 --- a/mozilla/layout/html/base/src/nsLineLayout.h +++ b/mozilla/layout/html/base/src/nsLineLayout.h @@ -296,6 +296,7 @@ public: const nsHTMLReflowState* mReflowState; PRBool mNoWrap; PRUint8 mDirection; + PRBool mChangedFrameDirection; nscoord mLeftEdge; nscoord mX;