LCOV - code coverage report
Current view: top level - layout/generic - FrameChildList.h (source / functions) Hit Total Coverage
Test: output.info Lines: 34 34 100.0 %
Date: 2017-07-14 16:53:18 Functions: 16 16 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
       2             : /* vim: set shiftwidth=2 tabstop=8 autoindent cindent expandtab: */
       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             : #ifndef FrameChildList_h_
       8             : #define FrameChildList_h_
       9             : 
      10             : #include "nsFrameList.h"
      11             : #include "nsTArray.h"
      12             : 
      13             : class nsIFrame;
      14             : 
      15             : namespace mozilla {
      16             : namespace layout {
      17             : 
      18             : // enum FrameChildListID lives in nsFrameList.h to solve circular dependencies.
      19             : 
      20             : #ifdef DEBUG_FRAME_DUMP
      21             : extern const char* ChildListName(FrameChildListID aListID);
      22             : #endif
      23             : 
      24             : class FrameChildListIDs {
      25             : friend class FrameChildListIterator;
      26             :  public:
      27        5037 :   FrameChildListIDs() : mIDs(0) {}
      28             :   FrameChildListIDs(const FrameChildListIDs& aOther) : mIDs(aOther.mIDs) {}
      29        8793 :   MOZ_IMPLICIT FrameChildListIDs(FrameChildListID aListID) : mIDs(aListID) {}
      30             : 
      31        1210 :   FrameChildListIDs operator|(FrameChildListIDs aOther) const {
      32        1210 :     return FrameChildListIDs(mIDs | aOther.mIDs);
      33             :   }
      34        3522 :   FrameChildListIDs& operator|=(FrameChildListIDs aOther) {
      35        3522 :     mIDs |= aOther.mIDs;
      36        3522 :     return *this;
      37             :   }
      38             :   bool operator==(FrameChildListIDs aOther) const {
      39             :     return mIDs == aOther.mIDs;
      40             :   }
      41             :   bool operator!=(const FrameChildListIDs& aOther) const {
      42             :     return !(*this == aOther);
      43             :   }
      44        4057 :   bool Contains(FrameChildListIDs aOther) const {
      45        4057 :     return (mIDs & aOther.mIDs) == aOther.mIDs;
      46             :   }
      47             : 
      48             :  protected:
      49        1210 :   explicit FrameChildListIDs(uint32_t aIDs) : mIDs(aIDs) {}
      50             :   uint32_t mIDs;
      51             : };
      52             : 
      53        4846 : class FrameChildList {
      54             :  public:
      55        4846 :   FrameChildList(const nsFrameList& aList, FrameChildListID aID)
      56        4846 :     : mList(aList), mID(aID) {}
      57             :   nsFrameList mList;
      58             :   FrameChildListID mID;
      59             : };
      60             : 
      61             : /**
      62             :  * A class to iterate frame child lists.
      63             :  */
      64             : class MOZ_STACK_CLASS FrameChildListArrayIterator {
      65             :  public:
      66        6008 :   explicit FrameChildListArrayIterator(const nsTArray<FrameChildList>& aLists)
      67        6008 :     : mLists(aLists), mCurrentIndex(0) {}
      68       23411 :   bool IsDone() const { return mCurrentIndex >= mLists.Length(); }
      69        2090 :   FrameChildListID CurrentID() const {
      70        2090 :     NS_ASSERTION(!IsDone(), "CurrentID(): iterator at end");
      71        2090 :     return mLists[mCurrentIndex].mID;
      72             :   }
      73        4473 :   const nsFrameList& CurrentList() const {
      74        4473 :     NS_ASSERTION(!IsDone(), "CurrentList(): iterator at end");
      75        4473 :     return mLists[mCurrentIndex].mList;
      76             :   }
      77        4846 :   void Next() {
      78        4846 :     NS_ASSERTION(!IsDone(), "Next(): iterator at end");
      79        4846 :     ++mCurrentIndex;
      80        4846 :   }
      81             : 
      82             : protected:
      83             :   const nsTArray<FrameChildList>& mLists;
      84             :   uint32_t mCurrentIndex;
      85             : };
      86             : 
      87             : /**
      88             :  * A class for retrieving a frame's child lists and iterate them.
      89             :  */
      90        4434 : class MOZ_STACK_CLASS FrameChildListIterator
      91             :   : public FrameChildListArrayIterator {
      92             :  public:
      93             :   explicit FrameChildListIterator(const nsIFrame* aFrame);
      94             : 
      95             : protected:
      96             :   AutoTArray<FrameChildList,4> mLists;
      97             : };
      98             : 
      99             : inline mozilla::layout::FrameChildListIDs
     100           4 : operator|(mozilla::layout::FrameChildListID aLeftOp,
     101             :           mozilla::layout::FrameChildListID aRightOp)
     102             : {
     103           8 :   return mozilla::layout::FrameChildListIDs(aLeftOp) |
     104          12 :          mozilla::layout::FrameChildListIDs(aRightOp);
     105             : }
     106             : 
     107             : inline mozilla::layout::FrameChildListIDs
     108             : operator|(mozilla::layout::FrameChildListID aLeftOp,
     109             :           const mozilla::layout::FrameChildListIDs& aRightOp)
     110             : {
     111             :   return mozilla::layout::FrameChildListIDs(aLeftOp) | aRightOp;
     112             : }
     113             : 
     114             : } // namespace layout
     115             : } // namespace mozilla
     116             : 
     117        6273 : inline void nsFrameList::AppendIfNonempty(
     118             :          nsTArray<mozilla::layout::FrameChildList>* aLists,
     119             :          mozilla::layout::FrameChildListID aListID) const
     120             : {
     121        6273 :   if (NotEmpty()) {
     122        4846 :     aLists->AppendElement(mozilla::layout::FrameChildList(*this, aListID));
     123             :   }
     124        6273 : }
     125             : 
     126             : #endif /* !defined(FrameChildList_h_) */

Generated by: LCOV version 1.13