mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-08 01:10:08 +02:00
Respect maxCanvasPixels
when computing canvas dimensions
Ensure that we never round the canvas dimensions above `maxCanvasPixels` by rounding them to the preceeding multiple of the display ratio rather than the succeeding one.
This commit is contained in:
parent
12692d2e39
commit
de23bb9b82
3 changed files with 20 additions and 15 deletions
|
@ -260,6 +260,7 @@ function binarySearchFirstItem(items, condition, start = 0) {
|
|||
* @param {number} x - Positive float number.
|
||||
* @returns {Array} Estimated fraction: the first array item is a numerator,
|
||||
* the second one is a denominator.
|
||||
* They are both natural numbers.
|
||||
*/
|
||||
function approximateFraction(x) {
|
||||
// Fast paths for int numbers or their inversions.
|
||||
|
@ -306,9 +307,12 @@ function approximateFraction(x) {
|
|||
return result;
|
||||
}
|
||||
|
||||
function roundToDivide(x, div) {
|
||||
const r = x % div;
|
||||
return r === 0 ? x : Math.round(x - r + div);
|
||||
/**
|
||||
* @param {number} x - A positive number to round to a multiple of `div`.
|
||||
* @param {number} div - A natural number.
|
||||
*/
|
||||
function floorToDivide(x, div) {
|
||||
return x - (x % div);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -863,6 +867,7 @@ export {
|
|||
DEFAULT_SCALE_DELTA,
|
||||
DEFAULT_SCALE_VALUE,
|
||||
docStyle,
|
||||
floorToDivide,
|
||||
getActiveOrFocusedElement,
|
||||
getPageSizeInches,
|
||||
getVisibleElements,
|
||||
|
@ -881,7 +886,6 @@ export {
|
|||
ProgressBar,
|
||||
removeNullCharacters,
|
||||
RenderingStates,
|
||||
roundToDivide,
|
||||
SCROLLBAR_PADDING,
|
||||
scrollIntoView,
|
||||
ScrollMode,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue