1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 08:08:12 +00:00

LibWeb: Remove unnecessary code from sided border shorthand expansion

I'm sure at some point we made use of `Edge::All` and this made sense,
but now it's just overly verbose.
This commit is contained in:
Sam Atkins 2023-09-20 12:30:58 +01:00 committed by Sam Atkins
parent 3a071bc4dd
commit ae9eaeffc4

View file

@ -351,19 +351,6 @@ static void sort_matching_rules(Vector<MatchingRule>& matching_rules)
});
}
enum class Edge {
Top,
Right,
Bottom,
Left,
All,
};
static bool contains(Edge a, Edge b)
{
return a == b || b == Edge::All;
}
static void set_property_expanding_shorthands(StyleProperties& style, CSS::PropertyID property_id, StyleValue const& value, DOM::Document& document, CSS::CSSStyleDeclaration const* declaration, StyleProperties::PropertyValues const& properties_for_revert)
{
auto set_longhand_property = [&](CSS::PropertyID property_id, StyleValue const& value) {
@ -572,45 +559,31 @@ static void set_property_expanding_shorthands(StyleProperties& style, CSS::Prope
|| property_id == CSS::PropertyID::BorderBottom
|| property_id == CSS::PropertyID::BorderLeft) {
Edge edge = Edge::All;
switch (property_id) {
case CSS::PropertyID::BorderTop:
edge = Edge::Top;
break;
case CSS::PropertyID::BorderRight:
edge = Edge::Right;
break;
case CSS::PropertyID::BorderBottom:
edge = Edge::Bottom;
break;
case CSS::PropertyID::BorderLeft:
edge = Edge::Left;
break;
default:
break;
}
if (value.is_border()) {
auto const& border = value.as_border();
if (contains(Edge::Top, edge)) {
if (property_id == CSS::PropertyID::BorderTop) {
set_longhand_property(PropertyID::BorderTopWidth, border.border_width());
set_longhand_property(PropertyID::BorderTopStyle, border.border_style());
set_longhand_property(PropertyID::BorderTopColor, border.border_color());
return;
}
if (contains(Edge::Right, edge)) {
if (property_id == CSS::PropertyID::BorderRight) {
set_longhand_property(PropertyID::BorderRightWidth, border.border_width());
set_longhand_property(PropertyID::BorderRightStyle, border.border_style());
set_longhand_property(PropertyID::BorderRightColor, border.border_color());
return;
}
if (contains(Edge::Bottom, edge)) {
if (property_id == CSS::PropertyID::BorderBottom) {
set_longhand_property(PropertyID::BorderBottomWidth, border.border_width());
set_longhand_property(PropertyID::BorderBottomStyle, border.border_style());
set_longhand_property(PropertyID::BorderBottomColor, border.border_color());
return;
}
if (contains(Edge::Left, edge)) {
if (property_id == CSS::PropertyID::BorderLeft) {
set_longhand_property(PropertyID::BorderLeftWidth, border.border_width());
set_longhand_property(PropertyID::BorderLeftStyle, border.border_style());
set_longhand_property(PropertyID::BorderLeftColor, border.border_color());
return;
}
return;
}