Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | Private Member Functions | Friends
DOMCSSDeclarationImpl Class Reference
Inheritance diagram for DOMCSSDeclarationImpl:
Inheritance graph
[legend]
Collaboration diagram for DOMCSSDeclarationImpl:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 DOMCSSDeclarationImpl (nsICSSStyleRule *aRule)
virtual ~DOMCSSDeclarationImpl (void)
NS_IMETHOD GetParentRule (nsIDOMCSSRule **aParent)
virtual void DropReference (void)
virtual nsresult GetCSSDeclaration (nsCSSDeclaration **aDecl, PRBool aAllocate)
virtual nsresult GetCSSParsingEnvironment (nsIURI **aSheetURI, nsIURI **aBaseURI, nsICSSLoader **aCSSLoader, nsICSSParser **aCSSParser)
virtual nsresult DeclarationChanged ()
 NS_IMETHOD_ (nsrefcnt) AddRef(void)
 NS_IMETHOD_ (nsrefcnt) Release(void)
NS_IMETHOD QueryInterface (REFNSIID aIID, void **aInstancePtr)
NS_DECL_NSICSSDECLARATION
NS_IMETHOD 
GetCssText (nsAString &aCssText)
NS_IMETHOD SetCssText (const nsAString &aCssText)
NS_IMETHOD GetPropertyValue (const nsAString &propertyName, nsAString &_retval)
NS_IMETHOD GetPropertyValue (const nsCSSProperty aPropID, nsAString &aValue)=0
 Method analogous to nsIDOMCSSStyleDeclaration::GetPropertyValue, which obeys all the same restrictions.
NS_IMETHOD GetPropertyCSSValue (const nsAString &propertyName, nsIDOMCSSValue **_retval)
NS_IMETHOD RemoveProperty (const nsAString &propertyName, nsAString &_retval)
NS_IMETHOD GetPropertyPriority (const nsAString &propertyName, nsAString &_retval)
NS_IMETHOD SetProperty (const nsAString &propertyName, const nsAString &value, const nsAString &priority)
NS_IMETHOD GetLength (PRUint32 *aLength)
NS_IMETHOD Item (PRUint32 index, nsAString &_retval)
NS_IMETHOD SetPropertyValue (const nsCSSProperty aPropID, const nsAString &aValue)=0
 Method analogous to nsIDOMCSSStyleDeclaration::SetProperty.
DOMString getPropertyValue (in DOMString propertyName)
nsIDOMCSSValue getPropertyCSSValue (in DOMString propertyName)
DOMString removeProperty (in DOMString propertyName) raises (DOMException)
DOMString getPropertyPriority (in DOMString propertyName)
void setProperty (in DOMString propertyName, in DOMString value, in DOMString priority) raises (DOMException)
DOMString item (in unsigned long index)

Public Attributes

attribute DOMString cssText
readonly attribute unsigned long length
readonly attribute nsIDOMCSSRule parentRule

Protected Member Functions

DOMCSSStyleRuleImplDomRule ()
nsresult RemoveProperty (const nsCSSProperty aPropID)
nsresult ParsePropertyValue (const nsCSSProperty aPropID, const nsAString &aPropValue)
nsresult ParseDeclaration (const nsAString &aDecl, PRBool aParseOnlyOneDecl, PRBool aClearOldDecl)

Protected Attributes

nsICSSStyleRulemRule

Private Member Functions

voidoperator new (size_t size) CPP_THROW_NEW

Friends

class DOMCSSStyleRuleImpl

Detailed Description

Definition at line 812 of file nsCSSStyleRule.cpp.


Constructor & Destructor Documentation

Definition at line 876 of file nsCSSStyleRule.cpp.

Definition at line 882 of file nsCSSStyleRule.cpp.

{
  NS_ASSERTION(!mRule, "DropReference not called.");

  MOZ_COUNT_DTOR(DOMCSSDeclarationImpl);
}

Member Function Documentation

Implements nsDOMCSSDeclaration.

Definition at line 973 of file nsCSSStyleRule.cpp.

{
  NS_PRECONDITION(mRule,
         "can only be called when |GetCSSDeclaration| returned a declaration");

  nsCOMPtr<nsIDocument> owningDoc;
  nsCOMPtr<nsIStyleSheet> sheet;
  mRule->GetStyleSheet(*getter_AddRefs(sheet));
  if (sheet) {
    sheet->GetOwningDocument(*getter_AddRefs(owningDoc));
  }

  mozAutoDocUpdate updateBatch(owningDoc, UPDATE_STYLE, PR_TRUE);

  nsCOMPtr<nsICSSStyleRule> oldRule = mRule;
  mRule = oldRule->DeclarationChanged(PR_TRUE).get();
  if (!mRule)
    return NS_ERROR_OUT_OF_MEMORY;
  nsrefcnt cnt = mRule->Release();
  if (cnt == 0) {
    NS_NOTREACHED("container didn't take ownership");
    mRule = nsnull;
    return NS_ERROR_UNEXPECTED;
  }

  if (owningDoc) {
    owningDoc->StyleRuleChanged(sheet, oldRule, mRule);
  }
  return NS_OK;
}

