mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-13 11:42:38 +03:00
LibWeb: Support special border width identifiers
Previously identifiers were resolved to zero length. This could be seen when a border declaration doesn't have specified width (e.g. `border: solid`), as the initial border width is 'medium'. The spec doesn't specify what the identifiers should really resolve to, but it gives us some example values and that's what I've used here. :^) Spec link: https://www.w3.org/TR/css-backgrounds-3/#border-width
This commit is contained in:
parent
ff5882291f
commit
586a7dca88
Notes:
sideshowbarker
2024-07-17 07:38:17 +09:00
Author: https://github.com/krkk Commit: https://github.com/SerenityOS/serenity/commit/586a7dca88 Pull-request: https://github.com/SerenityOS/serenity/pull/16177 Reviewed-by: https://github.com/davidot ✅
@ -543,10 +543,33 @@ void NodeWithStyle::apply_style(const CSS::StyleProperties& computed_style)
|
||||
// specified first, so it's far from ideal.
|
||||
border.color = computed_style.color_or_fallback(color_property, *this, computed_values.color());
|
||||
border.line_style = computed_style.line_style(style_property).value_or(CSS::LineStyle::None);
|
||||
if (border.line_style == CSS::LineStyle::None)
|
||||
if (border.line_style == CSS::LineStyle::None) {
|
||||
border.width = 0;
|
||||
else
|
||||
border.width = computed_style.length_or_fallback(width_property, CSS::Length::make_px(0)).to_px(*this);
|
||||
} else {
|
||||
auto resolve_border_width = [&]() {
|
||||
auto value = computed_style.property(width_property);
|
||||
if (value->is_calculated())
|
||||
return CSS::Length::make_calculated(value->as_calculated()).to_px(*this);
|
||||
if (value->has_length())
|
||||
return value->to_length().to_px(*this);
|
||||
if (value->is_identifier()) {
|
||||
// FIXME: These values should depend on something, e.g. a font size.
|
||||
switch (value->to_identifier()) {
|
||||
case CSS::ValueID::Thin:
|
||||
return 1.0f;
|
||||
case CSS::ValueID::Medium:
|
||||
return 3.0f;
|
||||
case CSS::ValueID::Thick:
|
||||
return 5.0f;
|
||||
default:
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
}
|
||||
VERIFY_NOT_REACHED();
|
||||
};
|
||||
|
||||
border.width = resolve_border_width();
|
||||
}
|
||||
};
|
||||
|
||||
do_border_style(computed_values.border_left(), CSS::PropertyID::BorderLeftWidth, CSS::PropertyID::BorderLeftColor, CSS::PropertyID::BorderLeftStyle);
|
||||
|
Loading…
Reference in New Issue
Block a user