diff options
author | Sam Atkins <atkinssj@serenityos.org> | 2021-11-10 13:54:33 +0000 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-11-10 21:58:14 +0100 |
commit | e52f987020be996f49c09dfdd53306366f2cbab9 (patch) | |
tree | 2efbd6939f235e00058110623d64bd3c36c0e129 /Meta/Lagom | |
parent | 4d4291548531e7ceaa734b0a782a891b8a85fbd4 (diff) | |
download | serenity-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 'Meta/Lagom')
-rw-r--r-- | Meta/Lagom/Tools/CodeGenerators/LibWeb/Generate_CSS_PropertyID_cpp.cpp | 7 | ||||
-rw-r--r-- | Meta/Lagom/Tools/CodeGenerators/LibWeb/Generate_CSS_PropertyID_h.cpp | 3 |
2 files changed, 4 insertions, 6 deletions
diff --git a/Meta/Lagom/Tools/CodeGenerators/LibWeb/Generate_CSS_PropertyID_cpp.cpp b/Meta/Lagom/Tools/CodeGenerators/LibWeb/Generate_CSS_PropertyID_cpp.cpp index 24c7ea9b94..7c4e524dab 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibWeb/Generate_CSS_PropertyID_cpp.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/LibWeb/Generate_CSS_PropertyID_cpp.cpp @@ -169,7 +169,7 @@ bool is_inherited_property(PropertyID property_id) } } -RefPtr<StyleValue> property_initial_value(PropertyID property_id) +NonnullRefPtr<StyleValue> property_initial_value(PropertyID property_id) { static HashMap<PropertyID, NonnullRefPtr<StyleValue>> initial_values; if (initial_values.is_empty()) { @@ -219,10 +219,7 @@ RefPtr<StyleValue> property_initial_value(PropertyID property_id) generator.append(R"~~~( } - auto it = initial_values.find(property_id); - if (it == initial_values.end()) - return nullptr; - return it->value; + return *initial_values.find(property_id)->value; } bool property_has_quirk(PropertyID property_id, Quirk quirk) diff --git a/Meta/Lagom/Tools/CodeGenerators/LibWeb/Generate_CSS_PropertyID_h.cpp b/Meta/Lagom/Tools/CodeGenerators/LibWeb/Generate_CSS_PropertyID_h.cpp index 8fb24c945c..6ded891fe5 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibWeb/Generate_CSS_PropertyID_h.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/LibWeb/Generate_CSS_PropertyID_h.cpp @@ -45,6 +45,7 @@ int main(int argc, char** argv) generator.append(R"~~~( #pragma once +#include <AK/NonnullRefPtr.h> #include <AK/StringView.h> #include <AK/Traits.h> #include <LibWeb/Forward.h> @@ -104,7 +105,7 @@ PropertyID property_id_from_camel_case_string(StringView); PropertyID property_id_from_string(const StringView&); const char* string_from_property_id(PropertyID); bool is_inherited_property(PropertyID); -RefPtr<StyleValue> property_initial_value(PropertyID); +NonnullRefPtr<StyleValue> property_initial_value(PropertyID); bool property_accepts_value(PropertyID, StyleValue&); size_t property_maximum_value_count(PropertyID); |