Back to index

lightning-sunbird  0.9+nobinonly
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes
nsCSSRuleProcessor Class Reference

The CSS style rule processor provides a mechanism for sibling style sheets to combine their rule processing in order to allow proper cascading to happen. More...

#include <nsCSSRuleProcessor.h>

Inheritance diagram for nsCSSRuleProcessor:
Inheritance graph
[legend]
Collaboration diagram for nsCSSRuleProcessor:
Collaboration graph
[legend]

List of all members.

Public Types

typedef PRBool(* PR_CALLBACK )(nsIStyleRuleProcessor *, void *)

Public Member Functions

 nsCSSRuleProcessor (const nsCOMArray< nsICSSStyleSheet > &aSheets)
virtual ~nsCSSRuleProcessor ()
nsresult ClearRuleCascades ()
NS_IMETHOD RulesMatching (ElementRuleProcessorData *aData)
 Find the |nsIStyleRule|s matching the given content node and position the given |nsRuleWalker| at the |nsRuleNode| in the rule tree representing that ordered list of rules (with higher precedence being farther from the root of the lexicographic tree).
NS_IMETHOD RulesMatching (PseudoRuleProcessorData *aData)
 Just like the previous |RulesMatching|, except for a given content node and pseudo-element.
NS_IMETHOD HasStateDependentStyle (StateRuleProcessorData *aData, nsReStyleHint *aResult)
 Return how (as described by nsReStyleHint) style can depend on a change of the given content state on the given content node.
NS_IMETHOD HasAttributeDependentStyle (AttributeRuleProcessorData *aData, nsReStyleHint *aResult)
 Return how (as described by nsReStyleHint) style can depend on the presence or value of the given attribute for the given content node.

Protected Member Functions

RuleCascadeDataGetRuleCascade (nsPresContext *aPresContext)

Protected Attributes

nsCOMArray< nsICSSStyleSheetmSheets
RuleCascadeDatamRuleCascades

Detailed Description

The CSS style rule processor provides a mechanism for sibling style sheets to combine their rule processing in order to allow proper cascading to happen.

CSS style rule processors keep a live reference on all style sheets bound to them. The CSS style sheets keep a weak reference to all the processors that they are bound to (many to many). The CSS style sheet is told when the rule processor is going away (via DropRuleProcessor).

Definition at line 59 of file nsCSSRuleProcessor.h.


Member Typedef Documentation

Definition at line 182 of file nsIStyleRuleProcessor.h.


Constructor & Destructor Documentation

Definition at line 2625 of file nsCSSStyleSheet.cpp.

  : mSheets(aSheets),
    mRuleCascades(nsnull)
{
  for (PRInt32 i = mSheets.Count() - 1; i >= 0; --i)
    mSheets[i]->AddRuleProcessor(this);
}

Here is the call graph for this function:

Definition at line 2633 of file nsCSSStyleSheet.cpp.

{
  for (PRInt32 i = mSheets.Count() - 1; i >= 0; --i)
    mSheets[i]->DropRuleProcessor(this);
  mSheets.Clear();
  ClearRuleCascades();
}

Here is the call graph for this function:


Member Function Documentation

Here is the caller graph for this function:

Definition at line 3918 of file nsCSSStyleSheet.cpp.

{
  // Having RuleCascadeData objects be per-medium works for now since
  // nsCSSRuleProcessor objects are per-document.  (For a given set
  // of stylesheets they can vary based on medium (@media) or document
  // (@-moz-document).)  Things will get a little more complicated if
  // we implement media queries, though.

  RuleCascadeData **cascadep = &mRuleCascades;
  RuleCascadeData *cascade;
  nsIAtom *medium = aPresContext->Medium();
  while ((cascade = *cascadep)) {
    if (cascade->mMedium == medium)
      return cascade;
    cascadep = &cascade->mNext;
  }

  if (mSheets.Count() != 0) {
    cascade = new RuleCascadeData(medium,
                                  eCompatibility_NavQuirks == aPresContext->CompatibilityMode());
    if (cascade) {
      CascadeEnumData data(aPresContext, cascade->mRuleHash.Arena());
      mSheets.EnumerateForwards(CascadeSheetRulesInto, &data);
      nsVoidArray weightedRules;
      PutRulesInList(&data.mRuleArrays, &weightedRules);

      // Put things into the rule hash backwards because it's easier to
      // build a singly linked list lowest-first that way.
      if (!weightedRules.EnumerateBackwards(AddRule, cascade)) {
        delete cascade;
        cascade = nsnull;
      }

      *cascadep = cascade;
    }
  }
  return cascade;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Return how (as described by nsReStyleHint) style can depend on the presence or value of the given attribute for the given content node.

This test is used for optimization only, and may err on the side of reporting more dependencies than really exist.

Implements nsIStyleRuleProcessor.

Return how (as described by nsReStyleHint) style can depend on a change of the given content state on the given content node.

This test is used for optimization only, and may err on the side of reporting more dependencies than really exist.

Event states are defined in nsIEventStateManager.h.

Implements nsIStyleRuleProcessor.

Find the |nsIStyleRule|s matching the given content node and position the given |nsRuleWalker| at the |nsRuleNode| in the rule tree representing that ordered list of rules (with higher precedence being farther from the root of the lexicographic tree).

Implements nsIStyleRuleProcessor.

Definition at line 3467 of file nsCSSStyleSheet.cpp.

{
  NS_PRECONDITION(aData->mContent->IsContentOfType(nsIContent::eELEMENT),
                  "content must be element");

  RuleCascadeData* cascade = GetRuleCascade(aData->mPresContext);

  if (cascade) {
    nsIStyledContent* styledContent = aData->mStyledContent;
    const nsAttrValue* classes = nsnull;
    if (styledContent)
      classes = styledContent->GetClasses();
    
    cascade->mRuleHash.EnumerateAllRules(aData->mNameSpaceID,
                                         aData->mContentTag,
                                         aData->mContentID,
                                         classes,
                                         ContentEnumFunc,
                                         aData);
  }
  return NS_OK;
}

Here is the call graph for this function:

Just like the previous |RulesMatching|, except for a given content node and pseudo-element.

Implements nsIStyleRuleProcessor.

Definition at line 3536 of file nsCSSStyleSheet.cpp.

{
  NS_PRECONDITION(!aData->mContent ||
                  aData->mContent->IsContentOfType(nsIContent::eELEMENT),
                  "content (if present) must be element");

  RuleCascadeData* cascade = GetRuleCascade(aData->mPresContext);

  if (cascade) {
    cascade->mRuleHash.EnumerateTagRules(aData->mPseudoTag,
                                         PseudoEnumFunc, aData);
  }
  return NS_OK;
}

Here is the call graph for this function:


Member Data Documentation

Definition at line 85 of file nsCSSRuleProcessor.h.

Definition at line 83 of file nsCSSRuleProcessor.h.


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