mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-26 01:35:08 +02:00
LibWeb/CSS: Implement CSSNumericType.equals()
This commit is contained in:
committed by
Andreas Kling
parent
d29084997e
commit
7be645a091
Notes:
github-actions[bot]
2025-08-29 09:58:23 +00:00
Author: https://github.com/AtkinsSJ Commit: https://github.com/LadybirdBrowser/ladybird/commit/7be645a0913 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5955 Reviewed-by: https://github.com/trflynn89
@@ -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 value1’s 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 value1’s values internal slot is not an equal numeric value to the item in value2’s 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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user