Here is the call graph for this function:

Definition at line 889 of file nsCSSStyleRule.cpp.

Implements nsDOMCSSDeclaration.

Definition at line 900 of file nsCSSStyleRule.cpp.

{
  mRule = nsnull;
}

Here is the caller graph for this function:

Implements nsDOMCSSDeclaration.

Definition at line 906 of file nsCSSStyleRule.cpp.

{
  if (mRule) {
    *aDecl = mRule->GetDeclaration();
  }
  else {
    *aDecl = nsnull;
  }

  return NS_OK;
}

Here is the call graph for this function:

nsresult DOMCSSDeclarationImpl::GetCSSParsingEnvironment ( nsIURI **  aSheetURI,
nsIURI **  aBaseURI,
nsICSSLoader **  aCSSLoader,
nsICSSParser **  aCSSParser 
) [virtual]

Implements nsDOMCSSDeclaration.

Definition at line 925 of file nsCSSStyleRule.cpp.

{
  // null out the out params since some of them may not get initialized below
  *aSheetURI = nsnull;
  *aBaseURI = nsnull;
  *aCSSLoader = nsnull;
  *aCSSParser = nsnull;
  nsresult result;
  nsCOMPtr<nsIStyleSheet> sheet;
  if (mRule) {
    mRule->GetStyleSheet(*getter_AddRefs(sheet));
    if (sheet) {
      sheet->GetSheetURI(aSheetURI);
      sheet->GetBaseURI(aBaseURI);
      nsCOMPtr<nsIDocument> document;
      sheet->GetOwningDocument(*getter_AddRefs(document));
      if (document) {
        NS_ADDREF(*aCSSLoader = document->CSSLoader());
      }
    }
  }
  // XXXldb Why bother if |mRule| is null?
  if (*aCSSLoader) {
    result = (*aCSSLoader)->GetParserFor(nsnull, aCSSParser);
  } else {
    result = NS_NewCSSParser(aCSSParser);
  }

  return result;
}

Here is the call graph for this function:

NS_IMETHODIMP nsDOMCSSDeclaration::GetCssText ( nsAString &  aCssText) [inherited]

Definition at line 106 of file nsDOMCSSDeclaration.cpp.

{
  nsCSSDeclaration* decl;
  aCssText.Truncate();
  GetCSSDeclaration(&decl, PR_FALSE);

  if (decl) {
    decl->ToString(aCssText);
  }

  return NS_OK;
}

Here is the call graph for this function:

Definition at line 126 of file nsDOMCSSDeclaration.cpp.

{
  nsCSSDeclaration *decl;
  nsresult result = GetCSSDeclaration(&decl, PR_FALSE);
 
  if (decl) {
    *aLength = decl->Count();
  } else {
    *aLength = 0;
  }

  return result;
}

Here is the call graph for this function:

Implements nsDOMCSSDeclaration.

Definition at line 960 of file nsCSSStyleRule.cpp.

{
  NS_ENSURE_ARG_POINTER(aParent);

  if (!mRule) {
    *aParent = nsnull;
    return NS_OK;
  }

  return mRule->GetDOMRule(aParent);
}

Here is the call graph for this function:

nsIDOMCSSValue nsIDOMCSSStyleDeclaration::getPropertyCSSValue ( in DOMString  propertyName) [inherited]
NS_IMETHODIMP nsDOMCSSDeclaration::GetPropertyCSSValue ( const nsAString &  propertyName,
nsIDOMCSSValue **  _retval 
) [inherited]

Definition at line 141 of file nsDOMCSSDeclaration.cpp.

{
  NS_ENSURE_ARG_POINTER(aReturn);

  // We don't support CSSValue yet so we'll just return null...
  *aReturn = nsnull;

  return NS_OK;
}
DOMString nsIDOMCSSStyleDeclaration::getPropertyPriority ( in DOMString  propertyName) [inherited]
NS_IMETHODIMP nsDOMCSSDeclaration::GetPropertyPriority ( const nsAString &  propertyName,
nsAString &  _retval 
) [inherited]

