diff options
3 files changed, 21 insertions, 2 deletions
diff --git a/Tests/LibWeb/Layout/expected/flex-item-with-intrinsic-aspect-ratio.txt b/Tests/LibWeb/Layout/expected/flex-item-with-intrinsic-aspect-ratio.txt new file mode 100644 index 0000000000..ffac888f15 --- /dev/null +++ b/Tests/LibWeb/Layout/expected/flex-item-with-intrinsic-aspect-ratio.txt @@ -0,0 +1,4 @@ +Viewport <#document> at (0,0) content-size 800x600 children: not-inline + BlockContainer <html> at (0,0) content-size 800x200 children: not-inline + Box <body> at (0,0) content-size 400x200 flex-container(column) children: not-inline + ImageBox <img> at (0,0) content-size 400x200 flex-item children: not-inline diff --git a/Tests/LibWeb/Layout/input/flex-item-with-intrinsic-aspect-ratio.html b/Tests/LibWeb/Layout/input/flex-item-with-intrinsic-aspect-ratio.html new file mode 100644 index 0000000000..5b5077f46e --- /dev/null +++ b/Tests/LibWeb/Layout/input/flex-item-with-intrinsic-aspect-ratio.html @@ -0,0 +1,11 @@ +<!DOCTYPE html><html><head><style> + * { + margin: 0; + padding: 0; + } + body { + display: flex; + flex-direction: column; + width: 400px; + } +</style></head><body><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAABLAAAAJYCAMAAABFOO8oAAABg1BMVEUAAAAXK0wXK00YJTwYLlEYLlIYLlQYMloYMlwYNmMZAAAZIjYZIzgZJDkZJj8ZLVEZMVkZQHcaNmQaOmsbMVQcJzwcNVsdPW4eK0QfNVYfNlwfQ3kfRXofR38gQHAhOF4hOWAiIiIiJCwiJS4iJi8iJzEiRnwjJy4jKz4jLEIjXK8jXLAkKjUkLDEkP2kkR3wkSIAkXbIkX7UkX7YlSYAlYLclYbkmMEYmSn0mYrwmZL8nZcEnZsInZsMoS30pZ8MqaMQracQva8UvbMUybsYzbsY0b8c1cMc2ccc5hwU6c8g6dMg6hwU7dMk7iQU7igU8dck8jQU9dslAlgZKlxVShc9Thc9YidFYzwha0ghbZH1b1Qhd2QleZ4Je3Qlf3glg4glh5Ali5gljkdRkkdRlb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InAAQLQLAAwQIQLADBAgQLQLAABAsQLADBAhAsQLAABAtAsADBAhAsAMECBAtAsAAECxAsAMECECxAsAAEC0CwAMECECxAsAAEC0CwAMECECwAwQIEC0CwAAQLECwAwQIQLECwAAQLQLAAwQIQLADBAgQLQLAABAsQLADBAhAsQLAABAtAsADBAhAsQLAABAtAsADBAhAsAMECBAtAsAAECxAsAMECECxAsAAEC0CwAMECECwAwQIEC0CwAAQLECwAwQIQLECwAAQLQLAAwQIQLECwAAQLQLAAwQIQLADBAgQLQLAABAsQLADBAhAsQLAABAtAsADBAhAsAMECBAtAsAAECxAsAMECECxAsAAEC0CwAMECECxAsAAEC0CwAMECECwAwQIEC0CwAAQLECwAwQIQLECwAAQLQLAAwQIQLADBAgQLQLAABAsQLADBAhAsQLAABAtAsADBAhAsQLAABAtAsADBAhAsAMECBAtAsAAEC2i8fwDFkO6lWFprKQAAAABJRU5ErkJggg==">
\ No newline at end of file diff --git a/Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp b/Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp index 4fd235ee53..f2636de719 100644 --- a/Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp +++ b/Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp @@ -614,7 +614,9 @@ void FlexFormattingContext::determine_flex_base_size_and_hypothetical_main_size( && item.used_flex_basis.type == CSS::FlexBasis::Content && has_definite_cross_size(item.box)) { // flex_base_size is calculated from definite cross size and intrinsic aspect ratio - return resolved_definite_cross_size(item) * item.box->intrinsic_aspect_ratio().value(); + if (is_row_layout()) + return inner_cross_size(item.box) * item.box->intrinsic_aspect_ratio().value(); + return inner_cross_size(item.box) / item.box->intrinsic_aspect_ratio().value(); } // C. If the used flex basis is content or depends on its available space, @@ -724,7 +726,9 @@ Optional<CSSPixels> FlexFormattingContext::transferred_size_suggestion(FlexItem if (item.box->has_intrinsic_aspect_ratio() && has_definite_cross_size(item.box)) { auto aspect_ratio = item.box->intrinsic_aspect_ratio().value(); // FIXME: Clamp cross size to min/max cross size before this conversion. - return resolved_definite_cross_size(item) * aspect_ratio; + if (is_row_layout()) + return resolved_definite_cross_size(item) * aspect_ratio; + return resolved_definite_cross_size(item) / aspect_ratio; } // It is otherwise undefined. |