mirror of
https://github.com/SerenityOS/serenity
synced 2026-05-03 12:52:31 +02:00
LibWeb: Ensure normal line-height on HTMLInputElement
Previously, setting CSS `line-height: 0` on an `input` element would result in no text being displayed. Other browsers handle this by setting the minimum height to the "normal" value for single line inputs. (cherry picked from commit 629068c2a7eb02db37ffb4fe8d536306ee71e156)
This commit is contained in:
@@ -128,6 +128,14 @@ void HTMLInputElement::adjust_computed_style(CSS::StyleProperties& style)
|
||||
if (style.property(CSS::PropertyID::Width)->has_auto())
|
||||
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 compatability 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();
|
||||
|
||||
if (is_single_line() && current_line_height < normal_line_height)
|
||||
style.set_property(CSS::PropertyID::LineHeight, CSS::IdentifierStyleValue::create(CSS::ValueID::Normal));
|
||||
}
|
||||
|
||||
void HTMLInputElement::set_checked(bool checked, ChangeSource change_source)
|
||||
|
||||
Reference in New Issue
Block a user