LCOV - code coverage report
Current view: directory - objdir/dist/include - nsRuleData.h (source / functions) Found Hit Coverage
Test: app.info Lines: 7 0 0.0 %
Date: 2012-06-02 Functions: 1 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 Communicator client code.
      16                 :  *
      17                 :  * The Initial Developer of the Original Code is
      18                 :  * Netscape Communications Corporation.
      19                 :  * Portions created by the Initial Developer are Copyright (C) 1998
      20                 :  * the Initial Developer. All Rights Reserved.
      21                 :  *
      22                 :  * Contributor(s):
      23                 :  *   Original Author: David W. Hyatt (hyatt@netscape.com)
      24                 :  *
      25                 :  * Alternatively, the contents of this file may be used under the terms of
      26                 :  * either of the GNU General Public License Version 2 or later (the "GPL"),
      27                 :  * or 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                 : /*
      40                 :  * temporary (expanded) representation of property-value pairs used to
      41                 :  * hold data from matched rules during style data computation.
      42                 :  */
      43                 : 
      44                 : #ifndef nsRuleData_h_
      45                 : #define nsRuleData_h_
      46                 : 
      47                 : #include "nsCSSProps.h"
      48                 : #include "nsStyleStructFwd.h"
      49                 : 
      50                 : class nsPresContext;
      51                 : class nsStyleContext;
      52                 : struct nsRuleData;
      53                 : 
      54                 : typedef void (*nsPostResolveFunc)(void* aStyleStruct, nsRuleData* aData);
      55                 : 
      56                 : struct nsRuleData
      57                 : {
      58                 :   const PRUint32 mSIDs;
      59                 :   bool mCanStoreInRuleTree;
      60                 :   bool mIsImportantRule;
      61                 :   PRUint8 mLevel; // an nsStyleSet::sheetType
      62                 :   nsPresContext* const mPresContext;
      63                 :   nsStyleContext* const mStyleContext;
      64                 :   const nsPostResolveFunc mPostResolveCallback;
      65                 : 
      66                 :   // We store nsCSSValues needed to compute the data for one or more
      67                 :   // style structs (specified by the bitfield mSIDs).  These are stored
      68                 :   // in a single array allocation (which our caller allocates; see
      69                 :   // AutoCSSValueArray)   The offset of each property |prop| in
      70                 :   // mValueStorage is the sum of
      71                 :   // mValueOffsets[nsCSSProps::kSIDTable[prop]] and
      72                 :   // nsCSSProps::PropertyIndexInStruct(prop).  The only place we gather
      73                 :   // more than one style struct's data at a time is
      74                 :   // nsRuleNode::HasAuthorSpecifiedRules; therefore some code that we
      75                 :   // know is not called from HasAuthorSpecifiedRules assumes that the
      76                 :   // mValueOffsets for the one struct in mSIDs is zero.
      77                 :   nsCSSValue* const mValueStorage; // our user owns this array
      78                 :   size_t mValueOffsets[nsStyleStructID_Length];
      79                 : 
      80                 :   nsRuleData(PRUint32 aSIDs, nsCSSValue* aValueStorage,
      81                 :              nsPresContext* aContext, nsStyleContext* aStyleContext);
      82                 : 
      83                 : #ifdef DEBUG
      84                 :   ~nsRuleData();
      85                 : #else
      86                 :   ~nsRuleData() {}
      87                 : #endif
      88                 : 
      89                 :   /**
      90                 :    * Return a pointer to the value object within |this| corresponding
      91                 :    * to property |aProperty|.
      92                 :    *
      93                 :    * This function must only be called if the given property is in
      94                 :    * mSIDs.
      95                 :    */
      96               0 :   nsCSSValue* ValueFor(nsCSSProperty aProperty)
      97                 :   {
      98               0 :     NS_ABORT_IF_FALSE(aProperty < eCSSProperty_COUNT_no_shorthands,
      99                 :                       "invalid or shorthand property");
     100                 : 
     101               0 :     nsStyleStructID sid = nsCSSProps::kSIDTable[aProperty];
     102               0 :     size_t indexInStruct = nsCSSProps::PropertyIndexInStruct(aProperty);
     103                 : 
     104                 :     // This should really be nsCachedStyleData::GetBitForSID, but we can't
     105                 :     // include that here since it includes us.
     106               0 :     NS_ABORT_IF_FALSE(mSIDs & (1 << sid),
     107                 :                       "calling nsRuleData::ValueFor on property not in mSIDs");
     108               0 :     NS_ABORT_IF_FALSE(sid != eStyleStruct_BackendOnly &&
     109                 :                       indexInStruct != size_t(-1),
     110                 :                       "backend-only property");
     111                 : 
     112               0 :     return mValueStorage + mValueOffsets[sid] + indexInStruct;
     113                 :   }
     114                 : 
     115                 :   const nsCSSValue* ValueFor(nsCSSProperty aProperty) const {
     116                 :     return const_cast<nsRuleData*>(this)->ValueFor(aProperty);
     117                 :   }
     118                 : 
     119                 :   /**
     120                 :    * Getters like ValueFor(aProperty), but for each property by name
     121                 :    * (ValueForBackgroundColor, etc.), and more efficient than ValueFor.
     122                 :    * These use the names used for the property on DOM interfaces (the
     123                 :    * 'method' field in nsCSSPropList.h).
     124                 :    *
     125                 :    * Like ValueFor(), the caller must check that the property is within
     126                 :    * mSIDs.
     127                 :    */
     128                 :   #define CSS_PROP_DOMPROP_PREFIXED(prop_) prop_
     129                 :   #define CSS_PROP(name_, id_, method_, flags_, parsevariant_, kwtable_,     \
     130                 :                    stylestruct_, stylestructoffset_, animtype_)              \
     131                 :     nsCSSValue* ValueFor##method_() {                                        \
     132                 :       NS_ABORT_IF_FALSE(mSIDs & NS_STYLE_INHERIT_BIT(stylestruct_),          \
     133                 :                         "Calling nsRuleData::ValueFor" #method_ " without "  \
     134                 :                         "NS_STYLE_INHERIT_BIT(" #stylestruct_ " in mSIDs."); \
     135                 :       nsStyleStructID sid = eStyleStruct_##stylestruct_;                     \
     136                 :       size_t indexInStruct =                                                 \
     137                 :         nsCSSProps::PropertyIndexInStruct(eCSSProperty_##id_);               \
     138                 :       NS_ABORT_IF_FALSE(sid != eStyleStruct_BackendOnly &&                   \
     139                 :                         indexInStruct != size_t(-1),                         \
     140                 :                         "backend-only property");                            \
     141                 :       return mValueStorage + mValueOffsets[sid] + indexInStruct;             \
     142                 :     }                                                                        \
     143                 :     const nsCSSValue* ValueFor##method_() const {                            \
     144                 :       return const_cast<nsRuleData*>(this)->ValueFor##method_();             \
     145                 :     }
     146                 :   #define CSS_PROP_BACKENDONLY(name_, id_, method_, flags_, parsevariant_,   \
     147                 :                                kwtable_)                                     \
     148                 :     /* empty; backend-only structs are not in nsRuleData  */
     149                 :   #include "nsCSSPropList.h"
     150                 :   #undef CSS_PROP
     151                 :   #undef CSS_PROP_DOMPROP_PREFIXED
     152                 :   #undef CSS_PROP_BACKENDONLY
     153                 : 
     154                 : private:
     155                 :   inline size_t GetPoisonOffset();
     156                 : 
     157                 : };
     158                 : 
     159                 : #endif

Generated by: LCOV version 1.7