summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb/CSS
diff options
context:
space:
mode:
authorSam Atkins <atkinssj@serenityos.org>2021-11-10 13:54:33 +0000
committerAndreas Kling <kling@serenityos.org>2021-11-10 21:58:14 +0100
commite52f987020be996f49c09dfdd53306366f2cbab9 (patch)
tree2efbd6939f235e00058110623d64bd3c36c0e129 /Userland/Libraries/LibWeb/CSS
parent4d4291548531e7ceaa734b0a782a891b8a85fbd4 (diff)
downloadserenity-e52f987020be996f49c09dfdd53306366f2cbab9.zip
LibWeb: Make property_initial_value() return a NonnullRefPtr
The finale! Users can now be sure that the value is valid, which makes things simpler.
Diffstat (limited to 'Userland/Libraries/LibWeb/CSS')
-rw-r--r--Userland/Libraries/LibWeb/CSS/StyleComputer.cpp14
1 files changed, 3 insertions, 11 deletions
diff --git a/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp b/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp
index e99b1108cb..c01eeca59e 100644
--- a/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp
+++ b/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp
@@ -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;
}