Back to index

lightning-sunbird  0.9+nobinonly
Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes
nsStyleSet Class Reference

#include <nsStyleSet.h>

Collaboration diagram for nsStyleSet:
Collaboration graph
[legend]

List of all members.

Public Types

enum  sheetType {
  eAgentSheet, ePresHintSheet, eUserSheet, eHTMLPresHintSheet,
  eDocSheet, eStyleAttrSheet, eOverrideSheet, eSheetTypeCount
}

Public Member Functions

 nsStyleSet ()
nsresult Init (nsPresContext *aPresContext)
nsCachedStyleDataDefaultStyleData ()
void ClearStyleData (nsPresContext *aPresContext)
void EnableQuirkStyleSheet (PRBool aEnable)
already_AddRefed< nsStyleContextResolveStyleFor (nsIContent *aContent, nsStyleContext *aParentContext)
already_AddRefed< nsStyleContextResolveStyleForNonElement (nsStyleContext *aParentContext)
already_AddRefed< nsStyleContextResolvePseudoStyleFor (nsIContent *aParentContent, nsIAtom *aPseudoTag, nsStyleContext *aParentContext, nsICSSPseudoComparator *aComparator=nsnull)
already_AddRefed< nsStyleContextProbePseudoStyleFor (nsIContent *aParentContent, nsIAtom *aPseudoTag, nsStyleContext *aParentContext)
void BeginShutdown (nsPresContext *aPresContext)
void Shutdown (nsPresContext *aPresContext)
void NotifyStyleContextDestroyed (nsPresContext *aPresContext, nsStyleContext *aStyleContext)
already_AddRefed< nsStyleContextReParentStyleContext (nsPresContext *aPresContext, nsStyleContext *aStyleContext, nsStyleContext *aNewParentContext)
nsReStyleHint HasStateDependentStyle (nsPresContext *aPresContext, nsIContent *aContent, PRInt32 aStateMask)
nsReStyleHint HasAttributeDependentStyle (nsPresContext *aPresContext, nsIContent *aContent, nsIAtom *aAttribute, PRInt32 aModType)
void SetStyleRuleSupplier (nsIStyleRuleSupplier *aSupplier)
nsIStyleRuleSupplierGetStyleRuleSupplier () const
nsresult AppendStyleSheet (sheetType aType, nsIStyleSheet *aSheet)
nsresult PrependStyleSheet (sheetType aType, nsIStyleSheet *aSheet)
nsresult RemoveStyleSheet (sheetType aType, nsIStyleSheet *aSheet)
nsresult ReplaceSheets (sheetType aType, const nsCOMArray< nsIStyleSheet > &aNewSheets)
PRBool GetAuthorStyleDisabled ()
nsresult SetAuthorStyleDisabled (PRBool aStyleDisabled)
PRInt32 SheetCount (sheetType aType) const
nsIStyleSheetStyleSheetAt (sheetType aType, PRInt32 aIndex) const
nsresult AddDocStyleSheet (nsIStyleSheet *aSheet, nsIDocument *aDocument)
void BeginUpdate ()
nsresult EndUpdate ()

Static Public Member Functions

static void FreeGlobals ()

Private Member Functions

 nsStyleSet (const nsStyleSet &aCopy)
nsStyleSetoperator= (const nsStyleSet &aCopy)
PRBool BuildDefaultStyleData (nsPresContext *aPresContext)
nsresult GatherRuleProcessors (sheetType aType)
void AddImportantRules (nsRuleNode *aCurrLevelNode, nsRuleNode *aLastPrevLevelNode)
void FileRules (nsIStyleRuleProcessor::EnumFunc aCollectorFunc, RuleProcessorData *aData)
void WalkRuleProcessors (nsIStyleRuleProcessor::EnumFunc aFunc, RuleProcessorData *aData)
already_AddRefed< nsStyleContextGetContext (nsPresContext *aPresContext, nsStyleContext *aParentContext, nsIAtom *aPseudoTag)
 |GetContext| implements sharing of style contexts (not just the data on the rule nodes) between siblings and cousins of the same generation.
nsPresContextPresContext ()

Private Attributes

