LibWeb/CSS: Add has_property() to CSSStyleDeclaration

This isn't part of the CSSOM API directly, but will be used by
StylePropertyMapReadOnly.has() to avoid doing the work to serialize a
string version of the property's value, just to throw it away again.
This commit is contained in:
Sam Atkins 2025-08-13 13:07:28 +01:00
commit 37ea9a4ce3
Notes: github-actions[bot] 2025-08-18 09:14:31 +00:00
5 changed files with 22 additions and 0 deletions

View file

@ -281,6 +281,14 @@ RefPtr<StyleValue const> CSSDescriptors::descriptor_or_initial_value(DescriptorI
return descriptor_initial_value(m_at_rule_id, descriptor_id);
}
bool CSSDescriptors::has_property(StringView property_name) const
{
auto descriptor_id = descriptor_id_from_string(m_at_rule_id, property_name);
if (!descriptor_id.has_value())
return false;
return descriptor(*descriptor_id) != nullptr;
}
bool is_shorthand(AtRuleID at_rule, DescriptorID descriptor)
{
if (at_rule == AtRuleID::Page && descriptor == DescriptorID::Margin)