Classes | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes

nsStyleContext Class Reference

An nsStyleContext represents the computed style data for an element. More...

#include <nsStyleContext.h>

Collaboration diagram for nsStyleContext:

List of all members.


struct  AllocationHeader

Public Member Functions

 nsStyleContext (nsStyleContext *aParent, nsIAtom *aPseudoTag, nsCSSPseudoElements::Type aPseudoType, nsRuleNode *aRuleNode, nsPresContext *aPresContext)
 ~nsStyleContext ()
void * operator new (size_t sz, nsPresContext *aPresContext) throw ()
void Destroy ()
nsrefcnt AddRef ()
nsrefcnt Release ()
nsPresContextPresContext () const
nsStyleContextGetParent () const
nsIAtomGetPseudo () const
nsCSSPseudoElements::Type GetPseudoType () const
already_AddRefed< nsStyleContextFindChildWithRules (const nsIAtom *aPseudoTag, nsRuleNode *aRules, nsRuleNode *aRulesIfVisited, PRBool aRelevantLinkVisited)
PRBool HasTextDecorations () const
PRBool HasPseudoElementData () const
PRBool RelevantLinkVisited () const
PRBool IsLinkContext () const
PRBool IsStyleIfVisited () const
void SetIsStyleIfVisited ()
nsStyleContextGetStyleIfVisited () const
void SetStyleIfVisited (already_AddRefed< nsStyleContext > aStyleIfVisited)
void SetStyle (nsStyleStructID aSID, void *aStruct)
void SetStyleFont (nsStyleFont *aStruct)
void SetStyleColor (nsStyleColor *aStruct)
void SetStyleList (nsStyleList *aStruct)
void SetStyleText (nsStyleText *aStruct)
void SetStyleVisibility (nsStyleVisibility *aStruct)
void SetStyleQuotes (nsStyleQuotes *aStruct)
void SetStyleUserInterface (nsStyleUserInterface *aStruct)
void SetStyleTableBorder (nsStyleTableBorder *aStruct)
void SetStyleSVG (nsStyleSVG *aStruct)
nsRuleNodeGetRuleNode ()
void AddStyleBit (const PRUint32 &aBit)
void Mark ()
const void * GetStyleData (nsStyleStructID aSID)
const nsStyleFontGetStyleFont ()
const nsStyleColorGetStyleColor ()
const nsStyleBackgroundGetStyleBackground ()
const nsStyleListGetStyleList ()
const nsStylePositionGetStylePosition ()
const nsStyleTextGetStyleText ()
const nsStyleTextResetGetStyleTextReset ()
const nsStyleDisplayGetStyleDisplay ()
const nsStyleVisibilityGetStyleVisibility ()
const nsStyleContentGetStyleContent ()
const nsStyleQuotesGetStyleQuotes ()
const nsStyleUserInterfaceGetStyleUserInterface ()
const nsStyleUIResetGetStyleUIReset ()
const nsStyleTableGetStyleTable ()
const nsStyleTableBorderGetStyleTableBorder ()
const nsStyleMarginGetStyleMargin ()
const nsStylePaddingGetStylePadding ()
const nsStyleBorderGetStyleBorder ()
const nsStyleOutlineGetStyleOutline ()
const nsStyleXULGetStyleXUL ()
const nsStyleSVGGetStyleSVG ()
const nsStyleSVGResetGetStyleSVGReset ()
const nsStyleColumnGetStyleColumn ()
const nsStyleFontPeekStyleFont ()
const nsStyleColorPeekStyleColor ()
const nsStyleBackgroundPeekStyleBackground ()
const nsStyleListPeekStyleList ()
const nsStylePositionPeekStylePosition ()
const nsStyleTextPeekStyleText ()
const nsStyleTextResetPeekStyleTextReset ()
const nsStyleDisplayPeekStyleDisplay ()
const nsStyleVisibilityPeekStyleVisibility ()
const nsStyleContentPeekStyleContent ()
const nsStyleQuotesPeekStyleQuotes ()
const nsStyleUserInterfacePeekStyleUserInterface ()
const nsStyleUIResetPeekStyleUIReset ()
const nsStyleTablePeekStyleTable ()
const nsStyleTableBorderPeekStyleTableBorder ()
const nsStyleMarginPeekStyleMargin ()
const nsStylePaddingPeekStylePadding ()
const nsStyleBorderPeekStyleBorder ()
const nsStyleOutlinePeekStyleOutline ()
const nsStyleXULPeekStyleXUL ()
const nsStyleSVGPeekStyleSVG ()
const nsStyleSVGResetPeekStyleSVGReset ()
const nsStyleColumnPeekStyleColumn ()
void * GetUniqueStyleData (const nsStyleStructID &aSID)
nsChangeHint CalcStyleDifference (nsStyleContext *aOther)
nscolor GetVisitedDependentColor (nsCSSProperty aProperty)
 Get a color that depends on link-visitedness using this and this->GetStyleIfVisited().
