LibWeb: Allow calling property_initial_value() without a Realm
In this situation we're only able to get initial values that have already been parsed. It's a little sketchy but doesn't seem to break anything.
This commit is contained in:
parent
671d3e8a48
commit
c405c4bcf1
Notes:
github-actions[bot]
2024-11-30 10:02:29 +00:00
Author: https://github.com/AtkinsSJ Commit: https://github.com/LadybirdBrowser/ladybird/commit/c405c4bcf14 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2638
1 changed files with 6 additions and 3 deletions
|
@ -219,7 +219,7 @@ Optional<PropertyID> property_id_from_string(StringView);
|
|||
[[nodiscard]] FlyString const& string_from_property_id(PropertyID);
|
||||
[[nodiscard]] FlyString const& camel_case_string_from_property_id(PropertyID);
|
||||
bool is_inherited_property(PropertyID);
|
||||
NonnullRefPtr<CSSStyleValue> property_initial_value(JS::Realm&, PropertyID);
|
||||
NonnullRefPtr<CSSStyleValue> property_initial_value(Optional<JS::Realm&>, PropertyID);
|
||||
|
||||
enum class ValueType {
|
||||
Angle,
|
||||
|
@ -661,17 +661,20 @@ bool property_affects_stacking_context(PropertyID property_id)
|
|||
}
|
||||
}
|
||||
|
||||
NonnullRefPtr<CSSStyleValue> property_initial_value(JS::Realm& context_realm, PropertyID property_id)
|
||||
NonnullRefPtr<CSSStyleValue> property_initial_value(Optional<JS::Realm&> context_realm, PropertyID property_id)
|
||||
{
|
||||
static Array<RefPtr<CSSStyleValue>, to_underlying(last_property_id) + 1> initial_values;
|
||||
if (auto initial_value = initial_values[to_underlying(property_id)])
|
||||
return initial_value.release_nonnull();
|
||||
|
||||
// We need a Realm to parse any new values.
|
||||
VERIFY(context_realm.has_value());
|
||||
|
||||
// Lazily parse initial values as needed.
|
||||
// This ensures the shorthands will always be able to get the initial values of their longhands.
|
||||
// This also now allows a longhand have its own longhand (like background-position-x).
|
||||
|
||||
Parser::ParsingContext parsing_context(context_realm);
|
||||
Parser::ParsingContext parsing_context(context_realm.value());
|
||||
switch (property_id) {
|
||||
)~~~");
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue