Change the format of the BidiResult object.

This commit is contained in:
Julian Viereck 2012-09-14 15:03:27 -07:00
parent 897b99500e
commit 8d6565d1a8
2 changed files with 12 additions and 12 deletions

View File

@ -138,16 +138,16 @@ var bidi = PDFJS.bidi = (function bidiClosure() {
}
}
function bidiResult(content, direction) {
this.content = content;
this.direction = direction;
function BidiResult(str, isLTR) {
this.str = str;
this.ltr = isLTR;
}
function bidi(str, startLevel) {
var direction = '';
var isLTR = true;
var strLength = str.length;
if (strLength == 0)
return new bidiResult(str, direction);
return new BidiResult(str, ltr);
// get types, fill arrays
@ -181,16 +181,16 @@ var bidi = PDFJS.bidi = (function bidiClosure() {
// if less than 30% chars are rtl then string is primarily ltr
// if more than 30% chars are rtl then string is primarily rtl
if (numBidi == 0) {
direction = 'ltr';
return new bidiResult(str, direction);
isLTR = true;
return new BidiResult(str, isLTR);
}
if (startLevel == -1) {
if ((strLength / numBidi) < 0.3) {
direction = 'ltr';
isLTR = true;
startLevel = 0;
} else {
direction = 'rtl';
isLTR = false;
startLevel = 1;
}
}
@ -444,7 +444,7 @@ var bidi = PDFJS.bidi = (function bidiClosure() {
result += ch;
}
return new bidiResult(result, direction);
return new BidiResult(result, isLTR);
}
return bidi;

View File

@ -1935,8 +1935,8 @@ var TextLayerBuilder = function textLayerBuilder(textLayerDiv) {
var textDiv = textDivs[i];
var bidiText = PDFJS.bidi(textContent[i], -1);
textDiv.textContent = bidiText.content;
textDiv.dir = bidiText.direction;
textDiv.textContent = bidiText.str;
textDiv.dir = bidiText.ltr ? 'ltr' : 'rtl';
}
this.setupRenderLayoutTimer();