From 774e1563259e112ea9133d5699e92ac05d22a7ab Mon Sep 17 00:00:00 2001 From: "uriber%gmail.com" Date: Wed, 13 Dec 2006 16:16:25 +0000 Subject: [PATCH] Use the containing block's direction (LTR/RTL) instead of this frame's direction when deciding on default alignment of the frame. bug=328181 r+sr=dbaron git-svn-id: svn://10.0.0.236/trunk@216942 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/layout/forms/nsLegendFrame.cpp | 2 +- mozilla/layout/generic/nsHTMLReflowState.cpp | 25 ++++++++++---------- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/mozilla/layout/forms/nsLegendFrame.cpp b/mozilla/layout/forms/nsLegendFrame.cpp index 68d9035427c..a3c8ecc2ca8 100644 --- a/mozilla/layout/forms/nsLegendFrame.cpp +++ b/mozilla/layout/forms/nsLegendFrame.cpp @@ -113,7 +113,7 @@ PRInt32 nsLegendFrame::GetAlign() { PRInt32 intValue = NS_STYLE_TEXT_ALIGN_LEFT; #ifdef IBMBIDI - if (NS_STYLE_DIRECTION_RTL == GetStyleVisibility()->mDirection) { + if (mParent && NS_STYLE_DIRECTION_RTL == mParent->GetStyleVisibility()->mDirection) { intValue = NS_STYLE_TEXT_ALIGN_RIGHT; } #endif // IBMBIDI diff --git a/mozilla/layout/generic/nsHTMLReflowState.cpp b/mozilla/layout/generic/nsHTMLReflowState.cpp index 38c831fdd27..79248c81490 100644 --- a/mozilla/layout/generic/nsHTMLReflowState.cpp +++ b/mozilla/layout/generic/nsHTMLReflowState.cpp @@ -450,12 +450,11 @@ nsHTMLReflowState::ComputeRelativeOffsets(const nsHTMLReflowState* cbrs, // If neither 'left' not 'right' are auto, then we're over-constrained and // we ignore one of them if (!leftIsAuto && !rightIsAuto) { - const nsStyleVisibility* vis = frame->GetStyleVisibility(); - - if (NS_STYLE_DIRECTION_LTR == vis->mDirection) { - rightIsAuto = PR_TRUE; - } else { + if (mCBReflowState && + NS_STYLE_DIRECTION_RTL == mCBReflowState->mStyleVisibility->mDirection) { leftIsAuto = PR_TRUE; + } else { + rightIsAuto = PR_TRUE; } } @@ -971,7 +970,7 @@ nsHTMLReflowState::InitAbsoluteConstraints(nsPresContext* aPresContext, mComputedOffsets.right); } - PRUint8 direction = mStyleVisibility->mDirection; + PRUint8 direction = cbrs ? cbrs->mStyleVisibility->mDirection : NS_STYLE_DIRECTION_LTR; // Use the horizontal component of the hypothetical box in the cases // where it's needed. @@ -1733,10 +1732,11 @@ nsHTMLReflowState::CalculateBlockSideMargins(nscoord aAvailWidth, // If the available margin space is negative, then don't follow the // usual overconstraint rules. if (availMarginSpace < 0) { - if (mStyleVisibility->mDirection == NS_STYLE_DIRECTION_LTR) { - mComputedMargin.right += availMarginSpace; - } else { + if (mCBReflowState && + mCBReflowState->mStyleVisibility->mDirection == NS_STYLE_DIRECTION_RTL) { mComputedMargin.left += availMarginSpace; + } else { + mComputedMargin.right += availMarginSpace; } return; } @@ -1771,11 +1771,12 @@ nsHTMLReflowState::CalculateBlockSideMargins(nscoord aAvailWidth, } // Otherwise apply the CSS rules, and ignore one margin by forcing // it to 'auto', depending on 'direction'. - else if (NS_STYLE_DIRECTION_LTR == mStyleVisibility->mDirection) { - isAutoRightMargin = PR_TRUE; + else if (mCBReflowState && + NS_STYLE_DIRECTION_RTL == mCBReflowState->mStyleVisibility->mDirection) { + isAutoLeftMargin = PR_TRUE; } else { - isAutoLeftMargin = PR_TRUE; + isAutoRightMargin = PR_TRUE; } }