mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 23:50:19 +00:00
LibWeb: Use property_accepts_value() for list style parsing
This commit is contained in:
parent
dcf70ab821
commit
b08094bccc
Notes:
sideshowbarker
2024-07-18 03:32:11 +09:00
Author: https://github.com/AtkinsSJ Commit: https://github.com/SerenityOS/serenity/commit/b08094bcccb Pull-request: https://github.com/SerenityOS/serenity/pull/10188
1 changed files with 3 additions and 43 deletions
|
@ -2348,46 +2348,6 @@ RefPtr<StyleValue> Parser::parse_font_family_value(ParsingContext const& context
|
|||
|
||||
RefPtr<StyleValue> Parser::parse_list_style_value(ParsingContext const& context, Vector<StyleComponentValueRule> const& component_values)
|
||||
{
|
||||
auto is_list_style_image = [](StyleValue const& value) -> bool {
|
||||
if (value.is_image())
|
||||
return true;
|
||||
if (value.is_identifier() && value.to_identifier() == ValueID::None)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
auto is_list_style_position = [](StyleValue const& value) -> bool {
|
||||
switch (value.to_identifier()) {
|
||||
case ValueID::Inside:
|
||||
case ValueID::Outside:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
auto is_list_style_type = [](StyleValue const& value) -> bool {
|
||||
// FIXME: Handle strings and symbols("...") syntax
|
||||
switch (value.to_identifier()) {
|
||||
case CSS::ValueID::None:
|
||||
case CSS::ValueID::Disc:
|
||||
case CSS::ValueID::Circle:
|
||||
case CSS::ValueID::Square:
|
||||
case CSS::ValueID::Decimal:
|
||||
case CSS::ValueID::DecimalLeadingZero:
|
||||
case CSS::ValueID::LowerAlpha:
|
||||
case CSS::ValueID::LowerLatin:
|
||||
case CSS::ValueID::UpperAlpha:
|
||||
case CSS::ValueID::UpperLatin:
|
||||
case CSS::ValueID::UpperRoman:
|
||||
case CSS::ValueID::LowerRoman:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
if (component_values.size() > 3)
|
||||
return nullptr;
|
||||
|
||||
|
@ -2406,19 +2366,19 @@ RefPtr<StyleValue> Parser::parse_list_style_value(ParsingContext const& context,
|
|||
continue;
|
||||
}
|
||||
|
||||
if (is_list_style_position(*value)) {
|
||||
if (property_accepts_value(PropertyID::ListStylePosition, *value)) {
|
||||
if (list_position)
|
||||
return nullptr;
|
||||
list_position = value.release_nonnull();
|
||||
continue;
|
||||
}
|
||||
if (is_list_style_image(*value)) {
|
||||
if (property_accepts_value(PropertyID::ListStyleImage, *value)) {
|
||||
if (list_image)
|
||||
return nullptr;
|
||||
list_image = value.release_nonnull();
|
||||
continue;
|
||||
}
|
||||
if (is_list_style_type(*value)) {
|
||||
if (property_accepts_value(PropertyID::ListStyleType, *value)) {
|
||||
if (list_type)
|
||||
return nullptr;
|
||||
list_type = value.release_nonnull();
|
||||
|
|
Loading…
Reference in a new issue