Merge pull request #18218 from nicolo-ribaudo/test-maxCanvasPixels

Respect `maxCanvasPixels` when computing canvas dimensions
This commit is contained in:
Tim van der Meij 2024-06-19 16:47:09 +02:00 committed by GitHub
commit 3e1d779859
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 187 additions and 62 deletions

View file

@ -263,6 +263,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.
@ -309,9 +310,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);
}
/**
@ -866,6 +870,7 @@ export {
DEFAULT_SCALE_DELTA,
DEFAULT_SCALE_VALUE,
docStyle,
floorToDivide,
getActiveOrFocusedElement,
getPageSizeInches,
getVisibleElements,
@ -884,7 +889,6 @@ export {
ProgressBar,
removeNullCharacters,
RenderingStates,
roundToDivide,
SCROLLBAR_PADDING,
scrollIntoView,
ScrollMode,