Back to index

lightning-sunbird  0.9+nobinonly
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions
CSSStyleRuleImpl Class Reference
Inheritance diagram for CSSStyleRuleImpl:
Inheritance graph
[legend]
Collaboration diagram for CSSStyleRuleImpl:
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

 CSSStyleRuleImpl (nsCSSSelectorList *aSelector, nsCSSDeclaration *aDeclaration)
virtual
NS_DECL_ISUPPORTS_INHERITED
nsCSSSelectorList
Selector (void)
virtual PRUint32 GetLineNumber (void) const
virtual void SetLineNumber (PRUint32 aLineNumber)
virtual nsCSSDeclarationGetDeclaration (void) const
virtual already_AddRefed
< nsIStyleRule
GetImportantRule (void)
NS_IMETHOD GetStyleSheet (nsIStyleSheet *&aSheet) const
NS_IMETHOD SetStyleSheet (nsICSSStyleSheet *aSheet)
NS_IMETHOD SetParentRule (nsICSSGroupRule *aRule)
virtual nsresult GetCssText (nsAString &aCssText)
virtual nsresult SetCssText (const nsAString &aCssText)
virtual nsresult GetParentStyleSheet (nsICSSStyleSheet **aSheet)
virtual nsresult GetParentRule (nsICSSGroupRule **aParentRule)
virtual nsresult GetSelectorText (nsAString &aSelectorText)
virtual nsresult SetSelectorText (const nsAString &aSelectorText)
NS_IMETHOD GetType (PRInt32 &aType) const
NS_IMETHOD Clone (nsICSSRule *&aClone) const
NS_IMETHOD GetDOMRule (nsIDOMCSSRule **aDOMRule)
virtual already_AddRefed
< nsICSSStyleRule
DeclarationChanged (PRBool aHandleContainer)
 Return a new |nsIStyleRule| instance that replaces the current one, due to a change in the |nsCSSDeclaration|.
NS_IMETHOD MapRuleInfoInto (nsRuleData *aRuleData)
 NS_IMETHOD_ (nsrefcnt) AddRef()
 NS_IMETHOD_ (nsrefcnt) Release()

Protected Member Functions

virtual ~CSSStyleRuleImpl (void)

Protected Attributes

nsCSSSelectorListmSelector
nsCSSDeclarationmDeclaration
CSSImportantRulemImportantRule
DOMCSSStyleRuleImplmDOMRule
PRUint32 mLineNumber
nsAutoRefCnt mRefCnt
nsICSSStyleSheetmSheet
nsICSSGroupRulemParentRule

Private Member Functions

 CSSStyleRuleImpl (const CSSStyleRuleImpl &aCopy)
 CSSStyleRuleImpl (CSSStyleRuleImpl &aCopy, nsCSSDeclaration *aDeclaration)
CSSStyleRuleImploperator= (const CSSStyleRuleImpl &aCopy)

Detailed Description

Definition at line 1120 of file nsCSSStyleRule.cpp.


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 1187 of file nsCSSStyleRule.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1200 of file nsCSSStyleRule.cpp.

  : nsCSSRule(aCopy),
    mSelector(aCopy.mSelector ? aCopy.mSelector->Clone() : nsnull),
    mDeclaration(aCopy.mDeclaration->Clone()),
    mImportantRule(nsnull),
    mDOMRule(nsnull),
    mLineNumber(aCopy.mLineNumber)
{
  if (mDeclaration)
    mDeclaration->AddRef();
  // rest is constructed lazily on existing data
}

Here is the call graph for this function:

CSSStyleRuleImpl::CSSStyleRuleImpl ( CSSStyleRuleImpl aCopy,
nsCSSDeclaration aDeclaration 
) [private]

