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:
parent
f354fd72f1
commit
1c829e0417
6 changed files with 163 additions and 1 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue