mirror of
https://github.com/RGBCube/serenity
synced 2025-06-01 03:08:13 +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:
parent
4d42915485
commit
e52f987020
3 changed files with 7 additions and 17 deletions
|
@ -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)
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue