Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Public Attributes | Protected Member Functions | Private Attributes
nsDOMCSSDeclaration Class Reference

#include <nsDOMCSSDeclaration.h>

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

List of all members.

Public Member Functions

 nsDOMCSSDeclaration ()
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 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 GetParentRule (nsIDOMCSSRule **aParentRule)=0
virtual void DropReference ()=0
NS_IMETHOD GetPropertyValue (const nsCSSProperty aPropID, nsAString &aValue)=0
 Method analogous to nsIDOMCSSStyleDeclaration::GetPropertyValue, which obeys all the same restrictions.
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

virtual nsresult GetCSSDeclaration (nsCSSDeclaration **aDecl, PRBool aAllocate)=0
virtual nsresult DeclarationChanged ()=0
virtual nsresult GetCSSParsingEnvironment (nsIURI **aSheetURI, nsIURI **aBaseURI, nsICSSLoader **aCSSLoader, nsICSSParser **aCSSParser)=0
nsresult ParsePropertyValue (const nsCSSProperty aPropID, const nsAString &aPropValue)
nsresult ParseDeclaration (const nsAString &aDecl, PRBool aParseOnlyOneDecl, PRBool aClearOldDecl)
nsresult RemoveProperty (const nsCSSProperty aPropID)
virtual ~nsDOMCSSDeclaration ()

Private Attributes

CSS2PropertiesTearoff mInner

Detailed Description

Definition at line 63 of file nsDOMCSSDeclaration.h.


Constructor & Destructor Documentation

Definition at line 53 of file nsDOMCSSDeclaration.cpp.

  : mInner(this)
{
}

Definition at line 58 of file nsDOMCSSDeclaration.cpp.

{
}

Member Function Documentation

virtual nsresult nsDOMCSSDeclaration::DeclarationChanged ( ) [protected, pure virtual]

Implemented in DOMCSSDeclarationImpl, and nsDOMCSSAttributeDeclaration.

Here is the caller graph for this function:

virtual void nsDOMCSSDeclaration::DropReference ( ) [pure virtual]
virtual nsresult nsDOMCSSDeclaration::GetCSSDeclaration ( nsCSSDeclaration **  aDecl,
PRBool  aAllocate 
) [protected, pure virtual]

Implemented in DOMCSSDeclarationImpl, and nsDOMCSSAttributeDeclaration.

Here is the caller graph for this function:

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

Implemented in DOMCSSDeclarationImpl, and nsDOMCSSAttributeDeclaration.

Here is the caller graph for this function:

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:

NS_IMETHOD nsDOMCSSDeclaration::GetParentRule ( nsIDOMCSSRule **  aParentRule) [pure virtual]
nsIDOMCSSValue nsIDOMCSSStyleDeclaration::getPropertyCSSValue ( in DOMString  propertyName) [inherited]
NS_IMETHODIMP nsDOMCSSDeclaration::GetPropertyCSSValue ( const nsAString &  propertyName,
nsIDOMCSSValue **  _retval 
)

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 
)

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]

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 
)

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:

nsresult nsDOMCSSDeclaration::ParseDeclaration ( const nsAString &  aDecl,
PRBool  aParseOnlyOneDecl,
PRBool  aClearOldDecl 
) [protected]

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]

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:

DOMString nsIDOMCSSStyleDeclaration::removeProperty ( in DOMString  propertyName) raises (DOMException) [inherited]
NS_IMETHODIMP nsDOMCSSDeclaration::RemoveProperty ( const nsAString &  propertyName,
nsAString &  _retval 
)

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:

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:

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 
)

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).


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 122 of file nsDOMCSSDeclaration.h.

Definition at line 69 of file nsIDOMCSSStyleDeclaration.idl.


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