mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-31 21:21:08 +00:00
Add typesafe functions (global |GetStyleData|) for accessing style data. b=111883 r=pierre sr=hyatt
This commit is contained in:
parent
026075a4bd
commit
5720f35dba
@ -76,6 +76,7 @@ enum nsStyleStructID {
|
|||||||
eStyleStruct_Border = 18,
|
eStyleStruct_Border = 18,
|
||||||
eStyleStruct_Outline = 19,
|
eStyleStruct_Outline = 19,
|
||||||
eStyleStruct_XUL = 20,
|
eStyleStruct_XUL = 20,
|
||||||
|
eStyleStruct_Min = eStyleStruct_Font,
|
||||||
eStyleStruct_Max = eStyleStruct_XUL,
|
eStyleStruct_Max = eStyleStruct_XUL,
|
||||||
eStyleStruct_BorderPaddingShortcut = 21 // only for use in GetStyle()
|
eStyleStruct_BorderPaddingShortcut = 21 // only for use in GetStyle()
|
||||||
};
|
};
|
||||||
@ -112,6 +113,11 @@ enum nsStyleStructID {
|
|||||||
// A bit to test whether or not we have any text decorations.
|
// A bit to test whether or not we have any text decorations.
|
||||||
#define NS_STYLE_HAS_TEXT_DECORATIONS 0x200000
|
#define NS_STYLE_HAS_TEXT_DECORATIONS 0x200000
|
||||||
|
|
||||||
|
#define NS_DEFINE_STATIC_STYLESTRUCTID_ACCESSOR(the_sid) \
|
||||||
|
static const nsStyleStructID GetStyleStructID() {return the_sid;}
|
||||||
|
|
||||||
|
#define NS_GET_STYLESTRUCTID(type) (type::GetStyleStructID())
|
||||||
|
|
||||||
// The actual structs start here
|
// The actual structs start here
|
||||||
struct nsStyleStruct {
|
struct nsStyleStruct {
|
||||||
};
|
};
|
||||||
@ -122,6 +128,8 @@ struct nsStyleFont : public nsStyleStruct {
|
|||||||
nsStyleFont(void);
|
nsStyleFont(void);
|
||||||
~nsStyleFont(void) {};
|
~nsStyleFont(void) {};
|
||||||
|
|
||||||
|
NS_DEFINE_STATIC_STYLESTRUCTID_ACCESSOR(eStyleStruct_Font)
|
||||||
|
|
||||||
PRInt32 CalcDifference(const nsStyleFont& aOther) const;
|
PRInt32 CalcDifference(const nsStyleFont& aOther) const;
|
||||||
static PRInt32 CalcFontDifference(const nsFont& aFont1, const nsFont& aFont2);
|
static PRInt32 CalcFontDifference(const nsFont& aFont1, const nsFont& aFont2);
|
||||||
|
|
||||||
@ -145,6 +153,8 @@ struct nsStyleColor : public nsStyleStruct {
|
|||||||
nsStyleColor(const nsStyleColor& aOther);
|
nsStyleColor(const nsStyleColor& aOther);
|
||||||
~nsStyleColor(void) {};
|
~nsStyleColor(void) {};
|
||||||
|
|
||||||
|
NS_DEFINE_STATIC_STYLESTRUCTID_ACCESSOR(eStyleStruct_Color)
|
||||||
|
|
||||||
PRInt32 CalcDifference(const nsStyleColor& aOther) const;
|
PRInt32 CalcDifference(const nsStyleColor& aOther) const;
|
||||||
|
|
||||||
void* operator new(size_t sz, nsIPresContext* aContext) {
|
void* operator new(size_t sz, nsIPresContext* aContext) {
|
||||||
@ -167,6 +177,8 @@ struct nsStyleBackground : public nsStyleStruct {
|
|||||||
nsStyleBackground(const nsStyleBackground& aOther);
|
nsStyleBackground(const nsStyleBackground& aOther);
|
||||||
~nsStyleBackground() {};
|
~nsStyleBackground() {};
|
||||||
|
|
||||||
|
NS_DEFINE_STATIC_STYLESTRUCTID_ACCESSOR(eStyleStruct_Background)
|
||||||
|
|
||||||
void* operator new(size_t sz, nsIPresContext* aContext) {
|
void* operator new(size_t sz, nsIPresContext* aContext) {
|
||||||
void* result = nsnull;
|
void* result = nsnull;
|
||||||
aContext->AllocateFromShell(sz, &result);
|
aContext->AllocateFromShell(sz, &result);
|
||||||
@ -209,6 +221,8 @@ struct nsStyleMargin: public nsStyleStruct {
|
|||||||
nsStyleMargin(const nsStyleMargin& aMargin);
|
nsStyleMargin(const nsStyleMargin& aMargin);
|
||||||
~nsStyleMargin(void) {};
|
~nsStyleMargin(void) {};
|
||||||
|
|
||||||
|
NS_DEFINE_STATIC_STYLESTRUCTID_ACCESSOR(eStyleStruct_Margin)
|
||||||
|
|
||||||
void* operator new(size_t sz, nsIPresContext* aContext);
|
void* operator new(size_t sz, nsIPresContext* aContext);
|
||||||
void Destroy(nsIPresContext* aContext);
|
void Destroy(nsIPresContext* aContext);
|
||||||
|
|
||||||
@ -240,6 +254,8 @@ struct nsStylePadding: public nsStyleStruct {
|
|||||||
nsStylePadding(const nsStylePadding& aPadding);
|
nsStylePadding(const nsStylePadding& aPadding);
|
||||||
~nsStylePadding(void) {};
|
~nsStylePadding(void) {};
|
||||||
|
|
||||||
|
NS_DEFINE_STATIC_STYLESTRUCTID_ACCESSOR(eStyleStruct_Padding)
|
||||||
|
|
||||||
void* operator new(size_t sz, nsIPresContext* aContext);
|
void* operator new(size_t sz, nsIPresContext* aContext);
|
||||||
void Destroy(nsIPresContext* aContext);
|
void Destroy(nsIPresContext* aContext);
|
||||||
|
|
||||||
@ -272,6 +288,8 @@ struct nsStyleBorder: public nsStyleStruct {
|
|||||||
nsStyleBorder(const nsStyleBorder& aBorder);
|
nsStyleBorder(const nsStyleBorder& aBorder);
|
||||||
~nsStyleBorder(void) {};
|
~nsStyleBorder(void) {};
|
||||||
|
|
||||||
|
NS_DEFINE_STATIC_STYLESTRUCTID_ACCESSOR(eStyleStruct_Border)
|
||||||
|
|
||||||
void* operator new(size_t sz, nsIPresContext* aContext);
|
void* operator new(size_t sz, nsIPresContext* aContext);
|
||||||
void Destroy(nsIPresContext* aContext);
|
void Destroy(nsIPresContext* aContext);
|
||||||
|
|
||||||
@ -366,6 +384,9 @@ struct nsStyleBorderPadding: public nsStyleStruct {
|
|||||||
nsStyleBorderPadding(void) { mHasCachedBorderPadding = PR_FALSE; };
|
nsStyleBorderPadding(void) { mHasCachedBorderPadding = PR_FALSE; };
|
||||||
~nsStyleBorderPadding(void) {};
|
~nsStyleBorderPadding(void) {};
|
||||||
|
|
||||||
|
// No accessor for this struct, since it's not a real struct. At
|
||||||
|
// least not for now...
|
||||||
|
|
||||||
PRBool GetBorderPadding(nsMargin& aBorderPadding) const {
|
PRBool GetBorderPadding(nsMargin& aBorderPadding) const {
|
||||||
if (mHasCachedBorderPadding) {
|
if (mHasCachedBorderPadding) {
|
||||||
aBorderPadding = mCachedBorderPadding;
|
aBorderPadding = mCachedBorderPadding;
|
||||||
@ -390,6 +411,8 @@ struct nsStyleOutline: public nsStyleStruct {
|
|||||||
nsStyleOutline(const nsStyleOutline& aOutline);
|
nsStyleOutline(const nsStyleOutline& aOutline);
|
||||||
~nsStyleOutline(void) {};
|
~nsStyleOutline(void) {};
|
||||||
|
|
||||||
|
NS_DEFINE_STATIC_STYLESTRUCTID_ACCESSOR(eStyleStruct_Outline)
|
||||||
|
|
||||||
void* operator new(size_t sz, nsIPresContext* aContext) {
|
void* operator new(size_t sz, nsIPresContext* aContext) {
|
||||||
void* result = nsnull;
|
void* result = nsnull;
|
||||||
aContext->AllocateFromShell(sz, &result);
|
aContext->AllocateFromShell(sz, &result);
|
||||||
@ -472,6 +495,8 @@ struct nsStyleList : public nsStyleStruct {
|
|||||||
nsStyleList(const nsStyleList& aStyleList);
|
nsStyleList(const nsStyleList& aStyleList);
|
||||||
~nsStyleList(void);
|
~nsStyleList(void);
|
||||||
|
|
||||||
|
NS_DEFINE_STATIC_STYLESTRUCTID_ACCESSOR(eStyleStruct_List)
|
||||||
|
|
||||||
void* operator new(size_t sz, nsIPresContext* aContext) {
|
void* operator new(size_t sz, nsIPresContext* aContext) {
|
||||||
void* result = nsnull;
|
void* result = nsnull;
|
||||||
aContext->AllocateFromShell(sz, &result);
|
aContext->AllocateFromShell(sz, &result);
|
||||||
@ -494,6 +519,8 @@ struct nsStylePosition : public nsStyleStruct {
|
|||||||
nsStylePosition(const nsStylePosition& aOther);
|
nsStylePosition(const nsStylePosition& aOther);
|
||||||
~nsStylePosition(void);
|
~nsStylePosition(void);
|
||||||
|
|
||||||
|
NS_DEFINE_STATIC_STYLESTRUCTID_ACCESSOR(eStyleStruct_Position)
|
||||||
|
|
||||||
void* operator new(size_t sz, nsIPresContext* aContext) {
|
void* operator new(size_t sz, nsIPresContext* aContext) {
|
||||||
void* result = nsnull;
|
void* result = nsnull;
|
||||||
aContext->AllocateFromShell(sz, &result);
|
aContext->AllocateFromShell(sz, &result);
|
||||||
@ -523,6 +550,8 @@ struct nsStyleTextReset : public nsStyleStruct {
|
|||||||
nsStyleTextReset(const nsStyleTextReset& aOther);
|
nsStyleTextReset(const nsStyleTextReset& aOther);
|
||||||
~nsStyleTextReset(void);
|
~nsStyleTextReset(void);
|
||||||
|
|
||||||
|
NS_DEFINE_STATIC_STYLESTRUCTID_ACCESSOR(eStyleStruct_TextReset)
|
||||||
|
|
||||||
void* operator new(size_t sz, nsIPresContext* aContext) {
|
void* operator new(size_t sz, nsIPresContext* aContext) {
|
||||||
void* result = nsnull;
|
void* result = nsnull;
|
||||||
aContext->AllocateFromShell(sz, &result);
|
aContext->AllocateFromShell(sz, &result);
|
||||||
@ -548,6 +577,8 @@ struct nsStyleText : public nsStyleStruct {
|
|||||||
nsStyleText(const nsStyleText& aOther);
|
nsStyleText(const nsStyleText& aOther);
|
||||||
~nsStyleText(void);
|
~nsStyleText(void);
|
||||||
|
|
||||||
|
NS_DEFINE_STATIC_STYLESTRUCTID_ACCESSOR(eStyleStruct_Text)
|
||||||
|
|
||||||
void* operator new(size_t sz, nsIPresContext* aContext) {
|
void* operator new(size_t sz, nsIPresContext* aContext) {
|
||||||
void* result = nsnull;
|
void* result = nsnull;
|
||||||
aContext->AllocateFromShell(sz, &result);
|
aContext->AllocateFromShell(sz, &result);
|
||||||
@ -579,6 +610,8 @@ struct nsStyleVisibility : public nsStyleStruct {
|
|||||||
nsStyleVisibility(const nsStyleVisibility& aVisibility);
|
nsStyleVisibility(const nsStyleVisibility& aVisibility);
|
||||||
~nsStyleVisibility() {};
|
~nsStyleVisibility() {};
|
||||||
|
|
||||||
|
NS_DEFINE_STATIC_STYLESTRUCTID_ACCESSOR(eStyleStruct_Visibility)
|
||||||
|
|
||||||
void* operator new(size_t sz, nsIPresContext* aContext) {
|
void* operator new(size_t sz, nsIPresContext* aContext) {
|
||||||
void* result = nsnull;
|
void* result = nsnull;
|
||||||
aContext->AllocateFromShell(sz, &result);
|
aContext->AllocateFromShell(sz, &result);
|
||||||
@ -611,6 +644,8 @@ struct nsStyleDisplay : public nsStyleStruct {
|
|||||||
nsStyleDisplay(const nsStyleDisplay& aOther);
|
nsStyleDisplay(const nsStyleDisplay& aOther);
|
||||||
~nsStyleDisplay() {};
|
~nsStyleDisplay() {};
|
||||||
|
|
||||||
|
NS_DEFINE_STATIC_STYLESTRUCTID_ACCESSOR(eStyleStruct_Display)
|
||||||
|
|
||||||
void* operator new(size_t sz, nsIPresContext* aContext) {
|
void* operator new(size_t sz, nsIPresContext* aContext) {
|
||||||
void* result = nsnull;
|
void* result = nsnull;
|
||||||
aContext->AllocateFromShell(sz, &result);
|
aContext->AllocateFromShell(sz, &result);
|
||||||
@ -662,6 +697,8 @@ struct nsStyleTable: public nsStyleStruct {
|
|||||||
nsStyleTable(const nsStyleTable& aOther);
|
nsStyleTable(const nsStyleTable& aOther);
|
||||||
~nsStyleTable(void);
|
~nsStyleTable(void);
|
||||||
|
|
||||||
|
NS_DEFINE_STATIC_STYLESTRUCTID_ACCESSOR(eStyleStruct_Table)
|
||||||
|
|
||||||
void* operator new(size_t sz, nsIPresContext* aContext) {
|
void* operator new(size_t sz, nsIPresContext* aContext) {
|
||||||
void* result = nsnull;
|
void* result = nsnull;
|
||||||
aContext->AllocateFromShell(sz, &result);
|
aContext->AllocateFromShell(sz, &result);
|
||||||
@ -686,6 +723,8 @@ struct nsStyleTableBorder: public nsStyleStruct {
|
|||||||
nsStyleTableBorder(const nsStyleTableBorder& aOther);
|
nsStyleTableBorder(const nsStyleTableBorder& aOther);
|
||||||
~nsStyleTableBorder(void);
|
~nsStyleTableBorder(void);
|
||||||
|
|
||||||
|
NS_DEFINE_STATIC_STYLESTRUCTID_ACCESSOR(eStyleStruct_TableBorder)
|
||||||
|
|
||||||
void* operator new(size_t sz, nsIPresContext* aContext) {
|
void* operator new(size_t sz, nsIPresContext* aContext) {
|
||||||
void* result = nsnull;
|
void* result = nsnull;
|
||||||
aContext->AllocateFromShell(sz, &result);
|
aContext->AllocateFromShell(sz, &result);
|
||||||
@ -735,6 +774,8 @@ struct nsStyleQuotes : public nsStyleStruct {
|
|||||||
nsStyleQuotes(const nsStyleQuotes& aQuotes);
|
nsStyleQuotes(const nsStyleQuotes& aQuotes);
|
||||||
~nsStyleQuotes();
|
~nsStyleQuotes();
|
||||||
|
|
||||||
|
NS_DEFINE_STATIC_STYLESTRUCTID_ACCESSOR(eStyleStruct_Quotes)
|
||||||
|
|
||||||
void* operator new(size_t sz, nsIPresContext* aContext) {
|
void* operator new(size_t sz, nsIPresContext* aContext) {
|
||||||
void* result = nsnull;
|
void* result = nsnull;
|
||||||
aContext->AllocateFromShell(sz, &result);
|
aContext->AllocateFromShell(sz, &result);
|
||||||
@ -794,6 +835,8 @@ struct nsStyleContent: public nsStyleStruct {
|
|||||||
nsStyleContent(const nsStyleContent& aContent);
|
nsStyleContent(const nsStyleContent& aContent);
|
||||||
~nsStyleContent(void);
|
~nsStyleContent(void);
|
||||||
|
|
||||||
|
NS_DEFINE_STATIC_STYLESTRUCTID_ACCESSOR(eStyleStruct_Content)
|
||||||
|
|
||||||
void* operator new(size_t sz, nsIPresContext* aContext) {
|
void* operator new(size_t sz, nsIPresContext* aContext) {
|
||||||
void* result = nsnull;
|
void* result = nsnull;
|
||||||
aContext->AllocateFromShell(sz, &result);
|
aContext->AllocateFromShell(sz, &result);
|
||||||
@ -931,6 +974,8 @@ struct nsStyleUIReset: public nsStyleStruct {
|
|||||||
nsStyleUIReset(const nsStyleUIReset& aOther);
|
nsStyleUIReset(const nsStyleUIReset& aOther);
|
||||||
~nsStyleUIReset(void);
|
~nsStyleUIReset(void);
|
||||||
|
|
||||||
|
NS_DEFINE_STATIC_STYLESTRUCTID_ACCESSOR(eStyleStruct_UIReset)
|
||||||
|
|
||||||
void* operator new(size_t sz, nsIPresContext* aContext) {
|
void* operator new(size_t sz, nsIPresContext* aContext) {
|
||||||
void* result = nsnull;
|
void* result = nsnull;
|
||||||
aContext->AllocateFromShell(sz, &result);
|
aContext->AllocateFromShell(sz, &result);
|
||||||
@ -953,6 +998,8 @@ struct nsStyleUserInterface: public nsStyleStruct {
|
|||||||
nsStyleUserInterface(const nsStyleUserInterface& aOther);
|
nsStyleUserInterface(const nsStyleUserInterface& aOther);
|
||||||
~nsStyleUserInterface(void);
|
~nsStyleUserInterface(void);
|
||||||
|
|
||||||
|
NS_DEFINE_STATIC_STYLESTRUCTID_ACCESSOR(eStyleStruct_UserInterface)
|
||||||
|
|
||||||
void* operator new(size_t sz, nsIPresContext* aContext) {
|
void* operator new(size_t sz, nsIPresContext* aContext) {
|
||||||
void* result = nsnull;
|
void* result = nsnull;
|
||||||
aContext->AllocateFromShell(sz, &result);
|
aContext->AllocateFromShell(sz, &result);
|
||||||
@ -979,6 +1026,8 @@ struct nsStyleXUL : public nsStyleStruct {
|
|||||||
nsStyleXUL(const nsStyleXUL& aSource);
|
nsStyleXUL(const nsStyleXUL& aSource);
|
||||||
~nsStyleXUL();
|
~nsStyleXUL();
|
||||||
|
|
||||||
|
NS_DEFINE_STATIC_STYLESTRUCTID_ACCESSOR(eStyleStruct_XUL)
|
||||||
|
|
||||||
void* operator new(size_t sz, nsIPresContext* aContext) {
|
void* operator new(size_t sz, nsIPresContext* aContext) {
|
||||||
void* result = nsnull;
|
void* result = nsnull;
|
||||||
aContext->AllocateFromShell(sz, &result);
|
aContext->AllocateFromShell(sz, &result);
|
||||||
@ -1051,6 +1100,24 @@ inline nsBorderEdges::nsBorderEdges()
|
|||||||
mOutsideEdge = PR_TRUE;
|
mOutsideEdge = PR_TRUE;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// typesafe mechanisms for accessing style data
|
||||||
|
class nsIFrame;
|
||||||
|
class nsIStyleContext;
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
inline void
|
||||||
|
GetStyleData(nsIFrame* aFrame, const T** aStyleStruct)
|
||||||
|
{
|
||||||
|
aFrame->GetStyleData(NS_GET_STYLESTRUCTID(T),
|
||||||
|
*NS_REINTERPRET_CAST(const nsStyleStruct**, aStyleStruct));
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
inline void
|
||||||
|
GetStyleData(nsIStyleContext* aStyleContext, const T** aStyleStruct)
|
||||||
|
{
|
||||||
|
*aStyleStruct = NS_STATIC_CAST(const T*,
|
||||||
|
aStyleContext->GetStyleData(NS_GET_STYLESTRUCTID(T)));
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* nsStyleStruct_h___ */
|
#endif /* nsStyleStruct_h___ */
|
||||||
|
|
||||||
|
@ -76,6 +76,7 @@ enum nsStyleStructID {
|
|||||||
eStyleStruct_Border = 18,
|
eStyleStruct_Border = 18,
|
||||||
eStyleStruct_Outline = 19,
|
eStyleStruct_Outline = 19,
|
||||||
eStyleStruct_XUL = 20,
|
eStyleStruct_XUL = 20,
|
||||||
|
eStyleStruct_Min = eStyleStruct_Font,
|
||||||
eStyleStruct_Max = eStyleStruct_XUL,
|
eStyleStruct_Max = eStyleStruct_XUL,
|
||||||
eStyleStruct_BorderPaddingShortcut = 21 // only for use in GetStyle()
|
eStyleStruct_BorderPaddingShortcut = 21 // only for use in GetStyle()
|
||||||
};
|
};
|
||||||
@ -112,6 +113,11 @@ enum nsStyleStructID {
|
|||||||
// A bit to test whether or not we have any text decorations.
|
// A bit to test whether or not we have any text decorations.
|
||||||
#define NS_STYLE_HAS_TEXT_DECORATIONS 0x200000
|
#define NS_STYLE_HAS_TEXT_DECORATIONS 0x200000
|
||||||
|
|
||||||
|
#define NS_DEFINE_STATIC_STYLESTRUCTID_ACCESSOR(the_sid) \
|
||||||
|
static const nsStyleStructID GetStyleStructID() {return the_sid;}
|
||||||
|
|
||||||
|
#define NS_GET_STYLESTRUCTID(type) (type::GetStyleStructID())
|
||||||
|
|
||||||
// The actual structs start here
|
// The actual structs start here
|
||||||
struct nsStyleStruct {
|
struct nsStyleStruct {
|
||||||
};
|
};
|
||||||
@ -122,6 +128,8 @@ struct nsStyleFont : public nsStyleStruct {
|
|||||||
nsStyleFont(void);
|
nsStyleFont(void);
|
||||||
~nsStyleFont(void) {};
|
~nsStyleFont(void) {};
|
||||||
|
|
||||||
|
NS_DEFINE_STATIC_STYLESTRUCTID_ACCESSOR(eStyleStruct_Font)
|
||||||
|
|
||||||
PRInt32 CalcDifference(const nsStyleFont& aOther) const;
|
PRInt32 CalcDifference(const nsStyleFont& aOther) const;
|
||||||
static PRInt32 CalcFontDifference(const nsFont& aFont1, const nsFont& aFont2);
|
static PRInt32 CalcFontDifference(const nsFont& aFont1, const nsFont& aFont2);
|
||||||
|
|
||||||
@ -145,6 +153,8 @@ struct nsStyleColor : public nsStyleStruct {
|
|||||||
nsStyleColor(const nsStyleColor& aOther);
|
nsStyleColor(const nsStyleColor& aOther);
|
||||||
~nsStyleColor(void) {};
|
~nsStyleColor(void) {};
|
||||||
|
|
||||||
|
NS_DEFINE_STATIC_STYLESTRUCTID_ACCESSOR(eStyleStruct_Color)
|
||||||
|
|
||||||
PRInt32 CalcDifference(const nsStyleColor& aOther) const;
|
PRInt32 CalcDifference(const nsStyleColor& aOther) const;
|
||||||
|
|
||||||
void* operator new(size_t sz, nsIPresContext* aContext) {
|
void* operator new(size_t sz, nsIPresContext* aContext) {
|
||||||
@ -167,6 +177,8 @@ struct nsStyleBackground : public nsStyleStruct {
|
|||||||
nsStyleBackground(const nsStyleBackground& aOther);
|
nsStyleBackground(const nsStyleBackground& aOther);
|
||||||
~nsStyleBackground() {};
|
~nsStyleBackground() {};
|
||||||
|
|
||||||
|
NS_DEFINE_STATIC_STYLESTRUCTID_ACCESSOR(eStyleStruct_Background)
|
||||||
|
|
||||||
void* operator new(size_t sz, nsIPresContext* aContext) {
|
void* operator new(size_t sz, nsIPresContext* aContext) {
|
||||||
void* result = nsnull;
|
void* result = nsnull;
|
||||||
aContext->AllocateFromShell(sz, &result);
|
aContext->AllocateFromShell(sz, &result);
|
||||||
@ -209,6 +221,8 @@ struct nsStyleMargin: public nsStyleStruct {
|
|||||||
nsStyleMargin(const nsStyleMargin& aMargin);
|
nsStyleMargin(const nsStyleMargin& aMargin);
|
||||||
~nsStyleMargin(void) {};
|
~nsStyleMargin(void) {};
|
||||||
|
|
||||||
|
NS_DEFINE_STATIC_STYLESTRUCTID_ACCESSOR(eStyleStruct_Margin)
|
||||||
|
|
||||||
void* operator new(size_t sz, nsIPresContext* aContext);
|
void* operator new(size_t sz, nsIPresContext* aContext);
|
||||||
void Destroy(nsIPresContext* aContext);
|
void Destroy(nsIPresContext* aContext);
|
||||||
|
|
||||||
@ -240,6 +254,8 @@ struct nsStylePadding: public nsStyleStruct {
|
|||||||
nsStylePadding(const nsStylePadding& aPadding);
|
nsStylePadding(const nsStylePadding& aPadding);
|
||||||
~nsStylePadding(void) {};
|
~nsStylePadding(void) {};
|
||||||
|
|
||||||
|
NS_DEFINE_STATIC_STYLESTRUCTID_ACCESSOR(eStyleStruct_Padding)
|
||||||
|
|
||||||
void* operator new(size_t sz, nsIPresContext* aContext);
|
void* operator new(size_t sz, nsIPresContext* aContext);
|
||||||
void Destroy(nsIPresContext* aContext);
|
void Destroy(nsIPresContext* aContext);
|
||||||
|
|
||||||
@ -272,6 +288,8 @@ struct nsStyleBorder: public nsStyleStruct {
|
|||||||
nsStyleBorder(const nsStyleBorder& aBorder);
|
nsStyleBorder(const nsStyleBorder& aBorder);
|
||||||
~nsStyleBorder(void) {};
|
~nsStyleBorder(void) {};
|
||||||
|
|
||||||
|
NS_DEFINE_STATIC_STYLESTRUCTID_ACCESSOR(eStyleStruct_Border)
|
||||||
|
|
||||||
void* operator new(size_t sz, nsIPresContext* aContext);
|
void* operator new(size_t sz, nsIPresContext* aContext);
|
||||||
void Destroy(nsIPresContext* aContext);
|
void Destroy(nsIPresContext* aContext);
|
||||||
|
|
||||||
@ -366,6 +384,9 @@ struct nsStyleBorderPadding: public nsStyleStruct {
|
|||||||
nsStyleBorderPadding(void) { mHasCachedBorderPadding = PR_FALSE; };
|
nsStyleBorderPadding(void) { mHasCachedBorderPadding = PR_FALSE; };
|
||||||
~nsStyleBorderPadding(void) {};
|
~nsStyleBorderPadding(void) {};
|
||||||
|
|
||||||
|
// No accessor for this struct, since it's not a real struct. At
|
||||||
|
// least not for now...
|
||||||
|
|
||||||
PRBool GetBorderPadding(nsMargin& aBorderPadding) const {
|
PRBool GetBorderPadding(nsMargin& aBorderPadding) const {
|
||||||
if (mHasCachedBorderPadding) {
|
if (mHasCachedBorderPadding) {
|
||||||
aBorderPadding = mCachedBorderPadding;
|
aBorderPadding = mCachedBorderPadding;
|
||||||
@ -390,6 +411,8 @@ struct nsStyleOutline: public nsStyleStruct {
|
|||||||
nsStyleOutline(const nsStyleOutline& aOutline);
|
nsStyleOutline(const nsStyleOutline& aOutline);
|
||||||
~nsStyleOutline(void) {};
|
~nsStyleOutline(void) {};
|
||||||
|
|
||||||
|
NS_DEFINE_STATIC_STYLESTRUCTID_ACCESSOR(eStyleStruct_Outline)
|
||||||
|
|
||||||
void* operator new(size_t sz, nsIPresContext* aContext) {
|
void* operator new(size_t sz, nsIPresContext* aContext) {
|
||||||
void* result = nsnull;
|
void* result = nsnull;
|
||||||
aContext->AllocateFromShell(sz, &result);
|
aContext->AllocateFromShell(sz, &result);
|
||||||
@ -472,6 +495,8 @@ struct nsStyleList : public nsStyleStruct {
|
|||||||
nsStyleList(const nsStyleList& aStyleList);
|
nsStyleList(const nsStyleList& aStyleList);
|
||||||
~nsStyleList(void);
|
~nsStyleList(void);
|
||||||
|
|
||||||
|
NS_DEFINE_STATIC_STYLESTRUCTID_ACCESSOR(eStyleStruct_List)
|
||||||
|
|
||||||
void* operator new(size_t sz, nsIPresContext* aContext) {
|
void* operator new(size_t sz, nsIPresContext* aContext) {
|
||||||
void* result = nsnull;
|
void* result = nsnull;
|
||||||
aContext->AllocateFromShell(sz, &result);
|
aContext->AllocateFromShell(sz, &result);
|
||||||
@ -494,6 +519,8 @@ struct nsStylePosition : public nsStyleStruct {
|
|||||||
nsStylePosition(const nsStylePosition& aOther);
|
nsStylePosition(const nsStylePosition& aOther);
|
||||||
~nsStylePosition(void);
|
~nsStylePosition(void);
|
||||||
|
|
||||||
|
NS_DEFINE_STATIC_STYLESTRUCTID_ACCESSOR(eStyleStruct_Position)
|
||||||
|
|
||||||
void* operator new(size_t sz, nsIPresContext* aContext) {
|
void* operator new(size_t sz, nsIPresContext* aContext) {
|
||||||
void* result = nsnull;
|
void* result = nsnull;
|
||||||
aContext->AllocateFromShell(sz, &result);
|
aContext->AllocateFromShell(sz, &result);
|
||||||
@ -523,6 +550,8 @@ struct nsStyleTextReset : public nsStyleStruct {
|
|||||||
nsStyleTextReset(const nsStyleTextReset& aOther);
|
nsStyleTextReset(const nsStyleTextReset& aOther);
|
||||||
~nsStyleTextReset(void);
|
~nsStyleTextReset(void);
|
||||||
|
|
||||||
|
NS_DEFINE_STATIC_STYLESTRUCTID_ACCESSOR(eStyleStruct_TextReset)
|
||||||
|
|
||||||
void* operator new(size_t sz, nsIPresContext* aContext) {
|
void* operator new(size_t sz, nsIPresContext* aContext) {
|
||||||
void* result = nsnull;
|
void* result = nsnull;
|
||||||
aContext->AllocateFromShell(sz, &result);
|
aContext->AllocateFromShell(sz, &result);
|
||||||
@ -548,6 +577,8 @@ struct nsStyleText : public nsStyleStruct {
|
|||||||
nsStyleText(const nsStyleText& aOther);
|
nsStyleText(const nsStyleText& aOther);
|
||||||
~nsStyleText(void);
|
~nsStyleText(void);
|
||||||
|
|
||||||
|
NS_DEFINE_STATIC_STYLESTRUCTID_ACCESSOR(eStyleStruct_Text)
|
||||||
|
|
||||||
void* operator new(size_t sz, nsIPresContext* aContext) {
|
void* operator new(size_t sz, nsIPresContext* aContext) {
|
||||||
void* result = nsnull;
|
void* result = nsnull;
|
||||||
aContext->AllocateFromShell(sz, &result);
|
aContext->AllocateFromShell(sz, &result);
|
||||||
@ -579,6 +610,8 @@ struct nsStyleVisibility : public nsStyleStruct {
|
|||||||
nsStyleVisibility(const nsStyleVisibility& aVisibility);
|
nsStyleVisibility(const nsStyleVisibility& aVisibility);
|
||||||
~nsStyleVisibility() {};
|
~nsStyleVisibility() {};
|
||||||
|
|
||||||
|
NS_DEFINE_STATIC_STYLESTRUCTID_ACCESSOR(eStyleStruct_Visibility)
|
||||||
|
|
||||||
void* operator new(size_t sz, nsIPresContext* aContext) {
|
void* operator new(size_t sz, nsIPresContext* aContext) {
|
||||||
void* result = nsnull;
|
void* result = nsnull;
|
||||||
aContext->AllocateFromShell(sz, &result);
|
aContext->AllocateFromShell(sz, &result);
|
||||||
@ -611,6 +644,8 @@ struct nsStyleDisplay : public nsStyleStruct {
|
|||||||
nsStyleDisplay(const nsStyleDisplay& aOther);
|
nsStyleDisplay(const nsStyleDisplay& aOther);
|
||||||
~nsStyleDisplay() {};
|
~nsStyleDisplay() {};
|
||||||
|
|
||||||
|
NS_DEFINE_STATIC_STYLESTRUCTID_ACCESSOR(eStyleStruct_Display)
|
||||||
|
|
||||||
void* operator new(size_t sz, nsIPresContext* aContext) {
|
void* operator new(size_t sz, nsIPresContext* aContext) {
|
||||||
void* result = nsnull;
|
void* result = nsnull;
|
||||||
aContext->AllocateFromShell(sz, &result);
|
aContext->AllocateFromShell(sz, &result);
|
||||||
@ -662,6 +697,8 @@ struct nsStyleTable: public nsStyleStruct {
|
|||||||
nsStyleTable(const nsStyleTable& aOther);
|
nsStyleTable(const nsStyleTable& aOther);
|
||||||
~nsStyleTable(void);
|
~nsStyleTable(void);
|
||||||
|
|
||||||
|
NS_DEFINE_STATIC_STYLESTRUCTID_ACCESSOR(eStyleStruct_Table)
|
||||||
|
|
||||||
void* operator new(size_t sz, nsIPresContext* aContext) {
|
void* operator new(size_t sz, nsIPresContext* aContext) {
|
||||||
void* result = nsnull;
|
void* result = nsnull;
|
||||||
aContext->AllocateFromShell(sz, &result);
|
aContext->AllocateFromShell(sz, &result);
|
||||||
@ -686,6 +723,8 @@ struct nsStyleTableBorder: public nsStyleStruct {
|
|||||||
nsStyleTableBorder(const nsStyleTableBorder& aOther);
|
nsStyleTableBorder(const nsStyleTableBorder& aOther);
|
||||||
~nsStyleTableBorder(void);
|
~nsStyleTableBorder(void);
|
||||||
|
|
||||||
|
NS_DEFINE_STATIC_STYLESTRUCTID_ACCESSOR(eStyleStruct_TableBorder)
|
||||||
|
|
||||||
void* operator new(size_t sz, nsIPresContext* aContext) {
|
void* operator new(size_t sz, nsIPresContext* aContext) {
|
||||||
void* result = nsnull;
|
void* result = nsnull;
|
||||||
aContext->AllocateFromShell(sz, &result);
|
aContext->AllocateFromShell(sz, &result);
|
||||||
@ -735,6 +774,8 @@ struct nsStyleQuotes : public nsStyleStruct {
|
|||||||
nsStyleQuotes(const nsStyleQuotes& aQuotes);
|
nsStyleQuotes(const nsStyleQuotes& aQuotes);
|
||||||
~nsStyleQuotes();
|
~nsStyleQuotes();
|
||||||
|
|
||||||
|
NS_DEFINE_STATIC_STYLESTRUCTID_ACCESSOR(eStyleStruct_Quotes)
|
||||||
|
|
||||||
void* operator new(size_t sz, nsIPresContext* aContext) {
|
void* operator new(size_t sz, nsIPresContext* aContext) {
|
||||||
void* result = nsnull;
|
void* result = nsnull;
|
||||||
aContext->AllocateFromShell(sz, &result);
|
aContext->AllocateFromShell(sz, &result);
|
||||||
@ -794,6 +835,8 @@ struct nsStyleContent: public nsStyleStruct {
|
|||||||
nsStyleContent(const nsStyleContent& aContent);
|
nsStyleContent(const nsStyleContent& aContent);
|
||||||
~nsStyleContent(void);
|
~nsStyleContent(void);
|
||||||
|
|
||||||
|
NS_DEFINE_STATIC_STYLESTRUCTID_ACCESSOR(eStyleStruct_Content)
|
||||||
|
|
||||||
void* operator new(size_t sz, nsIPresContext* aContext) {
|
void* operator new(size_t sz, nsIPresContext* aContext) {
|
||||||
void* result = nsnull;
|
void* result = nsnull;
|
||||||
aContext->AllocateFromShell(sz, &result);
|
aContext->AllocateFromShell(sz, &result);
|
||||||
@ -931,6 +974,8 @@ struct nsStyleUIReset: public nsStyleStruct {
|
|||||||
nsStyleUIReset(const nsStyleUIReset& aOther);
|
nsStyleUIReset(const nsStyleUIReset& aOther);
|
||||||
~nsStyleUIReset(void);
|
~nsStyleUIReset(void);
|
||||||
|
|
||||||
|
NS_DEFINE_STATIC_STYLESTRUCTID_ACCESSOR(eStyleStruct_UIReset)
|
||||||
|
|
||||||
void* operator new(size_t sz, nsIPresContext* aContext) {
|
void* operator new(size_t sz, nsIPresContext* aContext) {
|
||||||
void* result = nsnull;
|
void* result = nsnull;
|
||||||
aContext->AllocateFromShell(sz, &result);
|
aContext->AllocateFromShell(sz, &result);
|
||||||
@ -953,6 +998,8 @@ struct nsStyleUserInterface: public nsStyleStruct {
|
|||||||
nsStyleUserInterface(const nsStyleUserInterface& aOther);
|
nsStyleUserInterface(const nsStyleUserInterface& aOther);
|
||||||
~nsStyleUserInterface(void);
|
~nsStyleUserInterface(void);
|
||||||
|
|
||||||
|
NS_DEFINE_STATIC_STYLESTRUCTID_ACCESSOR(eStyleStruct_UserInterface)
|
||||||
|
|
||||||
void* operator new(size_t sz, nsIPresContext* aContext) {
|
void* operator new(size_t sz, nsIPresContext* aContext) {
|
||||||
void* result = nsnull;
|
void* result = nsnull;
|
||||||
aContext->AllocateFromShell(sz, &result);
|
aContext->AllocateFromShell(sz, &result);
|
||||||
@ -979,6 +1026,8 @@ struct nsStyleXUL : public nsStyleStruct {
|
|||||||
nsStyleXUL(const nsStyleXUL& aSource);
|
nsStyleXUL(const nsStyleXUL& aSource);
|
||||||
~nsStyleXUL();
|
~nsStyleXUL();
|
||||||
|
|
||||||
|
NS_DEFINE_STATIC_STYLESTRUCTID_ACCESSOR(eStyleStruct_XUL)
|
||||||
|
|
||||||
void* operator new(size_t sz, nsIPresContext* aContext) {
|
void* operator new(size_t sz, nsIPresContext* aContext) {
|
||||||
void* result = nsnull;
|
void* result = nsnull;
|
||||||
aContext->AllocateFromShell(sz, &result);
|
aContext->AllocateFromShell(sz, &result);
|
||||||
@ -1051,6 +1100,24 @@ inline nsBorderEdges::nsBorderEdges()
|
|||||||
mOutsideEdge = PR_TRUE;
|
mOutsideEdge = PR_TRUE;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// typesafe mechanisms for accessing style data
|
||||||
|
class nsIFrame;
|
||||||
|
class nsIStyleContext;
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
inline void
|
||||||
|
GetStyleData(nsIFrame* aFrame, const T** aStyleStruct)
|
||||||
|
{
|
||||||
|
aFrame->GetStyleData(NS_GET_STYLESTRUCTID(T),
|
||||||
|
*NS_REINTERPRET_CAST(const nsStyleStruct**, aStyleStruct));
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
inline void
|
||||||
|
GetStyleData(nsIStyleContext* aStyleContext, const T** aStyleStruct)
|
||||||
|
{
|
||||||
|
*aStyleStruct = NS_STATIC_CAST(const T*,
|
||||||
|
aStyleContext->GetStyleData(NS_GET_STYLESTRUCTID(T)));
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* nsStyleStruct_h___ */
|
#endif /* nsStyleStruct_h___ */
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user