LCOV - code coverage report
Current view: directory - content/svg/content/src - nsSVGClass.cpp (source / functions) Found Hit Coverage
Test: app.info Lines: 61 2 3.3 %
Date: 2012-06-02 Functions: 19 2 10.5 %

       1                 : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
       2                 : /* ***** BEGIN LICENSE BLOCK *****
       3                 :  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
       4                 :  *
       5                 :  * The contents of this file are subject to the Mozilla Public License Version
       6                 :  * 1.1 (the "License"); you may not use this file except in compliance with
       7                 :  * the License. You may obtain a copy of the License at
       8                 :  * http://www.mozilla.org/MPL/
       9                 :  *
      10                 :  * Software distributed under the License is distributed on an "AS IS" basis,
      11                 :  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
      12                 :  * for the specific language governing rights and limitations under the
      13                 :  * License.
      14                 :  *
      15                 :  * The Original Code is the Mozilla SVG project.
      16                 :  *
      17                 :  * The Initial Developer of the Original Code is Robert Longson.
      18                 :  * Portions created by the Initial Developer are Copyright (C) 2011
      19                 :  * the Initial Developer. All Rights Reserved.
      20                 :  *
      21                 :  * Contributor(s):
      22                 :  *
      23                 :  * Alternatively, the contents of this file may be used under the terms of
      24                 :  * either the GNU General Public License Version 2 or later (the "GPL"), or
      25                 :  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
      26                 :  * in which case the provisions of the GPL or the LGPL are applicable instead
      27                 :  * of those above. If you wish to allow use of your version of this file only
      28                 :  * under the terms of either the GPL or the LGPL, and not to allow others to
      29                 :  * use your version of this file under the terms of the MPL, indicate your
      30                 :  * decision by deleting the provisions above and replace them with the notice
      31                 :  * and other provisions required by the GPL or the LGPL. If you do not delete
      32                 :  * the provisions above, a recipient may use your version of this file under
      33                 :  * the terms of any one of the MPL, the GPL or the LGPL.
      34                 :  *
      35                 :  * ***** END LICENSE BLOCK ***** */
      36                 : 
      37                 : #include "nsSVGClass.h"
      38                 : #include "nsSVGStylableElement.h"
      39                 : #include "nsSMILValue.h"
      40                 : #include "SMILStringType.h"
      41                 : 
      42                 : using namespace mozilla;
      43                 : 
      44            1464 : NS_SVG_VAL_IMPL_CYCLE_COLLECTION(nsSVGClass::DOMAnimatedString, mSVGElement)
      45                 : 
      46               0 : NS_IMPL_CYCLE_COLLECTING_ADDREF(nsSVGClass::DOMAnimatedString)
      47               0 : NS_IMPL_CYCLE_COLLECTING_RELEASE(nsSVGClass::DOMAnimatedString)
      48                 : 
      49                 : DOMCI_DATA(SVGAnimatedClass, nsSVGClass::DOMAnimatedString)
      50                 : 
      51               0 : NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsSVGClass::DOMAnimatedString)
      52               0 :   NS_INTERFACE_MAP_ENTRY(nsIDOMSVGAnimatedString)
      53               0 :   NS_INTERFACE_MAP_ENTRY(nsISupports)
      54               0 :   NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGAnimatedString)
      55               0 : NS_INTERFACE_MAP_END
      56                 : 
      57                 : /* Implementation */
      58                 : 
      59                 : void
      60               0 : nsSVGClass::SetBaseValue(const nsAString& aValue,
      61                 :                          nsSVGStylableElement *aSVGElement,
      62                 :                          bool aDoSetAttr)
      63                 : {
      64               0 :   NS_ASSERTION(aSVGElement, "Null element passed to SetBaseValue");
      65                 : 
      66               0 :   aSVGElement->SetFlags(NODE_MAY_HAVE_CLASS);
      67               0 :   if (aDoSetAttr) {
      68               0 :     aSVGElement->SetAttr(kNameSpaceID_None, nsGkAtoms::_class, aValue, true);
      69                 :   }
      70               0 :   if (mAnimVal) {
      71               0 :     aSVGElement->AnimationNeedsResample();
      72                 :   }
      73               0 : }
      74                 : 
      75                 : void
      76               0 : nsSVGClass::GetBaseValue(nsAString& aValue, const nsSVGStylableElement *aSVGElement) const
      77                 : {
      78               0 :   aSVGElement->GetAttr(kNameSpaceID_None, nsGkAtoms::_class, aValue);
      79               0 : }
      80                 : 
      81                 : void
      82               0 : nsSVGClass::GetAnimValue(nsAString& aResult, const nsSVGStylableElement *aSVGElement) const
      83                 : {
      84               0 :   if (mAnimVal) {
      85               0 :     aResult = *mAnimVal;
      86               0 :     return;
      87                 :   }
      88                 : 
      89               0 :   aSVGElement->GetAttr(kNameSpaceID_None, nsGkAtoms::_class, aResult);
      90                 : }
      91                 : 
      92                 : void
      93               0 : nsSVGClass::SetAnimValue(const nsAString& aValue, nsSVGStylableElement *aSVGElement)
      94                 : {
      95               0 :   if (!mAnimVal) {
      96               0 :     mAnimVal = new nsString();
      97                 :   }
      98               0 :   *mAnimVal = aValue;
      99               0 :   aSVGElement->SetFlags(NODE_MAY_HAVE_CLASS);
     100               0 :   aSVGElement->DidAnimateClass();
     101               0 : }
     102                 : 
     103                 : nsresult
     104               0 : nsSVGClass::ToDOMAnimatedString(nsIDOMSVGAnimatedString **aResult,
     105                 :                                 nsSVGStylableElement *aSVGElement)
     106                 : {
     107               0 :   *aResult = new DOMAnimatedString(this, aSVGElement);
     108               0 :   NS_ADDREF(*aResult);
     109               0 :   return NS_OK;
     110                 : }
     111                 : 
     112                 : NS_IMETHODIMP
     113               0 : nsSVGClass::DOMAnimatedString::GetAnimVal(nsAString& aResult)
     114                 : { 
     115               0 :   mSVGElement->FlushAnimations();
     116               0 :   mVal->GetAnimValue(aResult, mSVGElement);
     117               0 :   return NS_OK;
     118                 : }
     119                 : 
     120                 : nsISMILAttr*
     121               0 : nsSVGClass::ToSMILAttr(nsSVGStylableElement *aSVGElement)
     122                 : {
     123               0 :   return new SMILString(this, aSVGElement);
     124                 : }
     125                 : 
     126                 : nsresult
     127               0 : nsSVGClass::SMILString::ValueFromString(const nsAString& aStr,
     128                 :                                         const nsISMILAnimationElement* /*aSrcElement*/,
     129                 :                                         nsSMILValue& aValue,
     130                 :                                         bool& aPreventCachingOfSandwich) const
     131                 : {
     132               0 :   nsSMILValue val(&SMILStringType::sSingleton);
     133                 : 
     134               0 :   *static_cast<nsAString*>(val.mU.mPtr) = aStr;
     135               0 :   aValue.Swap(val);
     136               0 :   aPreventCachingOfSandwich = false;
     137               0 :   return NS_OK;
     138                 : }
     139                 : 
     140                 : nsSMILValue
     141               0 : nsSVGClass::SMILString::GetBaseValue() const
     142                 : {
     143               0 :   nsSMILValue val(&SMILStringType::sSingleton);
     144                 :   mSVGElement->GetAttr(kNameSpaceID_None, nsGkAtoms::_class,
     145               0 :                        *static_cast<nsAString*>(val.mU.mPtr));
     146                 :   return val;
     147                 : }
     148                 : 
     149                 : void
     150               0 : nsSVGClass::SMILString::ClearAnimValue()
     151                 : {
     152               0 :   if (mVal->mAnimVal) {
     153               0 :     mVal->mAnimVal = nsnull;
     154               0 :     mSVGElement->DidAnimateClass();
     155                 :   }
     156               0 : }
     157                 : 
     158                 : nsresult
     159               0 : nsSVGClass::SMILString::SetAnimValue(const nsSMILValue& aValue)
     160                 : {
     161               0 :   NS_ASSERTION(aValue.mType == &SMILStringType::sSingleton,
     162                 :                "Unexpected type to assign animated value");
     163               0 :   if (aValue.mType == &SMILStringType::sSingleton) {
     164               0 :     mVal->SetAnimValue(*static_cast<nsAString*>(aValue.mU.mPtr), mSVGElement);
     165                 :   }
     166               0 :   return NS_OK;
     167            4392 : }

Generated by: LCOV version 1.7