1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-22 16:18:08 +02:00

Merge branch 'master' of git://github.com/mozilla/pdf.js.git into tree-53

Conflicts:
	test/test_manifest.json
This commit is contained in:
notmasteryet 2012-01-04 19:57:08 -06:00
commit caacd31a2c
9 changed files with 101 additions and 68 deletions

View file

@ -257,8 +257,9 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
this.ctx.scale(cw / mediaBox.width, ch / mediaBox.height);
// Move the media left-top corner to the (0,0) canvas position
this.ctx.translate(-mediaBox.x, -mediaBox.y);
this.textDivs = [];
this.textLayerQueue = [];
if (this.textLayer)
this.textLayer.beginLayout();
},
executeIRQueue: function canvasGraphicsExecuteIRQueue(codeIR,
@ -322,27 +323,8 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
endDrawing: function canvasGraphicsEndDrawing() {
this.ctx.restore();
var textLayer = this.textLayer;
if (!textLayer)
return;
var self = this;
var textDivs = this.textDivs;
this.textLayerTimer = setInterval(function renderTextLayer() {
if (textDivs.length === 0) {
clearInterval(self.textLayerTimer);
return;
}
var textDiv = textDivs.shift();
if (textDiv.dataset.textLength > 1) { // avoid div by zero
textLayer.appendChild(textDiv);
// Adjust div width (via letterSpacing) to match canvas text
// Due to the .offsetWidth calls, this is slow
textDiv.style.letterSpacing =
((textDiv.dataset.canvasWidth - textDiv.offsetWidth) /
(textDiv.dataset.textLength - 1)) + 'px';
}
}, 0);
if (this.textLayer)
this.textLayer.endLayout();
},
// Graphics state
@ -634,24 +616,6 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
return geometry;
},
pushTextDivs: function canvasGraphicsPushTextDivs(text) {
var div = document.createElement('div');
var fontSize = this.current.fontSize;
// vScale and hScale already contain the scaling to pixel units
// as mozCurrentTransform reflects ctx.scale() changes
// (see beginDrawing())
var fontHeight = fontSize * text.geom.vScale;
div.dataset.canvasWidth = text.canvasWidth * text.geom.hScale;
div.style.fontSize = fontHeight + 'px';
div.style.fontFamily = this.current.font.loadedName || 'sans-serif';
div.style.left = text.geom.x + 'px';
div.style.top = (text.geom.y - fontHeight) + 'px';
div.innerHTML = text.str;
div.dataset.textLength = text.length;
this.textDivs.push(div);
},
showText: function canvasGraphicsShowText(str, skipTextSelection) {
var ctx = this.ctx;
var current = this.current;
@ -751,7 +715,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
width += charWidth;
text.str += glyph.unicode === ' ' ? ' ' : glyph.unicode;
text.str += glyph.unicode === ' ' ? '\u00A0' : glyph.unicode;
text.length++;
text.canvasWidth += charWidth;
}
@ -760,7 +724,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
}
if (textSelection)
this.pushTextDivs(text);
this.textLayer.appendText(text, font.loadedName, fontSize);
return text;
},
@ -803,7 +767,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
if (e < 0 && text.geom.spaceWidth > 0) { // avoid div by zero
var numFakeSpaces = Math.round(-e / text.geom.spaceWidth);
if (numFakeSpaces > 0) {
text.str += '&nbsp;';
text.str += '\u00A0';
text.length++;
}
}
@ -813,7 +777,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
if (textSelection) {
if (shownText.str === ' ') {
text.str += '&nbsp;';
text.str += '\u00A0';
} else {
text.str += shownText.str;
}
@ -826,7 +790,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
}
if (textSelection)
this.pushTextDivs(text);
this.textLayer.appendText(text, font.loadedName, fontSize);
},
nextLineShowText: function canvasGraphicsNextLineShowText(text) {
this.nextLine();

View file

@ -1856,10 +1856,10 @@ var CCITTFaxStream = (function CCITTFaxStreamClosure() {
// values. The first array element indicates whether a valid code is being
// returned. The second array element is the actual code. The third array
// element indicates whether EOF was reached.
var findTableCode = function ccittFaxStreamFindTableCode(start, end, table,
limit) {
var limitValue = limit || 0;
CCITTFaxStream.prototype.findTableCode =
function ccittFaxStreamFindTableCode(start, end, table, limit) {
var limitValue = limit || 0;
for (var i = start; i <= end; ++i) {
var code = this.lookBits(i);
if (code == EOF)
@ -1890,7 +1890,7 @@ var CCITTFaxStream = (function CCITTFaxStreamClosure() {
return p[1];
}
} else {
var result = findTableCode(1, 7, twoDimTable);
var result = this.findTableCode(1, 7, twoDimTable);
if (result[0] && result[2])
return result[1];
}
@ -1919,11 +1919,11 @@ var CCITTFaxStream = (function CCITTFaxStreamClosure() {
return p[1];
}
} else {
var result = findTableCode(1, 9, whiteTable2);
var result = this.findTableCode(1, 9, whiteTable2);
if (result[0])
return result[1];
result = findTableCode(11, 12, whiteTable1);
result = this.findTableCode(11, 12, whiteTable1);
if (result[0])
return result[1];
}
@ -1952,15 +1952,15 @@ var CCITTFaxStream = (function CCITTFaxStreamClosure() {
return p[1];
}
} else {
var result = findTableCode(2, 6, blackTable3);
var result = this.findTableCode(2, 6, blackTable3);
if (result[0])
return result[1];
result = findTableCode(7, 12, blackTable2, 64);
result = this.findTableCode(7, 12, blackTable2, 64);
if (result[0])
return result[1];
result = findTableCode(10, 13, blackTable1);
result = this.findTableCode(10, 13, blackTable1);
if (result[0])
return result[1];
}