Remove the skipEmpty parameter from Util.intersect (PR 11059 follow-up)

Looking at this again, it struck me that added functionality in `Util.intersect` is probably more confusing than helpful in general; sorry about the churn in this code!
Based on the parameter name you'd probably expect it to only match when the intersection is `[0, 0,  0, 0]` and not when only one component is zero, hence the `skipEmpty` parameter thus feels too tightly coupled to the `Page.view` getter.
This commit is contained in:
Jonas Jenwald 2019-08-11 13:40:58 +02:00
parent 85acc9acac
commit 7ee370a394
2 changed files with 3 additions and 7 deletions

View File

@ -137,8 +137,8 @@ class Page {
if (cropBox === mediaBox || isArrayEqual(cropBox, mediaBox)) {
view = mediaBox;
} else {
const box = Util.intersect(cropBox, mediaBox, /* skipEmpty = */ true);
if (box) {
const box = Util.intersect(cropBox, mediaBox);
if (box && ((box[2] - box[0]) !== 0 && (box[3] - box[1]) !== 0)) {
view = box;
} else {
warn('Empty /CropBox and /MediaBox intersection.');

View File

@ -748,7 +748,7 @@ var Util = (function UtilClosure() {
// Returns a rectangle [x1, y1, x2, y2] corresponding to the
// intersection of rect1 and rect2. If no intersection, returns 'false'
// The rectangle coordinates of rect1, rect2 should be [x1, y1, x2, y2]
Util.intersect = function Util_intersect(rect1, rect2, skipEmpty = false) {
Util.intersect = function Util_intersect(rect1, rect2) {
function compare(a, b) {
return a - b;
}
@ -781,10 +781,6 @@ var Util = (function UtilClosure() {
return null;
}
if (skipEmpty &&
((result[2] - result[0]) === 0 || (result[3] - result[1]) === 0)) {
return null;
}
return result;
};