Back to index

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

#include <nsCSSRules.h>

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

List of all members.

Classes

struct  URL

Public Types

enum  Function { eURL, eURLPrefix, eDomain }
enum  {
  UNKNOWN_RULE = 0, STYLE_RULE = 1, IMPORT_RULE = 2, MEDIA_RULE = 3,
  FONT_FACE_RULE = 4, PAGE_RULE = 5, CHARSET_RULE = 6, NAMESPACE_RULE = 7,
  DOCUMENT_RULE = 8
}

Public Member Functions

 nsCSSDocumentRule (void)
 nsCSSDocumentRule (const nsCSSDocumentRule &aCopy)
virtual ~nsCSSDocumentRule (void)
NS_DECL_ISUPPORTS_INHERITED
NS_IMETHOD 
GetType (PRInt32 &aType) const
NS_IMETHOD Clone (nsICSSRule *&aClone) const
NS_DECL_NSIDOMCSSRULE
NS_DECL_NSIDOMCSSMOZDOCUMENTRULE 
NS_IMETHOD_ (PRBool) UseForPresentation(nsPresContext *aPresContext)
void SetURLs (URL *aURLs)
NS_IMETHOD AppendStyleRule (nsICSSRule *aRule)
NS_IMETHOD StyleRuleCount (PRInt32 &aCount) const
NS_IMETHOD GetStyleRuleAt (PRInt32 aIndex, nsICSSRule *&aRule) const
NS_IMETHOD EnumerateRulesForwards (nsISupportsArrayEnumFunc aFunc, void *aData) const
NS_IMETHOD DeleteStyleRuleAt (PRUint32 aIndex)
NS_IMETHOD InsertStyleRulesAt (PRUint32 aIndex, nsISupportsArray *aRules)
NS_IMETHOD ReplaceStyleRule (nsICSSRule *aOld, nsICSSRule *aNew)
 NS_IMETHOD_ (nsrefcnt) AddRef()
NS_IMETHOD GetStyleSheet (nsIStyleSheet *&aSheet) const
NS_IMETHOD GetStyleSheet (nsIStyleSheet *&aSheet) const =0
NS_IMETHOD SetStyleSheet (nsICSSStyleSheet *aSheet)
NS_IMETHOD SetStyleSheet (nsICSSStyleSheet *aSheet)=0
NS_IMETHOD SetParentRule (nsICSSGroupRule *aRule)
NS_IMETHOD SetParentRule (nsICSSGroupRule *aRule)=0
NS_IMETHOD MapRuleInfoInto (nsRuleData *aRuleData)
NS_IMETHOD MapRuleInfoInto (nsRuleData *aRuleData)=0
 |nsIStyleRule::MapRuleInfoInto| is a request to copy all stylistic data represented by the rule that:
NS_IMETHOD GetDOMRule (nsIDOMCSSRule **aDOMRule)=0
unsigned long insertRule (in DOMString rule, in unsigned long index) raises (DOMException)
void deleteRule (in unsigned long index) raises (DOMException)

Public Attributes

readonly attribute
nsIDOMCSSRuleList 
cssRules
const unsigned short UNKNOWN_RULE = 0
const unsigned short STYLE_RULE = 1
const unsigned short CHARSET_RULE = 2
const unsigned short IMPORT_RULE = 3
const unsigned short MEDIA_RULE = 4
const unsigned short FONT_FACE_RULE = 5
const unsigned short PAGE_RULE = 6
readonly attribute unsigned short type
attribute DOMString cssText
readonly attribute
nsIDOMCSSStyleSheet 
parentStyleSheet
readonly attribute nsIDOMCSSRule parentRule

Protected Member Functions

nsresult AppendRulesToCssText (nsAString &aCssText)
nsresult GetParentStyleSheet (nsIDOMCSSStyleSheet **aSheet)
nsresult GetParentRule (nsIDOMCSSRule **aParentRule)
nsresult GetCssRules (nsIDOMCSSRuleList **aRuleList)
nsresult InsertRule (const nsAString &aRule, PRUint32 aIndex, PRUint32 *_retval)
nsresult DeleteRule (PRUint32 aIndex)

Protected Attributes

