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

LibWeb: Make property_initial_value() return a NonnullRefPtr

The finale! Users can now be sure that the value is valid, which makes
things simpler.
This commit is contained in:
Sam Atkins 2021-11-10 13:54:33 +00:00 committed by Andreas Kling
parent 4d42915485
commit e52f987020
3 changed files with 7 additions and 17 deletions

View file

@ -635,18 +635,10 @@ void StyleComputer::compute_cascaded_values(StyleProperties& style, DOM::Element
// FIXME: Transition declarations [css-transitions-1]
}
static NonnullRefPtr<StyleValue> get_initial_value(CSS::PropertyID property_id)
{
auto value = property_initial_value(property_id);
if (!value)
return InitialStyleValue::the();
return value.release_nonnull();
};
static NonnullRefPtr<StyleValue> get_inherit_value(CSS::PropertyID property_id, DOM::Element const* element)
{
if (!element || !element->parent_element() || !element->parent_element()->specified_css_values())
return get_initial_value(property_id);
return property_initial_value(property_id);
auto& map = element->parent_element()->specified_css_values()->properties();
auto it = map.find(property_id);
VERIFY(it != map.end());
@ -662,12 +654,12 @@ void StyleComputer::compute_defaulted_property_value(StyleProperties& style, DOM
if (is_inherited_property(property_id))
style.m_property_values.set(property_id, get_inherit_value(property_id, element));
else
style.m_property_values.set(property_id, get_initial_value(property_id));
style.m_property_values.set(property_id, property_initial_value(property_id));
return;
}
if (it->value->is_initial()) {
it->value = get_initial_value(property_id);
it->value = property_initial_value(property_id);
return;
}