haikuwebkit/LayoutTests/css-dark-mode/default-colors.html

51 lines
1.6 KiB
HTML
Raw Permalink Normal View History

Default the view background color and text color to different values when in dark mode. https://bugs.webkit.org/show_bug.cgi?id=191607 rdar://problem/46045854 Reviewed by Dean Jackson. Source/WebCore: Test: css-dark-mode/default-colors.html * css/html.css: (html): Set color: text on macOS. * dom/Document.cpp: (WebCore::Document::processSupportedColorSchemes): Call recalculateBaseBackgroundColor(). * editing/EditingStyle.cpp: (WebCore::caretColorFromStyle): Added. (WebCore::EditingStyle::prepareToApplyAt): Use equalIgnoringSemanticColor. Check for caret-color directly since removeEquivalentProperties fails with semantic colors. (WebCore::extractPropertiesNotIn): Use equalIgnoringSemanticColor. Check for caret-color directly since removeEquivalentProperties fails with semantic colors. * page/Frame.cpp: (WebCore::Frame::createView): Drop backgroundColor. * page/Frame.h: * page/FrameView.cpp: (WebCore::FrameView::recalculateBaseBackgroundColor): Added. (WebCore::FrameView::updateBackgroundRecursively): Drop backgroundColor argument. Calculate the backgroundColor based on the transparent argument only. * page/FrameView.h: * platform/graphics/Color.h: (WebCore::equalIgnoringSemanticColor): Added for EditingStyle. * rendering/RenderBox.cpp: (WebCore::RenderBox::styleDidChange): Call recalculateBaseBackgroundColor(). * rendering/RenderLayerBacking.cpp: (WebCore::RenderLayerBacking::shouldDumpPropertyForLayer const): Use isWhiteColor() since it ignores the semantic color flag. * testing/Internals.cpp: (WebCore::Internals::setViewIsTransparent): Drop backgroundColor. (WebCore::Internals::viewBaseBackgroundColor): Added. * testing/Internals.h: * testing/Internals.idl: Added viewBaseBackgroundColor. Source/WebKit: * UIProcess/Cocoa/WebViewImpl.mm: (WebKit::WebViewImpl::backgroundColor const): Use controlBackgroundColor. (WebKit::WebViewImpl::updateLayer): Simplified and use backgroundColor() getter. * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp: (WebKit::WebFrameLoaderClient::transitionToCommittedForNewPage): Drop backgroundColor. * WebProcess/WebPage/WebPage.cpp: (WebKit::WebPage::setDrawsBackground): Drop backgroundColor. Source/WebKitLegacy/win: * WebFrame.cpp: (WebFrame::updateBackground): Drop backgroundColor. * WebCoreSupport/WebFrameLoaderClient.cpp: (WebFrameLoaderClient::transitionToCommittedForNewPage): Drop backgroundColor. LayoutTests: * css-dark-mode/default-colors-expected.txt: Added. * css-dark-mode/default-colors.html: Added. * inspector/css/shadow-scoped-style-expected.txt: Rebaseline. * platform/mac/printing/width-overflow-expected.txt: Rebaseline. Canonical link: https://commits.webkit.org/206414@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@238212 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-11-15 01:48:20 +00:00
<!DOCTYPE html>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
<body></body>
<script>
function test_prop(element, prop, expected) {
assert_equals(window.getComputedStyle(element).getPropertyValue(prop), expected);
}
test(function() {
test_prop(document.body, "color", "rgb(0, 0, 0)");
}, "Body text color is black, since the page isn't in dark mode");
test(function() {
assert_equals(internals.viewBaseBackgroundColor(), "rgb(255, 255, 255)");
}, "View base background color is white, since the page isn't in dark mode");
test(function() {
if (!window.internals)
return;
internals.settings.setUseDarkAppearance(true);
}, "Set dark appearance");
test(function() {
test_prop(document.body, "color", "rgb(0, 0, 0)");
}, "Body text color is black, since the page hasn't set a supported color scheme");
test(function() {
assert_equals(internals.viewBaseBackgroundColor(), "rgb(255, 255, 255)");
}, "View base background color is white, since the page hasn't set a supported color scheme");
test(function() {
let styleElement = document.createElement("style");
Rename `supported-color-schemes` to `color-scheme`. https://bugs.webkit.org/show_bug.cgi?id=197016 rdar://problem/49980259 Reviewed by Simon Fraser. Source/WebCore: Changed `supported-color-schemes` to `color-scheme` to follow the spec changes being tracked by: https://github.com/w3c/csswg-drafts/issues/3807 The old `supported-color-schemes` is now an alias of `color-scheme` for compatibility. Tests: css-dark-mode/color-scheme-css-parse.html css-dark-mode/color-scheme-css.html css-dark-mode/color-scheme-meta.html css-dark-mode/color-scheme-priority.html css-dark-mode/color-scheme-scrollbar.html css-dark-mode/older-syntax/supported-color-schemes-css.html css-dark-mode/older-syntax/supported-color-schemes-meta.html css-dark-mode/older-systems/color-scheme-css.html css-dark-mode/older-systems/color-scheme-meta.html * WebCore.xcodeproj/project.pbxproj: * css/CSSComputedStyleDeclaration.cpp: (WebCore::ComputedStyleExtractor::valueForPropertyinStyle): * css/CSSProperties.json: * css/CSSValueKeywords.in: * css/StyleBuilderConverter.h: (WebCore::StyleBuilderConverter::updateColorScheme): (WebCore::StyleBuilderConverter::convertColorScheme): (WebCore::StyleBuilderConverter::updateSupportedColorSchemes): Deleted. (WebCore::StyleBuilderConverter::convertSupportedColorSchemes): Deleted. * css/StyleBuilderCustom.h: (WebCore::StyleBuilderCustom::applyValueColorScheme): (WebCore::StyleBuilderCustom::applyValueSupportedColorSchemes): Deleted. * css/StyleResolver.cpp: (WebCore::StyleResolver::applyMatchedProperties): * css/parser/CSSPropertyParser.cpp: (WebCore::consumeColorScheme): (WebCore::CSSPropertyParser::parseSingleValue): (WebCore::consumeSupportedColorSchemes): Deleted. * dom/Document.cpp: (WebCore::processColorSchemeString): (WebCore::Document::processColorScheme): (WebCore::Document::useDarkAppearance const): (WebCore::processColorSchemes): Deleted. (WebCore::Document::processSupportedColorSchemes): Deleted. * dom/Document.h: * html/HTMLMetaElement.cpp: (WebCore::HTMLMetaElement::process): * page/FrameView.cpp: (WebCore::FrameView::rendererForColorScheme const): (WebCore::FrameView::useDarkAppearance const): (WebCore::FrameView::styleColorOptions const): (WebCore::FrameView::rendererForSupportedColorSchemes const): Deleted. * page/FrameView.h: * rendering/style/RenderStyle.cpp: (WebCore::rareInheritedDataChangeRequiresRepaint): * rendering/style/RenderStyle.h: (WebCore::RenderStyle::colorScheme const): (WebCore::RenderStyle::setHasExplicitlySetColorScheme): (WebCore::RenderStyle::hasExplicitlySetColorScheme const): (WebCore::RenderStyle::setColorScheme): (WebCore::RenderStyle::initialColorScheme): (WebCore::RenderStyle::NonInheritedFlags::operator== const): (WebCore::RenderStyle::supportedColorSchemes const): Deleted. (WebCore::RenderStyle::setHasExplicitlySetSupportedColorSchemes): Deleted. (WebCore::RenderStyle::hasExplicitlySetSupportedColorSchemes const): Deleted. (WebCore::RenderStyle::setSupportedColorSchemes): Deleted. (WebCore::RenderStyle::initialSupportedColorSchemes): Deleted. * rendering/style/RenderStyleConstants.h: * rendering/style/StyleColorScheme.h: Renamed from Source/WebCore/rendering/style/StyleSupportedColorSchemes.h. (WebCore::StyleColorScheme::StyleColorScheme): (WebCore::StyleColorScheme::operator== const): (WebCore::StyleColorScheme::operator!= const): (WebCore::StyleColorScheme::isAuto const): (WebCore::StyleColorScheme::isOnly const): (WebCore::StyleColorScheme::colorScheme const): (WebCore::StyleColorScheme::add): (WebCore::StyleColorScheme::contains const): (WebCore::StyleColorScheme::setAllowsTransformations): (WebCore::StyleColorScheme::allowsTransformations const): * rendering/style/StyleRareInheritedData.cpp: (WebCore::StyleRareInheritedData::StyleRareInheritedData): (WebCore::StyleRareInheritedData::operator== const): * rendering/style/StyleRareInheritedData.h: Source/WebInspectorUI: * UserInterface/Views/Main.css: (:root): LayoutTests: * css-dark-mode/color-scheme-css-expected.txt: Renamed from LayoutTests/css-dark-mode/supported-color-schemes-css-expected.txt. * css-dark-mode/color-scheme-css.html: Renamed from LayoutTests/css-dark-mode/supported-color-schemes-css.html. * css-dark-mode/color-scheme-meta-expected.txt: Renamed from LayoutTests/css-dark-mode/supported-color-schemes-expected.txt. * css-dark-mode/color-scheme-meta.html: Renamed from LayoutTests/css-dark-mode/supported-color-schemes.html. * css-dark-mode/color-scheme-parse-expected.txt: Renamed from LayoutTests/css-dark-mode/parse-supported-color-schemes-expected.txt. * css-dark-mode/color-scheme-parse.html: Renamed from LayoutTests/css-dark-mode/parse-supported-color-schemes.html. * css-dark-mode/color-scheme-priority-expected.txt: Renamed from LayoutTests/css-dark-mode/supported-color-schemes-priority-expected.txt. * css-dark-mode/color-scheme-priority.html: Renamed from LayoutTests/css-dark-mode/supported-color-schemes-priority.html. * css-dark-mode/color-scheme-scrollbar-expected.txt: Renamed from LayoutTests/css-dark-mode/supported-color-schemes-scrollbar-expected.txt. * css-dark-mode/color-scheme-scrollbar.html: Renamed from LayoutTests/css-dark-mode/supported-color-schemes-scrollbar.html. * css-dark-mode/older-syntax/supported-color-schemes-css-expected.txt: Copied from LayoutTests/css-dark-mode/supported-color-schemes-css-expected.txt. * css-dark-mode/older-syntax/supported-color-schemes-css.html: Copied from LayoutTests/css-dark-mode/supported-color-schemes-css.html. * css-dark-mode/older-syntax/supported-color-schemes-meta-expected.txt: Copied from LayoutTests/css-dark-mode/supported-color-schemes-expected.txt. * css-dark-mode/older-syntax/supported-color-schemes-meta.html: Copied from LayoutTests/css-dark-mode/supported-color-schemes.html. * css-dark-mode/older-systems/color-scheme-css-expected.txt: Renamed from LayoutTests/css-dark-mode/older-systems/supported-color-schemes-css-expected.txt * css-dark-mode/older-systems/color-scheme-css.html: Renamed from LayoutTests/css-dark-mode/older-systems/supported-color-schemes-css.html. * css-dark-mode/older-systems/color-scheme-meta-expected.txt: Renamed from LayoutTests/css-dark-mode/older-systems/supported-color-schemes-expected.txt. * css-dark-mode/older-systems/color-scheme-meta.html: Renamed from LayoutTests/css-dark-mode/older-systems/supported-color-schemes.html. * fast/css/style-enumerate-properties.html: Updated property count. Canonical link: https://commits.webkit.org/211294@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@244408 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-04-17 23:15:01 +00:00
styleElement.textContent = ":root { color-scheme: light dark; }";
Default the view background color and text color to different values when in dark mode. https://bugs.webkit.org/show_bug.cgi?id=191607 rdar://problem/46045854 Reviewed by Dean Jackson. Source/WebCore: Test: css-dark-mode/default-colors.html * css/html.css: (html): Set color: text on macOS. * dom/Document.cpp: (WebCore::Document::processSupportedColorSchemes): Call recalculateBaseBackgroundColor(). * editing/EditingStyle.cpp: (WebCore::caretColorFromStyle): Added. (WebCore::EditingStyle::prepareToApplyAt): Use equalIgnoringSemanticColor. Check for caret-color directly since removeEquivalentProperties fails with semantic colors. (WebCore::extractPropertiesNotIn): Use equalIgnoringSemanticColor. Check for caret-color directly since removeEquivalentProperties fails with semantic colors. * page/Frame.cpp: (WebCore::Frame::createView): Drop backgroundColor. * page/Frame.h: * page/FrameView.cpp: (WebCore::FrameView::recalculateBaseBackgroundColor): Added. (WebCore::FrameView::updateBackgroundRecursively): Drop backgroundColor argument. Calculate the backgroundColor based on the transparent argument only. * page/FrameView.h: * platform/graphics/Color.h: (WebCore::equalIgnoringSemanticColor): Added for EditingStyle. * rendering/RenderBox.cpp: (WebCore::RenderBox::styleDidChange): Call recalculateBaseBackgroundColor(). * rendering/RenderLayerBacking.cpp: (WebCore::RenderLayerBacking::shouldDumpPropertyForLayer const): Use isWhiteColor() since it ignores the semantic color flag. * testing/Internals.cpp: (WebCore::Internals::setViewIsTransparent): Drop backgroundColor. (WebCore::Internals::viewBaseBackgroundColor): Added. * testing/Internals.h: * testing/Internals.idl: Added viewBaseBackgroundColor. Source/WebKit: * UIProcess/Cocoa/WebViewImpl.mm: (WebKit::WebViewImpl::backgroundColor const): Use controlBackgroundColor. (WebKit::WebViewImpl::updateLayer): Simplified and use backgroundColor() getter. * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp: (WebKit::WebFrameLoaderClient::transitionToCommittedForNewPage): Drop backgroundColor. * WebProcess/WebPage/WebPage.cpp: (WebKit::WebPage::setDrawsBackground): Drop backgroundColor. Source/WebKitLegacy/win: * WebFrame.cpp: (WebFrame::updateBackground): Drop backgroundColor. * WebCoreSupport/WebFrameLoaderClient.cpp: (WebFrameLoaderClient::transitionToCommittedForNewPage): Drop backgroundColor. LayoutTests: * css-dark-mode/default-colors-expected.txt: Added. * css-dark-mode/default-colors.html: Added. * inspector/css/shadow-scoped-style-expected.txt: Rebaseline. * platform/mac/printing/width-overflow-expected.txt: Rebaseline. Canonical link: https://commits.webkit.org/206414@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@238212 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-11-15 01:48:20 +00:00
document.head.appendChild(styleElement);
}, "Set prefers-color-schemes: light dark on the body");
test(function() {
test_prop(document.body, "color", "rgb(255, 255, 255)");
}, "Body text color is white");
test(function() {
if (!window.internals)
return;
assert_equals(internals.viewBaseBackgroundColor(), "rgb(30, 30, 30)");
}, "View base background color is a dark grey");
</script>