mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-10-17 05:29:56 +00:00
LibWeb/CSS: Remove the "Auto" type from Length
This has always been a bit of a hack. Initially it made sense as a lot of properties that accept a length also accept `auto`, but while convenient, that leads to problems: It's easy to forget to check if a length is `auto`, and places that don't accept it end up with an invalid state lurking in the type system, which makes things unclear.
This commit is contained in:
parent
f74a40fdcb
commit
930ee495e7
Notes:
github-actions[bot]
2025-09-04 12:32:29 +00:00
Author: https://github.com/AtkinsSJ
Commit: 930ee495e7
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/6043
10 changed files with 8 additions and 66 deletions
|
@ -209,12 +209,8 @@ Size ComputedProperties::size_value(PropertyID id) const
|
|||
if (value.is_percentage())
|
||||
return Size::make_percentage(value.as_percentage().percentage());
|
||||
|
||||
if (value.is_length()) {
|
||||
auto length = value.as_length().length();
|
||||
if (length.is_auto())
|
||||
return Size::make_auto();
|
||||
return Size::make_length(length);
|
||||
}
|
||||
if (value.is_length())
|
||||
return Size::make_length(value.as_length().length());
|
||||
|
||||
// FIXME: Support `anchor-size(..)`
|
||||
if (value.is_anchor_size())
|
||||
|
@ -378,11 +374,8 @@ CSSPixels ComputedProperties::compute_line_height(CSSPixelRect const& viewport_r
|
|||
if (line_height.is_keyword() && line_height.to_keyword() == Keyword::Normal)
|
||||
return CSSPixels { round_to<i32>(font_metrics.font_size * normal_line_height_scale) };
|
||||
|
||||
if (line_height.is_length()) {
|
||||
auto line_height_length = line_height.as_length().length();
|
||||
if (!line_height_length.is_auto())
|
||||
return line_height_length.to_px(viewport_rect, font_metrics, root_font_metrics);
|
||||
}
|
||||
if (line_height.is_length())
|
||||
return line_height.as_length().length().to_px(viewport_rect, font_metrics, root_font_metrics);
|
||||
|
||||
if (line_height.is_number())
|
||||
return Length(line_height.as_number().number(), Length::Type::Em).to_px(viewport_rect, font_metrics, root_font_metrics);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue