mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-12-07 21:59:54 +00:00
LibWeb: Simplify handling of {text,box}-shadow
We know that shadow values are always parsed as a `KeywordStyleValue` with `Keyword::None` or a `StyleValueList`
This commit is contained in:
parent
4c4fa5c9cd
commit
0595d52be2
Notes:
github-actions[bot]
2025-12-01 10:18:46 +00:00
Author: https://github.com/Calme1709
Commit: 0595d52be2
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/6972
Reviewed-by: https://github.com/AtkinsSJ ✅
2 changed files with 14 additions and 30 deletions
|
|
@ -1381,29 +1381,21 @@ Vector<ShadowData> ComputedProperties::shadow(PropertyID property_id, Layout::No
|
|||
};
|
||||
};
|
||||
|
||||
if (value.is_value_list()) {
|
||||
auto const& value_list = value.as_value_list();
|
||||
if (value.to_keyword() == Keyword::None)
|
||||
return {};
|
||||
|
||||
Vector<ShadowData> shadow_data;
|
||||
shadow_data.ensure_capacity(value_list.size());
|
||||
for (auto const& layer_value : value_list.values()) {
|
||||
auto maybe_shadow_data = make_shadow_data(layer_value->as_shadow());
|
||||
if (!maybe_shadow_data.has_value())
|
||||
return {};
|
||||
shadow_data.append(maybe_shadow_data.release_value());
|
||||
}
|
||||
auto const& value_list = value.as_value_list();
|
||||
|
||||
return shadow_data;
|
||||
}
|
||||
|
||||
if (value.is_shadow()) {
|
||||
auto maybe_shadow_data = make_shadow_data(value.as_shadow());
|
||||
Vector<ShadowData> shadow_data;
|
||||
shadow_data.ensure_capacity(value_list.size());
|
||||
for (auto const& layer_value : value_list.values()) {
|
||||
auto maybe_shadow_data = make_shadow_data(layer_value->as_shadow());
|
||||
if (!maybe_shadow_data.has_value())
|
||||
return {};
|
||||
return { maybe_shadow_data.release_value() };
|
||||
shadow_data.append(maybe_shadow_data.release_value());
|
||||
}
|
||||
|
||||
return {};
|
||||
return shadow_data;
|
||||
}
|
||||
|
||||
Vector<ShadowData> ComputedProperties::box_shadow(Layout::Node const& layout_node) const
|
||||
|
|
|
|||
|
|
@ -1341,19 +1341,11 @@ RefPtr<StyleValue const> interpolate_box_shadow(DOM::Element& element, Calculati
|
|||
// (transparent 0 0 0 0) with a corresponding inset keyword as needed to match the longer list if
|
||||
// the shorter list is otherwise compatible with the longer one
|
||||
|
||||
static constexpr auto process_list = [](StyleValue const& value) {
|
||||
StyleValueVector shadows;
|
||||
if (value.is_value_list()) {
|
||||
for (auto const& element : value.as_value_list().values()) {
|
||||
if (element->is_shadow())
|
||||
shadows.append(element);
|
||||
}
|
||||
} else if (value.is_shadow()) {
|
||||
shadows.append(value);
|
||||
} else if (!value.is_keyword() || value.as_keyword().keyword() != Keyword::None) {
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
return shadows;
|
||||
static constexpr auto process_list = [](StyleValue const& value) -> StyleValueVector {
|
||||
if (value.to_keyword() == Keyword::None)
|
||||
return {};
|
||||
|
||||
return value.as_value_list().values();
|
||||
};
|
||||
|
||||
static constexpr auto extend_list_if_necessary = [](StyleValueVector& values, StyleValueVector const& other) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue