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

LibWeb: Deduplicate "ident is color" check

Reuse the check from IdentifierStyleValue in the CSS Parser, instead of
duplicating it. This might not be the ideal place to put it, but it
works for now.
This commit is contained in:
Sam Atkins 2023-08-23 15:40:17 +01:00 committed by Sam Atkins
parent da8692572a
commit 1dcd63be05
3 changed files with 11 additions and 65 deletions

View file

@ -19,9 +19,9 @@ String IdentifierStyleValue::to_string() const
return MUST(String::from_utf8(CSS::string_from_value_id(m_id)));
}
bool IdentifierStyleValue::has_color() const
bool IdentifierStyleValue::is_color(ValueID value_id)
{
switch (m_id) {
switch (value_id) {
case ValueID::Currentcolor:
case ValueID::LibwebLink:
case ValueID::LibwebPaletteActiveLink:
@ -84,6 +84,11 @@ bool IdentifierStyleValue::has_color() const
}
}
bool IdentifierStyleValue::has_color() const
{
return is_color(m_id);
}
Color IdentifierStyleValue::to_color(Optional<Layout::NodeWithStyle const&> node) const
{
if (id() == CSS::ValueID::Currentcolor) {