From 7ee370a394bcc4cc1a2b5af90ee8abf4571ed69b Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Sun, 11 Aug 2019 13:40:58 +0200 Subject: [PATCH] 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. --- src/core/document.js | 4 ++-- src/shared/util.js | 6 +----- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/src/core/document.js b/src/core/document.js index 993f8fa39..aba5117ef 100644 --- a/src/core/document.js +++ b/src/core/document.js @@ -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.'); diff --git a/src/shared/util.js b/src/shared/util.js index bc29e9d2b..e2545ffc0 100644 --- a/src/shared/util.js +++ b/src/shared/util.js @@ -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; };