LibWeb: Return empty Optional<StyleProperty> for shorthand properties

This is a stopgap until we implement shorthand -> longhand conversion.
This commit is contained in:
Luke Wilde 2022-10-28 15:42:18 +01:00 committed by Linus Groh
parent 377eb09492
commit 5e2b41175c
3 changed files with 13 additions and 1 deletions

View file

@ -520,9 +520,15 @@ Optional<StyleProperty> ResolvedCSSStyleDeclaration::property(PropertyID propert
if (!m_element->layout_node()) {
auto style = m_element->document().style_computer().compute_style(const_cast<DOM::Element&>(*m_element));
// FIXME: This is a stopgap until we implement shorthand -> longhand conversion.
auto value = style->maybe_null_property(property_id);
if (!value) {
dbgln("FIXME: ResolvedCSSStyleDeclaration::property(property_id=0x{:x}) No value for property ID in newly computed style case.", to_underlying(property_id));
return {};
}
return StyleProperty {
.property_id = property_id,
.value = style->property(property_id),
.value = value.release_nonnull(),
};
}

View file

@ -44,6 +44,11 @@ NonnullRefPtr<StyleValue> StyleProperties::property(CSS::PropertyID property_id)
return value.release_nonnull();
}
RefPtr<StyleValue> StyleProperties::maybe_null_property(CSS::PropertyID property_id) const
{
return m_property_values[to_underlying(property_id)];
}
CSS::Size StyleProperties::size_value(CSS::PropertyID id) const
{
auto value = property(id);

View file

@ -40,6 +40,7 @@ public:
void set_property(CSS::PropertyID, NonnullRefPtr<StyleValue> value);
NonnullRefPtr<StyleValue> property(CSS::PropertyID) const;
RefPtr<StyleValue> maybe_null_property(CSS::PropertyID) const;
CSS::Size size_value(CSS::PropertyID) const;
Length length_or_fallback(CSS::PropertyID, Length const& fallback) const;