Commit e90092de authored by Alan Cutter's avatar Alan Cutter Committed by Commit Bot

Respect "prefers reduced motion" option in the location bar by disabling icon label animations

This CL updates label icons to no longer perform the text "slide"
animation when the OS accessibility setting "prefers reduced motion"
is enabled.

Before:
https://bugs.chromium.org/p/chromium/issues/attachment?aid=417373&signed_aid=t0VJYHPUtkw0z1lDKkbiVA==&inline=1
After:
https://bugs.chromium.org/p/chromium/issues/attachment?aid=417374&signed_aid=5yX5WthdugQRYA75A6Ua8A==&inline=1

Change-Id: I79ede8bfec7c0c13b9678e2374ba16ec1aefee7e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1871504
Commit-Queue: Alan Cutter <alancutter@chromium.org>
Reviewed-by: default avatarEvan Stade <estade@chromium.org>
Reviewed-by: default avatarRobert Flack <flackr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#708441}
parent c6700b84
...@@ -211,6 +211,11 @@ bool IconLabelBubbleView::ShouldShowSeparator() const { ...@@ -211,6 +211,11 @@ bool IconLabelBubbleView::ShouldShowSeparator() const {
} }
double IconLabelBubbleView::WidthMultiplier() const { double IconLabelBubbleView::WidthMultiplier() const {
// TODO(https://crbug.com/8944): Disable animations globally instead of having
// piecemeal opt ins for respecting prefers reduced motion.
if (gfx::Animation::PrefersReducedMotion())
return 1.0;
if (!slide_animation_.is_animating() && !is_animation_paused_) if (!slide_animation_.is_animating() && !is_animation_paused_)
return 1.0; return 1.0;
......
...@@ -141,13 +141,15 @@ void Animation::UpdatePrefersReducedMotion() { ...@@ -141,13 +141,15 @@ void Animation::UpdatePrefersReducedMotion() {
// static // static
bool Animation::PrefersReducedMotion() { bool Animation::PrefersReducedMotion() {
if (!prefers_reduced_motion_.has_value()) {
if (base::CommandLine::ForCurrentProcess()->HasSwitch( if (base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kForcePrefersReducedMotion)) { switches::kForcePrefersReducedMotion)) {
return true; prefers_reduced_motion_ = true;
} } else {
if (!prefers_reduced_motion_)
UpdatePrefersReducedMotion(); UpdatePrefersReducedMotion();
return *prefers_reduced_motion_; }
}
return prefers_reduced_motion_.value();
} }
bool Animation::ShouldSendCanceledFromStop() { bool Animation::ShouldSendCanceledFromStop() {
......
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