Changeset 224163 in webkit
- Timestamp:
- Oct 29, 2017 1:22:34 PM (6 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r224158 r224163 1 2017-10-29 Antoine Quint <graouts@apple.com> 2 3 [Web Animations] Expose the currentTime property on Animation 4 https://bugs.webkit.org/show_bug.cgi?id=178988 5 6 Reviewed by Dean Jackson. 7 8 Add a new test that checks that the currentTime property is set 9 correctly based on the startTime value and the document timeline 10 currentTime, and that setting the property may raise an exception 11 and otherwise update the animation startTime. 12 13 * webanimations/animation-current-time-expected.txt: Added. 14 * webanimations/animation-current-time.html: Added. 15 1 16 2017-10-28 Dean Jackson <dino@apple.com> 2 17 -
trunk/Source/WebCore/ChangeLog
r224159 r224163 1 2017-10-29 Antoine Quint <graouts@apple.com> 2 3 [Web Animations] Expose the currentTime property on Animation 4 https://bugs.webkit.org/show_bug.cgi?id=178988 5 6 Reviewed by Dean Jackson. 7 8 We now expose the currentTime property on Animation objects, our first 9 step in implementing the Web Animations timing model, specifically section 10 3.5.4. "The current time of an animation" and section 3.5.5. "Setting the 11 current time of an animation". Setting the startTime has implications on 12 currentTime and vice-versa. 13 14 Test: webanimations/animation-current-time.html 15 16 * animation/WebAnimation.cpp: 17 (WebCore::WebAnimation::setBindingsStartTime): 18 (WebCore::WebAnimation::startTime const): 19 (WebCore::WebAnimation::setStartTime): 20 (WebCore::WebAnimation::bindingsCurrentTime const): 21 (WebCore::WebAnimation::setBindingsCurrentTime): 22 (WebCore::WebAnimation::currentTime const): 23 (WebCore::WebAnimation::setCurrentTime): 24 * animation/WebAnimation.h: 25 * animation/WebAnimation.idl: 26 1 27 2017-10-29 Ryosuke Niwa <rniwa@webkit.org> 2 28 -
trunk/Source/WebCore/animation/WebAnimation.cpp
r224127 r224163 69 69 { 70 70 if (startTime == std::nullopt) 71 m_startTime = std::nullopt;71 setStartTime(std::nullopt); 72 72 else 73 m_startTime = Seconds(startTime.value()); 73 setStartTime(Seconds(startTime.value())); 74 } 75 76 std::optional<Seconds> WebAnimation::startTime() const 77 { 78 return m_startTime; 79 } 80 81 void WebAnimation::setStartTime(std::optional<Seconds> startTime) 82 { 83 if (startTime == m_startTime) 84 return; 85 86 m_startTime = startTime; 87 } 88 89 std::optional<double> WebAnimation::bindingsCurrentTime() const 90 { 91 auto time = currentTime(); 92 if (!time) 93 return std::nullopt; 94 return time->value(); 95 } 96 97 ExceptionOr<void> WebAnimation::setBindingsCurrentTime(std::optional<double> currentTime) 98 { 99 if (!currentTime) 100 return Exception { TypeError }; 101 setCurrentTime(Seconds(currentTime.value())); 102 return { }; 103 } 104 105 std::optional<Seconds> WebAnimation::currentTime() const 106 { 107 // FIXME: return the hold time when we support pausing (webkit.org/b/178932). 108 109 if (!m_timeline || !m_startTime) 110 return std::nullopt; 111 112 auto timelineTime = m_timeline->currentTime(); 113 if (!timelineTime) 114 return std::nullopt; 115 116 // FIXME: account for playback rate when we support it (webkit.org/b/178931). 117 return timelineTime.value() - m_startTime.value(); 118 } 119 120 void WebAnimation::setCurrentTime(std::optional<Seconds> seekTime) 121 { 122 // FIXME: account for hold time when we support it (webkit.org/b/178932). 123 124 if (!m_timeline) { 125 setStartTime(std::nullopt); 126 return; 127 } 128 129 std::optional<Seconds> timelineTime = m_timeline->currentTime(); 130 if (timelineTime == std::nullopt) { 131 setStartTime(std::nullopt); 132 return; 133 } 134 135 // FIXME: account for playback rate when we support it (webkit.org/b/178931). 136 setStartTime(timelineTime.value() - seekTime.value()); 74 137 } 75 138 -
trunk/Source/WebCore/animation/WebAnimation.h
r224127 r224163 26 26 #pragma once 27 27 28 #include "ExceptionOr.h" 28 29 #include <wtf/Forward.h> 29 30 #include <wtf/Optional.h> … … 46 47 void setEffect(RefPtr<AnimationEffect>&&); 47 48 AnimationTimeline* timeline() const { return m_timeline.get(); } 49 48 50 std::optional<double> bindingsStartTime() const; 49 51 void setBindingsStartTime(std::optional<double>); 50 std::optional<Seconds> startTime() const { return m_startTime; } 51 void setStartTime(Seconds startTime) { m_startTime = startTime; } 52 std::optional<Seconds> startTime() const; 53 void setStartTime(std::optional<Seconds>); 54 55 std::optional<double> bindingsCurrentTime() const; 56 ExceptionOr<void> setBindingsCurrentTime(std::optional<double>); 57 std::optional<Seconds> currentTime() const; 58 void setCurrentTime(std::optional<Seconds>); 52 59 53 60 String description(); … … 55 62 private: 56 63 WebAnimation(AnimationTimeline*); 64 57 65 RefPtr<AnimationEffect> m_effect; 58 66 RefPtr<AnimationTimeline> m_timeline; -
trunk/Source/WebCore/animation/WebAnimation.idl
r223883 r224163 33 33 readonly attribute AnimationTimeline? timeline; 34 34 [ImplementedAs=bindingsStartTime] attribute double? startTime; 35 [MayThrowException, ImplementedAs=bindingsCurrentTime] attribute double? currentTime; 35 36 };
Note: See TracChangeset
for help on using the changeset viewer.