Chromium Code Reviews| Index: Source/core/animation/TimedItemTiming.cpp |
| diff --git a/Source/core/animation/TimedItemTiming.cpp b/Source/core/animation/TimedItemTiming.cpp |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..88332ef7b914883ad6b41175b640e60dde5c98bb |
| --- /dev/null |
| +++ b/Source/core/animation/TimedItemTiming.cpp |
| @@ -0,0 +1,103 @@ |
| +// Copyright 2014 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "config.h" |
| +#include "core/animation/TimedItemTiming.h" |
| + |
| +#include "core/animation/TimedItem.h" |
| +#include "platform/animation/TimingFunction.h" |
| + |
| +namespace WebCore { |
| + |
| +PassRefPtr<TimedItemTiming> TimedItemTiming::create(TimedItem* parent) |
| +{ |
| + return adoptRef(new TimedItemTiming(parent)); |
| +} |
| + |
| +TimedItemTiming::TimedItemTiming(TimedItem* parent) |
| +: m_parent(parent) |
| +{ |
| +} |
| + |
| +double TimedItemTiming::delay() |
| +{ |
| + return m_parent->specifiedTiming().startDelay; |
| +} |
| + |
| +String TimedItemTiming::fill() |
| +{ |
| + Timing::FillMode fillMode = m_parent->specifiedTiming().fillMode; |
| + switch (fillMode) { |
| + case Timing::FillModeNone: |
| + return "none"; |
| + case Timing::FillModeForwards: |
| + return "forwards"; |
| + case Timing::FillModeBackwards: |
| + return "backwards"; |
| + case Timing::FillModeBoth: |
| + return "both"; |
| + default: |
| + break; |
| + } |
| + return "auto"; |
| +} |
| + |
| +double TimedItemTiming::iterationStart() |
| +{ |
| + return m_parent->specifiedTiming().iterationStart; |
| +} |
| + |
| +double TimedItemTiming::iterations() |
| +{ |
| + return m_parent->specifiedTiming().iterationCount; |
| +} |
| + |
| +// This logic was copied from the example in bindings/tests/idls/TestInterface.idl |
| +// and bindings/tests/results/V8TestInterface.cpp. |
| +// FIXME: It might be possible to have 'duration' defined as an attribute in the idl. |
| +// If possible, fix will be in a follow-up patch. |
| +void TimedItemTiming::duration(String propertyName, bool& element0Enabled, double& element0, bool& element1Enabled, String& element1) |
| +{ |
| + if (propertyName != "duration") |
| + return; |
| + |
| + if (std::isnan(m_parent->specifiedTiming().iterationDuration)) { |
| + element1Enabled = true; |
| + element1 = "auto"; |
| + return; |
| + } |
| + element0Enabled = true; |
| + element0 = m_parent->specifiedTiming().iterationDuration; |
| + return; |
| +} |
| + |
| +double TimedItemTiming::playbackRate() |
| +{ |
| + return m_parent->specifiedTiming().playbackRate; |
| +} |
| + |
| +String TimedItemTiming::direction() |
| +{ |
| + Timing::PlaybackDirection direction = m_parent->specifiedTiming().direction; |
| + switch (direction) { |
| + case Timing::PlaybackDirectionNormal: |
| + return "normal"; |
| + case Timing::PlaybackDirectionReverse: |
| + return "reverse"; |
| + case Timing::PlaybackDirectionAlternate: |
| + return "alternate"; |
| + case Timing::PlaybackDirectionAlternateReverse: |
| + return "alternate-reverse"; |
| + default: |
|
dstockwell
2014/02/12 08:02:28
do we need default?
rjwright
2014/02/13 01:04:49
Done.
|
| + break; |
| + } |
| + 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.
|
| +} |
| + |
| +String TimedItemTiming::easing() |
| +{ |
| + return m_parent->specifiedTiming().timingFunction->toString(); |
| +} |
| + |
| +} // namespace WebCore |