LCOV - code coverage report
Current view: top level - dom/smil - nsSMILInterval.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 0 73 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 14 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 "nsSMILInterval.h"
       8             : 
       9           0 : nsSMILInterval::nsSMILInterval()
      10             : :
      11             :   mBeginFixed(false),
      12           0 :   mEndFixed(false)
      13             : {
      14           0 : }
      15             : 
      16           0 : nsSMILInterval::nsSMILInterval(const nsSMILInterval& aOther)
      17             : :
      18             :   mBegin(aOther.mBegin),
      19             :   mEnd(aOther.mEnd),
      20             :   mBeginFixed(false),
      21           0 :   mEndFixed(false)
      22             : {
      23           0 :   MOZ_ASSERT(aOther.mDependentTimes.IsEmpty(),
      24             :              "Attempt to copy-construct an interval with dependent times; this "
      25             :              "will lead to instance times being shared between intervals.");
      26             : 
      27             :   // For the time being we don't allow intervals with fixed endpoints to be
      28             :   // copied since we only ever copy-construct to establish a new current
      29             :   // interval. If we ever need to copy historical intervals we may need to move
      30             :   // the ReleaseFixedEndpoint calls from Unlink to the dtor.
      31           0 :   MOZ_ASSERT(!aOther.mBeginFixed && !aOther.mEndFixed,
      32             :              "Attempt to copy-construct an interval with fixed endpoints");
      33           0 : }
      34             : 
      35           0 : nsSMILInterval::~nsSMILInterval()
      36             : {
      37           0 :   MOZ_ASSERT(mDependentTimes.IsEmpty(),
      38             :              "Destroying interval without disassociating dependent instance "
      39             :              "times. Unlink was not called");
      40           0 : }
      41             : 
      42             : void
      43           0 : nsSMILInterval::Unlink(bool aFiltered)
      44             : {
      45           0 :   for (int32_t i = mDependentTimes.Length() - 1; i >= 0; --i) {
      46           0 :     if (aFiltered) {
      47           0 :       mDependentTimes[i]->HandleFilteredInterval();
      48             :     } else {
      49           0 :       mDependentTimes[i]->HandleDeletedInterval();
      50             :     }
      51             :   }
      52           0 :   mDependentTimes.Clear();
      53           0 :   if (mBegin && mBeginFixed) {
      54           0 :     mBegin->ReleaseFixedEndpoint();
      55             :   }
      56           0 :   mBegin = nullptr;
      57           0 :   if (mEnd && mEndFixed) {
      58           0 :     mEnd->ReleaseFixedEndpoint();
      59             :   }
      60           0 :   mEnd = nullptr;
      61           0 : }
      62             : 
      63             : nsSMILInstanceTime*
      64           0 : nsSMILInterval::Begin()
      65             : {
      66           0 :   MOZ_ASSERT(mBegin && mEnd,
      67             :              "Requesting Begin() on un-initialized interval.");
      68           0 :   return mBegin;
      69             : }
      70             : 
      71             : nsSMILInstanceTime*
      72           0 : nsSMILInterval::End()
      73             : {
      74           0 :   MOZ_ASSERT(mBegin && mEnd,
      75             :              "Requesting End() on un-initialized interval.");
      76           0 :   return mEnd;
      77             : }
      78             : 
      79             : void
      80           0 : nsSMILInterval::SetBegin(nsSMILInstanceTime& aBegin)
      81             : {
      82           0 :   MOZ_ASSERT(aBegin.Time().IsDefinite(),
      83             :              "Attempt to set unresolved or indefinite begin time on interval");
      84           0 :   MOZ_ASSERT(!mBeginFixed,
      85             :              "Attempt to set begin time but the begin point is fixed");
      86             :   // Check that we're not making an instance time dependent on itself. Such an
      87             :   // arrangement does not make intuitive sense and should be detected when
      88             :   // creating or updating intervals.
      89           0 :   MOZ_ASSERT(!mBegin || aBegin.GetBaseTime() != mBegin,
      90             :              "Attempt to make self-dependent instance time");
      91             : 
      92           0 :   mBegin = &aBegin;
      93           0 : }
      94             : 
      95             : void
      96           0 : nsSMILInterval::SetEnd(nsSMILInstanceTime& aEnd)
      97             : {
      98           0 :   MOZ_ASSERT(!mEndFixed,
      99             :              "Attempt to set end time but the end point is fixed");
     100             :   // As with SetBegin, check we're not making an instance time dependent on
     101             :   // itself.
     102           0 :   MOZ_ASSERT(!mEnd || aEnd.GetBaseTime() != mEnd,
     103             :              "Attempting to make self-dependent instance time");
     104             : 
     105           0 :   mEnd = &aEnd;
     106           0 : }
     107             : 
     108             : void
     109           0 : nsSMILInterval::FixBegin()
     110             : {
     111           0 :   MOZ_ASSERT(mBegin && mEnd,
     112             :              "Fixing begin point on un-initialized interval");
     113           0 :   MOZ_ASSERT(!mBeginFixed, "Duplicate calls to FixBegin()");
     114           0 :   mBeginFixed = true;
     115           0 :   mBegin->AddRefFixedEndpoint();
     116           0 : }
     117             : 
     118             : void
     119           0 : nsSMILInterval::FixEnd()
     120             : {
     121           0 :   MOZ_ASSERT(mBegin && mEnd,
     122             :              "Fixing end point on un-initialized interval");
     123           0 :   MOZ_ASSERT(mBeginFixed,
     124             :              "Fixing the end of an interval without a fixed begin");
     125           0 :   MOZ_ASSERT(!mEndFixed, "Duplicate calls to FixEnd()");
     126           0 :   mEndFixed = true;
     127           0 :   mEnd->AddRefFixedEndpoint();
     128           0 : }
     129             : 
     130             : void
     131           0 : nsSMILInterval::AddDependentTime(nsSMILInstanceTime& aTime)
     132             : {
     133             :   RefPtr<nsSMILInstanceTime>* inserted =
     134           0 :     mDependentTimes.InsertElementSorted(&aTime);
     135           0 :   if (!inserted) {
     136           0 :     NS_WARNING("Insufficient memory to insert instance time.");
     137             :   }
     138           0 : }
     139             : 
     140             : void
     141           0 : nsSMILInterval::RemoveDependentTime(const nsSMILInstanceTime& aTime)
     142             : {
     143             : #ifdef DEBUG
     144             :   bool found =
     145             : #endif
     146           0 :     mDependentTimes.RemoveElementSorted(&aTime);
     147           0 :   MOZ_ASSERT(found, "Couldn't find instance time to delete.");
     148           0 : }
     149             : 
     150             : void
     151           0 : nsSMILInterval::GetDependentTimes(InstanceTimeList& aTimes)
     152             : {
     153           0 :   aTimes = mDependentTimes;
     154           0 : }
     155             : 
     156             : bool
     157           0 : nsSMILInterval::IsDependencyChainLink() const
     158             : {
     159           0 :   if (!mBegin || !mEnd)
     160           0 :     return false; // Not yet initialised so it can't be part of a chain
     161             : 
     162           0 :   if (mDependentTimes.IsEmpty())
     163           0 :     return false; // No dependents, chain end
     164             : 
     165             :   // So we have dependents, but we're still only a link in the chain (as opposed
     166             :   // to the end of the chain) if one of our endpoints is dependent on an
     167             :   // interval other than ourselves.
     168           0 :   return (mBegin->IsDependent() && mBegin->GetBaseInterval() != this) ||
     169           0 :          (mEnd->IsDependent() && mEnd->GetBaseInterval() != this);
     170             : }

Generated by: LCOV version 1.13