nsAutoPtr< URLmURLs
nsCOMPtr< nsISupportsArraymRules
CSSGroupRuleRuleListImplmRuleCollection
nsAutoRefCnt mRefCnt
nsICSSStyleSheetmSheet
nsICSSGroupRulemParentRule

Detailed Description

Definition at line 143 of file nsCSSRules.h.


Member Enumeration Documentation

anonymous enum [inherited]
Enumerator:
UNKNOWN_RULE 
STYLE_RULE 
IMPORT_RULE 
MEDIA_RULE 
FONT_FACE_RULE 
PAGE_RULE 
CHARSET_RULE 
NAMESPACE_RULE 
DOCUMENT_RULE 

Definition at line 55 of file nsICSSRule.h.

Enumerator:
eURL 
eURLPrefix 
eDomain 

Definition at line 171 of file nsCSSRules.h.


Constructor & Destructor Documentation

Definition at line 1103 of file nsCSSRules.cpp.

{
}

Here is the caller graph for this function:

Definition at line 1107 of file nsCSSRules.cpp.

  : nsCSSGroupRule(aCopy)
  , mURLs(new URL(*aCopy.mURLs))
{
}

Definition at line 1113 of file nsCSSRules.cpp.

{
}

Member Function Documentation

nsresult nsCSSGroupRule::AppendRulesToCssText ( nsAString &  aCssText) [protected, inherited]

Definition at line 824 of file nsCSSRules.cpp.

{
  aCssText.AppendLiteral(" {\n");

  // get all the rules
  if (mRules) {
    PRUint32 count;
    mRules->Count(&count);
    for (PRUint32 index = 0; index < count; index++) {
      nsCOMPtr<nsICSSRule> rule;
      mRules->GetElementAt(index, getter_AddRefs(rule));
      nsCOMPtr<nsIDOMCSSRule> domRule;
      rule->GetDOMRule(getter_AddRefs(domRule));
      if (domRule) {
        nsAutoString cssText;
        domRule->GetCssText(cssText);
        aCssText.Append(NS_LITERAL_STRING("  ") +
                        cssText +
                        NS_LITERAL_STRING("\n"));
      }
    }
  }

  aCssText.AppendLiteral("}");
  
  return NS_OK;
}

Here is the call graph for this function:

NS_IMETHODIMP nsCSSGroupRule::AppendStyleRule ( nsICSSRule aRule) [virtual, inherited]

Implements nsICSSGroupRule.

Definition at line 718 of file nsCSSRules.cpp.

{
  nsresult result = NS_OK;
  if (!mRules) {
    result = NS_NewISupportsArray(getter_AddRefs(mRules));
  }
  if (NS_SUCCEEDED(result) && mRules) {
    mRules->AppendElement(aRule);
    aRule->SetStyleSheet(mSheet);
    aRule->SetParentRule(this);
    if (mSheet) {
      // XXXldb Shouldn't we be using |WillDirty| and |DidDirty| (and
      // shouldn't |SetModified| be removed?
      mSheet->SetModified(PR_TRUE);
    }
  }
  return result;
}

Here is the call graph for this function:

NS_IMETHODIMP nsCSSDocumentRule::Clone ( nsICSSRule *&  aClone) const [virtual]

Implements nsICSSRule.

Definition at line 1171 of file nsCSSRules.cpp.

{
  nsCSSDocumentRule* clone = new nsCSSDocumentRule(*this);
  if (clone) {
    return CallQueryInterface(clone, &aClone);
  }
  aClone = nsnull;
  return NS_ERROR_OUT_OF_MEMORY;
}

Here is the call graph for this function:

void nsIDOMCSSMozDocumentRule::deleteRule ( in unsigned long  index) raises (DOMException) [inherited]
nsresult nsCSSGroupRule::DeleteRule ( PRUint32  aIndex) [protected, inherited]

Definition at line 907 of file nsCSSRules.cpp.

{
  NS_ENSURE_TRUE(mSheet, NS_ERROR_FAILURE);
  if (!mRules)  {
    return NS_ERROR_DOM_INDEX_SIZE_ERR;
  }
  
  PRUint32 count;
  mRules->Count(&count);
  if (aIndex >= count)
    return NS_ERROR_DOM_INDEX_SIZE_ERR;

  return mSheet->DeleteRuleFromGroup(this, aIndex);
}

