Bug 1366004 - Update pdf.js to version 1.8.363. r=bdahl

This commit is contained in:
Ryan VanderMeulen 2017-05-18 13:40:06 -04:00
Родитель b138a8ec44
Коммит 96f477fd99
12 изменённых файлов: 131 добавлений и 138 удалений

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

@ -1,5 +1,5 @@
This is the PDF.js project output, https://github.com/mozilla/pdf.js
Current extension version is: 1.8.346
Current extension version is: 1.8.363
Taken from upstream commit: 15425d5b
Taken from upstream commit: 658fb03d

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

@ -12,8 +12,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/* globals Components, Services, XPCOMUtils, PdfjsChromeUtils,
PdfjsContentUtils, PdfStreamConverter */
"use strict";

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

@ -12,7 +12,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/* globals Components, Services */
"use strict";

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

@ -13,7 +13,6 @@
* limitations under the License.
*/
/* eslint max-len: ["error", 100] */
/* globals Components, Services */
"use strict";

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

@ -12,8 +12,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/* globals Components, Services, XPCOMUtils, NetUtil, PrivateBrowsingUtils,
dump, NetworkManager, PdfJsTelemetry, PdfjsContentUtils */
"use strict";

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

@ -12,7 +12,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/* globals Components, Services, XPCOMUtils */
"use strict";

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

@ -12,7 +12,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/* globals Components, Services, XPCOMUtils */
"use strict";

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