nsCOMArray< nsIStyleSheetmSheets [eSheetTypeCount]
nsCOMPtr< nsIStyleRuleProcessormRuleProcessors [eSheetTypeCount]
nsCOMPtr< nsIStyleSheetmQuirkStyleSheet
nsCOMPtr< nsIStyleRuleSuppliermStyleRuleSupplier
nsCachedStyleData mDefaultStyleData
nsRuleNodemRuleTree
nsRuleWalkermRuleWalker
PRInt32 mDestroyedCount
nsVoidArray mRoots
PRUint16 mBatching
unsigned mInShutdown: 1
unsigned mAuthorStyleDisabled: 1
unsigned mDirty: 7

Static Private Attributes

static nsIURIgQuirkURI = 0

Detailed Description

Definition at line 55 of file nsStyleSet.h.


Member Enumeration Documentation

Enumerator:
eAgentSheet 
ePresHintSheet 
eUserSheet 
eHTMLPresHintSheet 
eDocSheet 
eStyleAttrSheet 
eOverrideSheet 
eSheetTypeCount 

Definition at line 155 of file nsStyleSet.h.

                 {
    eAgentSheet, // CSS
    ePresHintSheet,
    eUserSheet, // CSS
    eHTMLPresHintSheet,
    eDocSheet, // CSS
    eStyleAttrSheet,
    eOverrideSheet, // CSS
    eSheetTypeCount
    // be sure to keep the number of bits in |mDirty| below updated when
    // changing the number of sheet types
  };

Constructor & Destructor Documentation

nsStyleSet::nsStyleSet ( const nsStyleSet aCopy) [private]

Member Function Documentation

Definition at line 233 of file nsStyleSet.cpp.

