mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1226621 - Update pdf.js to version 1.3.14. r=bdahl
This commit is contained in:
parent
5b2792e618
commit
69c4ba559c
@ -1,3 +1,3 @@
|
||||
This is the pdf.js project output, https://github.com/mozilla/pdf.js
|
||||
|
||||
Current extension version is: 1.2.109
|
||||
Current extension version is: 1.3.14
|
||||
|
@ -1,5 +1,3 @@
|
||||
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
|
||||
/* Copyright 2012 Mozilla Foundation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@ -14,11 +12,6 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/* jshint esnext:true */
|
||||
/* globals Components, Services, XPCOMUtils, PdfjsChromeUtils,
|
||||
PdfjsContentUtils, DEFAULT_PREFERENCES, PdfStreamConverter */
|
||||
|
||||
'use strict';
|
||||
|
||||
var EXPORTED_SYMBOLS = ['PdfJs'];
|
||||
|
||||
|
@ -1,5 +1,3 @@
|
||||
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
|
||||
/* Copyright 2013 Mozilla Foundation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
|
@ -1,5 +1,3 @@
|
||||
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
|
||||
/* Copyright 2012 Mozilla Foundation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
|
@ -1,5 +1,3 @@
|
||||
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
|
||||
/* Copyright 2012 Mozilla Foundation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@ -14,10 +12,6 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/* jshint esnext:true */
|
||||
/* globals Components, Services, XPCOMUtils, DEFAULT_PREFERENCES */
|
||||
|
||||
'use strict';
|
||||
|
||||
var EXPORTED_SYMBOLS = ['PdfjsChromeUtils'];
|
||||
|
||||
|
@ -1,5 +1,3 @@
|
||||
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
|
||||
/* Copyright 2012 Mozilla Foundation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
|
@ -1,5 +1,3 @@
|
||||
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
|
||||
/* Copyright 2012 Mozilla Foundation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@ -22,8 +20,8 @@ if (typeof PDFJS === 'undefined') {
|
||||
(typeof window !== 'undefined' ? window : this).PDFJS = {};
|
||||
}
|
||||
|
||||
PDFJS.version = '1.2.109';
|
||||
PDFJS.build = '875588d';
|
||||
PDFJS.version = '1.3.14';
|
||||
PDFJS.build = 'df46b64';
|
||||
|
||||
(function pdfjsWrapper() {
|
||||
// Use strict in our context only - users might not want it
|
||||
@ -1963,6 +1961,8 @@ var PDFDocumentProxy = (function PDFDocumentProxyClosure() {
|
||||
* calling of PDFPage.getViewport method.
|
||||
* @property {string} intent - Rendering intent, can be 'display' or 'print'
|
||||
* (default value is 'display').
|
||||
* @property {Array} transform - (optional) Additional transform, applied
|
||||
* just before viewport transform.
|
||||
* @property {Object} imageLayer - (optional) An object that has beginLayout,
|
||||
* endLayout and appendImage functions.
|
||||
* @property {function} continueCallback - (deprecated) A function that will be
|
||||
@ -3025,7 +3025,7 @@ var InternalRenderTask = (function InternalRenderTaskClosure() {
|
||||
this.gfx = new CanvasGraphics(params.canvasContext, this.commonObjs,
|
||||
this.objs, params.imageLayer);
|
||||
|
||||
this.gfx.beginDrawing(params.viewport, transparency);
|
||||
this.gfx.beginDrawing(params.transform, params.viewport, transparency);
|
||||
this.operatorListIdx = 0;
|
||||
this.graphicsReady = true;
|
||||
if (this.graphicsReadyCallback) {
|
||||
@ -3322,13 +3322,15 @@ function addContextCurrentTransform(ctx) {
|
||||
}
|
||||
|
||||
var CachedCanvases = (function CachedCanvasesClosure() {
|
||||
var cache = {};
|
||||
return {
|
||||
function CachedCanvases() {
|
||||
this.cache = Object.create(null);
|
||||
}
|
||||
CachedCanvases.prototype = {
|
||||
getCanvas: function CachedCanvases_getCanvas(id, width, height,
|
||||
trackTransform) {
|
||||
var canvasEntry;
|
||||
if (cache[id] !== undefined) {
|
||||
canvasEntry = cache[id];
|
||||
if (this.cache[id] !== undefined) {
|
||||
canvasEntry = this.cache[id];
|
||||
canvasEntry.canvas.width = width;
|
||||
canvasEntry.canvas.height = height;
|
||||
// reset canvas transform for emulated mozCurrentTransform, if needed
|
||||
@ -3339,21 +3341,22 @@ var CachedCanvases = (function CachedCanvasesClosure() {
|
||||
if (trackTransform) {
|
||||
addContextCurrentTransform(ctx);
|
||||
}
|
||||
cache[id] = canvasEntry = {canvas: canvas, context: ctx};
|
||||
this.cache[id] = canvasEntry = {canvas: canvas, context: ctx};
|
||||
}
|
||||
return canvasEntry;
|
||||
},
|
||||
clear: function () {
|
||||
for (var id in cache) {
|
||||
var canvasEntry = cache[id];
|
||||
for (var id in this.cache) {
|
||||
var canvasEntry = this.cache[id];
|
||||
// Zeroing the width and height causes Firefox to release graphics
|
||||
// resources immediately, which can greatly reduce memory consumption.
|
||||
canvasEntry.canvas.width = 0;
|
||||
canvasEntry.canvas.height = 0;
|
||||
delete cache[id];
|
||||
delete this.cache[id];
|
||||
}
|
||||
}
|
||||
};
|
||||
return CachedCanvases;
|
||||
})();
|
||||
|
||||
function compileType3Glyph(imgData) {
|
||||
@ -3591,6 +3594,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
|
||||
this.smaskStack = [];
|
||||
this.smaskCounter = 0;
|
||||
this.tempSMask = null;
|
||||
this.cachedCanvases = new CachedCanvases();
|
||||
if (canvasCtx) {
|
||||
// NOTE: if mozCurrentTransform is polyfilled, then the current state of
|
||||
// the transformation must already be set in canvasCtx._transformMatrix.
|
||||
@ -3867,28 +3871,39 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
|
||||
|
||||
CanvasGraphics.prototype = {
|
||||
|
||||
beginDrawing: function CanvasGraphics_beginDrawing(viewport, transparency) {
|
||||
beginDrawing: function CanvasGraphics_beginDrawing(transform, viewport,
|
||||
transparency) {
|
||||
// For pdfs that use blend modes we have to clear the canvas else certain
|
||||
// blend modes can look wrong since we'd be blending with a white
|
||||
// backdrop. The problem with a transparent backdrop though is we then
|
||||
// don't get sub pixel anti aliasing on text, so we fill with white if
|
||||
// we can.
|
||||
// don't get sub pixel anti aliasing on text, creating temporary
|
||||
// transparent canvas when we have blend modes.
|
||||
var width = this.ctx.canvas.width;
|
||||
var height = this.ctx.canvas.height;
|
||||
if (transparency) {
|
||||
this.ctx.clearRect(0, 0, width, height);
|
||||
} else {
|
||||
this.ctx.mozOpaque = true;
|
||||
this.ctx.save();
|
||||
this.ctx.fillStyle = 'rgb(255, 255, 255)';
|
||||
this.ctx.fillRect(0, 0, width, height);
|
||||
this.ctx.restore();
|
||||
}
|
||||
|
||||
var transform = viewport.transform;
|
||||
|
||||
this.ctx.save();
|
||||
this.ctx.transform.apply(this.ctx, transform);
|
||||
this.ctx.fillStyle = 'rgb(255, 255, 255)';
|
||||
this.ctx.fillRect(0, 0, width, height);
|
||||
this.ctx.restore();
|
||||
|
||||
if (transparency) {
|
||||
var transparentCanvas = this.cachedCanvases.getCanvas(
|
||||
'transparent', width, height, true);
|
||||
this.compositeCtx = this.ctx;
|
||||
this.transparentCanvas = transparentCanvas.canvas;
|
||||
this.ctx = transparentCanvas.context;
|
||||
this.ctx.save();
|
||||
// The transform can be applied before rendering, transferring it to
|
||||
// the new canvas.
|
||||
this.ctx.transform.apply(this.ctx,
|
||||
this.compositeCtx.mozCurrentTransform);
|
||||
}
|
||||
|
||||
this.ctx.save();
|
||||
if (transform) {
|
||||
this.ctx.transform.apply(this.ctx, transform);
|
||||
}
|
||||
this.ctx.transform.apply(this.ctx, viewport.transform);
|
||||
|
||||
this.baseTransform = this.ctx.mozCurrentTransform.slice();
|
||||
|
||||
@ -3970,7 +3985,14 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
|
||||
|
||||
endDrawing: function CanvasGraphics_endDrawing() {
|
||||
this.ctx.restore();
|
||||
CachedCanvases.clear();
|
||||
|
||||
if (this.transparentCanvas) {
|
||||
this.ctx = this.compositeCtx;
|
||||
this.ctx.drawImage(this.transparentCanvas, 0, 0);
|
||||
this.transparentCanvas = null;
|
||||
}
|
||||
|
||||
this.cachedCanvases.clear();
|
||||
WebGLUtils.clear();
|
||||
|
||||
if (this.imageLayer) {
|
||||
@ -4084,7 +4106,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
|
||||
var drawnWidth = activeSMask.canvas.width;
|
||||
var drawnHeight = activeSMask.canvas.height;
|
||||
var cacheId = 'smaskGroupAt' + this.groupLevel;
|
||||
var scratchCanvas = CachedCanvases.getCanvas(
|
||||
var scratchCanvas = this.cachedCanvases.getCanvas(
|
||||
cacheId, drawnWidth, drawnHeight, true);
|
||||
|
||||
var currentCtx = this.ctx;
|
||||
@ -4868,7 +4890,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
|
||||
// Using two cache entries is case if masks are used one after another.
|
||||
cacheId += '_smask_' + ((this.smaskCounter++) % 2);
|
||||
}
|
||||
var scratchCanvas = CachedCanvases.getCanvas(
|
||||
var scratchCanvas = this.cachedCanvases.getCanvas(
|
||||
cacheId, drawnWidth, drawnHeight, true);
|
||||
var groupCtx = scratchCanvas.context;
|
||||
|
||||
@ -5009,7 +5031,8 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
|
||||
return;
|
||||
}
|
||||
|
||||
var maskCanvas = CachedCanvases.getCanvas('maskCanvas', width, height);
|
||||
var maskCanvas = this.cachedCanvases.getCanvas('maskCanvas',
|
||||
width, height);
|
||||
var maskCtx = maskCanvas.context;
|
||||
maskCtx.save();
|
||||
|
||||
@ -5034,7 +5057,8 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
|
||||
var fillColor = this.current.fillColor;
|
||||
var isPatternFill = this.current.patternFill;
|
||||
|
||||
var maskCanvas = CachedCanvases.getCanvas('maskCanvas', width, height);
|
||||
var maskCanvas = this.cachedCanvases.getCanvas('maskCanvas',
|
||||
width, height);
|
||||
var maskCtx = maskCanvas.context;
|
||||
maskCtx.save();
|
||||
|
||||
@ -5069,7 +5093,8 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
|
||||
var image = images[i];
|
||||
var width = image.width, height = image.height;
|
||||
|
||||
var maskCanvas = CachedCanvases.getCanvas('maskCanvas', width, height);
|
||||
var maskCanvas = this.cachedCanvases.getCanvas('maskCanvas',
|
||||
width, height);
|
||||
var maskCtx = maskCanvas.context;
|
||||
maskCtx.save();
|
||||
|
||||
@ -5142,7 +5167,8 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
|
||||
if (imgData instanceof HTMLElement || !imgData.data) {
|
||||
imgToPaint = imgData;
|
||||
} else {
|
||||
tmpCanvas = CachedCanvases.getCanvas('inlineImage', width, height);
|
||||
tmpCanvas = this.cachedCanvases.getCanvas('inlineImage',
|
||||
width, height);
|
||||
var tmpCtx = tmpCanvas.context;
|
||||
putBinaryImageData(tmpCtx, imgData);
|
||||
imgToPaint = tmpCanvas.canvas;
|
||||
@ -5164,7 +5190,8 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
|
||||
newHeight = Math.ceil(paintHeight / 2);
|
||||
heightScale /= paintHeight / newHeight;
|
||||
}
|
||||
tmpCanvas = CachedCanvases.getCanvas(tmpCanvasId, newWidth, newHeight);
|
||||
tmpCanvas = this.cachedCanvases.getCanvas(tmpCanvasId,
|
||||
newWidth, newHeight);
|
||||
tmpCtx = tmpCanvas.context;
|
||||
tmpCtx.clearRect(0, 0, newWidth, newHeight);
|
||||
tmpCtx.drawImage(imgToPaint, 0, 0, paintWidth, paintHeight,
|
||||
@ -5196,7 +5223,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
|
||||
var w = imgData.width;
|
||||
var h = imgData.height;
|
||||
|
||||
var tmpCanvas = CachedCanvases.getCanvas('inlineImage', w, h);
|
||||
var tmpCanvas = this.cachedCanvases.getCanvas('inlineImage', w, h);
|
||||
var tmpCtx = tmpCanvas.context;
|
||||
putBinaryImageData(tmpCtx, imgData);
|
||||
|
||||
@ -5854,7 +5881,7 @@ var createMeshCanvas = (function createMeshCanvasClosure() {
|
||||
}
|
||||
|
||||
function createMeshCanvas(bounds, combinesScale, coords, colors, figures,
|
||||
backgroundColor) {
|
||||
backgroundColor, cachedCanvases) {
|
||||
// we will increase scale on some weird factor to let antialiasing take
|
||||
// care of "rough" edges
|
||||
var EXPECTED_SCALE = 1.1;
|
||||
@ -5888,11 +5915,11 @@ var createMeshCanvas = (function createMeshCanvasClosure() {
|
||||
figures, context);
|
||||
|
||||
// https://bugzilla.mozilla.org/show_bug.cgi?id=972126
|
||||
tmpCanvas = CachedCanvases.getCanvas('mesh', width, height, false);
|
||||
tmpCanvas = cachedCanvases.getCanvas('mesh', width, height, false);
|
||||
tmpCanvas.context.drawImage(canvas, 0, 0);
|
||||
canvas = tmpCanvas.canvas;
|
||||
} else {
|
||||
tmpCanvas = CachedCanvases.getCanvas('mesh', width, height, false);
|
||||
tmpCanvas = cachedCanvases.getCanvas('mesh', width, height, false);
|
||||
var tmpCtx = tmpCanvas.context;
|
||||
|
||||
var data = tmpCtx.createImageData(width, height);
|
||||
@ -5948,7 +5975,8 @@ ShadingIRs.Mesh = {
|
||||
// Rasterizing on the main thread since sending/queue large canvases
|
||||
// might cause OOM.
|
||||
var temporaryPatternCanvas = createMeshCanvas(bounds, scale, coords,
|
||||
colors, figures, shadingFill ? null : background);
|
||||
colors, figures, shadingFill ? null : background,
|
||||
owner.cachedCanvases);
|
||||
|
||||
if (!shadingFill) {
|
||||
ctx.setTransform.apply(ctx, owner.baseTransform);
|
||||
@ -6051,7 +6079,8 @@ var TilingPattern = (function TilingPatternClosure() {
|
||||
height = Math.min(Math.ceil(Math.abs(height * combinedScale[1])),
|
||||
MAX_PATTERN_SIZE);
|
||||
|
||||
var tmpCanvas = CachedCanvases.getCanvas('pattern', width, height, true);
|
||||
var tmpCanvas = owner.cachedCanvases.getCanvas('pattern',
|
||||
width, height, true);
|
||||
var tmpCtx = tmpCanvas.context;
|
||||
var graphics = new CanvasGraphics(tmpCtx, commonObjs, objs);
|
||||
graphics.groupLevel = owner.groupLevel;
|
||||
@ -6254,6 +6283,63 @@ var FontFaceObject = (function FontFaceObjectClosure() {
|
||||
})();
|
||||
|
||||
|
||||
/**
|
||||
* Optimised CSS custom property getter/setter.
|
||||
* @class
|
||||
*/
|
||||
var CustomStyle = (function CustomStyleClosure() {
|
||||
|
||||
// As noted on: http://www.zachstronaut.com/posts/2009/02/17/
|
||||
// animate-css-transforms-firefox-webkit.html
|
||||
// in some versions of IE9 it is critical that ms appear in this list
|
||||
// before Moz
|
||||
var prefixes = ['ms', 'Moz', 'Webkit', 'O'];
|
||||
var _cache = {};
|
||||
|
||||
function CustomStyle() {}
|
||||
|
||||
CustomStyle.getProp = function get(propName, element) {
|
||||
// check cache only when no element is given
|
||||
if (arguments.length === 1 && typeof _cache[propName] === 'string') {
|
||||
return _cache[propName];
|
||||
}
|
||||
|
||||
element = element || document.documentElement;
|
||||
var style = element.style, prefixed, uPropName;
|
||||
|
||||
// test standard property first
|
||||
if (typeof style[propName] === 'string') {
|
||||
return (_cache[propName] = propName);
|
||||
}
|
||||
|
||||
// capitalize
|
||||
uPropName = propName.charAt(0).toUpperCase() + propName.slice(1);
|
||||
|
||||
// test vendor specific properties
|
||||
for (var i = 0, l = prefixes.length; i < l; i++) {
|
||||
prefixed = prefixes[i] + uPropName;
|
||||
if (typeof style[prefixed] === 'string') {
|
||||
return (_cache[propName] = prefixed);
|
||||
}
|
||||
}
|
||||
|
||||
//if all fails then set to undefined
|
||||
return (_cache[propName] = 'undefined');
|
||||
};
|
||||
|
||||
CustomStyle.setProp = function set(propName, element, str) {
|
||||
var prop = this.getProp(propName);
|
||||
if (prop !== 'undefined') {
|
||||
element.style[prop] = str;
|
||||
}
|
||||
};
|
||||
|
||||
return CustomStyle;
|
||||
})();
|
||||
|
||||
PDFJS.CustomStyle = CustomStyle;
|
||||
|
||||
|
||||
var ANNOT_MIN_SIZE = 10; // px
|
||||
|
||||
var AnnotationUtils = (function AnnotationUtilsClosure() {
|
||||
@ -6526,6 +6612,225 @@ var AnnotationUtils = (function AnnotationUtilsClosure() {
|
||||
PDFJS.AnnotationUtils = AnnotationUtils;
|
||||
|
||||
|
||||
/**
|
||||
* Text layer render parameters.
|
||||
*
|
||||
* @typedef {Object} TextLayerRenderParameters
|
||||
* @property {TextContent} textContent - Text content to render (the object is
|
||||
* returned by the page's getTextContent() method).
|
||||
* @property {HTMLElement} container - HTML element that will contain text runs.
|
||||
* @property {PDFJS.PageViewport} viewport - The target viewport to properly
|
||||
* layout the text runs.
|
||||
* @property {Array} textDivs - (optional) HTML elements that are correspond
|
||||
* the text items of the textContent input. This is output and shall be
|
||||
* initially be set to empty array.
|
||||
* @property {number} timeout - (optional) Delay in milliseconds before
|
||||
* rendering of the text runs occurs.
|
||||
*/
|
||||
var renderTextLayer = (function renderTextLayerClosure() {
|
||||
var MAX_TEXT_DIVS_TO_RENDER = 100000;
|
||||
|
||||
var NonWhitespaceRegexp = /\S/;
|
||||
|
||||
function isAllWhitespace(str) {
|
||||
return !NonWhitespaceRegexp.test(str);
|
||||
}
|
||||
|
||||
function appendText(textDivs, viewport, geom, styles) {
|
||||
var style = styles[geom.fontName];
|
||||
var textDiv = document.createElement('div');
|
||||
textDivs.push(textDiv);
|
||||
if (isAllWhitespace(geom.str)) {
|
||||
textDiv.dataset.isWhitespace = true;
|
||||
return;
|
||||
}
|
||||
var tx = PDFJS.Util.transform(viewport.transform, geom.transform);
|
||||
var angle = Math.atan2(tx[1], tx[0]);
|
||||
if (style.vertical) {
|
||||
angle += Math.PI / 2;
|
||||
}
|
||||
var fontHeight = Math.sqrt((tx[2] * tx[2]) + (tx[3] * tx[3]));
|
||||
var fontAscent = fontHeight;
|
||||
if (style.ascent) {
|
||||
fontAscent = style.ascent * fontAscent;
|
||||
} else if (style.descent) {
|
||||
fontAscent = (1 + style.descent) * fontAscent;
|
||||
}
|
||||
|
||||
var left;
|
||||
var top;
|
||||
if (angle === 0) {
|
||||
left = tx[4];
|
||||
top = tx[5] - fontAscent;
|
||||
} else {
|
||||
left = tx[4] + (fontAscent * Math.sin(angle));
|
||||
top = tx[5] - (fontAscent * Math.cos(angle));
|
||||
}
|
||||
textDiv.style.left = left + 'px';
|
||||
textDiv.style.top = top + 'px';
|
||||
textDiv.style.fontSize = fontHeight + 'px';
|
||||
textDiv.style.fontFamily = style.fontFamily;
|
||||
|
||||
textDiv.textContent = geom.str;
|
||||
// |fontName| is only used by the Font Inspector. This test will succeed
|
||||
// when e.g. the Font Inspector is off but the Stepper is on, but it's
|
||||
// not worth the effort to do a more accurate test.
|
||||
if (PDFJS.pdfBug) {
|
||||
textDiv.dataset.fontName = geom.fontName;
|
||||
}
|
||||
// Storing into dataset will convert number into string.
|
||||
if (angle !== 0) {
|
||||
textDiv.dataset.angle = angle * (180 / Math.PI);
|
||||
}
|
||||
// We don't bother scaling single-char text divs, because it has very
|
||||
// little effect on text highlighting. This makes scrolling on docs with
|
||||
// lots of such divs a lot faster.
|
||||
if (geom.str.length > 1) {
|
||||
if (style.vertical) {
|
||||
textDiv.dataset.canvasWidth = geom.height * viewport.scale;
|
||||
} else {
|
||||
textDiv.dataset.canvasWidth = geom.width * viewport.scale;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function render(task) {
|
||||
if (task._canceled) {
|
||||
return;
|
||||
}
|
||||
var textLayerFrag = task._container;
|
||||
var textDivs = task._textDivs;
|
||||
var capability = task._capability;
|
||||
var textDivsLength = textDivs.length;
|
||||
|
||||
// No point in rendering many divs as it would make the browser
|
||||
// unusable even after the divs are rendered.
|
||||
if (textDivsLength > MAX_TEXT_DIVS_TO_RENDER) {
|
||||
capability.resolve();
|
||||
return;
|
||||
}
|
||||
|
||||
var canvas = document.createElement('canvas');
|
||||
canvas.mozOpaque = true;
|
||||
var ctx = canvas.getContext('2d', {alpha: false});
|
||||
|
||||
var lastFontSize;
|
||||
var lastFontFamily;
|
||||
for (var i = 0; i < textDivsLength; i++) {
|
||||
var textDiv = textDivs[i];
|
||||
if (textDiv.dataset.isWhitespace !== undefined) {
|
||||
continue;
|
||||
}
|
||||
|
||||
var fontSize = textDiv.style.fontSize;
|
||||
var fontFamily = textDiv.style.fontFamily;
|
||||
|
||||
// Only build font string and set to context if different from last.
|
||||
if (fontSize !== lastFontSize || fontFamily !== lastFontFamily) {
|
||||
ctx.font = fontSize + ' ' + fontFamily;
|
||||
lastFontSize = fontSize;
|
||||
lastFontFamily = fontFamily;
|
||||
}
|
||||
|
||||
var width = ctx.measureText(textDiv.textContent).width;
|
||||
if (width > 0) {
|
||||
textLayerFrag.appendChild(textDiv);
|
||||
var transform;
|
||||
if (textDiv.dataset.canvasWidth !== undefined) {
|
||||
// Dataset values come of type string.
|
||||
var textScale = textDiv.dataset.canvasWidth / width;
|
||||
transform = 'scaleX(' + textScale + ')';
|
||||
} else {
|
||||
transform = '';
|
||||
}
|
||||
var rotation = textDiv.dataset.angle;
|
||||
if (rotation) {
|
||||
transform = 'rotate(' + rotation + 'deg) ' + transform;
|
||||
}
|
||||
if (transform) {
|
||||
PDFJS.CustomStyle.setProp('transform' , textDiv, transform);
|
||||
}
|
||||
}
|
||||
}
|
||||
capability.resolve();
|
||||
}
|
||||
|
||||
/**
|
||||
* Text layer rendering task.
|
||||
*
|
||||
* @param {TextContent} textContent
|
||||
* @param {HTMLElement} container
|
||||
* @param {PDFJS.PageViewport} viewport
|
||||
* @param {Array} textDivs
|
||||
* @private
|
||||
*/
|
||||
function TextLayerRenderTask(textContent, container, viewport, textDivs) {
|
||||
this._textContent = textContent;
|
||||
this._container = container;
|
||||
this._viewport = viewport;
|
||||
textDivs = textDivs || [];
|
||||
this._textDivs = textDivs;
|
||||
this._canceled = false;
|
||||
this._capability = createPromiseCapability();
|
||||
this._renderTimer = null;
|
||||
}
|
||||
TextLayerRenderTask.prototype = {
|
||||
get promise() {
|
||||
return this._capability.promise;
|
||||
},
|
||||
|
||||
cancel: function TextLayer_cancel() {
|
||||
this._canceled = true;
|
||||
if (this._renderTimer !== null) {
|
||||
clearTimeout(this._renderTimer);
|
||||
this._renderTimer = null;
|
||||
}
|
||||
this._capability.reject('canceled');
|
||||
},
|
||||
|
||||
_render: function TextLayer_render(timeout) {
|
||||
var textItems = this._textContent.items;
|
||||
var styles = this._textContent.styles;
|
||||
var textDivs = this._textDivs;
|
||||
var viewport = this._viewport;
|
||||
for (var i = 0, len = textItems.length; i < len; i++) {
|
||||
appendText(textDivs, viewport, textItems[i], styles);
|
||||
}
|
||||
|
||||
if (!timeout) { // Render right away
|
||||
render(this);
|
||||
} else { // Schedule
|
||||
var self = this;
|
||||
this._renderTimer = setTimeout(function() {
|
||||
render(self);
|
||||
self._renderTimer = null;
|
||||
}, timeout);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Starts rendering of the text layer.
|
||||
*
|
||||
* @param {TextLayerRenderParameters} renderParameters
|
||||
* @returns {TextLayerRenderTask}
|
||||
*/
|
||||
function renderTextLayer(renderParameters) {
|
||||
var task = new TextLayerRenderTask(renderParameters.textContent,
|
||||
renderParameters.container,
|
||||
renderParameters.viewport,
|
||||
renderParameters.textDivs);
|
||||
task._render(renderParameters.timeout);
|
||||
return task;
|
||||
}
|
||||
|
||||
return renderTextLayer;
|
||||
})();
|
||||
|
||||
PDFJS.renderTextLayer = renderTextLayer;
|
||||
|
||||
|
||||
|
||||
|
||||
}).call((typeof window === 'undefined') ? this : window);
|
||||
|
@ -1,5 +1,3 @@
|
||||
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
|
||||
/* Copyright 2012 Mozilla Foundation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@ -22,8 +20,8 @@ if (typeof PDFJS === 'undefined') {
|
||||
(typeof window !== 'undefined' ? window : this).PDFJS = {};
|
||||
}
|
||||
|
||||
PDFJS.version = '1.2.109';
|
||||
PDFJS.build = '875588d';
|
||||
PDFJS.version = '1.3.14';
|
||||
PDFJS.build = 'df46b64';
|
||||
|
||||
(function pdfjsWrapper() {
|
||||
// Use strict in our context only - users might not want it
|
||||
@ -9664,6 +9662,11 @@ Shadings.RadialAxial = (function RadialAxialClosure() {
|
||||
if (matrix) {
|
||||
p0 = Util.applyTransform(p0, matrix);
|
||||
p1 = Util.applyTransform(p1, matrix);
|
||||
if (shadingType === ShadingType.RADIAL) {
|
||||
var scale = Util.singularValueDecompose2dScale(matrix);
|
||||
r0 *= scale[0];
|
||||
r1 *= scale[1];
|
||||
}
|
||||
}
|
||||
|
||||
return ['RadialAxial', type, this.colorStops, p0, p1, r0, r1];
|
||||
@ -34555,6 +34558,7 @@ var ArithmeticDecoder = (function ArithmeticDecoderClosure() {
|
||||
})();
|
||||
|
||||
|
||||
|
||||
var JpegImage = (function jpegImage() {
|
||||
var dctZigZag = new Uint8Array([
|
||||
0,
|
||||
@ -39233,6 +39237,7 @@ var bidi = PDFJS.bidi = (function bidiClosure() {
|
||||
})();
|
||||
|
||||
|
||||
|
||||
var MurmurHash3_64 = (function MurmurHash3_64Closure (seed) {
|
||||
// Workaround for missing math precison in JS.
|
||||
var MASK_HIGH = 0xffff0000;
|
||||
|
@ -1,5 +1,3 @@
|
||||
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
|
||||
/* Copyright 2012 Mozilla Foundation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
|
@ -1,5 +1,3 @@
|
||||
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
|
||||
/* Copyright 2014 Mozilla Foundation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
|
@ -1,5 +1,3 @@
|
||||
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
|
||||
/* Copyright 2012 Mozilla Foundation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
|
@ -1,5 +1,3 @@
|
||||
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
|
||||
/* globals FirefoxCom */
|
||||
|
||||
'use strict';
|
||||
|
@ -1574,7 +1574,25 @@ html[dir='rtl'] #documentPropertiesOverlay .row > * {
|
||||
font-size: 10px;
|
||||
}
|
||||
|
||||
#viewer.textLayer-visible .textLayer > div,
|
||||
#viewer.textLayer-visible .textLayer {
|
||||
opacity: 1.0;
|
||||
}
|
||||
|
||||
#viewer.textLayer-visible .canvasWrapper {
|
||||
background-color: rgb(128,255,128);
|
||||
}
|
||||
|
||||
#viewer.textLayer-visible .canvasWrapper canvas {
|
||||
mix-blend-mode: screen;
|
||||
}
|
||||
|
||||
#viewer.textLayer-visible .textLayer > div {
|
||||
background-color: rgba(255, 255, 0, 0.1);
|
||||
color: black;
|
||||
border: solid 1px rgba(255, 0, 0, 0.5);
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
#viewer.textLayer-hover .textLayer > div:hover {
|
||||
background-color: white;
|
||||
color: black;
|
||||
|
@ -1,5 +1,3 @@
|
||||
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
|
||||
/* Copyright 2012 Mozilla Foundation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@ -14,18 +12,6 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/* globals PDFJS, PDFBug, FirefoxCom, Stats, Cache, ProgressBar,
|
||||
DownloadManager, getFileName, getPDFFileNameFromURL,
|
||||
PDFHistory, Preferences, SidebarView, ViewHistory, Stats,
|
||||
PDFThumbnailViewer, URL, noContextMenuHandler, SecondaryToolbar,
|
||||
PasswordPrompt, PDFPresentationMode, PDFDocumentProperties, HandTool,
|
||||
Promise, PDFLinkService, PDFOutlineView, PDFAttachmentView,
|
||||
OverlayManager, PDFFindController, PDFFindBar, PDFViewer,
|
||||
PDFRenderingQueue, PresentationModeState, parseQueryString,
|
||||
RenderingStates, UNKNOWN_SCALE, DEFAULT_SCALE_VALUE,
|
||||
IGNORE_CURRENT_POSITION_ON_ZOOM: true */
|
||||
|
||||
'use strict';
|
||||
|
||||
var DEFAULT_URL = 'compressed.tracemonkey-pldi-09.pdf';
|
||||
var DEFAULT_SCALE_DELTA = 1.1;
|
||||
@ -52,57 +38,6 @@ var MAX_AUTO_SCALE = 1.25;
|
||||
var SCROLLBAR_PADDING = 40;
|
||||
var VERTICAL_PADDING = 5;
|
||||
|
||||
// optimised CSS custom property getter/setter
|
||||
var CustomStyle = (function CustomStyleClosure() {
|
||||
|
||||
// As noted on: http://www.zachstronaut.com/posts/2009/02/17/
|
||||
// animate-css-transforms-firefox-webkit.html
|
||||
// in some versions of IE9 it is critical that ms appear in this list
|
||||
// before Moz
|
||||
var prefixes = ['ms', 'Moz', 'Webkit', 'O'];
|
||||
var _cache = {};
|
||||
|
||||
function CustomStyle() {}
|
||||
|
||||
CustomStyle.getProp = function get(propName, element) {
|
||||
// check cache only when no element is given
|
||||
if (arguments.length === 1 && typeof _cache[propName] === 'string') {
|
||||
return _cache[propName];
|
||||
}
|
||||
|
||||
element = element || document.documentElement;
|
||||
var style = element.style, prefixed, uPropName;
|
||||
|
||||
// test standard property first
|
||||
if (typeof style[propName] === 'string') {
|
||||
return (_cache[propName] = propName);
|
||||
}
|
||||
|
||||
// capitalize
|
||||
uPropName = propName.charAt(0).toUpperCase() + propName.slice(1);
|
||||
|
||||
// test vendor specific properties
|
||||
for (var i = 0, l = prefixes.length; i < l; i++) {
|
||||
prefixed = prefixes[i] + uPropName;
|
||||
if (typeof style[prefixed] === 'string') {
|
||||
return (_cache[propName] = prefixed);
|
||||
}
|
||||
}
|
||||
|
||||
//if all fails then set to undefined
|
||||
return (_cache[propName] = 'undefined');
|
||||
};
|
||||
|
||||
CustomStyle.setProp = function set(propName, element, str) {
|
||||
var prop = this.getProp(propName);
|
||||
if (prop !== 'undefined') {
|
||||
element.style[prop] = str;
|
||||
}
|
||||
};
|
||||
|
||||
return CustomStyle;
|
||||
})();
|
||||
|
||||
var NullCharactersRegExp = /\x00/g;
|
||||
|
||||
function removeNullCharacters(str) {
|
||||
@ -2639,23 +2574,6 @@ var PDFPresentationMode = (function PDFPresentationModeClosure() {
|
||||
})();
|
||||
|
||||
|
||||
/* Copyright 2013 Rob Wu <gwnRob@gmail.com>
|
||||
* https://github.com/Rob--W/grab-to-pan.js
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
var GrabToPan = (function GrabToPanClosure() {
|
||||
/**
|
||||
@ -3518,6 +3436,8 @@ var TEXT_LAYER_RENDER_DELAY = 200; // ms
|
||||
* @implements {IRenderableView}
|
||||
*/
|
||||
var PDFPageView = (function PDFPageViewClosure() {
|
||||
var CustomStyle = PDFJS.CustomStyle;
|
||||
|
||||
/**
|
||||
* @constructs PDFPageView
|
||||
* @param {PDFPageViewOptions} options
|
||||
@ -3535,7 +3455,7 @@ var PDFPageView = (function PDFPageViewClosure() {
|
||||
this.renderingId = 'page' + id;
|
||||
|
||||
this.rotation = 0;
|
||||
this.scale = scale || 1.0;
|
||||
this.scale = scale || DEFAULT_SCALE;
|
||||
this.viewport = defaultViewport;
|
||||
this.pdfPageRotate = defaultViewport.rotation;
|
||||
this.hasRestrictedScaling = false;
|
||||
@ -3646,8 +3566,7 @@ var PDFPageView = (function PDFPageViewClosure() {
|
||||
|
||||
var isScalingRestricted = false;
|
||||
if (this.canvas && PDFJS.maxCanvasPixels > 0) {
|
||||
var ctx = this.canvas.getContext('2d');
|
||||
var outputScale = getOutputScale(ctx);
|
||||
var outputScale = this.outputScale;
|
||||
var pixelsInViewport = this.viewport.width * this.viewport.height;
|
||||
var maxScale = Math.sqrt(PDFJS.maxCanvasPixels / pixelsInViewport);
|
||||
if (((Math.floor(this.viewport.width) * outputScale.sx) | 0) *
|
||||
@ -3791,6 +3710,11 @@ var PDFPageView = (function PDFPageViewClosure() {
|
||||
|
||||
var canvas = document.createElement('canvas');
|
||||
canvas.id = 'page' + this.id;
|
||||
// Keep the canvas hidden until the first draw callback, or until drawing
|
||||
// is complete when `!this.renderingQueue`, to prevent black flickering.
|
||||
canvas.setAttribute('hidden', 'hidden');
|
||||
var isCanvasHidden = true;
|
||||
|
||||
canvasWrapper.appendChild(canvas);
|
||||
if (this.annotationLayer && this.annotationLayer.div) {
|
||||
// annotationLayer needs to stay on top
|
||||
@ -3800,8 +3724,10 @@ var PDFPageView = (function PDFPageViewClosure() {
|
||||
}
|
||||
this.canvas = canvas;
|
||||
|
||||
var ctx = canvas.getContext('2d');
|
||||
canvas.mozOpaque = true;
|
||||
var ctx = canvas.getContext('2d', {alpha: false});
|
||||
var outputScale = getOutputScale(ctx);
|
||||
this.outputScale = outputScale;
|
||||
|
||||
if (PDFJS.useOnlyCssZoom) {
|
||||
var actualSizeViewport = viewport.clone({scale: CSS_UNITS});
|
||||
@ -3854,10 +3780,6 @@ var PDFPageView = (function PDFPageViewClosure() {
|
||||
}
|
||||
this.textLayer = textLayer;
|
||||
|
||||
if (outputScale.scaled) {
|
||||
ctx.scale(outputScale.sx, outputScale.sy);
|
||||
}
|
||||
|
||||
var resolveRenderPromise, rejectRenderPromise;
|
||||
var promise = new Promise(function (resolve, reject) {
|
||||
resolveRenderPromise = resolve;
|
||||
@ -3882,6 +3804,11 @@ var PDFPageView = (function PDFPageViewClosure() {
|
||||
|
||||
self.renderingState = RenderingStates.FINISHED;
|
||||
|
||||
if (isCanvasHidden) {
|
||||
self.canvas.removeAttribute('hidden');
|
||||
isCanvasHidden = false;
|
||||
}
|
||||
|
||||
if (self.loadingIconDiv) {
|
||||
div.removeChild(self.loadingIconDiv);
|
||||
delete self.loadingIconDiv;
|
||||
@ -3928,12 +3855,19 @@ var PDFPageView = (function PDFPageViewClosure() {
|
||||
};
|
||||
return;
|
||||
}
|
||||
if (isCanvasHidden) {
|
||||
self.canvas.removeAttribute('hidden');
|
||||
isCanvasHidden = false;
|
||||
}
|
||||
cont();
|
||||
};
|
||||
}
|
||||
|
||||
var transform = !outputScale.scaled ? null :
|
||||
[outputScale.sx, 0, 0, outputScale.sy, 0, 0];
|
||||
var renderContext = {
|
||||
canvasContext: ctx,
|
||||
transform: transform,
|
||||
viewport: this.viewport,
|
||||
// intent: 'default', // === 'display'
|
||||
};
|
||||
@ -4037,14 +3971,6 @@ var PDFPageView = (function PDFPageViewClosure() {
|
||||
})();
|
||||
|
||||
|
||||
var MAX_TEXT_DIVS_TO_RENDER = 100000;
|
||||
|
||||
var NonWhitespaceRegexp = /\S/;
|
||||
|
||||
function isAllWhitespace(str) {
|
||||
return !NonWhitespaceRegexp.test(str);
|
||||
}
|
||||
|
||||
/**
|
||||
* @typedef {Object} TextLayerBuilderOptions
|
||||
* @property {HTMLDivElement} textLayerDiv - The text layer container.
|
||||
@ -4071,6 +3997,7 @@ var TextLayerBuilder = (function TextLayerBuilderClosure() {
|
||||
this.viewport = options.viewport;
|
||||
this.textDivs = [];
|
||||
this.findController = options.findController || null;
|
||||
this.textLayerRenderTask = null;
|
||||
this._bindMouse();
|
||||
}
|
||||
|
||||
@ -4089,64 +4016,6 @@ var TextLayerBuilder = (function TextLayerBuilderClosure() {
|
||||
this.textLayerDiv.dispatchEvent(event);
|
||||
},
|
||||
|
||||
renderLayer: function TextLayerBuilder_renderLayer() {
|
||||
var textLayerFrag = document.createDocumentFragment();
|
||||
var textDivs = this.textDivs;
|
||||
var textDivsLength = textDivs.length;
|
||||
var canvas = document.createElement('canvas');
|
||||
var ctx = canvas.getContext('2d');
|
||||
|
||||
// No point in rendering many divs as it would make the browser
|
||||
// unusable even after the divs are rendered.
|
||||
if (textDivsLength > MAX_TEXT_DIVS_TO_RENDER) {
|
||||
this._finishRendering();
|
||||
return;
|
||||
}
|
||||
|
||||
var lastFontSize;
|
||||
var lastFontFamily;
|
||||
for (var i = 0; i < textDivsLength; i++) {
|
||||
var textDiv = textDivs[i];
|
||||
if (textDiv.dataset.isWhitespace !== undefined) {
|
||||
continue;
|
||||
}
|
||||
|
||||
var fontSize = textDiv.style.fontSize;
|
||||
var fontFamily = textDiv.style.fontFamily;
|
||||
|
||||
// Only build font string and set to context if different from last.
|
||||
if (fontSize !== lastFontSize || fontFamily !== lastFontFamily) {
|
||||
ctx.font = fontSize + ' ' + fontFamily;
|
||||
lastFontSize = fontSize;
|
||||
lastFontFamily = fontFamily;
|
||||
}
|
||||
|
||||
var width = ctx.measureText(textDiv.textContent).width;
|
||||
if (width > 0) {
|
||||
textLayerFrag.appendChild(textDiv);
|
||||
var transform;
|
||||
if (textDiv.dataset.canvasWidth !== undefined) {
|
||||
// Dataset values come of type string.
|
||||
var textScale = textDiv.dataset.canvasWidth / width;
|
||||
transform = 'scaleX(' + textScale + ')';
|
||||
} else {
|
||||
transform = '';
|
||||
}
|
||||
var rotation = textDiv.dataset.angle;
|
||||
if (rotation) {
|
||||
transform = 'rotate(' + rotation + 'deg) ' + transform;
|
||||
}
|
||||
if (transform) {
|
||||
CustomStyle.setProp('transform' , textDiv, transform);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.textLayerDiv.appendChild(textLayerFrag);
|
||||
this._finishRendering();
|
||||
this.updateMatches();
|
||||
},
|
||||
|
||||
/**
|
||||
* Renders the text layer.
|
||||
* @param {number} timeout (optional) if specified, the rendering waits
|
||||
@ -4157,87 +4026,35 @@ var TextLayerBuilder = (function TextLayerBuilderClosure() {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.renderTimer) {
|
||||
clearTimeout(this.renderTimer);
|
||||
this.renderTimer = null;
|
||||
if (this.textLayerRenderTask) {
|
||||
this.textLayerRenderTask.cancel();
|
||||
this.textLayerRenderTask = null;
|
||||
}
|
||||
|
||||
if (!timeout) { // Render right away
|
||||
this.renderLayer();
|
||||
} else { // Schedule
|
||||
var self = this;
|
||||
this.renderTimer = setTimeout(function() {
|
||||
self.renderLayer();
|
||||
self.renderTimer = null;
|
||||
}, timeout);
|
||||
}
|
||||
},
|
||||
|
||||
appendText: function TextLayerBuilder_appendText(geom, styles) {
|
||||
var style = styles[geom.fontName];
|
||||
var textDiv = document.createElement('div');
|
||||
this.textDivs.push(textDiv);
|
||||
if (isAllWhitespace(geom.str)) {
|
||||
textDiv.dataset.isWhitespace = true;
|
||||
return;
|
||||
}
|
||||
var tx = PDFJS.Util.transform(this.viewport.transform, geom.transform);
|
||||
var angle = Math.atan2(tx[1], tx[0]);
|
||||
if (style.vertical) {
|
||||
angle += Math.PI / 2;
|
||||
}
|
||||
var fontHeight = Math.sqrt((tx[2] * tx[2]) + (tx[3] * tx[3]));
|
||||
var fontAscent = fontHeight;
|
||||
if (style.ascent) {
|
||||
fontAscent = style.ascent * fontAscent;
|
||||
} else if (style.descent) {
|
||||
fontAscent = (1 + style.descent) * fontAscent;
|
||||
}
|
||||
|
||||
var left;
|
||||
var top;
|
||||
if (angle === 0) {
|
||||
left = tx[4];
|
||||
top = tx[5] - fontAscent;
|
||||
} else {
|
||||
left = tx[4] + (fontAscent * Math.sin(angle));
|
||||
top = tx[5] - (fontAscent * Math.cos(angle));
|
||||
}
|
||||
textDiv.style.left = left + 'px';
|
||||
textDiv.style.top = top + 'px';
|
||||
textDiv.style.fontSize = fontHeight + 'px';
|
||||
textDiv.style.fontFamily = style.fontFamily;
|
||||
|
||||
textDiv.textContent = geom.str;
|
||||
// |fontName| is only used by the Font Inspector. This test will succeed
|
||||
// when e.g. the Font Inspector is off but the Stepper is on, but it's
|
||||
// not worth the effort to do a more accurate test.
|
||||
if (PDFJS.pdfBug) {
|
||||
textDiv.dataset.fontName = geom.fontName;
|
||||
}
|
||||
// Storing into dataset will convert number into string.
|
||||
if (angle !== 0) {
|
||||
textDiv.dataset.angle = angle * (180 / Math.PI);
|
||||
}
|
||||
// We don't bother scaling single-char text divs, because it has very
|
||||
// little effect on text highlighting. This makes scrolling on docs with
|
||||
// lots of such divs a lot faster.
|
||||
if (geom.str.length > 1) {
|
||||
if (style.vertical) {
|
||||
textDiv.dataset.canvasWidth = geom.height * this.viewport.scale;
|
||||
} else {
|
||||
textDiv.dataset.canvasWidth = geom.width * this.viewport.scale;
|
||||
}
|
||||
}
|
||||
this.textDivs = [];
|
||||
var textLayerFrag = document.createDocumentFragment();
|
||||
this.textLayerRenderTask = PDFJS.renderTextLayer({
|
||||
textContent: this.textContent,
|
||||
container: textLayerFrag,
|
||||
viewport: this.viewport,
|
||||
textDivs: this.textDivs,
|
||||
timeout: timeout
|
||||
});
|
||||
this.textLayerRenderTask.promise.then(function () {
|
||||
this.textLayerDiv.appendChild(textLayerFrag);
|
||||
this._finishRendering();
|
||||
this.updateMatches();
|
||||
}.bind(this), function (reason) {
|
||||
// canceled or failed to render text layer -- skipping errors
|
||||
});
|
||||
},
|
||||
|
||||
setTextContent: function TextLayerBuilder_setTextContent(textContent) {
|
||||
this.textContent = textContent;
|
||||
|
||||
var textItems = textContent.items;
|
||||
for (var i = 0, len = textItems.length; i < len; i++) {
|
||||
this.appendText(textItems[i], textContent.styles);
|
||||
if (this.textLayerRenderTask) {
|
||||
this.textLayerRenderTask.cancel();
|
||||
this.textLayerRenderTask = null;
|
||||
}
|
||||
this.textContent = textContent;
|
||||
this.divContentDone = true;
|
||||
},
|
||||
|
||||
@ -4478,6 +4295,8 @@ DefaultTextLayerFactory.prototype = {
|
||||
* @class
|
||||
*/
|
||||
var AnnotationsLayerBuilder = (function AnnotationsLayerBuilderClosure() {
|
||||
var CustomStyle = PDFJS.CustomStyle;
|
||||
|
||||
/**
|
||||
* @param {AnnotationsLayerBuilderOptions} options
|
||||
* @constructs AnnotationsLayerBuilder
|
||||
@ -5442,7 +5261,8 @@ var PDFThumbnailView = (function PDFThumbnailViewClosure() {
|
||||
|
||||
// Since this is a temporary canvas, we need to fill the canvas with a white
|
||||
// background ourselves. |_getPageDrawContext| uses CSS rules for this.
|
||||
var ctx = tempCanvas.getContext('2d');
|
||||
tempCanvas.mozOpaque = true;
|
||||
var ctx = tempCanvas.getContext('2d', {alpha: false});
|
||||
ctx.save();
|
||||
ctx.fillStyle = 'rgb(255, 255, 255)';
|
||||
ctx.fillRect(0, 0, width, height);
|
||||
@ -5582,7 +5402,8 @@ var PDFThumbnailView = (function PDFThumbnailViewClosure() {
|
||||
var canvas = document.createElement('canvas');
|
||||
this.canvas = canvas;
|
||||
|
||||
var ctx = canvas.getContext('2d');
|
||||
canvas.mozOpaque = true;
|
||||
var ctx = canvas.getContext('2d', {alpha: false});
|
||||
var outputScale = getOutputScale(ctx);
|
||||
|
||||
canvas.width = (this.canvasWidth * outputScale.sx) | 0;
|
||||
|
Loading…
Reference in New Issue
Block a user