mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-23 09:48:56 +00:00
LibWeb/CSS: Implement product_of_two_unit_maps()
Helper function for combining two UnitMaps.
This commit is contained in:
parent
e6e380b109
commit
5a42b7a40f
Notes:
github-actions[bot]
2025-09-12 11:47:03 +00:00
Author: https://github.com/AtkinsSJ
Commit: 5a42b7a40f
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/6162
Reviewed-by: https://github.com/gmta ✅
2 changed files with 18 additions and 0 deletions
|
@ -16,6 +16,23 @@
|
|||
|
||||
namespace Web::CSS {
|
||||
|
||||
// https://drafts.css-houdini.org/css-typed-om-1/#product-of-two-unit-maps
|
||||
UnitMap product_of_two_unit_maps(UnitMap const& units1, UnitMap const& units2)
|
||||
{
|
||||
// 1. Let result be a copy of units1.
|
||||
auto result = units1;
|
||||
|
||||
// 2. For each unit → power in units2:
|
||||
for (auto const& [unit, power] : units2) {
|
||||
// 1. If result[unit] exists, increment result[unit] by power.
|
||||
// 2. Otherwise, set result[unit] to power.
|
||||
result.ensure(unit) += power;
|
||||
}
|
||||
|
||||
// 3. Return result.
|
||||
return result;
|
||||
}
|
||||
|
||||
Optional<NumericType::BaseType> NumericType::base_type_from_value_type(ValueType value_type)
|
||||
{
|
||||
switch (value_type) {
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
namespace Web::CSS {
|
||||
|
||||
using UnitMap = HashMap<FlyString, i32>;
|
||||
UnitMap product_of_two_unit_maps(UnitMap const&, UnitMap const&);
|
||||
|
||||
// https://drafts.css-houdini.org/css-typed-om-1/#cssnumericvalue-type
|
||||
class NumericType {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue