1/* 2 * Copyright (C) 2011 Apple Inc. All rights reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 1. Redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer. 9 * 2. Redistributions in binary form must reproduce the above copyright 10 * notice, this list of conditions and the following disclaimer in the 11 * documentation and/or other materials provided with the distribution. 12 * 13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 */ 25 26#include "config.h" 27#include "WebKitAnimation.h" 28 29#include "Animation.h" 30#include "AnimationBase.h" 31#include "RenderStyle.h" 32 33using namespace std; 34 35namespace WebCore { 36 37WebKitAnimation::WebKitAnimation(PassRefPtr<KeyframeAnimation> keyframeAnimation) 38 : m_keyframeAnimation(keyframeAnimation) 39{ 40} 41 42String WebKitAnimation::name() const 43{ 44 return m_keyframeAnimation->animation()->name(); 45} 46 47double WebKitAnimation::duration() const 48{ 49 return m_keyframeAnimation->duration(); 50} 51 52double WebKitAnimation::elapsedTime() const 53{ 54 return m_keyframeAnimation->getElapsedTime(); 55} 56 57void WebKitAnimation::setElapsedTime(double time) 58{ 59 m_keyframeAnimation->setElapsedTime(time); 60} 61 62double WebKitAnimation::delay() const 63{ 64 return m_keyframeAnimation->animation()->delay(); 65} 66 67int WebKitAnimation::iterationCount() const 68{ 69 return m_keyframeAnimation->animation()->iterationCount(); 70} 71 72bool WebKitAnimation::paused() const 73{ 74 return m_keyframeAnimation->paused(); 75} 76 77bool WebKitAnimation::ended() const 78{ 79 int iterations = iterationCount(); 80 if (iterations == Animation::IterationCountInfinite) 81 return false; 82 return m_keyframeAnimation->getElapsedTime() > (m_keyframeAnimation->duration() * iterations); 83} 84 85WebKitAnimation::Direction WebKitAnimation::direction() const 86{ 87 if (m_keyframeAnimation->animation()->direction() == Animation::AnimationDirectionNormal) 88 return DIRECTION_NORMAL; 89 return DIRECTION_ALTERNATE; 90} 91 92WebKitAnimation::FillMode WebKitAnimation::fillMode() const 93{ 94 switch (m_keyframeAnimation->animation()->fillMode()) { 95 case AnimationFillModeNone: 96 return FILL_NONE; 97 break; 98 case AnimationFillModeForwards: 99 return FILL_FORWARDS; 100 break; 101 case AnimationFillModeBackwards: 102 return FILL_BACKWARDS; 103 break; 104 default: 105 return FILL_BOTH; 106 break; 107 } 108} 109 110void WebKitAnimation::pause() 111{ 112 m_keyframeAnimation->pause(); 113} 114 115void WebKitAnimation::play() 116{ 117 m_keyframeAnimation->play(); 118} 119 120} 121