mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-27 18:17:22 +02:00
LibWeb: Scale font size by 1.15 for line-height: normal
Browsers such as Chrome and Firefox apply an arbitrary scale to the current font size if `normal` is used for `line-height`. Firefox uses 1.2 while Chrome uses 1.15. Let's go with the latter for now, it's relatively easy to change if we ever want to go back on that decision. This also requires updating the expectations for a lot of layout tests. The upside of this is that it's a bit easier to compare our layout results to other browsers', especially Chrome.
This commit is contained in:
committed by
Andreas Kling
parent
01791c5a52
commit
71665fa504
Notes:
github-actions[bot]
2025-05-05 11:16:57 +00:00
Author: https://github.com/gmta Commit: https://github.com/LadybirdBrowser/ladybird/commit/71665fa504f Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4551 Reviewed-by: https://github.com/rmg-x
@@ -145,13 +145,15 @@ void HTMLInputElement::adjust_computed_style(CSS::ComputedProperties& style)
|
||||
style.set_property(CSS::PropertyID::Width, CSS::LengthStyleValue::create(CSS::Length(size(), CSS::Length::Type::Ch)));
|
||||
}
|
||||
|
||||
// NOTE: The following line-height check is done for web compatibility and usability reasons.
|
||||
// FIXME: The "normal" line-height value should be calculated but assume 1.0 for now.
|
||||
double normal_line_height = 1.0;
|
||||
double current_line_height = style.line_height().to_double();
|
||||
// NOTE: Other browsers apply a minimum height of a single line's line-height to single-line input elements.
|
||||
if (is_single_line() && style.property(CSS::PropertyID::Height).has_auto()) {
|
||||
auto current_line_height = style.line_height().to_double();
|
||||
auto minimum_line_height = style.first_available_computed_font().pixel_size() * CSS::ComputedProperties::normal_line_height_scale;
|
||||
|
||||
if (is_single_line() && current_line_height < normal_line_height)
|
||||
style.set_property(CSS::PropertyID::LineHeight, CSS::CSSKeywordValue::create(CSS::Keyword::Normal));
|
||||
// FIXME: Instead of overriding line-height, we should set height here instead.
|
||||
if (current_line_height < minimum_line_height)
|
||||
style.set_property(CSS::PropertyID::LineHeight, CSS::CSSKeywordValue::create(CSS::Keyword::Normal));
|
||||
}
|
||||
}
|
||||
|
||||
void HTMLInputElement::set_checked(bool checked)
|
||||
|
||||
Reference in New Issue
Block a user