diff --git a/Libraries/LibWeb/CSS/CSSStyleProperties.cpp b/Libraries/LibWeb/CSS/CSSStyleProperties.cpp index 893e1707f15..8560ac6a5cd 100644 --- a/Libraries/LibWeb/CSS/CSSStyleProperties.cpp +++ b/Libraries/LibWeb/CSS/CSSStyleProperties.cpp @@ -128,7 +128,7 @@ size_t CSSStyleProperties::length() const if (is_computed()) { if (!owner_node().has_value()) return 0; - return to_underlying(last_longhand_property_id) - to_underlying(first_longhand_property_id) + 1; + return number_of_longhand_properties; } return m_properties.size(); diff --git a/Libraries/LibWeb/CSS/StyleComputer.cpp b/Libraries/LibWeb/CSS/StyleComputer.cpp index d9c1843fa6f..5f6ece5d9bd 100644 --- a/Libraries/LibWeb/CSS/StyleComputer.cpp +++ b/Libraries/LibWeb/CSS/StyleComputer.cpp @@ -1058,7 +1058,7 @@ void StyleComputer::collect_animation_into(DOM::Element& element, Optional> result; HashMap longhands_set_by_property_id; - auto property_is_set_by_use_initial = MUST(Bitmap::create(to_underlying(last_longhand_property_id) - to_underlying(first_longhand_property_id) + 1, false)); + auto property_is_set_by_use_initial = MUST(Bitmap::create(number_of_longhand_properties, false)); auto property_is_logical_alias_including_shorthands = [&](PropertyID property_id) { if (property_is_shorthand(property_id)) diff --git a/Libraries/LibWeb/CSS/StylePropertyMapReadOnly.cpp b/Libraries/LibWeb/CSS/StylePropertyMapReadOnly.cpp index fde55c0322f..e09ca6bb4f3 100644 --- a/Libraries/LibWeb/CSS/StylePropertyMapReadOnly.cpp +++ b/Libraries/LibWeb/CSS/StylePropertyMapReadOnly.cpp @@ -150,7 +150,6 @@ WebIDL::UnsignedLong StylePropertyMapReadOnly::size() const // value on this" // Ensure style is computed on the element before we try to read it. element.document().update_style(); - auto longhands_count = to_underlying(last_longhand_property_id) - to_underlying(first_longhand_property_id) + 1; // Some custom properties set on the element might also be in the registered custom properties set, so we // want the size of the union of the two sets. @@ -160,7 +159,7 @@ WebIDL::UnsignedLong StylePropertyMapReadOnly::size() const for (auto const& [key, _] : element.document().registered_custom_properties()) custom_properties.set(key); - return longhands_count + custom_properties.size(); + return number_of_longhand_properties + custom_properties.size(); }, [](GC::Ref const& declaration) { return declaration->length(); }); } diff --git a/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateCSSPropertyID.cpp b/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateCSSPropertyID.cpp index 405c39e7c81..b607efe9f8b 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateCSSPropertyID.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateCSSPropertyID.cpp @@ -300,6 +300,7 @@ constexpr PropertyID first_inherited_longhand_property_id = PropertyID::@first_i constexpr PropertyID last_inherited_longhand_property_id = PropertyID::@last_inherited_longhand_property_id@; constexpr PropertyID first_longhand_property_id = PropertyID::@first_longhand_property_id@; constexpr PropertyID last_longhand_property_id = PropertyID::@last_longhand_property_id@; +constexpr size_t number_of_longhand_properties = to_underlying(last_longhand_property_id) - to_underlying(first_longhand_property_id) + 1; enum class Quirk { // https://quirks.spec.whatwg.org/#the-hashless-hex-color-quirk