added style size calculation methods

made get style data const
This commit is contained in:
peterl 1998-05-13 22:38:09 +00:00
parent cb3cb74d17
commit 084e36938f
4 changed files with 61 additions and 4 deletions

View File

@ -142,7 +142,7 @@ public:
/**
* Get the style data associated with this frame
*/
NS_IMETHOD GetStyleData(const nsIID& aSID, nsStyleStruct*& aStyleStruct) = 0;
NS_IMETHOD GetStyleData(const nsIID& aSID, nsStyleStruct*& aStyleStruct) const = 0;
/**
* Accessor functions for geometric and content parent.
@ -422,6 +422,16 @@ public:
*/
NS_IMETHOD GetWindow(nsIWidget*&) const = 0;
/**
* Is this frame a "containing block"?
*/
NS_IMETHOD IsPercentageBase(PRBool& aBase) const = 0;
/**
* Gets the size of an "auto" margin.
*/
NS_IMETHOD GetAutoMarginSize(PRUint8 aSide, nscoord& aSize) const = 0;
/**
* Sibling pointer used to link together frames
*/

View File

@ -57,6 +57,9 @@ PRInt32 fTrackerAddListMax = 0;
PRBool gTrackerDebug = PR_FALSE;
PRBool gCalcDebug = PR_FALSE;
static NS_DEFINE_IID(kStylePositionSID, NS_STYLEPOSITION_SID);
static NS_DEFINE_IID(kStyleDisplaySID, NS_STYLEDISPLAY_SID);
// [HACK] Foward Declarations
void BuildContentList(nsIContent*aContent);
PRBool IsInRange(nsIContent * aStartContent, nsIContent * aEndContent, nsIContent * aContent);
@ -258,7 +261,7 @@ NS_METHOD nsFrame::DidSetStyleContext(nsIPresContext* aPresContext)
return NS_OK;
}
NS_METHOD nsFrame::GetStyleData(const nsIID& aSID, nsStyleStruct*& aStyleStruct)
NS_METHOD nsFrame::GetStyleData(const nsIID& aSID, nsStyleStruct*& aStyleStruct) const
{
NS_ASSERTION(mStyleContext!=nsnull,"null style context");
if (mStyleContext) {
@ -1186,6 +1189,36 @@ NS_METHOD nsFrame::GetWindow(nsIWidget*& aWindow) const
return NS_OK;
}
// Style sizing methods
NS_METHOD nsFrame::IsPercentageBase(PRBool& aBase) const
{
nsStylePosition* position;
GetStyleData(kStylePositionSID, (nsStyleStruct*&)position);
if (position->mPosition != NS_STYLE_POSITION_NORMAL) {
aBase = PR_TRUE;
}
else {
nsStyleDisplay* display;
GetStyleData(kStyleDisplaySID, (nsStyleStruct*&)display);
if ((display->mDisplay == NS_STYLE_DISPLAY_BLOCK) ||
(display->mDisplay == NS_STYLE_DISPLAY_LIST_ITEM)) {
aBase = PR_TRUE;
}
else {
aBase = PR_FALSE;
}
}
return NS_OK;
}
NS_METHOD nsFrame::GetAutoMarginSize(PRUint8 aSide, nscoord& aSize) const
{
aSize = 0; // XXX probably not right, subclass override?
return NS_OK;
}
// Sibling pointer used to link together frames
NS_METHOD nsFrame::GetNextSibling(nsIFrame*& aNextSibling) const

View File

@ -51,7 +51,7 @@ public:
NS_IMETHOD SetStyleContext(nsIPresContext* aPresContext, nsIStyleContext* aContext);
// Get the style struct associated with this frame
NS_IMETHOD GetStyleData(const nsIID& aSID, nsStyleStruct*& aStyleStruct);
NS_IMETHOD GetStyleData(const nsIID& aSID, nsStyleStruct*& aStyleStruct) const;
// Geometric and content parent
@ -167,6 +167,10 @@ public:
// a window.
NS_IMETHOD GetWindow(nsIWidget*&) const;
// Style sizing methods
NS_IMETHOD IsPercentageBase(PRBool& aBase) const;
NS_IMETHOD GetAutoMarginSize(PRUint8 aSide, nscoord& aSize) const;
// Sibling pointer used to link together frames
NS_IMETHOD GetNextSibling(nsIFrame*& aNextSibling) const;
NS_IMETHOD SetNextSibling(nsIFrame* aNextSibling);

View File

@ -142,7 +142,7 @@ public:
/**
* Get the style data associated with this frame
*/
NS_IMETHOD GetStyleData(const nsIID& aSID, nsStyleStruct*& aStyleStruct) = 0;
NS_IMETHOD GetStyleData(const nsIID& aSID, nsStyleStruct*& aStyleStruct) const = 0;
/**
* Accessor functions for geometric and content parent.
@ -422,6 +422,16 @@ public:
*/
NS_IMETHOD GetWindow(nsIWidget*&) const = 0;
/**
* Is this frame a "containing block"?
*/
NS_IMETHOD IsPercentageBase(PRBool& aBase) const = 0;
/**
* Gets the size of an "auto" margin.
*/
NS_IMETHOD GetAutoMarginSize(PRUint8 aSide, nscoord& aSize) const = 0;
/**
* Sibling pointer used to link together frames
*/