mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-21 20:15:17 +00:00
LibWeb: Respect min/max-content available size in auto width calculation
Some checks are pending
CI / Lagom (arm64, Sanitizer_CI, false, macos-15, macOS, Clang) (push) Waiting to run
CI / Lagom (x86_64, Fuzzers_CI, false, ubuntu-24.04, Linux, Clang) (push) Waiting to run
CI / Lagom (x86_64, Sanitizer_CI, false, ubuntu-24.04, Linux, GNU) (push) Waiting to run
CI / Lagom (x86_64, Sanitizer_CI, true, ubuntu-24.04, Linux, Clang) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (macos-14, macOS, macOS-universal2) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (ubuntu-24.04, Linux, Linux-x86_64) (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Label PRs with merge conflicts / auto-labeler (push) Waiting to run
Push notes / build (push) Waiting to run
Some checks are pending
CI / Lagom (arm64, Sanitizer_CI, false, macos-15, macOS, Clang) (push) Waiting to run
CI / Lagom (x86_64, Fuzzers_CI, false, ubuntu-24.04, Linux, Clang) (push) Waiting to run
CI / Lagom (x86_64, Sanitizer_CI, false, ubuntu-24.04, Linux, GNU) (push) Waiting to run
CI / Lagom (x86_64, Sanitizer_CI, true, ubuntu-24.04, Linux, Clang) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (macos-14, macOS, macOS-universal2) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (ubuntu-24.04, Linux, Linux-x86_64) (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Label PRs with merge conflicts / auto-labeler (push) Waiting to run
Push notes / build (push) Waiting to run
...for block level boxes. Otherwise we end up resolving auto width as zero during intrinsic layout, which leads to incorrectly applied max-width constraint. Fixes https://github.com/LadybirdBrowser/ladybird/issues/4123
This commit is contained in:
parent
2794ed0c73
commit
732a5cdc12
Notes:
github-actions[bot]
2025-03-28 02:14:44 +00:00
Author: https://github.com/kalenikaliaksandr Commit: https://github.com/LadybirdBrowser/ladybird/commit/732a5cdc124 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4132 Reviewed-by: https://github.com/gmta ✅
3 changed files with 45 additions and 2 deletions
|
@ -265,6 +265,12 @@ void BlockFormattingContext::compute_width(Box const& box, AvailableSpace const&
|
|||
} else {
|
||||
width = zero_value;
|
||||
}
|
||||
} else if (available_space.width.is_min_content()) {
|
||||
width = CSS::Length::make_px(calculate_min_content_width(box));
|
||||
} else if (available_space.width.is_max_content()) {
|
||||
width = CSS::Length::make_px(calculate_max_content_width(box));
|
||||
} else {
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
} else {
|
||||
if (!margin_left.is_auto() && !margin_right.is_auto()) {
|
||||
|
@ -304,8 +310,7 @@ void BlockFormattingContext::compute_width(Box const& box, AvailableSpace const&
|
|||
// but this time using the computed value of 'max-width' as the computed value for 'width'.
|
||||
if (!should_treat_max_width_as_none(box, available_space.width)) {
|
||||
auto max_width = calculate_inner_width(box, remaining_available_space.width, computed_values.max_width());
|
||||
auto used_width_px = used_width.is_auto() ? CSSPixels { 0 } : used_width.to_px(box);
|
||||
if (used_width_px > max_width) {
|
||||
if (used_width.to_px(box) > max_width) {
|
||||
used_width = try_compute_width(CSS::Length::make_px(max_width));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
Viewport <#document> at (0,0) content-size 800x600 children: not-inline
|
||||
BlockContainer <html> at (0,0) content-size 800x16 [BFC] children: not-inline
|
||||
BlockContainer <body> at (8,8) content-size 784x0 children: not-inline
|
||||
BlockContainer <div.a> at (8,8) content-size 100x85 positioned [BFC] children: not-inline
|
||||
Box <div.b> at (8,8) content-size 100x85 flex-container(row) [FFC] children: not-inline
|
||||
BlockContainer <(anonymous)> at (8,8) content-size 105.5625x85 flex-item [BFC] children: inline
|
||||
frag 0 from TextNode start: 0, length: 11, rect: [8,8 98x17] baseline: 13.296875
|
||||
"foo bar baz"
|
||||
frag 1 from TextNode start: 12, length: 11, rect: [8,25 97.640625x17] baseline: 13.296875
|
||||
"lorem ipsum"
|
||||
frag 2 from TextNode start: 24, length: 9, rect: [8,42 70.40625x17] baseline: 13.296875
|
||||
"dolor sit"
|
||||
frag 3 from TextNode start: 34, length: 4, rect: [8,59 37.125x17] baseline: 13.296875
|
||||
"amet"
|
||||
frag 4 from TextNode start: 39, length: 12, rect: [8,76 105.5625x17] baseline: 13.296875
|
||||
"consectetuer"
|
||||
TextNode <#text>
|
||||
|
||||
ViewportPaintable (Viewport<#document>) [0,0 800x600]
|
||||
PaintableWithLines (BlockContainer<HTML>) [0,0 800x16]
|
||||
PaintableWithLines (BlockContainer<BODY>) [8,8 784x0]
|
||||
PaintableWithLines (BlockContainer<DIV>.a) [8,8 100x85] overflow: [8,8 105.5625x85]
|
||||
PaintableBox (Box<DIV>.b) [8,8 100x85] overflow: [8,8 105.5625x85]
|
||||
PaintableWithLines (BlockContainer(anonymous)) [8,8 105.5625x85]
|
||||
TextPaintable (TextNode<#text>)
|
|
@ -0,0 +1,13 @@
|
|||
<!DOCTYPE html>
|
||||
<style>
|
||||
.a {
|
||||
background: red;
|
||||
position: fixed;
|
||||
}
|
||||
.b {
|
||||
background: green;
|
||||
display: flex;
|
||||
max-width: 100px;
|
||||
}
|
||||
</style>
|
||||
<div class="a"><div class="b">foo bar baz lorem ipsum dolor sit amet consectetuer
|
Loading…
Add table
Reference in a new issue