LCOV - code coverage report
Current view: top level - dom/svg - DOMSVGAnimatedNumberList.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 0 52 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 19 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
       2             : /* vim: set ts=8 sts=2 et sw=2 tw=80: */
       3             : /* This Source Code Form is subject to the terms of the Mozilla Public
       4             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       5             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
       6             : 
       7             : #include "DOMSVGAnimatedNumberList.h"
       8             : #include "DOMSVGNumberList.h"
       9             : #include "SVGAnimatedNumberList.h"
      10             : #include "nsSVGElement.h"
      11             : #include "nsCOMPtr.h"
      12             : #include "nsSVGAttrTearoffTable.h"
      13             : #include "mozilla/dom/SVGAnimatedNumberListBinding.h"
      14             : 
      15             : // See the architecture comment in this file's header.
      16             : 
      17             : namespace mozilla {
      18             : 
      19             :   static inline
      20             : nsSVGAttrTearoffTable<SVGAnimatedNumberList, DOMSVGAnimatedNumberList>&
      21           0 : SVGAnimatedNumberListTearoffTable()
      22             : {
      23             :   static nsSVGAttrTearoffTable<SVGAnimatedNumberList, DOMSVGAnimatedNumberList>
      24           0 :     sSVGAnimatedNumberListTearoffTable;
      25           0 :   return sSVGAnimatedNumberListTearoffTable;
      26             : }
      27             : 
      28           0 : NS_SVG_VAL_IMPL_CYCLE_COLLECTION_WRAPPERCACHED(DOMSVGAnimatedNumberList, mElement)
      29             : 
      30           0 : NS_IMPL_CYCLE_COLLECTING_ADDREF(DOMSVGAnimatedNumberList)
      31           0 : NS_IMPL_CYCLE_COLLECTING_RELEASE(DOMSVGAnimatedNumberList)
      32             : 
      33           0 : NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(DOMSVGAnimatedNumberList)
      34           0 :   NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
      35           0 :   NS_INTERFACE_MAP_ENTRY(nsISupports)
      36           0 : NS_INTERFACE_MAP_END
      37             : 
      38             : JSObject*
      39           0 : DOMSVGAnimatedNumberList::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
      40             : {
      41           0 :   return mozilla::dom::SVGAnimatedNumberListBinding::Wrap(aCx, this, aGivenProto);
      42             : }
      43             : 
      44             : already_AddRefed<DOMSVGNumberList>
      45           0 : DOMSVGAnimatedNumberList::BaseVal()
      46             : {
      47           0 :   if (!mBaseVal) {
      48           0 :     mBaseVal = new DOMSVGNumberList(this, InternalAList().GetBaseValue());
      49             :   }
      50           0 :   RefPtr<DOMSVGNumberList> baseVal = mBaseVal;
      51           0 :   return baseVal.forget();
      52             : }
      53             : 
      54             : already_AddRefed<DOMSVGNumberList>
      55           0 : DOMSVGAnimatedNumberList::AnimVal()
      56             : {
      57           0 :   if (!mAnimVal) {
      58           0 :     mAnimVal = new DOMSVGNumberList(this, InternalAList().GetAnimValue());
      59             :   }
      60           0 :   RefPtr<DOMSVGNumberList> animVal = mAnimVal;
      61           0 :   return animVal.forget();
      62             : }
      63             : 
      64             : /* static */ already_AddRefed<DOMSVGAnimatedNumberList>
      65           0 : DOMSVGAnimatedNumberList::GetDOMWrapper(SVGAnimatedNumberList *aList,
      66             :                                         nsSVGElement *aElement,
      67             :                                         uint8_t aAttrEnum)
      68             : {
      69             :   RefPtr<DOMSVGAnimatedNumberList> wrapper =
      70           0 :     SVGAnimatedNumberListTearoffTable().GetTearoff(aList);
      71           0 :   if (!wrapper) {
      72           0 :     wrapper = new DOMSVGAnimatedNumberList(aElement, aAttrEnum);
      73           0 :     SVGAnimatedNumberListTearoffTable().AddTearoff(aList, wrapper);
      74             :   }
      75           0 :   return wrapper.forget();
      76             : }
      77             : 
      78             : /* static */ DOMSVGAnimatedNumberList*
      79           0 : DOMSVGAnimatedNumberList::GetDOMWrapperIfExists(SVGAnimatedNumberList *aList)
      80             : {
      81           0 :   return SVGAnimatedNumberListTearoffTable().GetTearoff(aList);
      82             : }
      83             : 
      84           0 : DOMSVGAnimatedNumberList::~DOMSVGAnimatedNumberList()
      85             : {
      86             :   // Script no longer has any references to us, to our base/animVal objects, or
      87             :   // to any of their list items.
      88           0 :   SVGAnimatedNumberListTearoffTable().RemoveTearoff(&InternalAList());
      89           0 : }
      90             : 
      91             : void
      92           0 : DOMSVGAnimatedNumberList::InternalBaseValListWillChangeTo(const SVGNumberList& aNewValue)
      93             : {
      94             :   // When the number of items in our internal counterpart's baseVal changes,
      95             :   // we MUST keep our baseVal in sync. If we don't, script will either see a
      96             :   // list that is too short and be unable to access indexes that should be
      97             :   // valid, or else, MUCH WORSE, script will see a list that is too long and be
      98             :   // able to access "items" at indexes that are out of bounds (read/write to
      99             :   // bad memory)!!
     100             : 
     101           0 :   RefPtr<DOMSVGAnimatedNumberList> kungFuDeathGrip;
     102           0 :   if (mBaseVal) {
     103           0 :     if (aNewValue.Length() < mBaseVal->LengthNoFlush()) {
     104             :       // InternalListLengthWillChange might clear last reference to |this|.
     105             :       // Retain a temporary reference to keep from dying before returning.
     106           0 :       kungFuDeathGrip = this;
     107             :     }
     108           0 :     mBaseVal->InternalListLengthWillChange(aNewValue.Length());
     109             :   }
     110             : 
     111             :   // If our attribute is not animating, then our animVal mirrors our baseVal
     112             :   // and we must sync its length too. (If our attribute is animating, then the
     113             :   // SMIL engine takes care of calling InternalAnimValListWillChangeTo() if
     114             :   // necessary.)
     115             : 
     116           0 :   if (!IsAnimating()) {
     117           0 :     InternalAnimValListWillChangeTo(aNewValue);
     118             :   }
     119           0 : }
     120             : 
     121             : void
     122           0 : DOMSVGAnimatedNumberList::InternalAnimValListWillChangeTo(const SVGNumberList& aNewValue)
     123             : {
     124           0 :   if (mAnimVal) {
     125           0 :     mAnimVal->InternalListLengthWillChange(aNewValue.Length());
     126             :   }
     127           0 : }
     128             : 
     129             : bool
     130           0 : DOMSVGAnimatedNumberList::IsAnimating() const
     131             : {
     132           0 :   return InternalAList().IsAnimating();
     133             : }
     134             : 
     135             : SVGAnimatedNumberList&
     136           0 : DOMSVGAnimatedNumberList::InternalAList()
     137             : {
     138           0 :   return *mElement->GetAnimatedNumberList(mAttrEnum);
     139             : }
     140             : 
     141             : const SVGAnimatedNumberList&
     142           0 : DOMSVGAnimatedNumberList::InternalAList() const
     143             : {
     144           0 :   return *mElement->GetAnimatedNumberList(mAttrEnum);
     145             : }
     146             : 
     147             : } // namespace mozilla

Generated by: LCOV version 1.13