Back to index

lightning-sunbird  0.9+nobinonly
nsRuleNode.h
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
00002 /* ***** BEGIN LICENSE BLOCK *****
00003  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00004  *
00005  * The contents of this file are subject to the Mozilla Public License Version
00006  * 1.1 (the "License"); you may not use this file except in compliance with
00007  * the License. You may obtain a copy of the License at
00008  * http://www.mozilla.org/MPL/
00009  *
00010  * Software distributed under the License is distributed on an "AS IS" basis,
00011  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00012  * for the specific language governing rights and limitations under the
00013  * License.
00014  *
00015  * The Original Code is Mozilla Communicator client code.
00016  *
00017  * The Initial Developer of the Original Code is
00018  * Netscape Communications Corporation.
00019  * Portions created by the Initial Developer are Copyright (C) 1998
00020  * the Initial Developer. All Rights Reserved.
00021  *
00022  * Contributor(s):
00023  *   Original Author: David W. Hyatt (hyatt@netscape.com)
00024  *
00025  * Alternatively, the contents of this file may be used under the terms of
00026  * either of the GNU General Public License Version 2 or later (the "GPL"),
00027  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00028  * in which case the provisions of the GPL or the LGPL are applicable instead
00029  * of those above. If you wish to allow use of your version of this file only
00030  * under the terms of either the GPL or the LGPL, and not to allow others to
00031  * use your version of this file under the terms of the MPL, indicate your
00032  * decision by deleting the provisions above and replace them with the notice
00033  * and other provisions required by the GPL or the LGPL. If you do not delete
00034  * the provisions above, a recipient may use your version of this file under
00035  * the terms of any one of the MPL, the GPL or the LGPL.
00036  *
00037  * ***** END LICENSE BLOCK ***** */
00038 
00039 #ifndef nsRuleNode_h___
00040 #define nsRuleNode_h___
00041 
00042 #include "nsPresContext.h"
00043 #include "nsStyleStruct.h"
00044 
00045 class nsStyleContext;
00046 struct nsRuleList;
00047 struct PLDHashTable;
00048 class nsILanguageAtomService;
00049 struct nsRuleData;
00050 class nsIStyleRule;
00051 struct nsCSSStruct;
00052 // Copy of typedef that's in nsCSSStruct.h, for compilation speed.
00053 typedef nsCSSStruct nsRuleDataStruct;
00054 
00055 struct nsRuleDataFont;
00056 class nsCSSValue;
00057 
00058 typedef void (*nsPostResolveFunc)(nsStyleStruct* aStyleStruct, nsRuleData* aData);
00059 
00060 struct nsInheritedStyleData
00061 {
00062 
00063 #define STYLE_STRUCT_INHERITED(name, checkdata_cb, ctor_args) \
00064   nsStyle##name * m##name##Data;
00065 #define STYLE_STRUCT_RESET(name, checkdata_cb, ctor_args)
00066 
00067 #include "nsStyleStructList.h"
00068 
00069 #undef STYLE_STRUCT_INHERITED
00070 #undef STYLE_STRUCT_RESET
00071 
00072   void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
00073     return aContext->AllocateFromShell(sz);
00074   };
00075 
00076   void ClearInheritedData(PRUint32 aBits) {
00077 #define STYLE_STRUCT_INHERITED(name, checkdata_cb, ctor_args) \
00078     if (m##name##Data && (aBits & NS_STYLE_INHERIT_BIT(name))) \
00079       m##name##Data = nsnull;
00080 #define STYLE_STRUCT_RESET(name, checkdata_cb, ctor_args)
00081 
00082 #include "nsStyleStructList.h"
00083 
00084 #undef STYLE_STRUCT_INHERITED
00085 #undef STYLE_STRUCT_RESET
00086   };
00087 
00088   void Destroy(PRUint32 aBits, nsPresContext* aContext) {
00089 #define STYLE_STRUCT_INHERITED(name, checkdata_cb, ctor_args) \
00090     if (m##name##Data && !(aBits & NS_STYLE_INHERIT_BIT(name))) \
00091       m##name##Data->Destroy(aContext);
00092 #define STYLE_STRUCT_RESET(name, checkdata_cb, ctor_args)
00093 
00094 #include "nsStyleStructList.h"
00095 
00096 #undef STYLE_STRUCT_INHERITED
00097 #undef STYLE_STRUCT_RESET
00098 
00099     aContext->FreeToShell(sizeof(nsInheritedStyleData), this);
00100   };
00101 
00102   nsInheritedStyleData() {
00103 #define STYLE_STRUCT_INHERITED(name, checkdata_cb, ctor_args) \
00104     m##name##Data = nsnull;
00105 #define STYLE_STRUCT_RESET(name, checkdata_cb, ctor_args)
00106 
00107 #include "nsStyleStructList.h"
00108 
00109 #undef STYLE_STRUCT_INHERITED
00110 #undef STYLE_STRUCT_RESET
00111 
00112   };
00113 };
00114 
00115 struct nsResetStyleData
00116 {
00117   nsResetStyleData()
00118   {
00119 #define STYLE_STRUCT_RESET(name, checkdata_cb, ctor_args) \
00120     m##name##Data = nsnull;
00121 #define STYLE_STRUCT_INHERITED(name, checkdata_cb, ctor_args)
00122 
00123 #include "nsStyleStructList.h"
00124 
00125 #undef STYLE_STRUCT_RESET
00126 #undef STYLE_STRUCT_INHERITED
00127   };
00128 
00129   void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
00130     return aContext->AllocateFromShell(sz);
00131   }
00132 
00133   void ClearInheritedData(PRUint32 aBits) {
00134 #define STYLE_STRUCT_RESET(name, checkdata_cb, ctor_args) \
00135     if (m##name##Data && (aBits & NS_STYLE_INHERIT_BIT(name))) \
00136       m##name##Data = nsnull;
00137 #define STYLE_STRUCT_INHERITED(name, checkdata_cb, ctor_args)
00138 
00139 #include "nsStyleStructList.h"
00140 
00141 #undef STYLE_STRUCT_RESET
00142 #undef STYLE_STRUCT_INHERITED
00143   };
00144 
00145   void Destroy(PRUint32 aBits, nsPresContext* aContext) {
00146 #define STYLE_STRUCT_RESET(name, checkdata_cb, ctor_args) \
00147     if (m##name##Data && !(aBits & NS_STYLE_INHERIT_BIT(name))) \
00148       m##name##Data->Destroy(aContext);
00149 #define STYLE_STRUCT_INHERITED(name, checkdata_cb, ctor_args)
00150 
00151 #include "nsStyleStructList.h"
00152 
00153 #undef STYLE_STRUCT_RESET
00154 #undef STYLE_STRUCT_INHERITED
00155 
00156     aContext->FreeToShell(sizeof(nsResetStyleData), this);
00157   };
00158 
00159 #define STYLE_STRUCT_RESET(name, checkdata_cb, ctor_args) \
00160   nsStyle##name * m##name##Data;
00161 #define STYLE_STRUCT_INHERITED(name, checkdata_cb, ctor_args)
00162 
00163 #include "nsStyleStructList.h"
00164 
00165 #undef STYLE_STRUCT_RESET
00166 #undef STYLE_STRUCT_INHERITED
00167 
00168 };
00169 
00170 struct nsCachedStyleData
00171 {
00172   struct StyleStructInfo {
00173     ptrdiff_t mCachedStyleDataOffset;
00174     ptrdiff_t mInheritResetOffset;
00175     PRBool    mIsReset;
00176   };
00177 
00178   static StyleStructInfo gInfo[];
00179 
00180   nsInheritedStyleData* mInheritedData;
00181   nsResetStyleData* mResetData;
00182 
00183   static PRBool IsReset(const nsStyleStructID& aSID) {
00184     return gInfo[aSID].mIsReset;
00185   };
00186 
00187   static PRUint32 GetBitForSID(const nsStyleStructID& aSID) {
00188     return 1 << aSID;
00189   };
00190 
00191   NS_HIDDEN_(nsStyleStruct*) NS_FASTCALL GetStyleData(const nsStyleStructID& aSID) {
00192     // Each struct is stored at this.m##type##Data->m##name##Data where
00193     // |type| is either Inherit or Reset, and |name| is the name of the
00194     // style struct.  The |gInfo| stores the offset of the appropriate
00195     // m##type##Data for the struct within nsCachedStyleData (|this|)
00196     // and the offset of the appropriate m##name##Data within the
00197     // m##type##Data.  Note that if we don't have any reset structs,
00198     // then mResetData is null, and likewise for mInheritedData.  This
00199     // saves us from having to go through the long if-else cascade into
00200     // which most compilers will turn a case statement.
00201 
00202     // NOTE:  nsStyleContext::SetStyle works roughly the same way.
00203 
00204     const StyleStructInfo& info = gInfo[aSID];
00205 
00206     // Get either &mInheritedData or &mResetData.
00207     char* resetOrInheritSlot = NS_REINTERPRET_CAST(char*, this) + info.mCachedStyleDataOffset;
00208 
00209     // Get either mInheritedData or mResetData.
00210     char* resetOrInherit = NS_REINTERPRET_CAST(char*, *NS_REINTERPRET_CAST(void**, resetOrInheritSlot));
00211 
00212     nsStyleStruct* data = nsnull;
00213     if (resetOrInherit) {
00214       // If we have the mInheritedData or mResetData, then we might have
00215       // the struct, so get it.
00216       char* dataSlot = resetOrInherit + info.mInheritResetOffset;
00217       data = *NS_REINTERPRET_CAST(nsStyleStruct**, dataSlot);
00218     }
00219     return data;
00220   };
00221 
00222   NS_HIDDEN_(void) ClearInheritedData(PRUint32 aBits) {
00223     if (mResetData)
00224       mResetData->ClearInheritedData(aBits);
00225     if (mInheritedData)
00226       mInheritedData->ClearInheritedData(aBits);
00227   }
00228 
00229   NS_HIDDEN_(void) Destroy(PRUint32 aBits, nsPresContext* aContext) {
00230     if (mResetData)
00231       mResetData->Destroy(aBits, aContext);
00232     if (mInheritedData)
00233       mInheritedData->Destroy(aBits, aContext);
00234     mResetData = nsnull;
00235     mInheritedData = nsnull;
00236   }
00237 
00238   nsCachedStyleData() :mInheritedData(nsnull), mResetData(nsnull) {};
00239   ~nsCachedStyleData() {};
00240 };
00241 
00286 class nsRuleNode {
00287 public:
00288     // for purposes of the RuleDetail (and related code),
00289     //  * a non-inherited value is one that is specified as a
00290     //    non-"inherit" value or as an "inherit" value that is reflected
00291     //    in the struct and to the user of the style system with an
00292     //    eCSSUnit_Inherit value
00293     //  * an inherited value is one that is specified as "inherit" and
00294     //    where the inheritance is computed by the style system
00295   enum RuleDetail {
00296     eRuleNone, // No props have been specified at all.
00297     eRulePartialReset, // At least one prop with a non-inherited value
00298                        // has been specified.  No props have been
00299                        // specified with an inherited value.  At least
00300                        // one prop remains unspecified.
00301     eRulePartialMixed, // At least one prop with a non-inherited value
00302                        // has been specified.  Some props may also have
00303                        // been specified with an inherited value.  At
00304                        // least one prop remains unspecified.
00305     eRulePartialInherited, // Only props with inherited values have
00306                            // have been specified.  At least one prop
00307                            // remains unspecified.
00308     eRuleFullReset, // All props have been specified.  None has an
00309                     // inherited value.
00310     eRuleFullMixed, // All props have been specified.  At least one has
00311                     // a non-inherited value.
00312     eRuleFullInherited, // All props have been specified with inherited
00313                         // values.
00314     eRuleUnknown // Information unknown (used as a result from a check
00315                  // callback to trigger the normal checking codepath)
00316   };
00317 
00318 private:
00319   nsPresContext* mPresContext; // Our pres context.
00320 
00321   nsRuleNode* mParent; // A pointer to the parent node in the tree.
00322                        // This enables us to walk backwards from the
00323                        // most specific rule matched to the least
00324                        // specific rule (which is the optimal order to
00325                        // use for lookups of style properties.
00326   nsIStyleRule* mRule; // [STRONG] A pointer to our specific rule.
00327 
00328   // The children of this node are stored in either a hashtable or list
00329   // that maps from rules to our nsRuleNode children.  When matching
00330   // rules, we use this mapping to transition from node to node
00331   // (constructing new nodes as needed to flesh out the tree).
00332 
00333   void *mChildrenTaggedPtr; // Accessed only through the methods below.
00334 
00335   enum {
00336     kTypeMask = 0x1,
00337     kListType = 0x0,
00338     kHashType = 0x1
00339   };
00340   enum {
00341     // Maximum to have in a list before converting to a hashtable.
00342     // XXX Need to optimize this.
00343     kMaxChildrenInList = 32
00344   };
00345 
00346   PRBool HaveChildren() {
00347     return mChildrenTaggedPtr != nsnull;
00348   }
00349   PRBool ChildrenAreHashed() {
00350     return (PRWord(mChildrenTaggedPtr) & kTypeMask) == kHashType;
00351   }
00352   nsRuleList* ChildrenList() {
00353     return NS_REINTERPRET_CAST(nsRuleList*, mChildrenTaggedPtr);
00354   }
00355   nsRuleList** ChildrenListPtr() {
00356     return NS_REINTERPRET_CAST(nsRuleList**, &mChildrenTaggedPtr);
00357   }
00358   PLDHashTable* ChildrenHash() {
00359     return (PLDHashTable*) (PRWord(mChildrenTaggedPtr) & ~PRWord(kTypeMask));
00360   }
00361   void SetChildrenList(nsRuleList *aList) {
00362     NS_ASSERTION(!(PRWord(aList) & kTypeMask),
00363                  "pointer not 2-byte aligned");
00364     mChildrenTaggedPtr = aList;
00365   }
00366   void SetChildrenHash(PLDHashTable *aHashtable) {
00367     NS_ASSERTION(!(PRWord(aHashtable) & kTypeMask),
00368                  "pointer not 2-byte aligned");
00369     mChildrenTaggedPtr = (void*)(PRWord(aHashtable) | kHashType);
00370   }
00371   void ConvertChildrenToHash();
00372 
00373   nsCachedStyleData mStyleData;   // Any data we cached on the rule node.
00374 
00375   PRUint32 mDependentBits; // Used to cache the fact that we can look up
00376                            // cached data under a parent rule.
00377 
00378   PRUint32 mNoneBits; // Used to cache the fact that the branch to this
00379                       // node specifies no non-inherited data for a
00380                       // given struct type.  (This usually implies that
00381                       // the entire branch specifies no non-inherited
00382                       // data, although not necessarily, if a
00383                       // non-inherited value is overridden by an
00384                       // explicit 'inherit' value.)  For example, if an
00385                       // entire rule branch specifies no color
00386                       // information, then a bit will be set along every
00387                       // rule node on that branch, so that you can break
00388                       // out of the rule tree early and just inherit
00389                       // from the parent style context.  The presence of
00390                       // this bit means we should just get inherited
00391                       // data from the parent style context, and it is
00392                       // never used for reset structs since their
00393                       // Compute*Data functions don't initialize from
00394                       // inherited data.
00395 
00396 friend struct nsRuleList;
00397 
00398 public:
00399   // Overloaded new operator. Initializes the memory to 0 and relies on an arena
00400   // (which comes from the presShell) to perform the allocation.
00401   NS_HIDDEN_(void*) operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW;
00402   NS_HIDDEN_(void) Destroy();
00403   static NS_HIDDEN_(nsILanguageAtomService*) gLangService;
00404 
00405 protected:
00406   NS_HIDDEN_(void) PropagateDependentBit(PRUint32 aBit,
00407                                          nsRuleNode* aHighestNode);
00408   NS_HIDDEN_(void) PropagateNoneBit(PRUint32 aBit, nsRuleNode* aHighestNode);
00409   
00410   NS_HIDDEN_(const nsStyleStruct*) SetDefaultOnRoot(const nsStyleStructID aSID,
00411                                                     nsStyleContext* aContext);
00412 
00413   NS_HIDDEN_(const nsStyleStruct*)
00414     WalkRuleTree(const nsStyleStructID aSID, nsStyleContext* aContext, 
00415                  nsRuleData* aRuleData, nsRuleDataStruct* aSpecificData);
00416 
00417   NS_HIDDEN_(const nsStyleStruct*)
00418     ComputeDisplayData(nsStyleStruct* aStartDisplay,
00419                        const nsRuleDataStruct& aDisplayData,
00420                        nsStyleContext* aContext, nsRuleNode* aHighestNode,
00421                        const RuleDetail& aRuleDetail, PRBool aInherited);
00422 
00423   NS_HIDDEN_(const nsStyleStruct*)
00424     ComputeVisibilityData(nsStyleStruct* aStartVisibility,
00425                           const nsRuleDataStruct& aDisplayData,
00426                           nsStyleContext* aContext, nsRuleNode* aHighestNode,
00427                           const RuleDetail& aRuleDetail, PRBool aInherited);
00428 
00429   NS_HIDDEN_(const nsStyleStruct*)
00430     ComputeFontData(nsStyleStruct* aStartFont,
00431                     const nsRuleDataStruct& aFontData,
00432                     nsStyleContext* aContext, nsRuleNode* aHighestNode,
00433                     const RuleDetail& aRuleDetail, PRBool aInherited);
00434 
00435   NS_HIDDEN_(const nsStyleStruct*)
00436     ComputeColorData(nsStyleStruct* aStartColor,
00437                      const nsRuleDataStruct& aColorData,
00438                      nsStyleContext* aContext, nsRuleNode* aHighestNode,
00439                      const RuleDetail& aRuleDetail, PRBool aInherited);
00440 
00441   NS_HIDDEN_(const nsStyleStruct*)
00442     ComputeBackgroundData(nsStyleStruct* aStartBackground,
00443                           const nsRuleDataStruct& aColorData, 
00444                           nsStyleContext* aContext, nsRuleNode* aHighestNode,
00445                           const RuleDetail& aRuleDetail, PRBool aInherited);
00446 
00447   NS_HIDDEN_(const nsStyleStruct*)
00448     ComputeMarginData(nsStyleStruct* aStartMargin,
00449                       const nsRuleDataStruct& aMarginData, 
00450                       nsStyleContext* aContext, nsRuleNode* aHighestNode,
00451                       const RuleDetail& aRuleDetail, PRBool aInherited);
00452 
00453   NS_HIDDEN_(const nsStyleStruct*)
00454     ComputeBorderData(nsStyleStruct* aStartBorder,
00455                       const nsRuleDataStruct& aMarginData, 
00456                       nsStyleContext* aContext, nsRuleNode* aHighestNode,
00457                       const RuleDetail& aRuleDetail, PRBool aInherited);
00458 
00459   NS_HIDDEN_(const nsStyleStruct*)
00460     ComputePaddingData(nsStyleStruct* aStartPadding,
00461                        const nsRuleDataStruct& aMarginData, 
00462                        nsStyleContext* aContext, nsRuleNode* aHighestNode,
00463                        const RuleDetail& aRuleDetail, PRBool aInherited);
00464 
00465   NS_HIDDEN_(const nsStyleStruct*)
00466     ComputeOutlineData(nsStyleStruct* aStartOutline,
00467                        const nsRuleDataStruct& aMarginData, 
00468                        nsStyleContext* aContext, nsRuleNode* aHighestNode,
00469                        const RuleDetail& aRuleDetail, PRBool aInherited);
00470 
00471   NS_HIDDEN_(const nsStyleStruct*)
00472     ComputeListData(nsStyleStruct* aStartList,
00473                     const nsRuleDataStruct& aListData,
00474                     nsStyleContext* aContext, nsRuleNode* aHighestNode,
00475                     const RuleDetail& aRuleDetail, PRBool aInherited);
00476 
00477   NS_HIDDEN_(const nsStyleStruct*)
00478     ComputePositionData(nsStyleStruct* aStartPosition,
00479                         const nsRuleDataStruct& aPositionData, 
00480                         nsStyleContext* aContext, nsRuleNode* aHighestNode,
00481                         const RuleDetail& aRuleDetail, PRBool aInherited);
00482 
00483   NS_HIDDEN_(const nsStyleStruct*)
00484     ComputeTableData(nsStyleStruct* aStartTable,
00485                      const nsRuleDataStruct& aTableData, 
00486                      nsStyleContext* aContext, nsRuleNode* aHighestNode,
00487                      const RuleDetail& aRuleDetail, PRBool aInherited);
00488 
00489   NS_HIDDEN_(const nsStyleStruct*)
00490     ComputeTableBorderData(nsStyleStruct* aStartTable,
00491                            const nsRuleDataStruct& aTableData, 
00492                            nsStyleContext* aContext, nsRuleNode* aHighestNode,
00493                            const RuleDetail& aRuleDetail, PRBool aInherited);
00494 
00495   NS_HIDDEN_(const nsStyleStruct*)
00496     ComputeContentData(nsStyleStruct* aStartContent,
00497                        const nsRuleDataStruct& aData,
00498                        nsStyleContext* aContext, nsRuleNode* aHighestNode,
00499                        const RuleDetail& aRuleDetail, PRBool aInherited);
00500 
00501   NS_HIDDEN_(const nsStyleStruct*)
00502     ComputeQuotesData(nsStyleStruct* aStartQuotes,
00503                       const nsRuleDataStruct& aData, 
00504                       nsStyleContext* aContext, nsRuleNode* aHighestNode,
00505                       const RuleDetail& aRuleDetail, PRBool aInherited);
00506 
00507   NS_HIDDEN_(const nsStyleStruct*)
00508     ComputeTextData(nsStyleStruct* aStartData, const nsRuleDataStruct& aData, 
00509                     nsStyleContext* aContext, nsRuleNode* aHighestNode,
00510                     const RuleDetail& aRuleDetail, PRBool aInherited);
00511 
00512   NS_HIDDEN_(const nsStyleStruct*)
00513     ComputeTextResetData(nsStyleStruct* aStartData,
00514                          const nsRuleDataStruct& aData,
00515                          nsStyleContext* aContext, nsRuleNode* aHighestNode,
00516                          const RuleDetail& aRuleDetail, PRBool aInherited);
00517 
00518   NS_HIDDEN_(const nsStyleStruct*)
00519     ComputeUserInterfaceData(nsStyleStruct* aStartData,
00520                              const nsRuleDataStruct& aData, 
00521                              nsStyleContext* aContext,
00522                              nsRuleNode* aHighestNode,
00523                              const RuleDetail& aRuleDetail, PRBool aInherited);
00524 
00525   NS_HIDDEN_(const nsStyleStruct*)
00526     ComputeUIResetData(nsStyleStruct* aStartData,
00527                        const nsRuleDataStruct& aData,
00528                        nsStyleContext* aContext, nsRuleNode* aHighestNode,
00529                        const RuleDetail& aRuleDetail, PRBool aInherited);
00530 
00531   NS_HIDDEN_(const nsStyleStruct*)
00532     ComputeXULData(nsStyleStruct* aStartXUL, const nsRuleDataStruct& aXULData, 
00533                    nsStyleContext* aContext, nsRuleNode* aHighestNode,
00534                    const RuleDetail& aRuleDetail, PRBool aInherited);
00535 
00536   NS_HIDDEN_(const nsStyleStruct*)
00537     ComputeColumnData(nsStyleStruct* aStartColumn, const nsRuleDataStruct& aColumnData,
00538                       nsStyleContext* aContext, nsRuleNode* aHighestNode,
00539                       const RuleDetail& aRuleDetail, PRBool aInherited);
00540 
00541 #ifdef MOZ_SVG
00542   NS_HIDDEN_(const nsStyleStruct*)
00543     ComputeSVGData(nsStyleStruct* aStartSVG, const nsRuleDataStruct& aSVGData, 
00544                    nsStyleContext* aContext, nsRuleNode* aHighestNode,
00545                    const RuleDetail& aRuleDetail, PRBool aInherited);
00546 
00547   NS_HIDDEN_(const nsStyleStruct*)
00548     ComputeSVGResetData(nsStyleStruct* aStartSVG,
00549                         const nsRuleDataStruct& aSVGData, 
00550                         nsStyleContext* aContext, nsRuleNode* aHighestNode,
00551                         const RuleDetail& aRuleDetail, PRBool aInherited);
00552 #endif
00553 
00554   // helpers for |ComputeFontData| that need access to |mNoneBits|:
00555   static NS_HIDDEN_(void) SetFont(nsPresContext* aPresContext,
00556                                   nsStyleContext* aContext,
00557                                   nscoord aMinFontSize,
00558                                   PRBool aUseDocumentFonts,
00559                                   PRBool aIsGeneric,
00560                                   const nsRuleDataFont& aFontData,
00561                                   const nsFont& aDefaultFont,
00562                                   const nsStyleFont* aParentFont,
00563                                   nsStyleFont* aFont, PRBool& aInherited);
00564 
00565   static NS_HIDDEN_(void) SetGenericFont(nsPresContext* aPresContext,
00566                                          nsStyleContext* aContext,
00567                                          const nsRuleDataFont& aFontData,
00568                                          PRUint8 aGenericFontID,
00569                                          nscoord aMinFontSize,
00570                                          PRBool aUseDocumentFonts,
00571                                          nsStyleFont* aFont);
00572 
00573   NS_HIDDEN_(void) AdjustLogicalBoxProp(nsStyleContext* aContext,
00574                                         const nsCSSValue& aLTRSource,
00575                                         const nsCSSValue& aRTLSource,
00576                                         const nsCSSValue& aLTRLogicalValue,
00577                                         const nsCSSValue& aRTLLogicalValue,
00578                                         const nsStyleSides& aParentRect,
00579                                         nsStyleSides& aRect,
00580                                         PRUint8 aSide,
00581                                         PRInt32 aMask,
00582                                         PRBool& aInherited);
00583   
00584   inline RuleDetail CheckSpecifiedProperties(const nsStyleStructID aSID, const nsRuleDataStruct& aRuleDataStruct);
00585 
00586   NS_HIDDEN_(const nsStyleStruct*) GetParentData(const nsStyleStructID aSID);
00587   NS_HIDDEN_(const nsStyleStruct*) GetDisplayData(nsStyleContext* aContext);
00588   NS_HIDDEN_(const nsStyleStruct*) GetVisibilityData(nsStyleContext* aContext);
00589   NS_HIDDEN_(const nsStyleStruct*) GetFontData(nsStyleContext* aContext);
00590   NS_HIDDEN_(const nsStyleStruct*) GetColorData(nsStyleContext* aContext);
00591   NS_HIDDEN_(const nsStyleStruct*) GetBackgroundData(nsStyleContext* aContext);
00592   NS_HIDDEN_(const nsStyleStruct*) GetMarginData(nsStyleContext* aContext);
00593   NS_HIDDEN_(const nsStyleStruct*) GetBorderData(nsStyleContext* aContext);
00594   NS_HIDDEN_(const nsStyleStruct*) GetPaddingData(nsStyleContext* aContext);
00595   NS_HIDDEN_(const nsStyleStruct*) GetOutlineData(nsStyleContext* aContext);
00596   NS_HIDDEN_(const nsStyleStruct*) GetListData(nsStyleContext* aContext);
00597   NS_HIDDEN_(const nsStyleStruct*) GetPositionData(nsStyleContext* aContext);
00598   NS_HIDDEN_(const nsStyleStruct*) GetTableData(nsStyleContext* aContext);
00599   NS_HIDDEN_(const nsStyleStruct*)
00600     GetTableBorderData(nsStyleContext* aContext);
00601 
00602   NS_HIDDEN_(const nsStyleStruct*) GetContentData(nsStyleContext* aContext);
00603   NS_HIDDEN_(const nsStyleStruct*) GetQuotesData(nsStyleContext* aContext);
00604   NS_HIDDEN_(const nsStyleStruct*) GetTextData(nsStyleContext* aContext);
00605   NS_HIDDEN_(const nsStyleStruct*) GetTextResetData(nsStyleContext* aContext);
00606   NS_HIDDEN_(const nsStyleStruct*)
00607     GetUserInterfaceData(nsStyleContext* aContext);
00608 
00609   NS_HIDDEN_(const nsStyleStruct*) GetUIResetData(nsStyleContext* aContext);
00610   NS_HIDDEN_(const nsStyleStruct*) GetXULData(nsStyleContext* aContext);
00611   NS_HIDDEN_(const nsStyleStruct*) GetColumnData(nsStyleContext* aContext);
00612 #ifdef MOZ_SVG
00613   NS_HIDDEN_(const nsStyleStruct*) GetSVGData(nsStyleContext* aContext);
00614   NS_HIDDEN_(const nsStyleStruct*) GetSVGResetData(nsStyleContext* aContext);
00615 #endif
00616 
00617 public:
00618   nsRuleNode(nsPresContext* aPresContext, nsIStyleRule* aRule,
00619              nsRuleNode* aParent) NS_HIDDEN;
00620   virtual ~nsRuleNode() NS_HIDDEN;
00621 
00622   static NS_HIDDEN_(nsRuleNode*) CreateRootNode(nsPresContext* aPresContext);
00623 
00624   NS_HIDDEN_(nsresult) Transition(nsIStyleRule* aRule, nsRuleNode** aResult);
00625   nsRuleNode* GetParent() const { return mParent; }
00626   PRBool IsRoot() const { return mParent == nsnull; }
00627 
00628   // NOTE:  Does not |AddRef|.
00629   nsIStyleRule* GetRule() const { return mRule; }
00630   // NOTE: Does not |AddRef|.
00631   nsPresContext* GetPresContext() const { return mPresContext; }
00632 
00633   NS_HIDDEN_(nsresult) ClearStyleData();
00634   NS_HIDDEN_(const nsStyleStruct*) GetStyleData(nsStyleStructID aSID, 
00635                                                 nsStyleContext* aContext,
00636                                                 PRBool aComputeData);
00637 
00638   /*
00639    * Garbage collection.  Mark walks up the tree, marking any unmarked
00640    * ancestors until it reaches a marked one.  Sweep recursively sweeps
00641    * the children, destroys any that are unmarked, and clears marks,
00642    * returning true if the node on which it was called was destroyed.
00643    */
00644   NS_HIDDEN_(void) Mark();
00645   NS_HIDDEN_(PRBool) Sweep();
00646 };
00647 
00648 #endif