@ -1199,78 +1199,73 @@ exports.DOMCMapReaderFactory = exports.DOMCanvasFactory = exports.DEFAULT_LINK_R
var _util = __w_pdfjs_require__(0);
var DEFAULT_LINK_REL = 'noopener noreferrer nofollow';
function DOMCanvasFactory() {}
DOMCanvasFactory.prototype = {
create: function DOMCanvasFactory_create(width, height) {
class DOMCanvasFactory {
create(width, height) {
(0, _util.assert)(width > 0 && height > 0, 'invalid canvas size');
var canvas = document.createElement('canvas');
var context = canvas.getContext('2d');
let canvas = document.createElement('canvas');
let context = canvas.getContext('2d');
canvas.width = width;
canvas.height = height;
return {
canvas,
context
};
},
reset: function DOMCanvasFactory_reset(canvasAndContextPair, width, height) {
(0, _util.assert)(canvasAndContextPair.canvas, 'canvas is not specified');
}
reset(canvasAndContext, width, height) {
(0, _util.assert)(canvasAndContext.canvas, 'canvas is not specified');
(0, _util.assert)(width > 0 && height > 0, 'invalid canvas size');
canvasAndContextPair.canvas.width = width;
canvasAndContextPair.canvas.height = height;
},
destroy: function DOMCanvasFactory_destroy(canvasAndContextPair) {
(0, _util.assert)(canvasAndContextPair.canvas, 'canvas is not specified');
canvasAndContextPair.canvas.width = 0;
canvasAndContextPair.canvas.height = 0;
canvasAndContextPair.canvas = null;
canvasAndContextPair.context = null;
canvasAndContext.canvas.width = width;
canvasAndContext.canvas.height = height;
}
};
var DOMCMapReaderFactory = function DOMCMapReaderFactoryClosure() {
function DOMCMapReaderFactory(params) {
this.baseUrl = params.baseUrl || null;
this.isCompressed = params.isCompressed || false;
destroy(canvasAndContext) {
(0, _util.assert)(canvasAndContext.canvas, 'canvas is not specified');
canvasAndContext.canvas.width = 0;
canvasAndContext.canvas.height = 0;
canvasAndContext.canvas = null;
canvasAndContext.context = null;
}
DOMCMapReaderFactory.prototype = {
fetch(params) {
var name = params.name;
if (!name) {
return Promise.reject(new Error('CMap name must be specified.'));
}
class DOMCMapReaderFactory {
constructor({ baseUrl = null, isCompressed = false }) {
this.baseUrl = baseUrl;
this.isCompressed = isCompressed;
}
fetch({ name }) {
if (!name) {
return Promise.reject(new Error('CMap name must be specified.'));
}
return new Promise((resolve, reject) => {
let url = this.baseUrl + name + (this.isCompressed ? '.bcmap' : '');
let request = new XMLHttpRequest();
request.open('GET', url, true);
if (this.isCompressed) {
request.responseType = 'arraybuffer';
}
return new Promise((resolve, reject) => {
var url = this.baseUrl + name + (this.isCompressed ? '.bcmap' : '');
var request = new XMLHttpRequest();
request.open('GET', url, true);
if (this.isCompressed) {
request.responseType = 'arraybuffer';
request.onreadystatechange = () => {
if (request.readyState !== XMLHttpRequest.DONE) {
return;
}
request.onreadystatechange = () => {
if (request.readyState !== XMLHttpRequest.DONE) {
if (request.status === 200 || request.status === 0) {
let data;
if (this.isCompressed && request.response) {
data = new Uint8Array(request.response);
} else if (!this.isCompressed && request.responseText) {
data = (0, _util.stringToBytes)(request.responseText);
}
if (data) {
resolve({
cMapData: data,
compressionType: this.isCompressed ? _util.CMapCompressionType.BINARY : _util.CMapCompressionType.NONE
});
return;
}
if (request.status === 200 || request.status === 0) {
var data;
if (this.isCompressed && request.response) {
data = new Uint8Array(request.response);
} else if (!this.isCompressed && request.responseText) {
data = (0, _util.stringToBytes)(request.responseText);
}
if (data) {
resolve({
cMapData: data,
compressionType: this.isCompressed ? _util.CMapCompressionType.BINARY : _util.CMapCompressionType.NONE
});
return;
}
}
reject(new Error('Unable to load ' + (this.isCompressed ? 'binary ' : '') + 'CMap at: ' + url));
};
request.send(null);
});
}
};
return DOMCMapReaderFactory;
}();
}
reject(new Error('Unable to load ' + (this.isCompressed ? 'binary ' : '') + 'CMap at: ' + url));
};
request.send(null);
});
}
}
var CustomStyle = function CustomStyleClosure() {
var prefixes = ['ms', 'Moz', 'Webkit', 'O'];
var _cache = Object.create(null);
@ -3328,7 +3323,12 @@ var InternalRenderTask = function InternalRenderTaskClosure() {
}
var params = this.params;
this.gfx = new _canvas.CanvasGraphics(params.canvasContext, this.commonObjs, this.objs, this.canvasFactory, params.imageLayer);
this.gfx.beginDrawing(params.transform, params.viewport, transparency);
this.gfx.beginDrawing({
transform: params.transform,
viewport: params.viewport,
transparency,
background: params.background
});
this.operatorListIdx = 0;
this.graphicsReady = true;
if (this.graphicsReadyCallback) {
@ -3405,8 +3405,8 @@ var _UnsupportedManager = function UnsupportedManagerClosure() {
}();
var version, build;
{
exports.version = version = '1.8.346';
exports.build = build = '15425d5b';
exports.version = version = '1.8.363';
exports.build = build = '658fb03d';
}
exports.getDocument = getDocument;
exports.LoopbackPort = LoopbackPort;
@ -4408,8 +4408,8 @@ if (!_util.globalScope.PDFJS) {
}
var PDFJS = _util.globalScope.PDFJS;
{
PDFJS.version = '1.8.346';
PDFJS.build = '15425d5b';
PDFJS.version = '1.8.363';
PDFJS.build = '658fb03d';
}
PDFJS.pdfBug = false;
if (PDFJS.verbosity !== undefined) {
@ -5060,11 +5060,11 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
var NORMAL_CLIP = {};
var EO_CLIP = {};
CanvasGraphics.prototype = {
beginDrawing: function CanvasGraphics_beginDrawing(transform, viewport, transparency) {
beginDrawing({ transform, viewport, transparency, background = null }) {
var width = this.ctx.canvas.width;
var height = this.ctx.canvas.height;
this.ctx.save();
this.ctx.fillStyle = 'rgb(255, 255, 255)';
this.ctx.fillStyle = background || 'rgb(255, 255, 255)';
this.ctx.fillRect(0, 0, width, height);
this.ctx.restore();
if (transparency) {
@ -6723,8 +6723,8 @@ exports.TilingPattern = TilingPattern;
"use strict";
var pdfjsVersion = '1.8.346';
var pdfjsBuild = '15425d5b';
var pdfjsVersion = '1.8.363';
var pdfjsBuild = '658fb03d';
var pdfjsSharedUtil = __w_pdfjs_require__(0);
var pdfjsDisplayGlobal = __w_pdfjs_require__(8);
var pdfjsDisplayAPI = __w_pdfjs_require__(3);

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

@ -16738,6 +16738,12 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
if (nativeImageDecoderSupport !== NativeImageDecoding.NONE && !softMask && !mask && image instanceof JpegStream && NativeImageDecoder.isSupported(image, this.xref, resources)) {
operatorList.addOp(OPS.paintJpegXObject, args);
this.handler.send('obj', [objId, this.pageIndex, 'JpegStream', image.getIR(this.options.forceDataSchema)]);
if (cacheKey) {
imageCache[cacheKey] = {
fn: OPS.paintJpegXObject,
args
};
}
return;
}
var nativeImageDecoder = null;
@ -36639,8 +36645,8 @@ exports.Type1Parser = Type1Parser;
"use strict";
var pdfjsVersion = '1.8.346';
var pdfjsBuild = '15425d5b';
var pdfjsVersion = '1.8.363';
var pdfjsBuild = '658fb03d';
var pdfjsCoreWorker = __w_pdfjs_require__(17);
;
exports.WorkerMessageHandler = pdfjsCoreWorker.WorkerMessageHandler;

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

@ -12,7 +12,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/* globals Components, PdfJs, Services */
"use strict";

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

@ -12,7 +12,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/* globals Components, PdfjsContentUtils */
"use strict";

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

@ -4852,16 +4852,15 @@ var PDFPageView = function PDFPageViewClosure() {
getPagePoint: function PDFPageView_getPagePoint(x, y) {
return this.viewport.convertToPdfPoint(x, y);
},
draw: function PDFPageView_draw() {
draw() {
if (this.renderingState !== _pdf_rendering_queue.RenderingStates.INITIAL) {
console.error('Must be in new state before drawing');
this.reset();
}
this.renderingState = _pdf_rendering_queue.RenderingStates.RUNNING;
var self = this;
var pdfPage = this.pdfPage;
var div = this.div;
var canvasWrapper = document.createElement('div');
let pdfPage = this.pdfPage;
let div = this.div;
let canvasWrapper = document.createElement('div');
canvasWrapper.style.width = div.style.width;
canvasWrapper.style.height = div.style.height;
canvasWrapper.classList.add('canvasWrapper');
@ -4870,10 +4869,9 @@ var PDFPageView = function PDFPageViewClosure() {
} else {
div.appendChild(canvasWrapper);
}
var textLayerDiv = null;
var textLayer = null;
let textLayer = null;
if (this.textLayerFactory) {
textLayerDiv = document.createElement('div');
let textLayerDiv = document.createElement('div');
textLayerDiv.className = 'textLayer';
textLayerDiv.style.width = canvasWrapper.style.width;
textLayerDiv.style.height = canvasWrapper.style.height;
@ -4885,13 +4883,13 @@ var PDFPageView = function PDFPageViewClosure() {
textLayer = this.textLayerFactory.createTextLayerBuilder(textLayerDiv, this.id - 1, this.viewport, this.enhanceTextSelection);
}
this.textLayer = textLayer;
var renderContinueCallback = null;
let renderContinueCallback = null;
if (this.renderingQueue) {
renderContinueCallback = function renderContinueCallback(cont) {
if (!self.renderingQueue.isHighestPriority(self)) {
self.renderingState = _pdf_rendering_queue.RenderingStates.PAUSED;
self.resume = function resumeCallback() {
self.renderingState = _pdf_rendering_queue.RenderingStates.RUNNING;
renderContinueCallback = cont => {
if (!this.renderingQueue.isHighestPriority(this)) {
this.renderingState = _pdf_rendering_queue.RenderingStates.PAUSED;
this.resume = () => {
this.renderingState = _pdf_rendering_queue.RenderingStates.RUNNING;
cont();
};
return;
@ -4899,28 +4897,28 @@ var PDFPageView = function PDFPageViewClosure() {
cont();
};
}
var finishPaintTask = function finishPaintTask(error) {
if (paintTask === self.paintTask) {
self.paintTask = null;
let finishPaintTask = error => {
if (paintTask === this.paintTask) {
this.paintTask = null;
}
if (error instanceof _pdfjs.RenderingCancelledException) {
self.error = null;
this.error = null;
return Promise.resolve(undefined);
}
self.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
if (self.loadingIconDiv) {
div.removeChild(self.loadingIconDiv);
delete self.loadingIconDiv;
this.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
if (this.loadingIconDiv) {
div.removeChild(this.loadingIconDiv);
delete this.loadingIconDiv;
}
self._resetZoomLayer(true);
self.error = error;
self.stats = pdfPage.stats;
if (self.onAfterDraw) {
self.onAfterDraw();
this._resetZoomLayer(true);
this.error = error;
this.stats = pdfPage.stats;
if (this.onAfterDraw) {
this.onAfterDraw();
}
self.eventBus.dispatch('pagerendered', {
source: self,
pageNumber: self.id,
this.eventBus.dispatch('pagerendered', {
source: this,
pageNumber: this.id,
cssTransform: false
});
if (error) {
@ -4928,10 +4926,10 @@ var PDFPageView = function PDFPageViewClosure() {
}
return Promise.resolve(undefined);
};
var paintTask = this.renderer === _ui_utils.RendererType.SVG ? this.paintOnSvg(canvasWrapper) : this.paintOnCanvas(canvasWrapper);
let paintTask = this.renderer === _ui_utils.RendererType.SVG ? this.paintOnSvg(canvasWrapper) : this.paintOnCanvas(canvasWrapper);
paintTask.onRenderContinue = renderContinueCallback;
this.paintTask = paintTask;
var resultPromise = paintTask.promise.then(function () {
let resultPromise = paintTask.promise.then(function () {
return finishPaintTask(null).then(function () {
if (textLayer) {
pdfPage.getTextContent({ normalizeWhitespace: true }).then(function textContentResolved(textContent) {
@ -5024,16 +5022,16 @@ var PDFPageView = function PDFPageViewClosure() {
cont();
}
};
renderTask.promise.then(function pdfPageRenderCallback() {
renderTask.promise.then(function () {
showCanvas();
renderCapability.resolve(undefined);
}, function pdfPageRenderError(error) {
}, function (error) {
showCanvas();
renderCapability.reject(error);
});
return result;
},
paintOnSvg: function PDFPageView_paintOnSvg(wrapper) {
paintOnSvg(wrapper) {
return {
promise: Promise.reject(new Error('SVG rendering is not supported.')),
onRenderContinue(cont) {},
@ -5845,53 +5843,52 @@ var PDFThumbnailView = function PDFThumbnailViewClosure() {
this.canvas.height = 0;
delete this.canvas;
},
draw: function PDFThumbnailView_draw() {
draw() {
if (this.renderingState !== _pdf_rendering_queue.RenderingStates.INITIAL) {
console.error('Must be in new state before drawing');
return Promise.resolve(undefined);
}
this.renderingState = _pdf_rendering_queue.RenderingStates.RUNNING;
var renderCapability = (0, _pdfjs.createPromiseCapability)();
var self = this;
function thumbnailDrawCallback(error) {
if (renderTask === self.renderTask) {
self.renderTask = null;
let renderCapability = (0, _pdfjs.createPromiseCapability)();
let finishRenderTask = error => {
if (renderTask === this.renderTask) {
this.renderTask = null;
}
if (error instanceof _pdfjs.RenderingCancelledException) {
renderCapability.resolve(undefined);
return;
}
self.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
self._convertCanvasToImage();
this.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
this._convertCanvasToImage();
if (!error) {
renderCapability.resolve(undefined);
} else {
renderCapability.reject(error);
}
}
var ctx = this._getPageDrawContext();
var drawViewport = this.viewport.clone({ scale: this.scale });
var renderContinueCallback = function renderContinueCallback(cont) {
if (!self.renderingQueue.isHighestPriority(self)) {
self.renderingState = _pdf_rendering_queue.RenderingStates.PAUSED;
self.resume = function resumeCallback() {
self.renderingState = _pdf_rendering_queue.RenderingStates.RUNNING;
};
let ctx = this._getPageDrawContext();
let drawViewport = this.viewport.clone({ scale: this.scale });
let renderContinueCallback = cont => {
if (!this.renderingQueue.isHighestPriority(this)) {
this.renderingState = _pdf_rendering_queue.RenderingStates.PAUSED;
this.resume = () => {
this.renderingState = _pdf_rendering_queue.RenderingStates.RUNNING;
cont();
};
return;
}
cont();
};
var renderContext = {
let renderContext = {
canvasContext: ctx,
viewport: drawViewport
};
var renderTask = this.renderTask = this.pdfPage.render(renderContext);
let renderTask = this.renderTask = this.pdfPage.render(renderContext);
renderTask.onContinue = renderContinueCallback;
renderTask.promise.then(function pdfPageRenderCallback() {
thumbnailDrawCallback(null);
}, function pdfPageRenderError(error) {
thumbnailDrawCallback(error);
renderTask.promise.then(function () {
finishRenderTask(null);
}, function (error) {
finishRenderTask(error);
});
return renderCapability.promise;
},