blitz-pdf 0.1.5 → 0.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +38 -3
- package/THIRD_PARTY_NOTICES.md +2 -0
- package/package.json +1 -1
- package/vendor/README.md +24 -0
- package/vendor/blitz-paint/Cargo.toml +50 -0
- package/vendor/blitz-paint/LICENSE-APACHE +176 -0
- package/vendor/blitz-paint/LICENSE-MIT +23 -0
- package/vendor/blitz-paint/src/color.rs +66 -0
- package/vendor/blitz-paint/src/debug_overlay.rs +168 -0
- package/vendor/blitz-paint/src/filters.rs +40 -0
- package/vendor/blitz-paint/src/gradient.rs +536 -0
- package/vendor/blitz-paint/src/kurbo_css/css_box.rs +847 -0
- package/vendor/blitz-paint/src/kurbo_css/mod.rs +77 -0
- package/vendor/blitz-paint/src/kurbo_css/non_uniform_radii.rs +60 -0
- package/vendor/blitz-paint/src/layers.rs +95 -0
- package/vendor/blitz-paint/src/lib.rs +190 -0
- package/vendor/blitz-paint/src/render/background.rs +968 -0
- package/vendor/blitz-paint/src/render/border.rs +631 -0
- package/vendor/blitz-paint/src/render/box_shadow.rs +157 -0
- package/vendor/blitz-paint/src/render/clip_path.rs +492 -0
- package/vendor/blitz-paint/src/render/form_controls.rs +103 -0
- package/vendor/blitz-paint/src/render/mask.rs +144 -0
- package/vendor/blitz-paint/src/render.rs +1351 -0
- package/vendor/blitz-paint/src/sizing.rs +63 -0
- package/vendor/blitz-paint/src/text.rs +747 -0
- package/wasm/blitz_pdf_bg.wasm +0 -0
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
use style::properties::generated::longhands::object_fit::computed_value::T as ObjectFit;
|
|
2
|
+
|
|
3
|
+
pub(crate) fn compute_object_fit(
|
|
4
|
+
container_size: taffy::Size<f32>,
|
|
5
|
+
object_size: Option<taffy::Size<f32>>,
|
|
6
|
+
object_fit: ObjectFit,
|
|
7
|
+
) -> taffy::Size<f32> {
|
|
8
|
+
match object_fit {
|
|
9
|
+
ObjectFit::None => object_size.unwrap_or(container_size),
|
|
10
|
+
ObjectFit::Fill => container_size,
|
|
11
|
+
ObjectFit::Cover => compute_object_fit_cover(container_size, object_size),
|
|
12
|
+
ObjectFit::Contain => compute_object_fit_contain(container_size, object_size),
|
|
13
|
+
ObjectFit::ScaleDown => {
|
|
14
|
+
let contain_size = compute_object_fit_contain(container_size, object_size);
|
|
15
|
+
match object_size {
|
|
16
|
+
Some(object_size) if object_size.width < contain_size.width => object_size,
|
|
17
|
+
_ => contain_size,
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
fn compute_object_fit_contain(
|
|
24
|
+
container_size: taffy::Size<f32>,
|
|
25
|
+
object_size: Option<taffy::Size<f32>>,
|
|
26
|
+
) -> taffy::Size<f32> {
|
|
27
|
+
let Some(object_size) = object_size else {
|
|
28
|
+
return container_size;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
let x_ratio = container_size.width / object_size.width;
|
|
32
|
+
let y_ratio = container_size.height / object_size.height;
|
|
33
|
+
|
|
34
|
+
let ratio = match (x_ratio < 1.0, y_ratio < 1.0) {
|
|
35
|
+
(true, true) => x_ratio.min(y_ratio),
|
|
36
|
+
(true, false) => x_ratio,
|
|
37
|
+
(false, true) => y_ratio,
|
|
38
|
+
(false, false) => x_ratio.min(y_ratio),
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
object_size.map(|dim| dim * ratio)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
fn compute_object_fit_cover(
|
|
45
|
+
container_size: taffy::Size<f32>,
|
|
46
|
+
object_size: Option<taffy::Size<f32>>,
|
|
47
|
+
) -> taffy::Size<f32> {
|
|
48
|
+
let Some(object_size) = object_size else {
|
|
49
|
+
return container_size;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
let x_ratio = container_size.width / object_size.width;
|
|
53
|
+
let y_ratio = container_size.height / object_size.height;
|
|
54
|
+
|
|
55
|
+
let ratio = match (x_ratio < 1.0, y_ratio < 1.0) {
|
|
56
|
+
(true, true) => x_ratio.max(y_ratio),
|
|
57
|
+
(true, false) => y_ratio,
|
|
58
|
+
(false, true) => x_ratio,
|
|
59
|
+
(false, false) => x_ratio.max(y_ratio),
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
object_size.map(|dim| dim * ratio)
|
|
63
|
+
}
|