Definition at line 180 of file nsDOMCSSDeclaration.cpp.

{
  nsCSSDeclaration *decl;
  nsresult result = GetCSSDeclaration(&decl, PR_FALSE);

  aReturn.Truncate();
  if (decl && decl->GetValueIsImportant(aPropertyName)) {
    aReturn.AssignLiteral("important");    
  }

  return result;
}

Here is the call graph for this function:

DOMString nsIDOMCSSStyleDeclaration::getPropertyValue ( in DOMString  propertyName) [inherited]
NS_IMETHOD nsICSSDeclaration::GetPropertyValue ( const nsCSSProperty  aPropID,
nsAString &  aValue 
) [pure virtual, inherited]

Method analogous to nsIDOMCSSStyleDeclaration::GetPropertyValue, which obeys all the same restrictions.

NS_IMETHODIMP nsDOMCSSDeclaration::GetPropertyValue ( const nsAString &  propertyName,
nsAString &  _retval 
) [virtual, inherited]

Implements nsICSSDeclaration.

Definition at line 74 of file nsDOMCSSDeclaration.cpp.

{
  NS_PRECONDITION(aPropID != eCSSProperty_UNKNOWN,
                  "Should never pass eCSSProperty_UNKNOWN around");
  
  nsCSSDeclaration *decl;
  nsresult result = GetCSSDeclaration(&decl, PR_FALSE);

  aValue.Truncate();
  if (decl) {
    result = decl->GetValue(aPropID, aValue);
  }

  return result;
}

Here is the call graph for this function:

Here is the caller graph for this function:

DOMString nsIDOMCSSStyleDeclaration::item ( in unsigned long  index) [inherited]

Here is the caller graph for this function:

NS_IMETHODIMP nsDOMCSSDeclaration::Item ( PRUint32  index,
nsAString &  _retval 
) [inherited]

Definition at line 153 of file nsDOMCSSDeclaration.cpp.

{
  nsCSSDeclaration *decl;
  nsresult result = GetCSSDeclaration(&decl, PR_FALSE);

  aReturn.SetLength(0);
  if (decl) {
    result = decl->GetNthProperty(aIndex, aReturn);
  }

  return result;
}

Here is the call graph for this function:

void* DOMCSSDeclarationImpl::operator new ( size_t  size) [private]
nsresult nsDOMCSSDeclaration::ParseDeclaration ( const nsAString &  aDecl,
PRBool  aParseOnlyOneDecl,
PRBool  aClearOldDecl 
) [protected, inherited]

Definition at line 278 of file nsDOMCSSDeclaration.cpp.

