LCOV - code coverage report
Current view: directory - objdir/dist/include/mozilla/layout - FrameChildList.h (source / functions) Found Hit Coverage
Test: app.info Lines: 33 0 0.0 %
Date: 2012-06-02 Functions: 17 0 0.0 %

       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                 : /* ***** BEGIN LICENSE BLOCK *****
       4                 :  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
       5                 :  *
       6                 :  * The contents of this file are subject to the Mozilla Public License Version
       7                 :  * 1.1 (the "License"); you may not use this file except in compliance with
       8                 :  * the License. You may obtain a copy of the License at
       9                 :  * http://www.mozilla.org/MPL/
      10                 :  *
      11                 :  * Software distributed under the License is distributed on an "AS IS" basis,
      12                 :  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
      13                 :  * for the specific language governing rights and limitations under the
      14                 :  * License.
      15                 :  *
      16                 :  * The Original Code is mozilla.org code.
      17                 :  *
      18                 :  * The Initial Developer of the Original Code is the Mozilla Foundation.
      19                 :  * Portions created by the Initial Developer are Copyright (C) 2011
      20                 :  * the Initial Developer. All Rights Reserved.
      21                 :  *
      22                 :  * Contributor(s):
      23                 :  *   Mats Palmgren <matspal@gmail.com> (original author)
      24                 :  *
      25                 :  * Alternatively, the contents of this file may be used under the terms of
      26                 :  * either the GNU General Public License Version 2 or later (the "GPL"), or
      27                 :  * 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                 : #ifndef FrameChildList_h_
      40                 : #define FrameChildList_h_
      41                 : 
      42                 : #include "nsFrameList.h"
      43                 : #include "nsTArray.h"
      44                 : 
      45                 : class nsIFrame;
      46                 : 
      47                 : namespace mozilla {
      48                 : namespace layout {
      49                 : 
      50                 : // enum FrameChildListID lives in nsFrameList.h to solve circular dependencies.
      51                 : 
      52                 : #ifdef DEBUG
      53                 : extern const char* ChildListName(FrameChildListID aListID);
      54                 : #endif
      55                 : 
      56                 : class FrameChildListIDs {
      57                 : friend class FrameChildListIterator;
      58                 :  public:
      59               0 :   FrameChildListIDs() : mIDs(0) {}
      60                 :   FrameChildListIDs(const FrameChildListIDs& aOther) : mIDs(aOther.mIDs) {}
      61               0 :   FrameChildListIDs(FrameChildListID aListID) : mIDs(aListID) {}
      62                 : 
      63               0 :   FrameChildListIDs operator|(FrameChildListIDs aOther) const {
      64               0 :     return FrameChildListIDs(mIDs | aOther.mIDs);
      65                 :   }
      66               0 :   FrameChildListIDs& operator|=(FrameChildListIDs aOther) {
      67               0 :     mIDs |= aOther.mIDs;
      68               0 :     return *this;
      69                 :   }
      70                 :   bool operator==(FrameChildListIDs aOther) const {
      71                 :     return mIDs == aOther.mIDs;
      72                 :   }
      73                 :   bool operator!=(FrameChildListIDs aOther) const {
      74                 :     return !(*this == aOther);
      75                 :   }
      76               0 :   bool Contains(FrameChildListIDs aOther) const {
      77               0 :     return (mIDs & aOther.mIDs) == aOther.mIDs;
      78                 :   }
      79                 : 
      80                 :  protected:
      81               0 :   FrameChildListIDs(PRUint32 aIDs) : mIDs(aIDs) {}
      82                 :   PRUint32 mIDs;
      83                 : };
      84                 : 
      85               0 : class FrameChildList {
      86                 :  public:
      87               0 :   FrameChildList(const nsFrameList& aList, FrameChildListID aID)
      88               0 :     : mList(aList), mID(aID) {}
      89                 :   nsFrameList mList;
      90                 :   FrameChildListID mID;
      91                 : };
      92                 : 
      93                 : /**
      94                 :  * A class to iterate frame child lists.
      95                 :  */
      96                 : class NS_STACK_CLASS FrameChildListArrayIterator {
      97                 :  public:
      98               0 :   FrameChildListArrayIterator(const nsTArray<FrameChildList>& aLists)
      99               0 :     : mLists(aLists), mCurrentIndex(0) {}
     100               0 :   bool IsDone() const { return mCurrentIndex >= mLists.Length(); }
     101               0 :   FrameChildListID CurrentID() const {
     102               0 :     NS_ASSERTION(!IsDone(), "CurrentID(): iterator at end");
     103               0 :     return mLists[mCurrentIndex].mID;
     104                 :   }
     105               0 :   const nsFrameList& CurrentList() const {
     106               0 :     NS_ASSERTION(!IsDone(), "CurrentList(): iterator at end");
     107               0 :     return mLists[mCurrentIndex].mList;
     108                 :   }
     109               0 :   void Next() {
     110               0 :     NS_ASSERTION(!IsDone(), "Next(): iterator at end");
     111               0 :     ++mCurrentIndex;
     112               0 :   }
     113                 : 
     114                 : protected:
     115                 :   const nsTArray<FrameChildList>& mLists;
     116                 :   PRUint32 mCurrentIndex;
     117                 : };
     118                 : 
     119                 : /**
     120                 :  * A class for retrieving a frame's child lists and iterate them.
     121                 :  */
     122                 : class NS_STACK_CLASS FrameChildListIterator
     123               0 :   : public FrameChildListArrayIterator {
     124                 :  public:
     125                 :   FrameChildListIterator(const nsIFrame* aFrame);
     126                 : 
     127                 : protected:
     128                 :   nsAutoTArray<FrameChildList,4> mLists;
     129                 : };
     130                 : 
     131                 : } // namespace layout
     132                 : } // namespace mozilla
     133                 : 
     134                 : inline mozilla::layout::FrameChildListIDs
     135               0 : operator|(mozilla::layout::FrameChildListID aLeftOp,
     136                 :           mozilla::layout::FrameChildListID aRightOp)
     137                 : {
     138                 :   return mozilla::layout::FrameChildListIDs(aLeftOp) |
     139               0 :          mozilla::layout::FrameChildListIDs(aRightOp);
     140                 : }
     141                 : 
     142                 : inline mozilla::layout::FrameChildListIDs
     143                 : operator|(mozilla::layout::FrameChildListID aLeftOp,
     144                 :           mozilla::layout::FrameChildListIDs aRightOp)
     145                 : {
     146                 :   return mozilla::layout::FrameChildListIDs(aLeftOp) | aRightOp;
     147                 : }
     148                 : 
     149               0 : inline void nsFrameList::AppendIfNonempty(
     150                 :          nsTArray<mozilla::layout::FrameChildList>* aLists,
     151                 :          mozilla::layout::FrameChildListID aListID) const
     152                 : {
     153               0 :   if (NotEmpty()) {
     154               0 :     aLists->AppendElement(mozilla::layout::FrameChildList(*this, aListID));
     155                 :   }
     156               0 : }
     157                 : 
     158                 : #endif /* !defined(FrameChildList_h_) */

Generated by: LCOV version 1.7