1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 11:07:45 +00:00

LibWeb: Implement MediaQuery matching :^)

Currently, `evaluate()` recalculates whether the MediaQuery matches or
not, and stores it in `m_matches`, which users can query using
`matches()`. This allows us to know when the match-state changes, which
is required to fire MediaQueryList's change event.
This commit is contained in:
Sam Atkins 2021-10-03 19:39:48 +01:00 committed by Andreas Kling
parent f354fd72f1
commit 1c829e0417
6 changed files with 163 additions and 1 deletions

View file

@ -67,4 +67,21 @@ void MediaList::delete_medium(String medium)
// FIXME: If nothing was removed, then throw a NotFoundError exception.
}
bool MediaList::evaluate(DOM::Window const& window)
{
for (auto& media : m_media)
media.evaluate(window);
return matches();
}
bool MediaList::matches() const
{
for (auto& media : m_media) {
if (media.matches())
return true;
}
return false;
}
}