<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[282751] trunk/Source/WebCore</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/282751">282751</a></dd>
<dt>Author</dt> <dd>graouts@webkit.org</dd>
<dt>Date</dt> <dd>2021-09-20 09:26:27 -0700 (Mon, 20 Sep 2021)</dd>
</dl>

<h3>Log Message</h3>
<pre>TimingFunction::transformTime() is poorly-named
https://bugs.webkit.org/show_bug.cgi?id=230478

Reviewed by Simon Fraser.

This function transforms an input _progress_ not a time, so we rename it to transformProgress()
and name its first parameter accordingly.

* animation/AnimationEffect.cpp:
(WebCore::AnimationEffect::getComputedTiming const):
* animation/KeyframeEffect.cpp:
(WebCore::KeyframeEffect::setAnimatedPropertiesInStyle):
* platform/ScrollAnimationSmooth.cpp:
(WebCore::ScrollAnimationSmooth::animateScroll):
* platform/animation/TimingFunction.cpp:
(WebCore::TimingFunction::transformProgress const):
(WebCore::TimingFunction::transformTime const): Deleted.
* platform/animation/TimingFunction.h:
* platform/graphics/nicosia/NicosiaAnimation.cpp:
(Nicosia::Animation::apply):
* platform/mac/ScrollbarsControllerMac.mm:
(-[WebScrollbarPartAnimation setCurrentProgress:]):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreanimationAnimationEffectcpp">trunk/Source/WebCore/animation/AnimationEffect.cpp</a></li>
<li><a href="#trunkSourceWebCoreanimationKeyframeEffectcpp">trunk/Source/WebCore/animation/KeyframeEffect.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformScrollAnimationSmoothcpp">trunk/Source/WebCore/platform/ScrollAnimationSmooth.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformanimationTimingFunctioncpp">trunk/Source/WebCore/platform/animation/TimingFunction.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformanimationTimingFunctionh">trunk/Source/WebCore/platform/animation/TimingFunction.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsnicosiaNicosiaAnimationcpp">trunk/Source/WebCore/platform/graphics/nicosia/NicosiaAnimation.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformmacScrollbarsControllerMacmm">trunk/Source/WebCore/platform/mac/ScrollbarsControllerMac.mm</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (282750 => 282751)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog   2021-09-20 16:19:04 UTC (rev 282750)
+++ trunk/Source/WebCore/ChangeLog      2021-09-20 16:26:27 UTC (rev 282751)
</span><span class="lines">@@ -1,3 +1,28 @@
</span><ins>+2021-09-20  Antoine Quint  <graouts@webkit.org>
+
+        TimingFunction::transformTime() is poorly-named
+        https://bugs.webkit.org/show_bug.cgi?id=230478
+
+        Reviewed by Simon Fraser.
+
+        This function transforms an input _progress_ not a time, so we rename it to transformProgress()
+        and name its first parameter accordingly.
+
+        * animation/AnimationEffect.cpp:
+        (WebCore::AnimationEffect::getComputedTiming const):
+        * animation/KeyframeEffect.cpp:
+        (WebCore::KeyframeEffect::setAnimatedPropertiesInStyle):
+        * platform/ScrollAnimationSmooth.cpp:
+        (WebCore::ScrollAnimationSmooth::animateScroll):
+        * platform/animation/TimingFunction.cpp:
+        (WebCore::TimingFunction::transformProgress const):
+        (WebCore::TimingFunction::transformTime const): Deleted.
+        * platform/animation/TimingFunction.h:
+        * platform/graphics/nicosia/NicosiaAnimation.cpp:
+        (Nicosia::Animation::apply):
+        * platform/mac/ScrollbarsControllerMac.mm:
+        (-[WebScrollbarPartAnimation setCurrentProgress:]):
+
</ins><span class="cx"> 2021-09-20  Aditya Keerthi  <akeerthi@apple.com>
</span><span class="cx"> 
</span><span class="cx">         Implement input-security
</span></span></pre></div>
<a id="trunkSourceWebCoreanimationAnimationEffectcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/animation/AnimationEffect.cpp (282750 => 282751)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/animation/AnimationEffect.cpp       2021-09-20 16:19:04 UTC (rev 282750)
+++ trunk/Source/WebCore/animation/AnimationEffect.cpp  2021-09-20 16:26:27 UTC (rev 282751)
</span><span class="lines">@@ -326,7 +326,7 @@
</span><span class="cx"> 
</span><span class="cx">             // 3. Return the result of evaluating the animation effect’s timing function passing directed progress as the
</span><span class="cx">             //    input progress value and before flag as the before flag.
</span><del>-            return m_timingFunction->transformTime(*directedProgress, iterationDuration, before);
</del><ins>+            return m_timingFunction->transformProgress(*directedProgress, iterationDuration, before);
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         return *directedProgress;
</span></span></pre></div>
<a id="trunkSourceWebCoreanimationKeyframeEffectcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/animation/KeyframeEffect.cpp (282750 => 282751)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/animation/KeyframeEffect.cpp        2021-09-20 16:19:04 UTC (rev 282750)
+++ trunk/Source/WebCore/animation/KeyframeEffect.cpp   2021-09-20 16:26:27 UTC (rev 282751)
</span><span class="lines">@@ -1555,7 +1555,7 @@
</span><span class="cx">             if (auto duration = iterationDuration()) {
</span><span class="cx">                 auto rangeDuration = (endOffset - startOffset) * duration.seconds();
</span><span class="cx">                 if (auto* timingFunction = timingFunctionForKeyframeAtIndex(startKeyframeIndex.value()))
</span><del>-                    transformedDistance = timingFunction->transformTime(intervalDistance, rangeDuration);
</del><ins>+                    transformedDistance = timingFunction->transformProgress(intervalDistance, rangeDuration);
</ins><span class="cx">             }
</span><span class="cx">         }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformScrollAnimationSmoothcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/ScrollAnimationSmooth.cpp (282750 => 282751)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/ScrollAnimationSmooth.cpp  2021-09-20 16:19:04 UTC (rev 282750)
+++ trunk/Source/WebCore/platform/ScrollAnimationSmooth.cpp     2021-09-20 16:26:27 UTC (rev 282751)
</span><span class="lines">@@ -133,7 +133,7 @@
</span><span class="cx">     currentTime = std::min(currentTime, endTime);
</span><span class="cx"> 
</span><span class="cx">     double fractionComplete = (currentTime - m_startTime) / m_duration;
</span><del>-    double progress = m_easeInOutTimingFunction->transformTime(fractionComplete, m_duration.value());
</del><ins>+    double progress = m_easeInOutTimingFunction->transformProgress(fractionComplete, m_duration.value());
</ins><span class="cx"> 
</span><span class="cx">     m_currentOffset = {
</span><span class="cx">         linearInterpolation(progress, m_startOffset.x(), m_destinationOffset.x()),
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformanimationTimingFunctioncpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/animation/TimingFunction.cpp (282750 => 282751)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/animation/TimingFunction.cpp       2021-09-20 16:19:04 UTC (rev 282750)
+++ trunk/Source/WebCore/platform/animation/TimingFunction.cpp  2021-09-20 16:26:27 UTC (rev 282751)
</span><span class="lines">@@ -89,17 +89,17 @@
</span><span class="cx">     return ts;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-double TimingFunction::transformTime(double inputTime, double duration, bool before) const
</del><ins>+double TimingFunction::transformProgress(double progress, double duration, bool before) const
</ins><span class="cx"> {
</span><span class="cx">     switch (m_type) {
</span><span class="cx">     case TimingFunction::CubicBezierFunction: {
</span><span class="cx">         auto& function = downcast<CubicBezierTimingFunction>(*this);
</span><span class="cx">         if (function.isLinear())
</span><del>-            return inputTime;
</del><ins>+            return progress;
</ins><span class="cx">         // The epsilon value we pass to UnitBezier::solve given that the animation is going to run over |dur| seconds. The longer the
</span><span class="cx">         // animation, the more precision we need in the timing function result to avoid ugly discontinuities.
</span><span class="cx">         auto epsilon = 1.0 / (1000.0 * duration);
</span><del>-        return UnitBezier(function.x1(), function.y1(), function.x2(), function.y2()).solve(inputTime, epsilon);
</del><ins>+        return UnitBezier(function.x1(), function.y1(), function.x2(), function.y2()).solve(progress, epsilon);
</ins><span class="cx">     }
</span><span class="cx">     case TimingFunction::StepsFunction: {
</span><span class="cx">         // https://drafts.csswg.org/css-easing-1/#step-timing-functions
</span><span class="lines">@@ -107,7 +107,7 @@
</span><span class="cx">         auto steps = function.numberOfSteps();
</span><span class="cx">         auto stepPosition = function.stepPosition();
</span><span class="cx">         // 1. Calculate the current step as floor(input progress value × steps).
</span><del>-        auto currentStep = std::floor(inputTime * steps);
</del><ins>+        auto currentStep = std::floor(progress * steps);
</ins><span class="cx">         // 2. If the step position property is start, increment current step by one.
</span><span class="cx">         if (stepPosition == StepsTimingFunction::StepPosition::JumpStart || stepPosition == StepsTimingFunction::StepPosition::Start || stepPosition == StepsTimingFunction::StepPosition::JumpBoth)
</span><span class="cx">             ++currentStep;
</span><span class="lines">@@ -115,10 +115,10 @@
</span><span class="cx">         //    - the before flag is set, and
</span><span class="cx">         //    - input progress value × steps mod 1 equals zero (that is, if input progress value × steps is integral), then
</span><span class="cx">         //    decrement current step by one.
</span><del>-        if (before && !fmod(inputTime * steps, 1))
</del><ins>+        if (before && !fmod(progress * steps, 1))
</ins><span class="cx">             currentStep--;
</span><span class="cx">         // 4. If input progress value ≥ 0 and current step < 0, let current step be zero.
</span><del>-        if (inputTime >= 0 && currentStep < 0)
</del><ins>+        if (progress >= 0 && currentStep < 0)
</ins><span class="cx">             currentStep = 0;
</span><span class="cx">         // 5. Calculate jumps based on the step position.
</span><span class="cx">         if (stepPosition == StepsTimingFunction::StepPosition::JumpNone)
</span><span class="lines">@@ -126,7 +126,7 @@
</span><span class="cx">         else if (stepPosition == StepsTimingFunction::StepPosition::JumpBoth)
</span><span class="cx">             ++steps;
</span><span class="cx">         // 6. If input progress value ≤ 1 and current step > jumps, let current step be jumps.
</span><del>-        if (inputTime <= 1 && currentStep > steps)
</del><ins>+        if (progress <= 1 && currentStep > steps)
</ins><span class="cx">             currentStep = steps;
</span><span class="cx">         // 7. The output progress value is current step / jumps.
</span><span class="cx">         return currentStep / steps;
</span><span class="lines">@@ -133,10 +133,10 @@
</span><span class="cx">     }
</span><span class="cx">     case TimingFunction::SpringFunction: {
</span><span class="cx">         auto& function = downcast<SpringTimingFunction>(*this);
</span><del>-        return SpringSolver(function.mass(), function.stiffness(), function.damping(), function.initialVelocity()).solve(inputTime * duration);
</del><ins>+        return SpringSolver(function.mass(), function.stiffness(), function.damping(), function.initialVelocity()).solve(progress * duration);
</ins><span class="cx">     }
</span><span class="cx">     case TimingFunction::LinearFunction:
</span><del>-        return inputTime;
</del><ins>+        return progress;
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     ASSERT_NOT_REACHED();
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformanimationTimingFunctionh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/animation/TimingFunction.h (282750 => 282751)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/animation/TimingFunction.h 2021-09-20 16:19:04 UTC (rev 282750)
+++ trunk/Source/WebCore/platform/animation/TimingFunction.h    2021-09-20 16:26:27 UTC (rev 282751)
</span><span class="lines">@@ -55,7 +55,7 @@
</span><span class="cx"> 
</span><span class="cx">     static ExceptionOr<RefPtr<TimingFunction>> createFromCSSText(const String&);
</span><span class="cx">     static RefPtr<TimingFunction> createFromCSSValue(const CSSValue&);
</span><del>-    double transformTime(double, double, bool before = false) const;
</del><ins>+    double transformProgress(double progress, double duration, bool before = false) const;
</ins><span class="cx">     String cssText() const;
</span><span class="cx"> 
</span><span class="cx"> protected:
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsnicosiaNicosiaAnimationcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/nicosia/NicosiaAnimation.cpp (282750 => 282751)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/nicosia/NicosiaAnimation.cpp      2021-09-20 16:19:04 UTC (rev 282750)
+++ trunk/Source/WebCore/platform/graphics/nicosia/NicosiaAnimation.cpp 2021-09-20 16:26:27 UTC (rev 282751)
</span><span class="lines">@@ -248,7 +248,7 @@
</span><span class="cx">     }
</span><span class="cx">     if (m_keyframes.size() == 2) {
</span><span class="cx">         auto& timingFunction = timingFunctionForAnimationValue(m_keyframes.at(0), *this);
</span><del>-        normalizedValue = timingFunction.transformTime(normalizedValue, m_duration);
</del><ins>+        normalizedValue = timingFunction.transformProgress(normalizedValue, m_duration);
</ins><span class="cx">         applyInternal(applicationResults, m_keyframes.at(0), m_keyframes.at(1), normalizedValue);
</span><span class="cx">         return;
</span><span class="cx">     }
</span><span class="lines">@@ -261,7 +261,7 @@
</span><span class="cx"> 
</span><span class="cx">         normalizedValue = (normalizedValue - from.keyTime()) / (to.keyTime() - from.keyTime());
</span><span class="cx">         auto& timingFunction = timingFunctionForAnimationValue(from, *this);
</span><del>-        normalizedValue = timingFunction.transformTime(normalizedValue, m_duration);
</del><ins>+        normalizedValue = timingFunction.transformProgress(normalizedValue, m_duration);
</ins><span class="cx">         applyInternal(applicationResults, from, to, normalizedValue);
</span><span class="cx">         break;
</span><span class="cx">     }
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformmacScrollbarsControllerMacmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/mac/ScrollbarsControllerMac.mm (282750 => 282751)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mac/ScrollbarsControllerMac.mm     2021-09-20 16:19:04 UTC (rev 282750)
+++ trunk/Source/WebCore/platform/mac/ScrollbarsControllerMac.mm        2021-09-20 16:26:27 UTC (rev 282751)
</span><span class="lines">@@ -261,7 +261,7 @@
</span><span class="cx">         NSTimeInterval t = 1;
</span><span class="cx">         if (_duration)
</span><span class="cx">             t = elapsed / _duration;
</span><del>-        progress = _timingFunction->transformTime(t, _duration);
</del><ins>+        progress = _timingFunction->transformProgress(t, _duration);
</ins><span class="cx">     }
</span><span class="cx">     ASSERT(_scrollbar);
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>