Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Public Attributes | 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:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 nsStyleContext (nsStyleContext *aParent, nsIAtom *aPseudoTag, nsRuleNode *aRuleNode, nsPresContext *aPresContext) NS_HIDDEN
 ~nsStyleContext () NS_HIDDEN
 NS_HIDDEN_ (void *) operator new(size_t sz
 NS_HIDDEN_ (void) Destroy()
nsrefcnt AddRef ()
nsrefcnt Release ()
nsPresContextPresContext () const
nsStyleContextGetParent () const
nsStyleContextGetFirstChild () const
nsIAtomGetPseudoType () const
 FindChildWithRules (const nsIAtom *aPseudoTag, nsRuleNode *aRules)
 NS_HIDDEN_ (PRBool) Equals(const nsStyleContext *aOther) const
PRBool HasTextDecorations ()
 NS_HIDDEN_ (void) GetBorderPaddingFor(nsStyleBorderPadding &aBorderPadding)
 NS_HIDDEN_ (void) SetStyle(nsStyleStructID aSID
nsRuleNodeGetRuleNode ()
void AddStyleBit (const PRUint32 &aBit)
 NS_HIDDEN_ (void) Mark()
 NS_HIDDEN_ (const nsStyleStruct *) NS_FASTCALL GetStyleData(nsStyleStructID aSID)
 NS_HIDDEN_ (const nsStyleStruct *) PeekStyleData(nsStyleStructID aSID)
 NS_HIDDEN_ (nsStyleStruct *) GetUniqueStyleData(const nsStyleStructID &aSID)
 NS_HIDDEN_ (void) ClearStyleData(nsPresContext *aPresContext)
 NS_HIDDEN_ (nsChangeHint) CalcStyleDifference(nsStyleContext *aOther)

Public Attributes

nsPresContext *aPresContext CPP_THROW_NEW
nsStyleStructaStruct

Protected Member Functions

 NS_HIDDEN_ (void) AppendChild(nsStyleContext *aChild)
 NS_HIDDEN_ (void) RemoveChild(nsStyleContext *aChild)
 NS_HIDDEN_ (void) ApplyStyleFixups(nsPresContext *aPresContext)

Protected Attributes

nsStyleContextmParent
nsStyleContextmChild
nsStyleContextmEmptyChild
nsStyleContextmPrevSibling
nsStyleContextmNextSibling
nsCOMPtr< nsIAtommPseudoTag
nsRuleNode *const mRuleNode
nsCachedStyleData mCachedStyleData
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.

Definition at line 70 of file nsStyleContext.h.


Constructor & Destructor Documentation

nsStyleContext::nsStyleContext ( nsStyleContext aParent,
nsIAtom aPseudoTag,
nsRuleNode aRuleNode,
nsPresContext aPresContext 
)

Definition at line 66 of file nsStyleContext.cpp.

  : mParent(aParent),
    mChild(nsnull),
    mEmptyChild(nsnull),
    mPseudoTag(aPseudoTag),
    mRuleNode(aRuleNode),
    mBits(0),
    mRefCnt(0)
{
  mNextSibling = this;
  mPrevSibling = this;
  if (mParent) {
    mParent->AddRef();
    mParent->AppendChild(this);
  }

  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");
}

Here is the call graph for this function:

Definition at line 92 of file nsStyleContext.cpp.

{
  NS_ASSERTION((nsnull == mChild) && (nsnull == mEmptyChild), "destructing context with children");

  nsPresContext *presContext = mRuleNode->GetPresContext();

  presContext->PresShell()->StyleSet()->
    NotifyStyleContextDestroyed(presContext, this);

  if (mParent) {
    mParent->RemoveChild(this);
    mParent->Release();
  }

  // Free up our data structs.
  if (mCachedStyleData.mResetData || mCachedStyleData.mInheritedData) {
    mCachedStyleData.Destroy(mBits, presContext);
  }
}

Here is the call graph for this function:


Member Function Documentation

Definition at line 80 of file nsStyleContext.h.

                    {
    ++mRefCnt;
    NS_LOG_ADDREF(this, mRefCnt, "nsStyleContext", sizeof(nsStyleContext));
    return mRefCnt;
  }

Here is the caller graph for this function:

Definition at line 115 of file nsStyleContext.h.

{ mBits |= aBit; }

Here is the caller graph for this function:

Definition at line 174 of file nsStyleContext.cpp.

{
  PRUint32 threshold = 10; // The # of siblings we're willing to examine
                           // before just giving this whole thing up.

  nsStyleContext* aResult = nsnull;

  if ((nsnull != mChild) || (nsnull != mEmptyChild)) {
    nsStyleContext* child;
    if (aRuleNode->IsRoot()) {
      if (nsnull != mEmptyChild) {
        child = mEmptyChild;
        do {
          if (aPseudoTag == child->mPseudoTag) {
            aResult = child;
            break;
          }
          child = child->mNextSibling;
          threshold--;
          if (threshold == 0)
            break;
        } while (child != mEmptyChild);
      }
    }
    else if (nsnull != mChild) {
      child = mChild;
      
      do {
        if (child->mRuleNode == aRuleNode && child->mPseudoTag == aPseudoTag) {
          aResult = child;
          break;
        }
        child = child->mNextSibling;
        threshold--;
        if (threshold == 0)
          break;
      } while (child != mChild);
    }
  }

  if (aResult)
    aResult->AddRef();

  return aResult;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 100 of file nsStyleContext.h.

{ return mChild; }

Definition at line 98 of file nsStyleContext.h.

{ return mParent; }

Here is the caller graph for this function:

Definition at line 102 of file nsStyleContext.h.

{ return mPseudoTag; }

Here is the caller graph for this function:

Definition at line 114 of file nsStyleContext.h.

{ return mRuleNode; }

Here is the caller graph for this function:

Definition at line 108 of file nsStyleContext.h.

Here is the caller graph for this function:

nsStyleContext::NS_HIDDEN_ ( void  ) [protected]
nsStyleContext::NS_HIDDEN_ ( void  ) [protected]
nsStyleContext::NS_HIDDEN_ ( void  ) [protected]

Definition at line 96 of file nsStyleContext.h.

{ return mRuleNode->GetPresContext(); }

Here is the call graph for this function:

Definition at line 86 of file nsStyleContext.h.

                     {
    --mRefCnt;
    NS_LOG_RELEASE(this, mRefCnt, "nsStyleContext");
    if (mRefCnt == 0) {
      Destroy();
      return 0;
    }
    return mRefCnt;
  }

Here is the caller graph for this function:


Member Data Documentation

Definition at line 112 of file nsStyleContext.h.

Definition at line 77 of file nsStyleContext.h.

Definition at line 211 of file nsStyleContext.h.

Definition at line 210 of file nsStyleContext.h.

Definition at line 187 of file nsStyleContext.h.

Definition at line 188 of file nsStyleContext.h.

Definition at line 190 of file nsStyleContext.h.

Definition at line 181 of file nsStyleContext.h.

Definition at line 189 of file nsStyleContext.h.

Definition at line 194 of file nsStyleContext.h.

Definition at line 213 of file nsStyleContext.h.

Definition at line 202 of file nsStyleContext.h.


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