LCOV - code coverage report
Current view: directory - content/svg/content/src - DOMSVGAnimatedTransformList.cpp (source / functions) Found Hit Coverage
Test: app.info Lines: 51 3 5.9 %
Date: 2012-06-02 Functions: 18 2 11.1 %

       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
      18                 :  * Crocodile Clips Ltd..
      19                 :  * Portions created by the Initial Developer are Copyright (C) 2001
      20                 :  * the Initial Developer. All Rights Reserved.
      21                 :  *
      22                 :  * Contributor(s):
      23                 :  *   Alex Fritze <alex.fritze@crocodile-clips.com> (original author)
      24                 :  *
      25                 :  * Alternatively, the contents of this file may be used under the terms of
      26                 :  * either of the GNU General Public License Version 2 or later (the "GPL"),
      27                 :  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
      28                 :  * in which case the provisions of the GPL or the LGPL are applicable instead
      29                 :  * of those above. If you wish to allow use of your version of this file only
      30                 :  * under the terms of either the GPL or the LGPL, and not to allow others to
      31                 :  * use your version of this file under the terms of the MPL, indicate your
      32                 :  * decision by deleting the provisions above and replace them with the notice
      33                 :  * and other provisions required by the GPL or the LGPL. If you do not delete
      34                 :  * the provisions above, a recipient may use your version of this file under
      35                 :  * the terms of any one of the MPL, the GPL or the LGPL.
      36                 :  *
      37                 :  * ***** END LICENSE BLOCK ***** */
      38                 : 
      39                 : #include "DOMSVGAnimatedTransformList.h"
      40                 : #include "DOMSVGTransformList.h"
      41                 : #include "SVGAnimatedTransformList.h"
      42                 : #include "nsSVGAttrTearoffTable.h"
      43                 : 
      44                 : namespace mozilla {
      45                 : 
      46                 : static
      47                 :   nsSVGAttrTearoffTable<SVGAnimatedTransformList,DOMSVGAnimatedTransformList>
      48            1464 :   sSVGAnimatedTransformListTearoffTable;
      49                 : 
      50            1464 : NS_SVG_VAL_IMPL_CYCLE_COLLECTION(DOMSVGAnimatedTransformList, mElement)
      51                 : 
      52               0 : NS_IMPL_CYCLE_COLLECTING_ADDREF(DOMSVGAnimatedTransformList)
      53               0 : NS_IMPL_CYCLE_COLLECTING_RELEASE(DOMSVGAnimatedTransformList)
      54                 : 
      55                 : } // namespace mozilla
      56                 : DOMCI_DATA(SVGAnimatedTransformList, mozilla::DOMSVGAnimatedTransformList)
      57                 : namespace mozilla {
      58                 : 
      59               0 : NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(DOMSVGAnimatedTransformList)
      60               0 :   NS_INTERFACE_MAP_ENTRY(nsIDOMSVGAnimatedTransformList)
      61               0 :   NS_INTERFACE_MAP_ENTRY(nsISupports)
      62               0 :   NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGAnimatedTransformList)
      63               0 : NS_INTERFACE_MAP_END
      64                 : 
      65                 : //----------------------------------------------------------------------
      66                 : // nsIDOMSVGAnimatedTransformList methods:
      67                 : 
      68                 : /* readonly attribute nsIDOMSVGTransformList baseVal; */
      69                 : NS_IMETHODIMP
      70               0 : DOMSVGAnimatedTransformList::GetBaseVal(nsIDOMSVGTransformList** aBaseVal)
      71                 : {
      72               0 :   if (!mBaseVal) {
      73               0 :     mBaseVal = new DOMSVGTransformList(this, InternalAList().GetBaseValue());
      74                 :   }
      75               0 :   NS_ADDREF(*aBaseVal = mBaseVal);
      76               0 :   return NS_OK;
      77                 : }
      78                 : 
      79                 : /* readonly attribute nsIDOMSVGTransformList animVal; */
      80                 : NS_IMETHODIMP
      81               0 : DOMSVGAnimatedTransformList::GetAnimVal(nsIDOMSVGTransformList** aAnimVal)
      82                 : {
      83               0 :   if (!mAnimVal) {
      84               0 :     mAnimVal = new DOMSVGTransformList(this, InternalAList().GetAnimValue());
      85                 :   }
      86               0 :   NS_ADDREF(*aAnimVal = mAnimVal);
      87               0 :   return NS_OK;
      88                 : }
      89                 : 
      90                 : /* static */ already_AddRefed<DOMSVGAnimatedTransformList>
      91               0 : DOMSVGAnimatedTransformList::GetDOMWrapper(SVGAnimatedTransformList *aList,
      92                 :                                            nsSVGElement *aElement)
      93                 : {
      94                 :   DOMSVGAnimatedTransformList *wrapper =
      95               0 :     sSVGAnimatedTransformListTearoffTable.GetTearoff(aList);
      96               0 :   if (!wrapper) {
      97               0 :     wrapper = new DOMSVGAnimatedTransformList(aElement);
      98               0 :     sSVGAnimatedTransformListTearoffTable.AddTearoff(aList, wrapper);
      99                 :   }
     100               0 :   NS_ADDREF(wrapper);
     101               0 :   return wrapper;
     102                 : }
     103                 : 
     104                 : /* static */ DOMSVGAnimatedTransformList*
     105               0 : DOMSVGAnimatedTransformList::GetDOMWrapperIfExists(
     106                 :   SVGAnimatedTransformList *aList)
     107                 : {
     108               0 :   return sSVGAnimatedTransformListTearoffTable.GetTearoff(aList);
     109                 : }
     110                 : 
     111               0 : DOMSVGAnimatedTransformList::~DOMSVGAnimatedTransformList()
     112                 : {
     113                 :   // Script no longer has any references to us, to our base/animVal objects, or
     114                 :   // to any of their list items.
     115               0 :   sSVGAnimatedTransformListTearoffTable.RemoveTearoff(&InternalAList());
     116               0 : }
     117                 : 
     118                 : void
     119               0 : DOMSVGAnimatedTransformList::InternalBaseValListWillChangeLengthTo(
     120                 :   PRUint32 aNewLength)
     121                 : {
     122                 :   // When the number of items in our internal counterpart's baseVal changes,
     123                 :   // we MUST keep our baseVal in sync. If we don't, script will either see a
     124                 :   // list that is too short and be unable to access indexes that should be
     125                 :   // valid, or else, MUCH WORSE, script will see a list that is too long and be
     126                 :   // able to access "items" at indexes that are out of bounds (read/write to
     127                 :   // bad memory)!!
     128                 : 
     129               0 :   nsRefPtr<DOMSVGAnimatedTransformList> kungFuDeathGrip;
     130               0 :   if (mBaseVal) {
     131               0 :     if (aNewLength < mBaseVal->Length()) {
     132                 :       // InternalListLengthWillChange might clear last reference to |this|.
     133                 :       // Retain a temporary reference to keep from dying before returning.
     134               0 :       kungFuDeathGrip = this;
     135                 :     }
     136               0 :     mBaseVal->InternalListLengthWillChange(aNewLength);
     137                 :   }
     138                 : 
     139                 :   // If our attribute is not animating, then our animVal mirrors our baseVal
     140                 :   // and we must sync its length too. (If our attribute is animating, then the
     141                 :   // SMIL engine takes care of calling InternalAnimValListWillChangeLengthTo()
     142                 :   // if necessary.)
     143                 : 
     144               0 :   if (!IsAnimating()) {
     145               0 :     InternalAnimValListWillChangeLengthTo(aNewLength);
     146                 :   }
     147               0 : }
     148                 : 
     149                 : void
     150               0 : DOMSVGAnimatedTransformList::InternalAnimValListWillChangeLengthTo(
     151                 :   PRUint32 aNewLength)
     152                 : {
     153               0 :   if (mAnimVal) {
     154               0 :     mAnimVal->InternalListLengthWillChange(aNewLength);
     155                 :   }
     156               0 : }
     157                 : 
     158                 : bool
     159               0 : DOMSVGAnimatedTransformList::IsAnimating() const
     160                 : {
     161               0 :   return InternalAList().IsAnimating();
     162                 : }
     163                 : 
     164                 : SVGAnimatedTransformList&
     165               0 : DOMSVGAnimatedTransformList::InternalAList()
     166                 : {
     167               0 :   return *mElement->GetAnimatedTransformList();
     168                 : }
     169                 : 
     170                 : const SVGAnimatedTransformList&
     171               0 : DOMSVGAnimatedTransformList::InternalAList() const
     172                 : {
     173               0 :   return *mElement->GetAnimatedTransformList();
     174                 : }
     175                 : 
     176            4392 : } // namespace mozilla

Generated by: LCOV version 1.7