Back to index

lightning-sunbird  0.9+nobinonly
nsCSSProps.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 nsCSSProps_h___
00039 #define nsCSSProps_h___
00040 
00041 #include "nsString.h"
00042 #include "nsChangeHint.h"
00043 #include "nsCSSProperty.h"
00044 #include "nsStyleStruct.h"
00045 #include "nsCSSKeywords.h"
00046 
00047 class nsCSSProps {
00048 public:
00049   static void AddRefTable(void);
00050   static void ReleaseTable(void);
00051 
00052   // Given a property string, return the enum value
00053   static nsCSSProperty LookupProperty(const nsAString& aProperty);
00054   static nsCSSProperty LookupProperty(const nsACString& aProperty);
00055 
00056   static inline PRBool IsShorthand(nsCSSProperty aProperty) {
00057     NS_ASSERTION(0 <= aProperty && aProperty < eCSSProperty_COUNT,
00058                  "out of range");
00059     return (aProperty >= eCSSProperty_COUNT_no_shorthands);
00060   }
00061 
00062   // Given a property enum, get the string value
00063   static const nsAFlatCString& GetStringValue(nsCSSProperty aProperty);
00064 
00065   // Given a CSS Property and a Property Enum Value
00066   // Return back a const nsString& representation of the 
00067   // value. Return back nullstr if no value is found
00068   static const nsAFlatCString& LookupPropertyValue(nsCSSProperty aProperty, PRInt32 aValue);
00069 
00070   // Get a color name for a predefined color value like buttonhighlight or activeborder
00071   // Sets the aStr param to the name of the propertyID
00072   static PRBool GetColorName(PRInt32 aPropID, nsCString &aStr);
00073 
00074   // Find |aKeyword| in |aTable|, if found set |aValue| to its corresponding value.
00075   // If not found, return PR_FALSE and do not set |aValue|.
00076   static PRBool FindKeyword(nsCSSKeyword aKeyword, const PRInt32 aTable[], PRInt32& aValue);
00077   // Return the first keyword in |aTable| that has the corresponding value |aValue|.
00078   // Return |eCSSKeyword_UNKNOWN| if not found.
00079   static nsCSSKeyword ValueToKeywordEnum(PRInt32 aValue, const PRInt32 aTable[]);
00080   // Ditto but as a string, return "" when not found.
00081   static const nsAFlatCString& ValueToKeyword(PRInt32 aValue, const PRInt32 aTable[]);
00082 
00083   static const nsCSSType       kTypeTable[eCSSProperty_COUNT_no_shorthands];
00084   static const nsStyleStructID kSIDTable[eCSSProperty_COUNT_no_shorthands];
00085   static const PRInt32* const  kKeywordTableTable[eCSSProperty_COUNT_no_shorthands];
00086 
00087   // A table for shorthand properties.  The appropriate index is the
00088   // property ID minus eCSSProperty_COUNT_no_shorthands.
00089 private:
00090   static const nsCSSProperty *const
00091     kSubpropertyTable[eCSSProperty_COUNT - eCSSProperty_COUNT_no_shorthands];
00092 
00093 public:
00094   static inline
00095   const nsCSSProperty *const SubpropertyEntryFor(nsCSSProperty aProperty) {
00096     NS_ASSERTION(eCSSProperty_COUNT_no_shorthands <= aProperty &&
00097                  aProperty < eCSSProperty_COUNT,
00098                  "out of range");
00099     return nsCSSProps::kSubpropertyTable[aProperty -
00100                                          eCSSProperty_COUNT_no_shorthands];
00101   }
00102 
00103 #define CSSPROPS_FOR_SHORTHAND_SUBPROPERTIES(iter_, prop_)                    \
00104   for (const nsCSSProperty* iter_ = nsCSSProps::SubpropertyEntryFor(prop_);   \
00105        *iter_ != eCSSProperty_UNKNOWN; ++iter_)
00106 
00107   // Keyword/Enum value tables
00108   static const PRInt32 kAppearanceKTable[];
00109   static const PRInt32 kAzimuthKTable[];
00110   static const PRInt32 kBackgroundAttachmentKTable[];
00111   static const PRInt32 kBackgroundClipKTable[];
00112   static const PRInt32 kBackgroundColorKTable[];
00113   static const PRInt32 kBackgroundInlinePolicyKTable[];
00114   static const PRInt32 kBackgroundOriginKTable[];
00115   static const PRInt32 kBackgroundRepeatKTable[];
00116   static const PRInt32 kBackgroundXPositionKTable[];
00117   static const PRInt32 kBackgroundYPositionKTable[];
00118   static const PRInt32 kBorderCollapseKTable[];
00119   static const PRInt32 kBorderColorKTable[];
00120   static const PRInt32 kBorderStyleKTable[];
00121   static const PRInt32 kBorderWidthKTable[];
00122   static const PRInt32 kBoxAlignKTable[];
00123   static const PRInt32 kBoxDirectionKTable[];
00124   static const PRInt32 kBoxOrientKTable[];
00125   static const PRInt32 kBoxPackKTable[];
00126 #ifdef MOZ_SVG
00127   static const PRInt32 kDominantBaselineKTable[];
00128   static const PRInt32 kFillRuleKTable[];
00129   static const PRInt32 kPointerEventsKTable[];
00130   static const PRInt32 kShapeRenderingKTable[];
00131   static const PRInt32 kStrokeLinecapKTable[];
00132   static const PRInt32 kStrokeLinejoinKTable[];
00133   static const PRInt32 kTextAnchorKTable[];
00134   static const PRInt32 kTextRenderingKTable[];
00135 #endif
00136   static const PRInt32 kBoxPropSourceKTable[];
00137   static const PRInt32 kBoxSizingKTable[];
00138   static const PRInt32 kCaptionSideKTable[];
00139   static const PRInt32 kClearKTable[];
00140   static const PRInt32 kColorKTable[];
00141   static const PRInt32 kContentKTable[];
00142   static const PRInt32 kCursorKTable[];
00143   static const PRInt32 kDirectionKTable[];
00144   static const PRInt32 kDisplayKTable[];
00145   static const PRInt32 kElevationKTable[];
00146   static const PRInt32 kEmptyCellsKTable[];
00147   static const PRInt32 kFloatKTable[];
00148   static const PRInt32 kFloatEdgeKTable[];
00149   static const PRInt32 kFontKTable[];
00150   static const PRInt32 kFontSizeKTable[];
00151   static const PRInt32 kFontStretchKTable[];
00152   static const PRInt32 kFontStyleKTable[];
00153   static const PRInt32 kFontVariantKTable[];
00154   static const PRInt32 kFontWeightKTable[];
00155   static const PRInt32 kKeyEquivalentKTable[];
00156   static const PRInt32 kListStylePositionKTable[];
00157   static const PRInt32 kListStyleKTable[];
00158   static const PRInt32 kOutlineStyleKTable[];
00159   static const PRInt32 kOutlineColorKTable[];
00160   static const PRInt32 kOverflowKTable[];
00161   static const PRInt32 kOverflowSubKTable[];
00162   static const PRInt32 kPageBreakKTable[];
00163   static const PRInt32 kPageBreakInsideKTable[];
00164   static const PRInt32 kPageMarksKTable[];
00165   static const PRInt32 kPageSizeKTable[];
00166   static const PRInt32 kPitchKTable[];
00167   static const PRInt32 kPositionKTable[];
00168   static const PRInt32 kSpeakKTable[];
00169   static const PRInt32 kSpeakHeaderKTable[];
00170   static const PRInt32 kSpeakNumeralKTable[];
00171   static const PRInt32 kSpeakPunctuationKTable[];
00172   static const PRInt32 kSpeechRateKTable[];
00173   static const PRInt32 kTableLayoutKTable[];
00174   static const PRInt32 kTextAlignKTable[];
00175   static const PRInt32 kTextDecorationKTable[];
00176   static const PRInt32 kTextTransformKTable[];
00177   static const PRInt32 kUnicodeBidiKTable[];
00178   static const PRInt32 kUserFocusKTable[];
00179   static const PRInt32 kUserInputKTable[];
00180   static const PRInt32 kUserModifyKTable[];
00181   static const PRInt32 kUserSelectKTable[];
00182   static const PRInt32 kVerticalAlignKTable[];
00183   static const PRInt32 kVisibilityKTable[];
00184   static const PRInt32 kVolumeKTable[];
00185   static const PRInt32 kWhitespaceKTable[];
00186 };
00187 
00188 #endif /* nsCSSProps_h___ */