зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1301577 - Update pdf.js to version 1.5.437. r=bdahl
This commit is contained in:
Родитель
d5acd544da
Коммит
00b6191463
|
@ -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.5.413
|
Current extension version is: 1.5.437
|
||||||
|
|
|
@ -91,7 +91,8 @@ function initializeDefaultPreferences() {
|
||||||
"disableFontFace": false,
|
"disableFontFace": false,
|
||||||
"disableTextLayer": false,
|
"disableTextLayer": false,
|
||||||
"useOnlyCssZoom": false,
|
"useOnlyCssZoom": false,
|
||||||
"externalLinkTarget": 0
|
"externalLinkTarget": 0,
|
||||||
|
"renderInteractiveForms": false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -49,7 +49,8 @@ var DEFAULT_PREFERENCES =
|
||||||
"disableFontFace": false,
|
"disableFontFace": false,
|
||||||
"disableTextLayer": false,
|
"disableTextLayer": false,
|
||||||
"useOnlyCssZoom": false,
|
"useOnlyCssZoom": false,
|
||||||
"externalLinkTarget": 0
|
"externalLinkTarget": 0,
|
||||||
|
"renderInteractiveForms": false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -28,8 +28,8 @@ factory((root.pdfjsDistBuildPdf = {}));
|
||||||
// Use strict in our context only - users might not want it
|
// Use strict in our context only - users might not want it
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var pdfjsVersion = '1.5.413';
|
var pdfjsVersion = '1.5.437';
|
||||||
var pdfjsBuild = '6bb95e3';
|
var pdfjsBuild = 'ca61ccc';
|
||||||
|
|
||||||
var pdfjsFilePath =
|
var pdfjsFilePath =
|
||||||
typeof document !== 'undefined' && document.currentScript ?
|
typeof document !== 'undefined' && document.currentScript ?
|
||||||
|
@ -1158,6 +1158,7 @@ function createPromiseCapability() {
|
||||||
throw new Error('DOM Promise is not present');
|
throw new Error('DOM Promise is not present');
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
|
||||||
var StatTimer = (function StatTimerClosure() {
|
var StatTimer = (function StatTimerClosure() {
|
||||||
function rpad(str, pad, length) {
|
function rpad(str, pad, length) {
|
||||||
while (str.length < length) {
|
while (str.length < length) {
|
||||||
|
@ -1938,6 +1939,8 @@ var getDefaultSetting = displayDOMUtils.getDefaultSetting;
|
||||||
* @property {PageViewport} viewport
|
* @property {PageViewport} viewport
|
||||||
* @property {IPDFLinkService} linkService
|
* @property {IPDFLinkService} linkService
|
||||||
* @property {DownloadManager} downloadManager
|
* @property {DownloadManager} downloadManager
|
||||||
|
* @property {string} imageResourcesPath
|
||||||
|
* @property {boolean} renderInteractiveForms
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1962,6 +1965,12 @@ AnnotationElementFactory.prototype =
|
||||||
return new TextAnnotationElement(parameters);
|
return new TextAnnotationElement(parameters);
|
||||||
|
|
||||||
case AnnotationType.WIDGET:
|
case AnnotationType.WIDGET:
|
||||||
|
var fieldType = parameters.data.fieldType;
|
||||||
|
|
||||||
|
switch (fieldType) {
|
||||||
|
case 'Tx':
|
||||||
|
return new TextWidgetAnnotationElement(parameters);
|
||||||
|
}
|
||||||
return new WidgetAnnotationElement(parameters);
|
return new WidgetAnnotationElement(parameters);
|
||||||
|
|
||||||
case AnnotationType.POPUP:
|
case AnnotationType.POPUP:
|
||||||
|
@ -2002,6 +2011,7 @@ var AnnotationElement = (function AnnotationElementClosure() {
|
||||||
this.linkService = parameters.linkService;
|
this.linkService = parameters.linkService;
|
||||||
this.downloadManager = parameters.downloadManager;
|
this.downloadManager = parameters.downloadManager;
|
||||||
this.imageResourcesPath = parameters.imageResourcesPath;
|
this.imageResourcesPath = parameters.imageResourcesPath;
|
||||||
|
this.renderInteractiveForms = parameters.renderInteractiveForms;
|
||||||
|
|
||||||
if (isRenderable) {
|
if (isRenderable) {
|
||||||
this.container = this._createContainer();
|
this.container = this._createContainer();
|
||||||
|
@ -2285,9 +2295,7 @@ var TextAnnotationElement = (function TextAnnotationElementClosure() {
|
||||||
*/
|
*/
|
||||||
var WidgetAnnotationElement = (function WidgetAnnotationElementClosure() {
|
var WidgetAnnotationElement = (function WidgetAnnotationElementClosure() {
|
||||||
function WidgetAnnotationElement(parameters) {
|
function WidgetAnnotationElement(parameters) {
|
||||||
var isRenderable = !parameters.data.hasAppearance &&
|
AnnotationElement.call(this, parameters, true);
|
||||||
!!parameters.data.fieldValue;
|
|
||||||
AnnotationElement.call(this, parameters, isRenderable);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Util.inherit(WidgetAnnotationElement, AnnotationElement, {
|
Util.inherit(WidgetAnnotationElement, AnnotationElement, {
|
||||||
|
@ -2299,18 +2307,55 @@ var WidgetAnnotationElement = (function WidgetAnnotationElementClosure() {
|
||||||
* @returns {HTMLSectionElement}
|
* @returns {HTMLSectionElement}
|
||||||
*/
|
*/
|
||||||
render: function WidgetAnnotationElement_render() {
|
render: function WidgetAnnotationElement_render() {
|
||||||
var content = document.createElement('div');
|
// Show only the container for unsupported field types.
|
||||||
content.textContent = this.data.fieldValue;
|
return this.container;
|
||||||
var textAlignment = this.data.textAlignment;
|
}
|
||||||
content.style.textAlign = ['left', 'center', 'right'][textAlignment];
|
});
|
||||||
content.style.verticalAlign = 'middle';
|
|
||||||
content.style.display = 'table-cell';
|
|
||||||
|
|
||||||
var font = (this.data.fontRefName ?
|
return WidgetAnnotationElement;
|
||||||
this.page.commonObjs.getData(this.data.fontRefName) : null);
|
})();
|
||||||
this._setTextStyle(content, font);
|
|
||||||
|
|
||||||
this.container.appendChild(content);
|
/**
|
||||||
|
* @class
|
||||||
|
* @alias TextWidgetAnnotationElement
|
||||||
|
*/
|
||||||
|
var TextWidgetAnnotationElement = (
|
||||||
|
function TextWidgetAnnotationElementClosure() {
|
||||||
|
function TextWidgetAnnotationElement(parameters) {
|
||||||
|
WidgetAnnotationElement.call(this, parameters);
|
||||||
|
}
|
||||||
|
|
||||||
|
Util.inherit(TextWidgetAnnotationElement, WidgetAnnotationElement, {
|
||||||
|
/**
|
||||||
|
* Render the text widget annotation's HTML element in the empty container.
|
||||||
|
*
|
||||||
|
* @public
|
||||||
|
* @memberof TextWidgetAnnotationElement
|
||||||
|
* @returns {HTMLSectionElement}
|
||||||
|
*/
|
||||||
|
render: function TextWidgetAnnotationElement_render() {
|
||||||
|
this.container.className = 'textWidgetAnnotation';
|
||||||
|
|
||||||
|
if (this.renderInteractiveForms) {
|
||||||
|
var input = document.createElement('input');
|
||||||
|
input.type = 'text';
|
||||||
|
input.value = this.data.fieldValue;
|
||||||
|
|
||||||
|
this.container.appendChild(input);
|
||||||
|
} else {
|
||||||
|
var content = document.createElement('div');
|
||||||
|
content.textContent = this.data.fieldValue;
|
||||||
|
var textAlignment = this.data.textAlignment;
|
||||||
|
content.style.textAlign = ['left', 'center', 'right'][textAlignment];
|
||||||
|
content.style.verticalAlign = 'middle';
|
||||||
|
content.style.display = 'table-cell';
|
||||||
|
|
||||||
|
var font = (this.data.fontRefName ?
|
||||||
|
this.page.commonObjs.getData(this.data.fontRefName) : null);
|
||||||
|
this._setTextStyle(content, font);
|
||||||
|
|
||||||
|
this.container.appendChild(content);
|
||||||
|
}
|
||||||
return this.container;
|
return this.container;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -2320,10 +2365,10 @@ var WidgetAnnotationElement = (function WidgetAnnotationElementClosure() {
|
||||||
* @private
|
* @private
|
||||||
* @param {HTMLDivElement} element
|
* @param {HTMLDivElement} element
|
||||||
* @param {Object} font
|
* @param {Object} font
|
||||||
* @memberof WidgetAnnotationElement
|
* @memberof TextWidgetAnnotationElement
|
||||||
*/
|
*/
|
||||||
_setTextStyle:
|
_setTextStyle:
|
||||||
function WidgetAnnotationElement_setTextStyle(element, font) {
|
function TextWidgetAnnotationElement_setTextStyle(element, font) {
|
||||||
// TODO: This duplicates some of the logic in CanvasGraphics.setFont().
|
// TODO: This duplicates some of the logic in CanvasGraphics.setFont().
|
||||||
var style = element.style;
|
var style = element.style;
|
||||||
style.fontSize = this.data.fontSize + 'px';
|
style.fontSize = this.data.fontSize + 'px';
|
||||||
|
@ -2345,7 +2390,7 @@ var WidgetAnnotationElement = (function WidgetAnnotationElementClosure() {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return WidgetAnnotationElement;
|
return TextWidgetAnnotationElement;
|
||||||
})();
|
})();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2737,6 +2782,7 @@ var FileAttachmentAnnotationElement = (
|
||||||
* @property {PDFPage} page
|
* @property {PDFPage} page
|
||||||
* @property {IPDFLinkService} linkService
|
* @property {IPDFLinkService} linkService
|
||||||
* @property {string} imageResourcesPath
|
* @property {string} imageResourcesPath
|
||||||
|
* @property {boolean} renderInteractiveForms
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2769,7 +2815,8 @@ var AnnotationLayer = (function AnnotationLayerClosure() {
|
||||||
linkService: parameters.linkService,
|
linkService: parameters.linkService,
|
||||||
downloadManager: parameters.downloadManager,
|
downloadManager: parameters.downloadManager,
|
||||||
imageResourcesPath: parameters.imageResourcesPath ||
|
imageResourcesPath: parameters.imageResourcesPath ||
|
||||||
getDefaultSetting('imageResourcesPath')
|
getDefaultSetting('imageResourcesPath'),
|
||||||
|
renderInteractiveForms: parameters.renderInteractiveForms || false,
|
||||||
};
|
};
|
||||||
var element = annotationElementFactory.create(properties);
|
var element = annotationElementFactory.create(properties);
|
||||||
if (element.isRenderable) {
|
if (element.isRenderable) {
|
||||||
|
@ -2830,6 +2877,8 @@ var getDefaultSetting = displayDOMUtils.getDefaultSetting;
|
||||||
* initially be set to empty array.
|
* initially be set to empty array.
|
||||||
* @property {number} timeout - (optional) Delay in milliseconds before
|
* @property {number} timeout - (optional) Delay in milliseconds before
|
||||||
* rendering of the text runs occurs.
|
* rendering of the text runs occurs.
|
||||||
|
* @property {boolean} enhanceTextSelection - (optional) Whether to turn on the
|
||||||
|
* text selection enhancement.
|
||||||
*/
|
*/
|
||||||
var renderTextLayer = (function renderTextLayerClosure() {
|
var renderTextLayer = (function renderTextLayerClosure() {
|
||||||
var MAX_TEXT_DIVS_TO_RENDER = 100000;
|
var MAX_TEXT_DIVS_TO_RENDER = 100000;
|
||||||
|
@ -2840,17 +2889,31 @@ var renderTextLayer = (function renderTextLayerClosure() {
|
||||||
return !NonWhitespaceRegexp.test(str);
|
return !NonWhitespaceRegexp.test(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
function appendText(textDivs, viewport, geom, styles, bounds,
|
function appendText(task, geom, styles) {
|
||||||
enhanceTextSelection) {
|
// Initialize all used properties to keep the caches monomorphic.
|
||||||
var style = styles[geom.fontName];
|
|
||||||
var textDiv = document.createElement('div');
|
var textDiv = document.createElement('div');
|
||||||
textDivs.push(textDiv);
|
var textDivProperties = {
|
||||||
|
angle: 0,
|
||||||
|
canvasWidth: 0,
|
||||||
|
isWhitespace: false,
|
||||||
|
originalTransform: '',
|
||||||
|
paddingBottom: 0,
|
||||||
|
paddingLeft: 0,
|
||||||
|
paddingRight: 0,
|
||||||
|
paddingTop: 0,
|
||||||
|
scale: 1,
|
||||||
|
};
|
||||||
|
|
||||||
|
task._textDivs.push(textDiv);
|
||||||
if (isAllWhitespace(geom.str)) {
|
if (isAllWhitespace(geom.str)) {
|
||||||
textDiv.dataset.isWhitespace = true;
|
textDivProperties.isWhitespace = true;
|
||||||
|
task._textDivProperties.set(textDiv, textDivProperties);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var tx = Util.transform(viewport.transform, geom.transform);
|
|
||||||
|
var tx = Util.transform(task._viewport.transform, geom.transform);
|
||||||
var angle = Math.atan2(tx[1], tx[0]);
|
var angle = Math.atan2(tx[1], tx[0]);
|
||||||
|
var style = styles[geom.fontName];
|
||||||
if (style.vertical) {
|
if (style.vertical) {
|
||||||
angle += Math.PI / 2;
|
angle += Math.PI / 2;
|
||||||
}
|
}
|
||||||
|
@ -2879,32 +2942,34 @@ var renderTextLayer = (function renderTextLayerClosure() {
|
||||||
textDiv.textContent = geom.str;
|
textDiv.textContent = geom.str;
|
||||||
// |fontName| is only used by the Font Inspector. This test will succeed
|
// |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
|
// 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.
|
// not worth the effort to do a more accurate test. We only use `dataset`
|
||||||
|
// here to make the font name available for the debugger.
|
||||||
if (getDefaultSetting('pdfBug')) {
|
if (getDefaultSetting('pdfBug')) {
|
||||||
textDiv.dataset.fontName = geom.fontName;
|
textDiv.dataset.fontName = geom.fontName;
|
||||||
}
|
}
|
||||||
// Storing into dataset will convert number into string.
|
|
||||||
if (angle !== 0) {
|
if (angle !== 0) {
|
||||||
textDiv.dataset.angle = angle * (180 / Math.PI);
|
textDivProperties.angle = angle * (180 / Math.PI);
|
||||||
}
|
}
|
||||||
// We don't bother scaling single-char text divs, because it has very
|
// We don't bother scaling single-char text divs, because it has very
|
||||||
// little effect on text highlighting. This makes scrolling on docs with
|
// little effect on text highlighting. This makes scrolling on docs with
|
||||||
// lots of such divs a lot faster.
|
// lots of such divs a lot faster.
|
||||||
if (geom.str.length > 1) {
|
if (geom.str.length > 1) {
|
||||||
if (style.vertical) {
|
if (style.vertical) {
|
||||||
textDiv.dataset.canvasWidth = geom.height * viewport.scale;
|
textDivProperties.canvasWidth = geom.height * task._viewport.scale;
|
||||||
} else {
|
} else {
|
||||||
textDiv.dataset.canvasWidth = geom.width * viewport.scale;
|
textDivProperties.canvasWidth = geom.width * task._viewport.scale;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (enhanceTextSelection) {
|
task._textDivProperties.set(textDiv, textDivProperties);
|
||||||
|
|
||||||
|
if (task._enhanceTextSelection) {
|
||||||
var angleCos = 1, angleSin = 0;
|
var angleCos = 1, angleSin = 0;
|
||||||
if (angle !== 0) {
|
if (angle !== 0) {
|
||||||
angleCos = Math.cos(angle);
|
angleCos = Math.cos(angle);
|
||||||
angleSin = Math.sin(angle);
|
angleSin = Math.sin(angle);
|
||||||
}
|
}
|
||||||
var divWidth = (style.vertical ? geom.height : geom.width) *
|
var divWidth = (style.vertical ? geom.height : geom.width) *
|
||||||
viewport.scale;
|
task._viewport.scale;
|
||||||
var divHeight = fontHeight;
|
var divHeight = fontHeight;
|
||||||
|
|
||||||
var m, b;
|
var m, b;
|
||||||
|
@ -2915,7 +2980,7 @@ var renderTextLayer = (function renderTextLayerClosure() {
|
||||||
b = [left, top, left + divWidth, top + divHeight];
|
b = [left, top, left + divWidth, top + divHeight];
|
||||||
}
|
}
|
||||||
|
|
||||||
bounds.push({
|
task._bounds.push({
|
||||||
left: b[0],
|
left: b[0],
|
||||||
top: b[1],
|
top: b[1],
|
||||||
right: b[2],
|
right: b[2],
|
||||||
|
@ -2952,7 +3017,8 @@ var renderTextLayer = (function renderTextLayerClosure() {
|
||||||
var lastFontFamily;
|
var lastFontFamily;
|
||||||
for (var i = 0; i < textDivsLength; i++) {
|
for (var i = 0; i < textDivsLength; i++) {
|
||||||
var textDiv = textDivs[i];
|
var textDiv = textDivs[i];
|
||||||
if (textDiv.dataset.isWhitespace !== undefined) {
|
var textDivProperties = task._textDivProperties.get(textDiv);
|
||||||
|
if (textDivProperties.isWhitespace) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2967,38 +3033,40 @@ var renderTextLayer = (function renderTextLayerClosure() {
|
||||||
}
|
}
|
||||||
|
|
||||||
var width = ctx.measureText(textDiv.textContent).width;
|
var width = ctx.measureText(textDiv.textContent).width;
|
||||||
textDiv.dataset.originalWidth = width;
|
|
||||||
textLayerFrag.appendChild(textDiv);
|
textLayerFrag.appendChild(textDiv);
|
||||||
var transform;
|
|
||||||
if (textDiv.dataset.canvasWidth !== undefined && width > 0) {
|
var transform = '';
|
||||||
// Dataset values come of type string.
|
if (textDivProperties.canvasWidth !== 0 && width > 0) {
|
||||||
var textScale = textDiv.dataset.canvasWidth / width;
|
textDivProperties.scale = textDivProperties.canvasWidth / width;
|
||||||
transform = 'scaleX(' + textScale + ')';
|
transform = 'scaleX(' + textDivProperties.scale + ')';
|
||||||
} else {
|
}
|
||||||
transform = '';
|
if (textDivProperties.angle !== 0) {
|
||||||
}
|
transform = 'rotate(' + textDivProperties.angle + 'deg) ' + transform;
|
||||||
var rotation = textDiv.dataset.angle;
|
}
|
||||||
if (rotation) {
|
if (transform !== '') {
|
||||||
transform = 'rotate(' + rotation + 'deg) ' + transform;
|
textDivProperties.originalTransform = transform;
|
||||||
}
|
CustomStyle.setProp('transform', textDiv, transform);
|
||||||
if (transform) {
|
}
|
||||||
textDiv.dataset.originalTransform = transform;
|
task._textDivProperties.set(textDiv, textDivProperties);
|
||||||
CustomStyle.setProp('transform' , textDiv, transform);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
task._renderingDone = true;
|
task._renderingDone = true;
|
||||||
capability.resolve();
|
capability.resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
function expand(bounds, viewport) {
|
function expand(task) {
|
||||||
|
var bounds = task._bounds;
|
||||||
|
var viewport = task._viewport;
|
||||||
|
|
||||||
var expanded = expandBounds(viewport.width, viewport.height, bounds);
|
var expanded = expandBounds(viewport.width, viewport.height, bounds);
|
||||||
for (var i = 0; i < expanded.length; i++) {
|
for (var i = 0; i < expanded.length; i++) {
|
||||||
var div = bounds[i].div;
|
var div = bounds[i].div;
|
||||||
if (!div.dataset.angle) {
|
var divProperties = task._textDivProperties.get(div);
|
||||||
div.dataset.paddingLeft = bounds[i].left - expanded[i].left;
|
if (divProperties.angle === 0) {
|
||||||
div.dataset.paddingTop = bounds[i].top - expanded[i].top;
|
divProperties.paddingLeft = bounds[i].left - expanded[i].left;
|
||||||
div.dataset.paddingRight = expanded[i].right - bounds[i].right;
|
divProperties.paddingTop = bounds[i].top - expanded[i].top;
|
||||||
div.dataset.paddingBottom = expanded[i].bottom - bounds[i].bottom;
|
divProperties.paddingRight = expanded[i].right - bounds[i].right;
|
||||||
|
divProperties.paddingBottom = expanded[i].bottom - bounds[i].bottom;
|
||||||
|
task._textDivProperties.set(div, divProperties);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// Box is rotated -- trying to find padding so rotated div will not
|
// Box is rotated -- trying to find padding so rotated div will not
|
||||||
|
@ -3032,21 +3100,22 @@ var renderTextLayer = (function renderTextLayerClosure() {
|
||||||
});
|
});
|
||||||
var findPositiveMin = function (ts, offset, count) {
|
var findPositiveMin = function (ts, offset, count) {
|
||||||
var result = 0;
|
var result = 0;
|
||||||
for (var i = 0; i < count; i++) {
|
for (var i = 0; i < count; i++) {
|
||||||
var t = ts[offset++];
|
var t = ts[offset++];
|
||||||
if (t > 0) {
|
if (t > 0) {
|
||||||
result = result ? Math.min(t, result) : t;
|
result = result ? Math.min(t, result) : t;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return result;
|
}
|
||||||
|
return result;
|
||||||
};
|
};
|
||||||
// Not based on math, but to simplify calculations, using cos and sin
|
// Not based on math, but to simplify calculations, using cos and sin
|
||||||
// absolute values to not exceed the box (it can but insignificantly).
|
// absolute values to not exceed the box (it can but insignificantly).
|
||||||
var boxScale = 1 + Math.min(Math.abs(c), Math.abs(s));
|
var boxScale = 1 + Math.min(Math.abs(c), Math.abs(s));
|
||||||
div.dataset.paddingLeft = findPositiveMin(ts, 32, 16) / boxScale;
|
divProperties.paddingLeft = findPositiveMin(ts, 32, 16) / boxScale;
|
||||||
div.dataset.paddingTop = findPositiveMin(ts, 48, 16) / boxScale;
|
divProperties.paddingTop = findPositiveMin(ts, 48, 16) / boxScale;
|
||||||
div.dataset.paddingRight = findPositiveMin(ts, 0, 16) / boxScale;
|
divProperties.paddingRight = findPositiveMin(ts, 0, 16) / boxScale;
|
||||||
div.dataset.paddingBottom = findPositiveMin(ts, 16, 16) / boxScale;
|
divProperties.paddingBottom = findPositiveMin(ts, 16, 16) / boxScale;
|
||||||
|
task._textDivProperties.set(div, divProperties);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3268,8 +3337,8 @@ var renderTextLayer = (function renderTextLayerClosure() {
|
||||||
this._textContent = textContent;
|
this._textContent = textContent;
|
||||||
this._container = container;
|
this._container = container;
|
||||||
this._viewport = viewport;
|
this._viewport = viewport;
|
||||||
textDivs = textDivs || [];
|
this._textDivs = textDivs || [];
|
||||||
this._textDivs = textDivs;
|
this._textDivProperties = new WeakMap();
|
||||||
this._renderingDone = false;
|
this._renderingDone = false;
|
||||||
this._canceled = false;
|
this._canceled = false;
|
||||||
this._capability = createPromiseCapability();
|
this._capability = createPromiseCapability();
|
||||||
|
@ -3294,14 +3363,9 @@ var renderTextLayer = (function renderTextLayerClosure() {
|
||||||
|
|
||||||
_render: function TextLayer_render(timeout) {
|
_render: function TextLayer_render(timeout) {
|
||||||
var textItems = this._textContent.items;
|
var textItems = this._textContent.items;
|
||||||
var styles = this._textContent.styles;
|
var textStyles = this._textContent.styles;
|
||||||
var textDivs = this._textDivs;
|
|
||||||
var viewport = this._viewport;
|
|
||||||
var enhanceTextSelection = this._enhanceTextSelection;
|
|
||||||
|
|
||||||
for (var i = 0, len = textItems.length; i < len; i++) {
|
for (var i = 0, len = textItems.length; i < len; i++) {
|
||||||
appendText(textDivs, viewport, textItems[i], styles, this._bounds,
|
appendText(this, textItems[i], textStyles);
|
||||||
enhanceTextSelection);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!timeout) { // Render right away
|
if (!timeout) { // Render right away
|
||||||
|
@ -3320,59 +3384,53 @@ var renderTextLayer = (function renderTextLayerClosure() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!this._expanded) {
|
if (!this._expanded) {
|
||||||
expand(this._bounds, this._viewport);
|
expand(this);
|
||||||
this._expanded = true;
|
this._expanded = true;
|
||||||
this._bounds.length = 0;
|
this._bounds.length = 0;
|
||||||
}
|
}
|
||||||
if (expandDivs) {
|
|
||||||
for (var i = 0, ii = this._textDivs.length; i < ii; i++) {
|
for (var i = 0, ii = this._textDivs.length; i < ii; i++) {
|
||||||
var div = this._textDivs[i];
|
var div = this._textDivs[i];
|
||||||
var transform;
|
var divProperties = this._textDivProperties.get(div);
|
||||||
var width = div.dataset.originalWidth;
|
|
||||||
if (div.dataset.canvasWidth !== undefined && width > 0) {
|
if (expandDivs) {
|
||||||
// Dataset values come of type string.
|
var transform = '';
|
||||||
var textScale = div.dataset.canvasWidth / width;
|
|
||||||
transform = 'scaleX(' + textScale + ')';
|
if (divProperties.scale !== 1) {
|
||||||
} else {
|
transform = 'scaleX(' + divProperties.scale + ')';
|
||||||
transform = '';
|
|
||||||
}
|
}
|
||||||
var rotation = div.dataset.angle;
|
if (divProperties.angle !== 0) {
|
||||||
if (rotation) {
|
transform = 'rotate(' + divProperties.angle + 'deg) ' + transform;
|
||||||
transform = 'rotate(' + rotation + 'deg) ' + transform;
|
|
||||||
}
|
}
|
||||||
if (div.dataset.paddingLeft) {
|
if (divProperties.paddingLeft !== 0) {
|
||||||
div.style.paddingLeft =
|
div.style.paddingLeft =
|
||||||
(div.dataset.paddingLeft / textScale) + 'px';
|
(divProperties.paddingLeft / divProperties.scale) + 'px';
|
||||||
transform += ' translateX(' +
|
transform += ' translateX(' +
|
||||||
(-div.dataset.paddingLeft / textScale) + 'px)';
|
(-divProperties.paddingLeft / divProperties.scale) + 'px)';
|
||||||
}
|
}
|
||||||
if (div.dataset.paddingTop) {
|
if (divProperties.paddingTop !== 0) {
|
||||||
div.style.paddingTop = div.dataset.paddingTop + 'px';
|
div.style.paddingTop = divProperties.paddingTop + 'px';
|
||||||
transform += ' translateY(' + (-div.dataset.paddingTop) + 'px)';
|
transform += ' translateY(' + (-divProperties.paddingTop) + 'px)';
|
||||||
}
|
}
|
||||||
if (div.dataset.paddingRight) {
|
if (divProperties.paddingRight !== 0) {
|
||||||
div.style.paddingRight =
|
div.style.paddingRight =
|
||||||
div.dataset.paddingRight / textScale + 'px';
|
(divProperties.paddingRight / divProperties.scale) + 'px';
|
||||||
}
|
}
|
||||||
if (div.dataset.paddingBottom) {
|
if (divProperties.paddingBottom !== 0) {
|
||||||
div.style.paddingBottom = div.dataset.paddingBottom + 'px';
|
div.style.paddingBottom = divProperties.paddingBottom + 'px';
|
||||||
}
|
}
|
||||||
if (transform) {
|
if (transform !== '') {
|
||||||
CustomStyle.setProp('transform' , div, transform);
|
CustomStyle.setProp('transform', div, transform);
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
} else {
|
|
||||||
for (i = 0, ii = this._textDivs.length; i < ii; i++) {
|
|
||||||
div = this._textDivs[i];
|
|
||||||
div.style.padding = 0;
|
div.style.padding = 0;
|
||||||
transform = div.dataset.originalTransform || '';
|
CustomStyle.setProp('transform', div,
|
||||||
CustomStyle.setProp('transform', div, transform);
|
divProperties.originalTransform);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Starts rendering of the text layer.
|
* Starts rendering of the text layer.
|
||||||
*
|
*
|
||||||
|
@ -6594,6 +6652,7 @@ var error = sharedUtil.error;
|
||||||
var deprecated = sharedUtil.deprecated;
|
var deprecated = sharedUtil.deprecated;
|
||||||
var getVerbosityLevel = sharedUtil.getVerbosityLevel;
|
var getVerbosityLevel = sharedUtil.getVerbosityLevel;
|
||||||
var info = sharedUtil.info;
|
var info = sharedUtil.info;
|
||||||
|
var isInt = sharedUtil.isInt;
|
||||||
var isArrayBuffer = sharedUtil.isArrayBuffer;
|
var isArrayBuffer = sharedUtil.isArrayBuffer;
|
||||||
var isSameOrigin = sharedUtil.isSameOrigin;
|
var isSameOrigin = sharedUtil.isSameOrigin;
|
||||||
var loadJpegStream = sharedUtil.loadJpegStream;
|
var loadJpegStream = sharedUtil.loadJpegStream;
|
||||||
|
@ -8115,7 +8174,7 @@ var WorkerTransport = (function WorkerTransportClosure() {
|
||||||
|
|
||||||
messageHandler.on('JpegDecode', function(data) {
|
messageHandler.on('JpegDecode', function(data) {
|
||||||
if (this.destroyed) {
|
if (this.destroyed) {
|
||||||
return Promise.reject('Worker was terminated');
|
return Promise.reject(new Error('Worker was destroyed'));
|
||||||
}
|
}
|
||||||
|
|
||||||
var imageUrl = data[0];
|
var imageUrl = data[0];
|
||||||
|
@ -8165,8 +8224,7 @@ var WorkerTransport = (function WorkerTransportClosure() {
|
||||||
},
|
},
|
||||||
|
|
||||||
getPage: function WorkerTransport_getPage(pageNumber, capability) {
|
getPage: function WorkerTransport_getPage(pageNumber, capability) {
|
||||||
if (pageNumber <= 0 || pageNumber > this.numPages ||
|
if (!isInt(pageNumber) || pageNumber <= 0 || pageNumber > this.numPages) {
|
||||||
(pageNumber|0) !== pageNumber) {
|
|
||||||
return Promise.reject(new Error('Invalid page request'));
|
return Promise.reject(new Error('Invalid page request'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8189,12 +8247,11 @@ var WorkerTransport = (function WorkerTransportClosure() {
|
||||||
},
|
},
|
||||||
|
|
||||||
getPageIndex: function WorkerTransport_getPageIndexByRef(ref) {
|
getPageIndex: function WorkerTransport_getPageIndexByRef(ref) {
|
||||||
return this.messageHandler.sendWithPromise('GetPageIndex', { ref: ref }).
|
return this.messageHandler.sendWithPromise('GetPageIndex', {
|
||||||
then(function (pageIndex) {
|
ref: ref,
|
||||||
return pageIndex;
|
}).catch(function (reason) {
|
||||||
}, function (reason) {
|
return Promise.reject(new Error(reason));
|
||||||
return Promise.reject(new Error(reason));
|
});
|
||||||
});
|
|
||||||
},
|
},
|
||||||
|
|
||||||
getAnnotations: function WorkerTransport_getAnnotations(pageIndex, intent) {
|
getAnnotations: function WorkerTransport_getAnnotations(pageIndex, intent) {
|
||||||
|
@ -8792,6 +8849,13 @@ exports._UnsupportedManager = _UnsupportedManager;
|
||||||
PDFJS.isEvalSupported = (PDFJS.isEvalSupported === undefined ?
|
PDFJS.isEvalSupported = (PDFJS.isEvalSupported === undefined ?
|
||||||
true : PDFJS.isEvalSupported);
|
true : PDFJS.isEvalSupported);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Renders interactive form elements.
|
||||||
|
* @var {boolean}
|
||||||
|
*/
|
||||||
|
PDFJS.renderInteractiveForms = (PDFJS.renderInteractiveForms === undefined ?
|
||||||
|
false : PDFJS.renderInteractiveForms);
|
||||||
|
|
||||||
|
|
||||||
PDFJS.getDocument = displayAPI.getDocument;
|
PDFJS.getDocument = displayAPI.getDocument;
|
||||||
PDFJS.PDFDataRangeTransport = displayAPI.PDFDataRangeTransport;
|
PDFJS.PDFDataRangeTransport = displayAPI.PDFDataRangeTransport;
|
||||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -101,6 +101,26 @@
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.annotationLayer .textWidgetAnnotation input {
|
||||||
|
background-color: rgba(0, 54, 255, 0.13);
|
||||||
|
border: 1px solid transparent;
|
||||||
|
box-sizing: border-box;
|
||||||
|
font-size: 9px;
|
||||||
|
height: 100%;
|
||||||
|
padding: 0 3px;
|
||||||
|
vertical-align: top;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.annotationLayer .textWidgetAnnotation input:hover {
|
||||||
|
border: 1px solid #000;
|
||||||
|
}
|
||||||
|
|
||||||
|
.annotationLayer .textWidgetAnnotation input:focus {
|
||||||
|
background: none;
|
||||||
|
border: 1px solid transparent;
|
||||||
|
}
|
||||||
|
|
||||||
.annotationLayer .popupWrapper {
|
.annotationLayer .popupWrapper {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
width: 20em;
|
width: 20em;
|
||||||
|
|
|
@ -951,7 +951,8 @@ exports.PDFRenderingQueue = PDFRenderingQueue;
|
||||||
"disableFontFace": false,
|
"disableFontFace": false,
|
||||||
"disableTextLayer": false,
|
"disableTextLayer": false,
|
||||||
"useOnlyCssZoom": false,
|
"useOnlyCssZoom": false,
|
||||||
"externalLinkTarget": 0
|
"externalLinkTarget": 0,
|
||||||
|
"renderInteractiveForms": false
|
||||||
}
|
}
|
||||||
|
|
||||||
);
|
);
|
||||||
|
@ -5037,7 +5038,7 @@ var TEXT_LAYER_RENDER_DELAY = 200; // ms
|
||||||
* @property {IPDFTextLayerFactory} textLayerFactory
|
* @property {IPDFTextLayerFactory} textLayerFactory
|
||||||
* @property {IPDFAnnotationLayerFactory} annotationLayerFactory
|
* @property {IPDFAnnotationLayerFactory} annotationLayerFactory
|
||||||
* @property {boolean} enhanceTextSelection - Turns on the text selection
|
* @property {boolean} enhanceTextSelection - Turns on the text selection
|
||||||
* enhancement. The default is `false`.
|
* enhancement. The default is `false`.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -5793,7 +5794,7 @@ exports.PDFThumbnailViewer = PDFThumbnailViewer;
|
||||||
* @property {PageViewport} viewport - The viewport of the text layer.
|
* @property {PageViewport} viewport - The viewport of the text layer.
|
||||||
* @property {PDFFindController} findController
|
* @property {PDFFindController} findController
|
||||||
* @property {boolean} enhanceTextSelection - Option to turn on improved
|
* @property {boolean} enhanceTextSelection - Option to turn on improved
|
||||||
* text selection.
|
* text selection.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -6190,7 +6191,8 @@ var AnnotationLayerBuilder = (function AnnotationLayerBuilderClosure() {
|
||||||
annotations: annotations,
|
annotations: annotations,
|
||||||
page: self.pdfPage,
|
page: self.pdfPage,
|
||||||
linkService: self.linkService,
|
linkService: self.linkService,
|
||||||
downloadManager: self.downloadManager
|
downloadManager: self.downloadManager,
|
||||||
|
renderInteractiveForms: pdfjsLib.PDFJS.renderInteractiveForms,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (self.div) {
|
if (self.div) {
|
||||||
|
@ -7403,6 +7405,9 @@ var PDFViewerApplication = {
|
||||||
}
|
}
|
||||||
PDFJS.externalLinkTarget = value;
|
PDFJS.externalLinkTarget = value;
|
||||||
}),
|
}),
|
||||||
|
Preferences.get('renderInteractiveForms').then(function resolved(value) {
|
||||||
|
PDFJS.renderInteractiveForms = value;
|
||||||
|
}),
|
||||||
// TODO move more preferences and other async stuff here
|
// TODO move more preferences and other async stuff here
|
||||||
]).catch(function (reason) { });
|
]).catch(function (reason) { });
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче