Title: [272665] trunk/Source/WebCore
Revision
272665
Author
akeer...@apple.com
Date
2021-02-10 11:27:35 -0800 (Wed, 10 Feb 2021)

Log Message

[iOS][FCR] Add reduced motion animation for indeterminate progress bars
https://bugs.webkit.org/show_bug.cgi?id=221680
<rdar://problem/74191515>

Reviewed by Wenson Hsieh.

The reduced motion animation for indeterminate progress bars is an
opacity pulse from 30% to 60%.

* rendering/RenderThemeIOS.mm:
(WebCore::RenderThemeIOS::paintProgressBarWithFormControlRefresh):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (272664 => 272665)


--- trunk/Source/WebCore/ChangeLog	2021-02-10 19:01:15 UTC (rev 272664)
+++ trunk/Source/WebCore/ChangeLog	2021-02-10 19:27:35 UTC (rev 272665)
@@ -1,3 +1,17 @@
+2021-02-10  Aditya Keerthi  <akeer...@apple.com>
+
+        [iOS][FCR] Add reduced motion animation for indeterminate progress bars
+        https://bugs.webkit.org/show_bug.cgi?id=221680
+        <rdar://problem/74191515>
+
+        Reviewed by Wenson Hsieh.
+
+        The reduced motion animation for indeterminate progress bars is an
+        opacity pulse from 30% to 60%.
+
+        * rendering/RenderThemeIOS.mm:
+        (WebCore::RenderThemeIOS::paintProgressBarWithFormControlRefresh):
+
 2021-02-10  Antti Koivisto  <an...@apple.com>
 
         [LFC][Integration] Paint invalidation for inline element style changes

Modified: trunk/Source/WebCore/rendering/RenderThemeIOS.mm (272664 => 272665)


--- trunk/Source/WebCore/rendering/RenderThemeIOS.mm	2021-02-10 19:01:15 UTC (rev 272664)
+++ trunk/Source/WebCore/rendering/RenderThemeIOS.mm	2021-02-10 19:27:35 UTC (rev 272665)
@@ -70,6 +70,7 @@
 #import "RenderView.h"
 #import "RuntimeEnabledFeatures.h"
 #import "Settings.h"
+#import "Theme.h"
 #import "UTIUtilities.h"
 #import "UserAgentScripts.h"
 #import "UserAgentStyleSheets.h"
@@ -2142,6 +2143,9 @@
 // progress bar is repainted.
 constexpr Seconds progressAnimationRepeatInterval = 33_ms;
 
+constexpr auto reducedMotionProgressAnimationMinOpacity = 0.3f;
+constexpr auto reducedMotionProgressAnimationMaxOpacity = 0.6f;
+
 Seconds RenderThemeIOS::animationRepeatIntervalForProgressBar(const RenderProgress& renderProgress) const
 {
     if (!renderProgress.settings().iOSFormControlRefreshEnabled())
@@ -2176,6 +2180,7 @@
 
     float barWidth;
     float barLeft = rect.x();
+    float alpha = 1.0f;
 
     if (renderProgress.isDeterminate()) {
         barWidth = clampTo<float>(renderProgress.position(), 0.0f, 1.0f) * trackRect.width();
@@ -2183,23 +2188,33 @@
         if (!renderProgress.style().isLeftToRightDirection())
             barLeft = trackRect.maxX() - barWidth;
     } else {
-        barWidth = 0.25f * trackRect.width();
-
         Seconds elapsed = MonotonicTime::now() - renderProgress.animationStartTime();
         float position = fmodf(elapsed.value(), 1.0f);
-        float offset = position * (trackRect.width() + barWidth);
-
         bool reverseDirection = static_cast<int>(elapsed.value()) % 2;
-        if (reverseDirection)
-            barLeft = trackRect.maxX() - offset;
-        else
-            barLeft -= barWidth - offset;
 
-        context.clipRoundedRect(roundedTrackRect);
+        if (Theme::singleton().userPrefersReducedMotion()) {
+            barWidth = trackRect.width();
+
+            float difference = position * (reducedMotionProgressAnimationMaxOpacity - reducedMotionProgressAnimationMinOpacity);
+            if (reverseDirection)
+                alpha = reducedMotionProgressAnimationMaxOpacity - difference;
+            else
+                alpha = reducedMotionProgressAnimationMinOpacity + difference;
+        } else {
+            barWidth = 0.25f * trackRect.width();
+
+            float offset = position * (trackRect.width() + barWidth);
+            if (reverseDirection)
+                barLeft = trackRect.maxX() - offset;
+            else
+                barLeft -= barWidth - offset;
+
+            context.clipRoundedRect(roundedTrackRect);
+        }
     }
 
     FloatRect barRect(barLeft, barTop, barWidth, barHeight);
-    context.fillRoundedRect(FloatRoundedRect(barRect, barCornerRadii), controlColor);
+    context.fillRoundedRect(FloatRoundedRect(barRect, barCornerRadii), controlColor.colorWithAlphaByte(alpha * 255.0f));
 
     return false;
 }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to