Don't re-evaluate viewport dependent media queries if the viewport doesn't change
https://bugs.webkit.org/show_bug.cgi?id=231949
rdar://77240171
Reviewed by Alan Bujtas.
Source/WebCore:
If there are many viewport dependent rules (some pages have thousands) re-evaluating can take a while.
It is currently done unconditionally before layout.
* css/MediaQueryEvaluator.cpp:
(WebCore::mediaQueryViewportStateForDocument):
* css/MediaQueryEvaluator.h:
* style/StyleScope.cpp:
(WebCore::Style::Scope::evaluateMediaQueriesForViewportChange):
Save the viewport state so we can test if anything that affects media query results has changed since the last time.
* style/StyleScope.h:
Source/WebKit:
* WebProcess/cocoa/WebProcessCocoa.mm:
(WebKit::WebProcess::handlePreferenceChange):
Remember to signal accessibility settings change on this code path too.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@284536 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/WebCore/css/MediaQueryEvaluator.h b/Source/WebCore/css/MediaQueryEvaluator.h
index 4ef175d..a1bcea5 100644
--- a/Source/WebCore/css/MediaQueryEvaluator.h
+++ b/Source/WebCore/css/MediaQueryEvaluator.h
@@ -27,6 +27,7 @@
#pragma once
+#include "IntSize.h"
#include "MediaQueryExpression.h"
#include <wtf/WeakPtr.h>
@@ -55,6 +56,10 @@
bool isEmpty() const { return viewport.isEmpty() && appearance.isEmpty() && accessibilitySettings.isEmpty(); }
};
+using MediaQueryViewportState = std::tuple<IntSize, float, bool>;
+
+MediaQueryViewportState mediaQueryViewportStateForDocument(const Document&);
+
// Some of the constructors are used for cases where the device characteristics are not known.
// These can be used to prune the loading of stylesheets to only those which are not already known to not match.