Here is the call graph for this function:

NS_IMETHODIMP nsCSSGroupRule::DeleteStyleRuleAt ( PRUint32  aIndex) [virtual, inherited]

Implements nsICSSGroupRule.

Definition at line 784 of file nsCSSRules.cpp.

{
  NS_ENSURE_TRUE(mRules, NS_ERROR_FAILURE);

  nsCOMPtr<nsICSSRule> rule = dont_AddRef((nsICSSRule*)mRules->ElementAt(aIndex));
  if (rule) {
    rule->SetStyleSheet(nsnull);
    rule->SetParentRule(nsnull);
  }
  return mRules->DeleteElementAt(aIndex);
}

Here is the call graph for this function:

NS_IMETHODIMP nsCSSGroupRule::EnumerateRulesForwards ( nsISupportsArrayEnumFunc  aFunc,
void aData 
) const [virtual, inherited]

Implements nsICSSGroupRule.

Definition at line 769 of file nsCSSRules.cpp.

{
  if (mRules) {
    return ((mRules->EnumerateForwards(aFunc, aData)) ? NS_OK : NS_ENUMERATOR_FALSE);
  }
  return NS_OK;
}
nsresult nsCSSGroupRule::GetCssRules ( nsIDOMCSSRuleList **  aRuleList) [protected, inherited]

Definition at line 874 of file nsCSSRules.cpp.

Here is the call graph for this function:

NS_IMETHOD nsICSSRule::GetDOMRule ( nsIDOMCSSRule **  aDOMRule) [pure virtual, inherited]

Implemented in CSSStyleRuleImpl.

Here is the caller graph for this function:

nsresult nsCSSGroupRule::GetParentRule ( nsIDOMCSSRule **  aParentRule) [protected, inherited]

Definition at line 863 of file nsCSSRules.cpp.

{
  if (mParentRule) {
    return mParentRule->GetDOMRule(aParentRule);
  }
  *aParentRule = nsnull;
  return NS_OK;
}

Here is the call graph for this function:

nsresult nsCSSGroupRule::GetParentStyleSheet ( nsIDOMCSSStyleSheet **  aSheet) [protected, inherited]

Definition at line 853 of file nsCSSRules.cpp.

{
  if (mSheet) {
    return CallQueryInterface(mSheet, aSheet);
  }
  *aSheet = nsnull;
  return NS_OK;
}

Here is the call graph for this function:

NS_IMETHODIMP nsCSSGroupRule::GetStyleRuleAt ( PRInt32  aIndex,
nsICSSRule *&  aRule 
) const [virtual, inherited]

Implements nsICSSGroupRule.

Definition at line 752 of file nsCSSRules.cpp.

{
  if (mRules) {
    PRInt32 count = 0;
    nsresult rv = StyleRuleCount(count);
    NS_ENSURE_SUCCESS(rv, rv);
    if (aIndex >= count) {
      aRule = nsnull;
      return NS_ERROR_ILLEGAL_VALUE;
    }      
    aRule = (nsICSSRule*)mRules->ElementAt(aIndex);
    return NS_OK;
  }
  return NS_ERROR_ILLEGAL_VALUE;
}

Here is the call graph for this function:

NS_IMETHODIMP nsCSSRule::GetStyleSheet ( nsIStyleSheet *&  aSheet) const [inherited]

Reimplemented in CSSStyleRuleImpl.

Definition at line 64 of file nsCSSRule.cpp.

{
  NS_IF_ADDREF(mSheet);
  aSheet = mSheet;
  return NS_OK;
}
NS_IMETHOD nsICSSRule::GetStyleSheet ( nsIStyleSheet *&  aSheet) const [pure virtual, inherited]

Implemented in CSSStyleRuleImpl.

Here is the caller graph for this function:

NS_IMETHODIMP nsCSSDocumentRule::GetType ( PRInt32 aType) const [virtual]

Implements nsICSSRule.

Definition at line 1164 of file nsCSSRules.cpp.

