LCOV - code coverage report
Current view: directory - layout/base - nsGenConList.h (source / functions) Found Hit Coverage
Test: app.info Lines: 21 0 0.0 %
Date: 2012-06-02 Functions: 11 0 0.0 %

       1                 : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
       2                 : /* ***** BEGIN LICENSE BLOCK *****
       3                 :  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
       4                 :  *
       5                 :  * The contents of this file are subject to the Mozilla Public License Version
       6                 :  * 1.1 (the "License"); you may not use this file except in compliance with
       7                 :  * the License. You may obtain a copy of the License at
       8                 :  * http://www.mozilla.org/MPL/
       9                 :  *
      10                 :  * Software distributed under the License is distributed on an "AS IS" basis,
      11                 :  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
      12                 :  * for the specific language governing rights and limitations under the
      13                 :  * License.
      14                 :  *
      15                 :  * The Original Code is mozilla.org code.
      16                 :  *
      17                 :  * The Initial Developer of the Original Code is
      18                 :  * Esben Mose Hansen.
      19                 :  *
      20                 :  * Contributor(s):
      21                 :  *   Esben Mose Hansen <esben@oek.dk> (original author)
      22                 :  *   L. David Baron <dbaron@dbaron.org>
      23                 :  *
      24                 :  * Alternatively, the contents of this file may be used under the terms of
      25                 :  * either the GNU General Public License Version 2 or later (the "GPL"), or
      26                 :  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
      27                 :  * in which case the provisions of the GPL or the LGPL are applicable instead
      28                 :  * of those above. If you wish to allow use of your version of this file only
      29                 :  * under the terms of either the GPL or the LGPL, and not to allow others to
      30                 :  * use your version of this file under the terms of the MPL, indicate your
      31                 :  * decision by deleting the provisions above and replace them with the notice
      32                 :  * and other provisions required by the GPL or the LGPL. If you do not delete
      33                 :  * the provisions above, a recipient may use your version of this file under
      34                 :  * the terms of any one of the MPL, the GPL or the LGPL.
      35                 :  *
      36                 :  * ***** END LICENSE BLOCK ***** */
      37                 : 
      38                 : /* base class for nsCounterList and nsQuoteList */
      39                 : 
      40                 : #ifndef nsGenConList_h___
      41                 : #define nsGenConList_h___
      42                 : 
      43                 : #include "nsIFrame.h"
      44                 : #include "nsStyleStruct.h"
      45                 : #include "prclist.h"
      46                 : #include "nsIDOMCharacterData.h"
      47                 : #include "nsCSSPseudoElements.h"
      48                 : 
      49                 : class nsGenConList;
      50                 : 
      51                 : struct nsGenConNode : public PRCList {
      52                 :   // The wrapper frame for all of the pseudo-element's content.  This
      53                 :   // frame generally has useful style data and has the
      54                 :   // NS_FRAME_GENERATED_CONTENT bit set (so we use it to track removal),
      55                 :   // but does not necessarily for |nsCounterChangeNode|s.
      56                 :   nsIFrame* mPseudoFrame;
      57                 : 
      58                 :   // Index within the list of things specified by the 'content' property,
      59                 :   // which is needed to do 'content: open-quote open-quote' correctly,
      60                 :   // and needed for similar cases for counters.
      61                 :   const PRInt32 mContentIndex;
      62                 : 
      63                 :   // null for 'content:no-open-quote', 'content:no-close-quote' and for
      64                 :   // counter nodes for increments and resets (rather than uses)
      65                 :   nsCOMPtr<nsIDOMCharacterData> mText;
      66                 : 
      67               0 :   nsGenConNode(PRInt32 aContentIndex)
      68                 :     : mPseudoFrame(nsnull)
      69               0 :     , mContentIndex(aContentIndex)
      70                 :   {
      71               0 :   }
      72                 : 
      73                 :   /**
      74                 :    * Finish initializing the generated content node once we know the
      75                 :    * relevant text frame. This must be called just after
      76                 :    * the textframe has been initialized. This need not be called at all
      77                 :    * for nodes that don't generate text. This will generally set the
      78                 :    * mPseudoFrame, insert the node into aList, and set aTextFrame up
      79                 :    * with the correct text.
      80                 :    * @param aList the list the node belongs to
      81                 :    * @param aPseudoFrame the :before or :after frame
      82                 :    * @param aTextFrame the textframe where the node contents will render
      83                 :    * @return true iff this marked the list dirty
      84                 :    */
      85               0 :   virtual bool InitTextFrame(nsGenConList* aList, nsIFrame* aPseudoFrame,
      86                 :                                nsIFrame* aTextFrame)
      87                 :   {
      88               0 :     mPseudoFrame = aPseudoFrame;
      89               0 :     CheckFrameAssertions();
      90               0 :     return false;
      91                 :   }
      92                 : 
      93               0 :   virtual ~nsGenConNode() {} // XXX Avoid, perhaps?
      94                 : 
      95                 : protected:
      96               0 :   void CheckFrameAssertions() {
      97               0 :     NS_ASSERTION(mContentIndex <
      98                 :                    PRInt32(mPseudoFrame->GetStyleContent()->ContentCount()),
      99                 :                  "index out of range");
     100                 :       // We allow negative values of mContentIndex for 'counter-reset' and
     101                 :       // 'counter-increment'.
     102                 : 
     103               0 :     NS_ASSERTION(mContentIndex < 0 ||
     104                 :                  mPseudoFrame->GetStyleContext()->GetPseudo() ==
     105                 :                    nsCSSPseudoElements::before ||
     106                 :                  mPseudoFrame->GetStyleContext()->GetPseudo() ==
     107                 :                    nsCSSPseudoElements::after,
     108                 :                  "not :before/:after generated content and not counter change");
     109               0 :     NS_ASSERTION(mContentIndex < 0 ||
     110                 :                  mPseudoFrame->GetStateBits() & NS_FRAME_GENERATED_CONTENT,
     111                 :                  "not generated content and not counter change");
     112               0 :   }
     113                 : };
     114                 : 
     115                 : class nsGenConList {
     116                 : protected:
     117                 :   nsGenConNode* mFirstNode;
     118                 :   PRUint32 mSize;
     119                 : public:
     120               0 :   nsGenConList() : mFirstNode(nsnull), mSize(0) {}
     121               0 :   ~nsGenConList() { Clear(); }
     122                 :   void Clear();
     123               0 :   static nsGenConNode* Next(nsGenConNode* aNode) {
     124               0 :     return static_cast<nsGenConNode*>(PR_NEXT_LINK(aNode));
     125                 :   }
     126               0 :   static nsGenConNode* Prev(nsGenConNode* aNode) {
     127               0 :     return static_cast<nsGenConNode*>(PR_PREV_LINK(aNode));
     128                 :   }
     129                 :   void Insert(nsGenConNode* aNode);
     130                 :   // returns whether any nodes have been destroyed
     131                 :   bool DestroyNodesFor(nsIFrame* aFrame); //destroy all nodes with aFrame as parent
     132                 : 
     133                 :   // Return true if |aNode1| is after |aNode2|.
     134                 :   static bool NodeAfter(const nsGenConNode* aNode1,
     135                 :                           const nsGenConNode* aNode2);
     136                 : 
     137               0 :   void Remove(nsGenConNode* aNode) { PR_REMOVE_LINK(aNode); mSize--; }
     138               0 :   bool IsLast(nsGenConNode* aNode) { return (Next(aNode) == mFirstNode); }
     139                 : };
     140                 : 
     141                 : #endif /* nsGenConList_h___ */

Generated by: LCOV version 1.7