Improve Forced Colors Invalidation for Page Color Block List
This CL addresses an issue where changes in Forced Colors mode could
lead to duplicate invalidations and subsequent repainting.
Specifically, a forced colors invalidation can be triggered as a
result of two events:
1.) The forced colors web preference changing
2.) The color providers in Blink updating
The issue was that not only was the page being repainted more than
required for a single change, but also, if the order of repainting was
incorrect, it could result in a brief display of incorrect colors. For
instance, if repainting was triggered by a change in the forced colors
web pref before the color providers in Blink were updated, the page
could momentarily display incorrect colors.
The key steps taken are:
1.) Removing invalidation from the `inForcedColors` web pref: The
invalidation method associated with the `inForcedColors preference` in
settings.json5 was removed. This ensured that forced colors web pref
changes no longer triggered repaints.
2.) Handling Page Colors Block List Changes: The page colors block list
allows users to opt out of forced colors mode for specific sites.
Previously, this feature relied on the `inForcedColors` web pref
invalidation. With this change, a consistent way to handle changes to
the block list is established by:
a.) Introducing a new web pref, `isForcedColorsDisabled`, specifically
for the block list scenario
b.) Adding a custom invalidation method for Forced Colors, used to
invalidate when the `isForcedColorsDisabled` pref changes
3.) Updating Blink Tests: Relevant Blink tests were also updated.
Previously, these tests relied on invalidation triggered by the
forced colors web pref. Now, they directly invalidate from the
Document.
Bug: 40779801
Change-Id: I2fde82bf6d1511b1c882d00523e6faf6c9278b37
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5651705
Reviewed-by: danakj <[email protected]>
Reviewed-by: Alison Maher <[email protected]>
Commit-Queue: Sam Davis Omekara <[email protected]>
Reviewed-by: Benjamin Beaudry <[email protected]>
Reviewed-by: Dominic Battré <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1328347}
diff --git a/chrome/browser/prefs/browser_prefs.cc b/chrome/browser/prefs/browser_prefs.cc
index a9e8315..f20578f 100644
--- a/chrome/browser/prefs/browser_prefs.cc
+++ b/chrome/browser/prefs/browser_prefs.cc
@@ -19,6 +19,7 @@
#include "chrome/browser/about_flags.h"
#include "chrome/browser/accessibility/accessibility_labels_service.h"
#include "chrome/browser/accessibility/invert_bubble_prefs.h"
+#include "chrome/browser/accessibility/page_colors.h"
#include "chrome/browser/accessibility/prefers_default_scrollbar_styles_prefs.h"
#include "chrome/browser/browser_process_impl.h"
#include "chrome/browser/chrome_content_browser_client.h"
@@ -1901,6 +1902,7 @@
ntp_tiles::MostVisitedSites::RegisterProfilePrefs(registry);
optimization_guide::prefs::RegisterProfilePrefs(registry);
optimization_guide::model_execution::prefs::RegisterProfilePrefs(registry);
+ PageColors::RegisterProfilePrefs(registry);
password_manager::PasswordManager::RegisterProfilePrefs(registry);
payments::RegisterProfilePrefs(registry);
performance_manager::user_tuning::prefs::RegisterProfilePrefs(registry);