Add <meta name="supported-color-schemes"> to control what color schemes the page...
authortimothy@apple.com <timothy@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 16 Oct 2018 21:53:55 +0000 (21:53 +0000)
committertimothy@apple.com <timothy@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 16 Oct 2018 21:53:55 +0000 (21:53 +0000)
commit3147fb9f6fa9e19a15ba9b1619f60776378b34fd
tree8304569b0575f2bbc29da95e75407ac87f4dc705
parenta9d28bc0e67b29e2fc82a8496ed40bf0b647f442
Add <meta name="supported-color-schemes"> to control what color schemes the page supports
https://bugs.webkit.org/show_bug.cgi?id=190526
rdar://problem/45230140

Reviewed by Dean Jackson.

Source/WebCore:

Test: css-dark-mode/supported-color-schemes.html

* dom/Document.cpp:
(WebCore::isColorSchemeSeparator): Added.
(WebCore::processColorSchemes): Added.
(WebCore::Document::processSupportedColorSchemes): Added.
(WebCore::Document::useDarkAppearance const): Take system appearance and document's
suppoerted color shcemes into account.
* dom/Document.h:
* editing/cocoa/WebContentReaderCocoa.mm:
(WebCore::createFragment): Update use of LocalDefaultSystemAppearance.
* html/HTMLMetaElement.cpp:
(WebCore::HTMLMetaElement::process): Added supported-color-schemes behind runtime feature check.
* inspector/InspectorOverlay.cpp:
(WebCore::InspectorOverlay::paint): Update use of LocalDefaultSystemAppearance.
* platform/mac/DragImageMac.mm:
(WebCore::createDragImageForLink): Update use of LocalDefaultSystemAppearance.
* platform/mac/LocalDefaultSystemAppearance.h:
* platform/mac/LocalDefaultSystemAppearance.mm:
(WebCore::LocalDefaultSystemAppearance::LocalDefaultSystemAppearance):
Drop the need for useSystemAppearance. This is accounted for in Document::useDarkAppearance.
* platform/mac/ThemeMac.mm:
(WebCore::ThemeMac::paint): Update use of LocalDefaultSystemAppearance.
* rendering/RenderLayerBacking.cpp:
(WebCore::RenderLayerBacking::paintContents): Update use of LocalDefaultSystemAppearance.
* rendering/RenderLayerCompositor.cpp:
(WebCore::RenderLayerCompositor::paintContents): Update use of LocalDefaultSystemAppearance.
* rendering/RenderTheme.cpp:
(WebCore::RenderTheme::paint): Use document instead of page.
* rendering/RenderThemeCocoa.mm:
(WebCore::RenderThemeCocoa::drawLineForDocumentMarker): Update use of LocalDefaultSystemAppearance.
* rendering/RenderThemeMac.mm:
(WebCore::RenderThemeMac::documentViewFor const): Update use of LocalDefaultSystemAppearance.
(WebCore::RenderThemeMac::platformActiveSelectionBackgroundColor const): Ditto.
(WebCore::RenderThemeMac::platformInactiveSelectionBackgroundColor const): Ditto.
(WebCore::RenderThemeMac::transformSelectionBackgroundColor const): Ditto.
(WebCore::RenderThemeMac::supportsSelectionForegroundColors const): Ditto.
(WebCore::RenderThemeMac::platformActiveSelectionForegroundColor const): Ditto.
(WebCore::RenderThemeMac::platformInactiveSelectionForegroundColor const): Ditto.
(WebCore::RenderThemeMac::platformActiveListBoxSelectionBackgroundColor const): Ditto.
(WebCore::RenderThemeMac::platformInactiveListBoxSelectionBackgroundColor const): Ditto.
(WebCore::RenderThemeMac::platformActiveListBoxSelectionForegroundColor const): Ditto.
(WebCore::RenderThemeMac::platformInactiveListBoxSelectionForegroundColor const): Ditto.
(WebCore::RenderThemeMac::platformActiveTextSearchHighlightColor const): Ditto.
(WebCore::RenderThemeMac::colorCache const): Ditto.
(WebCore::RenderThemeMac::systemColor const): Ditto.
(WebCore::RenderThemeMac::paintCellAndSetFocusedElementNeedsRepaintIfNecessary): Ditto.
(WebCore::RenderThemeMac::paintSliderThumb): Ditto.
(WebCore::RenderThemeMac::usingDarkAppearance const): No need to limit to macOS here.
* svg/graphics/SVGImage.cpp:
(WebCore::SVGImage::draw): Update use of LocalDefaultSystemAppearance.

Source/WebKit:

* UIProcess/mac/WKPrintingView.mm:
(-[WKPrintingView drawRect:]): Update use of LocalDefaultSystemAppearance.
* WebProcess/InjectedBundle/DOM/InjectedBundleRangeHandle.cpp:
(WebKit::InjectedBundleRangeHandle::renderedImage): Ditto.
* WebProcess/Plugins/PDF/PDFPlugin.mm:
(WebKit::PDFPlugin::paintControlForLayerInContext): Ditto.
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::drawRect): Ditto.

Source/WebKitLegacy/mac:

* WebCoreSupport/WebEditorClient.mm:
(_WebCreateFragment): Update use of LocalDefaultSystemAppearance.

LayoutTests:

* css-dark-mode/supported-color-schemes-expected.txt: Added.
* css-dark-mode/supported-color-schemes.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@237204 268f45cc-cd09-0410-ab3c-d52691b4dbfc
28 files changed:
LayoutTests/ChangeLog
LayoutTests/css-dark-mode/supported-color-schemes-expected.txt [new file with mode: 0644]
LayoutTests/css-dark-mode/supported-color-schemes.html [new file with mode: 0644]
LayoutTests/platform/mac-highsierra/css-dark-mode/supported-color-schemes-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac-sierra/css-dark-mode/supported-color-schemes-expected.txt [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/dom/Document.cpp
Source/WebCore/dom/Document.h
Source/WebCore/editing/cocoa/WebContentReaderCocoa.mm
Source/WebCore/html/HTMLMetaElement.cpp
Source/WebCore/inspector/InspectorOverlay.cpp
Source/WebCore/platform/mac/DragImageMac.mm
Source/WebCore/platform/mac/LocalDefaultSystemAppearance.h
Source/WebCore/platform/mac/LocalDefaultSystemAppearance.mm
Source/WebCore/platform/mac/ThemeMac.mm
Source/WebCore/rendering/RenderLayerBacking.cpp
Source/WebCore/rendering/RenderLayerCompositor.cpp
Source/WebCore/rendering/RenderTheme.cpp
Source/WebCore/rendering/RenderThemeCocoa.mm
Source/WebCore/rendering/RenderThemeMac.mm
Source/WebCore/svg/graphics/SVGImage.cpp
Source/WebKit/ChangeLog
Source/WebKit/UIProcess/mac/WKPrintingView.mm
Source/WebKit/WebProcess/InjectedBundle/DOM/InjectedBundleRangeHandle.cpp
Source/WebKit/WebProcess/Plugins/PDF/PDFPlugin.mm
Source/WebKit/WebProcess/WebPage/WebPage.cpp
Source/WebKitLegacy/mac/ChangeLog
Source/WebKitLegacy/mac/WebCoreSupport/WebEditorClient.mm