LibWeb: Resolve 3-part and 4-part border-width values

This commit is contained in:
Timothy Flynn 2021-05-17 15:02:14 -04:00 committed by Andreas Kling
parent b160a15682
commit 984a39f7c0
Notes: sideshowbarker 2024-07-18 17:54:59 +09:00

View file

@ -389,7 +389,28 @@ static void set_property_expanding_shorthands(StyleProperties& style, CSS::Prope
if (property_id == CSS::PropertyID::BorderWidth) {
auto parts = split_on_whitespace(value.to_string());
if (value.is_string() && parts.size() == 2) {
if (value.is_string() && parts.size() == 4) {
auto top_border_width = parse_css_value(context, parts[0]);
auto right_border_width = parse_css_value(context, parts[1]);
auto bottom_border_width = parse_css_value(context, parts[2]);
auto left_border_width = parse_css_value(context, parts[3]);
if (top_border_width && right_border_width && bottom_border_width && left_border_width) {
style.set_property(CSS::PropertyID::BorderTopWidth, *top_border_width);
style.set_property(CSS::PropertyID::BorderRightWidth, *right_border_width);
style.set_property(CSS::PropertyID::BorderBottomWidth, *bottom_border_width);
style.set_property(CSS::PropertyID::BorderLeftWidth, *left_border_width);
}
} else if (value.is_string() && parts.size() == 3) {
auto top_border_width = parse_css_value(context, parts[0]);
auto horizontal_border_width = parse_css_value(context, parts[1]);
auto bottom_border_width = parse_css_value(context, parts[2]);
if (top_border_width && horizontal_border_width && bottom_border_width) {
style.set_property(CSS::PropertyID::BorderTopWidth, *top_border_width);
style.set_property(CSS::PropertyID::BorderRightWidth, *horizontal_border_width);
style.set_property(CSS::PropertyID::BorderBottomWidth, *bottom_border_width);
style.set_property(CSS::PropertyID::BorderLeftWidth, *horizontal_border_width);
}
} else if (value.is_string() && parts.size() == 2) {
auto vertical_border_width = parse_css_value(context, parts[0]);
auto horizontal_border_width = parse_css_value(context, parts[1]);
if (vertical_border_width && horizontal_border_width) {