mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-10 11:55:49 +00:00
Bug 1222198 - Update pdf.js to version 1.2.68. r=bdahl, r=Mossop
--HG-- extra : rebase_source : 27058d7e12388176763eda7cb3a769f6bf9017b1
This commit is contained in:
parent
c4b8c9e1e5
commit
dcca1994a7
@ -1,3 +1,3 @@
|
|||||||
This is the pdf.js project output, https://github.com/mozilla/pdf.js
|
This is the pdf.js project output, https://github.com/mozilla/pdf.js
|
||||||
|
|
||||||
Current extension version is: 1.1.551
|
Current extension version is: 1.2.68
|
||||||
|
@ -368,6 +368,12 @@ ChromeActions.prototype = {
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
|
supportedMouseWheelZoomModifierKeys: function() {
|
||||||
|
return {
|
||||||
|
ctrlKey: getIntPref('mousewheel.with_control.action', 3) === 3,
|
||||||
|
metaKey: getIntPref('mousewheel.with_meta.action', 1) === 3,
|
||||||
|
};
|
||||||
|
},
|
||||||
reportTelemetry: function (data) {
|
reportTelemetry: function (data) {
|
||||||
var probeInfo = JSON.parse(data);
|
var probeInfo = JSON.parse(data);
|
||||||
switch (probeInfo.type) {
|
switch (probeInfo.type) {
|
||||||
@ -772,7 +778,7 @@ RequestListener.prototype.receive = function(event) {
|
|||||||
var response;
|
var response;
|
||||||
if (sync) {
|
if (sync) {
|
||||||
response = actions[action].call(this.actions, data);
|
response = actions[action].call(this.actions, data);
|
||||||
event.detail.response = response;
|
event.detail.response = makeContentReadable(response, doc.defaultView);
|
||||||
} else {
|
} else {
|
||||||
if (!event.detail.responseExpected) {
|
if (!event.detail.responseExpected) {
|
||||||
doc.documentElement.removeChild(message);
|
doc.documentElement.removeChild(message);
|
||||||
|
@ -22,8 +22,8 @@ if (typeof PDFJS === 'undefined') {
|
|||||||
(typeof window !== 'undefined' ? window : this).PDFJS = {};
|
(typeof window !== 'undefined' ? window : this).PDFJS = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
PDFJS.version = '1.1.551';
|
PDFJS.version = '1.2.68';
|
||||||
PDFJS.build = '2a5616c';
|
PDFJS.build = '8079bdd';
|
||||||
|
|
||||||
(function pdfjsWrapper() {
|
(function pdfjsWrapper() {
|
||||||
// Use strict in our context only - users might not want it
|
// Use strict in our context only - users might not want it
|
||||||
@ -1326,6 +1326,8 @@ function loadJpegStream(id, imageUrl, objs) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
var DEFAULT_RANGE_CHUNK_SIZE = 65536; // 2^16 = 65536
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The maximum allowed image size in total pixels e.g. width * height. Images
|
* The maximum allowed image size in total pixels e.g. width * height. Images
|
||||||
* above this value will not be drawn. Use -1 for no limit.
|
* above this value will not be drawn. Use -1 for no limit.
|
||||||
@ -1520,6 +1522,9 @@ PDFJS.isEvalSupported = (PDFJS.isEvalSupported === undefined ?
|
|||||||
* @property {number} length - The PDF file length. It's used for progress
|
* @property {number} length - The PDF file length. It's used for progress
|
||||||
* reports and range requests operations.
|
* reports and range requests operations.
|
||||||
* @property {PDFDataRangeTransport} range
|
* @property {PDFDataRangeTransport} range
|
||||||
|
* @property {number} rangeChunkSize - Optional parameter to specify
|
||||||
|
* maximum number of bytes fetched per range request. The default value is
|
||||||
|
* 2^16 = 65536.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1629,6 +1634,8 @@ PDFJS.getDocument = function getDocument(src,
|
|||||||
params[key] = source[key];
|
params[key] = source[key];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
params.rangeChunkSize = source.rangeChunkSize || DEFAULT_RANGE_CHUNK_SIZE;
|
||||||
|
|
||||||
workerInitializedCapability = createPromiseCapability();
|
workerInitializedCapability = createPromiseCapability();
|
||||||
transport = new WorkerTransport(workerInitializedCapability, source.range);
|
transport = new WorkerTransport(workerInitializedCapability, source.range);
|
||||||
workerInitializedCapability.promise.then(function transportInitialized() {
|
workerInitializedCapability.promise.then(function transportInitialized() {
|
||||||
@ -2526,6 +2533,9 @@ var WorkerTransport = (function WorkerTransportClosure() {
|
|||||||
}, this);
|
}, this);
|
||||||
|
|
||||||
messageHandler.on('StartRenderPage', function transportRender(data) {
|
messageHandler.on('StartRenderPage', function transportRender(data) {
|
||||||
|
if (this.destroyed) {
|
||||||
|
return; // Ignore any pending requests if the worker was terminated.
|
||||||
|
}
|
||||||
var page = this.pageCache[data.pageIndex];
|
var page = this.pageCache[data.pageIndex];
|
||||||
|
|
||||||
page.stats.timeEnd('Page Request');
|
page.stats.timeEnd('Page Request');
|
||||||
@ -2533,12 +2543,19 @@ var WorkerTransport = (function WorkerTransportClosure() {
|
|||||||
}, this);
|
}, this);
|
||||||
|
|
||||||
messageHandler.on('RenderPageChunk', function transportRender(data) {
|
messageHandler.on('RenderPageChunk', function transportRender(data) {
|
||||||
|
if (this.destroyed) {
|
||||||
|
return; // Ignore any pending requests if the worker was terminated.
|
||||||
|
}
|
||||||
var page = this.pageCache[data.pageIndex];
|
var page = this.pageCache[data.pageIndex];
|
||||||
|
|
||||||
page._renderPageChunk(data.operatorList, data.intent);
|
page._renderPageChunk(data.operatorList, data.intent);
|
||||||
}, this);
|
}, this);
|
||||||
|
|
||||||
messageHandler.on('commonobj', function transportObj(data) {
|
messageHandler.on('commonobj', function transportObj(data) {
|
||||||
|
if (this.destroyed) {
|
||||||
|
return; // Ignore any pending requests if the worker was terminated.
|
||||||
|
}
|
||||||
|
|
||||||
var id = data[0];
|
var id = data[0];
|
||||||
var type = data[1];
|
var type = data[1];
|
||||||
if (this.commonObjs.hasData(id)) {
|
if (this.commonObjs.hasData(id)) {
|
||||||
@ -2575,6 +2592,10 @@ var WorkerTransport = (function WorkerTransportClosure() {
|
|||||||
}, this);
|
}, this);
|
||||||
|
|
||||||
messageHandler.on('obj', function transportObj(data) {
|
messageHandler.on('obj', function transportObj(data) {
|
||||||
|
if (this.destroyed) {
|
||||||
|
return; // Ignore any pending requests if the worker was terminated.
|
||||||
|
}
|
||||||
|
|
||||||
var id = data[0];
|
var id = data[0];
|
||||||
var pageIndex = data[1];
|
var pageIndex = data[1];
|
||||||
var type = data[2];
|
var type = data[2];
|
||||||
@ -2606,6 +2627,10 @@ var WorkerTransport = (function WorkerTransportClosure() {
|
|||||||
}, this);
|
}, this);
|
||||||
|
|
||||||
messageHandler.on('DocProgress', function transportDocProgress(data) {
|
messageHandler.on('DocProgress', function transportDocProgress(data) {
|
||||||
|
if (this.destroyed) {
|
||||||
|
return; // Ignore any pending requests if the worker was terminated.
|
||||||
|
}
|
||||||
|
|
||||||
var loadingTask = this.loadingTask;
|
var loadingTask = this.loadingTask;
|
||||||
if (loadingTask.onProgress) {
|
if (loadingTask.onProgress) {
|
||||||
loadingTask.onProgress({
|
loadingTask.onProgress({
|
||||||
@ -2616,6 +2641,10 @@ var WorkerTransport = (function WorkerTransportClosure() {
|
|||||||
}, this);
|
}, this);
|
||||||
|
|
||||||
messageHandler.on('PageError', function transportError(data) {
|
messageHandler.on('PageError', function transportError(data) {
|
||||||
|
if (this.destroyed) {
|
||||||
|
return; // Ignore any pending requests if the worker was terminated.
|
||||||
|
}
|
||||||
|
|
||||||
var page = this.pageCache[data.pageNum - 1];
|
var page = this.pageCache[data.pageNum - 1];
|
||||||
var intentState = page.intentStates[data.intent];
|
var intentState = page.intentStates[data.intent];
|
||||||
if (intentState.displayReadyCapability) {
|
if (intentState.displayReadyCapability) {
|
||||||
@ -2626,6 +2655,10 @@ var WorkerTransport = (function WorkerTransportClosure() {
|
|||||||
}, this);
|
}, this);
|
||||||
|
|
||||||
messageHandler.on('JpegDecode', function(data) {
|
messageHandler.on('JpegDecode', function(data) {
|
||||||
|
if (this.destroyed) {
|
||||||
|
return Promise.reject('Worker was terminated');
|
||||||
|
}
|
||||||
|
|
||||||
var imageUrl = data[0];
|
var imageUrl = data[0];
|
||||||
var components = data[1];
|
var components = data[1];
|
||||||
if (components !== 3 && components !== 1) {
|
if (components !== 3 && components !== 1) {
|
||||||
@ -2665,7 +2698,7 @@ var WorkerTransport = (function WorkerTransportClosure() {
|
|||||||
};
|
};
|
||||||
img.src = imageUrl;
|
img.src = imageUrl;
|
||||||
});
|
});
|
||||||
});
|
}, this);
|
||||||
},
|
},
|
||||||
|
|
||||||
fetchDocument: function WorkerTransport_fetchDocument(loadingTask, source) {
|
fetchDocument: function WorkerTransport_fetchDocument(loadingTask, source) {
|
||||||
@ -4521,16 +4554,13 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
|
|||||||
var x = 0, i;
|
var x = 0, i;
|
||||||
for (i = 0; i < glyphsLength; ++i) {
|
for (i = 0; i < glyphsLength; ++i) {
|
||||||
var glyph = glyphs[i];
|
var glyph = glyphs[i];
|
||||||
if (glyph === null) {
|
if (isNum(glyph)) {
|
||||||
// word break
|
|
||||||
x += fontDirection * wordSpacing;
|
|
||||||
continue;
|
|
||||||
} else if (isNum(glyph)) {
|
|
||||||
x += spacingDir * glyph * fontSize / 1000;
|
x += spacingDir * glyph * fontSize / 1000;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
var restoreNeeded = false;
|
var restoreNeeded = false;
|
||||||
|
var spacing = (glyph.isSpace ? wordSpacing : 0) + charSpacing;
|
||||||
var character = glyph.fontChar;
|
var character = glyph.fontChar;
|
||||||
var accent = glyph.accent;
|
var accent = glyph.accent;
|
||||||
var scaledX, scaledY, scaledAccentX, scaledAccentY;
|
var scaledX, scaledY, scaledAccentX, scaledAccentY;
|
||||||
@ -4574,7 +4604,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var charWidth = width * widthAdvanceScale + charSpacing * fontDirection;
|
var charWidth = width * widthAdvanceScale + spacing * fontDirection;
|
||||||
x += charWidth;
|
x += charWidth;
|
||||||
|
|
||||||
if (restoreNeeded) {
|
if (restoreNeeded) {
|
||||||
@ -4619,18 +4649,14 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
|
|||||||
|
|
||||||
for (i = 0; i < glyphsLength; ++i) {
|
for (i = 0; i < glyphsLength; ++i) {
|
||||||
glyph = glyphs[i];
|
glyph = glyphs[i];
|
||||||
if (glyph === null) {
|
if (isNum(glyph)) {
|
||||||
// word break
|
|
||||||
this.ctx.translate(wordSpacing, 0);
|
|
||||||
current.x += wordSpacing * textHScale;
|
|
||||||
continue;
|
|
||||||
} else if (isNum(glyph)) {
|
|
||||||
spacingLength = spacingDir * glyph * fontSize / 1000;
|
spacingLength = spacingDir * glyph * fontSize / 1000;
|
||||||
this.ctx.translate(spacingLength, 0);
|
this.ctx.translate(spacingLength, 0);
|
||||||
current.x += spacingLength * textHScale;
|
current.x += spacingLength * textHScale;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var spacing = (glyph.isSpace ? wordSpacing : 0) + charSpacing;
|
||||||
var operatorList = font.charProcOperatorList[glyph.operatorListId];
|
var operatorList = font.charProcOperatorList[glyph.operatorListId];
|
||||||
if (!operatorList) {
|
if (!operatorList) {
|
||||||
warn('Type3 character \"' + glyph.operatorListId +
|
warn('Type3 character \"' + glyph.operatorListId +
|
||||||
@ -4645,7 +4671,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
|
|||||||
this.restore();
|
this.restore();
|
||||||
|
|
||||||
var transformed = Util.applyTransform([glyph.width, 0], fontMatrix);
|
var transformed = Util.applyTransform([glyph.width, 0], fontMatrix);
|
||||||
width = transformed[0] * fontSize + charSpacing;
|
width = transformed[0] * fontSize + spacing;
|
||||||
|
|
||||||
ctx.translate(width, 0);
|
ctx.translate(width, 0);
|
||||||
current.x += width * textHScale;
|
current.x += width * textHScale;
|
||||||
|
124
browser/extensions/pdfjs/content/build/pdf.worker.js
vendored
124
browser/extensions/pdfjs/content/build/pdf.worker.js
vendored
@ -22,8 +22,8 @@ if (typeof PDFJS === 'undefined') {
|
|||||||
(typeof window !== 'undefined' ? window : this).PDFJS = {};
|
(typeof window !== 'undefined' ? window : this).PDFJS = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
PDFJS.version = '1.1.551';
|
PDFJS.version = '1.2.68';
|
||||||
PDFJS.build = '2a5616c';
|
PDFJS.build = '8079bdd';
|
||||||
|
|
||||||
(function pdfjsWrapper() {
|
(function pdfjsWrapper() {
|
||||||
// Use strict in our context only - users might not want it
|
// Use strict in our context only - users might not want it
|
||||||
@ -1856,9 +1856,6 @@ var ChunkedStreamManager = (function ChunkedStreamManagerClosure() {
|
|||||||
})();
|
})();
|
||||||
|
|
||||||
|
|
||||||
// The maximum number of bytes fetched per range request
|
|
||||||
var RANGE_CHUNK_SIZE = 65536;
|
|
||||||
|
|
||||||
// TODO(mack): Make use of PDFJS.Util.inherit() when it becomes available
|
// TODO(mack): Make use of PDFJS.Util.inherit() when it becomes available
|
||||||
var BasePdfManager = (function BasePdfManagerClosure() {
|
var BasePdfManager = (function BasePdfManagerClosure() {
|
||||||
function BasePdfManager() {
|
function BasePdfManager() {
|
||||||
@ -1990,7 +1987,8 @@ var NetworkPdfManager = (function NetworkPdfManagerClosure() {
|
|||||||
disableAutoFetch: args.disableAutoFetch,
|
disableAutoFetch: args.disableAutoFetch,
|
||||||
initialData: args.initialData
|
initialData: args.initialData
|
||||||
};
|
};
|
||||||
this.streamManager = new ChunkedStreamManager(args.length, RANGE_CHUNK_SIZE,
|
this.streamManager = new ChunkedStreamManager(args.length,
|
||||||
|
args.rangeChunkSize,
|
||||||
args.url, params);
|
args.url, params);
|
||||||
|
|
||||||
this.pdfDocument = new PDFDocument(this, this.streamManager.getStream(),
|
this.pdfDocument = new PDFDocument(this, this.streamManager.getStream(),
|
||||||
@ -10587,9 +10585,6 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
|
|||||||
|
|
||||||
for (var i = 0, ii = glyphs.length; i < ii; i++) {
|
for (var i = 0, ii = glyphs.length; i < ii; i++) {
|
||||||
var glyph = glyphs[i];
|
var glyph = glyphs[i];
|
||||||
if (glyph === null) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
buildPath(glyph.fontChar);
|
buildPath(glyph.fontChar);
|
||||||
|
|
||||||
// If the glyph has an accent we need to build a path for its
|
// If the glyph has an accent we need to build a path for its
|
||||||
@ -11249,10 +11244,6 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
|
|||||||
var defaultVMetrics = font.defaultVMetrics;
|
var defaultVMetrics = font.defaultVMetrics;
|
||||||
for (var i = 0; i < glyphs.length; i++) {
|
for (var i = 0; i < glyphs.length; i++) {
|
||||||
var glyph = glyphs[i];
|
var glyph = glyphs[i];
|
||||||
if (!glyph) { // Previous glyph was a space.
|
|
||||||
width += textState.wordSpacing * textState.textHScale;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
var vMetricX = null;
|
var vMetricX = null;
|
||||||
var vMetricY = null;
|
var vMetricY = null;
|
||||||
var glyphWidth = null;
|
var glyphWidth = null;
|
||||||
@ -11288,11 +11279,14 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
|
|||||||
// var x = pt[0];
|
// var x = pt[0];
|
||||||
// var y = pt[1];
|
// var y = pt[1];
|
||||||
|
|
||||||
var charSpacing = 0;
|
var charSpacing = textState.charSpacing;
|
||||||
if (textChunk.str.length > 0) {
|
if (glyph.isSpace) {
|
||||||
// Apply char spacing only when there are chars.
|
var wordSpacing = textState.wordSpacing;
|
||||||
// As a result there is only spacing between glyphs.
|
charSpacing += wordSpacing;
|
||||||
charSpacing = textState.charSpacing;
|
if (wordSpacing > 0) {
|
||||||
|
addFakeSpaces(wordSpacing * 1000 / textState.fontSize,
|
||||||
|
textChunk.str);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var tx = 0;
|
var tx = 0;
|
||||||
@ -11326,6 +11320,22 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
|
|||||||
return textChunk;
|
return textChunk;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function addFakeSpaces(width, strBuf) {
|
||||||
|
var spaceWidth = textState.font.spaceWidth;
|
||||||
|
if (spaceWidth <= 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var fakeSpaces = width / spaceWidth;
|
||||||
|
if (fakeSpaces > MULTI_SPACE_FACTOR) {
|
||||||
|
fakeSpaces = Math.round(fakeSpaces);
|
||||||
|
while (fakeSpaces--) {
|
||||||
|
strBuf.push(' ');
|
||||||
|
}
|
||||||
|
} else if (fakeSpaces > SPACE_FACTOR) {
|
||||||
|
strBuf.push(' ');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var timeSlotManager = new TimeSlotManager();
|
var timeSlotManager = new TimeSlotManager();
|
||||||
|
|
||||||
return new Promise(function next(resolve, reject) {
|
return new Promise(function next(resolve, reject) {
|
||||||
@ -11404,29 +11414,26 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
|
|||||||
// In the default coordinate system, a positive adjustment
|
// In the default coordinate system, a positive adjustment
|
||||||
// has the effect of moving the next glyph painted either to
|
// has the effect of moving the next glyph painted either to
|
||||||
// the left or down by the given amount.
|
// the left or down by the given amount.
|
||||||
var val = items[j] * textState.fontSize / 1000;
|
var advance = items[j];
|
||||||
|
var val = advance * textState.fontSize / 1000;
|
||||||
if (textState.font.vertical) {
|
if (textState.font.vertical) {
|
||||||
offset = val * textState.textMatrix[3];
|
offset = val *
|
||||||
textState.translateTextMatrix(0, offset);
|
(textState.textHScale * textState.textMatrix[2] +
|
||||||
|
textState.textMatrix[3]);
|
||||||
|
textState.translateTextMatrix(0, val);
|
||||||
// Value needs to be added to height to paint down.
|
// Value needs to be added to height to paint down.
|
||||||
textChunk.height += offset;
|
textChunk.height += offset;
|
||||||
} else {
|
} else {
|
||||||
offset = val * textState.textHScale *
|
offset = val * (
|
||||||
textState.textMatrix[0];
|
textState.textHScale * textState.textMatrix[0] +
|
||||||
textState.translateTextMatrix(offset, 0);
|
textState.textMatrix[1]);
|
||||||
|
textState.translateTextMatrix(-val, 0);
|
||||||
// Value needs to be subtracted from width to paint left.
|
// Value needs to be subtracted from width to paint left.
|
||||||
textChunk.width -= offset;
|
textChunk.width -= offset;
|
||||||
|
advance = -advance;
|
||||||
}
|
}
|
||||||
if (items[j] < 0 && textState.font.spaceWidth > 0) {
|
if (advance > 0) {
|
||||||
var fakeSpaces = -items[j] / textState.font.spaceWidth;
|
addFakeSpaces(advance, textChunk.str);
|
||||||
if (fakeSpaces > MULTI_SPACE_FACTOR) {
|
|
||||||
fakeSpaces = Math.round(fakeSpaces);
|
|
||||||
while (fakeSpaces--) {
|
|
||||||
textChunk.str.push(' ');
|
|
||||||
}
|
|
||||||
} else if (fakeSpaces > SPACE_FACTOR) {
|
|
||||||
textChunk.str.push(' ');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -12157,6 +12164,7 @@ var OperatorList = (function OperatorListClosure() {
|
|||||||
this.fnArray = [];
|
this.fnArray = [];
|
||||||
this.argsArray = [];
|
this.argsArray = [];
|
||||||
this.dependencies = {};
|
this.dependencies = {};
|
||||||
|
this._totalLength = 0;
|
||||||
this.pageIndex = pageIndex;
|
this.pageIndex = pageIndex;
|
||||||
this.intent = intent;
|
this.intent = intent;
|
||||||
}
|
}
|
||||||
@ -12166,6 +12174,14 @@ var OperatorList = (function OperatorListClosure() {
|
|||||||
return this.argsArray.length;
|
return this.argsArray.length;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @returns {number} The total length of the entire operator list,
|
||||||
|
* since `this.length === 0` after flushing.
|
||||||
|
*/
|
||||||
|
get totalLength() {
|
||||||
|
return (this._totalLength + this.length);
|
||||||
|
},
|
||||||
|
|
||||||
addOp: function(fn, args) {
|
addOp: function(fn, args) {
|
||||||
this.fnArray.push(fn);
|
this.fnArray.push(fn);
|
||||||
this.argsArray.push(args);
|
this.argsArray.push(args);
|
||||||
@ -12214,12 +12230,15 @@ var OperatorList = (function OperatorListClosure() {
|
|||||||
new QueueOptimizer().optimize(this);
|
new QueueOptimizer().optimize(this);
|
||||||
}
|
}
|
||||||
var transfers = getTransfers(this);
|
var transfers = getTransfers(this);
|
||||||
|
var length = this.length;
|
||||||
|
this._totalLength += length;
|
||||||
|
|
||||||
this.messageHandler.send('RenderPageChunk', {
|
this.messageHandler.send('RenderPageChunk', {
|
||||||
operatorList: {
|
operatorList: {
|
||||||
fnArray: this.fnArray,
|
fnArray: this.fnArray,
|
||||||
argsArray: this.argsArray,
|
argsArray: this.argsArray,
|
||||||
lastChunk: lastChunk,
|
lastChunk: lastChunk,
|
||||||
length: this.length
|
length: length
|
||||||
},
|
},
|
||||||
pageIndex: this.pageIndex,
|
pageIndex: this.pageIndex,
|
||||||
intent: this.intent
|
intent: this.intent
|
||||||
@ -16095,23 +16114,26 @@ function getFontType(type, subtype) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var Glyph = (function GlyphClosure() {
|
var Glyph = (function GlyphClosure() {
|
||||||
function Glyph(fontChar, unicode, accent, width, vmetric, operatorListId) {
|
function Glyph(fontChar, unicode, accent, width, vmetric, operatorListId,
|
||||||
|
isSpace) {
|
||||||
this.fontChar = fontChar;
|
this.fontChar = fontChar;
|
||||||
this.unicode = unicode;
|
this.unicode = unicode;
|
||||||
this.accent = accent;
|
this.accent = accent;
|
||||||
this.width = width;
|
this.width = width;
|
||||||
this.vmetric = vmetric;
|
this.vmetric = vmetric;
|
||||||
this.operatorListId = operatorListId;
|
this.operatorListId = operatorListId;
|
||||||
|
this.isSpace = isSpace;
|
||||||
}
|
}
|
||||||
|
|
||||||
Glyph.prototype.matchesForCache =
|
Glyph.prototype.matchesForCache = function(fontChar, unicode, accent, width,
|
||||||
function(fontChar, unicode, accent, width, vmetric, operatorListId) {
|
vmetric, operatorListId, isSpace) {
|
||||||
return this.fontChar === fontChar &&
|
return this.fontChar === fontChar &&
|
||||||
this.unicode === unicode &&
|
this.unicode === unicode &&
|
||||||
this.accent === accent &&
|
this.accent === accent &&
|
||||||
this.width === width &&
|
this.width === width &&
|
||||||
this.vmetric === vmetric &&
|
this.vmetric === vmetric &&
|
||||||
this.operatorListId === operatorListId;
|
this.operatorListId === operatorListId &&
|
||||||
|
this.isSpace === isSpace;
|
||||||
};
|
};
|
||||||
|
|
||||||
return Glyph;
|
return Glyph;
|
||||||
@ -18626,7 +18648,7 @@ var Font = (function FontClosure() {
|
|||||||
return width;
|
return width;
|
||||||
},
|
},
|
||||||
|
|
||||||
charToGlyph: function Font_charToGlyph(charcode) {
|
charToGlyph: function Font_charToGlyph(charcode, isSpace) {
|
||||||
var fontCharCode, width, operatorListId;
|
var fontCharCode, width, operatorListId;
|
||||||
|
|
||||||
var widthCode = charcode;
|
var widthCode = charcode;
|
||||||
@ -18669,9 +18691,9 @@ var Font = (function FontClosure() {
|
|||||||
var glyph = this.glyphCache[charcode];
|
var glyph = this.glyphCache[charcode];
|
||||||
if (!glyph ||
|
if (!glyph ||
|
||||||
!glyph.matchesForCache(fontChar, unicode, accent, width, vmetric,
|
!glyph.matchesForCache(fontChar, unicode, accent, width, vmetric,
|
||||||
operatorListId)) {
|
operatorListId, isSpace)) {
|
||||||
glyph = new Glyph(fontChar, unicode, accent, width, vmetric,
|
glyph = new Glyph(fontChar, unicode, accent, width, vmetric,
|
||||||
operatorListId);
|
operatorListId, isSpace);
|
||||||
this.glyphCache[charcode] = glyph;
|
this.glyphCache[charcode] = glyph;
|
||||||
}
|
}
|
||||||
return glyph;
|
return glyph;
|
||||||
@ -18707,22 +18729,16 @@ var Font = (function FontClosure() {
|
|||||||
charcode = c.charcode;
|
charcode = c.charcode;
|
||||||
var length = c.length;
|
var length = c.length;
|
||||||
i += length;
|
i += length;
|
||||||
glyph = this.charToGlyph(charcode);
|
// Space is char with code 0x20 and length 1 in multiple-byte codes.
|
||||||
|
var isSpace = length === 1 && chars.charCodeAt(i - 1) === 0x20;
|
||||||
|
glyph = this.charToGlyph(charcode, isSpace);
|
||||||
glyphs.push(glyph);
|
glyphs.push(glyph);
|
||||||
// placing null after each word break charcode (ASCII SPACE)
|
|
||||||
// Ignore occurences of 0x20 in multiple-byte codes.
|
|
||||||
if (length === 1 && chars.charCodeAt(i - 1) === 0x20) {
|
|
||||||
glyphs.push(null);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (i = 0, ii = chars.length; i < ii; ++i) {
|
for (i = 0, ii = chars.length; i < ii; ++i) {
|
||||||
charcode = chars.charCodeAt(i);
|
charcode = chars.charCodeAt(i);
|
||||||
glyph = this.charToGlyph(charcode);
|
glyph = this.charToGlyph(charcode, charcode === 0x20);
|
||||||
glyphs.push(glyph);
|
glyphs.push(glyph);
|
||||||
if (charcode === 0x20) {
|
|
||||||
glyphs.push(null);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -33808,7 +33824,7 @@ var WorkerMessageHandler = PDFJS.WorkerMessageHandler = {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
source.length = length;
|
source.length = length;
|
||||||
if (length <= 2 * RANGE_CHUNK_SIZE) {
|
if (length <= 2 * source.rangeChunkSize) {
|
||||||
// The file size is smaller than the size of two chunks, so it does
|
// The file size is smaller than the size of two chunks, so it does
|
||||||
// not make any sense to abort the request and retry with a range
|
// not make any sense to abort the request and retry with a range
|
||||||
// request.
|
// request.
|
||||||
@ -34115,7 +34131,7 @@ var WorkerMessageHandler = PDFJS.WorkerMessageHandler = {
|
|||||||
finishWorkerTask(task);
|
finishWorkerTask(task);
|
||||||
|
|
||||||
info('page=' + pageNum + ' - getOperatorList: time=' +
|
info('page=' + pageNum + ' - getOperatorList: time=' +
|
||||||
(Date.now() - start) + 'ms, len=' + operatorList.fnArray.length);
|
(Date.now() - start) + 'ms, len=' + operatorList.totalLength);
|
||||||
}, function(e) {
|
}, function(e) {
|
||||||
finishWorkerTask(task);
|
finishWorkerTask(task);
|
||||||
if (task.terminated) {
|
if (task.terminated) {
|
||||||
|
@ -59,6 +59,22 @@
|
|||||||
.textLayer ::selection { background: rgb(0,0,255); }
|
.textLayer ::selection { background: rgb(0,0,255); }
|
||||||
.textLayer ::-moz-selection { background: rgb(0,0,255); }
|
.textLayer ::-moz-selection { background: rgb(0,0,255); }
|
||||||
|
|
||||||
|
.textLayer .endOfContent {
|
||||||
|
display: block;
|
||||||
|
position: absolute;
|
||||||
|
left: 0px;
|
||||||
|
top: 100%;
|
||||||
|
right: 0px;
|
||||||
|
bottom: 0px;
|
||||||
|
z-index: -1;
|
||||||
|
cursor: default;
|
||||||
|
-moz-user-select: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.textLayer .endOfContent.active {
|
||||||
|
top: 0px;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
.annotationLayer .annotLink > a:hover {
|
.annotationLayer .annotLink > a:hover {
|
||||||
opacity: 0.2;
|
opacity: 0.2;
|
||||||
@ -420,9 +436,8 @@ html[dir='rtl'] #toolbarContainer, .findbar, .secondaryToolbar {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@keyframes progressIndeterminate {
|
@keyframes progressIndeterminate {
|
||||||
0% { left: 0%; }
|
0% { left: -142px; }
|
||||||
50% { left: 100%; }
|
100% { left: 0; }
|
||||||
100% { left: 100%; }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#loadingBar .progress.indeterminate {
|
#loadingBar .progress.indeterminate {
|
||||||
@ -430,18 +445,19 @@ html[dir='rtl'] #toolbarContainer, .findbar, .secondaryToolbar {
|
|||||||
transition: none;
|
transition: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
#loadingBar .indeterminate .glimmer {
|
#loadingBar .progress.indeterminate .glimmer {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 0;
|
top: 0;
|
||||||
left: 0;
|
left: 0;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
width: 50px;
|
width: calc(100% + 150px);
|
||||||
|
|
||||||
background-image: linear-gradient(to right, #999 0%, #fff 50%, #999 100%);
|
background: repeating-linear-gradient(135deg,
|
||||||
background-size: 100% 100%;
|
#bbb 0, #999 5px,
|
||||||
background-repeat: no-repeat;
|
#999 45px, #ddd 55px,
|
||||||
|
#ddd 95px, #bbb 100px);
|
||||||
|
|
||||||
animation: progressIndeterminate 2s linear infinite;
|
animation: progressIndeterminate 950ms linear infinite;
|
||||||
}
|
}
|
||||||
|
|
||||||
.findbar, .secondaryToolbar {
|
.findbar, .secondaryToolbar {
|
||||||
@ -551,6 +567,13 @@ html[dir='ltr'] .doorHangerRight:before {
|
|||||||
margin-right: -9px;
|
margin-right: -9px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#findResultsCount {
|
||||||
|
background-color: hsl(0, 0%, 85%);
|
||||||
|
color: hsl(0, 0%, 32%);
|
||||||
|
text-align: center;
|
||||||
|
padding: 3px 4px;
|
||||||
|
}
|
||||||
|
|
||||||
#findMsg {
|
#findMsg {
|
||||||
font-style: italic;
|
font-style: italic;
|
||||||
color: #A6B7D0;
|
color: #A6B7D0;
|
||||||
|
@ -88,6 +88,7 @@ See https://github.com/adobe-type-tools/cmap-resources
|
|||||||
<label for="findHighlightAll" class="toolbarLabel" data-l10n-id="find_highlight">Highlight all</label>
|
<label for="findHighlightAll" class="toolbarLabel" data-l10n-id="find_highlight">Highlight all</label>
|
||||||
<input type="checkbox" id="findMatchCase" class="toolbarField" tabindex="95">
|
<input type="checkbox" id="findMatchCase" class="toolbarField" tabindex="95">
|
||||||
<label for="findMatchCase" class="toolbarLabel" data-l10n-id="find_match_case_label">Match case</label>
|
<label for="findMatchCase" class="toolbarLabel" data-l10n-id="find_match_case_label">Match case</label>
|
||||||
|
<span id="findResultsCount" class="toolbarLabel hidden"></span>
|
||||||
<span id="findMsg" class="toolbarLabel"></span>
|
<span id="findMsg" class="toolbarLabel"></span>
|
||||||
</div> <!-- findbar -->
|
</div> <!-- findbar -->
|
||||||
|
|
||||||
|
@ -31,7 +31,6 @@ var DEFAULT_URL = 'compressed.tracemonkey-pldi-09.pdf';
|
|||||||
var DEFAULT_SCALE_DELTA = 1.1;
|
var DEFAULT_SCALE_DELTA = 1.1;
|
||||||
var MIN_SCALE = 0.25;
|
var MIN_SCALE = 0.25;
|
||||||
var MAX_SCALE = 10.0;
|
var MAX_SCALE = 10.0;
|
||||||
var VIEW_HISTORY_MEMORY = 20;
|
|
||||||
var SCALE_SELECT_CONTAINER_PADDING = 8;
|
var SCALE_SELECT_CONTAINER_PADDING = 8;
|
||||||
var SCALE_SELECT_PADDING = 22;
|
var SCALE_SELECT_PADDING = 22;
|
||||||
var PAGE_NUMBER_LOADING_INDICATOR = 'visiblePageIsLoading';
|
var PAGE_NUMBER_LOADING_INDICATOR = 'visiblePageIsLoading';
|
||||||
@ -266,6 +265,55 @@ function binarySearchFirstItem(items, condition) {
|
|||||||
return minIndex; /* === maxIndex */
|
return minIndex; /* === maxIndex */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Approximates float number as a fraction using Farey sequence (max order
|
||||||
|
* of 8).
|
||||||
|
* @param {number} x - Positive float number.
|
||||||
|
* @returns {Array} Estimated fraction: the first array item is a numerator,
|
||||||
|
* the second one is a denominator.
|
||||||
|
*/
|
||||||
|
function approximateFraction(x) {
|
||||||
|
// Fast paths for int numbers or their inversions.
|
||||||
|
if (Math.floor(x) === x) {
|
||||||
|
return [x, 1];
|
||||||
|
}
|
||||||
|
var xinv = 1 / x;
|
||||||
|
var limit = 8;
|
||||||
|
if (xinv > limit) {
|
||||||
|
return [1, limit];
|
||||||
|
} else if (Math.floor(xinv) === xinv) {
|
||||||
|
return [1, xinv];
|
||||||
|
}
|
||||||
|
|
||||||
|
var x_ = x > 1 ? xinv : x;
|
||||||
|
// a/b and c/d are neighbours in Farey sequence.
|
||||||
|
var a = 0, b = 1, c = 1, d = 1;
|
||||||
|
// Limiting search to order 8.
|
||||||
|
while (true) {
|
||||||
|
// Generating next term in sequence (order of q).
|
||||||
|
var p = a + c, q = b + d;
|
||||||
|
if (q > limit) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (x_ <= p / q) {
|
||||||
|
c = p; d = q;
|
||||||
|
} else {
|
||||||
|
a = p; b = q;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Select closest of the neighbours to x.
|
||||||
|
if (x_ - a / b < c / d - x_) {
|
||||||
|
return x_ === x ? [a, b] : [b, a];
|
||||||
|
} else {
|
||||||
|
return x_ === x ? [c, d] : [d, c];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function roundToDivide(x, div) {
|
||||||
|
var r = x % div;
|
||||||
|
return r === 0 ? x : Math.round(x - r + div);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generic helper to find out what elements are visible within a scroll pane.
|
* Generic helper to find out what elements are visible within a scroll pane.
|
||||||
*/
|
*/
|
||||||
@ -733,6 +781,8 @@ Preferences._readFromStorage = function (prefObj) {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
var DEFAULT_VIEW_HISTORY_CACHE_SIZE = 20;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* View History - This is a utility for saving various view parameters for
|
* View History - This is a utility for saving various view parameters for
|
||||||
* recently opened files.
|
* recently opened files.
|
||||||
@ -743,8 +793,9 @@ Preferences._readFromStorage = function (prefObj) {
|
|||||||
* - GENERIC or CHROME - uses localStorage, if it is available.
|
* - GENERIC or CHROME - uses localStorage, if it is available.
|
||||||
*/
|
*/
|
||||||
var ViewHistory = (function ViewHistoryClosure() {
|
var ViewHistory = (function ViewHistoryClosure() {
|
||||||
function ViewHistory(fingerprint) {
|
function ViewHistory(fingerprint, cacheSize) {
|
||||||
this.fingerprint = fingerprint;
|
this.fingerprint = fingerprint;
|
||||||
|
this.cacheSize = cacheSize || DEFAULT_VIEW_HISTORY_CACHE_SIZE;
|
||||||
this.isInitializedPromiseResolved = false;
|
this.isInitializedPromiseResolved = false;
|
||||||
this.initializedPromise =
|
this.initializedPromise =
|
||||||
this._readFromStorage().then(function (databaseStr) {
|
this._readFromStorage().then(function (databaseStr) {
|
||||||
@ -754,7 +805,7 @@ var ViewHistory = (function ViewHistoryClosure() {
|
|||||||
if (!('files' in database)) {
|
if (!('files' in database)) {
|
||||||
database.files = [];
|
database.files = [];
|
||||||
}
|
}
|
||||||
if (database.files.length >= VIEW_HISTORY_MEMORY) {
|
if (database.files.length >= this.cacheSize) {
|
||||||
database.files.shift();
|
database.files.shift();
|
||||||
}
|
}
|
||||||
var index;
|
var index;
|
||||||
@ -836,6 +887,7 @@ var PDFFindBar = (function PDFFindBarClosure() {
|
|||||||
this.highlightAll = options.highlightAllCheckbox || null;
|
this.highlightAll = options.highlightAllCheckbox || null;
|
||||||
this.caseSensitive = options.caseSensitiveCheckbox || null;
|
this.caseSensitive = options.caseSensitiveCheckbox || null;
|
||||||
this.findMsg = options.findMsg || null;
|
this.findMsg = options.findMsg || null;
|
||||||
|
this.findResultsCount = options.findResultsCount || null;
|
||||||
this.findStatusIcon = options.findStatusIcon || null;
|
this.findStatusIcon = options.findStatusIcon || null;
|
||||||
this.findPreviousButton = options.findPreviousButton || null;
|
this.findPreviousButton = options.findPreviousButton || null;
|
||||||
this.findNextButton = options.findNextButton || null;
|
this.findNextButton = options.findNextButton || null;
|
||||||
@ -898,7 +950,8 @@ var PDFFindBar = (function PDFFindBarClosure() {
|
|||||||
return window.dispatchEvent(event);
|
return window.dispatchEvent(event);
|
||||||
},
|
},
|
||||||
|
|
||||||
updateUIState: function PDFFindBar_updateUIState(state, previous) {
|
updateUIState:
|
||||||
|
function PDFFindBar_updateUIState(state, previous, matchCount) {
|
||||||
var notFound = false;
|
var notFound = false;
|
||||||
var findMsg = '';
|
var findMsg = '';
|
||||||
var status = '';
|
var status = '';
|
||||||
@ -935,6 +988,26 @@ var PDFFindBar = (function PDFFindBarClosure() {
|
|||||||
|
|
||||||
this.findField.setAttribute('data-status', status);
|
this.findField.setAttribute('data-status', status);
|
||||||
this.findMsg.textContent = findMsg;
|
this.findMsg.textContent = findMsg;
|
||||||
|
|
||||||
|
this.updateResultsCount(matchCount);
|
||||||
|
},
|
||||||
|
|
||||||
|
updateResultsCount: function(matchCount) {
|
||||||
|
if (!this.findResultsCount) {
|
||||||
|
return; // no UI control is provided
|
||||||
|
}
|
||||||
|
|
||||||
|
// If there are no matches, hide the counter
|
||||||
|
if (!matchCount) {
|
||||||
|
this.findResultsCount.classList.add('hidden');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create the match counter
|
||||||
|
this.findResultsCount.textContent = matchCount.toLocaleString();
|
||||||
|
|
||||||
|
// Show the counter
|
||||||
|
this.findResultsCount.classList.remove('hidden');
|
||||||
},
|
},
|
||||||
|
|
||||||
open: function PDFFindBar_open() {
|
open: function PDFFindBar_open() {
|
||||||
@ -991,6 +1064,7 @@ var PDFFindController = (function PDFFindControllerClosure() {
|
|||||||
this.active = false; // If active, find results will be highlighted.
|
this.active = false; // If active, find results will be highlighted.
|
||||||
this.pageContents = []; // Stores the text for each page.
|
this.pageContents = []; // Stores the text for each page.
|
||||||
this.pageMatches = [];
|
this.pageMatches = [];
|
||||||
|
this.matchCount = 0;
|
||||||
this.selected = { // Currently selected match.
|
this.selected = { // Currently selected match.
|
||||||
pageIdx: -1,
|
pageIdx: -1,
|
||||||
matchIdx: -1
|
matchIdx: -1
|
||||||
@ -1068,7 +1142,8 @@ var PDFFindController = (function PDFFindControllerClosure() {
|
|||||||
var queryLen = query.length;
|
var queryLen = query.length;
|
||||||
|
|
||||||
if (queryLen === 0) {
|
if (queryLen === 0) {
|
||||||
return; // Do nothing: the matches should be wiped out already.
|
// Do nothing: the matches should be wiped out already.
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!caseSensitive) {
|
if (!caseSensitive) {
|
||||||
@ -1091,6 +1166,12 @@ var PDFFindController = (function PDFFindControllerClosure() {
|
|||||||
this.resumePageIdx = null;
|
this.resumePageIdx = null;
|
||||||
this.nextPageMatch();
|
this.nextPageMatch();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Update the matches count
|
||||||
|
if (matches.length > 0) {
|
||||||
|
this.matchCount += matches.length;
|
||||||
|
this.updateUIResultsCount();
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
extractText: function PDFFindController_extractText() {
|
extractText: function PDFFindController_extractText() {
|
||||||
@ -1182,6 +1263,7 @@ var PDFFindController = (function PDFFindControllerClosure() {
|
|||||||
this.hadMatch = false;
|
this.hadMatch = false;
|
||||||
this.resumePageIdx = null;
|
this.resumePageIdx = null;
|
||||||
this.pageMatches = [];
|
this.pageMatches = [];
|
||||||
|
this.matchCount = 0;
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
for (var i = 0; i < numPages; i++) {
|
for (var i = 0; i < numPages; i++) {
|
||||||
@ -1338,6 +1420,15 @@ var PDFFindController = (function PDFFindControllerClosure() {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
updateUIResultsCount:
|
||||||
|
function PDFFindController_updateUIResultsCount() {
|
||||||
|
if (this.findBar === null) {
|
||||||
|
throw new Error('PDFFindController is not initialized with a ' +
|
||||||
|
'PDFFindBar instance.');
|
||||||
|
}
|
||||||
|
this.findBar.updateResultsCount(this.matchCount);
|
||||||
|
},
|
||||||
|
|
||||||
updateUIState: function PDFFindController_updateUIState(state, previous) {
|
updateUIState: function PDFFindController_updateUIState(state, previous) {
|
||||||
if (this.integratedFind) {
|
if (this.integratedFind) {
|
||||||
FirefoxCom.request('updateFindControlState',
|
FirefoxCom.request('updateFindControlState',
|
||||||
@ -1348,7 +1439,7 @@ var PDFFindController = (function PDFFindControllerClosure() {
|
|||||||
throw new Error('PDFFindController is not initialized with a ' +
|
throw new Error('PDFFindController is not initialized with a ' +
|
||||||
'PDFFindBar instance.');
|
'PDFFindBar instance.');
|
||||||
}
|
}
|
||||||
this.findBar.updateUIState(state, previous);
|
this.findBar.updateUIState(state, previous, this.matchCount);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
return PDFFindController;
|
return PDFFindController;
|
||||||
@ -3705,7 +3796,7 @@ var PDFPageView = (function PDFPageViewClosure() {
|
|||||||
var outputScale = getOutputScale(ctx);
|
var outputScale = getOutputScale(ctx);
|
||||||
|
|
||||||
if (PDFJS.useOnlyCssZoom) {
|
if (PDFJS.useOnlyCssZoom) {
|
||||||
var actualSizeViewport = viewport.clone({ scale: CSS_UNITS });
|
var actualSizeViewport = viewport.clone({scale: CSS_UNITS});
|
||||||
// Use a scale that will make the canvas be the original intended size
|
// Use a scale that will make the canvas be the original intended size
|
||||||
// of the page.
|
// of the page.
|
||||||
outputScale.sx *= actualSizeViewport.width / viewport.width;
|
outputScale.sx *= actualSizeViewport.width / viewport.width;
|
||||||
@ -3726,10 +3817,12 @@ var PDFPageView = (function PDFPageViewClosure() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
canvas.width = (Math.floor(viewport.width) * outputScale.sx) | 0;
|
var sfx = approximateFraction(outputScale.sx);
|
||||||
canvas.height = (Math.floor(viewport.height) * outputScale.sy) | 0;
|
var sfy = approximateFraction(outputScale.sy);
|
||||||
canvas.style.width = Math.floor(viewport.width) + 'px';
|
canvas.width = roundToDivide(viewport.width * outputScale.sx, sfx[0]);
|
||||||
canvas.style.height = Math.floor(viewport.height) + 'px';
|
canvas.height = roundToDivide(viewport.height * outputScale.sy, sfy[0]);
|
||||||
|
canvas.style.width = roundToDivide(viewport.width, sfx[1]) + 'px';
|
||||||
|
canvas.style.height = roundToDivide(viewport.height, sfy[1]) + 'px';
|
||||||
// Add the viewport so it's known what it was originally drawn with.
|
// Add the viewport so it's known what it was originally drawn with.
|
||||||
canvas._viewport = viewport;
|
canvas._viewport = viewport;
|
||||||
|
|
||||||
@ -3969,12 +4062,17 @@ var TextLayerBuilder = (function TextLayerBuilderClosure() {
|
|||||||
this.viewport = options.viewport;
|
this.viewport = options.viewport;
|
||||||
this.textDivs = [];
|
this.textDivs = [];
|
||||||
this.findController = options.findController || null;
|
this.findController = options.findController || null;
|
||||||
|
this._bindMouse();
|
||||||
}
|
}
|
||||||
|
|
||||||
TextLayerBuilder.prototype = {
|
TextLayerBuilder.prototype = {
|
||||||
_finishRendering: function TextLayerBuilder_finishRendering() {
|
_finishRendering: function TextLayerBuilder_finishRendering() {
|
||||||
this.renderingDone = true;
|
this.renderingDone = true;
|
||||||
|
|
||||||
|
var endOfContent = document.createElement('div');
|
||||||
|
endOfContent.className = 'endOfContent';
|
||||||
|
this.textLayerDiv.appendChild(endOfContent);
|
||||||
|
|
||||||
var event = document.createEvent('CustomEvent');
|
var event = document.createEvent('CustomEvent');
|
||||||
event.initCustomEvent('textlayerrendered', true, true, {
|
event.initCustomEvent('textlayerrendered', true, true, {
|
||||||
pageNumber: this.pageNumber
|
pageNumber: this.pageNumber
|
||||||
@ -4310,7 +4408,30 @@ var TextLayerBuilder = (function TextLayerBuilderClosure() {
|
|||||||
this.matches = this.convertMatches(this.findController === null ?
|
this.matches = this.convertMatches(this.findController === null ?
|
||||||
[] : (this.findController.pageMatches[this.pageIdx] || []));
|
[] : (this.findController.pageMatches[this.pageIdx] || []));
|
||||||
this.renderMatches(this.matches);
|
this.renderMatches(this.matches);
|
||||||
}
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fixes text selection: adds additional div where mouse was clicked.
|
||||||
|
* This reduces flickering of the content if mouse slowly dragged down/up.
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
_bindMouse: function TextLayerBuilder_bindMouse() {
|
||||||
|
var div = this.textLayerDiv;
|
||||||
|
div.addEventListener('mousedown', function (e) {
|
||||||
|
var end = div.querySelector('.endOfContent');
|
||||||
|
if (!end) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
end.classList.add('active');
|
||||||
|
});
|
||||||
|
div.addEventListener('mouseup', function (e) {
|
||||||
|
var end = div.querySelector('.endOfContent');
|
||||||
|
if (!end) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
end.classList.remove('active');
|
||||||
|
});
|
||||||
|
},
|
||||||
};
|
};
|
||||||
return TextLayerBuilder;
|
return TextLayerBuilder;
|
||||||
})();
|
})();
|
||||||
@ -4930,6 +5051,10 @@ var PDFViewer = (function pdfViewer() {
|
|||||||
*/
|
*/
|
||||||
scrollPageIntoView: function PDFViewer_scrollPageIntoView(pageNumber,
|
scrollPageIntoView: function PDFViewer_scrollPageIntoView(pageNumber,
|
||||||
dest) {
|
dest) {
|
||||||
|
if (!this.pdfDocument) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var pageView = this._pages[pageNumber - 1];
|
var pageView = this._pages[pageNumber - 1];
|
||||||
|
|
||||||
if (this.isInPresentationMode) {
|
if (this.isInPresentationMode) {
|
||||||
@ -6111,6 +6236,7 @@ var PDFViewerApplication = {
|
|||||||
highlightAllCheckbox: document.getElementById('findHighlightAll'),
|
highlightAllCheckbox: document.getElementById('findHighlightAll'),
|
||||||
caseSensitiveCheckbox: document.getElementById('findMatchCase'),
|
caseSensitiveCheckbox: document.getElementById('findMatchCase'),
|
||||||
findMsg: document.getElementById('findMsg'),
|
findMsg: document.getElementById('findMsg'),
|
||||||
|
findResultsCount: document.getElementById('findResultsCount'),
|
||||||
findStatusIcon: document.getElementById('findStatusIcon'),
|
findStatusIcon: document.getElementById('findStatusIcon'),
|
||||||
findPreviousButton: document.getElementById('findPrevious'),
|
findPreviousButton: document.getElementById('findPrevious'),
|
||||||
findNextButton: document.getElementById('findNext'),
|
findNextButton: document.getElementById('findNext'),
|
||||||
@ -6338,6 +6464,16 @@ var PDFViewerApplication = {
|
|||||||
return PDFJS.shadow(this, 'loadingBar', bar);
|
return PDFJS.shadow(this, 'loadingBar', bar);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
get supportedMouseWheelZoomModifierKeys() {
|
||||||
|
var support = {
|
||||||
|
ctrlKey: true,
|
||||||
|
metaKey: true,
|
||||||
|
};
|
||||||
|
support = FirefoxCom.requestSync('supportedMouseWheelZoomModifierKeys');
|
||||||
|
|
||||||
|
return PDFJS.shadow(this, 'supportedMouseWheelZoomModifierKeys', support);
|
||||||
|
},
|
||||||
|
|
||||||
initPassiveLoading: function pdfViewInitPassiveLoading() {
|
initPassiveLoading: function pdfViewInitPassiveLoading() {
|
||||||
function FirefoxComDataRangeTransport(length, initialData) {
|
function FirefoxComDataRangeTransport(length, initialData) {
|
||||||
PDFJS.PDFDataRangeTransport.call(this, length, initialData);
|
PDFJS.PDFDataRangeTransport.call(this, length, initialData);
|
||||||
@ -7624,6 +7760,11 @@ function handleMouseWheel(evt) {
|
|||||||
PDFViewerApplication.scrollPresentationMode(ticks *
|
PDFViewerApplication.scrollPresentationMode(ticks *
|
||||||
MOUSE_WHEEL_DELTA_FACTOR);
|
MOUSE_WHEEL_DELTA_FACTOR);
|
||||||
} else if (evt.ctrlKey || evt.metaKey) {
|
} else if (evt.ctrlKey || evt.metaKey) {
|
||||||
|
var support = PDFViewerApplication.supportedMouseWheelZoomModifierKeys;
|
||||||
|
if ((evt.ctrlKey && !support.ctrlKey) ||
|
||||||
|
(evt.metaKey && !support.metaKey)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
// Only zoom the pages, not the entire viewer.
|
// Only zoom the pages, not the entire viewer.
|
||||||
evt.preventDefault();
|
evt.preventDefault();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user