<picture> container doesn't update when prefers-color-scheme media query changes
authortimothy@apple.com <timothy@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 6 Nov 2018 19:53:13 +0000 (19:53 +0000)
committertimothy@apple.com <timothy@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 6 Nov 2018 19:53:13 +0000 (19:53 +0000)
https://bugs.webkit.org/show_bug.cgi?id=190913
rdar://problem/45608456

Reviewed by Dean Jackson.

Source/WebCore:

Test: css-dark-mode/prefers-color-scheme-picture-element.html

* css/MediaQueryEvaluator.cpp:
(WebCore::isAppearanceDependent): Added.
(WebCore::MediaQueryEvaluator::evaluate const): Keep track of appearanceDependentResults.
* css/MediaQueryEvaluator.h:
* css/StyleResolver.cpp:
(WebCore::StyleResolver::addAppearanceDependentMediaQueryResult): Added.
(WebCore::StyleResolver::hasMediaQueriesAffectedByAppearanceChange const): Added.
* css/StyleResolver.h:
(WebCore::StyleResolver::hasAppearanceDependentMediaQueries const): Added.
* dom/Document.cpp:
(WebCore::Document::evaluateMediaQueryList): Call checkAppearanceDependentPictures.
(WebCore::Document::checkAppearanceDependentPictures): Added.
(WebCore::Document::addAppearanceDependentPicture): Added.
(WebCore::Document::removeAppearanceDependentPicture): Added.
* dom/Document.h:
* html/HTMLImageElement.cpp:
(WebCore::HTMLImageElement::bestFitSourceFromPictureElement): Call addAppearanceDependentPicture.
* html/HTMLPictureElement.cpp:
(WebCore::HTMLPictureElement::~HTMLPictureElement): Call removeAppearanceDependentPicture.
(WebCore::HTMLPictureElement::didMoveToNewDocument): Ditto.
(WebCore::HTMLPictureElement::appearanceChangeAffectedPicture const): Added.
* html/HTMLPictureElement.h:
* page/Page.cpp:
(WebCore::Page::appearanceDidChange): Added.
(WebCore::Page::setUseSystemAppearance): Call appearanceDidChange.
(WebCore::Page::setUseDarkAppearance): Call appearanceDidChange.
* page/Page.h:
* style/StyleScope.cpp:
(WebCore::Style::Scope::evaluateMediaQueriesForAppearanceChange): Added.
* style/StyleScope.h:

LayoutTests:

* css-dark-mode/prefers-color-scheme-picture-element-expected.txt: Added.
* css-dark-mode/prefers-color-scheme-picture-element.html: Added.
* platform/mac-highsierra/css-dark-mode/prefers-color-scheme-picture-element-expected.txt: Added.
* platform/mac-sierra/css-dark-mode/prefers-color-scheme-picture-element-expected.txt: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@237878 268f45cc-cd09-0410-ab3c-d52691b4dbfc

