summaryrefslogtreecommitdiff
path: root/Source/WebCore/animation
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebCore/animation')
-rw-r--r--Source/WebCore/animation/Animatable.idl38
-rw-r--r--Source/WebCore/animation/AnimationEffect.cpp65
-rw-r--r--Source/WebCore/animation/AnimationEffect.h55
-rw-r--r--Source/WebCore/animation/AnimationEffect.idl36
-rw-r--r--Source/WebCore/animation/AnimationTimeline.cpp81
-rw-r--r--Source/WebCore/animation/AnimationTimeline.h80
-rw-r--r--Source/WebCore/animation/AnimationTimeline.idl36
-rw-r--r--Source/WebCore/animation/DocumentAnimation.cpp113
-rw-r--r--Source/WebCore/animation/DocumentAnimation.h68
-rw-r--r--Source/WebCore/animation/DocumentAnimation.idl35
-rw-r--r--Source/WebCore/animation/DocumentTimeline.cpp84
-rw-r--r--Source/WebCore/animation/DocumentTimeline.h61
-rw-r--r--Source/WebCore/animation/DocumentTimeline.idl37
-rw-r--r--Source/WebCore/animation/KeyframeEffect.cpp60
-rw-r--r--Source/WebCore/animation/KeyframeEffect.h55
-rw-r--r--Source/WebCore/animation/KeyframeEffect.idl37
-rw-r--r--Source/WebCore/animation/WebAnimation.cpp83
-rw-r--r--Source/WebCore/animation/WebAnimation.h65
-rw-r--r--Source/WebCore/animation/WebAnimation.idl39
19 files changed, 1128 insertions, 0 deletions
diff --git a/Source/WebCore/animation/Animatable.idl b/Source/WebCore/animation/Animatable.idl
new file mode 100644
index 000000000..df5158d0f
--- /dev/null
+++ b/Source/WebCore/animation/Animatable.idl
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) Canon Inc. 2016
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted, provided that the following conditions
+ * are required to be met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Canon Inc. nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY CANON INC. AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL CANON INC. AND ITS CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+[
+ Conditional=WEB_ANIMATIONS,
+ EnabledAtRuntime=WebAnimations,
+ NoInterfaceObject
+] interface Animatable {
+#if !defined(LANGUAGE_OBJECTIVE_C) || !LANGUAGE_OBJECTIVE_C
+ // FIXME: Incomplete interface (implement animate).
+ sequence<WebAnimation> getAnimations();
+#endif
+};
diff --git a/Source/WebCore/animation/AnimationEffect.cpp b/Source/WebCore/animation/AnimationEffect.cpp
new file mode 100644
index 000000000..a16e48eaa
--- /dev/null
+++ b/Source/WebCore/animation/AnimationEffect.cpp
@@ -0,0 +1,65 @@
+/*
+ * Copyright (C) Canon Inc. 2016
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted, provided that the following conditions
+ * are required to be met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Canon Inc. nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY CANON INC. AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL CANON INC. AND ITS CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "AnimationEffect.h"
+
+#if ENABLE(WEB_ANIMATIONS)
+
+#include "WebAnimation.h"
+
+namespace WebCore {
+
+AnimationEffect::AnimationEffect()
+{
+}
+
+AnimationEffect::~AnimationEffect()
+{
+}
+
+void AnimationEffect::setAnimation(WebAnimation* animation)
+{
+ m_animation = animation ? animation->createWeakPtr() : WeakPtr<WebAnimation>();
+}
+
+bool AnimationEffect::isCurrent() const
+{
+ // FIXME: Calculate whether animation is current according to spec.
+ return true;
+}
+
+bool AnimationEffect::isInEffect() const
+{
+ // FIXME: Calculate whether animation is in effect according to spec.
+ return false;
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(WEB_ANIMATIONS)
diff --git a/Source/WebCore/animation/AnimationEffect.h b/Source/WebCore/animation/AnimationEffect.h
new file mode 100644
index 000000000..9e9947ca6
--- /dev/null
+++ b/Source/WebCore/animation/AnimationEffect.h
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) Canon Inc. 2016
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted, provided that the following conditions
+ * are required to be met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Canon Inc. nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY CANON INC. AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL CANON INC. AND ITS CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#if ENABLE(WEB_ANIMATIONS)
+
+#include "WebAnimation.h"
+#include <wtf/RefCounted.h>
+#include <wtf/RefPtr.h>
+
+namespace WebCore {
+
+class AnimationEffect : public RefCounted<AnimationEffect> {
+public:
+ AnimationEffect();
+ virtual ~AnimationEffect();
+
+ void setAnimation(WebAnimation*);
+
+ bool isCurrent() const;
+ bool isInEffect() const;
+
+private:
+ WeakPtr<WebAnimation> m_animation;
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(WEB_ANIMATIONS)
diff --git a/Source/WebCore/animation/AnimationEffect.idl b/Source/WebCore/animation/AnimationEffect.idl
new file mode 100644
index 000000000..8a4b508a0
--- /dev/null
+++ b/Source/WebCore/animation/AnimationEffect.idl
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) Canon Inc. 2016
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted, provided that the following conditions
+ * are required to be met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Canon Inc. nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY CANON INC. AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL CANON INC. AND ITS CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+[
+ Conditional=WEB_ANIMATIONS,
+ EnabledAtRuntime=WebAnimations,
+ InterfaceName=AnimationEffectReadOnly,
+ SkipVTableValidation
+] interface AnimationEffect {
+ // FIXME: Stub only at the moment.
+};
diff --git a/Source/WebCore/animation/AnimationTimeline.cpp b/Source/WebCore/animation/AnimationTimeline.cpp
new file mode 100644
index 000000000..00ea6e727
--- /dev/null
+++ b/Source/WebCore/animation/AnimationTimeline.cpp
@@ -0,0 +1,81 @@
+/*
+ * Copyright (C) Canon Inc. 2016
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted, provided that the following conditions
+ * are required to be met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Canon Inc. nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY CANON INC. AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL CANON INC. AND ITS CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "AnimationTimeline.h"
+
+#if ENABLE(WEB_ANIMATIONS)
+
+#include "DocumentTimeline.h"
+
+namespace WebCore {
+
+AnimationTimeline::AnimationTimeline(ClassType classType)
+ : m_classType(classType)
+{
+ // NOTE: We only have one type of subclass at the moment.
+ ASSERT(classType == DocumentTimelineClass);
+}
+
+AnimationTimeline::~AnimationTimeline()
+{
+}
+
+void AnimationTimeline::destroy()
+{
+ if (classType() == DocumentTimelineClass) {
+ delete downcast<DocumentTimeline>(this);
+ return;
+ }
+
+ ASSERT_NOT_REACHED();
+}
+
+void AnimationTimeline::attachAnimation(WebAnimation& animation)
+{
+ if (classType() == DocumentTimelineClass) {
+ downcast<DocumentTimeline>(*this).attach(animation);
+ return;
+ }
+
+ ASSERT_NOT_REACHED();
+}
+
+void AnimationTimeline::detachAnimation(WebAnimation& animation)
+{
+ if (classType() == DocumentTimelineClass) {
+ downcast<DocumentTimeline>(*this).detach(animation);
+ return;
+ }
+
+ ASSERT_NOT_REACHED();
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(WEB_ANIMATIONS)
diff --git a/Source/WebCore/animation/AnimationTimeline.h b/Source/WebCore/animation/AnimationTimeline.h
new file mode 100644
index 000000000..674a8ab14
--- /dev/null
+++ b/Source/WebCore/animation/AnimationTimeline.h
@@ -0,0 +1,80 @@
+/*
+ * Copyright (C) Canon Inc. 2016
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted, provided that the following conditions
+ * are required to be met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Canon Inc. nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY CANON INC. AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL CANON INC. AND ITS CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#if ENABLE(WEB_ANIMATIONS)
+
+#include <wtf/RefCounted.h>
+#include <wtf/TypeCasts.h>
+
+namespace WebCore {
+
+class WebAnimation;
+
+class AnimationTimeline : public RefCounted<AnimationTimeline> {
+public:
+ // Override RefCounted's deref() to ensure operator delete is called on
+ // the appropriate subclass type.
+ void deref()
+ {
+ if (derefBase())
+ destroy();
+ }
+
+ bool isDocumentTimeline() const { return m_classType == DocumentTimelineClass; }
+
+ void attachAnimation(WebAnimation&);
+ void detachAnimation(WebAnimation&);
+
+protected:
+ enum ClassType {
+ DocumentTimelineClass
+ };
+
+ ClassType classType() const { return m_classType; }
+
+ explicit AnimationTimeline(ClassType);
+
+ // NOTE: Intentionally left non-virtual (using static polymorphism).
+ ~AnimationTimeline();
+
+private:
+ ClassType m_classType;
+
+ void destroy();
+};
+
+} // namespace WebCore
+
+#define SPECIALIZE_TYPE_TRAITS_ANIMATION_TIMELINE(ToValueTypeName, predicate) \
+SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::ToValueTypeName) \
+static bool isType(const WebCore::AnimationTimeline& value) { return value.predicate; } \
+SPECIALIZE_TYPE_TRAITS_END()
+
+#endif // ENABLE(WEB_ANIMATIONS)
diff --git a/Source/WebCore/animation/AnimationTimeline.idl b/Source/WebCore/animation/AnimationTimeline.idl
new file mode 100644
index 000000000..1c67a4a73
--- /dev/null
+++ b/Source/WebCore/animation/AnimationTimeline.idl
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) Canon Inc. 2016
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted, provided that the following conditions
+ * are required to be met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Canon Inc. nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY CANON INC. AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL CANON INC. AND ITS CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+[
+ Conditional=WEB_ANIMATIONS,
+ EnabledAtRuntime=WebAnimations,
+ CustomToJSObject,
+ ImplementationLacksVTable
+] interface AnimationTimeline {
+ // FIXME: Only a stub at the moment.
+};
diff --git a/Source/WebCore/animation/DocumentAnimation.cpp b/Source/WebCore/animation/DocumentAnimation.cpp
new file mode 100644
index 000000000..7e20c2eed
--- /dev/null
+++ b/Source/WebCore/animation/DocumentAnimation.cpp
@@ -0,0 +1,113 @@
+/*
+ * Copyright (C) Canon Inc. 2016
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted, provided that the following conditions
+ * are required to be met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Canon Inc. nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY CANON INC. AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL CANON INC. AND ITS CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "DocumentAnimation.h"
+
+#if ENABLE(WEB_ANIMATIONS)
+
+#include "Document.h"
+#include "DocumentTimeline.h"
+
+namespace WebCore {
+
+DocumentAnimation::DocumentAnimation()
+{
+}
+
+DocumentAnimation::~DocumentAnimation()
+{
+}
+
+DocumentTimeline* DocumentAnimation::timeline(Document& document)
+{
+ auto* documentAnimation = DocumentAnimation::from(&document);
+ if (!documentAnimation->m_defaultTimeline)
+ documentAnimation->m_defaultTimeline = DocumentTimeline::create(document, 0.0);
+ return documentAnimation->m_defaultTimeline.get();
+}
+
+const char* DocumentAnimation::supplementName()
+{
+ return "DocumentAnimation";
+}
+
+DocumentAnimation* DocumentAnimation::from(Document* document)
+{
+ DocumentAnimation* supplement = static_cast<DocumentAnimation*>(Supplement<Document>::from(document, supplementName()));
+ if (!supplement) {
+ auto newSupplement = std::make_unique<DocumentAnimation>();
+ supplement = newSupplement.get();
+ provideTo(document, supplementName(), WTFMove(newSupplement));
+ }
+ return supplement;
+}
+
+WebAnimationVector DocumentAnimation::getAnimations(std::function<bool(const AnimationEffect&)> effect_test) const
+{
+ WebAnimationVector animations;
+
+ auto sortBasedOnPriority = [](const RefPtr<WebAnimation>& a, const RefPtr<WebAnimation>& b)
+ {
+ // FIXME: Sort using the composite order as described in the spec.
+ UNUSED_PARAM(a);
+ UNUSED_PARAM(b);
+ return true;
+ };
+
+ for (auto& animation : m_animations.values()) {
+ if (animation && animation->effect()) {
+ const AnimationEffect& effect = *animation->effect();
+ if ((effect.isCurrent() || effect.isInEffect()) && effect_test(effect))
+ animations.append(animation.get());
+ }
+ }
+ std::sort(animations.begin(), animations.end(), sortBasedOnPriority);
+
+ return animations;
+}
+
+void DocumentAnimation::addAnimation(WebAnimation& animation)
+{
+ ASSERT(!m_animations.contains(&animation));
+ m_animations.add(&animation, animation.createWeakPtr());
+}
+
+void DocumentAnimation::removeAnimation(WebAnimation& animation)
+{
+ m_animations.remove(&animation);
+}
+
+WebAnimationVector DocumentAnimation::getAnimations(Document& document)
+{
+ return DocumentAnimation::from(&document)->getAnimations();
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(WEB_ANIMATIONS)
diff --git a/Source/WebCore/animation/DocumentAnimation.h b/Source/WebCore/animation/DocumentAnimation.h
new file mode 100644
index 000000000..27e6c3d7d
--- /dev/null
+++ b/Source/WebCore/animation/DocumentAnimation.h
@@ -0,0 +1,68 @@
+/*
+ * Copyright (C) Canon Inc. 2016
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted, provided that the following conditions
+ * are required to be met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Canon Inc. nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY CANON INC. AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL CANON INC. AND ITS CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#if ENABLE(WEB_ANIMATIONS)
+
+#include "AnimationEffect.h"
+#include "Supplementable.h"
+#include "WebAnimation.h"
+#include <wtf/HashMap.h>
+#include <wtf/WeakPtr.h>
+
+namespace WebCore {
+
+class DocumentTimeline;
+class Document;
+
+class DocumentAnimation : public Supplement<Document> {
+public:
+ DocumentAnimation();
+ virtual ~DocumentAnimation();
+
+ static DocumentAnimation* from(Document*);
+ static DocumentTimeline* timeline(Document&);
+ static WebAnimationVector getAnimations(Document&);
+
+ WebAnimationVector getAnimations(std::function<bool(const AnimationEffect&)> = [](const AnimationEffect&) { return true; }) const;
+
+ void addAnimation(WebAnimation&);
+ void removeAnimation(WebAnimation&);
+
+private:
+ static const char* supplementName();
+
+ RefPtr<DocumentTimeline> m_defaultTimeline;
+
+ HashMap<WebAnimation*, WeakPtr<WebAnimation>> m_animations;
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(WEB_ANIMATIONS)
diff --git a/Source/WebCore/animation/DocumentAnimation.idl b/Source/WebCore/animation/DocumentAnimation.idl
new file mode 100644
index 000000000..610d34a6c
--- /dev/null
+++ b/Source/WebCore/animation/DocumentAnimation.idl
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) Canon Inc. 2016
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted, provided that the following conditions
+ * are required to be met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Canon Inc. nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY CANON INC. AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL CANON INC. AND ITS CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+[
+ Conditional=WEB_ANIMATIONS,
+ EnabledAtRuntime=WebAnimations,
+] partial interface Document {
+ readonly attribute DocumentTimeline timeline;
+ sequence<WebAnimation> getAnimations();
+};
diff --git a/Source/WebCore/animation/DocumentTimeline.cpp b/Source/WebCore/animation/DocumentTimeline.cpp
new file mode 100644
index 000000000..dcdbcd52b
--- /dev/null
+++ b/Source/WebCore/animation/DocumentTimeline.cpp
@@ -0,0 +1,84 @@
+/*
+ * Copyright (C) Canon Inc. 2016
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted, provided that the following conditions
+ * are required to be met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Canon Inc. nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY CANON INC. AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL CANON INC. AND ITS CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "DocumentTimeline.h"
+
+#if ENABLE(WEB_ANIMATIONS)
+
+#include "Document.h"
+#include "DocumentAnimation.h"
+#include "WebAnimation.h"
+
+namespace WebCore {
+
+Ref<DocumentTimeline> DocumentTimeline::create(Document& context, double originTime)
+{
+ return adoptRef(*new DocumentTimeline(context, originTime));
+}
+
+DocumentTimeline::DocumentTimeline(Document& context, double originTime)
+ : AnimationTimeline(DocumentTimelineClass)
+ , m_document(context.createWeakPtr())
+ , m_originTime(originTime)
+{
+ UNUSED_PARAM(m_originTime);
+}
+
+DocumentTimeline::~DocumentTimeline()
+{
+}
+
+void DocumentTimeline::attach(WebAnimation& animation)
+{
+ ASSERT(animation.timeline() == this);
+ ASSERT(m_document);
+
+ if (!m_document)
+ return;
+
+ auto* document = DocumentAnimation::from(m_document.get());
+ if (document)
+ document->addAnimation(animation);
+}
+
+void DocumentTimeline::detach(WebAnimation& animation)
+{
+ ASSERT(m_document);
+
+ if (!m_document)
+ return;
+
+ auto* document = DocumentAnimation::from(m_document.get());
+ if (document)
+ document->removeAnimation(animation);
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(WEB_ANIMATIONS)
diff --git a/Source/WebCore/animation/DocumentTimeline.h b/Source/WebCore/animation/DocumentTimeline.h
new file mode 100644
index 000000000..5ceab9689
--- /dev/null
+++ b/Source/WebCore/animation/DocumentTimeline.h
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) Canon Inc. 2016
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted, provided that the following conditions
+ * are required to be met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Canon Inc. nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY CANON INC. AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL CANON INC. AND ITS CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#if ENABLE(WEB_ANIMATIONS)
+
+#include "AnimationTimeline.h"
+#include <wtf/Ref.h>
+#include <wtf/WeakPtr.h>
+
+namespace WebCore {
+
+class Document;
+
+class DocumentTimeline final : public AnimationTimeline {
+public:
+ static Ref<DocumentTimeline> create(Document&, double);
+ ~DocumentTimeline();
+
+ void attach(WebAnimation&);
+ void detach(WebAnimation&);
+
+protected:
+ DocumentTimeline(Document&, double);
+
+private:
+ WeakPtr<Document> m_document;
+ double m_originTime;
+};
+
+} // namespace WebCore
+
+SPECIALIZE_TYPE_TRAITS_ANIMATION_TIMELINE(DocumentTimeline, isDocumentTimeline())
+
+#endif // ENABLE(WEB_ANIMATIONS)
diff --git a/Source/WebCore/animation/DocumentTimeline.idl b/Source/WebCore/animation/DocumentTimeline.idl
new file mode 100644
index 000000000..9413ca65a
--- /dev/null
+++ b/Source/WebCore/animation/DocumentTimeline.idl
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) Canon Inc. 2016
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted, provided that the following conditions
+ * are required to be met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Canon Inc. nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY CANON INC. AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL CANON INC. AND ITS CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+[
+ Conditional=WEB_ANIMATIONS,
+ EnabledAtRuntime=WebAnimations,
+ ImplementationLacksVTable,
+ // FIXME: Should be DOMHighResTimeStamp rather than double (e.g. see Performance.now()).
+ Constructor(double originTime),
+ ConstructorCallWith=Document
+] interface DocumentTimeline : AnimationTimeline {
+};
diff --git a/Source/WebCore/animation/KeyframeEffect.cpp b/Source/WebCore/animation/KeyframeEffect.cpp
new file mode 100644
index 000000000..e513ec137
--- /dev/null
+++ b/Source/WebCore/animation/KeyframeEffect.cpp
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) Canon Inc. 2016
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted, provided that the following conditions
+ * are required to be met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Canon Inc. nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY CANON INC. AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL CANON INC. AND ITS CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "KeyframeEffect.h"
+
+#if ENABLE(WEB_ANIMATIONS)
+
+#include "Element.h"
+#include <wtf/Ref.h>
+
+namespace WebCore {
+
+RefPtr<KeyframeEffect> KeyframeEffect::create(Element* target)
+{
+ if (!target) {
+ // FIXME: Support null animation target.
+ return nullptr;
+ }
+
+ return adoptRef(new KeyframeEffect(target));
+}
+
+KeyframeEffect::KeyframeEffect(Element* target)
+ : m_target(target)
+{
+}
+
+KeyframeEffect::~KeyframeEffect()
+{
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(WEB_ANIMATIONS)
diff --git a/Source/WebCore/animation/KeyframeEffect.h b/Source/WebCore/animation/KeyframeEffect.h
new file mode 100644
index 000000000..975a75a0a
--- /dev/null
+++ b/Source/WebCore/animation/KeyframeEffect.h
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) Canon Inc. 2016
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted, provided that the following conditions
+ * are required to be met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Canon Inc. nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY CANON INC. AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL CANON INC. AND ITS CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#if ENABLE(WEB_ANIMATIONS)
+
+#include "AnimationEffect.h"
+
+namespace WebCore {
+
+class Element;
+
+class KeyframeEffect final : public AnimationEffect {
+public:
+ static RefPtr<KeyframeEffect> create(Element*);
+ ~KeyframeEffect() override;
+
+ Element* target() const { return m_target.get(); }
+
+private:
+ KeyframeEffect(Element*);
+
+ // FIXME: Ensure that there is no cyclic reference from Element to KeyframeEffect.
+ RefPtr<Element> m_target;
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(WEB_ANIMATIONS)
diff --git a/Source/WebCore/animation/KeyframeEffect.idl b/Source/WebCore/animation/KeyframeEffect.idl
new file mode 100644
index 000000000..c67196745
--- /dev/null
+++ b/Source/WebCore/animation/KeyframeEffect.idl
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) Canon Inc. 2016
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted, provided that the following conditions
+ * are required to be met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Canon Inc. nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY CANON INC. AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL CANON INC. AND ITS CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+[
+ Conditional=WEB_ANIMATIONS,
+ EnabledAtRuntime=WebAnimations,
+ // FIXME: Constructor stub only at the moment (should accept PseudoElement target, frames and options).
+ Constructor([Default=Undefined] Element? target)
+ // FIXME: Add interface for and inherit from KeyframeEffectReadOnly.
+] interface KeyframeEffect : AnimationEffect {
+ // FIXME: Stub only at the moment.
+};
diff --git a/Source/WebCore/animation/WebAnimation.cpp b/Source/WebCore/animation/WebAnimation.cpp
new file mode 100644
index 000000000..00661ce92
--- /dev/null
+++ b/Source/WebCore/animation/WebAnimation.cpp
@@ -0,0 +1,83 @@
+/*
+ * Copyright (C) Canon Inc. 2016
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted, provided that the following conditions
+ * are required to be met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Canon Inc. nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY CANON INC. AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL CANON INC. AND ITS CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebAnimation.h"
+
+#if ENABLE(WEB_ANIMATIONS)
+
+#include "AnimationEffect.h"
+#include "DocumentTimeline.h"
+#include <wtf/Ref.h>
+
+namespace WebCore {
+
+RefPtr<WebAnimation> WebAnimation::create(AnimationEffect* effect, AnimationTimeline* timeline)
+{
+ if (!effect) {
+ // FIXME: Support creating animations with null effect.
+ return nullptr;
+ }
+
+ if (!timeline) {
+ // FIXME: Support creating animations without a timeline.
+ return nullptr;
+ }
+
+ if (!timeline->isDocumentTimeline()) {
+ // FIXME: Currently only support DocumentTimeline.
+ return nullptr;
+ }
+
+ return adoptRef(new WebAnimation(effect, timeline));
+}
+
+WebAnimation::WebAnimation(AnimationEffect* effect, AnimationTimeline* timeline)
+ : m_effect(effect)
+ , m_timeline(timeline)
+ , m_weakPtrFactory(this)
+{
+ if (m_effect)
+ m_effect->setAnimation(this);
+
+ if (m_timeline)
+ m_timeline->attachAnimation(*this);
+}
+
+WebAnimation::~WebAnimation()
+{
+ if (m_effect)
+ m_effect->setAnimation(nullptr);
+
+ if (m_timeline)
+ m_timeline->detachAnimation(*this);
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(WEB_ANIMATIONS)
diff --git a/Source/WebCore/animation/WebAnimation.h b/Source/WebCore/animation/WebAnimation.h
new file mode 100644
index 000000000..b0173b6e3
--- /dev/null
+++ b/Source/WebCore/animation/WebAnimation.h
@@ -0,0 +1,65 @@
+/*
+ * Copyright (C) Canon Inc. 2016
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted, provided that the following conditions
+ * are required to be met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Canon Inc. nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY CANON INC. AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL CANON INC. AND ITS CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#if ENABLE(WEB_ANIMATIONS)
+
+#include <wtf/RefCounted.h>
+#include <wtf/RefPtr.h>
+#include <wtf/Vector.h>
+#include <wtf/WeakPtr.h>
+
+namespace WebCore {
+
+class AnimationEffect;
+class AnimationTimeline;
+
+class WebAnimation final : public RefCounted<WebAnimation> {
+public:
+ static RefPtr<WebAnimation> create(AnimationEffect*, AnimationTimeline*);
+ ~WebAnimation();
+
+ AnimationEffect* effect() const { return m_effect.get(); }
+ AnimationTimeline* timeline() const { return m_timeline.get(); }
+
+ WeakPtr<WebAnimation> createWeakPtr() const { return m_weakPtrFactory.createWeakPtr(); }
+
+private:
+ WebAnimation(AnimationEffect*, AnimationTimeline*);
+
+ RefPtr<AnimationEffect> m_effect;
+ RefPtr<AnimationTimeline> m_timeline;
+ WeakPtrFactory<WebAnimation> m_weakPtrFactory;
+};
+
+typedef Vector<WebAnimation *> WebAnimationVector;
+
+} // namespace WebCore
+
+#endif // ENABLE(WEB_ANIMATIONS)
diff --git a/Source/WebCore/animation/WebAnimation.idl b/Source/WebCore/animation/WebAnimation.idl
new file mode 100644
index 000000000..048581d16
--- /dev/null
+++ b/Source/WebCore/animation/WebAnimation.idl
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) Canon Inc. 2016
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted, provided that the following conditions
+ * are required to be met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Canon Inc. nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY CANON INC. AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL CANON INC. AND ITS CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+[
+ Conditional=WEB_ANIMATIONS,
+ EnabledAtRuntime=WebAnimations,
+ InterfaceName=Animation,
+ ImplementationLacksVTable,
+ Constructor([Default=Undefined] AnimationEffect? effect, [Default=Undefined] AnimationTimeline? timeline)
+] interface WebAnimation { // FIXME: Inherit from EventTarget.
+ // FIXME: Incomplete interface.
+ readonly attribute AnimationEffect? effect;
+ readonly attribute AnimationTimeline? timeline;
+};