Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use a light scrollbar for transparent web views in dark mode.
https://bugs.webkit.org/show_bug.cgi?id=191559 rdar://problem/46000489 Reviewed by Dean Jackson. Source/WebCore: Test: css-dark-mode/supported-color-schemes-scrollbar.html * css/CSSProperties.json: Marked supported-color-schemes as a custom Value. * css/StyleBuilderCustom.h: (WebCore::StyleBuilderCustom::applyValueSupportedColorSchemes): * editing/cocoa/WebContentReaderCocoa.mm: Use FrameView's useDarkAppearance(). (WebCore::createFragment): * inspector/InspectorOverlay.cpp: (WebCore::InspectorOverlay::paint): Use FrameView's useDarkAppearance(). * page/FrameView.cpp: (WebCore::FrameView::recalculateScrollbarOverlayStyle): Use a light scrollbar for transparent web views in dark mode. (WebCore::FrameView::rendererForSupportedColorSchemes const): Added. Return the body for document element renderer. (WebCore::FrameView::useDarkAppearance const): Use rendererForSupportedColorSchemes. (WebCore::FrameView::styleColorOptions const): Added. Ditto. * page/FrameView.h: * rendering/style/RenderStyle.cpp: (WebCore::rareInheritedDataChangeRequiresRepaint): Drive-by fix. Added supportedColorSchemes. * rendering/style/RenderStyle.h: (WebCore::RenderStyle::setHasExplicitlySetSupportedColorSchemes): Added. (WebCore::RenderStyle::hasExplicitlySetSupportedColorSchemes const): Added. (WebCore::RenderStyle::NonInheritedFlags::operator== const): Added supportedColorSchemes. * svg/graphics/SVGImage.cpp: (WebCore::SVGImage::draw): Use FrameView's useDarkAppearance(). * testing/Internals.cpp: (WebCore::Internals::setViewIsTransparent): Added. (WebCore::Internals::scrollbarOverlayStyle const): Added. * testing/Internals.h: * testing/Internals.idl: Added setViewIsTransparent and scrollbarOverlayStyle. Source/WebKit: * WebProcess/InjectedBundle/DOM/InjectedBundleRangeHandle.cpp: (WebKit::InjectedBundleRangeHandle::renderedImage): Use FrameView's useDarkAppaearance(). * WebProcess/WebPage/WebPage.cpp: (WebKit::WebPage::drawRect): Ditto. LayoutTests: * css-dark-mode/supported-color-schemes-scrollbar-expected.txt: Added. * css-dark-mode/supported-color-schemes-scrollbar.html: Added. Canonical link: https://commits.webkit.org/206359@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@238155 268f45cc-cd09-0410-ab3c-d52691b4dbfc
- Loading branch information
Showing
19 changed files
with
253 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
LayoutTests/css-dark-mode/supported-color-schemes-scrollbar-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
|
||
PASS Set dark appearance | ||
PASS Set view to transparent | ||
PASS Body Element supported color scheme is light and dark | ||
PASS Document Element supported color scheme is auto | ||
PASS Scrollbar overlay style is light | ||
PASS Set prefers-color-schemes: light on the document element | ||
PASS Body Element supported color scheme is light and dark | ||
PASS Document Element supported color scheme is light | ||
PASS Scrollbar overlay style is default | ||
|
66 changes: 66 additions & 0 deletions
66
LayoutTests/css-dark-mode/supported-color-schemes-scrollbar.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
<!DOCTYPE html> | ||
|
||
<!-- webkit-test-runner [ experimental:DarkModeCSSEnabled=true ] --> | ||
|
||
<script src="../resources/testharness.js"></script> | ||
<script src="../resources/testharnessreport.js"></script> | ||
|
||
<style> | ||
body { | ||
supported-color-schemes: light dark; | ||
} | ||
</style> | ||
|
||
<body></body> | ||
|
||
<script> | ||
function test_prop(element, prop, expected) { | ||
assert_equals(window.getComputedStyle(element).getPropertyValue(prop), expected); | ||
} | ||
|
||
test(function() { | ||
if (!window.internals) | ||
return; | ||
internals.settings.setUseDarkAppearance(true); | ||
}, "Set dark appearance"); | ||
|
||
test(function() { | ||
if (!window.internals) | ||
return; | ||
internals.setViewIsTransparent(true); | ||
}, "Set view to transparent"); | ||
|
||
test(function() { | ||
test_prop(document.body, "supported-color-schemes", "light dark"); | ||
}, "Body Element supported color scheme is light and dark"); | ||
|
||
test(function() { | ||
test_prop(document.documentElement, "supported-color-schemes", "auto"); | ||
}, "Document Element supported color scheme is auto"); | ||
|
||
test(function() { | ||
if (!window.internals) | ||
return; | ||
assert_equals(internals.scrollbarOverlayStyle(), "light"); | ||
}, "Scrollbar overlay style is light"); | ||
|
||
test(function() { | ||
let styleElement = document.createElement("style"); | ||
styleElement.textContent = ":root { supported-color-schemes: light }"; | ||
document.head.appendChild(styleElement); | ||
}, "Set prefers-color-schemes: light on the document element"); | ||
|
||
test(function() { | ||
test_prop(document.body, "supported-color-schemes", "light dark"); | ||
}, "Body Element supported color scheme is light and dark"); | ||
|
||
test(function() { | ||
test_prop(document.documentElement, "supported-color-schemes", "light"); | ||
}, "Document Element supported color scheme is light"); | ||
|
||
test(function() { | ||
if (!window.internals) | ||
return; | ||
assert_equals(internals.scrollbarOverlayStyle(), "default"); | ||
}, "Scrollbar overlay style is default"); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.