Commit 917c098e authored by Aran Gilman's avatar Aran Gilman Committed by Commit Bot

Check darkModePagePolicy flag before inverting site colors.

Bug: 925949
Change-Id: I55a9d8280be7cbe435f7c84629b79e919fdff016
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1499955
Commit-Queue: Aran Gilman <gilmanmh@google.com>
Reviewed-by: default avatarDominic Mazzoni <dmazzoni@chromium.org>
Reviewed-by: default avatarRune Lillesveen <futhark@chromium.org>
Cr-Commit-Position: refs/heads/master@{#638311}
parent a6be98b1
......@@ -31,11 +31,24 @@ bool HasLightBackground(const LayoutObject& layout_object) {
} // namespace
// TODO(https://crbug.com/925949): Call ShouldApplyDarkModeFilterToPage()
// and return default DarkModeSettings if it returns false.
DarkModeSettings BuildDarkModeSettings(const Settings& frame_settings,
const LayoutObject& layout_object) {
DarkModeSettings dark_mode_settings;
if (!ShouldApplyDarkModeFilterToPage(frame_settings.GetDarkModePagePolicy(),
layout_object)) {
// In theory it should be sufficient to set mode to
// kOff (or to just return the default struct) without also setting
// image_policy. However, this causes images to be inverted unexpectedly in
// some cases (such as when toggling between the site's light and dark theme
// on arstechnica.com).
//
// TODO(gilmanmh): Investigate unexpected image inversion behavior when
// image_policy not set to kFilterNone.
dark_mode_settings.mode = DarkMode::kOff;
dark_mode_settings.image_policy = DarkModeImagePolicy::kFilterNone;
return dark_mode_settings;
}
dark_mode_settings.mode = frame_settings.GetHighContrastMode();
dark_mode_settings.grayscale = frame_settings.GetHighContrastGrayscale();
dark_mode_settings.contrast = frame_settings.GetHighContrastContrast();
......
......@@ -914,6 +914,12 @@
type: "DarkModeImagePolicy",
invalidate: "Paint",
},
{
name: "darkModePagePolicy",
initial: "DarkModePagePolicy::kFilterAll",
type: "DarkModePagePolicy",
invalidate: "Paint",
},
{
name: "navigatorPlatformOverride",
type: "String",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment