diff options
author | Sam Atkins <atkinssj@serenityos.org> | 2021-10-08 20:21:46 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-10-08 23:02:57 +0200 |
commit | 5098cd22a478b7264db9226c996f7fa229fcdb60 (patch) | |
tree | 8d4421c5db6bd8778e7101c75468c9466e44f3eb /Userland/Libraries/LibWeb/DOM | |
parent | 57a25139a553d94d89f899eb93ca054301131be1 (diff) | |
download | serenity-5098cd22a478b7264db9226c996f7fa229fcdb60.zip |
LibWeb: Evaluate `@media` rules
We now evaluate the conditions of `@media` rules at the same point in
the HTML event loop as evaluation of `MediaQueryList`s. This is not
strictly to spec, but since the spec doesn't actually say when to do
this, it seems to make the most sense. In any case, it works! :^)
Diffstat (limited to 'Userland/Libraries/LibWeb/DOM')
-rw-r--r-- | Userland/Libraries/LibWeb/DOM/Document.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/Userland/Libraries/LibWeb/DOM/Document.cpp b/Userland/Libraries/LibWeb/DOM/Document.cpp index e575c64128..1e20c5b3e2 100644 --- a/Userland/Libraries/LibWeb/DOM/Document.cpp +++ b/Userland/Libraries/LibWeb/DOM/Document.cpp @@ -1156,6 +1156,11 @@ void Document::evaluate_media_queries_and_report_changes() media_query_list->dispatch_event(event); } } + + // Also not in the spec, but this is as good a place as any to evaluate @media rules! + for (auto& style_sheet : style_sheets().sheets()) { + style_sheet.evaluate_media_queries(window()); + } } } |