void * Alloc (size_t aSize)
 Allocate a chunk of memory that is scoped to the lifetime of this style context, i.e., memory that will automatically be freed when this style context is destroyed.

Static Public Member Functions

static nscolor CombineVisitedColors (nscolor *aColors, PRBool aLinkIsVisited)
 aColors should be a two element array of nscolor in which the first color is the unvisited color and the second is the visited color.

Protected Member Functions

void AddChild (nsStyleContext *aChild)
void RemoveChild (nsStyleContext *aChild)
void ApplyStyleFixups (nsPresContext *aPresContext)
void FreeAllocations (nsPresContext *aPresContext)
const void * GetCachedStyleData (nsStyleStructID aSID)
const nsStyleFontDoGetStyleFont (PRBool aComputeData)
const nsStyleColorDoGetStyleColor (PRBool aComputeData)
const nsStyleBackgroundDoGetStyleBackground (PRBool aComputeData)
const nsStyleListDoGetStyleList (PRBool aComputeData)
const nsStylePositionDoGetStylePosition (PRBool aComputeData)
const nsStyleTextDoGetStyleText (PRBool aComputeData)
const nsStyleTextResetDoGetStyleTextReset (PRBool aComputeData)
const nsStyleDisplayDoGetStyleDisplay (PRBool aComputeData)
const nsStyleVisibilityDoGetStyleVisibility (PRBool aComputeData)
const nsStyleContentDoGetStyleContent (PRBool aComputeData)
const nsStyleQuotesDoGetStyleQuotes (PRBool aComputeData)
const nsStyleUserInterfaceDoGetStyleUserInterface (PRBool aComputeData)
const nsStyleUIResetDoGetStyleUIReset (PRBool aComputeData)
const nsStyleTableDoGetStyleTable (PRBool aComputeData)
const nsStyleTableBorderDoGetStyleTableBorder (PRBool aComputeData)
const nsStyleMarginDoGetStyleMargin (PRBool aComputeData)
const nsStylePaddingDoGetStylePadding (PRBool aComputeData)
const nsStyleBorderDoGetStyleBorder (PRBool aComputeData)
const nsStyleOutlineDoGetStyleOutline (PRBool aComputeData)
const nsStyleXULDoGetStyleXUL (PRBool aComputeData)
const nsStyleSVGDoGetStyleSVG (PRBool aComputeData)
const nsStyleSVGResetDoGetStyleSVGReset (PRBool aComputeData)
const nsStyleColumnDoGetStyleColumn (PRBool aComputeData)

Protected Attributes

nsStyleContext *const mParent
nsRefPtr< nsStyleContextmStyleIfVisited
nsCOMPtr< nsIAtommPseudoTag
nsRuleNode *const mRuleNode
nsInheritedStyleData mCachedInheritedData
PRUint32 mBits
PRUint32 mRefCnt

Detailed Description

An nsStyleContext represents the computed style data for an element.

The computed style data are stored in a set of structs (see nsStyleStruct.h) that are cached either on the style context or in the rule tree (see nsRuleNode.h for a description of this caching and how the cached structs are shared).

Since the data in |nsIStyleRule|s and |nsRuleNode|s are immutable (with a few exceptions, like system color changes), the data in an nsStyleContext are also immutable (with the additional exception of GetUniqueStyleData). When style data change, nsFrameManager::ReResolveStyleContext creates a new style context.

Style contexts are reference counted. References are generally held by: 1. the |nsIFrame|s that are using the style context and 2. any *child* style contexts (this might be the reverse of expectation, but it makes sense in this case) Style contexts participate in the mark phase of rule node garbage collection.

