Back to index

lightning-sunbird  0.9+nobinonly
nsCSSStruct.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  *   Daniel Glazman <glazman@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 #ifndef nsCSSStruct_h___
00039 #define nsCSSStruct_h___
00040 
00041 #include "nsCSSValue.h"
00042 #include <stdio.h>
00043 
00044 struct nsCSSStruct {
00045   // EMPTY on purpose.  ABSTRACT with no virtuals (typedef void nsCSSStruct?)
00046 };
00047 
00048 // We use the nsCSS* structures for storing nsCSSDeclaration's
00049 // *temporary* data during parsing and modification.  (They are too big
00050 // for permanent storage.)  We also use them for nsRuleData, with some
00051 // additions of things that the style system must cascade, but that
00052 // aren't CSS properties.  Thus we use typedefs and inheritance
00053 // (forwards, when the rule data needs extra data) to make the rule data
00054 // structs from the declaration structs.
00055 // NOTE:  For compilation speed, this typedef also appears in nsRuleNode.h
00056 typedef nsCSSStruct nsRuleDataStruct;
00057 
00058 
00059 struct nsCSSFont : public nsCSSStruct {
00060   nsCSSFont(void);
00061   nsCSSFont(const nsCSSFont& aCopy);
00062   ~nsCSSFont(void);
00063 #ifdef DEBUG
00064   void List(FILE* out = stdout, PRInt32 aIndent = 0) const;
00065 #endif
00066 
00067   nsCSSValue mFamily;
00068   nsCSSValue mStyle;
00069   nsCSSValue mVariant;
00070   nsCSSValue mWeight;
00071   nsCSSValue mSize;
00072   nsCSSValue mSizeAdjust; // NEW
00073   nsCSSValue mStretch; // NEW
00074 };
00075 
00076 struct nsRuleDataFont : public nsCSSFont {
00077   PRBool mFamilyFromHTML; // Is the family from an HTML FONT element
00078 };
00079 
00080 // Prefer nsCSSValue::Array for lists of fixed size.
00081 struct nsCSSValueList {
00082   nsCSSValueList(void);
00083   nsCSSValueList(const nsCSSValueList& aCopy);
00084   ~nsCSSValueList(void);
00085 
00086   static PRBool Equal(nsCSSValueList* aList1, nsCSSValueList* aList2);
00087 
00088   nsCSSValue      mValue;
00089   nsCSSValueList* mNext;
00090 };
00091 
00092 struct nsCSSColor : public nsCSSStruct  {
00093   nsCSSColor(void);
00094   nsCSSColor(const nsCSSColor& aCopy);
00095   ~nsCSSColor(void);
00096 #ifdef DEBUG
00097   void List(FILE* out = stdout, PRInt32 aIndent = 0) const;
00098 #endif
00099 
00100   nsCSSValue      mColor;
00101   nsCSSValue      mBackColor;
00102   nsCSSValue      mBackImage;
00103   nsCSSValue      mBackRepeat;
00104   nsCSSValue      mBackAttachment;
00105   nsCSSValue      mBackPositionX;
00106   nsCSSValue      mBackPositionY;
00107   nsCSSValue      mBackClip;
00108   nsCSSValue      mBackOrigin;
00109   nsCSSValue      mBackInlinePolicy;
00110 };
00111 
00112 struct nsRuleDataColor : public nsCSSColor {
00113 };
00114 
00115 // Should be replaced with nsCSSValueList and nsCSSValue::Array.
00116 struct nsCSSShadow {
00117   nsCSSShadow(void);
00118   nsCSSShadow(const nsCSSShadow& aCopy);
00119   ~nsCSSShadow(void);
00120 
00121   static PRBool Equal(nsCSSShadow* aList1, nsCSSShadow* aList2);
00122 
00123   nsCSSValue mColor;
00124   nsCSSValue mXOffset;
00125   nsCSSValue mYOffset;
00126   nsCSSValue mRadius;
00127   nsCSSShadow*  mNext;
00128 };
00129 
00130 struct nsCSSText : public nsCSSStruct  {
00131   nsCSSText(void);
00132   nsCSSText(const nsCSSText& aCopy);
00133   ~nsCSSText(void);
00134 
00135 #ifdef DEBUG
00136   void List(FILE* out = stdout, PRInt32 aIndent = 0) const;
00137 #endif
00138 
00139   nsCSSValue mWordSpacing;
00140   nsCSSValue mLetterSpacing;
00141   nsCSSValue mVerticalAlign;
00142   nsCSSValue mTextTransform;
00143   nsCSSValue mTextAlign;
00144   nsCSSValue mTextIndent;
00145   nsCSSValue mDecoration;
00146   nsCSSShadow* mTextShadow; // NEW
00147   nsCSSValue mUnicodeBidi;  // NEW
00148   nsCSSValue mLineHeight;
00149   nsCSSValue mWhiteSpace;
00150 };
00151 
00152 struct nsRuleDataText : public nsCSSText {
00153 };
00154 
00155 struct nsCSSRect {
00156   nsCSSRect(void);
00157   nsCSSRect(const nsCSSRect& aCopy);
00158   ~nsCSSRect();
00159 #ifdef DEBUG
00160   void List(FILE* out = 0, nsCSSProperty aPropID = eCSSProperty_UNKNOWN, PRInt32 aIndent = 0) const;
00161   void List(FILE* out, PRInt32 aIndent, const nsCSSProperty aTRBL[]) const;
00162 #endif
00163 
00164   PRBool operator==(const nsCSSRect& aOther) const {
00165     return mTop == aOther.mTop &&
00166            mRight == aOther.mRight &&
00167            mBottom == aOther.mBottom &&
00168            mLeft == aOther.mLeft;
00169   }
00170 
00171   PRBool operator!=(const nsCSSRect& aOther) const {
00172     return mTop != aOther.mTop ||
00173            mRight != aOther.mRight ||
00174            mBottom != aOther.mBottom ||
00175            mLeft != aOther.mLeft;
00176   }
00177 
00178   void SetAllSidesTo(const nsCSSValue& aValue);
00179 
00180   void Reset() {
00181     mTop.Reset();
00182     mRight.Reset();
00183     mBottom.Reset();
00184     mLeft.Reset();
00185   }
00186 
00187   PRBool HasValue() const {
00188     return
00189       mTop.GetUnit() != eCSSUnit_Null ||
00190       mRight.GetUnit() != eCSSUnit_Null ||
00191       mBottom.GetUnit() != eCSSUnit_Null ||
00192       mLeft.GetUnit() != eCSSUnit_Null;
00193   }
00194   
00195   nsCSSValue mTop;
00196   nsCSSValue mRight;
00197   nsCSSValue mBottom;
00198   nsCSSValue mLeft;
00199 
00200   typedef nsCSSValue nsCSSRect::*side_type;
00201   static const side_type sides[4];
00202 };
00203 
00204 MOZ_DECL_CTOR_COUNTER(nsCSSValuePair)
00205 
00206 struct nsCSSValuePair {
00207   nsCSSValuePair()
00208   {
00209     MOZ_COUNT_CTOR(nsCSSValuePair);
00210   }
00211   nsCSSValuePair(const nsCSSValuePair& aCopy)
00212     : mXValue(aCopy.mXValue),
00213       mYValue(aCopy.mYValue)
00214   { 
00215     MOZ_COUNT_CTOR(nsCSSValuePair);
00216   }
00217   ~nsCSSValuePair()
00218   {
00219     MOZ_COUNT_DTOR(nsCSSValuePair);
00220   }
00221 
00222   PRBool operator==(const nsCSSValuePair& aOther) const {
00223     return mXValue == aOther.mXValue &&
00224            mYValue == aOther.mYValue;
00225   }
00226 
00227   PRBool operator!=(const nsCSSValuePair& aOther) const {
00228     return mXValue != aOther.mXValue ||
00229            mYValue != aOther.mYValue;
00230   }
00231 
00232   void SetBothValuesTo(const nsCSSValue& aValue) {
00233     mXValue = aValue;
00234     mYValue = aValue;
00235   }
00236 
00237 #ifdef DEBUG
00238   void AppendToString(nsAString& aString, nsCSSProperty aPropName) const;
00239 #endif
00240   
00241   nsCSSValue mXValue;
00242   nsCSSValue mYValue;
00243 };
00244 
00245 struct nsCSSValueListRect {
00246   nsCSSValueListRect(void);
00247   nsCSSValueListRect(const nsCSSValueListRect& aCopy);
00248   ~nsCSSValueListRect();
00249 #ifdef DEBUG
00250   void List(FILE* out = 0, nsCSSProperty aPropID = eCSSProperty_UNKNOWN, PRInt32 aIndent = 0) const;
00251   void List(FILE* out, PRInt32 aIndent, const nsCSSProperty aTRBL[]) const;
00252 #endif
00253 
00254   nsCSSValueList* mTop;
00255   nsCSSValueList* mRight;
00256   nsCSSValueList* mBottom;
00257   nsCSSValueList* mLeft;
00258 
00259   typedef nsCSSValueList* nsCSSValueListRect::*side_type;
00260   static const side_type sides[4];
00261 };
00262 
00263 struct nsCSSDisplay : public nsCSSStruct  {
00264   nsCSSDisplay(void);
00265   nsCSSDisplay(const nsCSSDisplay& aCopy);
00266   ~nsCSSDisplay(void);
00267 
00268 #ifdef DEBUG
00269   void List(FILE* out = stdout, PRInt32 aIndent = 0) const;
00270 #endif
00271 
00272   nsCSSValue mDirection;
00273   nsCSSValue mDisplay;
00274   nsCSSValue mBinding;
00275   nsCSSValue mAppearance;
00276   nsCSSValue mPosition;
00277   nsCSSValue mFloat;
00278   nsCSSValue mClear;
00279   nsCSSRect  mClip;
00280   nsCSSValue mOverflowX;
00281   nsCSSValue mOverflowY;
00282   nsCSSValue mVisibility;
00283   nsCSSValue mOpacity;
00284 
00285   // temp fix for bug 24000 
00286   nsCSSValue mBreakBefore;
00287   nsCSSValue mBreakAfter;
00288   // end temp fix
00289 };
00290 
00291 struct nsRuleDataDisplay : public nsCSSDisplay {
00292   nsCSSValue mLang;
00293 };
00294 
00295 struct nsCSSMargin : public nsCSSStruct  {
00296   nsCSSMargin(void);
00297   nsCSSMargin(const nsCSSMargin& aCopy);
00298   ~nsCSSMargin(void);
00299 
00300 #ifdef DEBUG
00301   void List(FILE* out = stdout, PRInt32 aIndent = 0) const;
00302 #endif
00303 
00304   nsCSSRect   mMargin;
00305   nsCSSValue  mMarginStart;
00306   nsCSSValue  mMarginEnd;
00307   nsCSSValue  mMarginLeftLTRSource;
00308   nsCSSValue  mMarginLeftRTLSource;
00309   nsCSSValue  mMarginRightLTRSource;
00310   nsCSSValue  mMarginRightRTLSource;
00311   nsCSSRect   mPadding;
00312   nsCSSValue  mPaddingStart;
00313   nsCSSValue  mPaddingEnd;
00314   nsCSSValue  mPaddingLeftLTRSource;
00315   nsCSSValue  mPaddingLeftRTLSource;
00316   nsCSSValue  mPaddingRightLTRSource;
00317   nsCSSValue  mPaddingRightRTLSource;
00318   nsCSSRect   mBorderWidth;
00319   nsCSSRect   mBorderColor;
00320   nsCSSValueListRect mBorderColors;
00321   nsCSSRect   mBorderStyle;
00322   nsCSSRect   mBorderRadius;  // (extension)
00323   nsCSSValue  mOutlineWidth;
00324   nsCSSValue  mOutlineColor;
00325   nsCSSValue  mOutlineStyle;
00326   nsCSSValue  mOutlineOffset;
00327   nsCSSRect   mOutlineRadius; // (extension)
00328   nsCSSValue  mFloatEdge; // NEW
00329 };
00330 
00331 struct nsRuleDataMargin : public nsCSSMargin {
00332 };
00333 
00334 struct nsCSSPosition : public nsCSSStruct  {
00335   nsCSSPosition(void);
00336   nsCSSPosition(const nsCSSPosition& aCopy);
00337   ~nsCSSPosition(void);
00338 
00339 #ifdef DEBUG
00340   void List(FILE* out = stdout, PRInt32 aIndent = 0) const;
00341 #endif
00342 
00343   nsCSSValue  mWidth;
00344   nsCSSValue  mMinWidth;
00345   nsCSSValue  mMaxWidth;
00346   nsCSSValue  mHeight;
00347   nsCSSValue  mMinHeight;
00348   nsCSSValue  mMaxHeight;
00349   nsCSSValue  mBoxSizing; // NEW
00350   nsCSSRect   mOffset;
00351   nsCSSValue  mZIndex;
00352 };
00353 
00354 struct nsRuleDataPosition : public nsCSSPosition {
00355 };
00356 
00357 struct nsCSSList : public nsCSSStruct  {
00358   nsCSSList(void);
00359   nsCSSList(const nsCSSList& aCopy);
00360   ~nsCSSList(void);
00361 
00362 #ifdef DEBUG
00363   void List(FILE* out = stdout, PRInt32 aIndent = 0) const;
00364 #endif
00365 
00366   nsCSSValue mType;
00367   nsCSSValue mImage;
00368   nsCSSValue mPosition;
00369   nsCSSRect  mImageRegion;
00370 };
00371 
00372 struct nsRuleDataList : public nsCSSList {
00373 };
00374 
00375 struct nsCSSTable : public nsCSSStruct  { // NEW
00376   nsCSSTable(void);
00377   nsCSSTable(const nsCSSTable& aCopy);
00378   ~nsCSSTable(void);
00379 
00380 #ifdef DEBUG
00381   void List(FILE* out = stdout, PRInt32 aIndent = 0) const;
00382 #endif
00383 
00384   nsCSSValue mBorderCollapse;
00385   nsCSSValuePair mBorderSpacing;
00386   nsCSSValue mCaptionSide;
00387   nsCSSValue mEmptyCells;
00388   
00389   nsCSSValue mLayout;
00390   nsCSSValue mFrame; // Not mappable via CSS, only using HTML4 table attrs.
00391   nsCSSValue mRules; // Not mappable via CSS, only using HTML4 table attrs.
00392   nsCSSValue mSpan; // Not mappable via CSS, only using HTML4 table attrs.
00393   nsCSSValue mCols; // Not mappable via CSS, only using HTML4 table attrs.
00394 };
00395 
00396 struct nsRuleDataTable : public nsCSSTable {
00397 };
00398 
00399 struct nsCSSBreaks : public nsCSSStruct  { // NEW
00400   nsCSSBreaks(void);
00401   nsCSSBreaks(const nsCSSBreaks& aCopy);
00402   ~nsCSSBreaks(void);
00403 
00404 #ifdef DEBUG
00405   void List(FILE* out = stdout, PRInt32 aIndent = 0) const;
00406 #endif
00407 
00408   nsCSSValue mOrphans;
00409   nsCSSValue mWidows;
00410   nsCSSValue mPage;
00411   // temp fix for bug 24000 
00412   //nsCSSValue mPageBreakAfter;
00413   //nsCSSValue mPageBreakBefore;
00414   nsCSSValue mPageBreakInside;
00415 };
00416 
00417 struct nsRuleDataBreaks : public nsCSSBreaks {
00418 };
00419 
00420 struct nsCSSPage : public nsCSSStruct  { // NEW
00421   nsCSSPage(void);
00422   nsCSSPage(const nsCSSPage& aCopy);
00423   ~nsCSSPage(void);
00424 
00425 #ifdef DEBUG
00426   void List(FILE* out = stdout, PRInt32 aIndent = 0) const;
00427 #endif
00428 
00429   nsCSSValue mMarks;
00430   nsCSSValuePair mSize;
00431 };
00432 
00433 struct nsRuleDataPage : public nsCSSPage {
00434 };
00435 
00436 // Should be replaced with nsCSSValueList and nsCSSValue::Array.
00437 struct nsCSSCounterData {
00438   nsCSSCounterData(void);
00439   nsCSSCounterData(const nsCSSCounterData& aCopy);
00440   ~nsCSSCounterData(void);
00441 
00442   static PRBool Equal(nsCSSCounterData* aList1, nsCSSCounterData* aList2);
00443 
00444   nsCSSValue        mCounter;
00445   nsCSSValue        mValue;
00446   nsCSSCounterData* mNext;
00447 };
00448 
00449 // Should be replaced with nsCSSValueList and nsCSSValue::Array.
00450 struct nsCSSQuotes {
00451   nsCSSQuotes(void);
00452   nsCSSQuotes(const nsCSSQuotes& aCopy);
00453   ~nsCSSQuotes(void);
00454 
00455   static PRBool Equal(nsCSSQuotes* aList1, nsCSSQuotes* aList2);
00456 
00457   nsCSSValue    mOpen;
00458   nsCSSValue    mClose;
00459   nsCSSQuotes*  mNext;
00460 };
00461 
00462 struct nsCSSContent : public nsCSSStruct  {
00463   nsCSSContent(void);
00464   nsCSSContent(const nsCSSContent& aCopy);
00465   ~nsCSSContent(void);
00466 
00467 #ifdef DEBUG
00468   void List(FILE* out = stdout, PRInt32 aIndent = 0) const;
00469 #endif
00470 
00471   nsCSSValueList*   mContent;
00472   nsCSSCounterData* mCounterIncrement;
00473   nsCSSCounterData* mCounterReset;
00474   nsCSSValue        mMarkerOffset;
00475   nsCSSQuotes*      mQuotes;
00476 };
00477 
00478 struct nsRuleDataContent : public nsCSSContent {
00479 };
00480 
00481 struct nsCSSUserInterface : public nsCSSStruct  { // NEW
00482   nsCSSUserInterface(void);
00483   nsCSSUserInterface(const nsCSSUserInterface& aCopy);
00484   ~nsCSSUserInterface(void);
00485 
00486 #ifdef DEBUG
00487   void List(FILE* out = stdout, PRInt32 aIndent = 0) const;
00488 #endif
00489 
00490   nsCSSValue      mUserInput;
00491   nsCSSValue      mUserModify;
00492   nsCSSValue      mUserSelect;
00493   nsCSSValue      mUserFocus;
00494   
00495   nsCSSValueList* mCursor;
00496   nsCSSValue      mForceBrokenImageIcon;
00497 };
00498 
00499 struct nsRuleDataUserInterface : public nsCSSUserInterface {
00500 };
00501 
00502 struct nsCSSAural : public nsCSSStruct  { // NEW
00503   nsCSSAural(void);
00504   nsCSSAural(const nsCSSAural& aCopy);
00505   ~nsCSSAural(void);
00506 
00507 #ifdef DEBUG
00508   void List(FILE* out = stdout, PRInt32 aIndent = 0) const;
00509 #endif
00510 
00511   nsCSSValue mAzimuth;
00512   nsCSSValue mElevation;
00513   nsCSSValue mCueAfter;
00514   nsCSSValue mCueBefore;
00515   nsCSSValue mPauseAfter;
00516   nsCSSValue mPauseBefore;
00517   nsCSSValue mPitch;
00518   nsCSSValue mPitchRange;
00519   nsCSSValuePair mPlayDuring; // mXValue is URI, mYValue are flags
00520   nsCSSValue mRichness;
00521   nsCSSValue mSpeak;
00522   nsCSSValue mSpeakHeader;
00523   nsCSSValue mSpeakNumeral;
00524   nsCSSValue mSpeakPunctuation;
00525   nsCSSValue mSpeechRate;
00526   nsCSSValue mStress;
00527   nsCSSValue mVoiceFamily;
00528   nsCSSValue mVolume;
00529 };
00530 
00531 struct nsRuleDataAural : public nsCSSAural {
00532 };
00533 
00534 struct nsCSSXUL : public nsCSSStruct  {
00535   nsCSSXUL(void);
00536   nsCSSXUL(const nsCSSXUL& aCopy);
00537   ~nsCSSXUL(void);
00538 
00539 #ifdef DEBUG
00540   void List(FILE* out = stdout, PRInt32 aIndent = 0) const;
00541 #endif
00542 
00543   nsCSSValue  mBoxAlign;
00544   nsCSSValue  mBoxDirection;
00545   nsCSSValue  mBoxFlex;
00546   nsCSSValue  mBoxOrient;
00547   nsCSSValue  mBoxPack;
00548   nsCSSValue  mBoxOrdinal;
00549 };
00550 
00551 struct nsRuleDataXUL : public nsCSSXUL {
00552 };
00553 
00554 struct nsCSSColumn : public nsCSSStruct  {
00555   nsCSSColumn(void);
00556   nsCSSColumn(const nsCSSColumn& aCopy);
00557   ~nsCSSColumn(void);
00558 
00559 #ifdef DEBUG
00560   void List(FILE* out = stdout, PRInt32 aIndent = 0) const;
00561 #endif
00562 
00563   nsCSSValue  mColumnCount;
00564   nsCSSValue  mColumnWidth;
00565   nsCSSValue  mColumnGap;
00566 };
00567 
00568 struct nsRuleDataColumn : public nsCSSColumn {
00569 };
00570 
00571 #ifdef MOZ_SVG
00572 struct nsCSSSVG : public nsCSSStruct {
00573   nsCSSSVG(void);
00574   nsCSSSVG(const nsCSSSVG& aCopy);
00575   ~nsCSSSVG(void);
00576 
00577 #ifdef DEBUG
00578   void List(FILE* out = stdout, PRInt32 aIndent = 0) const;
00579 #endif
00580 
00581   nsCSSValue mClipPath;
00582   nsCSSValue mClipRule;
00583   nsCSSValue mDominantBaseline;
00584   nsCSSValue mFill;
00585   nsCSSValue mFillOpacity;
00586   nsCSSValue mFillRule;
00587   nsCSSValue mMarkerEnd;
00588   nsCSSValue mMarkerMid;
00589   nsCSSValue mMarkerStart;
00590   nsCSSValue mPointerEvents;
00591   nsCSSValue mShapeRendering;
00592   nsCSSValue mStopColor;
00593   nsCSSValue mStopOpacity;
00594   nsCSSValue mStroke;
00595   nsCSSValueList *mStrokeDasharray;
00596   nsCSSValue mStrokeDashoffset;
00597   nsCSSValue mStrokeLinecap;
00598   nsCSSValue mStrokeLinejoin;
00599   nsCSSValue mStrokeMiterlimit;
00600   nsCSSValue mStrokeOpacity;
00601   nsCSSValue mStrokeWidth;
00602   nsCSSValue mTextAnchor;
00603   nsCSSValue mTextRendering;
00604 };
00605 
00606 struct nsRuleDataSVG : public nsCSSSVG {
00607 };
00608 #endif
00609 
00610 #endif /* nsCSSStruct_h___ */