19 files changed:
LayoutTests/ChangeLog
LayoutTests/css-dark-mode/prefers-color-scheme-picture-element-expected.txt [new file with mode: 0644]
LayoutTests/css-dark-mode/prefers-color-scheme-picture-element.html [new file with mode: 0644]
LayoutTests/platform/mac-highsierra/css-dark-mode/prefers-color-scheme-picture-element-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac-sierra/css-dark-mode/prefers-color-scheme-picture-element-expected.txt [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/css/MediaQueryEvaluator.cpp
Source/WebCore/css/MediaQueryEvaluator.h
Source/WebCore/css/StyleResolver.cpp
Source/WebCore/css/StyleResolver.h
Source/WebCore/dom/Document.cpp
Source/WebCore/dom/Document.h
Source/WebCore/html/HTMLImageElement.cpp
Source/WebCore/html/HTMLPictureElement.cpp
Source/WebCore/html/HTMLPictureElement.h
Source/WebCore/page/Page.cpp
Source/WebCore/page/Page.h
Source/WebCore/style/StyleScope.cpp
Source/WebCore/style/StyleScope.h

index 4300b17..606a291 100644 (file)
@@ -1,3 +1,16 @@
+2018-11-06  Timothy Hatcher  <timothy@apple.com>
+
+        <picture> container doesn't update when prefers-color-scheme media query changes
+        https://bugs.webkit.org/show_bug.cgi?id=190913
+        rdar://problem/45608456
+
+        Reviewed by Dean Jackson.
+
+        * css-dark-mode/prefers-color-scheme-picture-element-expected.txt: Added.
+        * css-dark-mode/prefers-color-scheme-picture-element.html: Added.
+        * platform/mac-highsierra/css-dark-mode/prefers-color-scheme-picture-element-expected.txt: Added.
+        * platform/mac-sierra/css-dark-mode/prefers-color-scheme-picture-element-expected.txt: Added.
+
 2018-11-06  Alex Christensen  <achristensen@webkit.org>
 
         Fix tests after r237863
diff --git a/LayoutTests/css-dark-mode/prefers-color-scheme-picture-element-expected.txt b/LayoutTests/css-dark-mode/prefers-color-scheme-picture-element-expected.txt
new file mode 100644 (file)
index 0000000..82ba4a0
--- /dev/null
@@ -0,0 +1,6 @@
+
+PASS Picture image has the light source selected 
+PASS Dark color scheme enabled 
+PASS Picture image has the dark source selected 
+
diff --git a/LayoutTests/css-dark-mode/prefers-color-scheme-picture-element.html b/LayoutTests/css-dark-mode/prefers-color-scheme-picture-element.html
new file mode 100644 (file)
index 0000000..de2b062
--- /dev/null
@@ -0,0 +1,33 @@
+<!DOCTYPE html>
+
+<!-- webkit-test-runner [ experimental:DarkModeCSSEnabled=true ] -->
+
+<script src="../resources/testharness.js"></script>
+<script src="../resources/testharnessreport.js"></script>
+
+<picture id="test1">
+    <source srcset="dark.png" media="(prefers-color-scheme: dark)">
+    <source srcset="light.png" media="(prefers-color-scheme: light)">
+    <img src="error.png">
+</picture>
+
+<script>
+function test_picture(id, expected) {
+    assert_regexp_match(document.getElementById(id).querySelector("img").currentSrc, new RegExp(`/${expected}$`));
+}
+
+test(function() {
+    // The current image should be the light source.
+    test_picture("test1", "light.png");
+}, "Picture image has the light source selected");
+
+test(function() {
+    if (window.internals)
+        internals.settings.setUseDarkAppearance(true);
+}, "Dark color scheme enabled");
+
+test(function() {
+    // The current image should be the dark source.
+    test_picture("test1", "dark.png");
+}, "Picture image has the dark source selected");
+</script>
diff --git a/LayoutTests/platform/mac-highsierra/css-dark-mode/prefers-color-scheme-picture-element-expected.txt b/LayoutTests/platform/mac-highsierra/css-dark-mode/prefers-color-scheme-picture-element-expected.txt
new file mode 100644 (file)
index 0000000..99e6cfa
--- /dev/null
@@ -0,0 +1,6 @@
+
+FAIL Picture image has the light source selected assert_regexp_match: expected object "/\/light.png$/" but got "file:///Volumes/Data/EWS/WebKit/LayoutTests/css-dark-mode/error.png"
+PASS Dark color scheme enabled 
+FAIL Picture image has the dark source selected assert_regexp_match: expected object "/\/dark.png$/" but got "file:///Volumes/Data/EWS/WebKit/LayoutTests/css-dark-mode/error.png"
+
diff --git a/LayoutTests/platform/mac-sierra/css-dark-mode/prefers-color-scheme-picture-element-expected.txt b/LayoutTests/platform/mac-sierra/css-dark-mode/prefers-color-scheme-picture-element-expected.txt
new file mode 100644 (file)
index 0000000..99e6cfa
--- /dev/null
@@ -0,0 +1,6 @@
+
+FAIL Picture image has the light source selected assert_regexp_match: expected object "/\/light.png$/" but got "file:///Volumes/Data/EWS/WebKit/LayoutTests/css-dark-mode/error.png"
+PASS Dark color scheme enabled 
+FAIL Picture image has the dark source selected assert_regexp_match: expected object "/\/dark.png$/" but got "file:///Volumes/Data/EWS/WebKit/LayoutTests/css-dark-mode/error.png"
+
index b20e767..460cfd2 100644 (file)
@@ -1,3 +1,44 @@
+2018-11-06  Timothy Hatcher  <timothy@apple.com>
+
+        <picture> container doesn't update when prefers-color-scheme media query changes
+        https://bugs.webkit.org/show_bug.cgi?id=190913
+        rdar://problem/45608456
+
+        Reviewed by Dean Jackson.
+
+        Test: css-dark-mode/prefers-color-scheme-picture-element.html
+
+        * css/MediaQueryEvaluator.cpp:
+        (WebCore::isAppearanceDependent): Added.
+        (WebCore::MediaQueryEvaluator::evaluate const): Keep track of appearanceDependentResults.
+        * css/MediaQueryEvaluator.h:
+        * css/StyleResolver.cpp:
+        (WebCore::StyleResolver::addAppearanceDependentMediaQueryResult): Added.
+        (WebCore::StyleResolver::hasMediaQueriesAffectedByAppearanceChange const): Added.
+        * css/StyleResolver.h:
+        (WebCore::StyleResolver::hasAppearanceDependentMediaQueries const): Added.
+        * dom/Document.cpp:
+        (WebCore::Document::evaluateMediaQueryList): Call checkAppearanceDependentPictures.
+        (WebCore::Document::checkAppearanceDependentPictures): Added.
+        (WebCore::Document::addAppearanceDependentPicture): Added.
+        (WebCore::Document::removeAppearanceDependentPicture): Added.
+        * dom/Document.h:
+        * html/HTMLImageElement.cpp:
+        (WebCore::HTMLImageElement::bestFitSourceFromPictureElement): Call addAppearanceDependentPicture.
+        * html/HTMLPictureElement.cpp:
+        (WebCore::HTMLPictureElement::~HTMLPictureElement): Call removeAppearanceDependentPicture.
+        (WebCore::HTMLPictureElement::didMoveToNewDocument): Ditto.
+        (WebCore::HTMLPictureElement::appearanceChangeAffectedPicture const): Added.
+        * html/HTMLPictureElement.h:
+        * page/Page.cpp:
+        (WebCore::Page::appearanceDidChange): Added.
+        (WebCore::Page::setUseSystemAppearance): Call appearanceDidChange.
+        (WebCore::Page::setUseDarkAppearance): Call appearanceDidChange.
+        * page/Page.h:
+        * style/StyleScope.cpp:
+        (WebCore::Style::Scope::evaluateMediaQueriesForAppearanceChange): Added.
+        * style/StyleScope.h:
+
 2018-11-06  Ryan Haddad  <ryanhaddad@apple.com>
 
         Unreviewed, rolling out r237834.
index 932e940..29f5046 100644 (file)
@@ -98,6 +98,15 @@ static bool isViewportDependent(const AtomicString& mediaFeature)
         || mediaFeature == MediaFeatureNames::maxAspectRatio;
 }
 
