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

Unified 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: Fix timed-item-specified-getters.html (mashed in rebase) 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/animation/TimedItemTiming.h ('k') | Source/core/animation/Timing.idl » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..8f7e14e4c6dad4c62182039cde4513fa646e1e23
--- /dev/null
+++ b/Source/core/animation/TimedItemTiming.cpp
@@ -0,0 +1,108 @@
+// 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;
+}
+
+double TimedItemTiming::endDelay()
+{
+ return m_parent->specifiedTiming().endDelay;
+}
+
+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";
+ case Timing::FillModeAuto:
+ return "auto";
+ }
+ ASSERT_NOT_REACHED();
+ 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";
+ }
+ ASSERT_NOT_REACHED();
+ return "normal";
+}
+
+String TimedItemTiming::easing()
+{
+ return m_parent->specifiedTiming().timingFunction->toString();
+}
+
+} // namespace WebCore
« no previous file with comments | « Source/core/animation/TimedItemTiming.h ('k') | Source/core/animation/Timing.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698