LCOV - code coverage report
Current view: top level - dom/grid - GridTracks.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 0 58 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 16 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 "GridTracks.h"
       8             : 
       9             : #include "GridDimension.h"
      10             : #include "GridTrack.h"
      11             : #include "mozilla/dom/GridBinding.h"
      12             : #include "nsGridContainerFrame.h"
      13             : 
      14             : namespace mozilla {
      15             : namespace dom {
      16             : 
      17           0 : NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(GridTracks, mParent, mTracks)
      18           0 : NS_IMPL_CYCLE_COLLECTING_ADDREF(GridTracks)
      19           0 : NS_IMPL_CYCLE_COLLECTING_RELEASE(GridTracks)
      20           0 : NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(GridTracks)
      21           0 :   NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
      22           0 :   NS_INTERFACE_MAP_ENTRY(nsISupports)
      23           0 : NS_INTERFACE_MAP_END
      24             : 
      25           0 : GridTracks::GridTracks(GridDimension *aParent)
      26           0 :   : mParent(aParent)
      27             : {
      28           0 :   MOZ_ASSERT(aParent,
      29             :     "Should never be instantiated with a null GridDimension");
      30           0 : }
      31             : 
      32           0 : GridTracks::~GridTracks()
      33             : {
      34           0 : }
      35             : 
      36             : JSObject*
      37           0 : GridTracks::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
      38             : {
      39           0 :   return GridTracksBinding::Wrap(aCx, this, aGivenProto);
      40             : }
      41             : 
      42             : uint32_t
      43           0 : GridTracks::Length() const
      44             : {
      45           0 :   return mTracks.Length();
      46             : }
      47             : 
      48             : GridTrack*
      49           0 : GridTracks::Item(uint32_t aIndex)
      50             : {
      51           0 :   return mTracks.SafeElementAt(aIndex);
      52             : }
      53             : 
      54             : GridTrack*
      55           0 : GridTracks::IndexedGetter(uint32_t aIndex,
      56             :                           bool& aFound)
      57             : {
      58           0 :   aFound = aIndex < mTracks.Length();
      59           0 :   if (!aFound) {
      60           0 :     return nullptr;
      61             :   }
      62           0 :   return mTracks[aIndex];
      63             : }
      64             : 
      65             : void
      66           0 : GridTracks::SetTrackInfo(const ComputedGridTrackInfo* aTrackInfo)
      67             : {
      68             :   // rebuild the tracks based on aTrackInfo
      69           0 :   mTracks.Clear();
      70             : 
      71           0 :   if (!aTrackInfo) {
      72           0 :     return;
      73             :   }
      74             : 
      75           0 :   nscoord lastTrackEdge = 0;
      76           0 :   uint32_t repeatIndex = 0;
      77             :   auto AppendRemovedAutoFits = [this, &aTrackInfo, &lastTrackEdge,
      78           0 :                                 &repeatIndex]()
      79           0 :   {
      80           0 :     uint32_t numRepeatTracks = aTrackInfo->mRemovedRepeatTracks.Length();
      81             :     // Add in removed auto-fit tracks
      82           0 :     while (repeatIndex < numRepeatTracks &&
      83           0 :          aTrackInfo->mRemovedRepeatTracks[repeatIndex]) {
      84             : 
      85           0 :       RefPtr<GridTrack> track = new GridTrack(this);
      86           0 :       mTracks.AppendElement(track);
      87           0 :       track->SetTrackValues(
      88             :         nsPresContext::AppUnitsToDoubleCSSPixels(lastTrackEdge),
      89             :         nsPresContext::AppUnitsToDoubleCSSPixels(0),
      90             :         GridDeclaration::Explicit,
      91             :         GridTrackState::Removed
      92           0 :       );
      93           0 :       repeatIndex++;
      94             :     }
      95           0 :     repeatIndex++;
      96           0 :   };
      97             : 
      98           0 :   for (size_t i = aTrackInfo->mStartFragmentTrack;
      99           0 :        i < aTrackInfo->mEndFragmentTrack;
     100             :        i++) {
     101           0 :     if (i >= aTrackInfo->mRepeatFirstTrack) {
     102             :       // Append removed auto-fit tracks, if appropriate. The
     103             :       // AppendRemovedAutoFits function exits early once it has been called
     104             :       // aTrackInfo->mRemovedRepeatTracks.Length() times -- a check we don't
     105             :       // replicate here or at subsequent calling sites.
     106           0 :       AppendRemovedAutoFits();
     107             :     }
     108             : 
     109           0 :     RefPtr<GridTrack> track = new GridTrack(this);
     110           0 :     mTracks.AppendElement(track);
     111           0 :     track->SetTrackValues(
     112           0 :       nsPresContext::AppUnitsToDoubleCSSPixels(aTrackInfo->mPositions[i]),
     113           0 :       nsPresContext::AppUnitsToDoubleCSSPixels(aTrackInfo->mSizes[i]),
     114             :       (
     115             :         // Implicit if index is before the first explicit track, or after
     116             :         // the last explicit track.
     117           0 :         (i < aTrackInfo->mNumLeadingImplicitTracks) ||
     118           0 :         (i >= aTrackInfo->mNumLeadingImplicitTracks +
     119           0 :               aTrackInfo->mNumExplicitTracks) ?
     120             :           GridDeclaration::Implicit :
     121             :           GridDeclaration::Explicit
     122             :       ),
     123           0 :       GridTrackState(aTrackInfo->mStates[i])
     124           0 :     );
     125             : 
     126           0 :     lastTrackEdge = aTrackInfo->mPositions[i] + aTrackInfo->mSizes[i];
     127             :   }
     128             : 
     129             :   // Append any trailing removed auto-fit tracks.
     130           0 :   AppendRemovedAutoFits();
     131             : }
     132             : 
     133             : } // namespace dom
     134             : } // namespace mozilla

Generated by: LCOV version 1.13