mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-05 09:06:08 +00:00
LibWeb: Allow intrinsic width layout to see definite heights
We were already allowing intrinsic height layout to see definite widths, and I can't think of a reason *not* to allow it the other way around. More importantly, this fixes an issue where things with an aspect ratio didn't have a height to resolve against before. Makes the logo show up on https://basecamp.com/ :^)
This commit is contained in:
parent
4bda65c8b3
commit
077bc68a4c
Notes:
github-actions[bot]
2024-10-05 17:25:11 +00:00
Author: https://github.com/awesomekling
Commit: 077bc68a4c
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1641
3 changed files with 27 additions and 4 deletions
|
@ -0,0 +1,11 @@
|
||||||
|
Viewport <#document> at (0,0) content-size 800x600 children: not-inline
|
||||||
|
BlockContainer <html> at (0,0) content-size 800x116 [BFC] children: not-inline
|
||||||
|
Box <body> at (8,8) content-size 100x100 flex-container(row) [FFC] children: not-inline
|
||||||
|
SVGSVGBox <svg> at (8,8) content-size 100x100 flex-item [SVG] children: not-inline
|
||||||
|
SVGGeometryBox <rect> at (8,8) content-size 100x100 children: not-inline
|
||||||
|
|
||||||
|
ViewportPaintable (Viewport<#document>) [0,0 800x600]
|
||||||
|
PaintableWithLines (BlockContainer<HTML>) [0,0 800x116]
|
||||||
|
PaintableBox (Box<BODY>) [8,8 100x100]
|
||||||
|
SVGSVGPaintable (SVGSVGBox<svg>) [8,8 100x100]
|
||||||
|
SVGPathPaintable (SVGGeometryBox<rect>) [8,8 100x100]
|
|
@ -0,0 +1,8 @@
|
||||||
|
<!doctype html><style>
|
||||||
|
* { outline: 1px solid black; }
|
||||||
|
body {
|
||||||
|
display: flex;
|
||||||
|
width: max-content;
|
||||||
|
height: 100px;
|
||||||
|
}
|
||||||
|
</style><body><svg viewBox="0 0 10 10" xmlns="http://www.w3.org/2000/svg"><rect x=0 y=0 width=10 height=10 fill=green></svg>
|
|
@ -1465,7 +1465,6 @@ CSSPixels FormattingContext::calculate_min_content_width(Layout::Box const& box)
|
||||||
auto& box_state = throwaway_state.get_mutable(box);
|
auto& box_state = throwaway_state.get_mutable(box);
|
||||||
box_state.width_constraint = SizeConstraint::MinContent;
|
box_state.width_constraint = SizeConstraint::MinContent;
|
||||||
box_state.set_indefinite_content_width();
|
box_state.set_indefinite_content_width();
|
||||||
box_state.set_indefinite_content_height();
|
|
||||||
|
|
||||||
auto context = const_cast<FormattingContext*>(this)->create_independent_formatting_context_if_needed(throwaway_state, LayoutMode::IntrinsicSizing, box);
|
auto context = const_cast<FormattingContext*>(this)->create_independent_formatting_context_if_needed(throwaway_state, LayoutMode::IntrinsicSizing, box);
|
||||||
if (!context) {
|
if (!context) {
|
||||||
|
@ -1473,7 +1472,10 @@ CSSPixels FormattingContext::calculate_min_content_width(Layout::Box const& box)
|
||||||
}
|
}
|
||||||
|
|
||||||
auto available_width = AvailableSize::make_min_content();
|
auto available_width = AvailableSize::make_min_content();
|
||||||
auto available_height = AvailableSize::make_indefinite();
|
auto available_height = box_state.has_definite_height()
|
||||||
|
? AvailableSize::make_definite(box_state.content_height())
|
||||||
|
: AvailableSize::make_indefinite();
|
||||||
|
|
||||||
context->run(AvailableSpace(available_width, available_height));
|
context->run(AvailableSpace(available_width, available_height));
|
||||||
|
|
||||||
cache.min_content_width = context->automatic_content_width();
|
cache.min_content_width = context->automatic_content_width();
|
||||||
|
@ -1503,7 +1505,6 @@ CSSPixels FormattingContext::calculate_max_content_width(Layout::Box const& box)
|
||||||
auto& box_state = throwaway_state.get_mutable(box);
|
auto& box_state = throwaway_state.get_mutable(box);
|
||||||
box_state.width_constraint = SizeConstraint::MaxContent;
|
box_state.width_constraint = SizeConstraint::MaxContent;
|
||||||
box_state.set_indefinite_content_width();
|
box_state.set_indefinite_content_width();
|
||||||
box_state.set_indefinite_content_height();
|
|
||||||
|
|
||||||
auto context = const_cast<FormattingContext*>(this)->create_independent_formatting_context_if_needed(throwaway_state, LayoutMode::IntrinsicSizing, box);
|
auto context = const_cast<FormattingContext*>(this)->create_independent_formatting_context_if_needed(throwaway_state, LayoutMode::IntrinsicSizing, box);
|
||||||
if (!context) {
|
if (!context) {
|
||||||
|
@ -1511,7 +1512,10 @@ CSSPixels FormattingContext::calculate_max_content_width(Layout::Box const& box)
|
||||||
}
|
}
|
||||||
|
|
||||||
auto available_width = AvailableSize::make_max_content();
|
auto available_width = AvailableSize::make_max_content();
|
||||||
auto available_height = AvailableSize::make_indefinite();
|
auto available_height = box_state.has_definite_height()
|
||||||
|
? AvailableSize::make_definite(box_state.content_height())
|
||||||
|
: AvailableSize::make_indefinite();
|
||||||
|
|
||||||
context->run(AvailableSpace(available_width, available_height));
|
context->run(AvailableSpace(available_width, available_height));
|
||||||
|
|
||||||
cache.max_content_width = context->automatic_content_width();
|
cache.max_content_width = context->automatic_content_width();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue