Force logical ordering in XUL elements on visual bidi pages. Bug 558403, r=roc

This commit is contained in:
Simon Montagu 2010-04-25 15:15:17 +03:00
Родитель a06c26318c
Коммит 0b4202e726
3 изменённых файлов: 27 добавлений и 37 удалений

Просмотреть файл

@ -310,8 +310,7 @@ AdvanceLineIteratorToFrame(nsIFrame* aFrame,
* EnsureBidiContinuation() in previous reflows into fluid continuations.
*/
nsresult
nsBidiPresUtils::Resolve(nsBlockFrame* aBlockFrame,
PRBool aIsVisualFormControl)
nsBidiPresUtils::Resolve(nsBlockFrame* aBlockFrame)
{
mLogicalFrames.Clear();
mContentToFrameIndex.Clear();
@ -372,12 +371,6 @@ nsBidiPresUtils::Resolve(nsBlockFrame* aBlockFrame,
return mSuccess;
}
PRBool isVisual;
if (aIsVisualFormControl) {
isVisual = PR_FALSE;
} else {
isVisual = presContext->IsVisualMode();
}
mSuccess = mBidiEngine->CountRuns(&runCount);
if (NS_FAILED(mSuccess) ) {
return mSuccess;
@ -407,6 +400,30 @@ nsBidiPresUtils::Resolve(nsBlockFrame* aBlockFrame,
}
nsIFrame* prevFrame = nsnull;
PRBool lineNeedsUpdate = PR_FALSE;
PRBool isVisual = presContext->IsVisualMode();
if (isVisual) {
/**
* Drill up in content to detect whether this is an element that needs to be
* rendered with logical order even on visual pages.
*
* We always use logical order on form controls, firstly so that text entry
* will be in logical order, but also because visual pages were written with
* the assumption that even if the browser had no support for right-to-left
* text rendering, it would use native widgets with bidi support to display
* form controls.
*
* We also use logical order in XUL elements, since we expect that if a XUL
* element appears in a visual page, it will be generated by an XBL binding
* and contain localized text which will be in logical order.
*/
for (content = aBlockFrame->GetContent() ; content; content = content->GetParent()) {
if (content->IsNodeOfType(nsINode::eHTML_FORM_CONTROL) || content->IsXUL()) {
isVisual = PR_FALSE;
break;
}
}
}
for (; ;) {
if (fragmentLength <= 0) {

Просмотреть файл

@ -167,14 +167,10 @@ public:
* descendants of a given block frame.
*
* @param aBlockFrame The block frame
* @param aIsVisualFormControl [IN] Set if we are in a form control on a
* visual page.
* @see nsBlockFrame::IsVisualFormControl
*
* @lina 06/18/2000
*/
nsresult Resolve(nsBlockFrame* aBlockFrame,
PRBool aIsVisualFormControl);
nsresult Resolve(nsBlockFrame* aBlockFrame);
/**
* Reorder this line using Bidi engine.

Просмотреть файл

@ -6897,30 +6897,7 @@ nsBlockFrame::ResolveBidi()
if (!bidiUtils)
return NS_ERROR_NULL_POINTER;
return bidiUtils->Resolve(this, IsVisualFormControl(presContext));
}
PRBool
nsBlockFrame::IsVisualFormControl(nsPresContext* aPresContext)
{
// We always use logical order on form controls, so that they will display
// correctly in native widgets in OSs with Bidi support.
// If the page uses logical ordering we can bail out immediately, but on
// visual pages we need to drill up in content to detect whether this block
// is a descendant of a form control.
if (!aPresContext->IsVisualMode()) {
return PR_FALSE;
}
nsIContent* content = GetContent();
for ( ; content; content = content->GetParent()) {
if (content->IsNodeOfType(nsINode::eHTML_FORM_CONTROL)) {
return PR_TRUE;
}
}
return PR_FALSE;
return bidiUtils->Resolve(this);
}
#endif