Bug 87229. Replace giant switch statements with bit-ops and jump tables where appropriate. r=attinasi, sr=hyatt

This commit is contained in:
waterson%netscape.com 2001-06-29 22:42:46 +00:00
Родитель cfa7baea01
Коммит f981ffed5f
8 изменённых файлов: 909 добавлений и 679 удалений

Просмотреть файл

@ -191,134 +191,35 @@ struct nsResetStyleData
struct nsCachedStyleData
{
struct StyleStructInfo {
ptrdiff_t mCachedStyleDataOffset;
ptrdiff_t mInheritResetOffset;
PRBool mIsReset;
};
static StyleStructInfo gInfo[];
nsInheritedStyleData* mInheritedData;
nsResetStyleData* mResetData;
static PRBool IsReset(const nsStyleStructID& aSID)
{
switch (aSID) {
case eStyleStruct_Visibility: // [Inherited]
case eStyleStruct_Font:
case eStyleStruct_List:
case eStyleStruct_TableBorder:
case eStyleStruct_Color:
case eStyleStruct_Quotes:
case eStyleStruct_Text:
case eStyleStruct_UserInterface:
return PR_FALSE;
case eStyleStruct_Display: // [Reset]
case eStyleStruct_Margin:
case eStyleStruct_Padding:
case eStyleStruct_Border:
case eStyleStruct_Outline:
case eStyleStruct_Position:
case eStyleStruct_Table:
case eStyleStruct_Background:
case eStyleStruct_Content:
case eStyleStruct_XUL:
case eStyleStruct_TextReset:
case eStyleStruct_UIReset:
return PR_TRUE;
}
return PR_TRUE;
static PRBool IsReset(const nsStyleStructID& aSID) {
return gInfo[aSID].mIsReset;
};
static PRUint32 GetBitForSID(const nsStyleStructID& aSID)
{
switch (aSID) {
case eStyleStruct_Visibility:
return NS_STYLE_INHERIT_VISIBILITY;
case eStyleStruct_Font:
return NS_STYLE_INHERIT_FONT;
case eStyleStruct_Color:
return NS_STYLE_INHERIT_COLOR;
case eStyleStruct_Background:
return NS_STYLE_INHERIT_BACKGROUND;
case eStyleStruct_List:
return NS_STYLE_INHERIT_LIST;
case eStyleStruct_Position:
return NS_STYLE_INHERIT_POSITION;
case eStyleStruct_Text:
return NS_STYLE_INHERIT_TEXT;
case eStyleStruct_TextReset:
return NS_STYLE_INHERIT_TEXT_RESET;
case eStyleStruct_Display:
return NS_STYLE_INHERIT_DISPLAY;
case eStyleStruct_Table:
return NS_STYLE_INHERIT_TABLE;
case eStyleStruct_TableBorder:
return NS_STYLE_INHERIT_TABLE_BORDER;
case eStyleStruct_Content:
return NS_STYLE_INHERIT_CONTENT;
case eStyleStruct_UserInterface:
return NS_STYLE_INHERIT_UI;
case eStyleStruct_UIReset:
return NS_STYLE_INHERIT_UI_RESET;
case eStyleStruct_Margin:
return NS_STYLE_INHERIT_MARGIN;
case eStyleStruct_Padding:
return NS_STYLE_INHERIT_PADDING;
case eStyleStruct_Border:
return NS_STYLE_INHERIT_BORDER;
case eStyleStruct_Outline:
return NS_STYLE_INHERIT_OUTLINE;
case eStyleStruct_Quotes:
return NS_STYLE_INHERIT_QUOTES;
#ifdef INCLUDE_XUL
case eStyleStruct_XUL:
return NS_STYLE_INHERIT_XUL;
#endif
}
return 0;
static PRUint32 GetBitForSID(const nsStyleStructID& aSID) {
return 1 << (aSID - 1);
};
nsStyleStruct* GetStyleData(const nsStyleStructID& aSID) {
switch (aSID) {
case eStyleStruct_Display:
return mResetData ? mResetData->mDisplayData : nsnull;
case eStyleStruct_Visibility:
return mInheritedData ? mInheritedData->mVisibilityData : nsnull;
case eStyleStruct_Font:
return mInheritedData ? mInheritedData->mFontData : nsnull;
case eStyleStruct_Color:
return mInheritedData ? mInheritedData->mColorData : nsnull;
case eStyleStruct_Background:
return mResetData ? mResetData->mBackgroundData : nsnull;
case eStyleStruct_Margin:
return mResetData ? mResetData->mMarginData : nsnull;
case eStyleStruct_Padding:
return mResetData ? mResetData->mPaddingData : nsnull;
case eStyleStruct_Border:
return mResetData ? mResetData->mBorderData : nsnull;
case eStyleStruct_Outline:
return mResetData ? mResetData->mOutlineData : nsnull;
case eStyleStruct_List:
return mInheritedData ? mInheritedData->mListData : nsnull;
case eStyleStruct_Position:
return mResetData ? mResetData->mPositionData : nsnull;
case eStyleStruct_Table:
return mResetData ? mResetData->mTableData : nsnull;
case eStyleStruct_TableBorder:
return mInheritedData ? mInheritedData->mTableData : nsnull;
case eStyleStruct_Content:
return mResetData ? mResetData->mContentData : nsnull;
case eStyleStruct_Quotes:
return mInheritedData ? mInheritedData->mQuotesData : nsnull;
case eStyleStruct_Text:
return mInheritedData ? mInheritedData->mTextData : nsnull;
case eStyleStruct_TextReset:
return mResetData ? mResetData->mTextData : nsnull;
case eStyleStruct_UserInterface:
return mInheritedData ? mInheritedData->mUIData : nsnull;
case eStyleStruct_UIReset:
return mResetData ? mResetData->mUIData : nsnull;
#ifdef INCLUDE_XUL
case eStyleStruct_XUL:
return mResetData ? mResetData->mXULData : nsnull;
#endif
const StyleStructInfo& info = gInfo[aSID];
char* resetOrInheritSlot = NS_REINTERPRET_CAST(char*, this) + info.mCachedStyleDataOffset;
char* resetOrInherit = NS_REINTERPRET_CAST(char*, *NS_REINTERPRET_CAST(void**, resetOrInheritSlot));
nsStyleStruct* data = nsnull;
if (resetOrInherit) {
char* dataSlot = resetOrInherit + info.mInheritResetOffset;
data = *NS_REINTERPRET_CAST(nsStyleStruct**, dataSlot);
}
return nsnull;
return data;
};
void ClearInheritedData(PRUint32 aBits) {
@ -368,7 +269,7 @@ struct nsRuleData
nsRuleData(const nsStyleStructID& aSID, nsIPresContext* aContext, nsIStyleContext* aStyleContext)
:mSID(aSID), mPresContext(aContext), mStyleContext(aStyleContext), mPostResolveCallback(nsnull),
mAttributes(nsnull), mDisplayData(nsnull), mFontData(nsnull), mMarginData(nsnull), mListData(nsnull),
mAttributes(nsnull), mFontData(nsnull), mDisplayData(nsnull), mMarginData(nsnull), mListData(nsnull),
mPositionData(nsnull), mTableData(nsnull), mColorData(nsnull), mContentData(nsnull), mTextData(nsnull),
mUIData(nsnull)
{

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -96,101 +96,107 @@ protected:
nsRuleData* aRuleData,
nsCSSStruct* aSpecificData);
const nsStyleStruct* ComputeStyleData(const nsStyleStructID& aSID, nsStyleStruct* aStartStruct,
const nsCSSStruct& aStartData,
const nsStyleStruct* ComputeDisplayData(nsStyleStruct* aStartDisplay, const nsCSSStruct& aDisplayData,
nsIStyleContext* aContext, nsRuleNode* aHighestNode,
const RuleDetail& aRuleDetail, PRBool aInherited);
const nsStyleStruct* ComputeDisplayData(nsStyleDisplay* aStartDisplay, const nsCSSDisplay& aDisplayData,
const nsStyleStruct* ComputeVisibilityData(nsStyleStruct* aStartVisibility, const nsCSSStruct& aDisplayData,
nsIStyleContext* aContext, nsRuleNode* aHighestNode,
const RuleDetail& aRuleDetail, PRBool aInherited);
const nsStyleStruct* ComputeVisibilityData(nsStyleVisibility* aStartVisibility, const nsCSSDisplay& aDisplayData,
const nsStyleStruct* ComputeFontData(nsStyleStruct* aStartFont, const nsCSSStruct& aFontData,
nsIStyleContext* aContext, nsRuleNode* aHighestNode,
const RuleDetail& aRuleDetail, PRBool aInherited);
const nsStyleStruct* ComputeFontData(nsStyleFont* aStartFont, const nsCSSFont& aFontData,
const nsStyleStruct* ComputeColorData(nsStyleStruct* aStartColor, const nsCSSStruct& aColorData,
nsIStyleContext* aContext, nsRuleNode* aHighestNode,
const RuleDetail& aRuleDetail, PRBool aInherited);
const nsStyleStruct* ComputeColorData(nsStyleColor* aStartColor, const nsCSSColor& aColorData,
const nsStyleStruct* ComputeBackgroundData(nsStyleStruct* aStartBackground, const nsCSSStruct& aColorData,
nsIStyleContext* aContext, nsRuleNode* aHighestNode,
const RuleDetail& aRuleDetail, PRBool aInherited);
const nsStyleStruct* ComputeBackgroundData(nsStyleBackground* aStartBackground, const nsCSSColor& aColorData,
const nsStyleStruct* ComputeMarginData(nsStyleStruct* aStartMargin, const nsCSSStruct& aMarginData,
nsIStyleContext* aContext, nsRuleNode* aHighestNode,
const RuleDetail& aRuleDetail, PRBool aInherited);
const nsStyleStruct* ComputeMarginData(nsStyleMargin* aStartMargin, const nsCSSMargin& aMarginData,
const nsStyleStruct* ComputeBorderData(nsStyleStruct* aStartBorder, const nsCSSStruct& aMarginData,
nsIStyleContext* aContext, nsRuleNode* aHighestNode,
const RuleDetail& aRuleDetail, PRBool aInherited);
const nsStyleStruct* ComputeBorderData(nsStyleBorder* aStartBorder, const nsCSSMargin& aMarginData,
const nsStyleStruct* ComputePaddingData(nsStyleStruct* aStartPadding, const nsCSSStruct& aMarginData,
nsIStyleContext* aContext, nsRuleNode* aHighestNode,
const RuleDetail& aRuleDetail, PRBool aInherited);
const nsStyleStruct* ComputePaddingData(nsStylePadding* aStartPadding, const nsCSSMargin& aMarginData,
const nsStyleStruct* ComputeOutlineData(nsStyleStruct* aStartOutline, const nsCSSStruct& aMarginData,
nsIStyleContext* aContext, nsRuleNode* aHighestNode,
const RuleDetail& aRuleDetail, PRBool aInherited);
const nsStyleStruct* ComputeOutlineData(nsStyleOutline* aStartOutline, const nsCSSMargin& aMarginData,
const nsStyleStruct* ComputeListData(nsStyleStruct* aStartList, const nsCSSStruct& aListData,
nsIStyleContext* aContext, nsRuleNode* aHighestNode,
const RuleDetail& aRuleDetail, PRBool aInherited);
const nsStyleStruct* ComputeListData(nsStyleList* aStartList, const nsCSSList& aListData,
const nsStyleStruct* ComputePositionData(nsStyleStruct* aStartPosition, const nsCSSStruct& aPositionData,
nsIStyleContext* aContext, nsRuleNode* aHighestNode,
const RuleDetail& aRuleDetail, PRBool aInherited);
const nsStyleStruct* ComputePositionData(nsStylePosition* aStartPosition, const nsCSSPosition& aPositionData,
const nsStyleStruct* ComputeTableData(nsStyleStruct* aStartTable, const nsCSSStruct& aTableData,
nsIStyleContext* aContext, nsRuleNode* aHighestNode,
const RuleDetail& aRuleDetail, PRBool aInherited);
const nsStyleStruct* ComputeTableData(nsStyleTable* aStartTable, const nsCSSTable& aTableData,
nsIStyleContext* aContext, nsRuleNode* aHighestNode,
const RuleDetail& aRuleDetail, PRBool aInherited);
const nsStyleStruct* ComputeTableBorderData(nsStyleTableBorder* aStartTable, const nsCSSTable& aTableData,
const nsStyleStruct* ComputeTableBorderData(nsStyleStruct* aStartTable, const nsCSSStruct& aTableData,
nsIStyleContext* aContext,
nsRuleNode* aHighestNode,
const RuleDetail& aRuleDetail, PRBool aInherited);
const nsStyleStruct* ComputeContentData(nsStyleContent* aStartContent, const nsCSSContent& aData,
const nsStyleStruct* ComputeContentData(nsStyleStruct* aStartContent, const nsCSSStruct& aData,
nsIStyleContext* aContext,
nsRuleNode* aHighestNode,
const RuleDetail& aRuleDetail, PRBool aInherited);
const nsStyleStruct* ComputeQuotesData(nsStyleQuotes* aStartQuotes, const nsCSSContent& aData,
const nsStyleStruct* ComputeQuotesData(nsStyleStruct* aStartQuotes, const nsCSSStruct& aData,
nsIStyleContext* aContext,
nsRuleNode* aHighestNode,
const RuleDetail& aRuleDetail, PRBool aInherited);
const nsStyleStruct* ComputeTextData(nsStyleText* aStartData, const nsCSSText& aData,
const nsStyleStruct* ComputeTextData(nsStyleStruct* aStartData, const nsCSSStruct& aData,
nsIStyleContext* aContext,
nsRuleNode* aHighestNode,
const RuleDetail& aRuleDetail, PRBool aInherited);
const nsStyleStruct* ComputeTextResetData(nsStyleTextReset* aStartData, const nsCSSText& aData,
const nsStyleStruct* ComputeTextResetData(nsStyleStruct* aStartData, const nsCSSStruct& aData,
nsIStyleContext* aContext,
nsRuleNode* aHighestNode,
const RuleDetail& aRuleDetail, PRBool aInherited);
const nsStyleStruct* ComputeUIData(nsStyleUserInterface* aStartData, const nsCSSUserInterface& aData,
const nsStyleStruct* ComputeUIData(nsStyleStruct* aStartData, const nsCSSStruct& aData,
nsIStyleContext* aContext,
nsRuleNode* aHighestNode,
const RuleDetail& aRuleDetail, PRBool aInherited);
const nsStyleStruct* ComputeUIResetData(nsStyleUIReset* aStartData, const nsCSSUserInterface& aData,
const nsStyleStruct* ComputeUIResetData(nsStyleStruct* aStartData, const nsCSSStruct& aData,
nsIStyleContext* aContext,
nsRuleNode* aHighestNode,
const RuleDetail& aRuleDetail, PRBool aInherited);
#ifdef INCLUDE_XUL
const nsStyleStruct* ComputeXULData(nsStyleXUL* aStartXUL, const nsCSSXUL& aXULData,
const nsStyleStruct* ComputeXULData(nsStyleStruct* aStartXUL, const nsCSSStruct& aXULData,
nsIStyleContext* aContext,
nsRuleNode* aHighestNode,
const RuleDetail& aRuleDetail, PRBool aInherited);
#endif
RuleDetail CheckSpecifiedProperties(const nsStyleStructID& aSID, const nsCSSStruct& aCSSStruct);
RuleDetail CheckDisplayProperties(const nsCSSDisplay& aDisplay);
RuleDetail CheckVisibilityProperties(const nsCSSDisplay& aDisplay);
RuleDetail CheckFontProperties(const nsCSSFont& aFont);
RuleDetail CheckColorProperties(const nsCSSColor& aColor);
RuleDetail CheckBackgroundProperties(const nsCSSColor& aColor);
RuleDetail CheckMarginProperties(const nsCSSMargin& aMargin);
RuleDetail CheckBorderProperties(const nsCSSMargin& aMargin);
RuleDetail CheckPaddingProperties(const nsCSSMargin& aMargin);
RuleDetail CheckOutlineProperties(const nsCSSMargin& aMargin);
RuleDetail CheckListProperties(const nsCSSList& aList);
RuleDetail CheckPositionProperties(const nsCSSPosition& aPosition);
RuleDetail CheckTableProperties(const nsCSSTable& aTable);
RuleDetail CheckTableBorderProperties(const nsCSSTable& aTable);
RuleDetail CheckContentProperties(const nsCSSContent& aContent);
RuleDetail CheckQuotesProperties(const nsCSSContent& aContent);
RuleDetail CheckTextProperties(const nsCSSText& aText);
RuleDetail CheckTextResetProperties(const nsCSSText& aText);
RuleDetail CheckUIProperties(const nsCSSUserInterface& aUI);
RuleDetail CheckUIResetProperties(const nsCSSUserInterface& aUI);
typedef const nsStyleStruct*
(nsRuleNode::*ComputeStyleDataFn)(nsStyleStruct* aStartStruct,
const nsCSSStruct& aStartData,
nsIStyleContext* aContext,
nsRuleNode* aHighestNode,
const RuleDetail& aRuleDetail,
PRBool aInherited);
static ComputeStyleDataFn gComputeStyleDataFn[];
inline RuleDetail CheckSpecifiedProperties(const nsStyleStructID& aSID, const nsCSSStruct& aCSSStruct);
inline RuleDetail CheckDisplayProperties(const nsCSSDisplay& aDisplay);
inline RuleDetail CheckVisibilityProperties(const nsCSSDisplay& aDisplay);
inline RuleDetail CheckFontProperties(const nsCSSFont& aFont);
inline RuleDetail CheckColorProperties(const nsCSSColor& aColor);
inline RuleDetail CheckBackgroundProperties(const nsCSSColor& aColor);
inline RuleDetail CheckMarginProperties(const nsCSSMargin& aMargin);
inline RuleDetail CheckBorderProperties(const nsCSSMargin& aMargin);
inline RuleDetail CheckPaddingProperties(const nsCSSMargin& aMargin);
inline RuleDetail CheckOutlineProperties(const nsCSSMargin& aMargin);
inline RuleDetail CheckListProperties(const nsCSSList& aList);
inline RuleDetail CheckPositionProperties(const nsCSSPosition& aPosition);
inline RuleDetail CheckTableProperties(const nsCSSTable& aTable);
inline RuleDetail CheckTableBorderProperties(const nsCSSTable& aTable);
inline RuleDetail CheckContentProperties(const nsCSSContent& aContent);
inline RuleDetail CheckQuotesProperties(const nsCSSContent& aContent);
inline RuleDetail CheckTextProperties(const nsCSSText& aText);
inline RuleDetail CheckTextResetProperties(const nsCSSText& aText);
inline RuleDetail CheckUIProperties(const nsCSSUserInterface& aUI);
inline RuleDetail CheckUIResetProperties(const nsCSSUserInterface& aUI);
#ifdef INCLUDE_XUL
RuleDetail CheckXULProperties(const nsCSSXUL& aXUL);
@ -220,6 +226,9 @@ protected:
const nsStyleStruct* GetXULData(nsIStyleContext* aContext);
#endif
typedef const nsStyleStruct* (nsRuleNode::*GetStyleDataFn)(nsIStyleContext*);
static GetStyleDataFn gGetStyleDataFn[];
public:
nsRuleNode(nsIPresContext* aPresContext, nsIStyleRule* aRule=nsnull, nsRuleNode* aParent=nsnull);
virtual ~nsRuleNode();

Просмотреть файл

@ -41,6 +41,122 @@
#include "nsIServiceManager.h"
#include "nsIPref.h"
// XXX This is here because nsCachedStyleData is accessed outside of
// the content module; e.g., by nsCSSFrameConstructor.
#include "nsIRuleNode.h"
nsCachedStyleData::StyleStructInfo
nsCachedStyleData::gInfo[] = {
// Note that these must line up _exactly_ with the numeric values of
// the nsStyleStructID enum.
{ 0, 0, 0 },
/* eStyleStruct_Font */
{ offsetof(nsCachedStyleData, mInheritedData),
offsetof(nsInheritedStyleData, mFontData),
PR_FALSE
},
/* eStyleStruct_Color */
{ offsetof(nsCachedStyleData, mInheritedData),
offsetof(nsInheritedStyleData, mColorData),
PR_FALSE
},
/* eStyleStruct_Background */
{ offsetof(nsCachedStyleData, mResetData),
offsetof(nsResetStyleData, mBackgroundData),
PR_TRUE
},
/* eStyleStruct_List */
{ offsetof(nsCachedStyleData, mInheritedData),
offsetof(nsInheritedStyleData, mListData),
PR_FALSE
},
/* eStyleStruct_Position */
{ offsetof(nsCachedStyleData, mResetData),
offsetof(nsResetStyleData, mPositionData),
PR_TRUE
},
/* eStyleStruct_Text */
{ offsetof(nsCachedStyleData, mInheritedData),
offsetof(nsInheritedStyleData, mTextData),
PR_FALSE
},
/* eStyleStruct_TextReset */
{ offsetof(nsCachedStyleData, mResetData),
offsetof(nsResetStyleData, mTextData),
PR_TRUE
},
/* eStyleStruct_Display */
{ offsetof(nsCachedStyleData, mResetData),
offsetof(nsResetStyleData, mDisplayData),
PR_TRUE
},
/* eStyleStruct_Visibility */
{ offsetof(nsCachedStyleData, mInheritedData),
offsetof(nsInheritedStyleData, mVisibilityData),
PR_FALSE
},
/* eStyleStruct_Content */
{ offsetof(nsCachedStyleData, mResetData),
offsetof(nsResetStyleData, mContentData),
PR_TRUE
},
/* eStyleStruct_Quotes */
{ offsetof(nsCachedStyleData, mInheritedData),
offsetof(nsInheritedStyleData, mQuotesData),
PR_FALSE
},
/* eStyleStruct_UserInterface */
{ offsetof(nsCachedStyleData, mInheritedData),
offsetof(nsInheritedStyleData, mUIData),
PR_FALSE
},
/* eStyleStruct_UIReset */
{ offsetof(nsCachedStyleData, mResetData),
offsetof(nsResetStyleData, mUIData),
PR_TRUE
},
/* eStyleStruct_Table */
{ offsetof(nsCachedStyleData, mResetData),
offsetof(nsResetStyleData, mTableData),
PR_TRUE
},
/* eStyleStruct_TableBorder */
{ offsetof(nsCachedStyleData, mInheritedData),
offsetof(nsInheritedStyleData, mTableData),
PR_FALSE
},
/* eStyleStruct_Margin */
{ offsetof(nsCachedStyleData, mResetData),
offsetof(nsResetStyleData, mMarginData),
PR_TRUE
},
/* eStyleStruct_Padding */
{ offsetof(nsCachedStyleData, mResetData),
offsetof(nsResetStyleData, mPaddingData),
PR_TRUE
},
/* eStyleStruct_Border */
{ offsetof(nsCachedStyleData, mResetData),
offsetof(nsResetStyleData, mBorderData),
PR_TRUE
},
/* eStyleStruct_Outline */
{ offsetof(nsCachedStyleData, mResetData),
offsetof(nsResetStyleData, mOutlineData),
PR_TRUE
},
#ifdef INCLUDE_XUL
/* eStyleStruct_XUL */
{ offsetof(nsCachedStyleData, mResetData),
offsetof(nsResetStyleData, mXULData),
PR_TRUE
},
#endif
{ 0, 0, 0 }
};
static NS_DEFINE_CID(kPrefCID, NS_PREF_CID);
#define POSITIVE_SCALE_FACTOR 1.10 /* 10% */

Просмотреть файл

@ -39,37 +39,6 @@
class nsIFrame;
// Bits for each struct.
#define NS_STYLE_INHERIT_FONT 0x000001
#define NS_STYLE_INHERIT_COLOR 0x000002
#define NS_STYLE_INHERIT_BACKGROUND 0x000004
#define NS_STYLE_INHERIT_LIST 0x000008
#define NS_STYLE_INHERIT_POSITION 0x000010
#define NS_STYLE_INHERIT_TEXT 0x000020
#define NS_STYLE_INHERIT_TEXT_RESET 0x000040
#define NS_STYLE_INHERIT_DISPLAY 0x000080
#define NS_STYLE_INHERIT_VISIBILITY 0x000100
#define NS_STYLE_INHERIT_TABLE 0x000200
#define NS_STYLE_INHERIT_TABLE_BORDER 0x000400
#define NS_STYLE_INHERIT_CONTENT 0x000800
#define NS_STYLE_INHERIT_QUOTES 0x001000
#define NS_STYLE_INHERIT_UI 0x002000
#define NS_STYLE_INHERIT_UI_RESET 0x004000
#define NS_STYLE_INHERIT_MARGIN 0x008000
#define NS_STYLE_INHERIT_PADDING 0x010000
#define NS_STYLE_INHERIT_BORDER 0x020000
#define NS_STYLE_INHERIT_OUTLINE 0x040000
#define NS_STYLE_INHERIT_XUL 0x080000
#define NS_STYLE_INHERIT_MASK 0x0fffff
// A bit to test whether or not a style context can be shared
// by siblings.
#define NS_STYLE_UNIQUE_CONTEXT 0x100000
// A bit to test whether or not we have any text decorations.
#define NS_STYLE_HAS_TEXT_DECORATIONS 0x200000
enum nsStyleStructID {
eStyleStruct_Font = 1,
eStyleStruct_Color = 2,
@ -95,6 +64,38 @@ enum nsStyleStructID {
eStyleStruct_BorderPaddingShortcut = 21 // only for use in GetStyle()
};
// Bits for each struct.
#define NS_STYLE_INHERIT_BIT(sid_) (1 << (PRInt32(sid_) - 1))
#define NS_STYLE_INHERIT_FONT NS_STYLE_INHERIT_BIT(eStyleStruct_Font)
#define NS_STYLE_INHERIT_COLOR NS_STYLE_INHERIT_BIT(eStyleStruct_Color)
#define NS_STYLE_INHERIT_BACKGROUND NS_STYLE_INHERIT_BIT(eStyleStruct_Background)
#define NS_STYLE_INHERIT_LIST NS_STYLE_INHERIT_BIT(eStyleStruct_List)
#define NS_STYLE_INHERIT_POSITION NS_STYLE_INHERIT_BIT(eStyleStruct_Position)
#define NS_STYLE_INHERIT_TEXT NS_STYLE_INHERIT_BIT(eStyleStruct_Text)
#define NS_STYLE_INHERIT_TEXT_RESET NS_STYLE_INHERIT_BIT(eStyleStruct_TextReset)
#define NS_STYLE_INHERIT_DISPLAY NS_STYLE_INHERIT_BIT(eStyleStruct_Display)
#define NS_STYLE_INHERIT_VISIBILITY NS_STYLE_INHERIT_BIT(eStyleStruct_Visibility)
#define NS_STYLE_INHERIT_TABLE NS_STYLE_INHERIT_BIT(eStyleStruct_Table)
#define NS_STYLE_INHERIT_TABLE_BORDER NS_STYLE_INHERIT_BIT(eStyleStruct_TableBorder)
#define NS_STYLE_INHERIT_CONTENT NS_STYLE_INHERIT_BIT(eStyleStruct_Content)
#define NS_STYLE_INHERIT_QUOTES NS_STYLE_INHERIT_BIT(eStyleStruct_Quotes)
#define NS_STYLE_INHERIT_UI NS_STYLE_INHERIT_BIT(eStyleStruct_UserInterface)
#define NS_STYLE_INHERIT_UI_RESET NS_STYLE_INHERIT_BIT(eStyleStruct_UIReset)
#define NS_STYLE_INHERIT_MARGIN NS_STYLE_INHERIT_BIT(eStyleStruct_Margin)
#define NS_STYLE_INHERIT_PADDING NS_STYLE_INHERIT_BIT(eStyleStruct_Padding)
#define NS_STYLE_INHERIT_BORDER NS_STYLE_INHERIT_BIT(eStyleStruct_Border)
#define NS_STYLE_INHERIT_OUTLINE NS_STYLE_INHERIT_BIT(eStyleStruct_Outline)
#define NS_STYLE_INHERIT_XUL NS_STYLE_INHERIT_BIT(eStyleStruct_XUL)
#define NS_STYLE_INHERIT_MASK 0x0fffff
// A bit to test whether or not a style context can be shared
// by siblings.
#define NS_STYLE_UNIQUE_CONTEXT 0x100000
// A bit to test whether or not we have any text decorations.
#define NS_STYLE_HAS_TEXT_DECORATIONS 0x200000
// The actual structs start here
struct nsStyleStruct {
};

Просмотреть файл

@ -41,6 +41,122 @@
#include "nsIServiceManager.h"
#include "nsIPref.h"
// XXX This is here because nsCachedStyleData is accessed outside of
// the content module; e.g., by nsCSSFrameConstructor.
#include "nsIRuleNode.h"
nsCachedStyleData::StyleStructInfo
nsCachedStyleData::gInfo[] = {
// Note that these must line up _exactly_ with the numeric values of
// the nsStyleStructID enum.
{ 0, 0, 0 },
/* eStyleStruct_Font */
{ offsetof(nsCachedStyleData, mInheritedData),
offsetof(nsInheritedStyleData, mFontData),
PR_FALSE
},
/* eStyleStruct_Color */
{ offsetof(nsCachedStyleData, mInheritedData),
offsetof(nsInheritedStyleData, mColorData),
PR_FALSE
},
/* eStyleStruct_Background */
{ offsetof(nsCachedStyleData, mResetData),
offsetof(nsResetStyleData, mBackgroundData),
PR_TRUE
},
/* eStyleStruct_List */
{ offsetof(nsCachedStyleData, mInheritedData),
offsetof(nsInheritedStyleData, mListData),
PR_FALSE
},
/* eStyleStruct_Position */
{ offsetof(nsCachedStyleData, mResetData),
offsetof(nsResetStyleData, mPositionData),
PR_TRUE
},
/* eStyleStruct_Text */
{ offsetof(nsCachedStyleData, mInheritedData),
offsetof(nsInheritedStyleData, mTextData),
PR_FALSE
},
/* eStyleStruct_TextReset */
{ offsetof(nsCachedStyleData, mResetData),
offsetof(nsResetStyleData, mTextData),
PR_TRUE
},
/* eStyleStruct_Display */
{ offsetof(nsCachedStyleData, mResetData),
offsetof(nsResetStyleData, mDisplayData),
PR_TRUE
},
/* eStyleStruct_Visibility */
{ offsetof(nsCachedStyleData, mInheritedData),
offsetof(nsInheritedStyleData, mVisibilityData),
PR_FALSE
},
/* eStyleStruct_Content */
{ offsetof(nsCachedStyleData, mResetData),
offsetof(nsResetStyleData, mContentData),
PR_TRUE
},
/* eStyleStruct_Quotes */
{ offsetof(nsCachedStyleData, mInheritedData),
offsetof(nsInheritedStyleData, mQuotesData),
PR_FALSE
},
/* eStyleStruct_UserInterface */
{ offsetof(nsCachedStyleData, mInheritedData),
offsetof(nsInheritedStyleData, mUIData),
PR_FALSE
},
/* eStyleStruct_UIReset */
{ offsetof(nsCachedStyleData, mResetData),
offsetof(nsResetStyleData, mUIData),
PR_TRUE
},
/* eStyleStruct_Table */
{ offsetof(nsCachedStyleData, mResetData),
offsetof(nsResetStyleData, mTableData),
PR_TRUE
},
/* eStyleStruct_TableBorder */
{ offsetof(nsCachedStyleData, mInheritedData),
offsetof(nsInheritedStyleData, mTableData),
PR_FALSE
},
/* eStyleStruct_Margin */
{ offsetof(nsCachedStyleData, mResetData),
offsetof(nsResetStyleData, mMarginData),
PR_TRUE
},
/* eStyleStruct_Padding */
{ offsetof(nsCachedStyleData, mResetData),
offsetof(nsResetStyleData, mPaddingData),
PR_TRUE
},
/* eStyleStruct_Border */
{ offsetof(nsCachedStyleData, mResetData),
offsetof(nsResetStyleData, mBorderData),
PR_TRUE
},
/* eStyleStruct_Outline */
{ offsetof(nsCachedStyleData, mResetData),
offsetof(nsResetStyleData, mOutlineData),
PR_TRUE
},
#ifdef INCLUDE_XUL
/* eStyleStruct_XUL */
{ offsetof(nsCachedStyleData, mResetData),
offsetof(nsResetStyleData, mXULData),
PR_TRUE
},
#endif
{ 0, 0, 0 }
};
static NS_DEFINE_CID(kPrefCID, NS_PREF_CID);
#define POSITIVE_SCALE_FACTOR 1.10 /* 10% */

Просмотреть файл

@ -39,37 +39,6 @@
class nsIFrame;
// Bits for each struct.
#define NS_STYLE_INHERIT_FONT 0x000001
#define NS_STYLE_INHERIT_COLOR 0x000002
#define NS_STYLE_INHERIT_BACKGROUND 0x000004
#define NS_STYLE_INHERIT_LIST 0x000008
#define NS_STYLE_INHERIT_POSITION 0x000010
#define NS_STYLE_INHERIT_TEXT 0x000020
#define NS_STYLE_INHERIT_TEXT_RESET 0x000040
#define NS_STYLE_INHERIT_DISPLAY 0x000080
#define NS_STYLE_INHERIT_VISIBILITY 0x000100
#define NS_STYLE_INHERIT_TABLE 0x000200
#define NS_STYLE_INHERIT_TABLE_BORDER 0x000400
#define NS_STYLE_INHERIT_CONTENT 0x000800
#define NS_STYLE_INHERIT_QUOTES 0x001000
#define NS_STYLE_INHERIT_UI 0x002000
#define NS_STYLE_INHERIT_UI_RESET 0x004000
#define NS_STYLE_INHERIT_MARGIN 0x008000
#define NS_STYLE_INHERIT_PADDING 0x010000
#define NS_STYLE_INHERIT_BORDER 0x020000
#define NS_STYLE_INHERIT_OUTLINE 0x040000
#define NS_STYLE_INHERIT_XUL 0x080000
#define NS_STYLE_INHERIT_MASK 0x0fffff
// A bit to test whether or not a style context can be shared
// by siblings.
#define NS_STYLE_UNIQUE_CONTEXT 0x100000
// A bit to test whether or not we have any text decorations.
#define NS_STYLE_HAS_TEXT_DECORATIONS 0x200000
enum nsStyleStructID {
eStyleStruct_Font = 1,
eStyleStruct_Color = 2,
@ -95,6 +64,38 @@ enum nsStyleStructID {
eStyleStruct_BorderPaddingShortcut = 21 // only for use in GetStyle()
};
// Bits for each struct.
#define NS_STYLE_INHERIT_BIT(sid_) (1 << (PRInt32(sid_) - 1))
#define NS_STYLE_INHERIT_FONT NS_STYLE_INHERIT_BIT(eStyleStruct_Font)
#define NS_STYLE_INHERIT_COLOR NS_STYLE_INHERIT_BIT(eStyleStruct_Color)
#define NS_STYLE_INHERIT_BACKGROUND NS_STYLE_INHERIT_BIT(eStyleStruct_Background)
#define NS_STYLE_INHERIT_LIST NS_STYLE_INHERIT_BIT(eStyleStruct_List)
#define NS_STYLE_INHERIT_POSITION NS_STYLE_INHERIT_BIT(eStyleStruct_Position)
#define NS_STYLE_INHERIT_TEXT NS_STYLE_INHERIT_BIT(eStyleStruct_Text)
#define NS_STYLE_INHERIT_TEXT_RESET NS_STYLE_INHERIT_BIT(eStyleStruct_TextReset)
#define NS_STYLE_INHERIT_DISPLAY NS_STYLE_INHERIT_BIT(eStyleStruct_Display)
#define NS_STYLE_INHERIT_VISIBILITY NS_STYLE_INHERIT_BIT(eStyleStruct_Visibility)
#define NS_STYLE_INHERIT_TABLE NS_STYLE_INHERIT_BIT(eStyleStruct_Table)
#define NS_STYLE_INHERIT_TABLE_BORDER NS_STYLE_INHERIT_BIT(eStyleStruct_TableBorder)
#define NS_STYLE_INHERIT_CONTENT NS_STYLE_INHERIT_BIT(eStyleStruct_Content)
#define NS_STYLE_INHERIT_QUOTES NS_STYLE_INHERIT_BIT(eStyleStruct_Quotes)
#define NS_STYLE_INHERIT_UI NS_STYLE_INHERIT_BIT(eStyleStruct_UserInterface)
#define NS_STYLE_INHERIT_UI_RESET NS_STYLE_INHERIT_BIT(eStyleStruct_UIReset)
#define NS_STYLE_INHERIT_MARGIN NS_STYLE_INHERIT_BIT(eStyleStruct_Margin)
#define NS_STYLE_INHERIT_PADDING NS_STYLE_INHERIT_BIT(eStyleStruct_Padding)
#define NS_STYLE_INHERIT_BORDER NS_STYLE_INHERIT_BIT(eStyleStruct_Border)
#define NS_STYLE_INHERIT_OUTLINE NS_STYLE_INHERIT_BIT(eStyleStruct_Outline)
#define NS_STYLE_INHERIT_XUL NS_STYLE_INHERIT_BIT(eStyleStruct_XUL)
#define NS_STYLE_INHERIT_MASK 0x0fffff
// A bit to test whether or not a style context can be shared
// by siblings.
#define NS_STYLE_UNIQUE_CONTEXT 0x100000
// A bit to test whether or not we have any text decorations.
#define NS_STYLE_HAS_TEXT_DECORATIONS 0x200000
// The actual structs start here
struct nsStyleStruct {
};

Просмотреть файл

@ -41,6 +41,122 @@
#include "nsIServiceManager.h"
#include "nsIPref.h"
// XXX This is here because nsCachedStyleData is accessed outside of
// the content module; e.g., by nsCSSFrameConstructor.
#include "nsIRuleNode.h"
nsCachedStyleData::StyleStructInfo
nsCachedStyleData::gInfo[] = {
// Note that these must line up _exactly_ with the numeric values of
// the nsStyleStructID enum.
{ 0, 0, 0 },
/* eStyleStruct_Font */
{ offsetof(nsCachedStyleData, mInheritedData),
offsetof(nsInheritedStyleData, mFontData),
PR_FALSE
},
/* eStyleStruct_Color */
{ offsetof(nsCachedStyleData, mInheritedData),
offsetof(nsInheritedStyleData, mColorData),
PR_FALSE
},
/* eStyleStruct_Background */
{ offsetof(nsCachedStyleData, mResetData),
offsetof(nsResetStyleData, mBackgroundData),
PR_TRUE
},
/* eStyleStruct_List */
{ offsetof(nsCachedStyleData, mInheritedData),
offsetof(nsInheritedStyleData, mListData),
PR_FALSE
},
/* eStyleStruct_Position */
{ offsetof(nsCachedStyleData, mResetData),
offsetof(nsResetStyleData, mPositionData),
PR_TRUE
},
/* eStyleStruct_Text */
{ offsetof(nsCachedStyleData, mInheritedData),
offsetof(nsInheritedStyleData, mTextData),
PR_FALSE
},
/* eStyleStruct_TextReset */
{ offsetof(nsCachedStyleData, mResetData),
offsetof(nsResetStyleData, mTextData),
PR_TRUE
},
/* eStyleStruct_Display */
{ offsetof(nsCachedStyleData, mResetData),
offsetof(nsResetStyleData, mDisplayData),
PR_TRUE
},
/* eStyleStruct_Visibility */
{ offsetof(nsCachedStyleData, mInheritedData),
offsetof(nsInheritedStyleData, mVisibilityData),
PR_FALSE
},
/* eStyleStruct_Content */
{ offsetof(nsCachedStyleData, mResetData),
offsetof(nsResetStyleData, mContentData),
PR_TRUE
},
/* eStyleStruct_Quotes */
{ offsetof(nsCachedStyleData, mInheritedData),
offsetof(nsInheritedStyleData, mQuotesData),
PR_FALSE
},
/* eStyleStruct_UserInterface */
{ offsetof(nsCachedStyleData, mInheritedData),
offsetof(nsInheritedStyleData, mUIData),
PR_FALSE
},
/* eStyleStruct_UIReset */
{ offsetof(nsCachedStyleData, mResetData),
offsetof(nsResetStyleData, mUIData),
PR_TRUE
},
/* eStyleStruct_Table */
{ offsetof(nsCachedStyleData, mResetData),
offsetof(nsResetStyleData, mTableData),
PR_TRUE
},
/* eStyleStruct_TableBorder */
{ offsetof(nsCachedStyleData, mInheritedData),
offsetof(nsInheritedStyleData, mTableData),
PR_FALSE
},
/* eStyleStruct_Margin */
{ offsetof(nsCachedStyleData, mResetData),
offsetof(nsResetStyleData, mMarginData),
PR_TRUE
},
/* eStyleStruct_Padding */
{ offsetof(nsCachedStyleData, mResetData),
offsetof(nsResetStyleData, mPaddingData),
PR_TRUE
},
/* eStyleStruct_Border */
{ offsetof(nsCachedStyleData, mResetData),
offsetof(nsResetStyleData, mBorderData),
PR_TRUE
},
/* eStyleStruct_Outline */
{ offsetof(nsCachedStyleData, mResetData),
offsetof(nsResetStyleData, mOutlineData),
PR_TRUE
},
#ifdef INCLUDE_XUL
/* eStyleStruct_XUL */
{ offsetof(nsCachedStyleData, mResetData),
offsetof(nsResetStyleData, mXULData),
PR_TRUE
},
#endif
{ 0, 0, 0 }
};
static NS_DEFINE_CID(kPrefCID, NS_PREF_CID);
#define POSITIVE_SCALE_FACTOR 1.10 /* 10% */