mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-10-15 20:49:41 +00:00
LibWeb/CSS: Implement "Create a sum value"
This commit is contained in:
parent
1c952b01ac
commit
80abffd2e8
Notes:
github-actions[bot]
2025-09-12 11:46:44 +00:00
Author: https://github.com/AtkinsSJ
Commit: 80abffd2e8
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/6162
Reviewed-by: https://github.com/gmta ✅
17 changed files with 320 additions and 1 deletions
|
@ -130,4 +130,32 @@ bool CSSMathMin::is_equal_numeric_value(GC::Ref<CSSNumericValue> other) const
|
|||
return m_values->is_equal_numeric_values(other_min->m_values);
|
||||
}
|
||||
|
||||
// https://drafts.css-houdini.org/css-typed-om-1/#create-a-sum-value
|
||||
Optional<SumValue> CSSMathMin::create_a_sum_value() const
|
||||
{
|
||||
// 1. Let args be the result of creating a sum value for each item in this’s values internal slot.
|
||||
Vector<Optional<SumValue>> args;
|
||||
args.ensure_capacity(m_values->length());
|
||||
for (auto const& value : m_values->values()) {
|
||||
args.unchecked_append(value->create_a_sum_value());
|
||||
}
|
||||
|
||||
Optional<SumValue> item_with_smallest_value = args.first();
|
||||
for (auto const& item : args) {
|
||||
// 2. If any item of args is failure, or has a length greater than one, return failure.
|
||||
if (!item.has_value() || item->size() > 1)
|
||||
return {};
|
||||
|
||||
// 3. If not all of the unit maps among the items of args are identical, return failure.
|
||||
if (item->first().unit_map != item_with_smallest_value->first().unit_map)
|
||||
return {};
|
||||
|
||||
if (item->first().value < item_with_smallest_value->first().value)
|
||||
item_with_smallest_value = item;
|
||||
}
|
||||
|
||||
// 4. Return the item of args whose sole item has the smallest value.
|
||||
return item_with_smallest_value;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue