Home | History | Annotate | Download | only in properties
      1 /*
      2  * Copyright (C) Research In Motion Limited 2010. All rights reserved.
      3  * Copyright (C) 2013 Samsung Electronics. All rights reserved.
      4  *
      5  * This library is free software; you can redistribute it and/or
      6  * modify it under the terms of the GNU Library General Public
      7  * License as published by the Free Software Foundation; either
      8  * version 2 of the License, or (at your option) any later version.
      9  *
     10  * This library is distributed in the hope that it will be useful,
     11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
     12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     13  * Library General Public License for more details.
     14  *
     15  * You should have received a copy of the GNU Library General Public License
     16  * along with this library; see the file COPYING.LIB.  If not, write to
     17  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
     18  * Boston, MA 02110-1301, USA.
     19  */
     20 
     21 #include "config.h"
     22 #include "core/svg/properties/SVGAnimatedProperty.h"
     23 
     24 #include "core/svg/SVGElement.h"
     25 
     26 namespace WebCore {
     27 
     28 SVGAnimatedProperty::SVGAnimatedProperty(SVGElement* contextElement, const QualifiedName& attributeName, AnimatedPropertyType animatedPropertyType)
     29     : m_contextElement(contextElement)
     30     , m_attributeName(attributeName)
     31     , m_animatedPropertyType(animatedPropertyType)
     32     , m_isAnimating(false)
     33     , m_isReadOnly(false)
     34 {
     35 }
     36 
     37 SVGAnimatedProperty::~SVGAnimatedProperty()
     38 {
     39     // Remove wrapper from cache.
     40     Cache* cache = animatedPropertyCache();
     41     const Cache::const_iterator end = cache->end();
     42     for (Cache::const_iterator it = cache->begin(); it != end; ++it) {
     43         if (it->value == this) {
     44             cache->remove(it->key);
     45             break;
     46         }
     47     }
     48 
     49     // Assure that animationEnded() was called, if animationStarted() was called before.
     50     ASSERT(!m_isAnimating);
     51 }
     52 
     53 void SVGAnimatedProperty::commitChange()
     54 {
     55     ASSERT(m_contextElement);
     56     ASSERT(!m_contextElement->m_deletionHasBegun);
     57     m_contextElement->invalidateSVGAttributes();
     58     m_contextElement->svgAttributeChanged(m_attributeName);
     59 }
     60 
     61 SVGAnimatedProperty::Cache* SVGAnimatedProperty::animatedPropertyCache()
     62 {
     63     static Cache* s_cache = new Cache;
     64     return s_cache;
     65 }
     66 
     67 } // namespace WebCore
     68