mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 09:47:35 +00:00
LibWeb: Remove type checking from set_property_expanding_shorthands()
Now that the Parser checks that StyleValues are valid, we don't need to do the checks here, since any value here is guaranteed to be acceptable.
This commit is contained in:
parent
f574f538d2
commit
e0a727bc76
1 changed files with 64 additions and 95 deletions
|
@ -158,14 +158,12 @@ static void set_property_expanding_shorthands(StyleProperties& style, CSS::Prope
|
|||
style.set_property(CSS::PropertyID::TextDecorationColor, text_decoration.color());
|
||||
return;
|
||||
}
|
||||
if (value.is_builtin()) {
|
||||
|
||||
style.set_property(CSS::PropertyID::TextDecorationLine, value);
|
||||
style.set_property(CSS::PropertyID::TextDecorationStyle, value);
|
||||
style.set_property(CSS::PropertyID::TextDecorationColor, value);
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (property_id == CSS::PropertyID::Overflow) {
|
||||
if (value.is_overflow()) {
|
||||
|
@ -174,13 +172,11 @@ static void set_property_expanding_shorthands(StyleProperties& style, CSS::Prope
|
|||
style.set_property(CSS::PropertyID::OverflowY, overflow.overflow_y());
|
||||
return;
|
||||
}
|
||||
if (value.is_builtin()) {
|
||||
|
||||
style.set_property(CSS::PropertyID::OverflowX, value);
|
||||
style.set_property(CSS::PropertyID::OverflowY, value);
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (property_id == CSS::PropertyID::Border) {
|
||||
set_property_expanding_shorthands(style, CSS::PropertyID::BorderTop, value, document);
|
||||
|
@ -197,15 +193,13 @@ static void set_property_expanding_shorthands(StyleProperties& style, CSS::Prope
|
|||
assign_edge_values(PropertyID::BorderTopLeftRadius, PropertyID::BorderTopRightRadius, PropertyID::BorderBottomRightRadius, PropertyID::BorderBottomLeftRadius, values_list.values());
|
||||
return;
|
||||
}
|
||||
if (value.is_builtin()) {
|
||||
|
||||
style.set_property(CSS::PropertyID::BorderTopLeftRadius, value);
|
||||
style.set_property(CSS::PropertyID::BorderTopRightRadius, value);
|
||||
style.set_property(CSS::PropertyID::BorderBottomRightRadius, value);
|
||||
style.set_property(CSS::PropertyID::BorderBottomLeftRadius, value);
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (property_id == CSS::PropertyID::BorderTop
|
||||
|| property_id == CSS::PropertyID::BorderRight
|
||||
|
@ -263,15 +257,13 @@ static void set_property_expanding_shorthands(StyleProperties& style, CSS::Prope
|
|||
assign_edge_values(PropertyID::BorderTopStyle, PropertyID::BorderRightStyle, PropertyID::BorderBottomStyle, PropertyID::BorderLeftStyle, values_list.values());
|
||||
return;
|
||||
}
|
||||
if (value.is_builtin() || value.is_custom_property() || value.is_identifier()) {
|
||||
|
||||
style.set_property(CSS::PropertyID::BorderTopStyle, value);
|
||||
style.set_property(CSS::PropertyID::BorderRightStyle, value);
|
||||
style.set_property(CSS::PropertyID::BorderBottomStyle, value);
|
||||
style.set_property(CSS::PropertyID::BorderLeftStyle, value);
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (property_id == CSS::PropertyID::BorderWidth) {
|
||||
if (value.is_value_list()) {
|
||||
|
@ -279,15 +271,13 @@ static void set_property_expanding_shorthands(StyleProperties& style, CSS::Prope
|
|||
assign_edge_values(PropertyID::BorderTopWidth, PropertyID::BorderRightWidth, PropertyID::BorderBottomWidth, PropertyID::BorderLeftWidth, values_list.values());
|
||||
return;
|
||||
}
|
||||
if (value.is_builtin() || value.is_custom_property() || value.is_length()) {
|
||||
|
||||
style.set_property(CSS::PropertyID::BorderTopWidth, value);
|
||||
style.set_property(CSS::PropertyID::BorderRightWidth, value);
|
||||
style.set_property(CSS::PropertyID::BorderBottomWidth, value);
|
||||
style.set_property(CSS::PropertyID::BorderLeftWidth, value);
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (property_id == CSS::PropertyID::BorderColor) {
|
||||
if (value.is_value_list()) {
|
||||
|
@ -295,15 +285,13 @@ static void set_property_expanding_shorthands(StyleProperties& style, CSS::Prope
|
|||
assign_edge_values(PropertyID::BorderTopColor, PropertyID::BorderRightColor, PropertyID::BorderBottomColor, PropertyID::BorderLeftColor, values_list.values());
|
||||
return;
|
||||
}
|
||||
if (value.is_builtin() || value.is_custom_property() || value.is_color()) {
|
||||
|
||||
style.set_property(CSS::PropertyID::BorderTopColor, value);
|
||||
style.set_property(CSS::PropertyID::BorderRightColor, value);
|
||||
style.set_property(CSS::PropertyID::BorderBottomColor, value);
|
||||
style.set_property(CSS::PropertyID::BorderLeftColor, value);
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (property_id == CSS::PropertyID::Background) {
|
||||
auto set_single_background = [&](CSS::BackgroundStyleValue const& background) {
|
||||
|
@ -328,7 +316,7 @@ static void set_property_expanding_shorthands(StyleProperties& style, CSS::Prope
|
|||
}
|
||||
return;
|
||||
}
|
||||
if (value.is_builtin()) {
|
||||
|
||||
set_property_expanding_shorthands(style, CSS::PropertyID::BackgroundColor, value, document);
|
||||
set_property_expanding_shorthands(style, CSS::PropertyID::BackgroundImage, value, document);
|
||||
set_property_expanding_shorthands(style, CSS::PropertyID::BackgroundRepeatX, value, document, true);
|
||||
|
@ -336,9 +324,6 @@ static void set_property_expanding_shorthands(StyleProperties& style, CSS::Prope
|
|||
return;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (property_id == CSS::PropertyID::BackgroundImage) {
|
||||
if (value.is_value_list()) {
|
||||
auto& background_image_list = static_cast<CSS::StyleValueList const&>(value).values();
|
||||
|
@ -349,12 +334,10 @@ static void set_property_expanding_shorthands(StyleProperties& style, CSS::Prope
|
|||
}
|
||||
return;
|
||||
}
|
||||
if (value.is_builtin() || value.is_image() || value.to_identifier() == ValueID::None) {
|
||||
|
||||
style.set_property(CSS::PropertyID::BackgroundImage, value);
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (property_id == CSS::PropertyID::BackgroundRepeat) {
|
||||
if (value.is_value_list()) {
|
||||
|
@ -376,13 +359,11 @@ static void set_property_expanding_shorthands(StyleProperties& style, CSS::Prope
|
|||
set_property_expanding_shorthands(style, PropertyID::BackgroundRepeatY, background_repeat.repeat_y(), document, true);
|
||||
return;
|
||||
}
|
||||
if (value.is_builtin()) {
|
||||
|
||||
set_property_expanding_shorthands(style, PropertyID::BackgroundRepeatX, value, document, true);
|
||||
set_property_expanding_shorthands(style, PropertyID::BackgroundRepeatY, value, document, true);
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (property_id == CSS::PropertyID::BackgroundRepeatX || property_id == CSS::PropertyID::BackgroundRepeatY) {
|
||||
auto value_id = value.to_identifier();
|
||||
|
@ -399,15 +380,13 @@ static void set_property_expanding_shorthands(StyleProperties& style, CSS::Prope
|
|||
assign_edge_values(PropertyID::MarginTop, PropertyID::MarginRight, PropertyID::MarginBottom, PropertyID::MarginLeft, values_list.values());
|
||||
return;
|
||||
}
|
||||
if (value.is_length() || value.is_builtin() || value.is_custom_property() || value.is_calculated()) {
|
||||
|
||||
style.set_property(CSS::PropertyID::MarginTop, value);
|
||||
style.set_property(CSS::PropertyID::MarginRight, value);
|
||||
style.set_property(CSS::PropertyID::MarginBottom, value);
|
||||
style.set_property(CSS::PropertyID::MarginLeft, value);
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (property_id == CSS::PropertyID::Padding) {
|
||||
if (value.is_value_list()) {
|
||||
|
@ -415,15 +394,13 @@ static void set_property_expanding_shorthands(StyleProperties& style, CSS::Prope
|
|||
assign_edge_values(PropertyID::PaddingTop, PropertyID::PaddingRight, PropertyID::PaddingBottom, PropertyID::PaddingLeft, values_list.values());
|
||||
return;
|
||||
}
|
||||
if (value.is_length() || value.is_builtin() || value.is_custom_property() || value.is_calculated()) {
|
||||
|
||||
style.set_property(CSS::PropertyID::PaddingTop, value);
|
||||
style.set_property(CSS::PropertyID::PaddingRight, value);
|
||||
style.set_property(CSS::PropertyID::PaddingBottom, value);
|
||||
style.set_property(CSS::PropertyID::PaddingLeft, value);
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (property_id == CSS::PropertyID::ListStyle) {
|
||||
if (value.is_list_style()) {
|
||||
|
@ -433,14 +410,12 @@ static void set_property_expanding_shorthands(StyleProperties& style, CSS::Prope
|
|||
style.set_property(CSS::PropertyID::ListStyleType, list_style.style_type());
|
||||
return;
|
||||
}
|
||||
if (value.is_builtin()) {
|
||||
|
||||
style.set_property(CSS::PropertyID::ListStylePosition, value);
|
||||
style.set_property(CSS::PropertyID::ListStyleImage, value);
|
||||
style.set_property(CSS::PropertyID::ListStyleType, value);
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (property_id == CSS::PropertyID::Font) {
|
||||
if (value.is_font()) {
|
||||
|
@ -453,7 +428,7 @@ static void set_property_expanding_shorthands(StyleProperties& style, CSS::Prope
|
|||
// FIXME: Implement font-stretch and font-variant
|
||||
return;
|
||||
}
|
||||
if (value.is_builtin()) {
|
||||
|
||||
style.set_property(CSS::PropertyID::FontSize, value);
|
||||
style.set_property(CSS::PropertyID::FontFamily, value);
|
||||
style.set_property(CSS::PropertyID::FontStyle, value);
|
||||
|
@ -462,8 +437,6 @@ static void set_property_expanding_shorthands(StyleProperties& style, CSS::Prope
|
|||
// FIXME: Implement font-stretch and font-variant
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (property_id == CSS::PropertyID::Flex) {
|
||||
if (value.is_flex()) {
|
||||
|
@ -473,14 +446,12 @@ static void set_property_expanding_shorthands(StyleProperties& style, CSS::Prope
|
|||
style.set_property(CSS::PropertyID::FlexBasis, flex.basis());
|
||||
return;
|
||||
}
|
||||
if (value.is_builtin()) {
|
||||
|
||||
style.set_property(CSS::PropertyID::FlexGrow, value);
|
||||
style.set_property(CSS::PropertyID::FlexShrink, value);
|
||||
style.set_property(CSS::PropertyID::FlexBasis, value);
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (property_id == CSS::PropertyID::FlexFlow) {
|
||||
if (value.is_flex_flow()) {
|
||||
|
@ -489,13 +460,11 @@ static void set_property_expanding_shorthands(StyleProperties& style, CSS::Prope
|
|||
style.set_property(CSS::PropertyID::FlexWrap, flex_flow.flex_wrap());
|
||||
return;
|
||||
}
|
||||
if (value.is_builtin()) {
|
||||
|
||||
style.set_property(CSS::PropertyID::FlexDirection, value);
|
||||
style.set_property(CSS::PropertyID::FlexWrap, value);
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
style.set_property(property_id, value);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue