Merge pull request #7977 from Snuffleupagus/paintedViewport-regression
Ensure that we use the *correct* `paintedViewport` in `PDFPageView.cssTransform`, to avoid visual glitches on quick rotations (PR 7738 follow-up)
This commit is contained in:
commit
857e360a42
@ -97,7 +97,7 @@ var PDFPageView = (function PDFPageViewClosure() {
|
|||||||
this.renderer = options.renderer || RendererType.CANVAS;
|
this.renderer = options.renderer || RendererType.CANVAS;
|
||||||
|
|
||||||
this.paintTask = null;
|
this.paintTask = null;
|
||||||
this.paintedViewport = null;
|
this.paintedViewportMap = new WeakMap();
|
||||||
this.renderingState = RenderingStates.INITIAL;
|
this.renderingState = RenderingStates.INITIAL;
|
||||||
this.resume = null;
|
this.resume = null;
|
||||||
this.error = null;
|
this.error = null;
|
||||||
@ -170,6 +170,7 @@ var PDFPageView = (function PDFPageViewClosure() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (this.canvas && !currentZoomLayerNode) {
|
if (this.canvas && !currentZoomLayerNode) {
|
||||||
|
this.paintedViewportMap.delete(this.canvas);
|
||||||
// Zeroing the width and height causes Firefox to release graphics
|
// Zeroing the width and height causes Firefox to release graphics
|
||||||
// resources immediately, which can greatly reduce memory consumption.
|
// resources immediately, which can greatly reduce memory consumption.
|
||||||
this.canvas.width = 0;
|
this.canvas.width = 0;
|
||||||
@ -177,11 +178,9 @@ var PDFPageView = (function PDFPageViewClosure() {
|
|||||||
delete this.canvas;
|
delete this.canvas;
|
||||||
}
|
}
|
||||||
if (this.svg) {
|
if (this.svg) {
|
||||||
|
this.paintedViewportMap.delete(this.svg);
|
||||||
delete this.svg;
|
delete this.svg;
|
||||||
}
|
}
|
||||||
if (!currentZoomLayerNode) {
|
|
||||||
this.paintedViewport = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.loadingIconDiv = document.createElement('div');
|
this.loadingIconDiv = document.createElement('div');
|
||||||
this.loadingIconDiv.className = 'loadingIcon';
|
this.loadingIconDiv.className = 'loadingIcon';
|
||||||
@ -281,7 +280,7 @@ var PDFPageView = (function PDFPageViewClosure() {
|
|||||||
Math.floor(height) + 'px';
|
Math.floor(height) + 'px';
|
||||||
// The canvas may have been originally rotated, rotate relative to that.
|
// The canvas may have been originally rotated, rotate relative to that.
|
||||||
var relativeRotation = this.viewport.rotation -
|
var relativeRotation = this.viewport.rotation -
|
||||||
this.paintedViewport.rotation;
|
this.paintedViewportMap.get(target).rotation;
|
||||||
var absRotation = Math.abs(relativeRotation);
|
var absRotation = Math.abs(relativeRotation);
|
||||||
var scaleX = 1, scaleY = 1;
|
var scaleX = 1, scaleY = 1;
|
||||||
if (absRotation === 90 || absRotation === 270) {
|
if (absRotation === 90 || absRotation === 270) {
|
||||||
@ -434,9 +433,10 @@ var PDFPageView = (function PDFPageViewClosure() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (self.zoomLayer) {
|
if (self.zoomLayer) {
|
||||||
|
var zoomLayerCanvas = self.zoomLayer.firstChild;
|
||||||
|
self.paintedViewportMap.delete(zoomLayerCanvas);
|
||||||
// Zeroing the width and height causes Firefox to release graphics
|
// Zeroing the width and height causes Firefox to release graphics
|
||||||
// resources immediately, which can greatly reduce memory consumption.
|
// resources immediately, which can greatly reduce memory consumption.
|
||||||
var zoomLayerCanvas = self.zoomLayer.firstChild;
|
|
||||||
zoomLayerCanvas.width = 0;
|
zoomLayerCanvas.width = 0;
|
||||||
zoomLayerCanvas.height = 0;
|
zoomLayerCanvas.height = 0;
|
||||||
|
|
||||||
@ -578,7 +578,7 @@ var PDFPageView = (function PDFPageViewClosure() {
|
|||||||
canvas.style.width = roundToDivide(viewport.width, sfx[1]) + 'px';
|
canvas.style.width = roundToDivide(viewport.width, sfx[1]) + 'px';
|
||||||
canvas.style.height = roundToDivide(viewport.height, sfy[1]) + 'px';
|
canvas.style.height = roundToDivide(viewport.height, sfy[1]) + 'px';
|
||||||
// Add the viewport so it's known what it was originally drawn with.
|
// Add the viewport so it's known what it was originally drawn with.
|
||||||
this.paintedViewport = viewport;
|
this.paintedViewportMap.set(canvas, viewport);
|
||||||
|
|
||||||
// Rendering area
|
// Rendering area
|
||||||
var transform = !outputScale.scaled ? null :
|
var transform = !outputScale.scaled ? null :
|
||||||
@ -643,7 +643,7 @@ var PDFPageView = (function PDFPageViewClosure() {
|
|||||||
return svgGfx.getSVG(opList, actualSizeViewport).then(function (svg) {
|
return svgGfx.getSVG(opList, actualSizeViewport).then(function (svg) {
|
||||||
ensureNotCancelled();
|
ensureNotCancelled();
|
||||||
self.svg = svg;
|
self.svg = svg;
|
||||||
self.paintedViewport = actualSizeViewport;
|
self.paintedViewportMap.set(svg, actualSizeViewport);
|
||||||
|
|
||||||
svg.style.width = wrapper.style.width;
|
svg.style.width = wrapper.style.width;
|
||||||
svg.style.height = wrapper.style.height;
|
svg.style.height = wrapper.style.height;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user