Back to index

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

#include <nsCSSRules.h>

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

List of all members.

Public Types

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

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_ (nsrefcnt) Release()
NS_IMETHOD GetStyleSheet (nsIStyleSheet *&aSheet) const
NS_IMETHOD SetStyleSheet (nsICSSStyleSheet *aSheet)
NS_IMETHOD SetParentRule (nsICSSGroupRule *aRule)
NS_IMETHOD MapRuleInfoInto (nsRuleData *aRuleData)
 NS_IMETHOD_ (PRBool) UseForPresentation(nsPresContext *aPresContext)=0
NS_IMETHOD GetType (PRInt32 &aType) const =0
NS_IMETHOD GetStyleSheet (nsIStyleSheet *&aSheet) const =0
NS_IMETHOD SetStyleSheet (nsICSSStyleSheet *aSheet)=0
NS_IMETHOD SetParentRule (nsICSSGroupRule *aRule)=0
NS_IMETHOD Clone (nsICSSRule *&aClone) const =0
NS_IMETHOD GetDOMRule (nsIDOMCSSRule **aDOMRule)=0
NS_IMETHOD MapRuleInfoInto (nsRuleData *aRuleData)=0
 |nsIStyleRule::MapRuleInfoInto| is a request to copy all stylistic data represented by the rule that:

Protected Member Functions

 nsCSSGroupRule ()
 nsCSSGroupRule (const nsCSSGroupRule &aCopy)
 ~nsCSSGroupRule ()
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

nsCOMPtr< nsISupportsArraymRules
CSSGroupRuleRuleListImplmRuleCollection
nsAutoRefCnt mRefCnt
nsICSSStyleSheetmSheet
nsICSSGroupRulemParentRule

Detailed Description

Definition at line 64 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.


Constructor & Destructor Documentation

Definition at line 623 of file nsCSSRules.cpp.

Definition at line 652 of file nsCSSRules.cpp.

  : nsCSSRule(aCopy)
  , mRuleCollection(nsnull) // lazily constructed
{
  if (aCopy.mRules) {
    NS_NewISupportsArray(getter_AddRefs(mRules));
    if (mRules) {
      aCopy.mRules->EnumerateForwards(CloneRuleInto, mRules);
      mRules->EnumerateForwards(SetParentRuleReference, this);
    }
  }
}

Here is the call graph for this function:

Definition at line 665 of file nsCSSRules.cpp.

Here is the call graph for this function:


Member Function Documentation

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

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:

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_IMETHOD nsICSSRule::Clone ( nsICSSRule *&  aClone) const [pure virtual, inherited]

Implemented in CSSNameSpaceRuleImpl, CSSStyleRuleImpl, CSSImportRuleImpl, CSSCharsetRuleImpl, nsCSSDocumentRule, and nsCSSMediaRule.

Here is the caller graph for this function:

nsresult nsCSSGroupRule::DeleteRule ( PRUint32  aIndex) [protected]

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:

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:

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

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]

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:

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]

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_IMETHOD nsICSSRule::GetType ( PRInt32 aType) const [pure virtual, inherited]

Implemented in CSSNameSpaceRuleImpl, CSSStyleRuleImpl, CSSImportRuleImpl, CSSCharsetRuleImpl, nsCSSDocumentRule, and nsCSSMediaRule.

Here is the caller graph for this function:

nsresult nsCSSGroupRule::InsertRule ( const nsAString &  aRule,
PRUint32  aIndex,
PRUint32 _retval 
) [protected]

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:

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]
nsCSSRule::NS_IMETHOD_ ( nsrefcnt  ) [inherited]
nsICSSGroupRule::NS_IMETHOD_ ( PRBool  ) [pure virtual, inherited]

Implemented in nsCSSDocumentRule, and nsCSSMediaRule.

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:

NS_IMETHODIMP nsCSSGroupRule::StyleRuleCount ( PRInt32 aCount) const [virtual]

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

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.


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