{
  nsCSSDeclaration* decl;
  nsresult result = GetCSSDeclaration(&decl, PR_TRUE);
  if (!decl) {
    return result;
  }

  nsCOMPtr<nsICSSLoader> cssLoader;
  nsCOMPtr<nsICSSParser> cssParser;
  nsCOMPtr<nsIURI> baseURI, sheetURI;

  result = GetCSSParsingEnvironment(getter_AddRefs(sheetURI),
                                    getter_AddRefs(baseURI),
                                    getter_AddRefs(cssLoader),
                                    getter_AddRefs(cssParser));

  if (NS_FAILED(result)) {
    return result;
  }

  PRBool changed;
  result = cssParser->ParseAndAppendDeclaration(aDecl, sheetURI, baseURI, decl,
                                                aParseOnlyOneDecl,
                                                &changed,
                                                aClearOldDecl);
  
  if (NS_SUCCEEDED(result) && changed) {
    result = DeclarationChanged();
  }

  if (cssLoader) {
    cssLoader->RecycleParser(cssParser);
  }

  return result;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsDOMCSSDeclaration::ParsePropertyValue ( const nsCSSProperty  aPropID,
const nsAString &  aPropValue 
) [protected, inherited]

Definition at line 242 of file nsDOMCSSDeclaration.cpp.

{
  nsCSSDeclaration* decl;
  nsresult result = GetCSSDeclaration(&decl, PR_TRUE);
  if (!decl) {
    return result;
  }
  
  nsCOMPtr<nsICSSLoader> cssLoader;
  nsCOMPtr<nsICSSParser> cssParser;
  nsCOMPtr<nsIURI> baseURI, sheetURI;
  
  result = GetCSSParsingEnvironment(getter_AddRefs(sheetURI),
                                    getter_AddRefs(baseURI),
                                    getter_AddRefs(cssLoader),
                                    getter_AddRefs(cssParser));
  if (NS_FAILED(result)) {
    return result;
  }

  PRBool changed;
  result = cssParser->ParseProperty(aPropID, aPropValue, sheetURI, baseURI,
                                    decl, &changed);
  if (NS_SUCCEEDED(result) && changed) {
    result = DeclarationChanged();
  }

  if (cssLoader) {
    cssLoader->RecycleParser(cssParser);
  }

  return result;
}

Here is the call graph for this function:

Here is the caller graph for this function:

NS_IMETHOD nsDOMCSSDeclaration::QueryInterface ( REFNSIID  aIID,
void **  aInstancePtr 
) [inherited]
DOMString nsIDOMCSSStyleDeclaration::removeProperty ( in DOMString  propertyName) raises (DOMException) [inherited]
NS_IMETHODIMP nsDOMCSSDeclaration::RemoveProperty ( const nsAString &  propertyName,
nsAString &  _retval 
) [inherited]

Definition at line 225 of file nsDOMCSSDeclaration.cpp.

{
  const nsCSSProperty propID = nsCSSProps::LookupProperty(aPropertyName);
  if (propID == eCSSProperty_UNKNOWN) {
    aReturn.Truncate();
    return NS_OK;
  }
  
  nsresult rv = GetPropertyValue(propID, aReturn);
  NS_ENSURE_SUCCESS(rv, rv);
  
  rv = RemoveProperty(propID);
  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsDOMCSSDeclaration::RemoveProperty ( const nsCSSProperty  aPropID) [protected, inherited]

Definition at line 319 of file nsDOMCSSDeclaration.cpp.

{
  nsCSSDeclaration* decl;
  nsresult rv = GetCSSDeclaration(&decl, PR_FALSE);
  if (!decl) {
    return rv;
  }

  rv = decl->RemoveProperty(aPropID);

  if (NS_SUCCEEDED(rv)) {
    rv = DeclarationChanged();
  } else {
    // RemoveProperty used to throw in all sorts of situations -- e.g.
    // if the property was a shorthand one.  Do not propagate its return
    // value to callers.  (XXX or should we propagate it again now?)
    rv = NS_OK;
  }

  return rv;
}

Here is the call graph for this function:

NS_IMETHODIMP nsDOMCSSDeclaration::SetCssText ( const nsAString &  aCssText) [inherited]

Definition at line 120 of file nsDOMCSSDeclaration.cpp.

{
  return ParseDeclaration(aCssText, PR_FALSE, PR_TRUE);
}

Here is the call graph for this function:

void nsIDOMCSSStyleDeclaration::setProperty ( in DOMString  propertyName,
in DOMString  value,
in DOMString  priority 
) raises (DOMException) [inherited]
NS_IMETHODIMP nsDOMCSSDeclaration::SetProperty ( const nsAString &  propertyName,
const nsAString &  value,
const nsAString &  priority 
) [inherited]

Definition at line 195 of file nsDOMCSSDeclaration.cpp.

{
  // In the common (and fast) cases we can use the property id
  nsCSSProperty propID = nsCSSProps::LookupProperty(aPropertyName);
  if (propID == eCSSProperty_UNKNOWN) {
    return NS_OK;
  }
  
  if (aValue.IsEmpty()) {
    // If the new value of the property is an empty string we remove the
    // property.
    return RemoveProperty(propID);
  }

  if (aPriority.IsEmpty()) {
    return ParsePropertyValue(propID, aValue);
  }

  // ParsePropertyValue does not handle priorities correctly -- it's
  // optimized for speed.  And the priority is not part of the
  // property value anyway.... So we have to use the full-blown
  // ParseDeclaration()
  return ParseDeclaration(aPropertyName + NS_LITERAL_STRING(":") +
                          aValue + NS_LITERAL_STRING("!") + aPriority,
                          PR_TRUE, PR_FALSE);
}

Here is the call graph for this function:

NS_IMETHOD nsICSSDeclaration::SetPropertyValue ( const nsCSSProperty  aPropID,
const nsAString &  aValue 
) [pure virtual, inherited]

Method analogous to nsIDOMCSSStyleDeclaration::SetProperty.

This method does NOT allow setting a priority (the priority will always be set to default priority).


Friends And Related Function Documentation

friend class DOMCSSStyleRuleImpl [friend]

Definition at line 833 of file nsCSSStyleRule.cpp.


Member Data Documentation

Definition at line 55 of file nsIDOMCSSStyleDeclaration.idl.

readonly attribute unsigned long nsIDOMCSSStyleDeclaration::length [inherited]

Definition at line 67 of file nsIDOMCSSStyleDeclaration.idl.

Definition at line 838 of file nsCSSStyleRule.cpp.

Definition at line 69 of file nsIDOMCSSStyleDeclaration.idl.


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