LCOV - app.info - content/svg/content/src/nsSVGString.cpp

LCOV - code coverage report
| Current view: | directory - content/svg/content/src - nsSVGString.cpp (source / functions) |  | Found | Hit | Coverage |
| Test: | app.info | Lines: | 57 | 2 | 3.5 %
| Date: | 2012-07-07 | Functions: | 17 | 2 | 11.8 %

           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) 2008
          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 "nsSVGString.h"
          38                 : #include "nsSMILValue.h"
          39                 : #include "SMILStringType.h"
          40                 :
          41                 : using namespace mozilla;
          42                 :
          43            1464 : NS_SVG_VAL_IMPL_CYCLE_COLLECTION(nsSVGString::DOMAnimatedString, mSVGElement)
          44                 :
          45               0 : NS_IMPL_CYCLE_COLLECTING_ADDREF(nsSVGString::DOMAnimatedString)
          46               0 : NS_IMPL_CYCLE_COLLECTING_RELEASE(nsSVGString::DOMAnimatedString)
          47                 :
          48                 : DOMCI_DATA(SVGAnimatedString, nsSVGString::DOMAnimatedString)
          49                 :
          50               0 : NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsSVGString::DOMAnimatedString)
          51               0 :   NS_INTERFACE_MAP_ENTRY(nsIDOMSVGAnimatedString)
          52               0 :   NS_INTERFACE_MAP_ENTRY(nsISupports)
          53               0 :   NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGAnimatedString)
          54               0 : NS_INTERFACE_MAP_END
          55                 :
          56                 : /* Implementation */
          57                 :
          58                 : void
          59               0 : nsSVGString::SetBaseValue(const nsAString& aValue,
          60                 :                           nsSVGElement *aSVGElement,
          61                 :                           bool aDoSetAttr)
          62                 : {
          63               0 :   NS_ASSERTION(aSVGElement, "Null element passed to SetBaseValue");
          64                 :
          65               0 :   mIsBaseSet = true;
          66               0 :   if (aDoSetAttr) {
          67               0 :     aSVGElement->SetStringBaseValue(mAttrEnum, aValue);
          68                 :   }
          69               0 :   if (mAnimVal) {
          70               0 :     aSVGElement->AnimationNeedsResample();
          71                 :   }
          72                 :
          73               0 :   aSVGElement->DidChangeString(mAttrEnum);
          74               0 : }
          75                 :
          76                 : void
          77               0 : nsSVGString::GetAnimValue(nsAString& aResult, const nsSVGElement *aSVGElement) const
          78                 : {
          79               0 :   if (mAnimVal) {
          80               0 :     aResult = *mAnimVal;
          81               0 :     return;
          82                 :   }
          83                 :
          84               0 :   aSVGElement->GetStringBaseValue(mAttrEnum, aResult);
          85                 : }
          86                 :
          87                 : void
          88               0 : nsSVGString::SetAnimValue(const nsAString& aValue, nsSVGElement *aSVGElement)
          89                 : {
          90               0 :   if (aSVGElement->IsStringAnimatable(mAttrEnum)) {
          91               0 :     if (!mAnimVal) {
          92               0 :       mAnimVal = new nsString();
          93                 :     }
          94               0 :     *mAnimVal = aValue;
          95               0 :     aSVGElement->DidAnimateString(mAttrEnum);
          96                 :   }
          97               0 : }
          98                 :
          99                 : nsresult
         100               0 : nsSVGString::ToDOMAnimatedString(nsIDOMSVGAnimatedString **aResult,
         101                 :                                  nsSVGElement *aSVGElement)
         102                 : {
         103               0 :   *aResult = new DOMAnimatedString(this, aSVGElement);
         104               0 :   if (!*aResult)
         105               0 :     return NS_ERROR_OUT_OF_MEMORY;
         106                 :
         107               0 :   NS_ADDREF(*aResult);
         108               0 :   return NS_OK;
         109                 : }
         110                 :
         111                 : nsISMILAttr*
         112               0 : nsSVGString::ToSMILAttr(nsSVGElement *aSVGElement)
         113                 : {
         114               0 :   return new SMILString(this, aSVGElement);
         115                 : }
         116                 :
         117                 : nsresult
         118               0 : nsSVGString::SMILString::ValueFromString(const nsAString& aStr,
         119                 :                                          const nsISMILAnimationElement* /*aSrcElement*/,
         120                 :                                          nsSMILValue& aValue,
         121                 :                                          bool& aPreventCachingOfSandwich) const
         122                 : {
         123               0 :   nsSMILValue val(&SMILStringType::sSingleton);
         124                 :
         125               0 :   *static_cast<nsAString*>(val.mU.mPtr) = aStr;
         126               0 :   aValue.Swap(val);
         127               0 :   aPreventCachingOfSandwich = false;
         128               0 :   return NS_OK;
         129                 : }
         130                 :
         131                 : nsSMILValue
         132               0 : nsSVGString::SMILString::GetBaseValue() const
         133                 : {
         134               0 :   nsSMILValue val(&SMILStringType::sSingleton);
         135               0 :   mSVGElement->GetStringBaseValue(mVal->mAttrEnum, *static_cast<nsAString*>(val.mU.mPtr));
         136                 :   return val;
         137                 : }
         138                 :
         139                 : void
         140               0 : nsSVGString::SMILString::ClearAnimValue()
         141                 : {
         142               0 :   if (mVal->mAnimVal) {
         143               0 :     mVal->mAnimVal = nsnull;
         144               0 :     mSVGElement->DidAnimateString(mVal->mAttrEnum);
         145                 :   }
         146               0 : }
         147                 :
         148                 : nsresult
         149               0 : nsSVGString::SMILString::SetAnimValue(const nsSMILValue& aValue)
         150                 : {
         151               0 :   NS_ASSERTION(aValue.mType == &SMILStringType::sSingleton,
         152                 :                "Unexpected type to assign animated value");
         153               0 :   if (aValue.mType == &SMILStringType::sSingleton) {
         154               0 :     mVal->SetAnimValue(*static_cast<nsAString*>(aValue.mU.mPtr), mSVGElement);
         155                 :   }
         156               0 :   return NS_OK;
         157            4392 : }

Generated by: LCOV version 1.7