Minor code style improvements after #7539
This commit is contained in:
parent
6bb95e3129
commit
7c961b6b7a
@ -187,22 +187,23 @@ var renderTextLayer = (function renderTextLayerClosure() {
|
||||
var width = ctx.measureText(textDiv.textContent).width;
|
||||
textDiv.dataset.originalWidth = width;
|
||||
textLayerFrag.appendChild(textDiv);
|
||||
var transform;
|
||||
if (textDiv.dataset.canvasWidth !== undefined && width > 0) {
|
||||
// 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) {
|
||||
textDiv.dataset.originalTransform = transform;
|
||||
CustomStyle.setProp('transform' , textDiv, transform);
|
||||
}
|
||||
|
||||
var transform;
|
||||
if (textDiv.dataset.canvasWidth !== undefined && width > 0) {
|
||||
// Dataset values are 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) {
|
||||
textDiv.dataset.originalTransform = transform;
|
||||
CustomStyle.setProp('transform' , textDiv, transform);
|
||||
}
|
||||
}
|
||||
task._renderingDone = true;
|
||||
capability.resolve();
|
||||
@ -250,13 +251,13 @@ var renderTextLayer = (function renderTextLayerClosure() {
|
||||
});
|
||||
var findPositiveMin = function (ts, offset, count) {
|
||||
var result = 0;
|
||||
for (var i = 0; i < count; i++) {
|
||||
var t = ts[offset++];
|
||||
if (t > 0) {
|
||||
result = result ? Math.min(t, result) : t;
|
||||
}
|
||||
for (var i = 0; i < count; i++) {
|
||||
var t = ts[offset++];
|
||||
if (t > 0) {
|
||||
result = result ? Math.min(t, result) : t;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
return result;
|
||||
};
|
||||
// Not based on math, but to simplify calculations, using cos and sin
|
||||
// absolute values to not exceed the box (it can but insignificantly).
|
||||
@ -515,10 +516,11 @@ var renderTextLayer = (function renderTextLayerClosure() {
|
||||
var styles = this._textContent.styles;
|
||||
var textDivs = this._textDivs;
|
||||
var viewport = this._viewport;
|
||||
var bounds = this._bounds;
|
||||
var enhanceTextSelection = this._enhanceTextSelection;
|
||||
|
||||
for (var i = 0, len = textItems.length; i < len; i++) {
|
||||
appendText(textDivs, viewport, textItems[i], styles, this._bounds,
|
||||
appendText(textDivs, viewport, textItems[i], styles, bounds,
|
||||
enhanceTextSelection);
|
||||
}
|
||||
|
||||
@ -548,7 +550,7 @@ var renderTextLayer = (function renderTextLayerClosure() {
|
||||
var transform;
|
||||
var width = div.dataset.originalWidth;
|
||||
if (div.dataset.canvasWidth !== undefined && width > 0) {
|
||||
// Dataset values come of type string.
|
||||
// Dataset values are of type string.
|
||||
var textScale = div.dataset.canvasWidth / width;
|
||||
transform = 'scaleX(' + textScale + ')';
|
||||
} else {
|
||||
|
@ -98,7 +98,7 @@ IPDFTextLayerFactory.prototype = {
|
||||
* @param {HTMLDivElement} textLayerDiv
|
||||
* @param {number} pageIndex
|
||||
* @param {PageViewport} viewport
|
||||
* @param {Boolean} enhanceTextSelection
|
||||
* @param {boolean} enhanceTextSelection
|
||||
* @returns {TextLayerBuilder}
|
||||
*/
|
||||
createTextLayerBuilder: function (textLayerDiv, pageIndex, viewport,
|
||||
|
@ -51,7 +51,7 @@ var TEXT_LAYER_RENDER_DELAY = 200; // ms
|
||||
* @property {IPDFTextLayerFactory} textLayerFactory
|
||||
* @property {IPDFAnnotationLayerFactory} annotationLayerFactory
|
||||
* @property {boolean} enhanceTextSelection - Turns on the text selection
|
||||
* enhancement. The default is `false`.
|
||||
* enhancement. The default is `false`.
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@ -36,7 +36,7 @@
|
||||
* @property {PageViewport} viewport - The viewport of the text layer.
|
||||
* @property {PDFFindController} findController
|
||||
* @property {boolean} enhanceTextSelection - Option to turn on improved
|
||||
* text selection.
|
||||
* text selection.
|
||||
*/
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user