Merge pull request #14797 from calixteman/12306

Don't clip when the clip path is empty (issue #12306)
This commit is contained in:
Jonas Jenwald 2022-04-18 11:18:32 +02:00 committed by GitHub
commit 5bbed400f2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 6 deletions

View File

@ -649,6 +649,10 @@ class CanvasExtraState {
this.startNewPathAndClipBox(intersect || [0, 0, 0, 0]);
}
isEmptyClip() {
return this.minX === Infinity;
}
startNewPathAndClipBox(box) {
this.clipBox = box;
this.minX = Infinity;
@ -2476,7 +2480,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();
}
@ -2862,7 +2866,7 @@ class CanvasGraphics {
resetCtxToDefault(this.ctx);
this.ctx.rect(rect[0], rect[1], width, height);
this.clip();
this.ctx.clip();
this.endPath();
}
}
@ -3212,6 +3216,7 @@ class CanvasGraphics {
// Helper functions
consumePath(clipBox) {
const isEmpty = this.current.isEmptyClip();
if (this.pendingClip) {
this.current.updateClipFromPath();
}
@ -3220,10 +3225,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"
}
]