OLD | NEW |
(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 double TimedItemTiming::endDelay() |
| 29 { |
| 30 return m_parent->specifiedTiming().endDelay; |
| 31 } |
| 32 |
| 33 String TimedItemTiming::fill() |
| 34 { |
| 35 Timing::FillMode fillMode = m_parent->specifiedTiming().fillMode; |
| 36 switch (fillMode) { |
| 37 case Timing::FillModeNone: |
| 38 return "none"; |
| 39 case Timing::FillModeForwards: |
| 40 return "forwards"; |
| 41 case Timing::FillModeBackwards: |
| 42 return "backwards"; |
| 43 case Timing::FillModeBoth: |
| 44 return "both"; |
| 45 case Timing::FillModeAuto: |
| 46 return "auto"; |
| 47 } |
| 48 ASSERT_NOT_REACHED(); |
| 49 return "auto"; |
| 50 } |
| 51 |
| 52 double TimedItemTiming::iterationStart() |
| 53 { |
| 54 return m_parent->specifiedTiming().iterationStart; |
| 55 } |
| 56 |
| 57 double TimedItemTiming::iterations() |
| 58 { |
| 59 return m_parent->specifiedTiming().iterationCount; |
| 60 } |
| 61 |
| 62 // This logic was copied from the example in bindings/tests/idls/TestInterface.i
dl |
| 63 // and bindings/tests/results/V8TestInterface.cpp. |
| 64 // FIXME: It might be possible to have 'duration' defined as an attribute in the
idl. |
| 65 // If possible, fix will be in a follow-up patch. |
| 66 void TimedItemTiming::duration(String propertyName, bool& element0Enabled, doubl
e& element0, bool& element1Enabled, String& element1) |
| 67 { |
| 68 if (propertyName != "duration") |
| 69 return; |
| 70 |
| 71 if (std::isnan(m_parent->specifiedTiming().iterationDuration)) { |
| 72 element1Enabled = true; |
| 73 element1 = "auto"; |
| 74 return; |
| 75 } |
| 76 element0Enabled = true; |
| 77 element0 = m_parent->specifiedTiming().iterationDuration; |
| 78 return; |
| 79 } |
| 80 |
| 81 double TimedItemTiming::playbackRate() |
| 82 { |
| 83 return m_parent->specifiedTiming().playbackRate; |
| 84 } |
| 85 |
| 86 String TimedItemTiming::direction() |
| 87 { |
| 88 Timing::PlaybackDirection direction = m_parent->specifiedTiming().direction; |
| 89 switch (direction) { |
| 90 case Timing::PlaybackDirectionNormal: |
| 91 return "normal"; |
| 92 case Timing::PlaybackDirectionReverse: |
| 93 return "reverse"; |
| 94 case Timing::PlaybackDirectionAlternate: |
| 95 return "alternate"; |
| 96 case Timing::PlaybackDirectionAlternateReverse: |
| 97 return "alternate-reverse"; |
| 98 } |
| 99 ASSERT_NOT_REACHED(); |
| 100 return "normal"; |
| 101 } |
| 102 |
| 103 String TimedItemTiming::easing() |
| 104 { |
| 105 return m_parent->specifiedTiming().timingFunction->toString(); |
| 106 } |
| 107 |
| 108 } // namespace WebCore |
OLD | NEW |