Commit b060d29d authored by Majid Valipour's avatar Majid Valipour Committed by Commit Bot

[animation-worklet] Add comment re potential precision loss in time conversion

Bug: 827194
Change-Id: Ib21f0c55e2a196f75f3aa27ee0d0bc997a5b4bd1
Reviewed-on: https://chromium-review.googlesource.com/986750
Commit-Queue: Majid Valipour <majidvp@chromium.org>
Reviewed-by: default avatarRobert Flack <flackr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#549860}
parent 19ac07e5
...@@ -19,8 +19,17 @@ class MODULES_EXPORT EffectProxy : public ScriptWrappable { ...@@ -19,8 +19,17 @@ class MODULES_EXPORT EffectProxy : public ScriptWrappable {
public: public:
EffectProxy() = default; EffectProxy() = default;
void setLocalTime(double time) { void setLocalTime(double time_ms) {
local_time_ = WTF::TimeDelta::FromMillisecondsD(time); // Convert double to TimeDelta because cc/animation expects TimeDelta.
//
// Note on precision loss: TimeDelta has microseconds precision which is
// also the precision recommended by the web animation specification as well
// [1]. If the input time value has a bigger precision then the conversion
// causes precision loss. Doing the conversion here ensures that reading the
// value back provides the actual value we use in further computation which
// is the least surprising path.
// [1] https://drafts.csswg.org/web-animations/#precision-of-time-values
local_time_ = WTF::TimeDelta::FromMillisecondsD(time_ms);
} }
double localTime() const { return local_time_.InMillisecondsF(); } double localTime() const { return local_time_.InMillisecondsF(); }
......
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