Definition at line 1214 of file nsCSSStyleRule.cpp.

  : nsCSSRule(aCopy),
    mSelector(aCopy.mSelector),
    mDeclaration(aDeclaration),
    mImportantRule(nsnull),
    mDOMRule(aCopy.mDOMRule),
    mLineNumber(aCopy.mLineNumber)
{
  // The DOM rule is replacing |aCopy| with |this|, so transfer
  // the reverse pointer as well (and transfer ownership).
  aCopy.mDOMRule = nsnull;

  NS_ASSERTION(aDeclaration == aCopy.mDeclaration, "declaration mismatch");
  // Transfer ownership of selector and declaration:
  aCopy.mSelector = nsnull;
#if 0
  aCopy.mDeclaration = nsnull;
#else
  // We ought to be able to transfer ownership of the selector and the
  // declaration since this rule should now be unused, but unfortunately
  // SetInlineStyleRule might use it before setting the new rule (see
  // stack in bug 209575).  So leave the declaration pointer on the old
  // rule.
  mDeclaration->AddRef();
#endif
}

Here is the call graph for this function:

CSSStyleRuleImpl::~CSSStyleRuleImpl ( void  ) [protected, virtual]

Definition at line 1243 of file nsCSSStyleRule.cpp.

Here is the call graph for this function:


Member Function Documentation

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

Implements nsICSSRule.

Definition at line 1338 of file nsCSSStyleRule.cpp.

{
  CSSStyleRuleImpl* clone = new CSSStyleRuleImpl(*this);
  if (!clone || !clone->mDeclaration || (!clone->mSelector != !mSelector)) {
    delete clone;
    aClone = nsnull;
    return NS_ERROR_OUT_OF_MEMORY;
  }
  return CallQueryInterface(clone, &aClone);
}

Here is the call graph for this function:

Return a new |nsIStyleRule| instance that replaces the current one, due to a change in the |nsCSSDeclaration|.

Due to the |nsIStyleRule| contract of immutability, this must be called if the declaration is modified.

|DeclarationChanged| handles replacing the object in the container sheet or group rule if |aHandleContainer| is true.

Implements nsICSSStyleRule.

Definition at line 1372 of file nsCSSStyleRule.cpp.

{
  CSSStyleRuleImpl* clone = new CSSStyleRuleImpl(*this, mDeclaration);
  if (!clone) {
    return nsnull;
  }

  NS_ADDREF(clone); // for return

  if (aHandleContainer) {
    NS_ASSERTION(mSheet, "rule must be in a sheet");
    if (mParentRule) {
      mSheet->ReplaceRuleInGroup(mParentRule, this, clone);
    } else {
      mSheet->ReplaceStyleRule(this, clone);
    }
  }

  return clone;
}

Here is the call graph for this function:

nsresult CSSStyleRuleImpl::GetCssText ( nsAString &  aCssText) [virtual]

Implements nsICSSStyleRule.

Definition at line 1425 of file nsCSSStyleRule.cpp.

{
  if (mSelector) {
    mSelector->ToString(aCssText, mSheet);
    aCssText.Append(PRUnichar(' '));
  }
  aCssText.Append(PRUnichar('{'));
  aCssText.Append(PRUnichar(' '));
  if (mDeclaration)
  {
    nsAutoString   tempString;
    mDeclaration->ToString( tempString );
    aCssText.Append( tempString );
  }
  aCssText.Append(PRUnichar(' '));
  aCssText.Append(PRUnichar('}'));
  return NS_OK;
}

Here is the call graph for this function:

Implements nsICSSStyleRule.

Definition at line 1289 of file nsCSSStyleRule.cpp.

{
  return mDeclaration;
}

Implements nsICSSRule.

Definition at line 1350 of file nsCSSStyleRule.cpp.

{
  if (!mSheet) {
    // inline style rules aren't supposed to have a DOM rule object, only
    // a declaration.
    *aDOMRule = nsnull;
    return NS_OK;
  }
  if (!mDOMRule) {
    mDOMRule = new DOMCSSStyleRuleImpl(this);
    if (!mDOMRule) {
      *aDOMRule = nsnull;
      return NS_ERROR_OUT_OF_MEMORY;
    }
    NS_ADDREF(mDOMRule);
  }
  *aDOMRule = mDOMRule;
  NS_ADDREF(*aDOMRule);
  return NS_OK;
}

Here is the call graph for this function:

Implements nsICSSStyleRule.

Definition at line 1294 of file nsCSSStyleRule.cpp.

{
  if (!mDeclaration->HasImportantData()) {
    NS_ASSERTION(!mImportantRule, "immutable, so should be no important rule");
    return nsnull;
  }

  if (!mImportantRule) {
    mImportantRule = new CSSImportantRule(mDeclaration);
    if (!mImportantRule)
      return nsnull;
    NS_ADDREF(mImportantRule);
  }
  NS_ADDREF(mImportantRule);
  return mImportantRule;
}

