<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)
commit67125059704590ee57c276b5f42dfefd48775e8e
tree5730683538da31c3201a672e5e11543ad85d9598
parent52cb73d3203e1092b155df3916bed5b3de2897c9
<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.

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