Back to index

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

#include <nsDOMCSSAttrDeclaration.h>

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

List of all members.

Public Member Functions

 nsDOMCSSAttributeDeclaration (nsIStyledContent *aContent)
 ~nsDOMCSSAttributeDeclaration ()
 NS_IMETHOD_ (nsrefcnt) AddRef(void)
 NS_IMETHOD_ (nsrefcnt) Release(void)
virtual void DropReference ()
virtual nsresult GetCSSDeclaration (nsCSSDeclaration **aDecl, PRBool aAllocate)
virtual nsresult GetCSSParsingEnvironment (nsIURI **aSheetURI, nsIURI **aBaseURI, nsICSSLoader **aCSSLoader, nsICSSParser **aCSSParser)
NS_IMETHOD GetParentRule (nsIDOMCSSRule **aParent)
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

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

Protected Attributes

nsAutoRefCnt mRefCnt
NS_DECL_OWNINGTHREAD
nsIStyledContent
mContent

Detailed Description

Definition at line 51 of file nsDOMCSSAttrDeclaration.h.


Constructor & Destructor Documentation

Definition at line 54 of file nsDOMCSSAttrDeclaration.cpp.

{
  MOZ_COUNT_CTOR(nsDOMCSSAttributeDeclaration);

  // This reference is not reference-counted. The content
  // object tells us when its about to go away.
  mContent = aContent;
}

Member Function Documentation

Implements nsDOMCSSDeclaration.

Definition at line 78 of file nsDOMCSSAttrDeclaration.cpp.

{
  NS_ASSERTION(mContent, "Must have content node to set the decl!");
  nsICSSStyleRule* oldRule = mContent->GetInlineStyleRule();
  NS_ASSERTION(oldRule, "content must have rule");

  nsCOMPtr<nsICSSStyleRule> newRule = oldRule->DeclarationChanged(PR_FALSE);
  if (!newRule) {
    return NS_ERROR_OUT_OF_MEMORY;
  }
    
  return mContent->SetInlineStyleRule(newRule, PR_TRUE);
}

Here is the call graph for this function:

Implements nsDOMCSSDeclaration.

Definition at line 72 of file nsDOMCSSAttrDeclaration.cpp.

Implements nsDOMCSSDeclaration.

Definition at line 93 of file nsDOMCSSAttrDeclaration.cpp.

{
  nsresult result = NS_OK;

  *aDecl = nsnull;
  if (mContent) {
    nsICSSStyleRule* cssRule = mContent->GetInlineStyleRule();
    if (cssRule) {
      *aDecl = cssRule->GetDeclaration();
    }
    else if (aAllocate) {
      nsCSSDeclaration *decl = new nsCSSDeclaration();
      if (!decl)
        return NS_ERROR_OUT_OF_MEMORY;
      if (!decl->InitializeEmpty()) {
        decl->RuleAbort();
        return NS_ERROR_OUT_OF_MEMORY;
      }
      
      nsCOMPtr<nsICSSStyleRule> newRule;
      result = NS_NewCSSStyleRule(getter_AddRefs(newRule), nsnull, decl);
      if (NS_FAILED(result)) {
        decl->RuleAbort();
        return result;
      }
        
      result = mContent->SetInlineStyleRule(newRule, PR_FALSE);
      if (NS_SUCCEEDED(result)) {
        *aDecl = decl;
      }
    }
  }

  return result;
}

Here is the call graph for this function:

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

Implements nsDOMCSSDeclaration.

Definition at line 136 of file nsDOMCSSAttrDeclaration.cpp.

{
  NS_ASSERTION(mContent, "Something is severely broken -- there should be an nsIContent here!");
  // null out the out params since some of them may not get initialized below
  *aSheetURI = nsnull;
  *aBaseURI = nsnull;
  *aCSSLoader = nsnull;
  *aCSSParser = nsnull;

  nsIDocument* doc = mContent->GetOwnerDoc();
  if (!doc) {
    // document has been destroyed
    return NS_ERROR_NOT_AVAILABLE;
  }

  nsCOMPtr<nsIURI> baseURI = mContent->GetBaseURI();
  nsCOMPtr<nsIURI> sheetURI = doc->GetDocumentURI();

  NS_ADDREF(*aCSSLoader = doc->CSSLoader());
  
  nsresult rv = NS_OK;

  // Note: parsers coming from a CSSLoader for a document already have
  // the right case-sensitivity, quirkiness, etc.
  rv = (*aCSSLoader)->GetParserFor(nsnull, aCSSParser);
  if (NS_FAILED(rv)) {
    return rv;
  }
  
  baseURI.swap(*aBaseURI);
  sheetURI.swap(*aSheetURI);

  return NS_OK;
}

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 175 of file nsDOMCSSAttrDeclaration.cpp.

{
  NS_ENSURE_ARG_POINTER(aParent);

  *aParent = nsnull;
  return NS_OK;
}
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:

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


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 78 of file nsDOMCSSAttrDeclaration.h.

Definition at line 75 of file nsDOMCSSAttrDeclaration.h.

Definition at line 69 of file nsIDOMCSSStyleDeclaration.idl.


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