+static bool isAppearanceDependent(const AtomicString& mediaFeature)
+{
+    return mediaFeature == MediaFeatureNames::prefersDarkInterface
+#if ENABLE(DARK_MODE_CSS)
+        || mediaFeature == MediaFeatureNames::prefersColorScheme
+#endif
+    ;
+}
+
 MediaQueryEvaluator::MediaQueryEvaluator(bool mediaFeatureResult)
     : m_fallbackResult(mediaFeatureResult)
 {
@@ -165,6 +174,8 @@ bool MediaQueryEvaluator::evaluate(const MediaQuerySet& querySet, StyleResolver*
                     styleResolver->addViewportDependentMediaQueryResult(expressions[j], expressionResult);
                 if (styleResolver && isAccessibilitySettingsDependent(expressions[j].mediaFeature()))
                     styleResolver->addAccessibilitySettingsDependentMediaQueryResult(expressions[j], expressionResult);
+                if (styleResolver && isAppearanceDependent(expressions[j].mediaFeature()))
+                    styleResolver->addAppearanceDependentMediaQueryResult(expressions[j], expressionResult);
                 if (!expressionResult)
                     break;
             }
@@ -179,7 +190,7 @@ bool MediaQueryEvaluator::evaluate(const MediaQuerySet& querySet, StyleResolver*
     return result;
 }
 
-bool MediaQueryEvaluator::evaluate(const MediaQuerySet& querySet, Vector<MediaQueryResult>& results) const
+bool MediaQueryEvaluator::evaluate(const MediaQuerySet& querySet, Vector<MediaQueryResult>& viewportDependentResults, Vector<MediaQueryResult>& appearanceDependentResults) const
 {
     auto& queries = querySet.queryVector();
     if (!queries.size())
@@ -198,7 +209,9 @@ bool MediaQueryEvaluator::evaluate(const MediaQuerySet& querySet, Vector<MediaQu
             for (; j < expressions.size(); ++j) {
                 bool expressionResult = evaluate(expressions[j]);
                 if (isViewportDependent(expressions[j].mediaFeature()))
-                    results.append({ expressions[j], expressionResult });
+                    viewportDependentResults.append({ expressions[j], expressionResult });
+                if (isAppearanceDependent(expressions[j].mediaFeature()))
+                    appearanceDependentResults.append({ expressions[j], expressionResult });
                 if (!expressionResult)
                     break;
             }
index 08de8ee..db1b718 100644 (file)
@@ -68,8 +68,8 @@ public:
     // Evaluates media query subexpression, ie "and (media-feature: value)" part.
     bool evaluate(const MediaQueryExpression&) const;
 
-    // Evaluates a list of media queries and fills in a vector with any viewport-dependent results found.
-    bool evaluate(const MediaQuerySet&, Vector<MediaQueryResult>&) const;
+    // Evaluates a list of media queries and fills in vectors with any viewport or dark mode dependent results found.
+    bool evaluate(const MediaQuerySet&, Vector<MediaQueryResult>& viewportDependentResults, Vector<MediaQueryResult>& appearanceDependentResults) const;
 
     static bool mediaAttributeMatches(Document&, const String& attributeValue);
 
index 57671c9..75b0b8d 100644 (file)
@@ -1882,6 +1882,21 @@ bool StyleResolver::hasMediaQueriesAffectedByAccessibilitySettingsChange() const
     return false;
 }
 
+void StyleResolver::addAppearanceDependentMediaQueryResult(const MediaQueryExpression& expression, bool result)
+{
+    m_appearanceDependentMediaQueryResults.append(MediaQueryResult { expression, result });
+}
+
+bool StyleResolver::hasMediaQueriesAffectedByAppearanceChange() const
+{
+    LOG(MediaQueries, "StyleResolver::hasMediaQueriesAffectedByAppearanceChange evaluating queries");
+    for (auto& result : m_appearanceDependentMediaQueryResults) {
+        if (m_mediaQueryEvaluator.evaluate(result.expression) != result.result)
+            return true;
+    }
+    return false;
+}
+
 static FilterOperation::OperationType filterOperationForType(CSSValueID type)
 {
     switch (type) {
index f19a500..9824216 100644 (file)
@@ -209,6 +209,10 @@ public:
     bool hasAccessibilitySettingsDependentMediaQueries() const { return !m_accessibilitySettingsDependentMediaQueryResults.isEmpty(); }
     bool hasMediaQueriesAffectedByAccessibilitySettingsChange() const;
 
+    void addAppearanceDependentMediaQueryResult(const MediaQueryExpression&, bool result);
+    bool hasAppearanceDependentMediaQueries() const { return !m_appearanceDependentMediaQueryResults.isEmpty(); }
+    bool hasMediaQueriesAffectedByAppearanceChange() const;
+
     void addKeyframeStyle(Ref<StyleRuleKeyframes>&&);
 
     bool usesFirstLineRules() const { return m_ruleSets.features().usesFirstLineRules; }
@@ -509,6 +513,7 @@ private:
 
     Vector<MediaQueryResult> m_viewportDependentMediaQueryResults;
     Vector<MediaQueryResult> m_accessibilitySettingsDependentMediaQueryResults;
+    Vector<MediaQueryResult> m_appearanceDependentMediaQueryResults;
 
 #if ENABLE(CSS_DEVICE_ADAPTATION)
     RefPtr<ViewportStyleResolver> m_viewportStyleResolver;
index d6e6e35..1e6bc4b 100644 (file)
@@ -3809,6 +3809,7 @@ void Document::evaluateMediaQueryList()
         m_mediaQueryMatcher->styleResolverChanged();
     
     checkViewportDependentPictures();
+    checkAppearanceDependentPictures();
 }
 
 void Document::checkViewportDependentPictures()
@@ -3823,6 +3824,18 @@ void Document::checkViewportDependentPictures()
         picture->sourcesChanged();
 }
 
+void Document::checkAppearanceDependentPictures()
+{
+    Vector<HTMLPictureElement*, 16> changedPictures;
+    for (auto* picture : m_appearanceDependentPictures) {
+        if (picture->appearanceChangeAffectedPicture())
+            changedPictures.append(picture);
+    }
+
+    for (auto* picture : changedPictures)
+        picture->sourcesChanged();
+}
+
 void Document::updateViewportUnitsOnResize()
 {
     if (!hasStyleWithViewportUnits())
@@ -7580,6 +7593,16 @@ void Document::removeViewportDependentPicture(HTMLPictureElement& picture)
     m_viewportDependentPictures.remove(&picture);
 }
 
+void Document::addAppearanceDependentPicture(HTMLPictureElement& picture)
+{
+    m_appearanceDependentPictures.add(&picture);
+}
+
+void Document::removeAppearanceDependentPicture(HTMLPictureElement& picture)
+{
+    m_appearanceDependentPictures.remove(&picture);
+}
+
 #if ENABLE(INTERSECTION_OBSERVER)
 void Document::addIntersectionObserver(IntersectionObserver& observer)
 {
index 6ddf145..6a7265a 100644 (file)
@@ -1399,6 +1399,9 @@ public:
     void addViewportDependentPicture(HTMLPictureElement&);
     void removeViewportDependentPicture(HTMLPictureElement&);
 
+    void addAppearanceDependentPicture(HTMLPictureElement&);
+    void removeAppearanceDependentPicture(HTMLPictureElement&);
+
 #if ENABLE(INTERSECTION_OBSERVER)
     void addIntersectionObserver(IntersectionObserver&);
     void removeIntersectionObserver(IntersectionObserver&);
@@ -1634,6 +1637,7 @@ private:
     void didLoadResourceSynchronously() final;
 
     void checkViewportDependentPictures();
+    void checkAppearanceDependentPictures();
 
 #if ENABLE(INTERSECTION_OBSERVER)
     void notifyIntersectionObserversTimerFired();
@@ -1828,6 +1832,7 @@ private:
 #endif
 
     HashSet<HTMLPictureElement*> m_viewportDependentPictures;
+    HashSet<HTMLPictureElement*> m_appearanceDependentPictures;
 
 #if ENABLE(INTERSECTION_OBSERVER)
     Vector<WeakPtr<IntersectionObserver>> m_intersectionObservers;
index bd56128..a23f878 100644 (file)
@@ -155,8 +155,13 @@ ImageCandidate HTMLImageElement::bestFitSourceFromPictureElement()
     auto picture = makeRefPtr(pictureElement());
     if (!picture)
         return { };
+
     picture->clearViewportDependentResults();
     document().removeViewportDependentPicture(*picture);
+
+    picture->clearAppearanceDependentResults();
+    document().removeAppearanceDependentPicture(*picture);
+
     for (RefPtr<Node> child = picture->firstChild(); child && child != this; child = child->nextSibling()) {
         if (!is<HTMLSourceElement>(*child))
             continue;
@@ -179,9 +184,11 @@ ImageCandidate HTMLImageElement::bestFitSourceFromPictureElement()
         MediaQueryEvaluator evaluator { document().printing() ? "print" : "screen", document(), documentElement ? documentElement->computedStyle() : nullptr };
         auto* queries = source.parsedMediaAttribute(document());
         LOG(MediaQueries, "HTMLImageElement %p bestFitSourceFromPictureElement evaluating media queries", this);
-        auto evaluation = !queries || evaluator.evaluate(*queries, picture->viewportDependentResults());
+        auto evaluation = !queries || evaluator.evaluate(*queries, picture->viewportDependentResults(), picture->appearanceDependentResults());
         if (picture->hasViewportDependentResults())
             document().addViewportDependentPicture(*picture);
+        if (picture->hasAppearanceDependentResults())
+            document().addAppearanceDependentPicture(*picture);
         if (!evaluation)
             continue;
 
index aa2aad6..0046d19 100644 (file)
@@ -45,11 +45,13 @@ HTMLPictureElement::HTMLPictureElement(const QualifiedName& tagName, Document& d
 HTMLPictureElement::~HTMLPictureElement()
 {
     document().removeViewportDependentPicture(*this);
+    document().removeAppearanceDependentPicture(*this);
 }
 
 void HTMLPictureElement::didMoveToNewDocument(Document& oldDocument, Document& newDocument)
 {
     oldDocument.removeViewportDependentPicture(*this);
+    oldDocument.removeAppearanceDependentPicture(*this);
     HTMLElement::didMoveToNewDocument(oldDocument, newDocument);
     sourcesChanged();
 }
@@ -77,6 +79,18 @@ bool HTMLPictureElement::viewportChangeAffectedPicture() const
     return false;
 }
 
+bool HTMLPictureElement::appearanceChangeAffectedPicture() const
+{
+    auto documentElement = makeRefPtr(document().documentElement());
+    MediaQueryEvaluator evaluator { document().printing() ? "print" : "screen", document(), documentElement ? documentElement->computedStyle() : nullptr };
+    for (auto& result : m_appearanceDependentMediaQueryResults) {
+        LOG(MediaQueries, "HTMLPictureElement %p appearanceChangeAffectedPicture evaluating media queries", this);
+        if (evaluator.evaluate(result.expression) != result.result)
+            return true;
+    }
+    return false;
+}
+
 #if USE(SYSTEM_PREVIEW)
 bool HTMLPictureElement::isSystemPreviewImage() const
 {
index c6da357..7704fd3 100644 (file)
@@ -42,7 +42,12 @@ public:
     bool hasViewportDependentResults() const { return m_viewportDependentMediaQueryResults.size(); }
     Vector<MediaQueryResult>& viewportDependentResults() { return m_viewportDependentMediaQueryResults; }
 
+    void clearAppearanceDependentResults() { m_appearanceDependentMediaQueryResults.clear(); }
+    bool hasAppearanceDependentResults() const { return m_appearanceDependentMediaQueryResults.size(); }
+    Vector<MediaQueryResult>& appearanceDependentResults() { return m_appearanceDependentMediaQueryResults; }
+
     bool viewportChangeAffectedPicture() const;
+    bool appearanceChangeAffectedPicture() const;
 
 #if USE(SYSTEM_PREVIEW)
     WEBCORE_EXPORT bool isSystemPreviewImage() const;
@@ -54,6 +59,7 @@ private:
     void didMoveToNewDocument(Document& oldDocument, Document& newDocument) final;
 
     Vector<MediaQueryResult> m_viewportDependentMediaQueryResults;
+    Vector<MediaQueryResult> m_appearanceDependentMediaQueryResults;
 };
 
 } // namespace WebCore
index 4ce5f42..9a6d27a 100644 (file)
@@ -2455,6 +2455,18 @@ void Page::accessibilitySettingsDidChange()
     }
 }
 
+void Page::appearanceDidChange()
+{
+    for (Frame* frame = &mainFrame(); frame; frame = frame->tree().traverseNext()) {
+        auto* document = frame->document();
+        if (!document)
+            continue;
+
+        document->styleScope().evaluateMediaQueriesForAppearanceChange();
+        document->evaluateMediaQueryList();
+    }
+}
+
 void Page::setUnobscuredSafeAreaInsets(const FloatBoxExtent& insets)
 {
     if (m_unobscuredSafeAreaInsets == insets)
@@ -2476,7 +2488,7 @@ void Page::setUseSystemAppearance(bool value)
 
     m_useSystemAppearance = value;
 
-    updateStyleAfterChangeInEnvironment();
+    appearanceDidChange();
 
     for (auto* frame = &mainFrame(); frame; frame = frame->tree().traverseNext()) {
         auto* document = frame->document();
@@ -2496,7 +2508,7 @@ void Page::setUseDarkAppearance(bool value)
 
     m_useDarkAppearance = value;
 
-    updateStyleAfterChangeInEnvironment();
+    appearanceDidChange();
 }
 
 bool Page::useDarkAppearance() const
index 5e71717..874da15 100644 (file)
@@ -382,6 +382,7 @@ public:
     ScrollElasticity horizontalScrollElasticity() const { return static_cast<ScrollElasticity>(m_horizontalScrollElasticity); }
 
     WEBCORE_EXPORT void accessibilitySettingsDidChange();
+    WEBCORE_EXPORT void appearanceDidChange();
 
     // Page and FrameView both store a Pagination value. Page::pagination() is set only by API,
     // and FrameView::pagination() is set only by CSS. Page::pagination() will affect all
index f22fd83..a5e6d73 100644 (file)
@@ -632,6 +632,13 @@ void Scope::evaluateMediaQueriesForAccessibilitySettingsChange()
     });
 }
 
+void Scope::evaluateMediaQueriesForAppearanceChange()
+{
+    evaluateMediaQueries([] (StyleResolver& resolver) {
+        return resolver.hasMediaQueriesAffectedByAppearanceChange();
+    });
+}
+
 template <typename TestFunction>
 void Scope::evaluateMediaQueries(TestFunction&& testFunction)
 {
index 2287a71..366fca6 100644 (file)
@@ -97,6 +97,7 @@ public:
 
     void evaluateMediaQueriesForViewportChange();
     void evaluateMediaQueriesForAccessibilitySettingsChange();
+    void evaluateMediaQueriesForAppearanceChange();
 
     // This is called when some stylesheet becomes newly enabled or disabled.
     void didChangeActiveStyleSheetCandidates();