{
  NS_PRECONDITION(aSheet && aDocument, "null arg");
  CHECK_APPLICABLE;

  nsCOMArray<nsIStyleSheet>& docSheets = mSheets[eDocSheet];

  docSheets.RemoveObject(aSheet);
  // lowest index first
  PRInt32 newDocIndex = aDocument->GetIndexOfStyleSheet(aSheet);
  PRInt32 count = docSheets.Count();
  PRInt32 index;
  for (index = 0; index < count; index++) {
    nsIStyleSheet* sheet = docSheets.ObjectAt(index);
    PRInt32 sheetDocIndex = aDocument->GetIndexOfStyleSheet(sheet);
    if (sheetDocIndex > newDocIndex)
      break;
  }
  if (!docSheets.InsertObjectAt(aSheet, index))
    return NS_ERROR_OUT_OF_MEMORY;
  if (!mBatching)
    return GatherRuleProcessors(eDocSheet);

  mDirty |= 1 << eDocSheet;
  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsStyleSet::AddImportantRules ( nsRuleNode aCurrLevelNode,
nsRuleNode aLastPrevLevelNode 
) [private]

Definition at line 377 of file nsStyleSet.cpp.

{
  if (!aCurrLevelNode || aCurrLevelNode == aLastPrevLevelNode)
    return;

  AddImportantRules(aCurrLevelNode->GetParent(), aLastPrevLevelNode);

  nsIStyleRule *rule = aCurrLevelNode->GetRule();
  nsCOMPtr<nsICSSStyleRule> cssRule(do_QueryInterface(rule));
  if (cssRule) {
    nsCOMPtr<nsIStyleRule> impRule = cssRule->GetImportantRule();
    if (impRule)
      mRuleWalker->Forward(impRule);
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 146 of file nsStyleSet.cpp.

{
  NS_PRECONDITION(aSheet, "null arg");
  CHECK_APPLICABLE;
  mSheets[aType].RemoveObject(aSheet);
  if (!mSheets[aType].AppendObject(aSheet))
    return NS_ERROR_OUT_OF_MEMORY;

  if (!mBatching)
    return GatherRuleProcessors(aType);

  mDirty |= 1 << aType;
  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 720 of file nsStyleSet.cpp.

{
  mInShutdown = 1;
  mRoots.Clear(); // no longer valid, since we won't keep it up to date
}

Definition at line 264 of file nsStyleSet.cpp.

{
  ++mBatching;
}

Here is the caller graph for this function:

Definition at line 527 of file nsStyleSet.cpp.

{
  NS_ASSERTION(!mDefaultStyleData.mResetData &&
               !mDefaultStyleData.mInheritedData,
               "leaking default style data");
  mDefaultStyleData.mResetData = new (aPresContext) nsResetStyleData;
  if (!mDefaultStyleData.mResetData)
    return PR_FALSE;
  mDefaultStyleData.mInheritedData = new (aPresContext) nsInheritedStyleData;
  if (!mDefaultStyleData.mInheritedData)
    return PR_FALSE;

#define SSARG_PRESCONTEXT aPresContext

#define CREATE_DATA(name, type, args) \
  if (!(mDefaultStyleData.m##type##Data->m##name##Data = \
          new (aPresContext) nsStyle##name args)) \
    return PR_FALSE;

#define STYLE_STRUCT_INHERITED(name, checkdata_cb, ctor_args) \
  CREATE_DATA(name, Inherited, ctor_args)
#define STYLE_STRUCT_RESET(name, checkdata_cb, ctor_args) \
  CREATE_DATA(name, Reset, ctor_args)

#include "nsStyleStructList.h"

#undef STYLE_STRUCT_INHERITED
#undef STYLE_STRUCT_RESET
#undef SSARG_PRESCONTEXT

  return PR_TRUE;
}

Here is the caller graph for this function:

Definition at line 774 of file nsStyleSet.cpp.

{
  mRuleTree->ClearStyleData();

  for (PRInt32 i = mRoots.Count() - 1; i >= 0; --i) {
    NS_STATIC_CAST(nsStyleContext*,mRoots[i])->ClearStyleData(aPresContext);
  }
}

Definition at line 67 of file nsStyleSet.h.

{ return &mDefaultStyleData; }

Definition at line 290 of file nsStyleSet.cpp.

{
  if (!mQuirkStyleSheet) {
    // first find the quirk sheet:
    // - run through all of the agent sheets and check for a CSSStyleSheet that
    //   has the URL we want
    PRInt32 nSheets = mSheets[eAgentSheet].Count();
    for (PRInt32 i = 0; i < nSheets; ++i) {
      nsIStyleSheet *sheet = mSheets[eAgentSheet].ObjectAt(i);
      NS_ASSERTION(sheet, "mAgentSheets should not contain null sheets");

      nsICSSStyleSheet *cssSheet = NS_STATIC_CAST(nsICSSStyleSheet*, sheet);
      NS_ASSERTION(nsCOMPtr<nsICSSStyleSheet>(do_QueryInterface(sheet)) == cssSheet,
                   "Agent sheet must be a CSSStyleSheet");

      nsCOMPtr<nsIStyleSheet> quirkSheet;
      PRBool bHasSheet = PR_FALSE;
      if (NS_SUCCEEDED(cssSheet->ContainsStyleSheet(gQuirkURI, bHasSheet, 
                                                    getter_AddRefs(quirkSheet))) 
          && bHasSheet) {
        NS_ASSERTION(quirkSheet, "QuirkSheet must be set: ContainsStyleSheet is hosed");
        // cache the sheet for faster lookup next time
        mQuirkStyleSheet = quirkSheet;
        // only one quirk style sheet can exist, so stop looking
        break;
      }
    }
  }
  NS_ASSERTION(mQuirkStyleSheet, "no quirk stylesheet");
  if (mQuirkStyleSheet) {
#ifdef DEBUG_dbaron_off // XXX Make this |DEBUG| once it stops firing.
    PRBool applicableNow;
    mQuirkStyleSheet->GetApplicable(applicableNow);
    NS_ASSERTION(!mRuleProcessors[eAgentSheet] || aEnable == applicableNow,
                 "enabling/disabling quirk stylesheet too late or incomplete quirk stylesheet");
    if (mRuleProcessors[eAgentSheet] && aEnable == applicableNow)
      printf("WARNING: We set the quirks mode too many times.\n"); // we do!
#endif
    mQuirkStyleSheet->SetEnabled(aEnable);
  }
}

Here is the call graph for this function:

Definition at line 270 of file nsStyleSet.cpp.

{
  NS_ASSERTION(mBatching > 0, "Unbalanced EndUpdate");
  if (--mBatching) {
    // We're not completely done yet.
    return NS_OK;
  }

  for (int i = 0; i < eSheetTypeCount; ++i) {
    if (mDirty & (1 << i)) {
      nsresult rv = GatherRuleProcessors(sheetType(i));
      NS_ENSURE_SUCCESS(rv, rv);
    }
  }

  mDirty = 0;
  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsStyleSet::FileRules ( nsIStyleRuleProcessor::EnumFunc  aCollectorFunc,
RuleProcessorData aData 
) [private]

Definition at line 429 of file nsStyleSet.cpp.

{
  // Cascading order:
  // [least important]
  //  1. UA normal rules                    = Agent        normal
  //  2. Presentation hints                 = PresHint     normal
  //  3. User normal rules                  = User         normal
  //  2. HTML Presentation hints            = HTMLPresHint normal
  //  5. Author normal rules                = Document     normal
  //  6. Override normal rules              = Override     normal
  //  7. Author !important rules            = Document     !important
  //  8. Override !important rules          = Override     !important
  //  9. User !important rules              = User         !important
  // 10. UA !important rules                = Agent        !important
  // [most important]

  NS_PRECONDITION(SheetCount(ePresHintSheet) == 0 ||
                  SheetCount(eHTMLPresHintSheet) == 0,
                  "Can't have both types of preshint sheets at once!");
  
  if (mRuleProcessors[eAgentSheet])
    (*aCollectorFunc)(mRuleProcessors[eAgentSheet], aData);
  nsRuleNode* lastAgentRN = mRuleWalker->GetCurrentNode();

  if (mRuleProcessors[ePresHintSheet])
    (*aCollectorFunc)(mRuleProcessors[ePresHintSheet], aData);
  nsRuleNode* lastPresHintRN = mRuleWalker->GetCurrentNode();
  
  if (mRuleProcessors[eUserSheet])
    (*aCollectorFunc)(mRuleProcessors[eUserSheet], aData);
  nsRuleNode* lastUserRN = mRuleWalker->GetCurrentNode();

  if (mRuleProcessors[eHTMLPresHintSheet])
    (*aCollectorFunc)(mRuleProcessors[eHTMLPresHintSheet], aData);
  nsRuleNode* lastHTMLPresHintRN = mRuleWalker->GetCurrentNode();
  
  PRBool cutOffInheritance = PR_FALSE;
  if (mStyleRuleSupplier) {
    // We can supply additional document-level sheets that should be walked.
    mStyleRuleSupplier->WalkRules(this, aCollectorFunc, aData,
                                  &cutOffInheritance);
  }
  if (!cutOffInheritance && mRuleProcessors[eDocSheet]) // NOTE: different
    (*aCollectorFunc)(mRuleProcessors[eDocSheet], aData);
  if (mRuleProcessors[eStyleAttrSheet])
    (*aCollectorFunc)(mRuleProcessors[eStyleAttrSheet], aData);

  if (mRuleProcessors[eOverrideSheet])
    (*aCollectorFunc)(mRuleProcessors[eOverrideSheet], aData);
  nsRuleNode* lastOvrRN = mRuleWalker->GetCurrentNode();

  // There should be no important rules in the preshint or HTMLpreshint level
  AddImportantRules(lastOvrRN, lastHTMLPresHintRN);  // doc and override
#ifdef DEBUG
  AssertNoCSSRules(lastHTMLPresHintRN, lastUserRN);
  AssertNoImportantRules(lastHTMLPresHintRN, lastUserRN); // HTML preshints
#endif
  AddImportantRules(lastUserRN, lastPresHintRN); //user
#ifdef DEBUG
  AssertNoImportantRules(lastPresHintRN, lastAgentRN); // preshints
#endif
  AddImportantRules(lastAgentRN, nsnull);     //agent

}

Here is the call graph for this function:

Here is the caller graph for this function:

static void nsStyleSet::FreeGlobals ( ) [inline, static]

Definition at line 151 of file nsStyleSet.h.

Definition at line 96 of file nsStyleSet.cpp.

{
  mRuleProcessors[aType] = nsnull;
  if (mAuthorStyleDisabled && (aType == eDocSheet || 
                               aType == ePresHintSheet ||
                               aType == eHTMLPresHintSheet ||
                               aType == eStyleAttrSheet)) {
    //don't regather if this level is disabled
    return NS_OK;
  }
  if (mSheets[aType].Count()) {
    switch (aType) {
      case eAgentSheet:
      case eUserSheet:
      case eDocSheet:
      case eOverrideSheet: {
        // levels containing CSS stylesheets
        nsCOMArray<nsIStyleSheet>& sheets = mSheets[aType];
        nsCOMArray<nsICSSStyleSheet> cssSheets(sheets.Count());
        for (PRInt32 i = 0, i_end = sheets.Count(); i < i_end; ++i) {
          nsCOMPtr<nsICSSStyleSheet> cssSheet = do_QueryInterface(sheets[i]);
          NS_ASSERTION(cssSheet, "not a CSS sheet");
          cssSheets.AppendObject(cssSheet);
        }
        mRuleProcessors[aType] = new nsCSSRuleProcessor(cssSheets);
      } break;

      default:
        // levels containing non-CSS stylesheets
        NS_ASSERTION(mSheets[aType].Count() == 1, "only one sheet per level");
        mRuleProcessors[aType] = do_QueryInterface(mSheets[aType][0]);
        break;
    }
  }

  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 210 of file nsStyleSet.cpp.

already_AddRefed< nsStyleContext > nsStyleSet::GetContext ( nsPresContext aPresContext,
nsStyleContext aParentContext,
nsIAtom aPseudoTag 
) [private]

|GetContext| implements sharing of style contexts (not just the data on the rule nodes) between siblings and cousins of the same generation.

(It works for cousins of the same generation since |aParentContext| could itself be a shared context.)

Definition at line 349 of file nsStyleSet.cpp.

{
  nsStyleContext* result = nsnull;
  nsRuleNode* ruleNode = mRuleWalker->GetCurrentNode();
      
  if (aParentContext)
    result = aParentContext->FindChildWithRules(aPseudoTag, ruleNode).get();

#ifdef NOISY_DEBUG
  if (result)
    fprintf(stdout, "--- SharedSC %d ---\n", ++gSharedCount);
  else
    fprintf(stdout, "+++ NewSC %d +++\n", ++gNewCount);
#endif

  if (!result) {
    result = NS_NewStyleContext(aParentContext, aPseudoTag, ruleNode,
                                aPresContext).get();
    if (!aParentContext && result)
      mRoots.AppendElement(result);
  }

  return result;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 145 of file nsStyleSet.h.

  {
    return mStyleRuleSupplier;
  }
nsReStyleHint nsStyleSet::HasAttributeDependentStyle ( nsPresContext aPresContext,
nsIContent aContent,
nsIAtom aAttribute,
PRInt32  aModType 
)

Definition at line 875 of file nsStyleSet.cpp.

Here is the call graph for this function:

nsReStyleHint nsStyleSet::HasStateDependentStyle ( nsPresContext aPresContext,
nsIContent aContent,
PRInt32  aStateMask 
)

Definition at line 832 of file nsStyleSet.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 66 of file nsStyleSet.cpp.

{
  if (!gQuirkURI) {
    static const char kQuirk_href[] = "resource://gre/res/quirk.css";
    NS_NewURI(&gQuirkURI, kQuirk_href);
    NS_ENSURE_TRUE(gQuirkURI, NS_ERROR_OUT_OF_MEMORY);
  }

  if (!BuildDefaultStyleData(aPresContext)) {
    mDefaultStyleData.Destroy(0, aPresContext);
    return NS_ERROR_OUT_OF_MEMORY;
  }

  mRuleTree = nsRuleNode::CreateRootNode(aPresContext);
  if (!mRuleTree) {
    mDefaultStyleData.Destroy(0, aPresContext);
    return NS_ERROR_OUT_OF_MEMORY;
  }

  mRuleWalker = new nsRuleWalker(mRuleTree);
  if (!mRuleWalker) {
    mRuleTree->Destroy();
    mDefaultStyleData.Destroy(0, aPresContext);
    return NS_ERROR_OUT_OF_MEMORY;
  }

  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsStyleSet::NotifyStyleContextDestroyed ( nsPresContext aPresContext,
nsStyleContext aStyleContext 
)

Definition at line 741 of file nsStyleSet.cpp.

{
  if (mInShutdown)
    return;

  if (!aStyleContext->GetParent()) {
    mRoots.RemoveElement(aStyleContext);
  }

  if (++mDestroyedCount == kGCInterval) {
    mDestroyedCount = 0;

    // Mark the style context tree by marking all roots, which will mark
    // all descendants.  This will reach style contexts in the
    // undisplayed map and "additional style contexts" since they are
    // descendants of the root.
    for (PRInt32 i = mRoots.Count() - 1; i >= 0; --i) {
      NS_STATIC_CAST(nsStyleContext*,mRoots[i])->Mark();
    }

    // Sweep the rule tree.
    NS_ASSERTION(mRuleWalker->AtRoot(), "Rule walker should be at root");
#ifdef DEBUG
    PRBool deleted =
#endif
      mRuleTree->Sweep();

    NS_ASSERTION(!deleted, "Root node must not be gc'd");
  }
}

Here is the call graph for this function:

nsStyleSet& nsStyleSet::operator= ( const nsStyleSet aCopy) [private]

Definition at line 162 of file nsStyleSet.cpp.

{
  NS_PRECONDITION(aSheet, "null arg");
  CHECK_APPLICABLE;
  mSheets[aType].RemoveObject(aSheet);
  if (!mSheets[aType].InsertObjectAt(aSheet, 0))
    return NS_ERROR_OUT_OF_MEMORY;

  if (!mBatching)
    return GatherRuleProcessors(aType);

  mDirty |= 1 << aType;
  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsPresContext* nsStyleSet::PresContext ( ) [inline, private]

Definition at line 235 of file nsStyleSet.h.

{ return mRuleTree->GetPresContext(); }

Here is the call graph for this function:

Here is the caller graph for this function:

already_AddRefed< nsStyleContext > nsStyleSet::ProbePseudoStyleFor ( nsIContent aParentContent,
nsIAtom aPseudoTag,
nsStyleContext aParentContext 
)

Definition at line 666 of file nsStyleSet.cpp.

{
  NS_ENSURE_FALSE(mInShutdown, nsnull);
  
  nsStyleContext*  result = nsnull;
  nsPresContext *presContext = PresContext();

  NS_ASSERTION(aPseudoTag, "must have pseudo tag");
  NS_ASSERTION(!aParentContent ||
               aParentContent->IsContentOfType(nsIContent::eELEMENT),
               "content (if non-null) must be element");

  if (aPseudoTag && presContext) {
    if (mRuleProcessors[eAgentSheet]        ||
        mRuleProcessors[ePresHintSheet]     ||
        mRuleProcessors[eUserSheet]         ||
        mRuleProcessors[eHTMLPresHintSheet] ||
        mRuleProcessors[eDocSheet]          ||
        mRuleProcessors[eStyleAttrSheet]    ||
        mRuleProcessors[eOverrideSheet]) {
      PseudoRuleProcessorData data(presContext, aParentContent, aPseudoTag,
                                   nsnull, mRuleWalker);
      FileRules(EnumPseudoRulesMatching, &data);

      if (!mRuleWalker->AtRoot())
        result = GetContext(presContext, aParentContext, aPseudoTag).get();

      // Now reset the walker back to the root of the tree.
      mRuleWalker->Reset();
    }
  }

  // For :before and :after pseudo-elements, having display: none or no
  // 'content' property is equivalent to not having the pseudo-element
  // at all.
  if (result &&
      (aPseudoTag == nsCSSPseudoElements::before ||
       aPseudoTag == nsCSSPseudoElements::after)) {
    const nsStyleDisplay *display = result->GetStyleDisplay();
    const nsStyleContent *content = result->GetStyleContent();
    // XXXldb What is contentCount for |content: ""|?
    if (display->mDisplay == NS_STYLE_DISPLAY_NONE ||
        content->ContentCount() == 0) {
      result->Release();
      result = nsnull;
    }
  }
  
  return result;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 178 of file nsStyleSet.cpp.

{
  NS_PRECONDITION(aSheet, "null arg");
#ifdef DEBUG
  PRBool complete = PR_TRUE;
  aSheet->GetComplete(complete);
  NS_ASSERTION(complete, "Incomplete sheet being removed from style set");
#endif
  mSheets[aType].RemoveObject(aSheet);
  if (!mBatching)
    return GatherRuleProcessors(aType);

  mDirty |= 1 << aType;
  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

already_AddRefed< nsStyleContext > nsStyleSet::ReParentStyleContext ( nsPresContext aPresContext,
nsStyleContext aStyleContext,
nsStyleContext aNewParentContext 
)

Definition at line 784 of file nsStyleSet.cpp.

{
  NS_ASSERTION(aPresContext, "must have pres context");
  NS_ASSERTION(aStyleContext, "must have style context");

  if (aPresContext && aStyleContext) {
    if (aStyleContext->GetParent() == aNewParentContext) {
      aStyleContext->AddRef();
      return aStyleContext;
    }
    else {  // really a new parent
      nsIAtom* pseudoTag = aStyleContext->GetPseudoType();

      nsRuleNode* ruleNode = aStyleContext->GetRuleNode();
      mRuleWalker->SetCurrentNode(ruleNode);

      already_AddRefed<nsStyleContext> result =
          GetContext(aPresContext, aNewParentContext, pseudoTag);
      mRuleWalker->Reset();
      return result;
    }
  }
  return nsnull;
}

Here is the call graph for this function:

Definition at line 195 of file nsStyleSet.cpp.

{
  mSheets[aType].Clear();
  if (!mSheets[aType].AppendObjects(aNewSheets))
    return NS_ERROR_OUT_OF_MEMORY;

  if (!mBatching)
    return GatherRuleProcessors(aType);

  mDirty |= 1 << aType;
  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

already_AddRefed< nsStyleContext > nsStyleSet::ResolvePseudoStyleFor ( nsIContent aParentContent,
nsIAtom aPseudoTag,
nsStyleContext aParentContext,
nsICSSPseudoComparator aComparator = nsnull 
)

Definition at line 628 of file nsStyleSet.cpp.

{
  NS_ENSURE_FALSE(mInShutdown, nsnull);

  nsStyleContext*  result = nsnull;
  nsPresContext *presContext = PresContext();

  NS_ASSERTION(aPseudoTag, "must have pseudo tag");
  NS_ASSERTION(!aParentContent ||
               aParentContent->IsContentOfType(nsIContent::eELEMENT),
               "content (if non-null) must be element");

  if (aPseudoTag && presContext) {
    if (mRuleProcessors[eAgentSheet]        ||
        mRuleProcessors[ePresHintSheet]     ||
        mRuleProcessors[eUserSheet]         ||
        mRuleProcessors[eHTMLPresHintSheet] ||
        mRuleProcessors[eDocSheet]          ||
        mRuleProcessors[eStyleAttrSheet]    ||
        mRuleProcessors[eOverrideSheet]) {
      PseudoRuleProcessorData data(presContext, aParentContent, aPseudoTag,
                                   aComparator, mRuleWalker);
      FileRules(EnumPseudoRulesMatching, &data);

      result = GetContext(presContext, aParentContext, aPseudoTag).get();

      // Now reset the walker back to the root of the tree.
      mRuleWalker->Reset();
    }
  }

  return result;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 561 of file nsStyleSet.cpp.

{
  NS_ENSURE_FALSE(mInShutdown, nsnull);
  
  nsStyleContext*  result = nsnull;
  nsPresContext* presContext = PresContext();

  NS_ASSERTION(aContent, "must have content");
  NS_ASSERTION(aContent->IsContentOfType(nsIContent::eELEMENT),
               "content must be element");

  if (aContent && presContext) {
    if (mRuleProcessors[eAgentSheet]        ||
        mRuleProcessors[ePresHintSheet]     ||
        mRuleProcessors[eUserSheet]         ||
        mRuleProcessors[eHTMLPresHintSheet] ||
        mRuleProcessors[eDocSheet]          ||
        mRuleProcessors[eStyleAttrSheet]    ||
        mRuleProcessors[eOverrideSheet]) {
      ElementRuleProcessorData data(presContext, aContent, mRuleWalker);
      FileRules(EnumRulesMatching, &data);
      result = GetContext(presContext, aParentContext, nsnull).get();

      // Now reset the walker back to the root of the tree.
      mRuleWalker->Reset();
    }
  }

  return result;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 594 of file nsStyleSet.cpp.

{
  nsStyleContext* result = nsnull;
  nsPresContext *presContext = PresContext();

  if (presContext) {
    if (mRuleProcessors[eAgentSheet]        ||
        mRuleProcessors[ePresHintSheet]     ||
        mRuleProcessors[eUserSheet]         ||
        mRuleProcessors[eHTMLPresHintSheet] ||
        mRuleProcessors[eDocSheet]          ||
        mRuleProcessors[eStyleAttrSheet]    ||
        mRuleProcessors[eOverrideSheet]) {
      result = GetContext(presContext, aParentContext,
                          nsCSSAnonBoxes::mozNonElement).get();
      NS_ASSERTION(mRuleWalker->AtRoot(), "rule walker must be at root");
    }
  }

  return result;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 216 of file nsStyleSet.cpp.

{
  if (aStyleDisabled == !mAuthorStyleDisabled) {
    mAuthorStyleDisabled = aStyleDisabled;
    BeginUpdate();
    mDirty |= 1 << eDocSheet |
              1 << ePresHintSheet |
              1 << eHTMLPresHintSheet |
              1 << eStyleAttrSheet;
    return EndUpdate();
  }
  return NS_OK;
}

Here is the call graph for this function:

Definition at line 140 of file nsStyleSet.h.

  {
    mStyleRuleSupplier = aSupplier;
  }
PRInt32 nsStyleSet::SheetCount ( sheetType  aType) const [inline]

Definition at line 180 of file nsStyleSet.h.

                                            {
    return mSheets[aType].Count();
  }

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 727 of file nsStyleSet.cpp.

{
  delete mRuleWalker;
  mRuleWalker = nsnull;

  mRuleTree->Destroy();
  mRuleTree = nsnull;

  mDefaultStyleData.Destroy(0, aPresContext);
}
nsIStyleSheet* nsStyleSet::StyleSheetAt ( sheetType  aType,
PRInt32  aIndex 
) const [inline]

Definition at line 184 of file nsStyleSet.h.

                                                                     {
    return mSheets[aType].ObjectAt(aIndex);
  }

Here is the call graph for this function:

Here is the caller graph for this function:

void nsStyleSet::WalkRuleProcessors ( nsIStyleRuleProcessor::EnumFunc  aFunc,
RuleProcessorData aData 
) [private]

Definition at line 498 of file nsStyleSet.cpp.

{
  NS_PRECONDITION(SheetCount(ePresHintSheet) == 0 ||
                  SheetCount(eHTMLPresHintSheet) == 0,
                  "Can't have both types of preshint sheets at once!");
  
  if (mRuleProcessors[eAgentSheet])
    (*aFunc)(mRuleProcessors[eAgentSheet], aData);
  if (mRuleProcessors[ePresHintSheet])
    (*aFunc)(mRuleProcessors[ePresHintSheet], aData);
  if (mRuleProcessors[eUserSheet])
    (*aFunc)(mRuleProcessors[eUserSheet], aData);
  if (mRuleProcessors[eHTMLPresHintSheet])
    (*aFunc)(mRuleProcessors[eHTMLPresHintSheet], aData);
  
  PRBool cutOffInheritance = PR_FALSE;
  if (mStyleRuleSupplier) {
    // We can supply additional document-level sheets that should be walked.
    mStyleRuleSupplier->WalkRules(this, aFunc, aData, &cutOffInheritance);
  }
  if (!cutOffInheritance && mRuleProcessors[eDocSheet]) // NOTE: different
    (*aFunc)(mRuleProcessors[eDocSheet], aData);
  if (mRuleProcessors[eStyleAttrSheet])
    (*aFunc)(mRuleProcessors[eStyleAttrSheet], aData);
  if (mRuleProcessors[eOverrideSheet])
    (*aFunc)(mRuleProcessors[eOverrideSheet], aData);
}

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

nsIURI * nsStyleSet::gQuirkURI = 0 [static, private]

Definition at line 237 of file nsStyleSet.h.

Definition at line 265 of file nsStyleSet.h.

Definition at line 262 of file nsStyleSet.h.

Definition at line 251 of file nsStyleSet.h.

Definition at line 259 of file nsStyleSet.h.

unsigned nsStyleSet::mDirty [private]

Definition at line 266 of file nsStyleSet.h.

unsigned nsStyleSet::mInShutdown [private]

Definition at line 264 of file nsStyleSet.h.

Definition at line 244 of file nsStyleSet.h.

Definition at line 260 of file nsStyleSet.h.

Definition at line 241 of file nsStyleSet.h.

Definition at line 253 of file nsStyleSet.h.

Definition at line 256 of file nsStyleSet.h.

Definition at line 239 of file nsStyleSet.h.

Definition at line 246 of file nsStyleSet.h.


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