Skip to content

Commit c7b785c

Browse files
committed
fix: dir in transfer minmax
1 parent 9b0f8e3 commit c7b785c

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

float-pigment-forest/tests/custom/css_aspect_ratio.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -657,3 +657,25 @@ pub fn aspect_ratio_block_size_with_box_sizing_and_writing_mode() {
657657
assert_eq!(child3.layout_position().height, 100.);
658658
}
659659
}
660+
661+
#[test]
662+
pub fn apsect_ratio_writing_mode_streched() {
663+
assert_xml!(
664+
r#"
665+
<div>
666+
<div style="height: 400px; width: 300px;">
667+
<div style="background: red; aspect-ratio: 3 / 1; min-width: 600px" expect_width="600" expect_height="200"></div>
668+
<div style="background: blue; aspect-ratio: 3 / 1; max-width: 60px" expect_width="60" expect_height="20"></div>
669+
</div>
670+
<div style="height: 300px; width: 400px; writing-mode: vertical-lr">
671+
<div style="background: red; aspect-ratio: 1 / 3; min-height: 600px" expect_width="200" expect_height="600"></div>
672+
<div style="background: blue; aspect-ratio: 1 / 3; max-height: 60px" expect_width="20" expect_height="60"></div>
673+
</div>
674+
<div style="height: 300px; width: 400px; writing-mode: vertical-lr">
675+
<div style="background: green; aspect-ratio: 3 / 1; min-height: 500px" expect_width="1500" expect_height="500"></div>
676+
<div style="background: blue; aspect-ratio: 3 / 1; max-height: 90px" expect_width="270" expect_height="90"></div>
677+
</div>
678+
</div>
679+
"#
680+
)
681+
}

float-pigment-layout/src/algo/flow.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -823,9 +823,13 @@ pub(crate) fn transfer_min_max_size<L: LengthNum>(
823823
return min_max_limit;
824824
}
825825
let mut transfer_limit = min_max_limit.clone();
826+
let resolve_func = match main_dir {
827+
AxisDirection::Horizontal => resolve_width_from_aspect_ratio,
828+
AxisDirection::Vertical => resolve_height_from_aspect_ratio,
829+
};
826830

827831
if min_max_limit.min_cross_size(main_dir).is_positive() {
828-
let min_main_size = resolve_height_from_aspect_ratio(
832+
let min_main_size = resolve_func(
829833
border,
830834
padding_border,
831835
&box_sizing,
@@ -838,7 +842,7 @@ pub(crate) fn transfer_min_max_size<L: LengthNum>(
838842
}
839843

840844
if min_max_limit.max_cross_size(main_dir).is_some() {
841-
let mut max_main_size = resolve_height_from_aspect_ratio(
845+
let mut max_main_size = resolve_func(
842846
border,
843847
padding_border,
844848
&box_sizing,

0 commit comments

Comments
 (0)