Back to index

lightning-sunbird  0.9+nobinonly
nsStyleStruct.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.org 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  *   Mats Palmgren <mats.palmgren@bredband.net>
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 #ifndef nsStyleStruct_h___
00039 #define nsStyleStruct_h___
00040 
00041 #include "nsColor.h"
00042 #include "nsCoord.h"
00043 #include "nsMargin.h"
00044 #include "nsRect.h"
00045 #include "nsFont.h"
00046 #include "nsVoidArray.h"
00047 #include "nsStyleCoord.h"
00048 #include "nsStyleConsts.h"
00049 #include "nsChangeHint.h"
00050 #include "nsPresContext.h"
00051 #include "nsIPresShell.h"
00052 #include "nsCOMPtr.h"
00053 #include "nsCOMArray.h"
00054 #include "nsIAtom.h"
00055 #include "nsIURI.h"
00056 #include "nsCSSValue.h"
00057 
00058 class nsIFrame;
00059 class imgIRequest;
00060 
00061 enum nsStyleStructID {
00062 
00063 /*
00064  * Define the constants eStyleStruct_Font, etc.
00065  *
00066  * The C++ standard, section 7.2, guarantees that enums begin with 0 and
00067  * increase by 1.
00068  */
00069 
00070 #define STYLE_STRUCT(name, checkdata_cb, ctor_args) eStyleStruct_##name,
00071 #include "nsStyleStructList.h"
00072 #undef STYLE_STRUCT
00073 
00074 nsStyleStructID_Length /* one past the end; length of 0-based list */
00075 
00076 };
00077 
00078 // Bits for each struct.
00079 #define NS_STYLE_INHERIT_BIT(sid_)        (1 << PRInt32(eStyleStruct_##sid_))
00080 #define NS_STYLE_INHERIT_MASK             0x00ffffff
00081 
00082 // Additional bits for nsStyleContext's mBits:
00083 // A bit to test whether or not we have any text decorations.
00084 #define NS_STYLE_HAS_TEXT_DECORATIONS     0x01000000
00085 
00086 // Additional bits for nsRuleNode's mDependentBits:
00087 #define NS_RULE_NODE_GC_MARK              0x02000000
00088 
00089 #define NS_DEFINE_STATIC_STYLESTRUCTID_ACCESSOR(the_sid) \
00090   static nsStyleStructID GetStyleStructID() {return the_sid;}
00091 
00092 #define NS_GET_STYLESTRUCTID(type) (type::GetStyleStructID())
00093 
00094 // The actual structs start here
00095 struct nsStyleStruct {
00096 };
00097 
00098 // The lifetime of these objects is managed by the presshell's arena.
00099 
00100 struct nsStyleFont : public nsStyleStruct {
00101   nsStyleFont(void);
00102   nsStyleFont(const nsFont& aFont);
00103   nsStyleFont(const nsStyleFont& aStyleFont);
00104   nsStyleFont(nsPresContext *aPresContext);
00105   ~nsStyleFont(void) {};
00106 
00107   NS_DEFINE_STATIC_STYLESTRUCTID_ACCESSOR(eStyleStruct_Font)
00108 
00109   nsChangeHint CalcDifference(const nsStyleFont& aOther) const;
00110 #ifdef DEBUG
00111   static nsChangeHint MaxDifference();
00112 #endif
00113   static nsChangeHint CalcFontDifference(const nsFont& aFont1, const nsFont& aFont2);
00114 
00115   static nscoord ZoomText(nsPresContext* aPresContext, nscoord aSize);
00116   static nscoord UnZoomText(nsPresContext* aPresContext, nscoord aSize);
00117   
00118   void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW;
00119   void Destroy(nsPresContext* aContext);
00120 
00121   PRUint8 mFlags;       // [inherited] See nsStyleConsts.h
00122   nsFont  mFont;        // [inherited]
00123   nscoord mSize;        // [inherited] Our "computed size". Can be different from mFont.size
00124                         // which is our "actual size" and is enforced to be >= the user's
00125                         // preferred min-size. mFont.size should be used for display purposes
00126                         // while mSize is the value to return in getComputedStyle() for example.
00127 };
00128 
00129 struct nsStyleColor : public nsStyleStruct {
00130   nsStyleColor(nsPresContext* aPresContext);
00131   nsStyleColor(const nsStyleColor& aOther);
00132   ~nsStyleColor(void) {};
00133 
00134   NS_DEFINE_STATIC_STYLESTRUCTID_ACCESSOR(eStyleStruct_Color)
00135 
00136   nsChangeHint CalcDifference(const nsStyleColor& aOther) const;
00137 #ifdef DEBUG
00138   static nsChangeHint MaxDifference();
00139 #endif
00140   
00141   void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
00142     return aContext->AllocateFromShell(sz);
00143   }
00144   void Destroy(nsPresContext* aContext) {
00145     this->~nsStyleColor();
00146     aContext->FreeToShell(sizeof(nsStyleColor), this);
00147   };
00148 
00149   // Don't add ANY members to this struct!  We can achieve caching in the rule
00150   // tree (rather than the style tree) by letting color stay by itself! -dwh
00151   nscolor mColor;                 // [inherited]
00152 };
00153 
00154 struct nsStyleBackground : public nsStyleStruct {
00155   nsStyleBackground(nsPresContext* aPresContext);
00156   nsStyleBackground(const nsStyleBackground& aOther);
00157   ~nsStyleBackground();
00158 
00159   NS_DEFINE_STATIC_STYLESTRUCTID_ACCESSOR(eStyleStruct_Background)
00160 
00161   void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
00162     return aContext->AllocateFromShell(sz);
00163   }
00164   void Destroy(nsPresContext* aContext) {
00165     this->~nsStyleBackground();
00166     aContext->FreeToShell(sizeof(nsStyleBackground), this);
00167   };
00168 
00169   nsChangeHint CalcDifference(const nsStyleBackground& aOther) const;
00170 #ifdef DEBUG
00171   static nsChangeHint MaxDifference();
00172 #endif
00173 
00174   // On Linux (others?), there is an extra byte being used up by
00175   // inheritance so we only have 3 bytes to fit these 6 things into.
00176   // Fortunately, the properties are enums which have few possible
00177   // values.
00178   PRUint8 mBackgroundFlags;            // [reset] See nsStyleConsts.h
00179   PRUint8 mBackgroundAttachment   : 4; // [reset] See nsStyleConsts.h
00180   PRUint8 mBackgroundClip         : 3; // [reset] See nsStyleConsts.h
00181   PRUint8 mBackgroundInlinePolicy : 2; // [reset] See nsStyleConsts.h
00182   PRUint8 mBackgroundOrigin       : 3; // [reset] See nsStyleConsts.h
00183   PRUint8 mBackgroundRepeat       : 4; // [reset] See nsStyleConsts.h
00184 
00185   // Note: a member of this union is valid IFF the appropriate bit flag
00186   // is set in mBackgroundFlags.
00187   union {
00188     nscoord mCoord;
00189     float   mFloat;
00190   } mBackgroundXPosition,         // [reset]
00191     mBackgroundYPosition;         // [reset]
00192 
00193   nscolor mBackgroundColor;       // [reset]
00194   nsCOMPtr<imgIRequest> mBackgroundImage; // [reset]
00195 
00196   PRBool IsTransparent() const
00197   {
00198     return (mBackgroundFlags &
00199             (NS_STYLE_BG_COLOR_TRANSPARENT | NS_STYLE_BG_IMAGE_NONE)) ==
00200             (NS_STYLE_BG_COLOR_TRANSPARENT | NS_STYLE_BG_IMAGE_NONE);
00201   }
00202 
00203   // We have to take slower codepaths for fixed background attachment,
00204   // but we don't want to do that when there's no image.
00205   // Not inline because it uses an nsCOMPtr<imgIRequest>
00206   PRBool HasFixedBackground() const;
00207 };
00208 
00209 #define BORDER_COLOR_TRANSPARENT  0x40
00210 #define BORDER_COLOR_FOREGROUND   0x20
00211 #define BORDER_COLOR_SPECIAL      0x60 // TRANSPARENT | FOREGROUND 
00212 #define BORDER_STYLE_MASK         0x1F
00213 
00214 #define NS_SPACING_MARGIN   0
00215 #define NS_SPACING_PADDING  1
00216 #define NS_SPACING_BORDER   2
00217 
00218 
00219 struct nsStyleMargin: public nsStyleStruct {
00220   nsStyleMargin(void);
00221   nsStyleMargin(const nsStyleMargin& aMargin);
00222   ~nsStyleMargin(void) {};
00223 
00224   NS_DEFINE_STATIC_STYLESTRUCTID_ACCESSOR(eStyleStruct_Margin)
00225 
00226   void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW;
00227   void Destroy(nsPresContext* aContext);
00228 
00229   void RecalcData();
00230   nsChangeHint CalcDifference(const nsStyleMargin& aOther) const;
00231 #ifdef DEBUG
00232   static nsChangeHint MaxDifference();
00233 #endif
00234 
00235   nsStyleSides  mMargin;          // [reset] length, percent, auto, inherit
00236 
00237   PRBool GetMargin(nsMargin& aMargin) const
00238   {
00239     if (mHasCachedMargin) {
00240       aMargin = mCachedMargin;
00241       return PR_TRUE;
00242     }
00243     return PR_FALSE;
00244   }
00245 
00246   // XXX this is a deprecated method
00247   void CalcMarginFor(const nsIFrame* aFrame, nsMargin& aMargin) const;
00248 
00249 protected:
00250   PRPackedBool  mHasCachedMargin;
00251   nsMargin      mCachedMargin;
00252 };
00253 
00254 
00255 struct nsStylePadding: public nsStyleStruct {
00256   nsStylePadding(void);
00257   nsStylePadding(const nsStylePadding& aPadding);
00258   ~nsStylePadding(void) {};
00259 
00260   NS_DEFINE_STATIC_STYLESTRUCTID_ACCESSOR(eStyleStruct_Padding)
00261 
00262   void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW;
00263   void Destroy(nsPresContext* aContext);
00264 
00265   void RecalcData();
00266   nsChangeHint CalcDifference(const nsStylePadding& aOther) const;
00267 #ifdef DEBUG
00268   static nsChangeHint MaxDifference();
00269 #endif
00270   
00271   nsStyleSides  mPadding;         // [reset] length, percent, inherit
00272 
00273   PRBool GetPadding(nsMargin& aPadding) const
00274   {
00275     if (mHasCachedPadding) {
00276       aPadding = mCachedPadding;
00277       return PR_TRUE;
00278     }
00279     return PR_FALSE;
00280   }
00281 
00282   // XXX this is a deprecated method
00283   void CalcPaddingFor(const nsIFrame* aFrame, nsMargin& aPadding) const;
00284   
00285 protected:
00286   PRPackedBool  mHasCachedPadding;
00287   nsMargin      mCachedPadding;
00288 };
00289 
00290 struct nsBorderColors {
00291   nsBorderColors* mNext;
00292   nscolor mColor;
00293   PRBool mTransparent;
00294 
00295   nsBorderColors* CopyColors() {
00296     nsBorderColors* next = nsnull;
00297     if (mNext)
00298       next = mNext->CopyColors();
00299     return new nsBorderColors(mColor, mTransparent, next);
00300   }
00301 
00302   nsBorderColors() :mNext(nsnull) { mColor = NS_RGB(0,0,0); };
00303 
00304   nsBorderColors(const nscolor& aColor, PRBool aTransparent, nsBorderColors* aNext=nsnull) {
00305     mColor = aColor;
00306     mTransparent = aTransparent;
00307     mNext = aNext;
00308   }
00309 
00310   ~nsBorderColors() {
00311     delete mNext;
00312   }
00313 
00314   PRBool Equals(nsBorderColors* aOther) {
00315     nsBorderColors* c1 = this;
00316     nsBorderColors* c2 = aOther;
00317     while (c1 && c2) {
00318       if (c1->mColor != c2->mColor ||
00319           c1->mTransparent != c2->mTransparent)
00320         return PR_FALSE;
00321       c1 = c1->mNext;
00322       c2 = c2->mNext;
00323     }
00324     return !c1 && !c2;
00325   }
00326 };
00327 
00328 struct nsStyleBorder: public nsStyleStruct {
00329   nsStyleBorder() :mBorderColors(nsnull) {};
00330   nsStyleBorder(nsPresContext* aContext);
00331   nsStyleBorder(const nsStyleBorder& aBorder);
00332   ~nsStyleBorder(void) {
00333     if (mBorderColors) {
00334       for (PRInt32 i = 0; i < 4; i++)
00335         delete mBorderColors[i];
00336       delete []mBorderColors;
00337     }
00338   };
00339 
00340   NS_DEFINE_STATIC_STYLESTRUCTID_ACCESSOR(eStyleStruct_Border)
00341 
00342   void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW;
00343   void Destroy(nsPresContext* aContext);
00344 
00345   nsChangeHint CalcDifference(const nsStyleBorder& aOther) const;
00346 #ifdef DEBUG
00347   static nsChangeHint MaxDifference();
00348 #endif
00349  
00350   nsStyleSides  mBorderRadius;    // [reset] length, percent, inherit
00351   PRUint8       mFloatEdge;       // [reset] see nsStyleConsts.h
00352   nsBorderColors** mBorderColors; // [reset] multiple levels of color for a border.
00353 
00354   void EnsureBorderColors() {
00355     if (!mBorderColors) {
00356       mBorderColors = new nsBorderColors*[4];
00357       if (mBorderColors)
00358         for (PRInt32 i = 0; i < 4; i++)
00359           mBorderColors[i] = nsnull;
00360     }
00361   }
00362 
00363   void ClearBorderColors(PRUint8 aSide) {
00364     if (mBorderColors[aSide]) {
00365       delete mBorderColors[aSide];
00366       mBorderColors[aSide] = nsnull;
00367     }
00368   }
00369 
00370   // Return whether aStyle is a visible style.  Invisible styles cause
00371   // the relevant computed border width to be 0.
00372   static PRBool IsVisibleStyle(PRUint8 aStyle) {
00373     return aStyle != NS_STYLE_BORDER_STYLE_NONE &&
00374            aStyle != NS_STYLE_BORDER_STYLE_HIDDEN;
00375   }
00376 
00377   // aBorderWidth is in twips
00378   void SetBorderWidth(PRUint8 aSide, nscoord aBorderWidth)
00379   {
00380     mBorder.side(aSide) = aBorderWidth;
00381     if (IsVisibleStyle(GetBorderStyle(aSide))) {
00382       mComputedBorder.side(aSide) = aBorderWidth;
00383     }
00384   }
00385 
00386   // Get the computed border, in twips.
00387   const nsMargin& GetBorder() const
00388   {
00389     return mComputedBorder;
00390   }
00391 
00392   // Get the computed border width for a particular side, in twips.  Note that
00393   // this is zero if and only if there is no border to be painted for this
00394   // side.  That is, this value takes into account the border style.
00395   nscoord GetBorderWidth(PRUint8 aSide) const
00396   {
00397     return mComputedBorder.side(aSide);
00398   }
00399 
00400   PRUint8 GetBorderStyle(PRUint8 aSide) const
00401   {
00402     NS_ASSERTION(aSide <= NS_SIDE_LEFT, "bad side"); 
00403     return (mBorderStyle[aSide] & BORDER_STYLE_MASK); 
00404   }
00405 
00406   void SetBorderStyle(PRUint8 aSide, PRUint8 aStyle)
00407   {
00408     NS_ASSERTION(aSide <= NS_SIDE_LEFT, "bad side"); 
00409     mBorderStyle[aSide] &= ~BORDER_STYLE_MASK; 
00410     mBorderStyle[aSide] |= (aStyle & BORDER_STYLE_MASK);
00411     if (IsVisibleStyle(aStyle)) {
00412       mComputedBorder.side(aSide) = mBorder.side(aSide);
00413     } else {
00414       mComputedBorder.side(aSide) = 0;
00415     }
00416   }
00417 
00418   void GetBorderColor(PRUint8 aSide, nscolor& aColor,
00419                       PRBool& aTransparent, PRBool& aForeground) const
00420   {
00421     aTransparent = aForeground = PR_FALSE;
00422     NS_ASSERTION(aSide <= NS_SIDE_LEFT, "bad side"); 
00423     if ((mBorderStyle[aSide] & BORDER_COLOR_SPECIAL) == 0)
00424       aColor = mBorderColor[aSide]; 
00425     else if (mBorderStyle[aSide] & BORDER_COLOR_FOREGROUND)
00426       aForeground = PR_TRUE;
00427     else
00428       aTransparent = PR_TRUE;
00429   }
00430 
00431   void SetBorderColor(PRUint8 aSide, nscolor aColor) 
00432   {
00433     NS_ASSERTION(aSide <= NS_SIDE_LEFT, "bad side"); 
00434     mBorderColor[aSide] = aColor; 
00435     mBorderStyle[aSide] &= ~BORDER_COLOR_SPECIAL;
00436   }
00437 
00438   void GetCompositeColors(PRInt32 aIndex, nsBorderColors** aColors) const
00439   {
00440     if (!mBorderColors)
00441       *aColors = nsnull;
00442     else
00443       *aColors = mBorderColors[aIndex];
00444   }
00445 
00446   void AppendBorderColor(PRInt32 aIndex, nscolor aColor, PRBool aTransparent)
00447   {
00448     NS_ASSERTION(aIndex >= 0 && aIndex <= 3, "bad side for composite border color");
00449     nsBorderColors* colorEntry = new nsBorderColors(aColor, aTransparent);
00450     if (!mBorderColors[aIndex])
00451       mBorderColors[aIndex] = colorEntry;
00452     else {
00453       nsBorderColors* last = mBorderColors[aIndex];
00454       while (last->mNext)
00455         last = last->mNext;
00456       last->mNext = colorEntry;
00457     }
00458     mBorderStyle[aIndex] &= ~BORDER_COLOR_SPECIAL;
00459   }
00460 
00461   void SetBorderTransparent(PRUint8 aSide)
00462   {
00463     NS_ASSERTION(aSide <= NS_SIDE_LEFT, "bad side"); 
00464     mBorderStyle[aSide] &= ~BORDER_COLOR_SPECIAL;
00465     mBorderStyle[aSide] |= BORDER_COLOR_TRANSPARENT; 
00466   }
00467 
00468   void SetBorderToForeground(PRUint8 aSide)
00469   {
00470     NS_ASSERTION(aSide <= NS_SIDE_LEFT, "bad side"); 
00471     mBorderStyle[aSide] &= ~BORDER_COLOR_SPECIAL;
00472     mBorderStyle[aSide] |= BORDER_COLOR_FOREGROUND; 
00473   }
00474 
00475   // XXX these are deprecated methods
00476   void CalcBorderFor(const nsIFrame* aFrame, nsMargin& aBorder) const
00477   {
00478     aBorder = GetBorder();
00479   }
00480   void CalcBorderFor(const nsIFrame* aFrame, PRUint8 aSide,
00481                      nscoord& aWidth) const {
00482     aWidth = GetBorderWidth(aSide);
00483   }
00484   
00485 protected:
00486   // mComputedBorder holds the CSS2.1 computed border-width values.  In
00487   // particular, these widths take into account the border-style for the
00488   // relevant side.
00489   nsMargin      mComputedBorder;
00490 
00491   // mBorder holds the nscoord values for the border widths as they would be if
00492   // all the border-style values were visible (not hidden or none).  This
00493   // member exists solely so that when we create structs using the copy
00494   // constructor during style resolution the new structs will know what the
00495   // specified values of the border were in case they have more specific rules
00496   // setting the border style.  Note that this isn't quite the CSS specified
00497   // value, since this has had the enumerated border widths converted to
00498   // lengths, and all lengths converted to twips.  But it's not quite the
00499   // computed value either; mComputedBorder is that.
00500   nsMargin      mBorder;
00501 
00502   PRUint8       mBorderStyle[4];  // [reset] See nsStyleConsts.h
00503   nscolor       mBorderColor[4];  // [reset] the colors to use for a simple border.  not used
00504                                   // if -moz-border-colors is specified
00505 };
00506 
00507 
00508 struct nsStyleBorderPadding: public nsStyleStruct {
00509   nsStyleBorderPadding(void) { mHasCachedBorderPadding = PR_FALSE; };
00510   ~nsStyleBorderPadding(void) {};
00511 
00512   // No accessor for this struct, since it's not a real struct.  At
00513   // least not for now...
00514 
00515   PRBool GetBorderPadding(nsMargin& aBorderPadding) const {
00516     if (mHasCachedBorderPadding) {
00517       aBorderPadding = mCachedBorderPadding;
00518       return PR_TRUE;
00519     }
00520     return PR_FALSE;
00521   }
00522 
00523   void SetBorderPadding(nsMargin aBorderPadding) {
00524     mCachedBorderPadding = aBorderPadding;
00525     mHasCachedBorderPadding = PR_TRUE;
00526   }
00527 
00528 protected:
00529   nsMargin      mCachedBorderPadding;
00530   PRPackedBool  mHasCachedBorderPadding;
00531 };
00532 
00533 
00534 struct nsStyleOutline: public nsStyleStruct {
00535   nsStyleOutline(nsPresContext* aPresContext);
00536   nsStyleOutline(const nsStyleOutline& aOutline);
00537   ~nsStyleOutline(void) {};
00538 
00539   NS_DEFINE_STATIC_STYLESTRUCTID_ACCESSOR(eStyleStruct_Outline)
00540 
00541   void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
00542     return aContext->AllocateFromShell(sz);
00543   }
00544   void Destroy(nsPresContext* aContext) {
00545     this->~nsStyleOutline();
00546     aContext->FreeToShell(sizeof(nsStyleOutline), this);
00547   };
00548 
00549   void RecalcData(nsPresContext* aContext);
00550   nsChangeHint CalcDifference(const nsStyleOutline& aOther) const;
00551 #ifdef DEBUG
00552   static nsChangeHint MaxDifference();
00553 #endif
00554  
00555   nsStyleSides  mOutlineRadius;    // [reset] length, percent, inherit
00556                                                                                                                 // (top=topLeft, right=topRight, bottom=bottomRight, left=bottomLeft)
00557 
00558   nsStyleCoord  mOutlineOffset;   // [reset] length
00559   nsStyleCoord  mOutlineWidth;    // [reset] length, enum (see nsStyleConsts.h)
00560 
00561   PRBool GetOutlineOffset(nscoord& aOffset) const
00562   {
00563     if (mOutlineOffset.GetUnit() == eStyleUnit_Coord) {
00564       aOffset = mOutlineOffset.GetCoordValue();
00565       return PR_TRUE;
00566     } else {
00567       NS_NOTYETIMPLEMENTED("GetOutlineOffset: eStyleUnit_Chars");
00568       aOffset = 0;
00569       return PR_FALSE;
00570     }
00571   }
00572 
00573   PRBool GetOutlineWidth(nscoord& aWidth) const
00574   {
00575     if (mHasCachedOutline) {
00576       aWidth = mCachedOutlineWidth;
00577       return PR_TRUE;
00578     }
00579     return PR_FALSE;
00580   }
00581 
00582   PRUint8 GetOutlineStyle(void) const
00583   {
00584     return (mOutlineStyle & BORDER_STYLE_MASK);
00585   }
00586 
00587   void SetOutlineStyle(PRUint8 aStyle)
00588   {
00589     mOutlineStyle &= ~BORDER_STYLE_MASK;
00590     mOutlineStyle |= (aStyle & BORDER_STYLE_MASK);
00591   }
00592 
00593   // PR_FALSE means INVERT 
00594   PRBool GetOutlineColor(nscolor& aColor) const
00595   {
00596     if ((mOutlineStyle & BORDER_COLOR_SPECIAL) == 0) {
00597       aColor = mOutlineColor;
00598       return PR_TRUE;
00599     }
00600     return PR_FALSE;
00601   }
00602 
00603   void SetOutlineColor(nscolor aColor)
00604   {
00605     mOutlineColor = aColor;
00606     mOutlineStyle &= ~BORDER_COLOR_SPECIAL;
00607   }
00608 
00609   void SetOutlineInvert(void)
00610   {
00611     mOutlineStyle |= BORDER_COLOR_SPECIAL;
00612   }
00613 
00614   PRBool  GetOutlineInvert(void) const
00615   {
00616     return(mOutlineStyle & BORDER_COLOR_SPECIAL);
00617   }
00618 
00619 protected:
00620   nscoord       mCachedOutlineWidth;
00621 
00622   nscolor       mOutlineColor;    // [reset] 
00623 
00624   PRPackedBool  mHasCachedOutline;
00625   PRUint8       mOutlineStyle;    // [reset] See nsStyleConsts.h
00626 };
00627 
00628 
00629 struct nsStyleList : public nsStyleStruct {
00630   nsStyleList(void);
00631   nsStyleList(const nsStyleList& aStyleList);
00632   ~nsStyleList(void);
00633 
00634   NS_DEFINE_STATIC_STYLESTRUCTID_ACCESSOR(eStyleStruct_List)
00635 
00636   void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
00637     return aContext->AllocateFromShell(sz);
00638   }
00639   void Destroy(nsPresContext* aContext) {
00640     this->~nsStyleList();
00641     aContext->FreeToShell(sizeof(nsStyleList), this);
00642   };
00643 
00644   nsChangeHint CalcDifference(const nsStyleList& aOther) const;
00645 #ifdef DEBUG
00646   static nsChangeHint MaxDifference();
00647 #endif
00648   
00649   PRUint8   mListStyleType;             // [inherited] See nsStyleConsts.h
00650   PRUint8   mListStylePosition;         // [inherited] 
00651   nsCOMPtr<imgIRequest> mListStyleImage; // [inherited]
00652   nsRect        mImageRegion;           // [inherited] the rect to use within an image  
00653 };
00654 
00655 struct nsStylePosition : public nsStyleStruct {
00656   nsStylePosition(void);
00657   nsStylePosition(const nsStylePosition& aOther);
00658   ~nsStylePosition(void);
00659 
00660   NS_DEFINE_STATIC_STYLESTRUCTID_ACCESSOR(eStyleStruct_Position)
00661 
00662   void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
00663     return aContext->AllocateFromShell(sz);
00664   }
00665   void Destroy(nsPresContext* aContext) {
00666     this->~nsStylePosition();
00667     aContext->FreeToShell(sizeof(nsStylePosition), this);
00668   };
00669 
00670   nsChangeHint CalcDifference(const nsStylePosition& aOther) const;
00671 #ifdef DEBUG
00672   static nsChangeHint MaxDifference();
00673 #endif
00674   
00675   nsStyleSides  mOffset;                // [reset]
00676   nsStyleCoord  mWidth;                 // [reset] coord, percent, auto, inherit
00677   nsStyleCoord  mMinWidth;              // [reset] coord, percent, inherit
00678   nsStyleCoord  mMaxWidth;              // [reset] coord, percent, null, inherit
00679   nsStyleCoord  mHeight;                // [reset] coord, percent, auto, inherit
00680   nsStyleCoord  mMinHeight;             // [reset] coord, percent, inherit
00681   nsStyleCoord  mMaxHeight;             // [reset] coord, percent, null, inherit
00682   PRUint8       mBoxSizing;             // [reset] see nsStyleConsts.h
00683   nsStyleCoord  mZIndex;                // [reset] 
00684 };
00685 
00686 struct nsStyleTextReset : public nsStyleStruct {
00687   nsStyleTextReset(void);
00688   nsStyleTextReset(const nsStyleTextReset& aOther);
00689   ~nsStyleTextReset(void);
00690 
00691   NS_DEFINE_STATIC_STYLESTRUCTID_ACCESSOR(eStyleStruct_TextReset)
00692 
00693   void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
00694     return aContext->AllocateFromShell(sz);
00695   }
00696   void Destroy(nsPresContext* aContext) {
00697     this->~nsStyleTextReset();
00698     aContext->FreeToShell(sizeof(nsStyleTextReset), this);
00699   };
00700 
00701   nsChangeHint CalcDifference(const nsStyleTextReset& aOther) const;
00702 #ifdef DEBUG
00703   static nsChangeHint MaxDifference();
00704 #endif
00705   
00706   PRUint8 mTextDecoration;              // [reset] see nsStyleConsts.h
00707   PRUint8 mUnicodeBidi;                 // [reset] see nsStyleConsts.h
00708 
00709   nsStyleCoord  mVerticalAlign;         // [reset] see nsStyleConsts.h for enums
00710 };
00711 
00712 struct nsStyleText : public nsStyleStruct {
00713   nsStyleText(void);
00714   nsStyleText(const nsStyleText& aOther);
00715   ~nsStyleText(void);
00716 
00717   NS_DEFINE_STATIC_STYLESTRUCTID_ACCESSOR(eStyleStruct_Text)
00718 
00719   void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
00720     return aContext->AllocateFromShell(sz);
00721   }
00722   void Destroy(nsPresContext* aContext) {
00723     this->~nsStyleText();
00724     aContext->FreeToShell(sizeof(nsStyleText), this);
00725   };
00726 
00727   nsChangeHint CalcDifference(const nsStyleText& aOther) const;
00728 #ifdef DEBUG
00729   static nsChangeHint MaxDifference();
00730 #endif
00731 
00732   PRUint8 mTextAlign;                   // [inherited] see nsStyleConsts.h
00733   PRUint8 mTextTransform;               // [inherited] see nsStyleConsts.h
00734   PRUint8 mWhiteSpace;                  // [inherited] see nsStyleConsts.h
00735 
00736   nsStyleCoord  mLetterSpacing;         // [inherited] 
00737   nsStyleCoord  mLineHeight;            // [inherited] 
00738   nsStyleCoord  mTextIndent;            // [inherited] 
00739   nsStyleCoord  mWordSpacing;           // [inherited] 
00740   
00741   PRBool WhiteSpaceIsSignificant() const {
00742     return mWhiteSpace == NS_STYLE_WHITESPACE_PRE ||
00743            mWhiteSpace == NS_STYLE_WHITESPACE_MOZ_PRE_WRAP;
00744   }
00745 };
00746 
00747 struct nsStyleVisibility : public nsStyleStruct {
00748   nsStyleVisibility(nsPresContext* aPresContext);
00749   nsStyleVisibility(const nsStyleVisibility& aVisibility);
00750   ~nsStyleVisibility() {};
00751 
00752   NS_DEFINE_STATIC_STYLESTRUCTID_ACCESSOR(eStyleStruct_Visibility)
00753 
00754   void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
00755     return aContext->AllocateFromShell(sz);
00756   }
00757   void Destroy(nsPresContext* aContext) {
00758     this->~nsStyleVisibility();
00759     aContext->FreeToShell(sizeof(nsStyleVisibility), this);
00760   };
00761 
00762   nsChangeHint CalcDifference(const nsStyleVisibility& aOther) const;
00763 #ifdef DEBUG
00764   static nsChangeHint MaxDifference();
00765 #endif
00766   
00767   PRUint8 mDirection;                  // [inherited] see nsStyleConsts.h NS_STYLE_DIRECTION_*
00768   PRUint8   mVisible;                  // [inherited]
00769   nsCOMPtr<nsIAtom> mLangGroup;        // [inherited]
00770  
00771   PRBool IsVisible() const {
00772               return (mVisible == NS_STYLE_VISIBILITY_VISIBLE);
00773        }
00774 
00775        PRBool IsVisibleOrCollapsed() const {
00776               return ((mVisible == NS_STYLE_VISIBILITY_VISIBLE) ||
00777                                           (mVisible == NS_STYLE_VISIBILITY_COLLAPSE));
00778        }
00779 };
00780 
00781 struct nsStyleDisplay : public nsStyleStruct {
00782   nsStyleDisplay();
00783   nsStyleDisplay(const nsStyleDisplay& aOther); 
00784   ~nsStyleDisplay() {};
00785 
00786   NS_DEFINE_STATIC_STYLESTRUCTID_ACCESSOR(eStyleStruct_Display)
00787 
00788   void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
00789     return aContext->AllocateFromShell(sz);
00790   }
00791   void Destroy(nsPresContext* aContext) {
00792     this->~nsStyleDisplay();
00793     aContext->FreeToShell(sizeof(nsStyleDisplay), this);
00794   };
00795 
00796   nsChangeHint CalcDifference(const nsStyleDisplay& aOther) const;
00797 #ifdef DEBUG
00798   static nsChangeHint MaxDifference();
00799 #endif
00800   
00801   nsCOMPtr<nsIURI> mBinding;    // [reset]
00802 #if 0
00803   // XXX This is how it is defined in the CSS2 spec, but the errata
00804   // changed it to be consistent with the positioning draft and how
00805   // Nav and IE implement it
00806   nsMargin  mClip;              // [reset] offsets from respective edge
00807 #else
00808   nsRect    mClip;              // [reset] offsets from upper-left border edge
00809 #endif
00810   float   mOpacity;             // [reset]
00811   PRUint8 mDisplay;             // [reset] see nsStyleConsts.h NS_STYLE_DISPLAY_*
00812   PRUint8 mOriginalDisplay;     // [reset] saved mDisplay for position:absolute/fixed
00813   PRUint8 mAppearance;          // [reset]
00814   PRUint8 mPosition;            // [reset] see nsStyleConsts.h
00815   PRUint8 mFloats;              // [reset] see nsStyleConsts.h NS_STYLE_FLOAT_*
00816   PRUint8 mBreakType;           // [reset] see nsStyleConsts.h NS_STYLE_CLEAR_*
00817   PRPackedBool mBreakBefore;    // [reset] 
00818   PRPackedBool mBreakAfter;     // [reset] 
00819   PRUint8 mOverflowX;           // [reset] see nsStyleConsts.h
00820   PRUint8 mOverflowY;           // [reset] see nsStyleConsts.h
00821   PRUint8   mClipFlags;         // [reset] see nsStyleConsts.h
00822   
00823   PRBool IsBlockLevel() const {return (NS_STYLE_DISPLAY_BLOCK == mDisplay) ||
00824                                       (NS_STYLE_DISPLAY_LIST_ITEM == mDisplay) ||
00825                                       (NS_STYLE_DISPLAY_TABLE == mDisplay);}
00826 
00827   PRBool IsFloating() const {
00828     return NS_STYLE_FLOAT_NONE != mFloats;
00829   }
00830 
00831   PRBool IsAbsolutelyPositioned() const {return (NS_STYLE_POSITION_ABSOLUTE == mPosition) ||
00832                                                 (NS_STYLE_POSITION_FIXED == mPosition);}
00833 
00834   PRBool IsPositioned() const {return IsAbsolutelyPositioned() ||
00835                                       (NS_STYLE_POSITION_RELATIVE == mPosition);}
00836 
00837   PRBool IsScrollableOverflow() const {
00838     // mOverflowX and mOverflowY always match when one of them is
00839     // NS_STYLE_OVERFLOW_VISIBLE or NS_STYLE_OVERFLOW_CLIP.
00840     return mOverflowX != NS_STYLE_OVERFLOW_VISIBLE &&
00841            mOverflowX != NS_STYLE_OVERFLOW_CLIP;
00842   }
00843 
00844   // For table elements that don't support scroll frame creation, we
00845   // support 'overflow: hidden' to mean 'overflow: -moz-hidden-unscrollable'.
00846   PRBool IsTableClip() const {
00847     return mOverflowX == NS_STYLE_OVERFLOW_CLIP ||
00848            (mOverflowX == NS_STYLE_OVERFLOW_HIDDEN &&
00849             mOverflowY == NS_STYLE_OVERFLOW_HIDDEN);
00850   }
00851 };
00852 
00853 struct nsStyleTable: public nsStyleStruct {
00854   nsStyleTable(void);
00855   nsStyleTable(const nsStyleTable& aOther);
00856   ~nsStyleTable(void);
00857 
00858   NS_DEFINE_STATIC_STYLESTRUCTID_ACCESSOR(eStyleStruct_Table)
00859 
00860   void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
00861     return aContext->AllocateFromShell(sz);
00862   }
00863   void Destroy(nsPresContext* aContext) {
00864     this->~nsStyleTable();
00865     aContext->FreeToShell(sizeof(nsStyleTable), this);
00866   };
00867 
00868   nsChangeHint CalcDifference(const nsStyleTable& aOther) const;
00869 #ifdef DEBUG
00870   static nsChangeHint MaxDifference();
00871 #endif
00872   
00873   PRUint8       mLayoutStrategy;// [reset] see nsStyleConsts.h NS_STYLE_TABLE_LAYOUT_*
00874   PRUint8       mFrame;         // [reset] see nsStyleConsts.h NS_STYLE_TABLE_FRAME_*
00875   PRUint8       mRules;         // [reset] see nsStyleConsts.h NS_STYLE_TABLE_RULES_*
00876   PRInt32       mCols;          // [reset] an integer if set, or see nsStyleConsts.h NS_STYLE_TABLE_COLS_*
00877   PRInt32       mSpan;          // [reset] the number of columns spanned by a colgroup or col
00878 };
00879 
00880 struct nsStyleTableBorder: public nsStyleStruct {
00881   nsStyleTableBorder(nsPresContext* aContext);
00882   nsStyleTableBorder(const nsStyleTableBorder& aOther);
00883   ~nsStyleTableBorder(void);
00884 
00885   NS_DEFINE_STATIC_STYLESTRUCTID_ACCESSOR(eStyleStruct_TableBorder)
00886 
00887   void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
00888     return aContext->AllocateFromShell(sz);
00889   }
00890   void Destroy(nsPresContext* aContext) {
00891     this->~nsStyleTableBorder();
00892     aContext->FreeToShell(sizeof(nsStyleTableBorder), this);
00893   };
00894 
00895   nsChangeHint CalcDifference(const nsStyleTableBorder& aOther) const;
00896 #ifdef DEBUG
00897   static nsChangeHint MaxDifference();
00898 #endif
00899   
00900   nsStyleCoord  mBorderSpacingX;// [inherited]
00901   nsStyleCoord  mBorderSpacingY;// [inherited]
00902   PRUint8       mBorderCollapse;// [inherited]
00903   PRUint8       mCaptionSide;   // [inherited]
00904   PRUint8       mEmptyCells;    // [inherited]
00905 };
00906 
00907 enum nsStyleContentType {
00908   eStyleContentType_String        = 1,
00909   eStyleContentType_Image         = 10,
00910   eStyleContentType_Attr          = 20,
00911   eStyleContentType_Counter       = 30,
00912   eStyleContentType_Counters      = 31,
00913   eStyleContentType_OpenQuote     = 40,
00914   eStyleContentType_CloseQuote    = 41,
00915   eStyleContentType_NoOpenQuote   = 42,
00916   eStyleContentType_NoCloseQuote  = 43
00917 };
00918 
00919 struct nsStyleContentData {
00920   nsStyleContentType  mType;
00921   union {
00922     PRUnichar *mString;
00923     imgIRequest *mImage;
00924     nsCSSValue::Array* mCounters;
00925   } mContent;
00926 
00927   nsStyleContentData() : mType(nsStyleContentType(0)) { mContent.mString = nsnull; }
00928   ~nsStyleContentData();
00929   nsStyleContentData& operator=(const nsStyleContentData& aOther);
00930   PRBool operator==(const nsStyleContentData& aOther);
00931 
00932   PRBool operator!=(const nsStyleContentData& aOther) {
00933     return !(*this == aOther);
00934   }
00935 private:
00936   nsStyleContentData(const nsStyleContentData&); // not to be implemented
00937 };
00938 
00939 struct nsStyleCounterData {
00940   nsString  mCounter;
00941   PRInt32   mValue;
00942 };
00943 
00944 
00945 #define DELETE_ARRAY_IF(array)  if (array) { delete[] array; array = nsnull; }
00946 
00947 struct nsStyleQuotes : public nsStyleStruct {
00948   nsStyleQuotes();
00949   nsStyleQuotes(const nsStyleQuotes& aQuotes);
00950   ~nsStyleQuotes();
00951 
00952   NS_DEFINE_STATIC_STYLESTRUCTID_ACCESSOR(eStyleStruct_Quotes)
00953 
00954   void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
00955     return aContext->AllocateFromShell(sz);
00956   }
00957   void Destroy(nsPresContext* aContext) {
00958     this->~nsStyleQuotes();
00959     aContext->FreeToShell(sizeof(nsStyleQuotes), this);
00960   };
00961 
00962   nsChangeHint CalcDifference(const nsStyleQuotes& aOther) const;
00963 #ifdef DEBUG
00964   static nsChangeHint MaxDifference();
00965 #endif
00966   
00967   PRUint32  QuotesCount(void) const { return mQuotesCount; } // [inherited]
00968 
00969   const nsString* OpenQuoteAt(PRUint32 aIndex) const
00970   {
00971     NS_ASSERTION(aIndex < mQuotesCount, "out of range");
00972     return mQuotes + (aIndex * 2);
00973   }
00974   const nsString* CloseQuoteAt(PRUint32 aIndex) const
00975   {
00976     NS_ASSERTION(aIndex < mQuotesCount, "out of range");
00977     return mQuotes + (aIndex * 2 + 1);
00978   }
00979   nsresult  GetQuotesAt(PRUint32 aIndex, nsString& aOpen, nsString& aClose) const {
00980     if (aIndex < mQuotesCount) {
00981       aIndex *= 2;
00982       aOpen = mQuotes[aIndex];
00983       aClose = mQuotes[++aIndex];
00984       return NS_OK;
00985     }
00986     return NS_ERROR_ILLEGAL_VALUE;
00987   }
00988 
00989   nsresult  AllocateQuotes(PRUint32 aCount) {
00990     if (aCount != mQuotesCount) {
00991       DELETE_ARRAY_IF(mQuotes);
00992       if (aCount) {
00993         mQuotes = new nsString[aCount * 2];
00994         if (! mQuotes) {
00995           mQuotesCount = 0;
00996           return NS_ERROR_OUT_OF_MEMORY;
00997         }
00998       }
00999       mQuotesCount = aCount;
01000     }
01001     return NS_OK;
01002   }
01003 
01004   nsresult  SetQuotesAt(PRUint32 aIndex, const nsString& aOpen, const nsString& aClose) {
01005     if (aIndex < mQuotesCount) {
01006       aIndex *= 2;
01007       mQuotes[aIndex] = aOpen;
01008       mQuotes[++aIndex] = aClose;
01009       return NS_OK;
01010     }
01011     return NS_ERROR_ILLEGAL_VALUE;
01012   }
01013 
01014 protected:
01015   PRUint32            mQuotesCount;
01016   nsString*           mQuotes;
01017 };
01018 
01019 struct nsStyleContent: public nsStyleStruct {
01020   nsStyleContent(void);
01021   nsStyleContent(const nsStyleContent& aContent);
01022   ~nsStyleContent(void);
01023 
01024   NS_DEFINE_STATIC_STYLESTRUCTID_ACCESSOR(eStyleStruct_Content)
01025 
01026   void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
01027     return aContext->AllocateFromShell(sz);
01028   }
01029   void Destroy(nsPresContext* aContext) {
01030     this->~nsStyleContent();
01031     aContext->FreeToShell(sizeof(nsStyleContent), this);
01032   };
01033 
01034   nsChangeHint CalcDifference(const nsStyleContent& aOther) const;
01035 #ifdef DEBUG
01036   static nsChangeHint MaxDifference();
01037 #endif
01038 
01039   PRUint32  ContentCount(void) const  { return mContentCount; } // [reset]
01040 
01041   const nsStyleContentData& ContentAt(PRUint32 aIndex) const {
01042     NS_ASSERTION(aIndex < mContentCount, "out of range");
01043     return mContents[aIndex];
01044   }
01045 
01046   nsStyleContentData& ContentAt(PRUint32 aIndex) {
01047     NS_ASSERTION(aIndex < mContentCount, "out of range");
01048     return mContents[aIndex];
01049   }
01050 
01051   nsresult AllocateContents(PRUint32 aCount);
01052 
01053   PRUint32  CounterIncrementCount(void) const { return mIncrementCount; }  // [reset]
01054   const nsStyleCounterData* GetCounterIncrementAt(PRUint32 aIndex) const {
01055     NS_ASSERTION(aIndex < mIncrementCount, "out of range");
01056     return &mIncrements[aIndex];
01057   }
01058 
01059   nsresult  AllocateCounterIncrements(PRUint32 aCount) {
01060     if (aCount != mIncrementCount) {
01061       DELETE_ARRAY_IF(mIncrements);
01062       if (aCount) {
01063         mIncrements = new nsStyleCounterData[aCount];
01064         if (! mIncrements) {
01065           mIncrementCount = 0;
01066           return NS_ERROR_OUT_OF_MEMORY;
01067         }
01068       }
01069       mIncrementCount = aCount;
01070     }
01071     return NS_OK;
01072   }
01073 
01074   nsresult  SetCounterIncrementAt(PRUint32 aIndex, const nsString& aCounter, PRInt32 aIncrement) {
01075     if (aIndex < mIncrementCount) {
01076       mIncrements[aIndex].mCounter = aCounter;
01077       mIncrements[aIndex].mValue = aIncrement;
01078       return NS_OK;
01079     }
01080     return NS_ERROR_ILLEGAL_VALUE;
01081   }
01082 
01083   PRUint32  CounterResetCount(void) const { return mResetCount; }  // [reset]
01084   const nsStyleCounterData* GetCounterResetAt(PRUint32 aIndex) const {
01085     NS_ASSERTION(aIndex < mResetCount, "out of range");
01086     return &mResets[aIndex];
01087   }
01088 
01089   nsresult  AllocateCounterResets(PRUint32 aCount) {
01090     if (aCount != mResetCount) {
01091       DELETE_ARRAY_IF(mResets);
01092       if (aCount) {
01093         mResets = new nsStyleCounterData[aCount];
01094         if (! mResets) {
01095           mResetCount = 0;
01096           return NS_ERROR_OUT_OF_MEMORY;
01097         }
01098       }
01099       mResetCount = aCount;
01100     }
01101     return NS_OK;
01102   }
01103 
01104   nsresult  SetCounterResetAt(PRUint32 aIndex, const nsString& aCounter, PRInt32 aValue) {
01105     if (aIndex < mResetCount) {
01106       mResets[aIndex].mCounter = aCounter;
01107       mResets[aIndex].mValue = aValue;
01108       return NS_OK;
01109     }
01110     return NS_ERROR_ILLEGAL_VALUE;
01111   }
01112 
01113   nsStyleCoord  mMarkerOffset;  // [reset]
01114 
01115 protected:
01116   PRUint32            mContentCount;
01117   nsStyleContentData* mContents;
01118 
01119   PRUint32            mIncrementCount;
01120   nsStyleCounterData* mIncrements;
01121 
01122   PRUint32            mResetCount;
01123   nsStyleCounterData* mResets;
01124 };
01125 
01126 struct nsStyleUIReset: public nsStyleStruct {
01127   nsStyleUIReset(void);
01128   nsStyleUIReset(const nsStyleUIReset& aOther);
01129   ~nsStyleUIReset(void);
01130 
01131   NS_DEFINE_STATIC_STYLESTRUCTID_ACCESSOR(eStyleStruct_UIReset)
01132 
01133   void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
01134     return aContext->AllocateFromShell(sz);
01135   }
01136   void Destroy(nsPresContext* aContext) {
01137     this->~nsStyleUIReset();
01138     aContext->FreeToShell(sizeof(nsStyleUIReset), this);
01139   };
01140 
01141   nsChangeHint CalcDifference(const nsStyleUIReset& aOther) const;
01142 #ifdef DEBUG
01143   static nsChangeHint MaxDifference();
01144 #endif
01145 
01146   PRUint8   mUserSelect;      // [reset] (selection-style)
01147   PRUint8   mForceBrokenImageIcon; // [reset]  (0 if not forcing, otherwise forcing)
01148 };
01149 
01150 struct nsCursorImage {
01151   nsCOMPtr<imgIRequest> mImage;
01152   PRBool mHaveHotspot;
01153   float mHotspotX, mHotspotY;
01154 
01155   nsCursorImage();
01156 };
01157 
01158 struct nsStyleUserInterface: public nsStyleStruct {
01159   nsStyleUserInterface(void);
01160   nsStyleUserInterface(const nsStyleUserInterface& aOther);
01161   ~nsStyleUserInterface(void);
01162 
01163   NS_DEFINE_STATIC_STYLESTRUCTID_ACCESSOR(eStyleStruct_UserInterface)
01164 
01165   void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
01166     return aContext->AllocateFromShell(sz);
01167   }
01168   void Destroy(nsPresContext* aContext) {
01169     this->~nsStyleUserInterface();
01170     aContext->FreeToShell(sizeof(nsStyleUserInterface), this);
01171   };
01172 
01173   nsChangeHint CalcDifference(const nsStyleUserInterface& aOther) const;
01174 #ifdef DEBUG
01175   static nsChangeHint MaxDifference();
01176 #endif
01177 
01178   PRUint8   mUserInput;       // [inherited]
01179   PRUint8   mUserModify;      // [inherited] (modify-content)
01180   PRUint8   mUserFocus;       // [inherited] (auto-select)
01181   
01182   PRUint8   mCursor;          // [inherited] See nsStyleConsts.h
01183 
01184   PRUint32 mCursorArrayLength;
01185   nsCursorImage *mCursorArray;// [inherited] The specified URL values
01186                               //   and coordinates.  Takes precedence over
01187                               //   mCursor.  Zero-length array is represented
01188                               //   by null pointer.
01189 
01190   // Does not free mCursorArray; the caller is responsible for calling
01191   // |delete [] mCursorArray| first if it is needed.
01192   void CopyCursorArrayFrom(const nsStyleUserInterface& aSource);
01193 };
01194 
01195 struct nsStyleXUL : public nsStyleStruct {
01196   nsStyleXUL();
01197   nsStyleXUL(const nsStyleXUL& aSource);
01198   ~nsStyleXUL();
01199 
01200   NS_DEFINE_STATIC_STYLESTRUCTID_ACCESSOR(eStyleStruct_XUL)
01201 
01202   void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
01203     return aContext->AllocateFromShell(sz);
01204   }
01205   void Destroy(nsPresContext* aContext) {
01206     this->~nsStyleXUL();
01207     aContext->FreeToShell(sizeof(nsStyleXUL), this);
01208   };
01209 
01210   nsChangeHint CalcDifference(const nsStyleXUL& aOther) const;
01211 #ifdef DEBUG
01212   static nsChangeHint MaxDifference();
01213 #endif
01214   
01215   float         mBoxFlex;               // [reset] see nsStyleConsts.h
01216   PRUint32      mBoxOrdinal;            // [reset] see nsStyleConsts.h
01217   PRUint8       mBoxAlign;              // [reset] see nsStyleConsts.h
01218   PRUint8       mBoxDirection;          // [reset] see nsStyleConsts.h
01219   PRUint8       mBoxOrient;             // [reset] see nsStyleConsts.h
01220   PRUint8       mBoxPack;               // [reset] see nsStyleConsts.h
01221 };
01222 
01223 struct nsStyleColumn : public nsStyleStruct {
01224   nsStyleColumn();
01225   nsStyleColumn(const nsStyleColumn& aSource);
01226   ~nsStyleColumn();
01227 
01228   NS_DEFINE_STATIC_STYLESTRUCTID_ACCESSOR(eStyleStruct_Column)
01229   
01230   void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
01231     return aContext->AllocateFromShell(sz);
01232   }
01233   void Destroy(nsPresContext* aContext) {
01234     this->~nsStyleColumn();
01235     aContext->FreeToShell(sizeof(nsStyleColumn), this);
01236   };
01237 
01238   nsChangeHint CalcDifference(const nsStyleColumn& aOther) const;
01239 #ifdef DEBUG
01240   static nsChangeHint MaxDifference();
01241 #endif
01242 
01243   PRUint32     mColumnCount; // [reset] see nsStyleConsts.h
01244   nsStyleCoord mColumnWidth; // [reset]
01245   nsStyleCoord mColumnGap;   // [reset]
01246 };
01247 
01248 #ifdef MOZ_SVG
01249 enum nsStyleSVGPaintType {
01250   eStyleSVGPaintType_None = 0,
01251   eStyleSVGPaintType_Color,
01252   eStyleSVGPaintType_Server
01253 };
01254 
01255 struct nsStyleSVGPaint
01256 {
01257   nsStyleSVGPaintType mType;
01258   union {
01259     nscolor mColor;
01260     nsIURI *mPaintServer;
01261   } mPaint;
01262 
01263   // empty constructor to keep Sun compiler happy
01264   nsStyleSVGPaint() {}
01265   ~nsStyleSVGPaint(); 
01266   nsStyleSVGPaint& operator=(const nsStyleSVGPaint& aOther);
01267   PRBool operator==(const nsStyleSVGPaint& aOther) const; 
01268 
01269   PRBool operator!=(const nsStyleSVGPaint& aOther) const {
01270     return !(*this == aOther);
01271   }
01272 };
01273 
01274 struct nsStyleSVG : public nsStyleStruct {
01275   nsStyleSVG();
01276   nsStyleSVG(const nsStyleSVG& aSource);
01277   ~nsStyleSVG();
01278 
01279   NS_DEFINE_STATIC_STYLESTRUCTID_ACCESSOR(eStyleStruct_SVG)
01280 
01281   void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
01282     return aContext->AllocateFromShell(sz);
01283   }
01284   void Destroy(nsPresContext* aContext) {
01285     this->~nsStyleSVG();
01286     aContext->FreeToShell(sizeof(nsStyleSVG), this);
01287   };
01288 
01289   nsChangeHint CalcDifference(const nsStyleSVG& aOther) const;
01290 #ifdef DEBUG
01291   static nsChangeHint MaxDifference();
01292 #endif
01293 
01294   nsStyleSVGPaint  mFill;             // [inherited]
01295   nsStyleSVGPaint  mStroke;           // [inherited]
01296   nsCOMPtr<nsIURI> mMarkerEnd;        // [inherited]
01297   nsCOMPtr<nsIURI> mMarkerMid;        // [inherited]
01298   nsCOMPtr<nsIURI> mMarkerStart;      // [inherited]
01299   nsStyleCoord    *mStrokeDasharray;  // [inherited]
01300 
01301   nsStyleCoord     mStrokeDashoffset; // [inherited]
01302   nsStyleCoord     mStrokeWidth;      // [inherited]
01303 
01304   float            mFillOpacity;      // [inherited]
01305   float            mStrokeMiterlimit; // [inherited]
01306   float            mStrokeOpacity;    // [inherited]
01307 
01308   PRUint32         mStrokeDasharrayLength;
01309   PRUint8          mClipRule;         // [inherited]
01310   PRUint8          mFillRule;         // [inherited] see nsStyleConsts.h
01311   PRUint8          mPointerEvents;    // [inherited] see nsStyleConsts.h
01312   PRUint8          mShapeRendering;   // [inherited] see nsStyleConsts.h
01313   PRUint8          mStrokeLinecap;    // [inherited] see nsStyleConsts.h
01314   PRUint8          mStrokeLinejoin;   // [inherited] see nsStyleConsts.h
01315   PRUint8          mTextAnchor;       // [inherited] see nsStyleConsts.h
01316   PRUint8          mTextRendering;    // [inherited] see nsStyleConsts.h
01317 };
01318 
01319 struct nsStyleSVGReset : public nsStyleStruct {
01320   nsStyleSVGReset();
01321   nsStyleSVGReset(const nsStyleSVGReset& aSource);
01322   ~nsStyleSVGReset();
01323 
01324   NS_DEFINE_STATIC_STYLESTRUCTID_ACCESSOR(eStyleStruct_SVGReset)
01325   
01326   void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
01327     return aContext->AllocateFromShell(sz);
01328   }
01329   void Destroy(nsPresContext* aContext) {
01330     this->~nsStyleSVGReset();
01331     aContext->FreeToShell(sizeof(nsStyleSVGReset), this);
01332   };
01333 
01334   nsChangeHint CalcDifference(const nsStyleSVGReset& aOther) const;
01335 #ifdef DEBUG
01336   static nsChangeHint MaxDifference();
01337 #endif
01338 
01339   nsStyleSVGPaint  mStopColor;        // [reset]
01340   nsCOMPtr<nsIURI> mClipPath;         // [reset]
01341   float            mStopOpacity;      // [reset]
01342   PRUint8          mDominantBaseline; // [reset] see nsStyleConsts.h
01343 };
01344 #endif
01345 
01346 
01347 #define BORDER_PRECEDENT_EQUAL  0
01348 #define BORDER_PRECEDENT_LOWER  1
01349 #define BORDER_PRECEDENT_HIGHER 2
01350 
01351 struct nsBorderEdges;
01352 
01354 struct nsBorderEdge
01355 {
01357   nscoord mWidth;
01359   nscoord mLength;
01360   nscolor mColor;
01362   nsBorderEdges * mInsideNeighbor;
01363   PRUint8 mStyle;  
01365   PRUint8 mSide;
01366 
01367   nsBorderEdge();
01368 };
01369 
01370 inline nsBorderEdge::nsBorderEdge()
01371 {
01372   mWidth=0;
01373   mLength=0;
01374   mStyle=NS_STYLE_BORDER_STYLE_NONE;
01375   mColor=0;
01376   mSide=NS_SIDE_LEFT;
01377   mInsideNeighbor = nsnull;
01378 }
01379 
01383 struct nsBorderEdges
01384 {
01385   nsVoidArray  mEdges[4];
01386   nsMargin     mMaxBorderWidth;
01387   PRPackedBool mOutsideEdge;
01388 
01389   nsBorderEdges();
01390 };
01391 
01392 inline nsBorderEdges::nsBorderEdges()
01393 {
01394   mMaxBorderWidth.SizeTo(0,0,0,0);
01395   mOutsideEdge = PR_TRUE;
01396 }
01397 
01398 #endif /* nsStyleStruct_h___ */