Here is the call graph for this function:

Implements nsICSSStyleRule.

Definition at line 1279 of file nsCSSStyleRule.cpp.

{
  return mLineNumber;
}

Implements nsICSSStyleRule.

Definition at line 1460 of file nsCSSStyleRule.cpp.

{
  *aParentRule = mParentRule;
  NS_IF_ADDREF(*aParentRule);
  return NS_OK;
}

Implements nsICSSStyleRule.

Definition at line 1452 of file nsCSSStyleRule.cpp.

{
  *aSheet = mSheet;
  NS_IF_ADDREF(*aSheet);
  return NS_OK;
}
nsresult CSSStyleRuleImpl::GetSelectorText ( nsAString &  aSelectorText) [virtual]

Implements nsICSSStyleRule.

Definition at line 1468 of file nsCSSStyleRule.cpp.

{
  if (mSelector)
    mSelector->ToString(aSelectorText, mSheet);
  else
    aSelectorText.Truncate();
  return NS_OK;
}

Here is the call graph for this function:

Reimplemented from nsCSSRule.

Definition at line 1312 of file nsCSSStyleRule.cpp.

{
// XXX What about inner, etc.
  return nsCSSRule::GetStyleSheet(aSheet);
}
NS_IMETHODIMP CSSStyleRuleImpl::GetType ( PRInt32 aType) const [virtual]

Implements nsICSSRule.

Definition at line 1331 of file nsCSSStyleRule.cpp.

{
  aType = nsICSSRule::STYLE_RULE;
  return NS_OK;
}

Reimplemented from nsCSSRule.

Definition at line 1394 of file nsCSSStyleRule.cpp.

{
  return mDeclaration->MapRuleInfoInto(aRuleData);
}

Here is the call graph for this function:

nsCSSRule::NS_IMETHOD_ ( nsrefcnt  ) [inherited]
nsCSSRule::NS_IMETHOD_ ( nsrefcnt  ) [inherited]
CSSStyleRuleImpl& CSSStyleRuleImpl::operator= ( const CSSStyleRuleImpl aCopy) [private]

Implements nsICSSStyleRule.

Definition at line 1274 of file nsCSSStyleRule.cpp.

{
  return mSelector;
}
nsresult CSSStyleRuleImpl::SetCssText ( const nsAString &  aCssText) [virtual]

Implements nsICSSStyleRule.

Definition at line 1445 of file nsCSSStyleRule.cpp.

{
  // XXX TBI - need to re-parse rule & declaration
  return NS_OK;
}
void CSSStyleRuleImpl::SetLineNumber ( PRUint32  aLineNumber) [virtual]

Implements nsICSSStyleRule.

Definition at line 1284 of file nsCSSStyleRule.cpp.

{
  mLineNumber = aLineNumber;
}

Reimplemented from nsCSSRule.

Definition at line 1325 of file nsCSSStyleRule.cpp.

{
  return nsCSSRule::SetParentRule(aRule);
}
nsresult CSSStyleRuleImpl::SetSelectorText ( const nsAString &  aSelectorText) [virtual]

Implements nsICSSStyleRule.

Definition at line 1478 of file nsCSSStyleRule.cpp.

{
  // XXX TBI - get a parser and re-parse the selectors, 
  // XXX then need to re-compute the cascade
  // XXX and dirty sheet
  return NS_OK;
}

Reimplemented from nsCSSRule.

Definition at line 1319 of file nsCSSStyleRule.cpp.

{
  return nsCSSRule::SetStyleSheet(aSheet);
}

Member Data Documentation

Definition at line 1181 of file nsCSSStyleRule.cpp.

Definition at line 1183 of file nsCSSStyleRule.cpp.

Definition at line 1182 of file nsCSSStyleRule.cpp.

Definition at line 1184 of file nsCSSStyleRule.cpp.

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 1180 of file nsCSSStyleRule.cpp.

nsICSSStyleSheet* nsCSSRule::mSheet [protected, inherited]

Definition at line 72 of file nsCSSRule.h.


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