Constructor & Destructor Documentation

nsStyleContext::nsStyleContext ( nsStyleContext aParent,
nsIAtom aPseudoTag,
nsCSSPseudoElements::Type  aPseudoType,
nsRuleNode aRuleNode,
nsPresContext aPresContext 
nsStyleContext::~nsStyleContext (  ) 

Member Function Documentation

void nsStyleContext::AddChild ( nsStyleContext aChild  )  [protected]
nsrefcnt nsStyleContext::AddRef ( void   )  [inline]
void nsStyleContext::AddStyleBit ( const PRUint32 &  aBit  )  [inline]
void* nsStyleContext::Alloc ( size_t  aSize  ) 

Allocate a chunk of memory that is scoped to the lifetime of this style context, i.e., memory that will automatically be freed when this style context is destroyed.

This is intended for allocations that are stored on this style context or its style structs. (Use on style structs is fine since any style context to which this context's style structs are shared will be a descendant of this style context and thus keep it alive.)

This currently allocates the memory out of the pres shell arena.

It would be relatively straightforward to write a Free method for the underlying implementation, but we don't need it (or the overhead of making a doubly-linked list or other structure to support it).

WARNING: Memory allocated using this method cannot be stored in the rule tree, since rule nodes may outlive the style context.

void nsStyleContext::ApplyStyleFixups ( nsPresContext aPresContext  )  [protected]
nsChangeHint nsStyleContext::CalcStyleDifference ( nsStyleContext aOther  ) 
static nscolor nsStyleContext::CombineVisitedColors ( nscolor aColors,
PRBool  aLinkIsVisited 
) [static]

aColors should be a two element array of nscolor in which the first color is the unvisited color and the second is the visited color.

Combine the R, G, and B components of whichever of aColors should be used based on aLinkIsVisited with the A component of aColors[0].

void nsStyleContext::Destroy (  ) 
const nsStyleBackground* nsStyleContext::DoGetStyleBackground ( PRBool  aComputeData  )  [inline, protected]
const nsStyleBorder* nsStyleContext::DoGetStyleBorder ( PRBool  aComputeData  )  [inline, protected]
const nsStyleColor* nsStyleContext::DoGetStyleColor ( PRBool  aComputeData  )  [inline, protected]
const nsStyleColumn* nsStyleContext::DoGetStyleColumn ( PRBool  aComputeData  )  [inline, protected]
const nsStyleContent* nsStyleContext::DoGetStyleContent ( PRBool  aComputeData  )  [inline, protected]
const nsStyleDisplay* nsStyleContext::DoGetStyleDisplay ( PRBool  aComputeData  )  [inline, protected]
const nsStyleFont* nsStyleContext::DoGetStyleFont ( PRBool  aComputeData  )  [inline, protected]
const nsStyleList* nsStyleContext::DoGetStyleList ( PRBool  aComputeData  )  [inline, protected]
const nsStyleMargin* nsStyleContext::DoGetStyleMargin ( PRBool  aComputeData  )  [inline, protected]
const nsStyleOutline* nsStyleContext::DoGetStyleOutline ( PRBool  aComputeData  )  [inline, protected]
const nsStylePadding* nsStyleContext::DoGetStylePadding ( PRBool  aComputeData  )  [inline, protected]
const nsStylePosition* nsStyleContext::DoGetStylePosition ( PRBool  aComputeData  )  [inline, protected]
const nsStyleQuotes* nsStyleContext::DoGetStyleQuotes ( PRBool  aComputeData  )  [inline, protected]
const nsStyleSVG* nsStyleContext::DoGetStyleSVG ( PRBool  aComputeData  )  [inline, protected]
const nsStyleSVGReset* nsStyleContext::DoGetStyleSVGReset ( PRBool  aComputeData  )  [inline, protected]
const nsStyleTable* nsStyleContext::DoGetStyleTable ( PRBool  aComputeData  )  [inline, protected]
const nsStyleTableBorder* nsStyleContext::DoGetStyleTableBorder ( PRBool  aComputeData  )  [inline, protected]
const nsStyleText* nsStyleContext::DoGetStyleText ( PRBool  aComputeData  )  [inline, protected]
const nsStyleTextReset* nsStyleContext::DoGetStyleTextReset ( PRBool  aComputeData  )  [inline, protected]
const nsStyleUIReset* nsStyleContext::DoGetStyleUIReset ( PRBool  aComputeData  )  [inline, protected]
const nsStyleUserInterface* nsStyleContext::DoGetStyleUserInterface ( PRBool  aComputeData  )  [inline, protected]
const nsStyleVisibility* nsStyleContext::DoGetStyleVisibility ( PRBool  aComputeData  )  [inline, protected]
const nsStyleXUL* nsStyleContext::DoGetStyleXUL ( PRBool  aComputeData  )  [inline, protected]
already_AddRefed<nsStyleContext> nsStyleContext::FindChildWithRules ( const nsIAtom aPseudoTag,
nsRuleNode aRules,
nsRuleNode aRulesIfVisited,
PRBool  aRelevantLinkVisited 
void nsStyleContext::FreeAllocations ( nsPresContext aPresContext  )  [protected]
const void* nsStyleContext::GetCachedStyleData ( nsStyleStructID  aSID  )  [inline, protected]
nsStyleContext* nsStyleContext::GetParent (  )  const [inline]
nsIAtom* nsStyleContext::GetPseudo (  )  const [inline]
nsCSSPseudoElements::Type nsStyleContext::GetPseudoType (  )  const [inline]
nsRuleNode* nsStyleContext::GetRuleNode (  )  [inline]
const nsStyleBackground* nsStyleContext::GetStyleBackground (  )  [inline]
const nsStyleBorder* nsStyleContext::GetStyleBorder (  )  [inline]
const nsStyleColor* nsStyleContext::GetStyleColor (  )  [inline]
const nsStyleColumn* nsStyleContext::GetStyleColumn (  )  [inline]
const nsStyleContent* nsStyleContext::GetStyleContent (  )  [inline]
const void* nsStyleContext::GetStyleData ( nsStyleStructID  aSID  ) 
const nsStyleDisplay* nsStyleContext::GetStyleDisplay (  )  [inline]
const nsStyleFont* nsStyleContext::GetStyleFont (  )  [inline]
nsStyleContext* nsStyleContext::GetStyleIfVisited (  )  const [inline]
const nsStyleList* nsStyleContext::GetStyleList (  )  [inline]
const nsStyleMargin* nsStyleContext::GetStyleMargin (  )  [inline]
const nsStyleOutline* nsStyleContext::GetStyleOutline (  )  [inline]
const nsStylePadding* nsStyleContext::GetStylePadding (  )  [inline]
const nsStylePosition* nsStyleContext::GetStylePosition (  )  [inline]
const nsStyleQuotes* nsStyleContext::GetStyleQuotes (  )  [inline]
const nsStyleSVG* nsStyleContext::GetStyleSVG (  )  [inline]
const nsStyleSVGReset* nsStyleContext::GetStyleSVGReset (  )  [inline]
const nsStyleTable* nsStyleContext::GetStyleTable (  )  [inline]
const nsStyleTableBorder* nsStyleContext::GetStyleTableBorder (  )  [inline]
const nsStyleText* nsStyleContext::GetStyleText (  )  [inline]
const nsStyleTextReset* nsStyleContext::GetStyleTextReset (  )  [inline]
const nsStyleUIReset* nsStyleContext::GetStyleUIReset (  )  [inline]
const nsStyleUserInterface* nsStyleContext::GetStyleUserInterface (  )  [inline]
const nsStyleVisibility* nsStyleContext::GetStyleVisibility (  )  [inline]
const nsStyleXUL* nsStyleContext::GetStyleXUL (  )  [inline]
void* nsStyleContext::GetUniqueStyleData ( const nsStyleStructID aSID  ) 
nscolor nsStyleContext::GetVisitedDependentColor ( nsCSSProperty  aProperty  ) 

Get a color that depends on link-visitedness using this and this->GetStyleIfVisited().

aProperty must be a color-valued property that nsStyleAnimation knows how to extract. It must also be a property that we know to do change handling for in nsStyleContext::CalcDifference.

Note that if aProperty is eCSSProperty_border_*_color, this function handles -moz-use-text-color.

PRBool nsStyleContext::HasPseudoElementData (  )  const [inline]
PRBool nsStyleContext::HasTextDecorations (  )  const [inline]
PRBool nsStyleContext::IsLinkContext (  )  const [inline]
PRBool nsStyleContext::IsStyleIfVisited (  )  const [inline]
void nsStyleContext::Mark (  ) 
void* nsStyleContext::operator new ( size_t  sz,
nsPresContext aPresContext 
) throw ()
const nsStyleBackground* nsStyleContext::PeekStyleBackground (  )  [inline]
const nsStyleBorder* nsStyleContext::PeekStyleBorder (  )  [inline]
const nsStyleColor* nsStyleContext::PeekStyleColor (  )  [inline]
const nsStyleColumn* nsStyleContext::PeekStyleColumn (  )  [inline]
const nsStyleContent* nsStyleContext::PeekStyleContent (  )  [inline]
const nsStyleDisplay* nsStyleContext::PeekStyleDisplay (  )  [inline]
const nsStyleFont* nsStyleContext::PeekStyleFont (  )  [inline]
const nsStyleList* nsStyleContext::PeekStyleList (  )  [inline]
const nsStyleMargin* nsStyleContext::PeekStyleMargin (  )  [inline]
const nsStyleOutline* nsStyleContext::PeekStyleOutline (  )  [inline]
const nsStylePadding* nsStyleContext::PeekStylePadding (  )  [inline]
const nsStylePosition* nsStyleContext::PeekStylePosition (  )  [inline]
const nsStyleQuotes* nsStyleContext::PeekStyleQuotes (  )  [inline]
const nsStyleSVG* nsStyleContext::PeekStyleSVG (  )  [inline]
const nsStyleSVGReset* nsStyleContext::PeekStyleSVGReset (  )  [inline]
const nsStyleTable* nsStyleContext::PeekStyleTable (  )  [inline]
const nsStyleTableBorder* nsStyleContext::PeekStyleTableBorder (  )  [inline]
const nsStyleText* nsStyleContext::PeekStyleText (  )  [inline]
const nsStyleTextReset* nsStyleContext::PeekStyleTextReset (  )  [inline]
const nsStyleUIReset* nsStyleContext::PeekStyleUIReset (  )  [inline]
const nsStyleUserInterface* nsStyleContext::PeekStyleUserInterface (  )  [inline]
const nsStyleVisibility* nsStyleContext::PeekStyleVisibility (  )  [inline]
const nsStyleXUL* nsStyleContext::PeekStyleXUL (  )  [inline]
nsPresContext* nsStyleContext::PresContext (  )  const [inline]
nsrefcnt nsStyleContext::Release ( void   )  [inline]
PRBool nsStyleContext::RelevantLinkVisited (  )  const [inline]
void nsStyleContext::RemoveChild ( nsStyleContext aChild  )  [protected]
void nsStyleContext::SetIsStyleIfVisited (  )  [inline]
void nsStyleContext::SetStyle ( nsStyleStructID  aSID,
void *  aStruct 
void nsStyleContext::SetStyleColor ( nsStyleColor aStruct  )  [inline]
void nsStyleContext::SetStyleFont ( nsStyleFont aStruct  )  [inline]
void nsStyleContext::SetStyleIfVisited ( already_AddRefed< nsStyleContext aStyleIfVisited  )  [inline]
void nsStyleContext::SetStyleList ( nsStyleList aStruct  )  [inline]
void nsStyleContext::SetStyleQuotes ( nsStyleQuotes aStruct  )  [inline]
void nsStyleContext::SetStyleSVG ( nsStyleSVG aStruct  )  [inline]
void nsStyleContext::SetStyleTableBorder ( nsStyleTableBorder aStruct  )  [inline]
void nsStyleContext::SetStyleText ( nsStyleText aStruct  )  [inline]
void nsStyleContext::SetStyleUserInterface ( nsStyleUserInterface aStruct  )  [inline]
void nsStyleContext::SetStyleVisibility ( nsStyleVisibility aStruct  )  [inline]

Member Data Documentation

PRUint32 nsStyleContext::mBits [protected]
PRUint32 nsStyleContext::mRefCnt [protected]

The documentation for this class was generated from the following files: