Don't clip when the clip path is empty (issue #12306)

This commit is contained in:
Calixte Denizet 2022-04-17 21:59:17 +02:00
parent 379125c37f
commit 3d74d2c6cb
3 changed files with 22 additions and 6 deletions

View File

@ -634,6 +634,10 @@ class CanvasExtraState {
this.startNewPathAndClipBox(intersect || [0, 0, 0, 0]);
}
isEmptyClip() {
return this.minX === Infinity;
}
startNewPathAndClipBox(box) {
this.clipBox = box;
this.minX = Infinity;
@ -2434,7 +2438,7 @@ class CanvasGraphics {
// TODO According to the spec we're also suppose to ignore any operators
// that set color or include images while processing this type3 font.
this.ctx.rect(llx, lly, urx - llx, ury - lly);
this.clip();
this.ctx.clip();
this.endPath();
}
@ -2820,7 +2824,7 @@ class CanvasGraphics {
resetCtxToDefault(this.ctx);
this.ctx.rect(rect[0], rect[1], width, height);
this.clip();
this.ctx.clip();
this.endPath();
}
}
@ -3170,6 +3174,7 @@ class CanvasGraphics {
// Helper functions
consumePath(clipBox) {
const isEmpty = this.current.isEmptyClip();
if (this.pendingClip) {
this.current.updateClipFromPath();
}
@ -3178,10 +3183,12 @@ class CanvasGraphics {
}
const ctx = this.ctx;
if (this.pendingClip) {
if (this.pendingClip === EO_CLIP) {
ctx.clip("evenodd");
} else {
ctx.clip();
if (!isEmpty) {
if (this.pendingClip === EO_CLIP) {
ctx.clip("evenodd");
} else {
ctx.clip();
}
}
this.pendingClip = null;
}

View File

@ -0,0 +1 @@
https://github.com/mozilla/pdf.js/files/5150027/document13-08-2020-122237.pdf

View File

@ -6362,5 +6362,13 @@
"link": true,
"lastPage": 1,
"type": "eq"
},
{ "id": "issue12306",
"file": "pdfs/issue12306.pdf",
"md5": "7fd05ba56791238b5a60adc6cc0e7a22",
"rounds": 1,
"link": true,
"lastPage": 1,
"type": "eq"
}
]