{
  aType = nsICSSRule::DOCUMENT_RULE;
  return NS_OK;
}
unsigned long nsIDOMCSSMozDocumentRule::insertRule ( in DOMString  rule,
in unsigned long  index 
) raises (DOMException) [inherited]
nsresult nsCSSGroupRule::InsertRule ( const nsAString &  aRule,
PRUint32  aIndex,
PRUint32 _retval 
) [protected, inherited]

Definition at line 888 of file nsCSSRules.cpp.

{
  NS_ENSURE_TRUE(mSheet, NS_ERROR_FAILURE);
  
  if (!mRules) {
    nsresult rv = NS_NewISupportsArray(getter_AddRefs(mRules));
    if (NS_FAILED(rv))
      return rv;
  }

  PRUint32 count;
  mRules->Count(&count);
  if (aIndex > count)
    return NS_ERROR_DOM_INDEX_SIZE_ERR;
  
  return mSheet->InsertRuleIntoGroup(aRule, this, aIndex, _retval);
}

Here is the call graph for this function:

NS_IMETHODIMP nsCSSGroupRule::InsertStyleRulesAt ( PRUint32  aIndex,
nsISupportsArray aRules 
) [virtual, inherited]

Implements nsICSSGroupRule.

Definition at line 797 of file nsCSSRules.cpp.

{
  NS_ENSURE_TRUE(mRules, NS_ERROR_FAILURE);

  aRules->EnumerateForwards(SetStyleSheetReference, mSheet);
  aRules->EnumerateForwards(SetParentRuleReference, this);
  // There is no xpcom-compatible version of InsertElementsAt.... :(
  if (! mRules->InsertElementsAt(aRules, aIndex)) {
    return NS_ERROR_FAILURE;
  }
  return NS_OK;
}

Here is the call graph for this function:

NS_IMETHODIMP nsCSSRule::MapRuleInfoInto ( nsRuleData aRuleData) [inherited]

Reimplemented in CSSStyleRuleImpl.

Definition at line 92 of file nsCSSRule.cpp.

{
  // The nsIStyleRule contract is not appropriate for all CSS rules.
  NS_NOTREACHED("nsCSSRule::MapRuleInfoInto");
  return NS_OK;
}
NS_IMETHOD nsIStyleRule::MapRuleInfoInto ( nsRuleData aRuleData) [pure virtual, inherited]

|nsIStyleRule::MapRuleInfoInto| is a request to copy all stylistic data represented by the rule that:

  • are relevant for |aRuleData->mSID| (the style struct ID)
  • are not already filled into the data struct into the appropriate data struct in |aRuleData|. It is important that only empty data are filled in, since the rule tree is walked from highest priority rule to least, so that the walk can stop if all needed data are found. Thus overwriting non-empty data will break CSS cascading rules.

Implemented in CSSStyleRuleImpl, CSSImportantRule, nsHTMLStyleSheet::TableUngroupedColRule, nsHTMLStyleSheet::TableColRule, nsHTMLStyleSheet::TableColgroupRule, nsHTMLStyleSheet::TableRowRule, nsHTMLStyleSheet::TableTbodyRule, nsHTMLStyleSheet::TableTHRule, nsHTMLStyleSheet::GenericTableRule, nsHTMLStyleSheet::HTMLColorRule, CSSFirstLetterRule, nsMappedAttributes, CSSFirstLineRule, and BodyRule.

Here is the caller graph for this function:

nsCSSRule::NS_IMETHOD_ ( nsrefcnt  ) [inherited]
NS_DECL_NSIDOMCSSRULE NS_DECL_NSIDOMCSSMOZDOCUMENTRULE nsCSSDocumentRule::NS_IMETHOD_ ( PRBool  ) [virtual]

Implements nsICSSGroupRule.

NS_IMETHODIMP nsCSSGroupRule::ReplaceStyleRule ( nsICSSRule aOld,
nsICSSRule aNew 
) [virtual, inherited]

Implements nsICSSGroupRule.

Definition at line 811 of file nsCSSRules.cpp.

