LibWeb: Intercept CSS initial/inherit values in StyleProperties

When property() previously would have returned an InitialStyleValue, we
now look up what the initial value would be, and return that instead.

We also intercep 'inherit', but inheritance is not implemented yet so we
just return nothing.

This does cause a regression on Acid2: The eyes no longer appear, and I
am not sure why. :^(
This commit is contained in:
Sam Atkins 2021-08-20 12:48:17 +01:00 committed by Andreas Kling
parent 160f434769
commit 3296fd70b3
Notes: sideshowbarker 2024-07-18 05:18:19 +09:00

View File

@ -45,10 +45,34 @@ void StyleProperties::set_property(CSS::PropertyID id, const StringView& value)
Optional<NonnullRefPtr<StyleValue>> StyleProperties::property(CSS::PropertyID id) const
{
auto it = m_property_values.find((unsigned)id);
if (it == m_property_values.end())
auto fetch_initial = [](CSS::PropertyID id) -> Optional<NonnullRefPtr<StyleValue>> {
auto initial_value = property_initial_value(id);
if (initial_value)
return initial_value.release_nonnull();
return {};
return it->value;
};
auto fetch_inherited = [](CSS::PropertyID) -> Optional<NonnullRefPtr<StyleValue>> {
// FIXME: Implement inheritance
return {};
};
auto it = m_property_values.find((unsigned)id);
if (it == m_property_values.end()) {
if (is_inherited_property(id)) {
return fetch_inherited(id);
} else {
// FIXME: This causes the Acid2 eyes to disappear for some reason
return fetch_initial(id);
}
}
auto& value = it->value;
if (value->is_initial())
return fetch_initial(id);
if (value->is_inherit())
return fetch_inherited(id);
return value;
}
Length StyleProperties::length_or_fallback(CSS::PropertyID id, const Length& fallback) const