LibWeb/CSS: Implement CSSNumericType.equals()
Some checks are pending
CI / macOS, arm64, Sanitizer, Clang (push) Waiting to run
CI / Linux, x86_64, Fuzzers, Clang (push) Waiting to run
CI / Linux, x86_64, Sanitizer, GNU (push) Waiting to run
CI / Linux, x86_64, Sanitizer, Clang (push) Waiting to run
Package the js repl as a binary artifact / Linux, arm64 (push) Waiting to run
Package the js repl as a binary artifact / macOS, arm64 (push) Waiting to run
Package the js repl as a binary artifact / Linux, x86_64 (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Label PRs with merge conflicts / auto-labeler (push) Waiting to run
Push notes / build (push) Waiting to run

This commit is contained in:
Sam Atkins 2025-08-22 12:53:15 +01:00 committed by Andreas Kling
commit 7be645a091
Notes: github-actions[bot] 2025-08-29 09:58:23 +00:00
22 changed files with 181 additions and 16 deletions

View file

@ -57,4 +57,26 @@ Optional<JS::Value> CSSNumericArray::item_value(size_t index) const
return {};
}
// https://drafts.css-houdini.org/css-typed-om-1/#equal-numeric-value
bool CSSNumericArray::is_equal_numeric_values(GC::Ref<CSSNumericArray> other) const
{
// NB: This is just step 3, moved here to reduce repetition.
// 3. If value1 and value2 are both CSSMathSums, CSSMathProducts, CSSMathMins, or CSSMathMaxs:
{
// 1. If value1s values and value2s values internal slots have different sizes, return false.
if (m_values.size() != other->m_values.size())
return false;
// 2. If any item in value1s values internal slot is not an equal numeric value to the item in value2s values
// internal slot at the same index, return false.
for (auto index = 0u; index < m_values.size(); ++index) {
if (!m_values[index]->is_equal_numeric_value(other->m_values[index]))
return false;
}
// 3. Return true.
return true;
}
}
}