To make maintainance easier and allow more data-as-data rather than data-as-code, create a preprocessable list of style structs and use it in many places where we previously listed all (or half) of the style structs. b=155745 r=bzbarsky sr=waterson

This commit is contained in:
dbaron%fas.harvard.edu 2002-07-09 04:10:10 +00:00
parent e479db29d7
commit 27b9d4524f
19 changed files with 688 additions and 2191 deletions

View File

@ -696,11 +696,6 @@ struct StructCheckData {
CheckCallbackFn callback;
};
#define CHECKDATA_STRUCT(_props) \
{_props, sizeof(_props)/sizeof(PropertyCheckData), nsnull}
#define CHECKDATA_STRUCT_WITH_CALLBACK(_props, _cb) \
{_props, sizeof(_props)/sizeof(PropertyCheckData), _cb}
static void
ExamineRectProperties(const nsCSSRect* aRect,
PRUint32& aSpecifiedCount, PRUint32& aInheritedCount)
@ -975,36 +970,16 @@ static const PropertyCheckData SVGCheckProperties[] = {
};
#endif
// These are indexed by style struct ID and must stay in order!
static const StructCheckData gCheckProperties[] = {
{ nsnull, 0, nsnull}, /* empty, since no 0th SID */
CHECKDATA_STRUCT_WITH_CALLBACK(FontCheckProperties, CheckFontCallback),
CHECKDATA_STRUCT(ColorCheckProperties),
CHECKDATA_STRUCT(BackgroundCheckProperties),
CHECKDATA_STRUCT(ListCheckProperties),
CHECKDATA_STRUCT(PositionCheckProperties),
CHECKDATA_STRUCT(TextCheckProperties),
CHECKDATA_STRUCT(TextResetCheckProperties),
CHECKDATA_STRUCT(DisplayCheckProperties),
CHECKDATA_STRUCT(VisibilityCheckProperties),
CHECKDATA_STRUCT(ContentCheckProperties),
CHECKDATA_STRUCT(QuotesCheckProperties),
CHECKDATA_STRUCT(UserInterfaceCheckProperties),
CHECKDATA_STRUCT(UIResetCheckProperties),
CHECKDATA_STRUCT(TableCheckProperties),
CHECKDATA_STRUCT(TableBorderCheckProperties),
CHECKDATA_STRUCT(MarginCheckProperties),
CHECKDATA_STRUCT(PaddingCheckProperties),
CHECKDATA_STRUCT(BorderCheckProperties),
CHECKDATA_STRUCT(OutlineCheckProperties),
#ifdef INCLUDE_XUL
CHECKDATA_STRUCT(XULCheckProperties),
#endif
#ifdef MOZ_SVG
CHECKDATA_STRUCT(SVGCheckProperties),
#endif
{ nsnull, 0, nsnull} /* empty, so at least we crash reliably if someone
passes in the BorderPaddingShortcut ID */
#define STYLE_STRUCT(name, checkdata_cb) \
{name##CheckProperties, \
sizeof(name##CheckProperties)/sizeof(PropertyCheckData), \
checkdata_cb},
#include "nsStyleStructList.h"
#undef STYLE_STRUCT
{nsnull, 0, nsnull}
};
@ -1252,7 +1227,7 @@ nsRuleNode::GetTextResetData(nsIStyleContext* aContext, PRBool aComputeData)
}
const nsStyleStruct*
nsRuleNode::GetUIData(nsIStyleContext* aContext, PRBool aComputeData)
nsRuleNode::GetUserInterfaceData(nsIStyleContext* aContext, PRBool aComputeData)
{
nsCSSUserInterface uiData; // Declare a struct with null CSS values.
nsRuleData ruleData(eStyleStruct_UserInterface, mPresContext, aContext);
@ -1600,8 +1575,8 @@ nsRuleNode::WalkRuleTree(const nsStyleStructID aSID,
// it never has to go back to the rule tree for data. Instead the style context tree
// should be walked to find the data.
const nsStyleStruct* parentStruct = parentContext->GetStyleData(aSID);
aContext->AddStyleBit(bit);
aContext->SetStyle(aSID, *parentStruct);
aContext->AddStyleBit(bit); // makes const_cast OK.
aContext->SetStyle(aSID, NS_CONST_CAST(nsStyleStruct*, parentStruct));
return parentStruct;
}
else
@ -1647,115 +1622,115 @@ nsRuleNode::SetDefaultOnRoot(const nsStyleStructID aSID, nsIStyleContext* aConte
nsStyleFont* fontData = new (mPresContext) nsStyleFont(*defaultFont);
fontData->mSize = fontData->mFont.size =
ZoomFont(mPresContext, fontData->mFont.size);
aContext->SetStyle(eStyleStruct_Font, *fontData);
aContext->SetStyle(eStyleStruct_Font, fontData);
return fontData;
}
case eStyleStruct_Display:
{
nsStyleDisplay* disp = new (mPresContext) nsStyleDisplay();
aContext->SetStyle(eStyleStruct_Display, *disp);
aContext->SetStyle(eStyleStruct_Display, disp);
return disp;
}
case eStyleStruct_Visibility:
{
nsStyleVisibility* vis = new (mPresContext) nsStyleVisibility(mPresContext);
aContext->SetStyle(eStyleStruct_Visibility, *vis);
aContext->SetStyle(eStyleStruct_Visibility, vis);
return vis;
}
case eStyleStruct_Text:
{
nsStyleText* text = new (mPresContext) nsStyleText();
aContext->SetStyle(eStyleStruct_Text, *text);
aContext->SetStyle(eStyleStruct_Text, text);
return text;
}
case eStyleStruct_TextReset:
{
nsStyleTextReset* text = new (mPresContext) nsStyleTextReset();
aContext->SetStyle(eStyleStruct_TextReset, *text);
aContext->SetStyle(eStyleStruct_TextReset, text);
return text;
}
case eStyleStruct_Color:
{
nsStyleColor* color = new (mPresContext) nsStyleColor(mPresContext);
aContext->SetStyle(eStyleStruct_Color, *color);
aContext->SetStyle(eStyleStruct_Color, color);
return color;
}
case eStyleStruct_Background:
{
nsStyleBackground* bg = new (mPresContext) nsStyleBackground(mPresContext);
aContext->SetStyle(eStyleStruct_Background, *bg);
aContext->SetStyle(eStyleStruct_Background, bg);
return bg;
}
case eStyleStruct_Margin:
{
nsStyleMargin* margin = new (mPresContext) nsStyleMargin();
aContext->SetStyle(eStyleStruct_Margin, *margin);
aContext->SetStyle(eStyleStruct_Margin, margin);
return margin;
}
case eStyleStruct_Border:
{
nsStyleBorder* border = new (mPresContext) nsStyleBorder(mPresContext);
aContext->SetStyle(eStyleStruct_Border, *border);
aContext->SetStyle(eStyleStruct_Border, border);
return border;
}
case eStyleStruct_Padding:
{
nsStylePadding* padding = new (mPresContext) nsStylePadding();
aContext->SetStyle(eStyleStruct_Padding, *padding);
aContext->SetStyle(eStyleStruct_Padding, padding);
return padding;
}
case eStyleStruct_Outline:
{
nsStyleOutline* outline = new (mPresContext) nsStyleOutline(mPresContext);
aContext->SetStyle(eStyleStruct_Outline, *outline);
aContext->SetStyle(eStyleStruct_Outline, outline);
return outline;
}
case eStyleStruct_List:
{
nsStyleList* list = new (mPresContext) nsStyleList();
aContext->SetStyle(eStyleStruct_List, *list);
aContext->SetStyle(eStyleStruct_List, list);
return list;
}
case eStyleStruct_Position:
{
nsStylePosition* pos = new (mPresContext) nsStylePosition();
aContext->SetStyle(eStyleStruct_Position, *pos);
aContext->SetStyle(eStyleStruct_Position, pos);
return pos;
}
case eStyleStruct_Table:
{
nsStyleTable* table = new (mPresContext) nsStyleTable();
aContext->SetStyle(eStyleStruct_Table, *table);
aContext->SetStyle(eStyleStruct_Table, table);
return table;
}
case eStyleStruct_TableBorder:
{
nsStyleTableBorder* table = new (mPresContext) nsStyleTableBorder(mPresContext);
aContext->SetStyle(eStyleStruct_TableBorder, *table);
aContext->SetStyle(eStyleStruct_TableBorder, table);
return table;
}
case eStyleStruct_Content:
{
nsStyleContent* content = new (mPresContext) nsStyleContent();
aContext->SetStyle(eStyleStruct_Content, *content);
aContext->SetStyle(eStyleStruct_Content, content);
return content;
}
case eStyleStruct_Quotes:
{
nsStyleQuotes* quotes = new (mPresContext) nsStyleQuotes();
aContext->SetStyle(eStyleStruct_Quotes, *quotes);
aContext->SetStyle(eStyleStruct_Quotes, quotes);
return quotes;
}
case eStyleStruct_UserInterface:
{
nsStyleUserInterface* ui = new (mPresContext) nsStyleUserInterface();
aContext->SetStyle(eStyleStruct_UserInterface, *ui);
aContext->SetStyle(eStyleStruct_UserInterface, ui);
return ui;
}
case eStyleStruct_UIReset:
{
nsStyleUIReset* ui = new (mPresContext) nsStyleUIReset();
aContext->SetStyle(eStyleStruct_UIReset, *ui);
aContext->SetStyle(eStyleStruct_UIReset, ui);
return ui;
}
@ -1763,7 +1738,7 @@ nsRuleNode::SetDefaultOnRoot(const nsStyleStructID aSID, nsIStyleContext* aConte
case eStyleStruct_XUL:
{
nsStyleXUL* xul = new (mPresContext) nsStyleXUL();
aContext->SetStyle(eStyleStruct_XUL, *xul);
aContext->SetStyle(eStyleStruct_XUL, xul);
return xul;
}
#endif
@ -1772,47 +1747,22 @@ nsRuleNode::SetDefaultOnRoot(const nsStyleStructID aSID, nsIStyleContext* aConte
case eStyleStruct_SVG:
{
nsStyleSVG* svg = new (mPresContext) nsStyleSVG();
aContext->SetStyle(eStyleStruct_SVG, *svg);
aContext->SetStyle(eStyleStruct_SVG, svg);
return svg;
}
#endif
case eStyleStruct_BorderPaddingShortcut:
NS_ERROR("unexpected SID");
}
return nsnull;
}
nsRuleNode::ComputeStyleDataFn
nsRuleNode::gComputeStyleDataFn[] = {
// Note that these must line up _exactly_ with the numeric values of
// the nsStyleStructID enum.
nsnull,
&nsRuleNode::ComputeFontData,
&nsRuleNode::ComputeColorData,
&nsRuleNode::ComputeBackgroundData,
&nsRuleNode::ComputeListData,
&nsRuleNode::ComputePositionData,
&nsRuleNode::ComputeTextData,
&nsRuleNode::ComputeTextResetData,
&nsRuleNode::ComputeDisplayData,
&nsRuleNode::ComputeVisibilityData,
&nsRuleNode::ComputeContentData,
&nsRuleNode::ComputeQuotesData,
&nsRuleNode::ComputeUIData,
&nsRuleNode::ComputeUIResetData,
&nsRuleNode::ComputeTableData,
&nsRuleNode::ComputeTableBorderData,
&nsRuleNode::ComputeMarginData,
&nsRuleNode::ComputePaddingData,
&nsRuleNode::ComputeBorderData,
&nsRuleNode::ComputeOutlineData,
#ifdef INCLUDE_XUL
&nsRuleNode::ComputeXULData,
#endif
#ifdef MOZ_SVG
&nsRuleNode::ComputeSVGData,
#endif
#define STYLE_STRUCT(name, checkdata_cb) \
&nsRuleNode::Compute##name##Data,
#include "nsStyleStructList.h"
#undef STYLE_STRUCT
nsnull
};
@ -2291,14 +2241,14 @@ nsRuleNode::ComputeFontData(nsStyleStruct* aStartStruct, const nsCSSStruct& aDat
if (inherited)
// We inherited, and therefore can't be cached in the rule node. We have to be put right on the
// style context.
aContext->SetStyle(eStyleStruct_Font, *font);
aContext->SetStyle(eStyleStruct_Font, font);
else {
// We were fully specified and can therefore be cached right on the rule node.
if (!aHighestNode->mStyleData.mInheritedData)
aHighestNode->mStyleData.mInheritedData = new (mPresContext) nsInheritedStyleData;
aHighestNode->mStyleData.mInheritedData->mFontData = font;
// Propagate the bit down.
PropagateDependentBit(NS_STYLE_INHERIT_FONT, aHighestNode);
PropagateDependentBit(NS_STYLE_INHERIT_BIT(Font), aHighestNode);
}
return font;
@ -2411,14 +2361,14 @@ nsRuleNode::ComputeTextData(nsStyleStruct* aStartStruct, const nsCSSStruct& aDat
if (inherited)
// We inherited, and therefore can't be cached in the rule node. We have to be put right on the
// style context.
aContext->SetStyle(eStyleStruct_Text, *text);
aContext->SetStyle(eStyleStruct_Text, text);
else {
// We were fully specified and can therefore be cached right on the rule node.
if (!aHighestNode->mStyleData.mInheritedData)
aHighestNode->mStyleData.mInheritedData = new (mPresContext) nsInheritedStyleData;
aHighestNode->mStyleData.mInheritedData->mTextData = text;
// Propagate the bit down.
PropagateDependentBit(NS_STYLE_INHERIT_TEXT, aHighestNode);
PropagateDependentBit(NS_STYLE_INHERIT_BIT(Text), aHighestNode);
}
return text;
@ -2483,24 +2433,26 @@ nsRuleNode::ComputeTextResetData(nsStyleStruct* aStartData, const nsCSSStruct& a
if (inherited)
// We inherited, and therefore can't be cached in the rule node. We have to be put right on the
// style context.
aContext->SetStyle(eStyleStruct_TextReset, *text);
aContext->SetStyle(eStyleStruct_TextReset, text);
else {
// We were fully specified and can therefore be cached right on the rule node.
if (!aHighestNode->mStyleData.mResetData)
aHighestNode->mStyleData.mResetData = new (mPresContext) nsResetStyleData;
aHighestNode->mStyleData.mResetData->mTextData = text;
aHighestNode->mStyleData.mResetData->mTextResetData = text;
// Propagate the bit down.
PropagateDependentBit(NS_STYLE_INHERIT_TEXT_RESET, aHighestNode);
PropagateDependentBit(NS_STYLE_INHERIT_BIT(TextReset), aHighestNode);
}
return text;
}
const nsStyleStruct*
nsRuleNode::ComputeUIData(nsStyleStruct* aStartData, const nsCSSStruct& aData,
nsIStyleContext* aContext,
nsRuleNode* aHighestNode,
const RuleDetail& aRuleDetail, PRBool aInherited)
nsRuleNode::ComputeUserInterfaceData(nsStyleStruct* aStartData,
const nsCSSStruct& aData,
nsIStyleContext* aContext,
nsRuleNode* aHighestNode,
const RuleDetail& aRuleDetail,
PRBool aInherited)
{
nsCOMPtr<nsIStyleContext> parentContext = getter_AddRefs(aContext->GetParent());
@ -2593,14 +2545,14 @@ nsRuleNode::ComputeUIData(nsStyleStruct* aStartData, const nsCSSStruct& aData,
if (inherited)
// We inherited, and therefore can't be cached in the rule node. We have to be put right on the
// style context.
aContext->SetStyle(eStyleStruct_UserInterface, *ui);
aContext->SetStyle(eStyleStruct_UserInterface, ui);
else {
// We were fully specified and can therefore be cached right on the rule node.
if (!aHighestNode->mStyleData.mInheritedData)
aHighestNode->mStyleData.mInheritedData = new (mPresContext) nsInheritedStyleData;
aHighestNode->mStyleData.mInheritedData->mUIData = ui;
aHighestNode->mStyleData.mInheritedData->mUserInterfaceData = ui;
// Propagate the bit down.
PropagateDependentBit(NS_STYLE_INHERIT_UI, aHighestNode);
PropagateDependentBit(NS_STYLE_INHERIT_BIT(UserInterface), aHighestNode);
}
return ui;
@ -2682,14 +2634,14 @@ nsRuleNode::ComputeUIResetData(nsStyleStruct* aStartData, const nsCSSStruct& aDa
if (inherited)
// We inherited, and therefore can't be cached in the rule node. We have to be put right on the
// style context.
aContext->SetStyle(eStyleStruct_UIReset, *ui);
aContext->SetStyle(eStyleStruct_UIReset, ui);
else {
// We were fully specified and can therefore be cached right on the rule node.
if (!aHighestNode->mStyleData.mResetData)
aHighestNode->mStyleData.mResetData = new (mPresContext) nsResetStyleData;
aHighestNode->mStyleData.mResetData->mUIData = ui;
aHighestNode->mStyleData.mResetData->mUIResetData = ui;
// Propagate the bit down.
PropagateDependentBit(NS_STYLE_INHERIT_UI_RESET, aHighestNode);
PropagateDependentBit(NS_STYLE_INHERIT_BIT(UIReset), aHighestNode);
}
return ui;
@ -2878,14 +2830,14 @@ nsRuleNode::ComputeDisplayData(nsStyleStruct* aStartStruct, const nsCSSStruct& a
if (inherited)
// We inherited, and therefore can't be cached in the rule node. We have to be put right on the
// style context.
aContext->SetStyle(eStyleStruct_Display, *display);
aContext->SetStyle(eStyleStruct_Display, display);
else {
// We were fully specified and can therefore be cached right on the rule node.
if (!aHighestNode->mStyleData.mResetData)
aHighestNode->mStyleData.mResetData = new (mPresContext) nsResetStyleData;
aHighestNode->mStyleData.mResetData->mDisplayData = display;
// Propagate the bit down.
PropagateDependentBit(NS_STYLE_INHERIT_DISPLAY, aHighestNode);
PropagateDependentBit(NS_STYLE_INHERIT_BIT(Display), aHighestNode);
}
// CSS2 specified fixups:
@ -3030,14 +2982,14 @@ nsRuleNode::ComputeVisibilityData(nsStyleStruct* aStartStruct, const nsCSSStruct
if (inherited)
// We inherited, and therefore can't be cached in the rule node. We have to be put right on the
// style context.
aContext->SetStyle(eStyleStruct_Visibility, *visibility);
aContext->SetStyle(eStyleStruct_Visibility, visibility);
else {
// We were fully specified and can therefore be cached right on the rule node.
if (!aHighestNode->mStyleData.mInheritedData)
aHighestNode->mStyleData.mInheritedData = new (mPresContext) nsInheritedStyleData;
aHighestNode->mStyleData.mInheritedData->mVisibilityData = visibility;
// Propagate the bit down.
PropagateDependentBit(NS_STYLE_INHERIT_VISIBILITY, aHighestNode);
PropagateDependentBit(NS_STYLE_INHERIT_BIT(Visibility), aHighestNode);
}
return visibility;
@ -3086,14 +3038,14 @@ nsRuleNode::ComputeColorData(nsStyleStruct* aStartStruct, const nsCSSStruct& aDa
if (inherited)
// We inherited, and therefore can't be cached in the rule node. We have to be put right on the
// style context.
aContext->SetStyle(eStyleStruct_Color, *color);
aContext->SetStyle(eStyleStruct_Color, color);
else {
// We were fully specified and can therefore be cached right on the rule node.
if (!aHighestNode->mStyleData.mInheritedData)
aHighestNode->mStyleData.mInheritedData = new (mPresContext) nsInheritedStyleData;
aHighestNode->mStyleData.mInheritedData->mColorData = color;
// Propagate the bit down.
PropagateDependentBit(NS_STYLE_INHERIT_COLOR, aHighestNode);
PropagateDependentBit(NS_STYLE_INHERIT_BIT(Color), aHighestNode);
}
return color;
@ -3227,14 +3179,14 @@ nsRuleNode::ComputeBackgroundData(nsStyleStruct* aStartStruct, const nsCSSStruct
if (inherited)
// We inherited, and therefore can't be cached in the rule node. We have to be put right on the
// style context.
aContext->SetStyle(eStyleStruct_Background, *bg);
aContext->SetStyle(eStyleStruct_Background, bg);
else {
// We were fully specified and can therefore be cached right on the rule node.
if (!aHighestNode->mStyleData.mResetData)
aHighestNode->mStyleData.mResetData = new (mPresContext) nsResetStyleData;
aHighestNode->mStyleData.mResetData->mBackgroundData = bg;
// Propagate the bit down.
PropagateDependentBit(NS_STYLE_INHERIT_BACKGROUND, aHighestNode);
PropagateDependentBit(NS_STYLE_INHERIT_BIT(Background), aHighestNode);
}
return bg;
@ -3291,14 +3243,14 @@ nsRuleNode::ComputeMarginData(nsStyleStruct* aStartStruct, const nsCSSStruct& aD
if (inherited)
// We inherited, and therefore can't be cached in the rule node. We have to be put right on the
// style context.
aContext->SetStyle(eStyleStruct_Margin, *margin);
aContext->SetStyle(eStyleStruct_Margin, margin);
else {
// We were fully specified and can therefore be cached right on the rule node.
if (!aHighestNode->mStyleData.mResetData)
aHighestNode->mStyleData.mResetData = new (mPresContext) nsResetStyleData;
aHighestNode->mStyleData.mResetData->mMarginData = margin;
// Propagate the bit down.
PropagateDependentBit(NS_STYLE_INHERIT_MARGIN, aHighestNode);
PropagateDependentBit(NS_STYLE_INHERIT_BIT(Margin), aHighestNode);
}
margin->RecalcData();
@ -3571,14 +3523,14 @@ nsRuleNode::ComputeBorderData(nsStyleStruct* aStartStruct, const nsCSSStruct& aD
if (inherited)
// We inherited, and therefore can't be cached in the rule node. We have to be put right on the
// style context.
aContext->SetStyle(eStyleStruct_Border, *border);
aContext->SetStyle(eStyleStruct_Border, border);
else {
// We were fully specified and can therefore be cached right on the rule node.
if (!aHighestNode->mStyleData.mResetData)
aHighestNode->mStyleData.mResetData = new (mPresContext) nsResetStyleData;
aHighestNode->mStyleData.mResetData->mBorderData = border;
// Propagate the bit down.
PropagateDependentBit(NS_STYLE_INHERIT_BORDER, aHighestNode);
PropagateDependentBit(NS_STYLE_INHERIT_BIT(Border), aHighestNode);
}
border->RecalcData();
@ -3636,14 +3588,14 @@ nsRuleNode::ComputePaddingData(nsStyleStruct* aStartStruct, const nsCSSStruct& a
if (inherited)
// We inherited, and therefore can't be cached in the rule node. We have to be put right on the
// style context.
aContext->SetStyle(eStyleStruct_Padding, *padding);
aContext->SetStyle(eStyleStruct_Padding, padding);
else {
// We were fully specified and can therefore be cached right on the rule node.
if (!aHighestNode->mStyleData.mResetData)
aHighestNode->mStyleData.mResetData = new (mPresContext) nsResetStyleData;
aHighestNode->mStyleData.mResetData->mPaddingData = padding;
// Propagate the bit down.
PropagateDependentBit(NS_STYLE_INHERIT_PADDING, aHighestNode);
PropagateDependentBit(NS_STYLE_INHERIT_BIT(Padding), aHighestNode);
}
padding->RecalcData();
@ -3708,14 +3660,14 @@ nsRuleNode::ComputeOutlineData(nsStyleStruct* aStartStruct, const nsCSSStruct& a
if (inherited)
// We inherited, and therefore can't be cached in the rule node. We have to be put right on the
// style context.
aContext->SetStyle(eStyleStruct_Outline, *outline);
aContext->SetStyle(eStyleStruct_Outline, outline);
else {
// We were fully specified and can therefore be cached right on the rule node.
if (!aHighestNode->mStyleData.mResetData)
aHighestNode->mStyleData.mResetData = new (mPresContext) nsResetStyleData;
aHighestNode->mStyleData.mResetData->mOutlineData = outline;
// Propagate the bit down.
PropagateDependentBit(NS_STYLE_INHERIT_OUTLINE, aHighestNode);
PropagateDependentBit(NS_STYLE_INHERIT_BIT(Outline), aHighestNode);
}
outline->RecalcData();
@ -3825,14 +3777,14 @@ nsRuleNode::ComputeListData(nsStyleStruct* aStartStruct, const nsCSSStruct& aDat
if (inherited)
// We inherited, and therefore can't be cached in the rule node. We have to be put right on the
// style context.
aContext->SetStyle(eStyleStruct_List, *list);
aContext->SetStyle(eStyleStruct_List, list);
else {
// We were fully specified and can therefore be cached right on the rule node.
if (!aHighestNode->mStyleData.mInheritedData)
aHighestNode->mStyleData.mInheritedData = new (mPresContext) nsInheritedStyleData;
aHighestNode->mStyleData.mInheritedData->mListData = list;
// Propagate the bit down.
PropagateDependentBit(NS_STYLE_INHERIT_LIST, aHighestNode);
PropagateDependentBit(NS_STYLE_INHERIT_BIT(List), aHighestNode);
}
return list;
@ -3933,14 +3885,14 @@ nsRuleNode::ComputePositionData(nsStyleStruct* aStartStruct, const nsCSSStruct&
if (inherited)
// We inherited, and therefore can't be cached in the rule node. We have to be put right on the
// style context.
aContext->SetStyle(eStyleStruct_Position, *pos);
aContext->SetStyle(eStyleStruct_Position, pos);
else {
// We were fully specified and can therefore be cached right on the rule node.
if (!aHighestNode->mStyleData.mResetData)
aHighestNode->mStyleData.mResetData = new (mPresContext) nsResetStyleData;
aHighestNode->mStyleData.mResetData->mPositionData = pos;
// Propagate the bit down.
PropagateDependentBit(NS_STYLE_INHERIT_POSITION, aHighestNode);
PropagateDependentBit(NS_STYLE_INHERIT_BIT(Position), aHighestNode);
}
return pos;
@ -4003,14 +3955,14 @@ nsRuleNode::ComputeTableData(nsStyleStruct* aStartStruct, const nsCSSStruct& aDa
if (inherited)
// We inherited, and therefore can't be cached in the rule node. We have to be put right on the
// style context.
aContext->SetStyle(eStyleStruct_Table, *table);
aContext->SetStyle(eStyleStruct_Table, table);
else {
// We were fully specified and can therefore be cached right on the rule node.
if (!aHighestNode->mStyleData.mResetData)
aHighestNode->mStyleData.mResetData = new (mPresContext) nsResetStyleData;
aHighestNode->mStyleData.mResetData->mTableData = table;
// Propagate the bit down.
PropagateDependentBit(NS_STYLE_INHERIT_TABLE, aHighestNode);
PropagateDependentBit(NS_STYLE_INHERIT_BIT(Table), aHighestNode);
}
return table;
@ -4101,14 +4053,14 @@ nsRuleNode::ComputeTableBorderData(nsStyleStruct* aStartStruct, const nsCSSStruc
if (inherited)
// We inherited, and therefore can't be cached in the rule node. We have to be put right on the
// style context.
aContext->SetStyle(eStyleStruct_TableBorder, *table);
aContext->SetStyle(eStyleStruct_TableBorder, table);
else {
// We were fully specified and can therefore be cached right on the rule node.
if (!aHighestNode->mStyleData.mInheritedData)
aHighestNode->mStyleData.mInheritedData = new (mPresContext) nsInheritedStyleData;
aHighestNode->mStyleData.mInheritedData->mTableData = table;
aHighestNode->mStyleData.mInheritedData->mTableBorderData = table;
// Propagate the bit down.
PropagateDependentBit(NS_STYLE_INHERIT_TABLE_BORDER, aHighestNode);
PropagateDependentBit(NS_STYLE_INHERIT_BIT(TableBorder), aHighestNode);
}
return table;
@ -4296,14 +4248,14 @@ nsRuleNode::ComputeContentData(nsStyleStruct* aStartStruct, const nsCSSStruct& a
if (inherited)
// We inherited, and therefore can't be cached in the rule node. We have to be put right on the
// style context.
aContext->SetStyle(eStyleStruct_Content, *content);
aContext->SetStyle(eStyleStruct_Content, content);
else {
// We were fully specified and can therefore be cached right on the rule node.
if (!aHighestNode->mStyleData.mResetData)
aHighestNode->mStyleData.mResetData = new (mPresContext) nsResetStyleData;
aHighestNode->mStyleData.mResetData->mContentData = content;
// Propagate the bit down.
PropagateDependentBit(NS_STYLE_INHERIT_CONTENT, aHighestNode);
PropagateDependentBit(NS_STYLE_INHERIT_BIT(Content), aHighestNode);
}
return content;
@ -4388,14 +4340,14 @@ nsRuleNode::ComputeQuotesData(nsStyleStruct* aStartStruct, const nsCSSStruct& aD
if (inherited)
// We inherited, and therefore can't be cached in the rule node. We have to be put right on the
// style context.
aContext->SetStyle(eStyleStruct_Quotes, *quotes);
aContext->SetStyle(eStyleStruct_Quotes, quotes);
else {
// We were fully specified and can therefore be cached right on the rule node.
if (!aHighestNode->mStyleData.mInheritedData)
aHighestNode->mStyleData.mInheritedData = new (mPresContext) nsInheritedStyleData;
aHighestNode->mStyleData.mInheritedData->mQuotesData = quotes;
// Propagate the bit down.
PropagateDependentBit(NS_STYLE_INHERIT_QUOTES, aHighestNode);
PropagateDependentBit(NS_STYLE_INHERIT_BIT(Quotes), aHighestNode);
}
return quotes;
@ -4483,14 +4435,14 @@ nsRuleNode::ComputeXULData(nsStyleStruct* aStartStruct, const nsCSSStruct& aData
if (inherited)
// We inherited, and therefore can't be cached in the rule node. We have to be put right on the
// style context.
aContext->SetStyle(eStyleStruct_XUL, *xul);
aContext->SetStyle(eStyleStruct_XUL, xul);
else {
// We were fully specified and can therefore be cached right on the rule node.
if (!aHighestNode->mStyleData.mResetData)
aHighestNode->mStyleData.mResetData = new (mPresContext) nsResetStyleData;
aHighestNode->mStyleData.mResetData->mXULData = xul;
// Propagate the bit down.
PropagateDependentBit(NS_STYLE_INHERIT_XUL, aHighestNode);
PropagateDependentBit(NS_STYLE_INHERIT_BIT(XUL), aHighestNode);
}
return xul;
@ -4657,14 +4609,14 @@ nsRuleNode::ComputeSVGData(nsStyleStruct* aStartStruct, const nsCSSStruct& aData
if (inherited)
// We inherited, and therefore can't be cached in the rule node. We have to be put right on the
// style context.
aContext->SetStyle(eStyleStruct_SVG, *svg);
aContext->SetStyle(eStyleStruct_SVG, svg);
else {
// We were fully specified and can therefore be cached right on the rule node.
if (!aHighestNode->mStyleData.mInheritedData)
aHighestNode->mStyleData.mInheritedData = new (mPresContext) nsInheritedStyleData;
aHighestNode->mStyleData.mInheritedData->mSVGData = svg;
// Propagate the bit down.
PropagateDependentBit(NS_STYLE_INHERIT_SVG, aHighestNode);
PropagateDependentBit(NS_STYLE_INHERIT_BIT(SVG), aHighestNode);
}
return svg;
@ -4690,34 +4642,11 @@ nsRuleNode::GetParentData(const nsStyleStructID aSID)
nsRuleNode::GetStyleDataFn
nsRuleNode::gGetStyleDataFn[] = {
// Note that these must line up _exactly_ with the numeric values of
// the nsStyleStructID enum.
nsnull,
&nsRuleNode::GetFontData,
&nsRuleNode::GetColorData,
&nsRuleNode::GetBackgroundData,
&nsRuleNode::GetListData,
&nsRuleNode::GetPositionData,
&nsRuleNode::GetTextData,
&nsRuleNode::GetTextResetData,
&nsRuleNode::GetDisplayData,
&nsRuleNode::GetVisibilityData,
&nsRuleNode::GetContentData,
&nsRuleNode::GetQuotesData,
&nsRuleNode::GetUIData,
&nsRuleNode::GetUIResetData,
&nsRuleNode::GetTableData,
&nsRuleNode::GetTableBorderData,
&nsRuleNode::GetMarginData,
&nsRuleNode::GetPaddingData,
&nsRuleNode::GetBorderData,
&nsRuleNode::GetOutlineData,
#ifdef INCLUDE_XUL
&nsRuleNode::GetXULData,
#endif
#ifdef MOZ_SVG
&nsRuleNode::GetSVGData,
#endif
#define STYLE_STRUCT(name, checkdata_cb) &nsRuleNode::Get##name##Data,
#include "nsStyleStructList.h"
#undef STYLE_STRUCT
nsnull
};

View File

@ -87,7 +87,7 @@ public:
NS_IMETHOD GetBorderPaddingFor(nsStyleBorderPadding& aBorderPadding);
NS_IMETHOD GetStyle(nsStyleStructID aSID, const nsStyleStruct** aStruct);
NS_IMETHOD SetStyle(nsStyleStructID aSID, const nsStyleStruct& aStruct);
NS_IMETHOD SetStyle(nsStyleStructID aSID, nsStyleStruct* aStruct);
NS_IMETHOD GetRuleNode(nsRuleNode** aResult) { *aResult = mRuleNode; return NS_OK; };
NS_IMETHOD AddStyleBit(const PRUint32& aBit) { mBits |= aBit; return NS_OK; };
@ -162,6 +162,10 @@ nsStyleContext::nsStyleContext(nsIStyleContext* aParent,
}
ApplyStyleFixups(aPresContext);
NS_ASSERTION(NS_STYLE_INHERIT_MASK &
(1 << PRInt32(nsStyleStructID_Length - 1)) != 0,
"NS_STYLE_INHERIT_MASK must be bigger, and other bits shifted");
}
nsStyleContext::~nsStyleContext()
@ -382,33 +386,33 @@ nsStyleContext::GetUniqueStyleData(nsIPresContext* aPresContext, const nsStyleSt
case eStyleStruct_Display: {
const nsStyleDisplay* dis = (const nsStyleDisplay*)GetStyleData(aSID);
nsStyleDisplay* newDis = new (aPresContext) nsStyleDisplay(*dis);
SetStyle(aSID, *newDis);
SetStyle(aSID, newDis);
result = newDis;
mBits &= ~NS_STYLE_INHERIT_DISPLAY;
mBits &= ~NS_STYLE_INHERIT_BIT(Display);
break;
}
case eStyleStruct_Background: {
const nsStyleBackground* bg = (const nsStyleBackground*)GetStyleData(aSID);
nsStyleBackground* newBG = new (aPresContext) nsStyleBackground(*bg);
SetStyle(aSID, *newBG);
SetStyle(aSID, newBG);
result = newBG;
mBits &= ~NS_STYLE_INHERIT_BACKGROUND;
mBits &= ~NS_STYLE_INHERIT_BIT(Background);
break;
}
case eStyleStruct_Text: {
const nsStyleText* text = (const nsStyleText*)GetStyleData(aSID);
nsStyleText* newText = new (aPresContext) nsStyleText(*text);
SetStyle(aSID, *newText);
SetStyle(aSID, newText);
result = newText;
mBits &= ~NS_STYLE_INHERIT_TEXT;
mBits &= ~NS_STYLE_INHERIT_BIT(Text);
break;
}
case eStyleStruct_TextReset: {
const nsStyleTextReset* reset = (const nsStyleTextReset*)GetStyleData(aSID);
nsStyleTextReset* newReset = new (aPresContext) nsStyleTextReset(*reset);
SetStyle(aSID, *newReset);
SetStyle(aSID, newReset);
result = newReset;
mBits &= ~NS_STYLE_INHERIT_TEXT_RESET;
mBits &= ~NS_STYLE_INHERIT_BIT(TextReset);
break;
}
default:
@ -426,101 +430,37 @@ nsStyleContext::GetStyle(nsStyleStructID aSID, const nsStyleStruct** aStruct)
}
NS_IMETHODIMP
nsStyleContext::SetStyle(nsStyleStructID aSID, const nsStyleStruct& aStruct)
nsStyleContext::SetStyle(nsStyleStructID aSID, nsStyleStruct* aStruct)
{
// This method should only be called from nsRuleNode! It is not a public
// method!
nsresult result = NS_OK;
PRBool isReset = mCachedStyleData.IsReset(aSID);
if (isReset) {
if (!mCachedStyleData.mResetData) {
nsCOMPtr<nsIPresContext> presContext;
mRuleNode->GetPresContext(getter_AddRefs(presContext));
mCachedStyleData.mResetData = new (presContext.get()) nsResetStyleData;
}
} else {
if (!mCachedStyleData.mInheritedData) {
nsCOMPtr<nsIPresContext> presContext;
mRuleNode->GetPresContext(getter_AddRefs(presContext));
mCachedStyleData.mInheritedData = new (presContext.get()) nsInheritedStyleData;
}
}
NS_ASSERTION(aSID >= 0 && aSID < nsStyleStructID_Length, "out of bounds");
switch (aSID) {
case eStyleStruct_Font:
mCachedStyleData.mInheritedData->mFontData = (nsStyleFont*)(const nsStyleFont*)(&aStruct);
break;
case eStyleStruct_Color:
mCachedStyleData.mInheritedData->mColorData = (nsStyleColor*)(const nsStyleColor*)(&aStruct);
break;
case eStyleStruct_Background:
mCachedStyleData.mResetData->mBackgroundData = (nsStyleBackground*)(const nsStyleBackground*)(&aStruct);
break;
case eStyleStruct_List:
mCachedStyleData.mInheritedData->mListData = (nsStyleList*)(const nsStyleList*)(&aStruct);
break;
case eStyleStruct_Position:
mCachedStyleData.mResetData->mPositionData = (nsStylePosition*)(const nsStylePosition*)(&aStruct);
break;
case eStyleStruct_Text:
mCachedStyleData.mInheritedData->mTextData = (nsStyleText*)(const nsStyleText*)(&aStruct);
break;
case eStyleStruct_TextReset:
mCachedStyleData.mResetData->mTextData = (nsStyleTextReset*)(const nsStyleTextReset*)(&aStruct);
break;
case eStyleStruct_Display:
mCachedStyleData.mResetData->mDisplayData = (nsStyleDisplay*)(const nsStyleDisplay*)(&aStruct);
break;
case eStyleStruct_Visibility:
mCachedStyleData.mInheritedData->mVisibilityData = (nsStyleVisibility*)(const nsStyleVisibility*)(&aStruct);
break;
case eStyleStruct_Table:
mCachedStyleData.mResetData->mTableData = (nsStyleTable*)(const nsStyleTable*)(&aStruct);
break;
case eStyleStruct_TableBorder:
mCachedStyleData.mInheritedData->mTableData = (nsStyleTableBorder*)(const nsStyleTableBorder*)(&aStruct);
break;
case eStyleStruct_Content:
mCachedStyleData.mResetData->mContentData = (nsStyleContent*)(const nsStyleContent*)(&aStruct);
break;
case eStyleStruct_Quotes:
mCachedStyleData.mInheritedData->mQuotesData = (nsStyleQuotes*)(const nsStyleQuotes*)(&aStruct);
break;
case eStyleStruct_UserInterface:
mCachedStyleData.mInheritedData->mUIData = (nsStyleUserInterface*)(const nsStyleUserInterface*)(&aStruct);
break;
case eStyleStruct_UIReset:
mCachedStyleData.mResetData->mUIData = (nsStyleUIReset*)(const nsStyleUIReset*)(&aStruct);
break;
case eStyleStruct_Margin:
mCachedStyleData.mResetData->mMarginData = (nsStyleMargin*)(const nsStyleMargin*)(&aStruct);
break;
case eStyleStruct_Padding:
mCachedStyleData.mResetData->mPaddingData = (nsStylePadding*)(const nsStylePadding*)(&aStruct);
break;
case eStyleStruct_Border:
mCachedStyleData.mResetData->mBorderData = (nsStyleBorder*)(const nsStyleBorder*)(&aStruct);
break;
case eStyleStruct_Outline:
mCachedStyleData.mResetData->mOutlineData = (nsStyleOutline*)(const nsStyleOutline*)(&aStruct);
break;
#ifdef INCLUDE_XUL
case eStyleStruct_XUL:
mCachedStyleData.mResetData->mXULData = (nsStyleXUL*)(const nsStyleXUL*)(&aStruct);
break;
#endif
#ifdef MOZ_SVG
case eStyleStruct_SVG:
mCachedStyleData.mInheritedData->mSVGData = (nsStyleSVG*)(const nsStyleSVG*)(&aStruct);
break;
#endif
default:
NS_ERROR("Invalid style struct id");
result = NS_ERROR_INVALID_ARG;
break;
// NOTE: nsCachedStyleData::GetStyleData works roughly the same way.
const nsCachedStyleData::StyleStructInfo& info =
nsCachedStyleData::gInfo[aSID];
char* resetOrInheritSlot = NS_REINTERPRET_CAST(char*, &mCachedStyleData) +
info.mCachedStyleDataOffset;
char* resetOrInherit = NS_REINTERPRET_CAST(char*,
*NS_REINTERPRET_CAST(void**, resetOrInheritSlot));
if (!resetOrInherit) {
nsCOMPtr<nsIPresContext> presContext;
mRuleNode->GetPresContext(getter_AddRefs(presContext));
if (mCachedStyleData.IsReset(aSID)) {
mCachedStyleData.mResetData = new (presContext.get()) nsResetStyleData;
resetOrInherit = NS_REINTERPRET_CAST(char*, mCachedStyleData.mResetData);
} else {
mCachedStyleData.mInheritedData =
new (presContext.get()) nsInheritedStyleData;
resetOrInherit =
NS_REINTERPRET_CAST(char*, mCachedStyleData.mInheritedData);
}
}
return result;
char* dataSlot = resetOrInherit + info.mInheritResetOffset;
*NS_REINTERPRET_CAST(nsStyleStruct**, dataSlot) = aStruct;
return NS_OK;
}
void

View File

@ -1,649 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
//
// IMPORTANT:
// This is not a stand-alone source file. It is included in nsStyleContext.cpp
//
//=========================================================================================================
#ifdef XP_MAC
#include <Events.h>
#include <Timer.h>
static PRBool MacKeyDown(unsigned char theKey)
{
KeyMap map;
GetKeys(map);
return ((*((unsigned char *)map + (theKey >> 3)) >> (theKey & 7)) & 1) != 0;
}
#endif
static PRBool IsTimeToDumpDebugData()
{
PRBool timeToDump = PR_FALSE;
#ifdef XP_MAC
static unsigned long lastTicks = 0;
if (MacKeyDown(0x3b)) { // control key
if ((unsigned long)(::TickCount() - lastTicks) > 60) {
lastTicks = ::TickCount();
timeToDump = PR_TRUE;
}
}
#endif
return timeToDump;
}
#ifdef XP_MAC
#pragma mark -
#endif
//=========================================================================================================
#ifdef LOG_STYLE_STRUCTS
static void LogStyleStructs(nsStyleContextData* aStyleContextData)
{
#define max_structs eStyleStruct_Max
static unsigned long totalCount = 0;
static unsigned long defaultStruct[max_structs];
static unsigned long setFromParent[max_structs];
static unsigned long gotMutable[max_structs];
static unsigned long gotMutableAndDefault[max_structs];
static PRBool resetCounters = PR_TRUE;
if (IsTimeToDumpDebugData()) {
resetCounters = PR_TRUE;
printf("\n\n\n");
printf("-------------------------------------------------------------------------------------------------------------\n");
printf("Count of nsStyleContextData: %ld\n", totalCount);
printf("-------------------------------------------------------------------------------------------------------------\n");
printf(" unchanged unchanged%c set-from-parent%c size-of-struct potential-gain-Kb gotMutable/total gotMutableAndDefault/default\n", '%', '%');
unsigned long totalFootprint = 0;
unsigned long totalPotentialGain = 0;
for (short i = 0; i < max_structs; i ++) {
short index = i+1;
short sizeOfStruct = 0;
unsigned long footprint = 0;
unsigned long potentialGain = 0;
switch (index) {
case eStyleStruct_Font: printf("eStyleStruct_Font "); sizeOfStruct = sizeof(StyleFontImpl); break;
case eStyleStruct_Color: printf("eStyleStruct_Color "); sizeOfStruct = sizeof(StyleColorImpl); break;
case eStyleStruct_List: printf("eStyleStruct_List "); sizeOfStruct = sizeof(StyleListImpl); break;
case eStyleStruct_Position: printf("eStyleStruct_Position "); sizeOfStruct = sizeof(StylePositionImpl); break;
case eStyleStruct_Text: printf("eStyleStruct_Text "); sizeOfStruct = sizeof(StyleTextImpl); break;
case eStyleStruct_Display: printf("eStyleStruct_Display "); sizeOfStruct = sizeof(StyleDisplayImpl); break;
case eStyleStruct_Table: printf("eStyleStruct_Table "); sizeOfStruct = sizeof(StyleTableImpl); break;
case eStyleStruct_Content: printf("eStyleStruct_Content "); sizeOfStruct = sizeof(StyleContentImpl); break;
case eStyleStruct_UserInterface: printf("eStyleStruct_UserInterface "); sizeOfStruct = sizeof(StyleUserInterfaceImpl); break;
case eStyleStruct_Print: printf("eStyleStruct_Print "); sizeOfStruct = sizeof(StylePrintImpl); break;
case eStyleStruct_Margin: printf("eStyleStruct_Margin "); sizeOfStruct = sizeof(StyleMarginImpl); break;
case eStyleStruct_Padding: printf("eStyleStruct_Padding "); sizeOfStruct = sizeof(StylePaddingImpl); break;
case eStyleStruct_Border: printf("eStyleStruct_Border "); sizeOfStruct = sizeof(StyleBorderImpl); break;
case eStyleStruct_Outline: printf("eStyleStruct_Outline "); sizeOfStruct = sizeof(StyleOutlineImpl); break;
#ifdef INCLUDE_XUL
case eStyleStruct_XUL: printf("eStyleStruct_Outline "); sizeOfStruct = sizeof(StyleXULImpl); break;
#endif
//#insert new style structs here#
}
short percentDefault = (totalCount == 0 ? 0 : ((100 * defaultStruct[i]) / totalCount));
short percentGotMutable = (totalCount == 0 ? 0 : ((100 * gotMutable[i]) / totalCount));
short percentGotMutableAndDefault = (defaultStruct[i] == 0 ? 0 : ((100 * gotMutableAndDefault[i]) / defaultStruct[i]));
short percentFromParent = (defaultStruct[i] == 0 ? 0 : ((100 * setFromParent[i]) / defaultStruct[i]));
footprint = totalCount * sizeOfStruct;
totalFootprint += footprint;
potentialGain = defaultStruct[i] * sizeOfStruct;
totalPotentialGain += potentialGain;
printf(" %7ld %3d %3d %5d %5d %5d %5d\n",
defaultStruct[i], percentDefault, percentFromParent, sizeOfStruct, potentialGain / 1024, percentGotMutable, percentGotMutableAndDefault);
}
printf("-------------------------------------------------------------------------------------------------------------\n");
printf("Current footprint: %4ld Kb\n", totalFootprint / 1024);
printf("Potential gain: %4ld Kb (or %d%c)\n", totalPotentialGain / 1024, totalPotentialGain*100/totalFootprint, '%');
printf("Would remain: %4ld Kb\n", (totalFootprint - totalPotentialGain) / 1024);
printf("-------------------------------------------------------------------------------------------------------------\n");
printf("These stats come from the nsStyleContextData structures that have been deleted since the last output.\n");
printf("To get the stats for a particular page: load page, dump stats, load 'about:blank', dump stats again.\n");
printf("-------------------------------------------------------------------------------------------------------------\n");
printf("\n\n\n");
}
if (resetCounters) {
resetCounters = PR_FALSE;
totalCount = 0;
for (short i = 0; i < max_structs; i ++) {
defaultStruct[i] = 0L;
gotMutable[i] = 0L;
gotMutableAndDefault[i] = 0L;
setFromParent[i] = 0L;
}
}
if (!aStyleContextData) {
printf ("*** aStyleContextData is nil\n");
return;
}
totalCount++;
for (short i = 0; i < max_structs; i ++) {
short index = i+1;
switch (index) {
case eStyleStruct_Font:
if (aStyleContextData->mGotMutable[i])
gotMutable[i]++;
if (aStyleContextData->mFont->CalcDifference(aStyleContextData->mFont->mInternalFont) == NS_STYLE_HINT_NONE) {
defaultStruct[i]++;
if (aStyleContextData->mGotMutable[i])
gotMutableAndDefault[i]++;
if (aStyleContextData->mFont->mSetFromParent)
setFromParent[i]++;
}
break;
case eStyleStruct_Color:
if (aStyleContextData->mGotMutable[i])
gotMutable[i]++;
if (aStyleContextData->mColor->CalcDifference(aStyleContextData->mColor->mInternalColor) == NS_STYLE_HINT_NONE) {
defaultStruct[i]++;
if (aStyleContextData->mGotMutable[i])
gotMutableAndDefault[i]++;
if (aStyleContextData->mColor->mSetFromParent)
setFromParent[i]++;
}
break;
case eStyleStruct_List:
if (aStyleContextData->mGotMutable[i])
gotMutable[i]++;
if (aStyleContextData->mList->CalcDifference(aStyleContextData->mList->mInternalList) == NS_STYLE_HINT_NONE) {
defaultStruct[i]++;
if (aStyleContextData->mGotMutable[i])
gotMutableAndDefault[i]++;
if (aStyleContextData->mList->mSetFromParent)
setFromParent[i]++;
}
break;
case eStyleStruct_Position:
if (aStyleContextData->mGotMutable[i])
gotMutable[i]++;
if (aStyleContextData->mPosition->CalcDifference(aStyleContextData->mPosition->mInternalPosition) == NS_STYLE_HINT_NONE) {
defaultStruct[i]++;
if (aStyleContextData->mGotMutable[i])
gotMutableAndDefault[i]++;
if (aStyleContextData->mPosition->mSetFromParent)
setFromParent[i]++;
}
break;
case eStyleStruct_Text:
if (aStyleContextData->mGotMutable[i])
gotMutable[i]++;
if (aStyleContextData->mText->CalcDifference(aStyleContextData->mText->mInternalText) == NS_STYLE_HINT_NONE) {
defaultStruct[i]++;
if (aStyleContextData->mGotMutable[i])
gotMutableAndDefault[i]++;
if (aStyleContextData->mText->mSetFromParent)
setFromParent[i]++;
}
break;
case eStyleStruct_Display:
if (aStyleContextData->mGotMutable[i])
gotMutable[i]++;
if (aStyleContextData->mDisplay->CalcDifference(aStyleContextData->mDisplay->mInternalDisplay) == NS_STYLE_HINT_NONE) {
defaultStruct[i]++;
if (aStyleContextData->mGotMutable[i])
gotMutableAndDefault[i]++;
if (aStyleContextData->mDisplay->mSetFromParent)
setFromParent[i]++;
}
break;
case eStyleStruct_Table:
if (aStyleContextData->mGotMutable[i])
gotMutable[i]++;
if (aStyleContextData->mTable->CalcDifference(aStyleContextData->mTable->mInternalTable) == NS_STYLE_HINT_NONE) {
defaultStruct[i]++;
if (aStyleContextData->mGotMutable[i])
gotMutableAndDefault[i]++;
if (aStyleContextData->mTable->mSetFromParent)
setFromParent[i]++;
}
break;
case eStyleStruct_Content:
if (aStyleContextData->mGotMutable[i])
gotMutable[i]++;
if (aStyleContextData->mContent->CalcDifference(aStyleContextData->mContent->mInternalContent) == NS_STYLE_HINT_NONE) {
defaultStruct[i]++;
if (aStyleContextData->mGotMutable[i])
gotMutableAndDefault[i]++;
if (aStyleContextData->mContent->mSetFromParent)
setFromParent[i]++;
}
break;
case eStyleStruct_UserInterface:
if (aStyleContextData->mGotMutable[i])
gotMutable[i]++;
if (aStyleContextData->mUserInterface->CalcDifference(aStyleContextData->mUserInterface->mInternalUserInterface) == NS_STYLE_HINT_NONE) {
defaultStruct[i]++;
if (aStyleContextData->mGotMutable[i])
gotMutableAndDefault[i]++;
if (aStyleContextData->mUserInterface->mSetFromParent)
setFromParent[i]++;
}
break;
case eStyleStruct_Print:
if (aStyleContextData->mGotMutable[i])
gotMutable[i]++;
if (aStyleContextData->mPrint->CalcDifference(aStyleContextData->mPrint->mInternalPrint) == NS_STYLE_HINT_NONE) {
defaultStruct[i]++;
if (aStyleContextData->mGotMutable[i])
gotMutableAndDefault[i]++;
if (aStyleContextData->mPrint->mSetFromParent)
setFromParent[i]++;
}
break;
case eStyleStruct_Margin:
if (aStyleContextData->mGotMutable[i])
gotMutable[i]++;
if (aStyleContextData->mMargin->CalcDifference(aStyleContextData->mMargin->mInternalMargin) == NS_STYLE_HINT_NONE) {
defaultStruct[i]++;
if (aStyleContextData->mGotMutable[i])
gotMutableAndDefault[i]++;
if (aStyleContextData->mMargin->mSetFromParent)
setFromParent[i]++;
}
break;
case eStyleStruct_Padding:
if (aStyleContextData->mGotMutable[i])
gotMutable[i]++;
if (aStyleContextData->mPadding->CalcDifference(aStyleContextData->mPadding->mInternalPadding) == NS_STYLE_HINT_NONE) {
defaultStruct[i]++;
if (aStyleContextData->mGotMutable[i])
gotMutableAndDefault[i]++;
if (aStyleContextData->mPadding->mSetFromParent)
setFromParent[i]++;
}
break;
case eStyleStruct_Border:
if (aStyleContextData->mGotMutable[i])
gotMutable[i]++;
if (aStyleContextData->mBorder->CalcDifference(aStyleContextData->mBorder->mInternalBorder) == NS_STYLE_HINT_NONE) {
defaultStruct[i]++;
if (aStyleContextData->mGotMutable[i])
gotMutableAndDefault[i]++;
if (aStyleContextData->mBorder->mSetFromParent)
setFromParent[i]++;
}
break;
case eStyleStruct_Outline:
if (aStyleContextData->mGotMutable[i])
gotMutable[i]++;
if (aStyleContextData->mOutline->CalcDifference(aStyleContextData->mOutline->mInternalOutline) == NS_STYLE_HINT_NONE) {
defaultStruct[i]++;
if (aStyleContextData->mGotMutable[i])
gotMutableAndDefault[i]++;
if (aStyleContextData->mOutline->mSetFromParent)
setFromParent[i]++;
}
break;
#ifdef INCLUDE_XUL
case eStyleStruct_XUL:
if (aStyleContextData->mGotMutable[i])
gotMutable[i]++;
if (aStyleContextData->mXUL->CalcDifference(aStyleContextData->mXUL->mInternalXUL) == NS_STYLE_HINT_NONE) {
defaultStruct[i]++;
if (aStyleContextData->mGotMutable[i])
gotMutableAndDefault[i]++;
if (aStyleContextData->mXUL->mSetFromParent)
setFromParent[i]++;
}
break;
#endif
//#insert new style structs here#
}
}
static short inCount = 0;
static short outCount = 0;
if (inCount++ % 1000 == 0) {
switch (outCount++) {
case 0: printf("still logging"); break;
case 20: printf("\n"); outCount = 0; break;
default: printf("."); fflush(stdout); break;
}
}
}
#endif // LOG_STYLE_STRUCTS
#ifdef XP_MAC
#pragma mark -
#endif
//=========================================================================================================
#ifdef LOG_GET_STYLE_DATA_CALLS
static void LogGetStyleDataCall(nsStyleStructID aSID, LogCallType aLogCallType, nsIStyleContext* aStyleContext, PRBool aEnteringFunction)
{
#define max_structs (eStyleStruct_Max + 1)
#define small_depth_threshold 8
static unsigned long calls[max_structs*logCallType_Max];
static unsigned long callspercent[max_structs*logCallType_Max];
static unsigned long depth[max_structs*logCallType_Max];
static unsigned long maxdepth[max_structs*logCallType_Max];
static unsigned long smalldepth[max_structs*logCallType_Max];
static unsigned long microsecs[logCallType_Max];
static unsigned long totalMicrosecs;
static UnsignedWide startMicrosecs;
static UnsignedWide endMicrosecs;
if (!aEnteringFunction) {
::Microseconds(&endMicrosecs);
totalMicrosecs += endMicrosecs.lo - startMicrosecs.lo;
microsecs[aLogCallType] += endMicrosecs.lo - startMicrosecs.lo;
return;
}
static PRBool resetCounters = PR_TRUE;
if (IsTimeToDumpDebugData()) {
resetCounters = PR_TRUE;
unsigned long totalCalls;
unsigned long totalMaxdepth;
unsigned long totalDepth;
for (short i = 0; i < (max_structs*logCallType_Max); i ++) {
if (i%max_structs == 0) {
switch (i/max_structs) {
case 0:
printf("\n\n\n");
printf("----GetStyleData--------------------------------------------------------------------------\n");
printf(" calls calls%c max depth avg depth (depth<%d)%\n", '%', small_depth_threshold);
break;
case 1:
printf("----ReadMutableStyleData-------------------------------------------------------------------\n");
printf(" calls calls%c max depth avg depth (depth<%d)%\n", '%', small_depth_threshold);
break;
case 2:
printf("----WriteMutableStyleData------------------------------------------------------------------\n");
printf(" calls calls%c max depth avg depth (depth<%d)%\n", '%', small_depth_threshold);
break;
case 3:
printf("----GetStyle------------------------------------------------------------------------------\n");
printf(" calls calls%c max depth avg depth (depth<%d)%\n", '%', small_depth_threshold);
break;
}
totalCalls = totalMaxdepth = totalDepth = 0;
for (short j = i; j < i + max_structs; j++) {
totalCalls += calls[j];
totalDepth += depth[j];
if (totalMaxdepth < maxdepth[j]) {
totalMaxdepth = maxdepth[j];
}
}
}
switch (i%max_structs + 1) {
case eStyleStruct_Font: printf("eStyleStruct_Font "); break;
case eStyleStruct_Color: printf("eStyleStruct_Color "); break;
case eStyleStruct_List: printf("eStyleStruct_List "); break;
case eStyleStruct_Position: printf("eStyleStruct_Position "); break;
case eStyleStruct_Text: printf("eStyleStruct_Text "); break;
case eStyleStruct_Display: printf("eStyleStruct_Display "); break;
case eStyleStruct_Table: printf("eStyleStruct_Table "); break;
case eStyleStruct_Content: printf("eStyleStruct_Content "); break;
case eStyleStruct_UserInterface: printf("eStyleStruct_UserInterface "); break;
case eStyleStruct_Print: printf("eStyleStruct_Print "); break;
case eStyleStruct_Margin: printf("eStyleStruct_Margin "); break;
case eStyleStruct_Padding: printf("eStyleStruct_Padding "); break;
case eStyleStruct_Border: printf("eStyleStruct_Border "); break;
case eStyleStruct_Outline: printf("eStyleStruct_Outline "); break;
#ifdef INCLUDE_XUL
case eStyleStruct_XUL: printf("eStyleStruct_XUL "); break;
#endif
//#insert new style structs here#
case eStyleStruct_BorderPaddingShortcut: printf("BorderPaddingShortcut "); break;
}
short percent = 100*calls[i]/totalCalls;
short avdepth = calls[i] == 0 ? 0 : round(float(depth[i])/float(calls[i]));
short smdepth = 100*smalldepth[i]/calls[i];
if (percent == 0) {
printf(" %7ld - %3ld %3d %3d\n", calls[i], maxdepth[i], avdepth, smdepth);
}
else {
printf(" %7ld %2ld %3ld %3d %3d\n", calls[i], percent, maxdepth[i], avdepth, smdepth);
}
if (i%max_structs + 1 == max_structs) {
short totaldepth = totalCalls == 0 ? 0 : round(float(totalDepth)/float(totalCalls));
printf("TOTAL ");
printf(" %7ld 100 %3ld %3d %ld ms\n", totalCalls, totalMaxdepth, totaldepth, microsecs[i/max_structs]/1000);
}
}
printf("------------------------------------------------------------------------------------------\n");
printf("TOTAL time = %ld microsecs (= %ld ms)\n", totalMicrosecs, totalMicrosecs/1000);
printf("------------------------------------------------------------------------------------------\n\n\n");
}
if (resetCounters) {
resetCounters = PR_FALSE;
totalMicrosecs = 0;
for (short i = 0; i < logCallType_Max; i ++) {
microsecs[i] = 0L;
}
for (short i = 0; i < (max_structs*logCallType_Max); i ++) {
calls[i] = 0L;
depth[i] = 0L;
maxdepth[i] = 0L;
smalldepth[i] = 0L;
}
}
short index = aSID - 1;
index += max_structs * aLogCallType;
calls[index]++;
unsigned long curdepth = 0;
nsCOMPtr<nsIStyleContext> childContext;
nsCOMPtr<nsIStyleContext> parentContext;
childContext = aStyleContext;
parentContext = getter_AddRefs(childContext->GetParent());
while (parentContext != nsnull) {
curdepth++;
parentContext = getter_AddRefs(childContext->GetParent());
if (parentContext == childContext) {
break;
}
childContext = parentContext;
}
depth[index] += curdepth;
if (maxdepth[index] < curdepth) {
maxdepth[index] = curdepth;
}
if (curdepth <= small_depth_threshold) {
smalldepth[index]++;
}
static short inCount = 0;
static short outCount = 0;
if (inCount++ % 1000 == 0) {
switch (outCount++) {
case 0: printf("still logging"); break;
case 20: printf("\n"); outCount = 0; break;
default: printf("."); fflush(stdout); break;
}
}
::Microseconds(&startMicrosecs);
}
#endif // LOG_GET_STYLE_DATA_CALLS
//=========================================================================================================
#ifdef LOG_WRITE_STYLE_DATA_CALLS
static void LogWriteMutableStyleDataCall(nsStyleStructID aSID, nsStyleStruct* aStyleStruct, StyleContextImpl* aStyleContext)
{
#define max_structs eStyleStruct_Max
static unsigned long calls[max_structs];
static unsigned long unchanged[max_structs];
static PRBool resetCounters = PR_TRUE;
if (IsTimeToDumpDebugData()) {
resetCounters = PR_TRUE;
printf("------------------------------------------------------------------------------------------\n");
printf("WriteMutableStyleData\n");
printf("------------------------------------------------------------------------------------------\n");
printf(" calls unchanged%c\n", '%');
for (short i = 0; i < max_structs; i ++) {
switch (i+1) {
case eStyleStruct_Font: printf("eStyleStruct_Font "); break;
case eStyleStruct_Color: printf("eStyleStruct_Color "); break;
case eStyleStruct_List: printf("eStyleStruct_List "); break;
case eStyleStruct_Position: printf("eStyleStruct_Position "); break;
case eStyleStruct_Text: printf("eStyleStruct_Text "); break;
case eStyleStruct_Display: printf("eStyleStruct_Display "); break;
case eStyleStruct_Table: printf("eStyleStruct_Table "); break;
case eStyleStruct_Content: printf("eStyleStruct_Content "); break;
case eStyleStruct_UserInterface: printf("eStyleStruct_UserInterface "); break;
case eStyleStruct_Print: printf("eStyleStruct_Print "); break;
case eStyleStruct_Margin: printf("eStyleStruct_Margin "); break;
case eStyleStruct_Padding: printf("eStyleStruct_Padding "); break;
case eStyleStruct_Border: printf("eStyleStruct_Border "); break;
case eStyleStruct_Outline: printf("eStyleStruct_Outline "); break;
#ifdef INCLUDE_XUL
case eStyleStruct_XUL: printf("eStyleStruct_XUL "); break;
#endif
//#insert new style structs here#
}
short percent = 100*unchanged[i]/calls[i];
if (percent == 0) {
printf(" %7ld -\n", calls[i]);
}
else {
printf(" %7ld %2ld\n", calls[i], percent);
}
}
printf("------------------------------------------------------------------------------------------\n\n\n");
}
if (resetCounters) {
resetCounters = PR_FALSE;
for (short i=0; i<max_structs; i++) {
calls[i] = 0;
unchanged[i] = 0;
}
}
calls[aSID-1] ++;
switch (aSID) {
case eStyleStruct_Font:
if (aStyleContext->GETSCDATA(Font)->CalcDifference(*(nsStyleFont*)aStyleStruct) == NS_STYLE_HINT_NONE)
unchanged[aSID-1]++;
break;
case eStyleStruct_Color:
if (aStyleContext->GETSCDATA(Color)->CalcDifference(*(nsStyleColor*)aStyleStruct) == NS_STYLE_HINT_NONE)
unchanged[aSID-1]++;
break;
case eStyleStruct_List:
if (aStyleContext->GETSCDATA(List)->CalcDifference(*(nsStyleList*)aStyleStruct) == NS_STYLE_HINT_NONE)
unchanged[aSID-1]++;
break;
case eStyleStruct_Position:
if (aStyleContext->GETSCDATA(Position)->CalcDifference(*(nsStylePosition*)aStyleStruct) == NS_STYLE_HINT_NONE)
unchanged[aSID-1]++;
break;
case eStyleStruct_Text:
if (aStyleContext->GETSCDATA(Text)->CalcDifference(*(nsStyleText*)aStyleStruct) == NS_STYLE_HINT_NONE)
unchanged[aSID-1]++;
break;
case eStyleStruct_Display:
if (aStyleContext->GETSCDATA(Display)->CalcDifference(*(nsStyleDisplay*)aStyleStruct) == NS_STYLE_HINT_NONE)
unchanged[aSID-1]++;
break;
case eStyleStruct_Table:
if (aStyleContext->GETSCDATA(Table)->CalcDifference(*(nsStyleTable*)aStyleStruct) == NS_STYLE_HINT_NONE)
unchanged[aSID-1]++;
break;
case eStyleStruct_Content:
if (aStyleContext->GETSCDATA(Content)->CalcDifference(*(nsStyleContent*)aStyleStruct) == NS_STYLE_HINT_NONE)
unchanged[aSID-1]++;
break;
case eStyleStruct_UserInterface:
if (aStyleContext->GETSCDATA(UserInterface)->CalcDifference(*(nsStyleUserInterface*)aStyleStruct) == NS_STYLE_HINT_NONE)
unchanged[aSID-1]++;
break;
case eStyleStruct_Print:
if (aStyleContext->GETSCDATA(Print)->CalcDifference(*(nsStylePrint*)aStyleStruct) == NS_STYLE_HINT_NONE)
unchanged[aSID-1]++;
break;
case eStyleStruct_Margin:
if (aStyleContext->GETSCDATA(Margin)->CalcDifference(*(nsStyleMargin*)aStyleStruct) == NS_STYLE_HINT_NONE)
unchanged[aSID-1]++;
break;
case eStyleStruct_Padding:
if (aStyleContext->GETSCDATA(Padding)->CalcDifference(*(nsStylePadding*)aStyleStruct) == NS_STYLE_HINT_NONE)
unchanged[aSID-1]++;
break;
case eStyleStruct_Border:
if (aStyleContext->GETSCDATA(Border)->CalcDifference(*(nsStyleBorder*)aStyleStruct) == NS_STYLE_HINT_NONE)
unchanged[aSID-1]++;
break;
case eStyleStruct_Outline:
if (aStyleContext->GETSCDATA(Outline)->CalcDifference(*(nsStyleOutline*)aStyleStruct) == NS_STYLE_HINT_NONE)
unchanged[aSID-1]++;
break;
#ifdef INCLUDE_XUL
case eStyleStruct_XUL:
if (aStyleContext->GETSCDATA(XUL)->CalcDifference(*(nsStyleXUL*)aStyleStruct) == NS_STYLE_HINT_NONE)
unchanged[aSID-1]++;
break;
#endif
//#insert new style structs here#
default:
NS_ERROR("Invalid style struct id");
break;
}
}
#endif // LOG_WRITE_STYLE_DATA_CALLS

View File

@ -1,295 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
//
// IMPORTANT:
// This is not a real header file. It is only included in nsStyleContext.cpp
//
#ifdef LOG_STYLE_STRUCTS
// StyleFontImpl mFont;
struct StyleFontImplLog: public StyleFontImpl {
StyleFontImplLog(const nsFont& aVariableFont, const nsFont& aFixedFont)
: StyleFontImpl(aVariableFont, aFixedFont),
mInternalFont(aVariableFont, aFixedFont)
{}
void ResetFrom(const nsStyleFont* aParent, nsIPresContext* aPresContext);
StyleFontImpl mInternalFont;
PRBool mSetFromParent;
};
void StyleFontImplLog::ResetFrom(const nsStyleFont* aParent, nsIPresContext* aPresContext)
{
StyleFontImpl::ResetFrom(aParent, aPresContext);
CopyTo(mInternalFont);
mSetFromParent = (aParent != nsnull);
}
// StyleColorImpl mColor;
struct StyleColorImplLog: public StyleColorImpl {
void ResetFrom(const nsStyleColor* aParent, nsIPresContext* aPresContext);
StyleColorImpl mInternalColor;
PRBool mSetFromParent;
};
void StyleColorImplLog::ResetFrom(const nsStyleColor* aParent, nsIPresContext* aPresContext)
{
StyleColorImpl::ResetFrom(aParent, aPresContext);
CopyTo(mInternalColor);
mSetFromParent = (aParent != nsnull);
}
// StyleListImpl mList;
struct StyleListImplLog: public StyleListImpl {
void ResetFrom(const nsStyleList* aParent, nsIPresContext* aPresContext);
StyleListImpl mInternalList;
PRBool mSetFromParent;
};
void StyleListImplLog::ResetFrom(const nsStyleList* aParent, nsIPresContext* aPresContext)
{
StyleListImpl::ResetFrom(aParent, aPresContext);
CopyTo(mInternalList);
mSetFromParent = (aParent != nsnull);
}
// StylePositionImpl mPosition;
struct StylePositionImplLog: public StylePositionImpl {
void ResetFrom(const nsStylePosition* aParent, nsIPresContext* aPresContext);
StylePositionImpl mInternalPosition;
PRBool mSetFromParent;
};
void StylePositionImplLog::ResetFrom(const nsStylePosition* aParent, nsIPresContext* aPresContext)
{
StylePositionImpl::ResetFrom(aParent, aPresContext);
CopyTo(mInternalPosition);
mSetFromParent = (aParent != nsnull);
}
// StyleTextImpl mText;
struct StyleTextImplLog: public StyleTextImpl {
void ResetFrom(const nsStyleText* aParent, nsIPresContext* aPresContext);
StyleTextImpl mInternalText;
PRBool mSetFromParent;
};
void StyleTextImplLog::ResetFrom(const nsStyleText* aParent, nsIPresContext* aPresContext)
{
StyleTextImpl::ResetFrom(aParent, aPresContext);
CopyTo(mInternalText);
mSetFromParent = (aParent != nsnull);
}
// StyleDisplayImpl mDisplay;
struct StyleDisplayImplLog: public StyleDisplayImpl {
void ResetFrom(const nsStyleDisplay* aParent, nsIPresContext* aPresContext);
StyleDisplayImpl mInternalDisplay;
PRBool mSetFromParent;
};
void StyleDisplayImplLog::ResetFrom(const nsStyleDisplay* aParent, nsIPresContext* aPresContext)
{
StyleDisplayImpl::ResetFrom(aParent, aPresContext);
CopyTo(mInternalDisplay);
mSetFromParent = (aParent != nsnull);
}
// StyleTableImpl mTable;
struct StyleTableImplLog: public StyleTableImpl {
void ResetFrom(const nsStyleTable* aParent, nsIPresContext* aPresContext);
StyleTableImpl mInternalTable;
PRBool mSetFromParent;
};
void StyleTableImplLog::ResetFrom(const nsStyleTable* aParent, nsIPresContext* aPresContext)
{
StyleTableImpl::ResetFrom(aParent, aPresContext);
CopyTo(mInternalTable);
mSetFromParent = (aParent != nsnull);
}
// StyleContentImpl mContent;
struct StyleContentImplLog: public StyleContentImpl {
void ResetFrom(const StyleContentImpl* aParent, nsIPresContext* aPresContext);
StyleContentImpl mInternalContent;
PRBool mSetFromParent;
};
void StyleContentImplLog::ResetFrom(const StyleContentImpl* aParent, nsIPresContext* aPresContext)
{
StyleContentImpl::ResetFrom(aParent, aPresContext);
CopyTo(mInternalContent);
mSetFromParent = (aParent != nsnull);
}
// StyleUserInterfaceImpl mUserInterface;
struct StyleUserInterfaceImplLog: public StyleUserInterfaceImpl {
void ResetFrom(const nsStyleUserInterface* aParent, nsIPresContext* aPresContext);
StyleUserInterfaceImpl mInternalUserInterface;
PRBool mSetFromParent;
};
void StyleUserInterfaceImplLog::ResetFrom(const nsStyleUserInterface* aParent, nsIPresContext* aPresContext)
{
StyleUserInterfaceImpl::ResetFrom(aParent, aPresContext);
CopyTo(mInternalUserInterface);
mSetFromParent = (aParent != nsnull);
}
// StylePrintImpl mPrint;
struct StylePrintImplLog: public StylePrintImpl {
void ResetFrom(const nsStylePrint* aParent, nsIPresContext* aPresContext);
StylePrintImpl mInternalPrint;
PRBool mSetFromParent;
};
void StylePrintImplLog::ResetFrom(const nsStylePrint* aParent, nsIPresContext* aPresContext)
{
StylePrintImpl::ResetFrom(aParent, aPresContext);
CopyTo(mInternalPrint);
mSetFromParent = (aParent != nsnull);
}
// StyleMarginImpl mMargin;
struct StyleMarginImplLog: public StyleMarginImpl {
void ResetFrom(const nsStyleMargin* aParent, nsIPresContext* aPresContext);
StyleMarginImpl mInternalMargin;
PRBool mSetFromParent;
};
void StyleMarginImplLog::ResetFrom(const nsStyleMargin* aParent, nsIPresContext* aPresContext)
{
StyleMarginImpl::ResetFrom(aParent, aPresContext);
CopyTo(mInternalMargin);
mSetFromParent = (aParent != nsnull);
}
// StylePaddingImpl mPadding;
struct StylePaddingImplLog: public StylePaddingImpl {
void ResetFrom(const nsStylePadding* aParent, nsIPresContext* aPresContext);
StylePaddingImpl mInternalPadding;
PRBool mSetFromParent;
};
void StylePaddingImplLog::ResetFrom(const nsStylePadding* aParent, nsIPresContext* aPresContext)
{
StylePaddingImpl::ResetFrom(aParent, aPresContext);
CopyTo(mInternalPadding);
mSetFromParent = (aParent != nsnull);
}
// StyleBorderImpl mBorder;
struct StyleBorderImplLog: public StyleBorderImpl {
void ResetFrom(const nsStyleBorder* aParent, nsIPresContext* aPresContext);
StyleBorderImpl mInternalBorder;
PRBool mSetFromParent;
};
void StyleBorderImplLog::ResetFrom(const nsStyleBorder* aParent, nsIPresContext* aPresContext)
{
StyleBorderImpl::ResetFrom(aParent, aPresContext);
CopyTo(mInternalBorder);
mSetFromParent = (aParent != nsnull);
}
// StyleOutlineImpl mOutline;
struct StyleOutlineImplLog: public StyleOutlineImpl {
void ResetFrom(const nsStyleOutline* aParent, nsIPresContext* aPresContext);
StyleOutlineImpl mInternalOutline;
PRBool mSetFromParent;
};
void StyleOutlineImplLog::ResetFrom(const nsStyleOutline* aParent, nsIPresContext* aPresContext)
{
StyleOutlineImpl::ResetFrom(aParent, aPresContext);
CopyTo(mInternalOutline);
mSetFromParent = (aParent != nsnull);
}
// StyleXULImpl mXUL;
#ifdef INCLUDE_XUL
struct StyleXULImplLog: public StyleXULImpl {
void ResetFrom(const nsStyleXUL* aParent, nsIPresContext* aPresContext);
StyleXULImpl mInternalXUL;
PRBool mSetFromParent;
};
void StyleXULImplLog::ResetFrom(const nsStyleXUL* aParent, nsIPresContext* aPresContext)
{
StyleXULImpl::ResetFrom(aParent, aPresContext);
CopyTo(mInternalXUL);
mSetFromParent = (aParent != nsnull);
}
#endif // INCLUDE_XUL
//=============================
static void LogStyleStructs(nsStyleContextData* aStyleContextData);
#endif // LOG_STYLE_STRUCTS
#ifdef XP_MAC
#pragma mark -
#endif
//=========================================================================================================
#ifdef LOG_GET_STYLE_DATA_CALLS
enum LogCallType {
logCallType_GetStyleData = 0,
logCallType_ReadMutableStyleData,
logCallType_WriteMutableStyleData,
logCallType_GetStyle,
logCallType_Max
};
static void LogGetStyleDataCall(nsStyleStructID aSID, LogCallType aLogCallType,
nsIStyleContext* aStyleContext, PRBool aEnteringFunction);
#endif // LOG_GET_STYLE_DATA_CALLS
//=========================================================================================================
static void LogWriteMutableStyleDataCall(nsStyleStructID aSID,
nsStyleStruct* aStyleStruct,
StyleContextImpl* aStyleContext);

View File

@ -62,120 +62,20 @@
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
#define STYLE_STRUCT_INHERITED(name, checkdata_cb) \
{ offsetof(nsCachedStyleData, mInheritedData), \
offsetof(nsInheritedStyleData, m##name##Data), \
PR_FALSE },
#define STYLE_STRUCT_RESET(name, checkdata_cb) \
{ offsetof(nsCachedStyleData, mResetData), \
offsetof(nsResetStyleData, m##name##Data), \
PR_TRUE },
#ifdef MOZ_SVG
/* eStyleStruct_SVG */
{ offsetof(nsCachedStyleData, mInheritedData),
offsetof(nsInheritedStyleData, mSVGData),
PR_FALSE
},
#endif
#include "nsStyleStructList.h"
#undef STYLE_STRUCT_INHERITED
#undef STYLE_STRUCT_RESET
{ 0, 0, 0 }
};

View File

@ -20,6 +20,7 @@ nsRuleWalker.h
nsStyleCoord.h
nsStyleUtil.h
nsStyleStruct.h
nsStyleStructList.h
nsTextFragment.h
nsXULAtomList.h
nsXULAtoms.h

View File

@ -47,6 +47,7 @@ nsRuleWalker.h \
nsStyleCoord.h \
nsStyleUtil.h \
nsStyleStruct.h \
nsStyleStructList.h \
nsTextFragment.h \
nsXULAtomList.h \
nsXULAtoms.h \

View File

@ -41,6 +41,7 @@ EXPORTS = \
nsStyleCoord.h \
nsStyleUtil.h \
nsStyleStruct.h \
nsStyleStructList.h \
nsTextFragment.h \
nsXULAtomList.h \
nsXULAtoms.h \

View File

@ -56,17 +56,15 @@ typedef void (*nsPostResolveFunc)(nsStyleStruct* aStyleStruct, nsRuleData* aData
struct nsInheritedStyleData
{
nsStyleVisibility* mVisibilityData;
nsStyleFont* mFontData;
nsStyleList* mListData;
nsStyleTableBorder* mTableData;
nsStyleColor* mColorData;
nsStyleQuotes* mQuotesData;
nsStyleText* mTextData;
nsStyleUserInterface* mUIData;
#ifdef MOZ_SVG
nsStyleSVG* mSVGData;
#endif
#define STYLE_STRUCT_INHERITED(name, checkdata_cb) \
nsStyle##name * m##name##Data;
#define STYLE_STRUCT_RESET(name, checkdata_cb)
#include "nsStyleStructList.h"
#undef STYLE_STRUCT_INHERITED
#undef STYLE_STRUCT_RESET
void* operator new(size_t sz, nsIPresContext* aContext) CPP_THROW_NEW {
void* result = nsnull;
@ -75,71 +73,56 @@ struct nsInheritedStyleData
};
void ClearInheritedData(PRUint32 aBits) {
if (mVisibilityData && (aBits & NS_STYLE_INHERIT_VISIBILITY))
mVisibilityData = nsnull;
if (mFontData && (aBits & NS_STYLE_INHERIT_FONT))
mFontData = nsnull;
if (mListData && (aBits & NS_STYLE_INHERIT_LIST))
mListData = nsnull;
if (mTableData && (aBits & NS_STYLE_INHERIT_TABLE_BORDER))
mTableData = nsnull;
if (mColorData && (aBits & NS_STYLE_INHERIT_COLOR))
mColorData = nsnull;
if (mQuotesData && (aBits & NS_STYLE_INHERIT_QUOTES))
mQuotesData = nsnull;
if (mTextData && (aBits & NS_STYLE_INHERIT_TEXT))
mTextData = nsnull;
if (mUIData && (aBits & NS_STYLE_INHERIT_UI))
mUIData = nsnull;
#ifdef MOZ_SVG
if (mSVGData && (aBits & NS_STYLE_INHERIT_SVG))
mSVGData = nsnull;
#endif
#define STYLE_STRUCT_INHERITED(name, checkdata_cb) \
if (m##name##Data && (aBits & NS_STYLE_INHERIT_BIT(name))) \
m##name##Data = nsnull;
#define STYLE_STRUCT_RESET(name, checkdata_cb)
#include "nsStyleStructList.h"
#undef STYLE_STRUCT_INHERITED
#undef STYLE_STRUCT_RESET
};
void Destroy(PRUint32 aBits, nsIPresContext* aContext) {
if (mVisibilityData && !(aBits & NS_STYLE_INHERIT_VISIBILITY))
mVisibilityData->Destroy(aContext);
if (mFontData && !(aBits & NS_STYLE_INHERIT_FONT))
mFontData->Destroy(aContext);
if (mListData && !(aBits & NS_STYLE_INHERIT_LIST))
mListData->Destroy(aContext);
if (mTableData && !(aBits & NS_STYLE_INHERIT_TABLE_BORDER))
mTableData->Destroy(aContext);
if (mColorData && !(aBits & NS_STYLE_INHERIT_COLOR))
mColorData->Destroy(aContext);
if (mQuotesData && !(aBits & NS_STYLE_INHERIT_QUOTES))
mQuotesData->Destroy(aContext);
if (mTextData && !(aBits & NS_STYLE_INHERIT_TEXT))
mTextData->Destroy(aContext);
if (mUIData && !(aBits & NS_STYLE_INHERIT_UI))
mUIData->Destroy(aContext);
#ifdef MOZ_SVG
if (mSVGData && !(aBits & NS_STYLE_INHERIT_SVG))
mSVGData->Destroy(aContext);
#endif
#define STYLE_STRUCT_INHERITED(name, checkdata_cb) \
if (m##name##Data && !(aBits & NS_STYLE_INHERIT_BIT(name))) \
m##name##Data->Destroy(aContext);
#define STYLE_STRUCT_RESET(name, checkdata_cb)
#include "nsStyleStructList.h"
#undef STYLE_STRUCT_INHERITED
#undef STYLE_STRUCT_RESET
aContext->FreeToShell(sizeof(nsInheritedStyleData), this);
};
nsInheritedStyleData()
:mVisibilityData(nsnull), mFontData(nsnull), mListData(nsnull),
mTableData(nsnull), mColorData(nsnull), mQuotesData(nsnull), mTextData(nsnull), mUIData(nsnull)
#ifdef MOZ_SVG
, mSVGData(nsnull)
#endif
{};
nsInheritedStyleData() {
#define STYLE_STRUCT_INHERITED(name, checkdata_cb) \
m##name##Data = nsnull;
#define STYLE_STRUCT_RESET(name, checkdata_cb)
#include "nsStyleStructList.h"
#undef STYLE_STRUCT_INHERITED
#undef STYLE_STRUCT_RESET
};
};
struct nsResetStyleData
{
nsResetStyleData()
:mDisplayData(nsnull), mMarginData(nsnull), mBorderData(nsnull), mPaddingData(nsnull),
mOutlineData(nsnull), mPositionData(nsnull), mTableData(nsnull), mBackgroundData(nsnull),
mContentData(nsnull), mTextData(nsnull), mUIData(nsnull)
{
#ifdef INCLUDE_XUL
mXULData = nsnull;
#endif
#define STYLE_STRUCT_RESET(name, checkdata_cb) \
m##name##Data = nsnull;
#define STYLE_STRUCT_INHERITED(name, checkdata_cb)
#include "nsStyleStructList.h"
#undef STYLE_STRUCT_RESET
#undef STYLE_STRUCT_INHERITED
};
void* operator new(size_t sz, nsIPresContext* aContext) CPP_THROW_NEW {
@ -149,78 +132,40 @@ struct nsResetStyleData
}
void ClearInheritedData(PRUint32 aBits) {
if (mDisplayData && (aBits & NS_STYLE_INHERIT_DISPLAY))
mDisplayData = nsnull;
if (mMarginData && (aBits & NS_STYLE_INHERIT_MARGIN))
mMarginData = nsnull;
if (mBorderData && (aBits & NS_STYLE_INHERIT_BORDER))
mBorderData = nsnull;
if (mPaddingData && (aBits & NS_STYLE_INHERIT_PADDING))
mPaddingData = nsnull;
if (mOutlineData && (aBits & NS_STYLE_INHERIT_OUTLINE))
mOutlineData = nsnull;
if (mPositionData && (aBits & NS_STYLE_INHERIT_POSITION))
mPositionData = nsnull;
if (mTableData && (aBits & NS_STYLE_INHERIT_TABLE))
mTableData = nsnull;
if (mBackgroundData && (aBits & NS_STYLE_INHERIT_BACKGROUND))
mBackgroundData = nsnull;
if (mContentData && (aBits & NS_STYLE_INHERIT_CONTENT))
mContentData = nsnull;
if (mTextData && (aBits & NS_STYLE_INHERIT_TEXT_RESET))
mTextData = nsnull;
if (mUIData && (aBits & NS_STYLE_INHERIT_UI_RESET))
mUIData = nsnull;
#ifdef INCLUDE_XUL
if (mXULData && (aBits & NS_STYLE_INHERIT_XUL))
mXULData = nsnull;
#endif
#define STYLE_STRUCT_RESET(name, checkdata_cb) \
if (m##name##Data && (aBits & NS_STYLE_INHERIT_BIT(name))) \
m##name##Data = nsnull;
#define STYLE_STRUCT_INHERITED(name, checkdata_cb)
#include "nsStyleStructList.h"
#undef STYLE_STRUCT_RESET
#undef STYLE_STRUCT_INHERITED
};
void Destroy(PRUint32 aBits, nsIPresContext* aContext) {
if (mDisplayData && !(aBits & NS_STYLE_INHERIT_DISPLAY))
mDisplayData->Destroy(aContext);
if (mMarginData && !(aBits & NS_STYLE_INHERIT_MARGIN))
mMarginData->Destroy(aContext);
if (mBorderData && !(aBits & NS_STYLE_INHERIT_BORDER))
mBorderData->Destroy(aContext);
if (mPaddingData && !(aBits & NS_STYLE_INHERIT_PADDING))
mPaddingData->Destroy(aContext);
if (mOutlineData && !(aBits & NS_STYLE_INHERIT_OUTLINE))
mOutlineData->Destroy(aContext);
if (mPositionData && !(aBits & NS_STYLE_INHERIT_POSITION))
mPositionData->Destroy(aContext);
if (mTableData && !(aBits & NS_STYLE_INHERIT_TABLE))
mTableData->Destroy(aContext);
if (mBackgroundData && !(aBits & NS_STYLE_INHERIT_BACKGROUND))
mBackgroundData->Destroy(aContext);
if (mContentData && !(aBits & NS_STYLE_INHERIT_CONTENT))
mContentData->Destroy(aContext);
if (mTextData && !(aBits & NS_STYLE_INHERIT_TEXT_RESET))
mTextData->Destroy(aContext);
if (mUIData && !(aBits & NS_STYLE_INHERIT_UI_RESET))
mUIData->Destroy(aContext);
#ifdef INCLUDE_XUL
if (mXULData && !(aBits & NS_STYLE_INHERIT_XUL))
mXULData->Destroy(aContext);
#endif
#define STYLE_STRUCT_RESET(name, checkdata_cb) \
if (m##name##Data && !(aBits & NS_STYLE_INHERIT_BIT(name))) \
m##name##Data->Destroy(aContext);
#define STYLE_STRUCT_INHERITED(name, checkdata_cb)
#include "nsStyleStructList.h"
#undef STYLE_STRUCT_RESET
#undef STYLE_STRUCT_INHERITED
aContext->FreeToShell(sizeof(nsResetStyleData), this);
};
nsStyleDisplay* mDisplayData;
nsStyleMargin* mMarginData;
nsStyleBorder* mBorderData;
nsStylePadding* mPaddingData;
nsStyleOutline* mOutlineData;
nsStylePosition* mPositionData;
nsStyleTable* mTableData;
nsStyleBackground* mBackgroundData;
nsStyleContent* mContentData;
nsStyleTextReset* mTextData;
nsStyleUIReset* mUIData;
#ifdef INCLUDE_XUL
nsStyleXUL* mXULData;
#endif
#define STYLE_STRUCT_RESET(name, checkdata_cb) \
nsStyle##name * m##name##Data;
#define STYLE_STRUCT_INHERITED(name, checkdata_cb)
#include "nsStyleStructList.h"
#undef STYLE_STRUCT_RESET
#undef STYLE_STRUCT_INHERITED
};
struct nsCachedStyleData
@ -241,10 +186,11 @@ struct nsCachedStyleData
};
static PRUint32 GetBitForSID(const nsStyleStructID& aSID) {
return 1 << (aSID - 1);
return 1 << aSID;
};
nsStyleStruct* GetStyleData(const nsStyleStructID& aSID) {
// NOTE: nsStyleContext::SetStyle works roughly the same way.
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));
@ -508,10 +454,12 @@ protected:
nsIStyleContext* aContext,
nsRuleNode* aHighestNode,
const RuleDetail& aRuleDetail, PRBool aInherited);
const nsStyleStruct* ComputeUIData(nsStyleStruct* aStartData, const nsCSSStruct& aData,
nsIStyleContext* aContext,
nsRuleNode* aHighestNode,
const RuleDetail& aRuleDetail, PRBool aInherited);
const nsStyleStruct* ComputeUserInterfaceData(nsStyleStruct* aStartData,
const nsCSSStruct& aData,
nsIStyleContext* aContext,
nsRuleNode* aHighestNode,
const RuleDetail& aRuleDetail,
PRBool aInherited);
const nsStyleStruct* ComputeUIResetData(nsStyleStruct* aStartData, const nsCSSStruct& aData,
nsIStyleContext* aContext,
nsRuleNode* aHighestNode,
@ -560,7 +508,7 @@ protected:
const nsStyleStruct* GetQuotesData(nsIStyleContext* aContext, PRBool aComputeData);
const nsStyleStruct* GetTextData(nsIStyleContext* aContext, PRBool aComputeData);
const nsStyleStruct* GetTextResetData(nsIStyleContext* aContext, PRBool aComputeData);
const nsStyleStruct* GetUIData(nsIStyleContext* aContext, PRBool aComputeData);
const nsStyleStruct* GetUserInterfaceData(nsIStyleContext* aContext, PRBool aComputeData);
const nsStyleStruct* GetUIResetData(nsIStyleContext* aContext, PRBool aComputeData);
#ifdef INCLUDE_XUL
const nsStyleStruct* GetXULData(nsIStyleContext* aContext, PRBool aComputeData);

View File

@ -55,63 +55,24 @@
class nsIFrame;
enum nsStyleStructID {
eStyleStruct_Font = 1,
eStyleStruct_Color = 2,
eStyleStruct_Background = 3,
eStyleStruct_List = 4,
eStyleStruct_Position = 5,
eStyleStruct_Text = 6,
eStyleStruct_TextReset = 7,
eStyleStruct_Display = 8,
eStyleStruct_Visibility = 9,
eStyleStruct_Content = 10,
eStyleStruct_Quotes = 11,
eStyleStruct_UserInterface = 12,
eStyleStruct_UIReset = 13,
eStyleStruct_Table = 14,
eStyleStruct_TableBorder = 15,
eStyleStruct_Margin = 16,
eStyleStruct_Padding = 17,
eStyleStruct_Border = 18,
eStyleStruct_Outline = 19,
eStyleStruct_XUL = 20,
#ifdef MOZ_SVG
eStyleStruct_SVG = 21,
eStyleStruct_Max = eStyleStruct_SVG,
eStyleStruct_BorderPaddingShortcut = 22, // only for use in GetStyle()
#else
eStyleStruct_Max = eStyleStruct_XUL,
eStyleStruct_BorderPaddingShortcut = 21, // only for use in GetStyle()
#endif
eStyleStruct_Min = eStyleStruct_Font
/*
* Define the constants eStyleStruct_Font, etc.
*
* The C++ standard, section 7.2, guarantees that enums begin with 0 and
* increase by 1.
*/
#define STYLE_STRUCT(name, checkdata_cb) eStyleStruct_##name,
#include "nsStyleStructList.h"
#undef STYLE_STRUCT
nsStyleStructID_Length /* one past the end; length of 0-based list */
};
// 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)
#ifdef MOZ_SVG
#define NS_STYLE_INHERIT_SVG NS_STYLE_INHERIT_BIT(eStyleStruct_SVG)
#endif
#define NS_STYLE_INHERIT_BIT(sid_) (1 << PRInt32(eStyleStruct_##sid_))
#define NS_STYLE_INHERIT_MASK 0x00ffffff
// A bit to test whether or not we have any text decorations.

View File

@ -0,0 +1,91 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
// vim:cindent:ts=8:et:sw=4:
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 2002
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* L. David Baron <dbaron@fas.harvard.edu> (original author)
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/*
* This file is intended to be used by different parts of the code, with
* the STYLE_STRUCT macro (or the STYLE_STRUCT_INHERITED and
* STYLE_STRUCT_RESET pair of macros) defined in different ways.
*/
#ifndef STYLE_STRUCT_INHERITED
#define STYLE_STRUCT_INHERITED(name, checkdata_cb) \
STYLE_STRUCT(name, checkdata_cb)
#define UNDEF_STYLE_STRUCT_INHERITED
#endif
#ifndef STYLE_STRUCT_RESET
#define STYLE_STRUCT_RESET(name, checkdata_cb) STYLE_STRUCT(name, checkdata_cb)
#define UNDEF_STYLE_STRUCT_RESET
#endif
STYLE_STRUCT_INHERITED(Font, CheckFontCallback)
STYLE_STRUCT_INHERITED(Color, nsnull)
STYLE_STRUCT_RESET(Background, nsnull)
STYLE_STRUCT_INHERITED(List, nsnull)
STYLE_STRUCT_RESET(Position, nsnull)
STYLE_STRUCT_INHERITED(Text, nsnull)
STYLE_STRUCT_RESET(TextReset, nsnull)
STYLE_STRUCT_RESET(Display, nsnull)
STYLE_STRUCT_INHERITED(Visibility, nsnull)
STYLE_STRUCT_RESET(Content, nsnull)
STYLE_STRUCT_INHERITED(Quotes, nsnull)
STYLE_STRUCT_INHERITED(UserInterface, nsnull)
STYLE_STRUCT_RESET(UIReset, nsnull)
STYLE_STRUCT_RESET(Table, nsnull)
STYLE_STRUCT_INHERITED(TableBorder, nsnull)
STYLE_STRUCT_RESET(Margin, nsnull)
STYLE_STRUCT_RESET(Padding, nsnull)
STYLE_STRUCT_RESET(Border, nsnull)
STYLE_STRUCT_RESET(Outline, nsnull)
#ifdef INCLUDE_XUL
STYLE_STRUCT_RESET(XUL, nsnull)
#endif
#ifdef MOZ_SVG
STYLE_STRUCT_INHERITED(SVG, nsnull)
#endif
#ifdef UNDEF_STYLE_STRUCT_INHERITED
#undef STYLE_STRUCT_INHERITED
#undef UNDEF_STYLE_STRUCT_INHERITED
#endif
#ifdef UNDEF_STYLE_STRUCT_RESET
#undef STYLE_STRUCT_RESET
#undef UNDEF_STYLE_STRUCT_RESET
#endif

View File

@ -62,120 +62,20 @@
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
#define STYLE_STRUCT_INHERITED(name, checkdata_cb) \
{ offsetof(nsCachedStyleData, mInheritedData), \
offsetof(nsInheritedStyleData, m##name##Data), \
PR_FALSE },
#define STYLE_STRUCT_RESET(name, checkdata_cb) \
{ offsetof(nsCachedStyleData, mResetData), \
offsetof(nsResetStyleData, m##name##Data), \
PR_TRUE },
#ifdef MOZ_SVG
/* eStyleStruct_SVG */
{ offsetof(nsCachedStyleData, mInheritedData),
offsetof(nsInheritedStyleData, mSVGData),
PR_FALSE
},
#endif
#include "nsStyleStructList.h"
#undef STYLE_STRUCT_INHERITED
#undef STYLE_STRUCT_RESET
{ 0, 0, 0 }
};

View File

@ -107,7 +107,7 @@ public:
// XXXdwh Make this function private. It should not be possible to call this
// function from layout.
// Fill a style struct with data.
NS_IMETHOD SetStyle(nsStyleStructID aSID, const nsStyleStruct& aStruct) = 0;
NS_IMETHOD SetStyle(nsStyleStructID aSID, nsStyleStruct* aStruct) = 0;
// Get the data for a style struct.
NS_IMETHOD GetStyle(nsStyleStructID aSID, const nsStyleStruct** aStruct) = 0;

View File

@ -696,11 +696,6 @@ struct StructCheckData {
CheckCallbackFn callback;
};
#define CHECKDATA_STRUCT(_props) \
{_props, sizeof(_props)/sizeof(PropertyCheckData), nsnull}
#define CHECKDATA_STRUCT_WITH_CALLBACK(_props, _cb) \
{_props, sizeof(_props)/sizeof(PropertyCheckData), _cb}
static void
ExamineRectProperties(const nsCSSRect* aRect,
PRUint32& aSpecifiedCount, PRUint32& aInheritedCount)
@ -975,36 +970,16 @@ static const PropertyCheckData SVGCheckProperties[] = {
};
#endif
// These are indexed by style struct ID and must stay in order!
static const StructCheckData gCheckProperties[] = {
{ nsnull, 0, nsnull}, /* empty, since no 0th SID */
CHECKDATA_STRUCT_WITH_CALLBACK(FontCheckProperties, CheckFontCallback),
CHECKDATA_STRUCT(ColorCheckProperties),
CHECKDATA_STRUCT(BackgroundCheckProperties),
CHECKDATA_STRUCT(ListCheckProperties),
CHECKDATA_STRUCT(PositionCheckProperties),
CHECKDATA_STRUCT(TextCheckProperties),
CHECKDATA_STRUCT(TextResetCheckProperties),
CHECKDATA_STRUCT(DisplayCheckProperties),
CHECKDATA_STRUCT(VisibilityCheckProperties),
CHECKDATA_STRUCT(ContentCheckProperties),
CHECKDATA_STRUCT(QuotesCheckProperties),
CHECKDATA_STRUCT(UserInterfaceCheckProperties),
CHECKDATA_STRUCT(UIResetCheckProperties),
CHECKDATA_STRUCT(TableCheckProperties),
CHECKDATA_STRUCT(TableBorderCheckProperties),
CHECKDATA_STRUCT(MarginCheckProperties),
CHECKDATA_STRUCT(PaddingCheckProperties),
CHECKDATA_STRUCT(BorderCheckProperties),
CHECKDATA_STRUCT(OutlineCheckProperties),
#ifdef INCLUDE_XUL
CHECKDATA_STRUCT(XULCheckProperties),
#endif
#ifdef MOZ_SVG
CHECKDATA_STRUCT(SVGCheckProperties),
#endif
{ nsnull, 0, nsnull} /* empty, so at least we crash reliably if someone
passes in the BorderPaddingShortcut ID */
#define STYLE_STRUCT(name, checkdata_cb) \
{name##CheckProperties, \
sizeof(name##CheckProperties)/sizeof(PropertyCheckData), \
checkdata_cb},
#include "nsStyleStructList.h"
#undef STYLE_STRUCT
{nsnull, 0, nsnull}
};
@ -1252,7 +1227,7 @@ nsRuleNode::GetTextResetData(nsIStyleContext* aContext, PRBool aComputeData)
}
const nsStyleStruct*
nsRuleNode::GetUIData(nsIStyleContext* aContext, PRBool aComputeData)
nsRuleNode::GetUserInterfaceData(nsIStyleContext* aContext, PRBool aComputeData)
{
nsCSSUserInterface uiData; // Declare a struct with null CSS values.
nsRuleData ruleData(eStyleStruct_UserInterface, mPresContext, aContext);
@ -1600,8 +1575,8 @@ nsRuleNode::WalkRuleTree(const nsStyleStructID aSID,
// it never has to go back to the rule tree for data. Instead the style context tree
// should be walked to find the data.
const nsStyleStruct* parentStruct = parentContext->GetStyleData(aSID);
aContext->AddStyleBit(bit);
aContext->SetStyle(aSID, *parentStruct);
aContext->AddStyleBit(bit); // makes const_cast OK.
aContext->SetStyle(aSID, NS_CONST_CAST(nsStyleStruct*, parentStruct));
return parentStruct;
}
else
@ -1647,115 +1622,115 @@ nsRuleNode::SetDefaultOnRoot(const nsStyleStructID aSID, nsIStyleContext* aConte
nsStyleFont* fontData = new (mPresContext) nsStyleFont(*defaultFont);
fontData->mSize = fontData->mFont.size =
ZoomFont(mPresContext, fontData->mFont.size);
aContext->SetStyle(eStyleStruct_Font, *fontData);
aContext->SetStyle(eStyleStruct_Font, fontData);
return fontData;
}
case eStyleStruct_Display:
{
nsStyleDisplay* disp = new (mPresContext) nsStyleDisplay();
aContext->SetStyle(eStyleStruct_Display, *disp);
aContext->SetStyle(eStyleStruct_Display, disp);
return disp;
}
case eStyleStruct_Visibility:
{
nsStyleVisibility* vis = new (mPresContext) nsStyleVisibility(mPresContext);
aContext->SetStyle(eStyleStruct_Visibility, *vis);
aContext->SetStyle(eStyleStruct_Visibility, vis);
return vis;
}
case eStyleStruct_Text:
{
nsStyleText* text = new (mPresContext) nsStyleText();
aContext->SetStyle(eStyleStruct_Text, *text);
aContext->SetStyle(eStyleStruct_Text, text);
return text;
}
case eStyleStruct_TextReset:
{
nsStyleTextReset* text = new (mPresContext) nsStyleTextReset();
aContext->SetStyle(eStyleStruct_TextReset, *text);
aContext->SetStyle(eStyleStruct_TextReset, text);
return text;
}
case eStyleStruct_Color:
{
nsStyleColor* color = new (mPresContext) nsStyleColor(mPresContext);
aContext->SetStyle(eStyleStruct_Color, *color);
aContext->SetStyle(eStyleStruct_Color, color);
return color;
}
case eStyleStruct_Background:
{
nsStyleBackground* bg = new (mPresContext) nsStyleBackground(mPresContext);
aContext->SetStyle(eStyleStruct_Background, *bg);
aContext->SetStyle(eStyleStruct_Background, bg);
return bg;
}
case eStyleStruct_Margin:
{
nsStyleMargin* margin = new (mPresContext) nsStyleMargin();
aContext->SetStyle(eStyleStruct_Margin, *margin);
aContext->SetStyle(eStyleStruct_Margin, margin);
return margin;
}
case eStyleStruct_Border:
{
nsStyleBorder* border = new (mPresContext) nsStyleBorder(mPresContext);
aContext->SetStyle(eStyleStruct_Border, *border);
aContext->SetStyle(eStyleStruct_Border, border);
return border;
}
case eStyleStruct_Padding:
{
nsStylePadding* padding = new (mPresContext) nsStylePadding();
aContext->SetStyle(eStyleStruct_Padding, *padding);
aContext->SetStyle(eStyleStruct_Padding, padding);
return padding;
}
case eStyleStruct_Outline:
{
nsStyleOutline* outline = new (mPresContext) nsStyleOutline(mPresContext);
aContext->SetStyle(eStyleStruct_Outline, *outline);
aContext->SetStyle(eStyleStruct_Outline, outline);
return outline;
}
case eStyleStruct_List:
{
nsStyleList* list = new (mPresContext) nsStyleList();
aContext->SetStyle(eStyleStruct_List, *list);
aContext->SetStyle(eStyleStruct_List, list);
return list;
}
case eStyleStruct_Position:
{
nsStylePosition* pos = new (mPresContext) nsStylePosition();
aContext->SetStyle(eStyleStruct_Position, *pos);
aContext->SetStyle(eStyleStruct_Position, pos);
return pos;
}
case eStyleStruct_Table:
{
nsStyleTable* table = new (mPresContext) nsStyleTable();
aContext->SetStyle(eStyleStruct_Table, *table);
aContext->SetStyle(eStyleStruct_Table, table);
return table;
}
case eStyleStruct_TableBorder:
{
nsStyleTableBorder* table = new (mPresContext) nsStyleTableBorder(mPresContext);
aContext->SetStyle(eStyleStruct_TableBorder, *table);
aContext->SetStyle(eStyleStruct_TableBorder, table);
return table;
}
case eStyleStruct_Content:
{
nsStyleContent* content = new (mPresContext) nsStyleContent();
aContext->SetStyle(eStyleStruct_Content, *content);
aContext->SetStyle(eStyleStruct_Content, content);
return content;
}
case eStyleStruct_Quotes:
{
nsStyleQuotes* quotes = new (mPresContext) nsStyleQuotes();
aContext->SetStyle(eStyleStruct_Quotes, *quotes);
aContext->SetStyle(eStyleStruct_Quotes, quotes);
return quotes;
}
case eStyleStruct_UserInterface:
{
nsStyleUserInterface* ui = new (mPresContext) nsStyleUserInterface();
aContext->SetStyle(eStyleStruct_UserInterface, *ui);
aContext->SetStyle(eStyleStruct_UserInterface, ui);
return ui;
}
case eStyleStruct_UIReset:
{
nsStyleUIReset* ui = new (mPresContext) nsStyleUIReset();
aContext->SetStyle(eStyleStruct_UIReset, *ui);
aContext->SetStyle(eStyleStruct_UIReset, ui);
return ui;
}
@ -1763,7 +1738,7 @@ nsRuleNode::SetDefaultOnRoot(const nsStyleStructID aSID, nsIStyleContext* aConte
case eStyleStruct_XUL:
{
nsStyleXUL* xul = new (mPresContext) nsStyleXUL();
aContext->SetStyle(eStyleStruct_XUL, *xul);
aContext->SetStyle(eStyleStruct_XUL, xul);
return xul;
}
#endif
@ -1772,47 +1747,22 @@ nsRuleNode::SetDefaultOnRoot(const nsStyleStructID aSID, nsIStyleContext* aConte
case eStyleStruct_SVG:
{
nsStyleSVG* svg = new (mPresContext) nsStyleSVG();
aContext->SetStyle(eStyleStruct_SVG, *svg);
aContext->SetStyle(eStyleStruct_SVG, svg);
return svg;
}
#endif
case eStyleStruct_BorderPaddingShortcut:
NS_ERROR("unexpected SID");
}
return nsnull;
}
nsRuleNode::ComputeStyleDataFn
nsRuleNode::gComputeStyleDataFn[] = {
// Note that these must line up _exactly_ with the numeric values of
// the nsStyleStructID enum.
nsnull,
&nsRuleNode::ComputeFontData,
&nsRuleNode::ComputeColorData,
&nsRuleNode::ComputeBackgroundData,
&nsRuleNode::ComputeListData,
&nsRuleNode::ComputePositionData,
&nsRuleNode::ComputeTextData,
&nsRuleNode::ComputeTextResetData,
&nsRuleNode::ComputeDisplayData,
&nsRuleNode::ComputeVisibilityData,
&nsRuleNode::ComputeContentData,
&nsRuleNode::ComputeQuotesData,
&nsRuleNode::ComputeUIData,
&nsRuleNode::ComputeUIResetData,
&nsRuleNode::ComputeTableData,
&nsRuleNode::ComputeTableBorderData,
&nsRuleNode::ComputeMarginData,
&nsRuleNode::ComputePaddingData,
&nsRuleNode::ComputeBorderData,
&nsRuleNode::ComputeOutlineData,
#ifdef INCLUDE_XUL
&nsRuleNode::ComputeXULData,
#endif
#ifdef MOZ_SVG
&nsRuleNode::ComputeSVGData,
#endif
#define STYLE_STRUCT(name, checkdata_cb) \
&nsRuleNode::Compute##name##Data,
#include "nsStyleStructList.h"
#undef STYLE_STRUCT
nsnull
};
@ -2291,14 +2241,14 @@ nsRuleNode::ComputeFontData(nsStyleStruct* aStartStruct, const nsCSSStruct& aDat
if (inherited)
// We inherited, and therefore can't be cached in the rule node. We have to be put right on the
// style context.
aContext->SetStyle(eStyleStruct_Font, *font);
aContext->SetStyle(eStyleStruct_Font, font);
else {
// We were fully specified and can therefore be cached right on the rule node.
if (!aHighestNode->mStyleData.mInheritedData)
aHighestNode->mStyleData.mInheritedData = new (mPresContext) nsInheritedStyleData;
aHighestNode->mStyleData.mInheritedData->mFontData = font;
// Propagate the bit down.
PropagateDependentBit(NS_STYLE_INHERIT_FONT, aHighestNode);
PropagateDependentBit(NS_STYLE_INHERIT_BIT(Font), aHighestNode);
}
return font;
@ -2411,14 +2361,14 @@ nsRuleNode::ComputeTextData(nsStyleStruct* aStartStruct, const nsCSSStruct& aDat
if (inherited)
// We inherited, and therefore can't be cached in the rule node. We have to be put right on the
// style context.
aContext->SetStyle(eStyleStruct_Text, *text);
aContext->SetStyle(eStyleStruct_Text, text);
else {
// We were fully specified and can therefore be cached right on the rule node.
if (!aHighestNode->mStyleData.mInheritedData)
aHighestNode->mStyleData.mInheritedData = new (mPresContext) nsInheritedStyleData;
aHighestNode->mStyleData.mInheritedData->mTextData = text;
// Propagate the bit down.
PropagateDependentBit(NS_STYLE_INHERIT_TEXT, aHighestNode);
PropagateDependentBit(NS_STYLE_INHERIT_BIT(Text), aHighestNode);
}
return text;
@ -2483,24 +2433,26 @@ nsRuleNode::ComputeTextResetData(nsStyleStruct* aStartData, const nsCSSStruct& a
if (inherited)
// We inherited, and therefore can't be cached in the rule node. We have to be put right on the
// style context.
aContext->SetStyle(eStyleStruct_TextReset, *text);
aContext->SetStyle(eStyleStruct_TextReset, text);
else {
// We were fully specified and can therefore be cached right on the rule node.
if (!aHighestNode->mStyleData.mResetData)
aHighestNode->mStyleData.mResetData = new (mPresContext) nsResetStyleData;
aHighestNode->mStyleData.mResetData->mTextData = text;
aHighestNode->mStyleData.mResetData->mTextResetData = text;
// Propagate the bit down.
PropagateDependentBit(NS_STYLE_INHERIT_TEXT_RESET, aHighestNode);
PropagateDependentBit(NS_STYLE_INHERIT_BIT(TextReset), aHighestNode);
}
return text;
}
const nsStyleStruct*
nsRuleNode::ComputeUIData(nsStyleStruct* aStartData, const nsCSSStruct& aData,
nsIStyleContext* aContext,
nsRuleNode* aHighestNode,
const RuleDetail& aRuleDetail, PRBool aInherited)
nsRuleNode::ComputeUserInterfaceData(nsStyleStruct* aStartData,
const nsCSSStruct& aData,
nsIStyleContext* aContext,
nsRuleNode* aHighestNode,
const RuleDetail& aRuleDetail,
PRBool aInherited)
{
nsCOMPtr<nsIStyleContext> parentContext = getter_AddRefs(aContext->GetParent());
@ -2593,14 +2545,14 @@ nsRuleNode::ComputeUIData(nsStyleStruct* aStartData, const nsCSSStruct& aData,
if (inherited)
// We inherited, and therefore can't be cached in the rule node. We have to be put right on the
// style context.
aContext->SetStyle(eStyleStruct_UserInterface, *ui);
aContext->SetStyle(eStyleStruct_UserInterface, ui);
else {
// We were fully specified and can therefore be cached right on the rule node.
if (!aHighestNode->mStyleData.mInheritedData)
aHighestNode->mStyleData.mInheritedData = new (mPresContext) nsInheritedStyleData;
aHighestNode->mStyleData.mInheritedData->mUIData = ui;
aHighestNode->mStyleData.mInheritedData->mUserInterfaceData = ui;
// Propagate the bit down.
PropagateDependentBit(NS_STYLE_INHERIT_UI, aHighestNode);
PropagateDependentBit(NS_STYLE_INHERIT_BIT(UserInterface), aHighestNode);
}
return ui;
@ -2682,14 +2634,14 @@ nsRuleNode::ComputeUIResetData(nsStyleStruct* aStartData, const nsCSSStruct& aDa
if (inherited)
// We inherited, and therefore can't be cached in the rule node. We have to be put right on the
// style context.
aContext->SetStyle(eStyleStruct_UIReset, *ui);
aContext->SetStyle(eStyleStruct_UIReset, ui);
else {
// We were fully specified and can therefore be cached right on the rule node.
if (!aHighestNode->mStyleData.mResetData)
aHighestNode->mStyleData.mResetData = new (mPresContext) nsResetStyleData;
aHighestNode->mStyleData.mResetData->mUIData = ui;
aHighestNode->mStyleData.mResetData->mUIResetData = ui;
// Propagate the bit down.
PropagateDependentBit(NS_STYLE_INHERIT_UI_RESET, aHighestNode);
PropagateDependentBit(NS_STYLE_INHERIT_BIT(UIReset), aHighestNode);
}
return ui;
@ -2878,14 +2830,14 @@ nsRuleNode::ComputeDisplayData(nsStyleStruct* aStartStruct, const nsCSSStruct& a
if (inherited)
// We inherited, and therefore can't be cached in the rule node. We have to be put right on the
// style context.
aContext->SetStyle(eStyleStruct_Display, *display);
aContext->SetStyle(eStyleStruct_Display, display);
else {
// We were fully specified and can therefore be cached right on the rule node.
if (!aHighestNode->mStyleData.mResetData)
aHighestNode->mStyleData.mResetData = new (mPresContext) nsResetStyleData;
aHighestNode->mStyleData.mResetData->mDisplayData = display;
// Propagate the bit down.
PropagateDependentBit(NS_STYLE_INHERIT_DISPLAY, aHighestNode);
PropagateDependentBit(NS_STYLE_INHERIT_BIT(Display), aHighestNode);
}
// CSS2 specified fixups:
@ -3030,14 +2982,14 @@ nsRuleNode::ComputeVisibilityData(nsStyleStruct* aStartStruct, const nsCSSStruct
if (inherited)
// We inherited, and therefore can't be cached in the rule node. We have to be put right on the
// style context.
aContext->SetStyle(eStyleStruct_Visibility, *visibility);
aContext->SetStyle(eStyleStruct_Visibility, visibility);
else {
// We were fully specified and can therefore be cached right on the rule node.
if (!aHighestNode->mStyleData.mInheritedData)
aHighestNode->mStyleData.mInheritedData = new (mPresContext) nsInheritedStyleData;
aHighestNode->mStyleData.mInheritedData->mVisibilityData = visibility;
// Propagate the bit down.
PropagateDependentBit(NS_STYLE_INHERIT_VISIBILITY, aHighestNode);
PropagateDependentBit(NS_STYLE_INHERIT_BIT(Visibility), aHighestNode);
}
return visibility;
@ -3086,14 +3038,14 @@ nsRuleNode::ComputeColorData(nsStyleStruct* aStartStruct, const nsCSSStruct& aDa
if (inherited)
// We inherited, and therefore can't be cached in the rule node. We have to be put right on the
// style context.
aContext->SetStyle(eStyleStruct_Color, *color);
aContext->SetStyle(eStyleStruct_Color, color);
else {
// We were fully specified and can therefore be cached right on the rule node.
if (!aHighestNode->mStyleData.mInheritedData)
aHighestNode->mStyleData.mInheritedData = new (mPresContext) nsInheritedStyleData;
aHighestNode->mStyleData.mInheritedData->mColorData = color;
// Propagate the bit down.
PropagateDependentBit(NS_STYLE_INHERIT_COLOR, aHighestNode);
PropagateDependentBit(NS_STYLE_INHERIT_BIT(Color), aHighestNode);
}
return color;
@ -3227,14 +3179,14 @@ nsRuleNode::ComputeBackgroundData(nsStyleStruct* aStartStruct, const nsCSSStruct
if (inherited)
// We inherited, and therefore can't be cached in the rule node. We have to be put right on the
// style context.
aContext->SetStyle(eStyleStruct_Background, *bg);
aContext->SetStyle(eStyleStruct_Background, bg);
else {
// We were fully specified and can therefore be cached right on the rule node.
if (!aHighestNode->mStyleData.mResetData)
aHighestNode->mStyleData.mResetData = new (mPresContext) nsResetStyleData;
aHighestNode->mStyleData.mResetData->mBackgroundData = bg;
// Propagate the bit down.
PropagateDependentBit(NS_STYLE_INHERIT_BACKGROUND, aHighestNode);
PropagateDependentBit(NS_STYLE_INHERIT_BIT(Background), aHighestNode);
}
return bg;
@ -3291,14 +3243,14 @@ nsRuleNode::ComputeMarginData(nsStyleStruct* aStartStruct, const nsCSSStruct& aD
if (inherited)
// We inherited, and therefore can't be cached in the rule node. We have to be put right on the
// style context.
aContext->SetStyle(eStyleStruct_Margin, *margin);
aContext->SetStyle(eStyleStruct_Margin, margin);
else {
// We were fully specified and can therefore be cached right on the rule node.
if (!aHighestNode->mStyleData.mResetData)
aHighestNode->mStyleData.mResetData = new (mPresContext) nsResetStyleData;
aHighestNode->mStyleData.mResetData->mMarginData = margin;
// Propagate the bit down.
PropagateDependentBit(NS_STYLE_INHERIT_MARGIN, aHighestNode);
PropagateDependentBit(NS_STYLE_INHERIT_BIT(Margin), aHighestNode);
}
margin->RecalcData();
@ -3571,14 +3523,14 @@ nsRuleNode::ComputeBorderData(nsStyleStruct* aStartStruct, const nsCSSStruct& aD
if (inherited)
// We inherited, and therefore can't be cached in the rule node. We have to be put right on the
// style context.
aContext->SetStyle(eStyleStruct_Border, *border);
aContext->SetStyle(eStyleStruct_Border, border);
else {
// We were fully specified and can therefore be cached right on the rule node.
if (!aHighestNode->mStyleData.mResetData)
aHighestNode->mStyleData.mResetData = new (mPresContext) nsResetStyleData;
aHighestNode->mStyleData.mResetData->mBorderData = border;
// Propagate the bit down.
PropagateDependentBit(NS_STYLE_INHERIT_BORDER, aHighestNode);
PropagateDependentBit(NS_STYLE_INHERIT_BIT(Border), aHighestNode);
}
border->RecalcData();
@ -3636,14 +3588,14 @@ nsRuleNode::ComputePaddingData(nsStyleStruct* aStartStruct, const nsCSSStruct& a
if (inherited)
// We inherited, and therefore can't be cached in the rule node. We have to be put right on the
// style context.
aContext->SetStyle(eStyleStruct_Padding, *padding);
aContext->SetStyle(eStyleStruct_Padding, padding);
else {
// We were fully specified and can therefore be cached right on the rule node.
if (!aHighestNode->mStyleData.mResetData)
aHighestNode->mStyleData.mResetData = new (mPresContext) nsResetStyleData;
aHighestNode->mStyleData.mResetData->mPaddingData = padding;
// Propagate the bit down.
PropagateDependentBit(NS_STYLE_INHERIT_PADDING, aHighestNode);
PropagateDependentBit(NS_STYLE_INHERIT_BIT(Padding), aHighestNode);
}
padding->RecalcData();
@ -3708,14 +3660,14 @@ nsRuleNode::ComputeOutlineData(nsStyleStruct* aStartStruct, const nsCSSStruct& a
if (inherited)
// We inherited, and therefore can't be cached in the rule node. We have to be put right on the
// style context.
aContext->SetStyle(eStyleStruct_Outline, *outline);
aContext->SetStyle(eStyleStruct_Outline, outline);
else {
// We were fully specified and can therefore be cached right on the rule node.
if (!aHighestNode->mStyleData.mResetData)
aHighestNode->mStyleData.mResetData = new (mPresContext) nsResetStyleData;
aHighestNode->mStyleData.mResetData->mOutlineData = outline;
// Propagate the bit down.
PropagateDependentBit(NS_STYLE_INHERIT_OUTLINE, aHighestNode);
PropagateDependentBit(NS_STYLE_INHERIT_BIT(Outline), aHighestNode);
}
outline->RecalcData();
@ -3825,14 +3777,14 @@ nsRuleNode::ComputeListData(nsStyleStruct* aStartStruct, const nsCSSStruct& aDat
if (inherited)
// We inherited, and therefore can't be cached in the rule node. We have to be put right on the
// style context.
aContext->SetStyle(eStyleStruct_List, *list);
aContext->SetStyle(eStyleStruct_List, list);
else {
// We were fully specified and can therefore be cached right on the rule node.
if (!aHighestNode->mStyleData.mInheritedData)
aHighestNode->mStyleData.mInheritedData = new (mPresContext) nsInheritedStyleData;
aHighestNode->mStyleData.mInheritedData->mListData = list;
// Propagate the bit down.
PropagateDependentBit(NS_STYLE_INHERIT_LIST, aHighestNode);
PropagateDependentBit(NS_STYLE_INHERIT_BIT(List), aHighestNode);
}
return list;
@ -3933,14 +3885,14 @@ nsRuleNode::ComputePositionData(nsStyleStruct* aStartStruct, const nsCSSStruct&
if (inherited)
// We inherited, and therefore can't be cached in the rule node. We have to be put right on the
// style context.
aContext->SetStyle(eStyleStruct_Position, *pos);
aContext->SetStyle(eStyleStruct_Position, pos);
else {
// We were fully specified and can therefore be cached right on the rule node.
if (!aHighestNode->mStyleData.mResetData)
aHighestNode->mStyleData.mResetData = new (mPresContext) nsResetStyleData;
aHighestNode->mStyleData.mResetData->mPositionData = pos;
// Propagate the bit down.
PropagateDependentBit(NS_STYLE_INHERIT_POSITION, aHighestNode);
PropagateDependentBit(NS_STYLE_INHERIT_BIT(Position), aHighestNode);
}
return pos;
@ -4003,14 +3955,14 @@ nsRuleNode::ComputeTableData(nsStyleStruct* aStartStruct, const nsCSSStruct& aDa
if (inherited)
// We inherited, and therefore can't be cached in the rule node. We have to be put right on the
// style context.
aContext->SetStyle(eStyleStruct_Table, *table);
aContext->SetStyle(eStyleStruct_Table, table);
else {
// We were fully specified and can therefore be cached right on the rule node.
if (!aHighestNode->mStyleData.mResetData)
aHighestNode->mStyleData.mResetData = new (mPresContext) nsResetStyleData;
aHighestNode->mStyleData.mResetData->mTableData = table;
// Propagate the bit down.
PropagateDependentBit(NS_STYLE_INHERIT_TABLE, aHighestNode);
PropagateDependentBit(NS_STYLE_INHERIT_BIT(Table), aHighestNode);
}
return table;
@ -4101,14 +4053,14 @@ nsRuleNode::ComputeTableBorderData(nsStyleStruct* aStartStruct, const nsCSSStruc
if (inherited)
// We inherited, and therefore can't be cached in the rule node. We have to be put right on the
// style context.
aContext->SetStyle(eStyleStruct_TableBorder, *table);
aContext->SetStyle(eStyleStruct_TableBorder, table);
else {
// We were fully specified and can therefore be cached right on the rule node.
if (!aHighestNode->mStyleData.mInheritedData)
aHighestNode->mStyleData.mInheritedData = new (mPresContext) nsInheritedStyleData;
aHighestNode->mStyleData.mInheritedData->mTableData = table;
aHighestNode->mStyleData.mInheritedData->mTableBorderData = table;
// Propagate the bit down.
PropagateDependentBit(NS_STYLE_INHERIT_TABLE_BORDER, aHighestNode);
PropagateDependentBit(NS_STYLE_INHERIT_BIT(TableBorder), aHighestNode);
}
return table;
@ -4296,14 +4248,14 @@ nsRuleNode::ComputeContentData(nsStyleStruct* aStartStruct, const nsCSSStruct& a
if (inherited)
// We inherited, and therefore can't be cached in the rule node. We have to be put right on the
// style context.
aContext->SetStyle(eStyleStruct_Content, *content);
aContext->SetStyle(eStyleStruct_Content, content);
else {
// We were fully specified and can therefore be cached right on the rule node.
if (!aHighestNode->mStyleData.mResetData)
aHighestNode->mStyleData.mResetData = new (mPresContext) nsResetStyleData;
aHighestNode->mStyleData.mResetData->mContentData = content;
// Propagate the bit down.
PropagateDependentBit(NS_STYLE_INHERIT_CONTENT, aHighestNode);
PropagateDependentBit(NS_STYLE_INHERIT_BIT(Content), aHighestNode);
}
return content;
@ -4388,14 +4340,14 @@ nsRuleNode::ComputeQuotesData(nsStyleStruct* aStartStruct, const nsCSSStruct& aD
if (inherited)
// We inherited, and therefore can't be cached in the rule node. We have to be put right on the
// style context.
aContext->SetStyle(eStyleStruct_Quotes, *quotes);
aContext->SetStyle(eStyleStruct_Quotes, quotes);
else {
// We were fully specified and can therefore be cached right on the rule node.
if (!aHighestNode->mStyleData.mInheritedData)
aHighestNode->mStyleData.mInheritedData = new (mPresContext) nsInheritedStyleData;
aHighestNode->mStyleData.mInheritedData->mQuotesData = quotes;
// Propagate the bit down.
PropagateDependentBit(NS_STYLE_INHERIT_QUOTES, aHighestNode);
PropagateDependentBit(NS_STYLE_INHERIT_BIT(Quotes), aHighestNode);
}
return quotes;
@ -4483,14 +4435,14 @@ nsRuleNode::ComputeXULData(nsStyleStruct* aStartStruct, const nsCSSStruct& aData
if (inherited)
// We inherited, and therefore can't be cached in the rule node. We have to be put right on the
// style context.
aContext->SetStyle(eStyleStruct_XUL, *xul);
aContext->SetStyle(eStyleStruct_XUL, xul);
else {
// We were fully specified and can therefore be cached right on the rule node.
if (!aHighestNode->mStyleData.mResetData)
aHighestNode->mStyleData.mResetData = new (mPresContext) nsResetStyleData;
aHighestNode->mStyleData.mResetData->mXULData = xul;
// Propagate the bit down.
PropagateDependentBit(NS_STYLE_INHERIT_XUL, aHighestNode);
PropagateDependentBit(NS_STYLE_INHERIT_BIT(XUL), aHighestNode);
}
return xul;
@ -4657,14 +4609,14 @@ nsRuleNode::ComputeSVGData(nsStyleStruct* aStartStruct, const nsCSSStruct& aData
if (inherited)
// We inherited, and therefore can't be cached in the rule node. We have to be put right on the
// style context.
aContext->SetStyle(eStyleStruct_SVG, *svg);
aContext->SetStyle(eStyleStruct_SVG, svg);
else {
// We were fully specified and can therefore be cached right on the rule node.
if (!aHighestNode->mStyleData.mInheritedData)
aHighestNode->mStyleData.mInheritedData = new (mPresContext) nsInheritedStyleData;
aHighestNode->mStyleData.mInheritedData->mSVGData = svg;
// Propagate the bit down.
PropagateDependentBit(NS_STYLE_INHERIT_SVG, aHighestNode);
PropagateDependentBit(NS_STYLE_INHERIT_BIT(SVG), aHighestNode);
}
return svg;
@ -4690,34 +4642,11 @@ nsRuleNode::GetParentData(const nsStyleStructID aSID)
nsRuleNode::GetStyleDataFn
nsRuleNode::gGetStyleDataFn[] = {
// Note that these must line up _exactly_ with the numeric values of
// the nsStyleStructID enum.
nsnull,
&nsRuleNode::GetFontData,
&nsRuleNode::GetColorData,
&nsRuleNode::GetBackgroundData,
&nsRuleNode::GetListData,
&nsRuleNode::GetPositionData,
&nsRuleNode::GetTextData,
&nsRuleNode::GetTextResetData,
&nsRuleNode::GetDisplayData,
&nsRuleNode::GetVisibilityData,
&nsRuleNode::GetContentData,
&nsRuleNode::GetQuotesData,
&nsRuleNode::GetUIData,
&nsRuleNode::GetUIResetData,
&nsRuleNode::GetTableData,
&nsRuleNode::GetTableBorderData,
&nsRuleNode::GetMarginData,
&nsRuleNode::GetPaddingData,
&nsRuleNode::GetBorderData,
&nsRuleNode::GetOutlineData,
#ifdef INCLUDE_XUL
&nsRuleNode::GetXULData,
#endif
#ifdef MOZ_SVG
&nsRuleNode::GetSVGData,
#endif
#define STYLE_STRUCT(name, checkdata_cb) &nsRuleNode::Get##name##Data,
#include "nsStyleStructList.h"
#undef STYLE_STRUCT
nsnull
};

View File

@ -56,17 +56,15 @@ typedef void (*nsPostResolveFunc)(nsStyleStruct* aStyleStruct, nsRuleData* aData
struct nsInheritedStyleData
{
nsStyleVisibility* mVisibilityData;
nsStyleFont* mFontData;
nsStyleList* mListData;
nsStyleTableBorder* mTableData;
nsStyleColor* mColorData;
nsStyleQuotes* mQuotesData;
nsStyleText* mTextData;
nsStyleUserInterface* mUIData;
#ifdef MOZ_SVG
nsStyleSVG* mSVGData;
#endif
#define STYLE_STRUCT_INHERITED(name, checkdata_cb) \
nsStyle##name * m##name##Data;
#define STYLE_STRUCT_RESET(name, checkdata_cb)
#include "nsStyleStructList.h"
#undef STYLE_STRUCT_INHERITED
#undef STYLE_STRUCT_RESET
void* operator new(size_t sz, nsIPresContext* aContext) CPP_THROW_NEW {
void* result = nsnull;
@ -75,71 +73,56 @@ struct nsInheritedStyleData
};
void ClearInheritedData(PRUint32 aBits) {
if (mVisibilityData && (aBits & NS_STYLE_INHERIT_VISIBILITY))
mVisibilityData = nsnull;
if (mFontData && (aBits & NS_STYLE_INHERIT_FONT))
mFontData = nsnull;
if (mListData && (aBits & NS_STYLE_INHERIT_LIST))
mListData = nsnull;
if (mTableData && (aBits & NS_STYLE_INHERIT_TABLE_BORDER))
mTableData = nsnull;
if (mColorData && (aBits & NS_STYLE_INHERIT_COLOR))
mColorData = nsnull;
if (mQuotesData && (aBits & NS_STYLE_INHERIT_QUOTES))
mQuotesData = nsnull;
if (mTextData && (aBits & NS_STYLE_INHERIT_TEXT))
mTextData = nsnull;
if (mUIData && (aBits & NS_STYLE_INHERIT_UI))
mUIData = nsnull;
#ifdef MOZ_SVG
if (mSVGData && (aBits & NS_STYLE_INHERIT_SVG))
mSVGData = nsnull;
#endif
#define STYLE_STRUCT_INHERITED(name, checkdata_cb) \
if (m##name##Data && (aBits & NS_STYLE_INHERIT_BIT(name))) \
m##name##Data = nsnull;
#define STYLE_STRUCT_RESET(name, checkdata_cb)
#include "nsStyleStructList.h"
#undef STYLE_STRUCT_INHERITED
#undef STYLE_STRUCT_RESET
};
void Destroy(PRUint32 aBits, nsIPresContext* aContext) {
if (mVisibilityData && !(aBits & NS_STYLE_INHERIT_VISIBILITY))
mVisibilityData->Destroy(aContext);
if (mFontData && !(aBits & NS_STYLE_INHERIT_FONT))
mFontData->Destroy(aContext);
if (mListData && !(aBits & NS_STYLE_INHERIT_LIST))
mListData->Destroy(aContext);
if (mTableData && !(aBits & NS_STYLE_INHERIT_TABLE_BORDER))
mTableData->Destroy(aContext);
if (mColorData && !(aBits & NS_STYLE_INHERIT_COLOR))
mColorData->Destroy(aContext);
if (mQuotesData && !(aBits & NS_STYLE_INHERIT_QUOTES))
mQuotesData->Destroy(aContext);
if (mTextData && !(aBits & NS_STYLE_INHERIT_TEXT))
mTextData->Destroy(aContext);
if (mUIData && !(aBits & NS_STYLE_INHERIT_UI))
mUIData->Destroy(aContext);
#ifdef MOZ_SVG
if (mSVGData && !(aBits & NS_STYLE_INHERIT_SVG))
mSVGData->Destroy(aContext);
#endif
#define STYLE_STRUCT_INHERITED(name, checkdata_cb) \
if (m##name##Data && !(aBits & NS_STYLE_INHERIT_BIT(name))) \
m##name##Data->Destroy(aContext);
#define STYLE_STRUCT_RESET(name, checkdata_cb)
#include "nsStyleStructList.h"
#undef STYLE_STRUCT_INHERITED
#undef STYLE_STRUCT_RESET
aContext->FreeToShell(sizeof(nsInheritedStyleData), this);
};
nsInheritedStyleData()
:mVisibilityData(nsnull), mFontData(nsnull), mListData(nsnull),
mTableData(nsnull), mColorData(nsnull), mQuotesData(nsnull), mTextData(nsnull), mUIData(nsnull)
#ifdef MOZ_SVG
, mSVGData(nsnull)
#endif
{};
nsInheritedStyleData() {
#define STYLE_STRUCT_INHERITED(name, checkdata_cb) \
m##name##Data = nsnull;
#define STYLE_STRUCT_RESET(name, checkdata_cb)
#include "nsStyleStructList.h"
#undef STYLE_STRUCT_INHERITED
#undef STYLE_STRUCT_RESET
};
};
struct nsResetStyleData
{
nsResetStyleData()
:mDisplayData(nsnull), mMarginData(nsnull), mBorderData(nsnull), mPaddingData(nsnull),
mOutlineData(nsnull), mPositionData(nsnull), mTableData(nsnull), mBackgroundData(nsnull),
mContentData(nsnull), mTextData(nsnull), mUIData(nsnull)
{
#ifdef INCLUDE_XUL
mXULData = nsnull;
#endif
#define STYLE_STRUCT_RESET(name, checkdata_cb) \
m##name##Data = nsnull;
#define STYLE_STRUCT_INHERITED(name, checkdata_cb)
#include "nsStyleStructList.h"
#undef STYLE_STRUCT_RESET
#undef STYLE_STRUCT_INHERITED
};
void* operator new(size_t sz, nsIPresContext* aContext) CPP_THROW_NEW {
@ -149,78 +132,40 @@ struct nsResetStyleData
}
void ClearInheritedData(PRUint32 aBits) {
if (mDisplayData && (aBits & NS_STYLE_INHERIT_DISPLAY))
mDisplayData = nsnull;
if (mMarginData && (aBits & NS_STYLE_INHERIT_MARGIN))
mMarginData = nsnull;
if (mBorderData && (aBits & NS_STYLE_INHERIT_BORDER))
mBorderData = nsnull;
if (mPaddingData && (aBits & NS_STYLE_INHERIT_PADDING))
mPaddingData = nsnull;
if (mOutlineData && (aBits & NS_STYLE_INHERIT_OUTLINE))
mOutlineData = nsnull;
if (mPositionData && (aBits & NS_STYLE_INHERIT_POSITION))
mPositionData = nsnull;
if (mTableData && (aBits & NS_STYLE_INHERIT_TABLE))
mTableData = nsnull;
if (mBackgroundData && (aBits & NS_STYLE_INHERIT_BACKGROUND))
mBackgroundData = nsnull;
if (mContentData && (aBits & NS_STYLE_INHERIT_CONTENT))
mContentData = nsnull;
if (mTextData && (aBits & NS_STYLE_INHERIT_TEXT_RESET))
mTextData = nsnull;
if (mUIData && (aBits & NS_STYLE_INHERIT_UI_RESET))
mUIData = nsnull;
#ifdef INCLUDE_XUL
if (mXULData && (aBits & NS_STYLE_INHERIT_XUL))
mXULData = nsnull;
#endif
#define STYLE_STRUCT_RESET(name, checkdata_cb) \
if (m##name##Data && (aBits & NS_STYLE_INHERIT_BIT(name))) \
m##name##Data = nsnull;
#define STYLE_STRUCT_INHERITED(name, checkdata_cb)
#include "nsStyleStructList.h"
#undef STYLE_STRUCT_RESET
#undef STYLE_STRUCT_INHERITED
};
void Destroy(PRUint32 aBits, nsIPresContext* aContext) {
if (mDisplayData && !(aBits & NS_STYLE_INHERIT_DISPLAY))
mDisplayData->Destroy(aContext);
if (mMarginData && !(aBits & NS_STYLE_INHERIT_MARGIN))
mMarginData->Destroy(aContext);
if (mBorderData && !(aBits & NS_STYLE_INHERIT_BORDER))
mBorderData->Destroy(aContext);
if (mPaddingData && !(aBits & NS_STYLE_INHERIT_PADDING))
mPaddingData->Destroy(aContext);
if (mOutlineData && !(aBits & NS_STYLE_INHERIT_OUTLINE))
mOutlineData->Destroy(aContext);
if (mPositionData && !(aBits & NS_STYLE_INHERIT_POSITION))
mPositionData->Destroy(aContext);
if (mTableData && !(aBits & NS_STYLE_INHERIT_TABLE))
mTableData->Destroy(aContext);
if (mBackgroundData && !(aBits & NS_STYLE_INHERIT_BACKGROUND))
mBackgroundData->Destroy(aContext);
if (mContentData && !(aBits & NS_STYLE_INHERIT_CONTENT))
mContentData->Destroy(aContext);
if (mTextData && !(aBits & NS_STYLE_INHERIT_TEXT_RESET))
mTextData->Destroy(aContext);
if (mUIData && !(aBits & NS_STYLE_INHERIT_UI_RESET))
mUIData->Destroy(aContext);
#ifdef INCLUDE_XUL
if (mXULData && !(aBits & NS_STYLE_INHERIT_XUL))
mXULData->Destroy(aContext);
#endif
#define STYLE_STRUCT_RESET(name, checkdata_cb) \
if (m##name##Data && !(aBits & NS_STYLE_INHERIT_BIT(name))) \
m##name##Data->Destroy(aContext);
#define STYLE_STRUCT_INHERITED(name, checkdata_cb)
#include "nsStyleStructList.h"
#undef STYLE_STRUCT_RESET
#undef STYLE_STRUCT_INHERITED
aContext->FreeToShell(sizeof(nsResetStyleData), this);
};
nsStyleDisplay* mDisplayData;
nsStyleMargin* mMarginData;
nsStyleBorder* mBorderData;
nsStylePadding* mPaddingData;
nsStyleOutline* mOutlineData;
nsStylePosition* mPositionData;
nsStyleTable* mTableData;
nsStyleBackground* mBackgroundData;
nsStyleContent* mContentData;
nsStyleTextReset* mTextData;
nsStyleUIReset* mUIData;
#ifdef INCLUDE_XUL
nsStyleXUL* mXULData;
#endif
#define STYLE_STRUCT_RESET(name, checkdata_cb) \
nsStyle##name * m##name##Data;
#define STYLE_STRUCT_INHERITED(name, checkdata_cb)
#include "nsStyleStructList.h"
#undef STYLE_STRUCT_RESET
#undef STYLE_STRUCT_INHERITED
};
struct nsCachedStyleData
@ -241,10 +186,11 @@ struct nsCachedStyleData
};
static PRUint32 GetBitForSID(const nsStyleStructID& aSID) {
return 1 << (aSID - 1);
return 1 << aSID;
};
nsStyleStruct* GetStyleData(const nsStyleStructID& aSID) {
// NOTE: nsStyleContext::SetStyle works roughly the same way.
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));
@ -508,10 +454,12 @@ protected:
nsIStyleContext* aContext,
nsRuleNode* aHighestNode,
const RuleDetail& aRuleDetail, PRBool aInherited);
const nsStyleStruct* ComputeUIData(nsStyleStruct* aStartData, const nsCSSStruct& aData,
nsIStyleContext* aContext,
nsRuleNode* aHighestNode,
const RuleDetail& aRuleDetail, PRBool aInherited);
const nsStyleStruct* ComputeUserInterfaceData(nsStyleStruct* aStartData,
const nsCSSStruct& aData,
nsIStyleContext* aContext,
nsRuleNode* aHighestNode,
const RuleDetail& aRuleDetail,
PRBool aInherited);
const nsStyleStruct* ComputeUIResetData(nsStyleStruct* aStartData, const nsCSSStruct& aData,
nsIStyleContext* aContext,
nsRuleNode* aHighestNode,
@ -560,7 +508,7 @@ protected:
const nsStyleStruct* GetQuotesData(nsIStyleContext* aContext, PRBool aComputeData);
const nsStyleStruct* GetTextData(nsIStyleContext* aContext, PRBool aComputeData);
const nsStyleStruct* GetTextResetData(nsIStyleContext* aContext, PRBool aComputeData);
const nsStyleStruct* GetUIData(nsIStyleContext* aContext, PRBool aComputeData);
const nsStyleStruct* GetUserInterfaceData(nsIStyleContext* aContext, PRBool aComputeData);
const nsStyleStruct* GetUIResetData(nsIStyleContext* aContext, PRBool aComputeData);
#ifdef INCLUDE_XUL
const nsStyleStruct* GetXULData(nsIStyleContext* aContext, PRBool aComputeData);

View File

@ -87,7 +87,7 @@ public:
NS_IMETHOD GetBorderPaddingFor(nsStyleBorderPadding& aBorderPadding);
NS_IMETHOD GetStyle(nsStyleStructID aSID, const nsStyleStruct** aStruct);
NS_IMETHOD SetStyle(nsStyleStructID aSID, const nsStyleStruct& aStruct);
NS_IMETHOD SetStyle(nsStyleStructID aSID, nsStyleStruct* aStruct);
NS_IMETHOD GetRuleNode(nsRuleNode** aResult) { *aResult = mRuleNode; return NS_OK; };
NS_IMETHOD AddStyleBit(const PRUint32& aBit) { mBits |= aBit; return NS_OK; };
@ -162,6 +162,10 @@ nsStyleContext::nsStyleContext(nsIStyleContext* aParent,
}
ApplyStyleFixups(aPresContext);
NS_ASSERTION(NS_STYLE_INHERIT_MASK &
(1 << PRInt32(nsStyleStructID_Length - 1)) != 0,
"NS_STYLE_INHERIT_MASK must be bigger, and other bits shifted");
}
nsStyleContext::~nsStyleContext()
@ -382,33 +386,33 @@ nsStyleContext::GetUniqueStyleData(nsIPresContext* aPresContext, const nsStyleSt
case eStyleStruct_Display: {
const nsStyleDisplay* dis = (const nsStyleDisplay*)GetStyleData(aSID);
nsStyleDisplay* newDis = new (aPresContext) nsStyleDisplay(*dis);
SetStyle(aSID, *newDis);
SetStyle(aSID, newDis);
result = newDis;
mBits &= ~NS_STYLE_INHERIT_DISPLAY;
mBits &= ~NS_STYLE_INHERIT_BIT(Display);
break;
}
case eStyleStruct_Background: {
const nsStyleBackground* bg = (const nsStyleBackground*)GetStyleData(aSID);
nsStyleBackground* newBG = new (aPresContext) nsStyleBackground(*bg);
SetStyle(aSID, *newBG);
SetStyle(aSID, newBG);
result = newBG;
mBits &= ~NS_STYLE_INHERIT_BACKGROUND;
mBits &= ~NS_STYLE_INHERIT_BIT(Background);
break;
}
case eStyleStruct_Text: {
const nsStyleText* text = (const nsStyleText*)GetStyleData(aSID);
nsStyleText* newText = new (aPresContext) nsStyleText(*text);
SetStyle(aSID, *newText);
SetStyle(aSID, newText);
result = newText;
mBits &= ~NS_STYLE_INHERIT_TEXT;
mBits &= ~NS_STYLE_INHERIT_BIT(Text);
break;
}
case eStyleStruct_TextReset: {
const nsStyleTextReset* reset = (const nsStyleTextReset*)GetStyleData(aSID);
nsStyleTextReset* newReset = new (aPresContext) nsStyleTextReset(*reset);
SetStyle(aSID, *newReset);
SetStyle(aSID, newReset);
result = newReset;
mBits &= ~NS_STYLE_INHERIT_TEXT_RESET;
mBits &= ~NS_STYLE_INHERIT_BIT(TextReset);
break;
}
default:
@ -426,101 +430,37 @@ nsStyleContext::GetStyle(nsStyleStructID aSID, const nsStyleStruct** aStruct)
}
NS_IMETHODIMP
nsStyleContext::SetStyle(nsStyleStructID aSID, const nsStyleStruct& aStruct)
nsStyleContext::SetStyle(nsStyleStructID aSID, nsStyleStruct* aStruct)
{
// This method should only be called from nsRuleNode! It is not a public
// method!
nsresult result = NS_OK;
PRBool isReset = mCachedStyleData.IsReset(aSID);
if (isReset) {
if (!mCachedStyleData.mResetData) {
nsCOMPtr<nsIPresContext> presContext;
mRuleNode->GetPresContext(getter_AddRefs(presContext));
mCachedStyleData.mResetData = new (presContext.get()) nsResetStyleData;
}
} else {
if (!mCachedStyleData.mInheritedData) {
nsCOMPtr<nsIPresContext> presContext;
mRuleNode->GetPresContext(getter_AddRefs(presContext));
mCachedStyleData.mInheritedData = new (presContext.get()) nsInheritedStyleData;
}
}
NS_ASSERTION(aSID >= 0 && aSID < nsStyleStructID_Length, "out of bounds");
switch (aSID) {
case eStyleStruct_Font:
mCachedStyleData.mInheritedData->mFontData = (nsStyleFont*)(const nsStyleFont*)(&aStruct);
break;
case eStyleStruct_Color:
mCachedStyleData.mInheritedData->mColorData = (nsStyleColor*)(const nsStyleColor*)(&aStruct);
break;
case eStyleStruct_Background:
mCachedStyleData.mResetData->mBackgroundData = (nsStyleBackground*)(const nsStyleBackground*)(&aStruct);
break;
case eStyleStruct_List:
mCachedStyleData.mInheritedData->mListData = (nsStyleList*)(const nsStyleList*)(&aStruct);
break;
case eStyleStruct_Position:
mCachedStyleData.mResetData->mPositionData = (nsStylePosition*)(const nsStylePosition*)(&aStruct);
break;
case eStyleStruct_Text:
mCachedStyleData.mInheritedData->mTextData = (nsStyleText*)(const nsStyleText*)(&aStruct);
break;
case eStyleStruct_TextReset:
mCachedStyleData.mResetData->mTextData = (nsStyleTextReset*)(const nsStyleTextReset*)(&aStruct);
break;
case eStyleStruct_Display:
mCachedStyleData.mResetData->mDisplayData = (nsStyleDisplay*)(const nsStyleDisplay*)(&aStruct);
break;
case eStyleStruct_Visibility:
mCachedStyleData.mInheritedData->mVisibilityData = (nsStyleVisibility*)(const nsStyleVisibility*)(&aStruct);
break;
case eStyleStruct_Table:
mCachedStyleData.mResetData->mTableData = (nsStyleTable*)(const nsStyleTable*)(&aStruct);
break;
case eStyleStruct_TableBorder:
mCachedStyleData.mInheritedData->mTableData = (nsStyleTableBorder*)(const nsStyleTableBorder*)(&aStruct);
break;
case eStyleStruct_Content:
mCachedStyleData.mResetData->mContentData = (nsStyleContent*)(const nsStyleContent*)(&aStruct);
break;
case eStyleStruct_Quotes:
mCachedStyleData.mInheritedData->mQuotesData = (nsStyleQuotes*)(const nsStyleQuotes*)(&aStruct);
break;
case eStyleStruct_UserInterface:
mCachedStyleData.mInheritedData->mUIData = (nsStyleUserInterface*)(const nsStyleUserInterface*)(&aStruct);
break;
case eStyleStruct_UIReset:
mCachedStyleData.mResetData->mUIData = (nsStyleUIReset*)(const nsStyleUIReset*)(&aStruct);
break;
case eStyleStruct_Margin:
mCachedStyleData.mResetData->mMarginData = (nsStyleMargin*)(const nsStyleMargin*)(&aStruct);
break;
case eStyleStruct_Padding:
mCachedStyleData.mResetData->mPaddingData = (nsStylePadding*)(const nsStylePadding*)(&aStruct);
break;
case eStyleStruct_Border:
mCachedStyleData.mResetData->mBorderData = (nsStyleBorder*)(const nsStyleBorder*)(&aStruct);
break;
case eStyleStruct_Outline:
mCachedStyleData.mResetData->mOutlineData = (nsStyleOutline*)(const nsStyleOutline*)(&aStruct);
break;
#ifdef INCLUDE_XUL
case eStyleStruct_XUL:
mCachedStyleData.mResetData->mXULData = (nsStyleXUL*)(const nsStyleXUL*)(&aStruct);
break;
#endif
#ifdef MOZ_SVG
case eStyleStruct_SVG:
mCachedStyleData.mInheritedData->mSVGData = (nsStyleSVG*)(const nsStyleSVG*)(&aStruct);
break;
#endif
default:
NS_ERROR("Invalid style struct id");
result = NS_ERROR_INVALID_ARG;
break;
// NOTE: nsCachedStyleData::GetStyleData works roughly the same way.
const nsCachedStyleData::StyleStructInfo& info =
nsCachedStyleData::gInfo[aSID];
char* resetOrInheritSlot = NS_REINTERPRET_CAST(char*, &mCachedStyleData) +
info.mCachedStyleDataOffset;
char* resetOrInherit = NS_REINTERPRET_CAST(char*,
*NS_REINTERPRET_CAST(void**, resetOrInheritSlot));
if (!resetOrInherit) {
nsCOMPtr<nsIPresContext> presContext;
mRuleNode->GetPresContext(getter_AddRefs(presContext));
if (mCachedStyleData.IsReset(aSID)) {
mCachedStyleData.mResetData = new (presContext.get()) nsResetStyleData;
resetOrInherit = NS_REINTERPRET_CAST(char*, mCachedStyleData.mResetData);
} else {
mCachedStyleData.mInheritedData =
new (presContext.get()) nsInheritedStyleData;
resetOrInherit =
NS_REINTERPRET_CAST(char*, mCachedStyleData.mInheritedData);
}
}
return result;
char* dataSlot = resetOrInherit + info.mInheritResetOffset;
*NS_REINTERPRET_CAST(nsStyleStruct**, dataSlot) = aStruct;
return NS_OK;
}
void

View File

@ -55,63 +55,24 @@
class nsIFrame;
enum nsStyleStructID {
eStyleStruct_Font = 1,
eStyleStruct_Color = 2,
eStyleStruct_Background = 3,
eStyleStruct_List = 4,
eStyleStruct_Position = 5,
eStyleStruct_Text = 6,
eStyleStruct_TextReset = 7,
eStyleStruct_Display = 8,
eStyleStruct_Visibility = 9,
eStyleStruct_Content = 10,
eStyleStruct_Quotes = 11,
eStyleStruct_UserInterface = 12,
eStyleStruct_UIReset = 13,
eStyleStruct_Table = 14,
eStyleStruct_TableBorder = 15,
eStyleStruct_Margin = 16,
eStyleStruct_Padding = 17,
eStyleStruct_Border = 18,
eStyleStruct_Outline = 19,
eStyleStruct_XUL = 20,
#ifdef MOZ_SVG
eStyleStruct_SVG = 21,
eStyleStruct_Max = eStyleStruct_SVG,
eStyleStruct_BorderPaddingShortcut = 22, // only for use in GetStyle()
#else
eStyleStruct_Max = eStyleStruct_XUL,
eStyleStruct_BorderPaddingShortcut = 21, // only for use in GetStyle()
#endif
eStyleStruct_Min = eStyleStruct_Font
/*
* Define the constants eStyleStruct_Font, etc.
*
* The C++ standard, section 7.2, guarantees that enums begin with 0 and
* increase by 1.
*/
#define STYLE_STRUCT(name, checkdata_cb) eStyleStruct_##name,
#include "nsStyleStructList.h"
#undef STYLE_STRUCT
nsStyleStructID_Length /* one past the end; length of 0-based list */
};
// 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)
#ifdef MOZ_SVG
#define NS_STYLE_INHERIT_SVG NS_STYLE_INHERIT_BIT(eStyleStruct_SVG)
#endif
#define NS_STYLE_INHERIT_BIT(sid_) (1 << PRInt32(eStyleStruct_##sid_))
#define NS_STYLE_INHERIT_MASK 0x00ffffff
// A bit to test whether or not we have any text decorations.

View File

@ -0,0 +1,91 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
// vim:cindent:ts=8:et:sw=4:
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 2002
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* L. David Baron <dbaron@fas.harvard.edu> (original author)
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/*
* This file is intended to be used by different parts of the code, with
* the STYLE_STRUCT macro (or the STYLE_STRUCT_INHERITED and
* STYLE_STRUCT_RESET pair of macros) defined in different ways.
*/
#ifndef STYLE_STRUCT_INHERITED
#define STYLE_STRUCT_INHERITED(name, checkdata_cb) \
STYLE_STRUCT(name, checkdata_cb)
#define UNDEF_STYLE_STRUCT_INHERITED
#endif
#ifndef STYLE_STRUCT_RESET
#define STYLE_STRUCT_RESET(name, checkdata_cb) STYLE_STRUCT(name, checkdata_cb)
#define UNDEF_STYLE_STRUCT_RESET
#endif
STYLE_STRUCT_INHERITED(Font, CheckFontCallback)
STYLE_STRUCT_INHERITED(Color, nsnull)
STYLE_STRUCT_RESET(Background, nsnull)
STYLE_STRUCT_INHERITED(List, nsnull)
STYLE_STRUCT_RESET(Position, nsnull)
STYLE_STRUCT_INHERITED(Text, nsnull)
STYLE_STRUCT_RESET(TextReset, nsnull)
STYLE_STRUCT_RESET(Display, nsnull)
STYLE_STRUCT_INHERITED(Visibility, nsnull)
STYLE_STRUCT_RESET(Content, nsnull)
STYLE_STRUCT_INHERITED(Quotes, nsnull)
STYLE_STRUCT_INHERITED(UserInterface, nsnull)
STYLE_STRUCT_RESET(UIReset, nsnull)
STYLE_STRUCT_RESET(Table, nsnull)
STYLE_STRUCT_INHERITED(TableBorder, nsnull)
STYLE_STRUCT_RESET(Margin, nsnull)
STYLE_STRUCT_RESET(Padding, nsnull)
STYLE_STRUCT_RESET(Border, nsnull)
STYLE_STRUCT_RESET(Outline, nsnull)
#ifdef INCLUDE_XUL
STYLE_STRUCT_RESET(XUL, nsnull)
#endif
#ifdef MOZ_SVG
STYLE_STRUCT_INHERITED(SVG, nsnull)
#endif
#ifdef UNDEF_STYLE_STRUCT_INHERITED
#undef STYLE_STRUCT_INHERITED
#undef UNDEF_STYLE_STRUCT_INHERITED
#endif
#ifdef UNDEF_STYLE_STRUCT_RESET
#undef STYLE_STRUCT_RESET
#undef UNDEF_STYLE_STRUCT_RESET
#endif

View File

@ -62,120 +62,20 @@
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
#define STYLE_STRUCT_INHERITED(name, checkdata_cb) \
{ offsetof(nsCachedStyleData, mInheritedData), \
offsetof(nsInheritedStyleData, m##name##Data), \
PR_FALSE },
#define STYLE_STRUCT_RESET(name, checkdata_cb) \
{ offsetof(nsCachedStyleData, mResetData), \
offsetof(nsResetStyleData, m##name##Data), \
PR_TRUE },
#ifdef MOZ_SVG
/* eStyleStruct_SVG */
{ offsetof(nsCachedStyleData, mInheritedData),
offsetof(nsInheritedStyleData, mSVGData),
PR_FALSE
},
#endif
#include "nsStyleStructList.h"
#undef STYLE_STRUCT_INHERITED
#undef STYLE_STRUCT_RESET
{ 0, 0, 0 }
};