Add command line switch to force prefers-reduced-motion
This enables users who are on platforms where we do not yet support
prefers-reduced-motion (primarily Linux) or where the user does not have
control over the system settings to launch Chrome in the
prefers-reduced-motion mode.
Bug: 929310
Change-Id: I1e6c1175911b769198aeb3a4f0e00da3ed9f3f80
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1671668
Reviewed-by: Sadrul Chowdhury <sadrul@chromium.org>
Reviewed-by: Alice Boxhall <aboxhall@chromium.org>
Commit-Queue: Stephen McGruer <smcgruer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#672344}
diff --git a/ui/gfx/animation/BUILD.gn b/ui/gfx/animation/BUILD.gn
index 8e3d773..81610e2 100644
--- a/ui/gfx/animation/BUILD.gn
+++ b/ui/gfx/animation/BUILD.gn
@@ -59,6 +59,7 @@
"//skia",
"//ui/gfx:geometry_skia",
"//ui/gfx:gfx_export",
+ "//ui/gfx:gfx_switches",
"//ui/gfx/geometry",
]
diff --git a/ui/gfx/animation/animation.cc b/ui/gfx/animation/animation.cc
index 92ae9cbf..096ed51 100644
--- a/ui/gfx/animation/animation.cc
+++ b/ui/gfx/animation/animation.cc
@@ -6,12 +6,14 @@
#include <memory>
+#include "base/command_line.h"
#include "base/message_loop/message_loop.h"
#include "build/build_config.h"
#include "ui/gfx/animation/animation_container.h"
#include "ui/gfx/animation/animation_delegate.h"
#include "ui/gfx/animation/tween.h"
#include "ui/gfx/geometry/rect.h"
+#include "ui/gfx/switches.h"
namespace gfx {
@@ -139,6 +141,10 @@
// static
bool Animation::PrefersReducedMotion() {
+ if (base::CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kForcePrefersReducedMotion)) {
+ return true;
+ }
if (!prefers_reduced_motion_)
UpdatePrefersReducedMotion();
return *prefers_reduced_motion_;
diff --git a/ui/gfx/switches.cc b/ui/gfx/switches.cc
index 189e147e..ba3dbf23 100644
--- a/ui/gfx/switches.cc
+++ b/ui/gfx/switches.cc
@@ -12,6 +12,10 @@
const char kDisableFontSubpixelPositioning[] =
"disable-font-subpixel-positioning";
+// Forces whether the user desires reduced motion, regardless of system
+// settings.
+const char kForcePrefersReducedMotion[] = "force-prefers-reduced-motion";
+
// Run in headless mode, i.e., without a UI or display server dependencies.
const char kHeadless[] = "headless";
diff --git a/ui/gfx/switches.h b/ui/gfx/switches.h
index c95989ae..1f0e6338 100644
--- a/ui/gfx/switches.h
+++ b/ui/gfx/switches.h
@@ -12,6 +12,8 @@
GFX_SWITCHES_EXPORT extern const char kDisableFontSubpixelPositioning[];
+GFX_SWITCHES_EXPORT extern const char kForcePrefersReducedMotion[];
+
GFX_SWITCHES_EXPORT extern const char kHeadless[];
GFX_SWITCHES_EXPORT extern const char kEnableNativeGpuMemoryBuffers[];