diff --git a/mozilla/layout/base/nsBidiPresUtils.cpp b/mozilla/layout/base/nsBidiPresUtils.cpp index 753519327d2..ed1b8a08b8a 100644 --- a/mozilla/layout/base/nsBidiPresUtils.cpp +++ b/mozilla/layout/base/nsBidiPresUtils.cpp @@ -151,7 +151,8 @@ nsresult nsBidiPresUtils::Resolve(nsIPresContext* aPresContext, nsIFrame* aBlockFrame, nsIFrame* aFirstChild, - PRBool& aForceReflow) + PRBool& aForceReflow, + PRBool aIsVisualFormControl) { aForceReflow = PR_FALSE; mLogicalFrames.Clear(); @@ -211,8 +212,11 @@ nsBidiPresUtils::Resolve(nsIPresContext* aPresContext, } PRBool isVisual; - aPresContext->IsVisualMode(isVisual); - + if (aIsVisualFormControl) { + isVisual = PR_FALSE; + } else { + aPresContext->IsVisualMode(isVisual); + } mSuccess = mBidiEngine->CountRuns(&runCount); if (NS_FAILED(mSuccess) ) { return mSuccess; diff --git a/mozilla/layout/base/nsBidiPresUtils.h b/mozilla/layout/base/nsBidiPresUtils.h index 2eb7804d6af..c5281827b87 100644 --- a/mozilla/layout/base/nsBidiPresUtils.h +++ b/mozilla/layout/base/nsBidiPresUtils.h @@ -46,7 +46,8 @@ public: nsresult Resolve(nsIPresContext* aPresContext, nsIFrame* aBlockFrame, nsIFrame* aFirstChild, - PRBool& aForceReflow); + PRBool& aForceReflow, + PRBool aIsVisualFormControl); /** * Reorder this line using Bidi engine. diff --git a/mozilla/layout/base/public/nsBidiPresUtils.h b/mozilla/layout/base/public/nsBidiPresUtils.h index 2eb7804d6af..c5281827b87 100644 --- a/mozilla/layout/base/public/nsBidiPresUtils.h +++ b/mozilla/layout/base/public/nsBidiPresUtils.h @@ -46,7 +46,8 @@ public: nsresult Resolve(nsIPresContext* aPresContext, nsIFrame* aBlockFrame, nsIFrame* aFirstChild, - PRBool& aForceReflow); + PRBool& aForceReflow, + PRBool aIsVisualFormControl); /** * Reorder this line using Bidi engine. diff --git a/mozilla/layout/base/public/nsHTMLReflowState.h b/mozilla/layout/base/public/nsHTMLReflowState.h index 644fc322299..81d6b96234b 100644 --- a/mozilla/layout/base/public/nsHTMLReflowState.h +++ b/mozilla/layout/base/public/nsHTMLReflowState.h @@ -248,7 +248,8 @@ struct nsHTMLReflowState { // percent height frames inside cells which may not have computed heights PRUint16 mIsTopOfPage:1; // is the current context at the top of a page? PRUint16 mBlinks:1; // Keep track of text-decoration: blink - PRUint16 mUnused:13; // for future use + PRUint16 mVisualBidiFormControl:1; // Keep track of descendants of form controls on Visual Bidi pages + PRUint16 mUnused:12; // for future use } mFlags; #ifdef IBMBIDI @@ -441,6 +442,18 @@ protected: // the width/height and it is removed due to box sizing) then it is driven to 0 void AdjustComputedHeight(void); void AdjustComputedWidth(void); + +#ifdef IBMBIDI + /** + * Test whether the frame is a form control in a visual Bidi page. + * This is necessary for backwards-compatibility, because most visual + * pages use logical order for form controls so that they will + * display correctly on native widgets in OSs with Bidi support + * @param aPresContext the pres context + * @return whether the frame is a BIDI form control + */ + PRBool IsBidiFormControl(nsIPresContext* aPresContext); +#endif }; #endif /* nsHTMLReflowState_h___ */ diff --git a/mozilla/layout/base/src/nsBidiPresUtils.cpp b/mozilla/layout/base/src/nsBidiPresUtils.cpp index 753519327d2..ed1b8a08b8a 100644 --- a/mozilla/layout/base/src/nsBidiPresUtils.cpp +++ b/mozilla/layout/base/src/nsBidiPresUtils.cpp @@ -151,7 +151,8 @@ nsresult nsBidiPresUtils::Resolve(nsIPresContext* aPresContext, nsIFrame* aBlockFrame, nsIFrame* aFirstChild, - PRBool& aForceReflow) + PRBool& aForceReflow, + PRBool aIsVisualFormControl) { aForceReflow = PR_FALSE; mLogicalFrames.Clear(); @@ -211,8 +212,11 @@ nsBidiPresUtils::Resolve(nsIPresContext* aPresContext, } PRBool isVisual; - aPresContext->IsVisualMode(isVisual); - + if (aIsVisualFormControl) { + isVisual = PR_FALSE; + } else { + aPresContext->IsVisualMode(isVisual); + } mSuccess = mBidiEngine->CountRuns(&runCount); if (NS_FAILED(mSuccess) ) { return mSuccess; diff --git a/mozilla/layout/generic/nsBlockFrame.cpp b/mozilla/layout/generic/nsBlockFrame.cpp index 5fc9a365770..8968b8bbe9a 100644 --- a/mozilla/layout/generic/nsBlockFrame.cpp +++ b/mozilla/layout/generic/nsBlockFrame.cpp @@ -832,7 +832,8 @@ nsBlockFrame::Reflow(nsIPresContext* aPresContext, PRBool forceReflow; nsresult rc = bidiUtils->Resolve(aPresContext, this, mLines.front()->mFirstChild, - forceReflow); + forceReflow, + aReflowState.mFlags.mVisualBidiFormControl); if (NS_SUCCEEDED(rc) && forceReflow) { // Mark everything dirty // XXXldb This should be done right. diff --git a/mozilla/layout/generic/nsHTMLReflowState.cpp b/mozilla/layout/generic/nsHTMLReflowState.cpp index ed818c4de79..1136f8781ca 100644 --- a/mozilla/layout/generic/nsHTMLReflowState.cpp +++ b/mozilla/layout/generic/nsHTMLReflowState.cpp @@ -51,6 +51,9 @@ #include "nsIPref.h" #include "nsIServiceManager.h" #include "nsIPercentHeightObserver.h" +#ifdef IBMBIDI +#include "nsBidiUtils.h" +#endif #define IS_TABLE_CELL(frameType)\ ((nsLayoutAtoms::tableCellFrame == frameType) || (nsLayoutAtoms::bcTableCellFrame == frameType)) @@ -133,6 +136,7 @@ nsHTMLReflowState::nsHTMLReflowState(nsIPresContext* aPresContext, mPercentHeightReflowInitiator = nsnull; Init(aPresContext); #ifdef IBMBIDI + mFlags.mVisualBidiFormControl = IsBidiFormControl(aPresContext); mRightEdge = NS_UNCONSTRAINEDSIZE; #endif } @@ -163,6 +167,7 @@ nsHTMLReflowState::nsHTMLReflowState(nsIPresContext* aPresContext, mPercentHeightReflowInitiator = nsnull; Init(aPresContext); #ifdef IBMBIDI + mFlags.mVisualBidiFormControl = IsBidiFormControl(aPresContext); mRightEdge = NS_UNCONSTRAINEDSIZE; #endif // IBMBIDI } @@ -209,6 +214,8 @@ nsHTMLReflowState::nsHTMLReflowState(nsIPresContext* aPresContext, } #ifdef IBMBIDI + mFlags.mVisualBidiFormControl = (aParentReflowState.mFlags.mVisualBidiFormControl) ? + PR_TRUE : IsBidiFormControl(aPresContext); mRightEdge = aParentReflowState.mRightEdge; #endif // IBMBIDI } @@ -250,6 +257,8 @@ nsHTMLReflowState::nsHTMLReflowState(nsIPresContext* aPresContext, Init(aPresContext); #ifdef IBMBIDI + mFlags.mVisualBidiFormControl = (aParentReflowState.mFlags.mVisualBidiFormControl) ? + PR_TRUE : IsBidiFormControl(aPresContext); mRightEdge = aParentReflowState.mRightEdge; #endif // IBMBIDI } @@ -293,6 +302,8 @@ nsHTMLReflowState::nsHTMLReflowState(nsIPresContext* aPresContext, Init(aPresContext, aContainingBlockWidth, aContainingBlockHeight); #ifdef IBMBIDI + mFlags.mVisualBidiFormControl = (aParentReflowState.mFlags.mVisualBidiFormControl) ? + PR_TRUE : IsBidiFormControl(aPresContext); mRightEdge = aParentReflowState.mRightEdge; #endif // IBMBIDI } @@ -2745,3 +2756,57 @@ void nsHTMLReflowState::AdjustComputedWidth(void) if(mComputedWidth<0) mComputedWidth = 0; } } +#ifdef IBMBIDI +PRBool +nsHTMLReflowState::IsBidiFormControl(nsIPresContext* aPresContext) +{ + // This check is only necessary on visual bidi pages, because most + // visual pages use logical order for form controls so that they will + // display correctly on native widgets in OSs with Bidi support. + // So bail out if the page is not Bidi, or not visual, or if the pref is + // set to use visual order on forms in visual pages + PRBool bidiEnabled; + aPresContext->GetBidiEnabled(&bidiEnabled); + if (!bidiEnabled) { + return PR_FALSE; + } + + PRBool isVisual; + aPresContext->IsVisualMode(isVisual); + if (!isVisual) { + return PR_FALSE; + } + + PRUint32 options; + aPresContext->GetBidi(&options); + if (IBMBIDI_CONTROLSTEXTMODE_LOGICAL != GET_BIDI_OPTION_CONTROLSTEXTMODE(options)) { + return PR_FALSE; + } + + nsCOMPtr content, parent; + nsresult rv = frame->GetContent(getter_AddRefs(content) ); + if (NS_FAILED(rv)) { + return PR_FALSE; + } + if (!content) { + return PR_FALSE; + } + + // If this is a root reflow, we have to walk up the content tree to + // find out if the reflow root is a descendant of a form control. + // Otherwise, just test this content node + if (mReflowDepth == 0) { + while (content) { + if (content->IsContentOfType(nsIContent::eHTML_FORM_CONTROL)) { + return PR_TRUE; + } + content->GetParent(*getter_AddRefs(parent)); + content = parent; + } + } else { + return (content->IsContentOfType(nsIContent::eHTML_FORM_CONTROL)); + } + + return PR_FALSE; +} +#endif diff --git a/mozilla/layout/generic/nsHTMLReflowState.h b/mozilla/layout/generic/nsHTMLReflowState.h index 644fc322299..81d6b96234b 100644 --- a/mozilla/layout/generic/nsHTMLReflowState.h +++ b/mozilla/layout/generic/nsHTMLReflowState.h @@ -248,7 +248,8 @@ struct nsHTMLReflowState { // percent height frames inside cells which may not have computed heights PRUint16 mIsTopOfPage:1; // is the current context at the top of a page? PRUint16 mBlinks:1; // Keep track of text-decoration: blink - PRUint16 mUnused:13; // for future use + PRUint16 mVisualBidiFormControl:1; // Keep track of descendants of form controls on Visual Bidi pages + PRUint16 mUnused:12; // for future use } mFlags; #ifdef IBMBIDI @@ -441,6 +442,18 @@ protected: // the width/height and it is removed due to box sizing) then it is driven to 0 void AdjustComputedHeight(void); void AdjustComputedWidth(void); + +#ifdef IBMBIDI + /** + * Test whether the frame is a form control in a visual Bidi page. + * This is necessary for backwards-compatibility, because most visual + * pages use logical order for form controls so that they will + * display correctly on native widgets in OSs with Bidi support + * @param aPresContext the pres context + * @return whether the frame is a BIDI form control + */ + PRBool IsBidiFormControl(nsIPresContext* aPresContext); +#endif }; #endif /* nsHTMLReflowState_h___ */ diff --git a/mozilla/layout/generic/nsLineLayout.cpp b/mozilla/layout/generic/nsLineLayout.cpp index 4be7dd2e866..28e43d4b574 100644 --- a/mozilla/layout/generic/nsLineLayout.cpp +++ b/mozilla/layout/generic/nsLineLayout.cpp @@ -62,7 +62,6 @@ #include "nsTextFragment.h" #ifdef IBMBIDI #include "nsBidiUtils.h" -#include "nsIFormControlFrame.h" #include "nsITextFrame.h" #define FIX_FOR_BUG_40882 #endif // IBMBIDI @@ -1048,30 +1047,12 @@ nsLineLayout::ReflowFrame(nsIFrame* aFrame, #ifdef IBMBIDI PRBool bidiEnabled; mPresContext->GetBidiEnabled(&bidiEnabled); - PRBool visual; - PRBool setMode = PR_FALSE; PRInt32 start, end; if (bidiEnabled) { if (state & NS_FRAME_IS_BIDI) { aFrame->GetOffsets(start, end); } - else { - nsCOMPtr formFrame(do_QueryInterface(aFrame) ); - if (formFrame) { - mPresContext->IsVisualMode(visual); - - PRUint32 options; - mPresContext->GetBidi(&options); - if ( (IBMBIDI_CONTROLSTEXTMODE_VISUAL == GET_BIDI_OPTION_CONTROLSTEXTMODE(options) - && !visual) - || (IBMBIDI_CONTROLSTEXTMODE_LOGICAL == GET_BIDI_OPTION_CONTROLSTEXTMODE(options) - && visual) ) { - mPresContext->SetVisualMode(!visual); - setMode = PR_TRUE; - } - } - } } #endif // IBMBIDI @@ -1084,12 +1065,6 @@ nsLineLayout::ReflowFrame(nsIFrame* aFrame, return rv; } -#ifdef IBMBIDI - if (setMode) { - mPresContext->SetVisualMode(visual); - } -#endif // IBMBIDI - // SEC: added this next block for bug 45152 // text frames don't know how to invalidate themselves on initial reflow. Do it for them here. // This only shows up in textareas, so do a quick check to see if we're inside one diff --git a/mozilla/layout/html/base/src/nsBlockFrame.cpp b/mozilla/layout/html/base/src/nsBlockFrame.cpp index 5fc9a365770..8968b8bbe9a 100644 --- a/mozilla/layout/html/base/src/nsBlockFrame.cpp +++ b/mozilla/layout/html/base/src/nsBlockFrame.cpp @@ -832,7 +832,8 @@ nsBlockFrame::Reflow(nsIPresContext* aPresContext, PRBool forceReflow; nsresult rc = bidiUtils->Resolve(aPresContext, this, mLines.front()->mFirstChild, - forceReflow); + forceReflow, + aReflowState.mFlags.mVisualBidiFormControl); if (NS_SUCCEEDED(rc) && forceReflow) { // Mark everything dirty // XXXldb This should be done right. diff --git a/mozilla/layout/html/base/src/nsHTMLReflowState.cpp b/mozilla/layout/html/base/src/nsHTMLReflowState.cpp index ed818c4de79..1136f8781ca 100644 --- a/mozilla/layout/html/base/src/nsHTMLReflowState.cpp +++ b/mozilla/layout/html/base/src/nsHTMLReflowState.cpp @@ -51,6 +51,9 @@ #include "nsIPref.h" #include "nsIServiceManager.h" #include "nsIPercentHeightObserver.h" +#ifdef IBMBIDI +#include "nsBidiUtils.h" +#endif #define IS_TABLE_CELL(frameType)\ ((nsLayoutAtoms::tableCellFrame == frameType) || (nsLayoutAtoms::bcTableCellFrame == frameType)) @@ -133,6 +136,7 @@ nsHTMLReflowState::nsHTMLReflowState(nsIPresContext* aPresContext, mPercentHeightReflowInitiator = nsnull; Init(aPresContext); #ifdef IBMBIDI + mFlags.mVisualBidiFormControl = IsBidiFormControl(aPresContext); mRightEdge = NS_UNCONSTRAINEDSIZE; #endif } @@ -163,6 +167,7 @@ nsHTMLReflowState::nsHTMLReflowState(nsIPresContext* aPresContext, mPercentHeightReflowInitiator = nsnull; Init(aPresContext); #ifdef IBMBIDI + mFlags.mVisualBidiFormControl = IsBidiFormControl(aPresContext); mRightEdge = NS_UNCONSTRAINEDSIZE; #endif // IBMBIDI } @@ -209,6 +214,8 @@ nsHTMLReflowState::nsHTMLReflowState(nsIPresContext* aPresContext, } #ifdef IBMBIDI + mFlags.mVisualBidiFormControl = (aParentReflowState.mFlags.mVisualBidiFormControl) ? + PR_TRUE : IsBidiFormControl(aPresContext); mRightEdge = aParentReflowState.mRightEdge; #endif // IBMBIDI } @@ -250,6 +257,8 @@ nsHTMLReflowState::nsHTMLReflowState(nsIPresContext* aPresContext, Init(aPresContext); #ifdef IBMBIDI + mFlags.mVisualBidiFormControl = (aParentReflowState.mFlags.mVisualBidiFormControl) ? + PR_TRUE : IsBidiFormControl(aPresContext); mRightEdge = aParentReflowState.mRightEdge; #endif // IBMBIDI } @@ -293,6 +302,8 @@ nsHTMLReflowState::nsHTMLReflowState(nsIPresContext* aPresContext, Init(aPresContext, aContainingBlockWidth, aContainingBlockHeight); #ifdef IBMBIDI + mFlags.mVisualBidiFormControl = (aParentReflowState.mFlags.mVisualBidiFormControl) ? + PR_TRUE : IsBidiFormControl(aPresContext); mRightEdge = aParentReflowState.mRightEdge; #endif // IBMBIDI } @@ -2745,3 +2756,57 @@ void nsHTMLReflowState::AdjustComputedWidth(void) if(mComputedWidth<0) mComputedWidth = 0; } } +#ifdef IBMBIDI +PRBool +nsHTMLReflowState::IsBidiFormControl(nsIPresContext* aPresContext) +{ + // This check is only necessary on visual bidi pages, because most + // visual pages use logical order for form controls so that they will + // display correctly on native widgets in OSs with Bidi support. + // So bail out if the page is not Bidi, or not visual, or if the pref is + // set to use visual order on forms in visual pages + PRBool bidiEnabled; + aPresContext->GetBidiEnabled(&bidiEnabled); + if (!bidiEnabled) { + return PR_FALSE; + } + + PRBool isVisual; + aPresContext->IsVisualMode(isVisual); + if (!isVisual) { + return PR_FALSE; + } + + PRUint32 options; + aPresContext->GetBidi(&options); + if (IBMBIDI_CONTROLSTEXTMODE_LOGICAL != GET_BIDI_OPTION_CONTROLSTEXTMODE(options)) { + return PR_FALSE; + } + + nsCOMPtr content, parent; + nsresult rv = frame->GetContent(getter_AddRefs(content) ); + if (NS_FAILED(rv)) { + return PR_FALSE; + } + if (!content) { + return PR_FALSE; + } + + // If this is a root reflow, we have to walk up the content tree to + // find out if the reflow root is a descendant of a form control. + // Otherwise, just test this content node + if (mReflowDepth == 0) { + while (content) { + if (content->IsContentOfType(nsIContent::eHTML_FORM_CONTROL)) { + return PR_TRUE; + } + content->GetParent(*getter_AddRefs(parent)); + content = parent; + } + } else { + return (content->IsContentOfType(nsIContent::eHTML_FORM_CONTROL)); + } + + return PR_FALSE; +} +#endif diff --git a/mozilla/layout/html/base/src/nsLineLayout.cpp b/mozilla/layout/html/base/src/nsLineLayout.cpp index 4be7dd2e866..28e43d4b574 100644 --- a/mozilla/layout/html/base/src/nsLineLayout.cpp +++ b/mozilla/layout/html/base/src/nsLineLayout.cpp @@ -62,7 +62,6 @@ #include "nsTextFragment.h" #ifdef IBMBIDI #include "nsBidiUtils.h" -#include "nsIFormControlFrame.h" #include "nsITextFrame.h" #define FIX_FOR_BUG_40882 #endif // IBMBIDI @@ -1048,30 +1047,12 @@ nsLineLayout::ReflowFrame(nsIFrame* aFrame, #ifdef IBMBIDI PRBool bidiEnabled; mPresContext->GetBidiEnabled(&bidiEnabled); - PRBool visual; - PRBool setMode = PR_FALSE; PRInt32 start, end; if (bidiEnabled) { if (state & NS_FRAME_IS_BIDI) { aFrame->GetOffsets(start, end); } - else { - nsCOMPtr formFrame(do_QueryInterface(aFrame) ); - if (formFrame) { - mPresContext->IsVisualMode(visual); - - PRUint32 options; - mPresContext->GetBidi(&options); - if ( (IBMBIDI_CONTROLSTEXTMODE_VISUAL == GET_BIDI_OPTION_CONTROLSTEXTMODE(options) - && !visual) - || (IBMBIDI_CONTROLSTEXTMODE_LOGICAL == GET_BIDI_OPTION_CONTROLSTEXTMODE(options) - && visual) ) { - mPresContext->SetVisualMode(!visual); - setMode = PR_TRUE; - } - } - } } #endif // IBMBIDI @@ -1084,12 +1065,6 @@ nsLineLayout::ReflowFrame(nsIFrame* aFrame, return rv; } -#ifdef IBMBIDI - if (setMode) { - mPresContext->SetVisualMode(visual); - } -#endif // IBMBIDI - // SEC: added this next block for bug 45152 // text frames don't know how to invalidate themselves on initial reflow. Do it for them here. // This only shows up in textareas, so do a quick check to see if we're inside one diff --git a/mozilla/modules/libpref/src/init/all.js b/mozilla/modules/libpref/src/init/all.js index 412b3cbed24..fc97c981db3 100644 --- a/mozilla/modules/libpref/src/init/all.js +++ b/mozilla/modules/libpref/src/init/all.js @@ -671,7 +671,7 @@ pref("bidi.texttype", 1); // Controls Text Mode // ------------------ // 1 = logicalcontrolstextmodeBidiCmd -// 2 = visiualcontrolstextmodeBidi +// 2 = visualcontrolstextmodeBidi <-- NO LONGER SUPPORTED // 3 = containercontrolstextmodeBidi * pref("bidi.controlstextmode", 1); // ------------------