Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(336)

Side by Side Diff: Source/core/animation/TimedItemTiming.cpp

Issue 152853003: Web Animations API: Bindings for TimedItem.specified with readonly attributes (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Small cleanup Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "config.h"
6 #include "core/animation/TimedItemTiming.h"
7
8 #include "core/animation/TimedItem.h"
9 #include "platform/animation/TimingFunction.h"
10
11 namespace WebCore {
12
13 PassRefPtr<TimedItemTiming> TimedItemTiming::create(TimedItem* parent)
14 {
15 return adoptRef(new TimedItemTiming(parent));
16 }
17
18 TimedItemTiming::TimedItemTiming(TimedItem* parent)
19 : m_parent(parent)
20 {
21 }
22
23 double TimedItemTiming::delay()
24 {
25 return m_parent->specifiedTiming().startDelay;
26 }
27
28 String TimedItemTiming::fill()
29 {
30 Timing::FillMode fillMode = m_parent->specifiedTiming().fillMode;
31 switch (fillMode) {
32 case Timing::FillModeNone:
33 return "none";
34 case Timing::FillModeForwards:
35 return "forwards";
36 case Timing::FillModeBackwards:
37 return "backwards";
38 case Timing::FillModeBoth:
39 return "both";
40 default:
41 break;
42 }
43 return "auto";
44 }
45
46 double TimedItemTiming::iterationStart()
47 {
48 return m_parent->specifiedTiming().iterationStart;
49 }
50
51 double TimedItemTiming::iterations()
52 {
53 return m_parent->specifiedTiming().iterationCount;
54 }
55
56 // This logic was copied from the example in bindings/tests/idls/TestInterface.i dl
57 // and bindings/tests/results/V8TestInterface.cpp.
58 // FIXME: It might be possible to have 'duration' defined as an attribute in the idl.
59 // If possible, fix will be in a follow-up patch.
60 void TimedItemTiming::duration(String propertyName, bool& element0Enabled, doubl e& element0, bool& element1Enabled, String& element1)
61 {
62 if (propertyName != "duration")
63 return;
64
65 if (std::isnan(m_parent->specifiedTiming().iterationDuration)) {
66 element1Enabled = true;
67 element1 = "auto";
68 return;
69 }
70 element0Enabled = true;
71 element0 = m_parent->specifiedTiming().iterationDuration;
72 return;
73 }
74
75 double TimedItemTiming::playbackRate()
76 {
77 return m_parent->specifiedTiming().playbackRate;
78 }
79
80 String TimedItemTiming::direction()
81 {
82 Timing::PlaybackDirection direction = m_parent->specifiedTiming().direction;
83 switch (direction) {
84 case Timing::PlaybackDirectionNormal:
85 return "normal";
86 case Timing::PlaybackDirectionReverse:
87 return "reverse";
88 case Timing::PlaybackDirectionAlternate:
89 return "alternate";
90 case Timing::PlaybackDirectionAlternateReverse:
91 return "alternate-reverse";
92 default:
dstockwell 2014/02/12 08:02:28 do we need default?
rjwright 2014/02/13 01:04:49 Done.
93 break;
94 }
95 return "normal";
dstockwell 2014/02/12 08:02:28 ASSERT_NOT_REACHED (same comments for fill above)
rjwright 2014/02/13 01:04:49 Done.
96 }
97
98 String TimedItemTiming::easing()
99 {
100 return m_parent->specifiedTiming().timingFunction->toString();
101 }
102
103 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698