mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-11 01:06:01 +03:00
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:
parent
160f434769
commit
3296fd70b3
Notes:
sideshowbarker
2024-07-18 05:18:19 +09:00
Author: https://github.com/AtkinsSJ Commit: https://github.com/SerenityOS/serenity/commit/3296fd70b31 Pull-request: https://github.com/SerenityOS/serenity/pull/9547 Reviewed-by: https://github.com/alimpfard ✅
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user