{
  PRInt32 index = mRules->IndexOf(aOld);
  NS_ENSURE_TRUE(index != -1, NS_ERROR_UNEXPECTED);
  mRules->ReplaceElementAt(aNew, index);
  aNew->SetStyleSheet(mSheet);
  aNew->SetParentRule(this);
  aOld->SetStyleSheet(nsnull);
  aOld->SetParentRule(nsnull);
  return NS_OK;
}

Here is the call graph for this function:

Reimplemented in CSSStyleRuleImpl.

Definition at line 82 of file nsCSSRule.cpp.

{
  // We don't reference count this up reference. The group rule
  // will tell us when it's going away or when we're detached from
  // it.
  mParentRule = aRule;
  return NS_OK;
}
NS_IMETHOD nsICSSRule::SetParentRule ( nsICSSGroupRule aRule) [pure virtual, inherited]

Implemented in CSSStyleRuleImpl.

Here is the caller graph for this function:

Reimplemented in CSSStyleRuleImpl, and nsCSSMediaRule.

Definition at line 72 of file nsCSSRule.cpp.

{
  // We don't reference count this up reference. The style sheet
  // will tell us when it's going away or when we're detached from
  // it.
  mSheet = aSheet;
  return NS_OK;
}

Here is the caller graph for this function:

NS_IMETHOD nsICSSRule::SetStyleSheet ( nsICSSStyleSheet aSheet) [pure virtual, inherited]

Implemented in CSSStyleRuleImpl, and nsCSSMediaRule.

Here is the caller graph for this function:

void nsCSSDocumentRule::SetURLs ( URL aURLs) [inline]

Definition at line 192 of file nsCSSRules.h.

{ mURLs = aURLs; }
NS_IMETHODIMP nsCSSGroupRule::StyleRuleCount ( PRInt32 aCount) const [virtual, inherited]

Implements nsICSSGroupRule.

Definition at line 738 of file nsCSSRules.cpp.

{
  if (mRules) {
    PRUint32 count;
    mRules->Count(&count);
    aCount = (PRInt32)count;
  }
  else {
    aCount = 0;
  }
  return NS_OK;
}

Here is the caller graph for this function:


Member Data Documentation

const unsigned short nsIDOMCSSRule::CHARSET_RULE = 2 [inherited]

Definition at line 58 of file nsIDOMCSSRule.idl.

Definition at line 46 of file nsIDOMCSSMozDocumentRule.idl.

attribute DOMString nsIDOMCSSRule::cssText [inherited]

Definition at line 65 of file nsIDOMCSSRule.idl.

const unsigned short nsIDOMCSSRule::FONT_FACE_RULE = 5 [inherited]

Definition at line 61 of file nsIDOMCSSRule.idl.

const unsigned short nsIDOMCSSRule::IMPORT_RULE = 3 [inherited]

Definition at line 59 of file nsIDOMCSSRule.idl.

const unsigned short nsIDOMCSSRule::MEDIA_RULE = 4 [inherited]

Definition at line 60 of file nsIDOMCSSRule.idl.

nsICSSGroupRule* nsCSSRule::mParentRule [protected, inherited]

Definition at line 73 of file nsCSSRule.h.

nsAutoRefCnt nsCSSRule::mRefCnt [protected, inherited]

Definition at line 58 of file nsCSSRule.h.

Definition at line 104 of file nsCSSRules.h.

Definition at line 103 of file nsCSSRules.h.

nsICSSStyleSheet* nsCSSRule::mSheet [protected, inherited]

Definition at line 72 of file nsCSSRule.h.

Definition at line 195 of file nsCSSRules.h.

const unsigned short nsIDOMCSSRule::PAGE_RULE = 6 [inherited]

Definition at line 62 of file nsIDOMCSSRule.idl.

Definition at line 69 of file nsIDOMCSSRule.idl.

Definition at line 68 of file nsIDOMCSSRule.idl.

const unsigned short nsIDOMCSSRule::STYLE_RULE = 1 [inherited]

Definition at line 57 of file nsIDOMCSSRule.idl.

readonly attribute unsigned short nsIDOMCSSRule::type [inherited]

Definition at line 64 of file nsIDOMCSSRule.idl.

const unsigned short nsIDOMCSSRule::UNKNOWN_RULE = 0 [inherited]

Definition at line 56 of file nsIDOMCSSRule.idl.


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