mirror of
https://github.com/mozilla/pdf.js.git
synced 2026-07-31 11:27:21 +02:00
Merge pull request #19628 from Snuffleupagus/MathClamp-2
Use the `MathClamp` helper function more (PR 19617 follow-up)
This commit is contained in:
commit
66af403f10
@ -18,6 +18,7 @@ import {
|
|||||||
FormatError,
|
FormatError,
|
||||||
IDENTITY_MATRIX,
|
IDENTITY_MATRIX,
|
||||||
info,
|
info,
|
||||||
|
MathClamp,
|
||||||
unreachable,
|
unreachable,
|
||||||
Util,
|
Util,
|
||||||
warn,
|
warn,
|
||||||
@ -843,17 +844,19 @@ class MeshShading extends BaseShading {
|
|||||||
((figureMaxX - figureMinX) * MeshShading.TRIANGLE_DENSITY) /
|
((figureMaxX - figureMinX) * MeshShading.TRIANGLE_DENSITY) /
|
||||||
(this.bounds[2] - this.bounds[0])
|
(this.bounds[2] - this.bounds[0])
|
||||||
);
|
);
|
||||||
splitXBy = Math.max(
|
splitXBy = MathClamp(
|
||||||
|
splitXBy,
|
||||||
MeshShading.MIN_SPLIT_PATCH_CHUNKS_AMOUNT,
|
MeshShading.MIN_SPLIT_PATCH_CHUNKS_AMOUNT,
|
||||||
Math.min(MeshShading.MAX_SPLIT_PATCH_CHUNKS_AMOUNT, splitXBy)
|
MeshShading.MAX_SPLIT_PATCH_CHUNKS_AMOUNT
|
||||||
);
|
);
|
||||||
let splitYBy = Math.ceil(
|
let splitYBy = Math.ceil(
|
||||||
((figureMaxY - figureMinY) * MeshShading.TRIANGLE_DENSITY) /
|
((figureMaxY - figureMinY) * MeshShading.TRIANGLE_DENSITY) /
|
||||||
(this.bounds[3] - this.bounds[1])
|
(this.bounds[3] - this.bounds[1])
|
||||||
);
|
);
|
||||||
splitYBy = Math.max(
|
splitYBy = MathClamp(
|
||||||
|
splitYBy,
|
||||||
MeshShading.MIN_SPLIT_PATCH_CHUNKS_AMOUNT,
|
MeshShading.MIN_SPLIT_PATCH_CHUNKS_AMOUNT,
|
||||||
Math.min(MeshShading.MAX_SPLIT_PATCH_CHUNKS_AMOUNT, splitYBy)
|
MeshShading.MAX_SPLIT_PATCH_CHUNKS_AMOUNT
|
||||||
);
|
);
|
||||||
|
|
||||||
const verticesPerRow = splitXBy + 1;
|
const verticesPerRow = splitXBy + 1;
|
||||||
|
|||||||
@ -21,6 +21,7 @@ import {
|
|||||||
$isSplittable,
|
$isSplittable,
|
||||||
$isThereMoreWidth,
|
$isThereMoreWidth,
|
||||||
} from "./symbol_utils.js";
|
} from "./symbol_utils.js";
|
||||||
|
import { MathClamp } from "../../shared/util.js";
|
||||||
import { measureToString } from "./html_utils.js";
|
import { measureToString } from "./html_utils.js";
|
||||||
|
|
||||||
// Subform and ExclGroup have a layout so they share these functions.
|
// Subform and ExclGroup have a layout so they share these functions.
|
||||||
@ -141,7 +142,7 @@ function addHTML(node, html, bbox) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "table": {
|
case "table": {
|
||||||
extra.width = Math.min(availableSpace.width, Math.max(extra.width, w));
|
extra.width = MathClamp(w, extra.width, availableSpace.width);
|
||||||
extra.height += h;
|
extra.height += h;
|
||||||
extra.children.push(html);
|
extra.children.push(html);
|
||||||
break;
|
break;
|
||||||
@ -150,7 +151,7 @@ function addHTML(node, html, bbox) {
|
|||||||
// Even if the subform can possibly take all the available width,
|
// Even if the subform can possibly take all the available width,
|
||||||
// we must compute the final width as it is in order to be able
|
// we must compute the final width as it is in order to be able
|
||||||
// for example to center the subform within its parent.
|
// for example to center the subform within its parent.
|
||||||
extra.width = Math.min(availableSpace.width, Math.max(extra.width, w));
|
extra.width = MathClamp(w, extra.width, availableSpace.width);
|
||||||
extra.height += h;
|
extra.height += h;
|
||||||
extra.children.push(html);
|
extra.children.push(html);
|
||||||
break;
|
break;
|
||||||
|
|||||||
@ -81,13 +81,11 @@ const StyleMapping = new Map([
|
|||||||
["kerning-mode", value => (value === "none" ? "none" : "normal")],
|
["kerning-mode", value => (value === "none" ? "none" : "normal")],
|
||||||
[
|
[
|
||||||
"xfa-font-horizontal-scale",
|
"xfa-font-horizontal-scale",
|
||||||
value =>
|
value => `scaleX(${Math.max(0, parseInt(value) / 100).toFixed(2)})`,
|
||||||
`scaleX(${Math.max(0, Math.min(parseInt(value) / 100)).toFixed(2)})`,
|
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
"xfa-font-vertical-scale",
|
"xfa-font-vertical-scale",
|
||||||
value =>
|
value => `scaleY(${Math.max(0, parseInt(value) / 100).toFixed(2)})`,
|
||||||
`scaleY(${Math.max(0, Math.min(parseInt(value) / 100)).toFixed(2)})`,
|
|
||||||
],
|
],
|
||||||
["xfa-spacerun", ""],
|
["xfa-spacerun", ""],
|
||||||
["xfa-tab-stops", ""],
|
["xfa-tab-stops", ""],
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user