Back to index

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

#include <nsIMediaList.h>

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

List of all members.

Public Member Functions

 nsMediaList ()
NS_DECL_ISUPPORTS
NS_DECL_NSIDOMMEDIALIST
nsresult 
GetText (nsAString &aMediaText)
nsresult SetText (const nsAString &aMediaText)
PRBool Matches (nsPresContext *aPresContext)
nsresult SetStyleSheet (nsICSSStyleSheet *aSheet)
nsresult AppendAtom (nsIAtom *aMediumAtom)
nsresult Clone (nsMediaList **aResult)
PRInt32 Count ()
nsIAtomMediumAt (PRInt32 aIndex)
void Clear ()
DOMString item (in unsigned long index)
void deleteMedium (in DOMString oldMedium) raises (DOMException)
void appendMedium (in DOMString newMedium) raises (DOMException)

Public Attributes

attribute DOMString mediaText
readonly attribute unsigned long length

Protected Member Functions

 ~nsMediaList ()
nsresult Delete (const nsAString &aOldMedium)
nsresult Append (const nsAString &aOldMedium)

Protected Attributes

nsCOMArray< nsIAtommArray
nsCSSStyleSheetmStyleSheet

Detailed Description

Definition at line 49 of file nsIMediaList.h.


Constructor & Destructor Documentation

Definition at line 822 of file nsCSSStyleSheet.cpp.

Here is the caller graph for this function:

nsMediaList::~nsMediaList ( ) [protected]

Definition at line 827 of file nsCSSStyleSheet.cpp.

{
}

Member Function Documentation

nsresult nsMediaList::Append ( const nsAString &  aOldMedium) [protected]

Definition at line 1031 of file nsCSSStyleSheet.cpp.

{
  if (aNewMedium.IsEmpty())
    return NS_ERROR_DOM_NOT_FOUND_ERR;

  nsCOMPtr<nsIAtom> media = do_GetAtom(aNewMedium);
  NS_ENSURE_TRUE(media, NS_ERROR_OUT_OF_MEMORY);

  PRInt32 indx = mArray.IndexOf(media);

  if (indx >= 0) {
    mArray.RemoveObjectAt(indx);
  }

  mArray.AppendObject(media);

  return NS_OK;
}

Here is the call graph for this function:

nsresult nsMediaList::AppendAtom ( nsIAtom aMediumAtom) [inline]

Definition at line 61 of file nsIMediaList.h.

                                            {
    return mArray.AppendObject(aMediumAtom) ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
  }

Here is the call graph for this function:

Here is the caller graph for this function:

void nsIDOMMediaList::appendMedium ( in DOMString  newMedium) raises (DOMException) [inherited]
void nsMediaList::Clear ( void  ) [inline]

Definition at line 69 of file nsIMediaList.h.

{ mArray.Clear(); }

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 897 of file nsCSSStyleSheet.cpp.

{
  nsRefPtr<nsMediaList> result = new nsMediaList();
  if (!result)
    return NS_ERROR_OUT_OF_MEMORY;
  if (!result->mArray.AppendObjects(mArray))
    return NS_ERROR_OUT_OF_MEMORY;
  NS_ADDREF(*aResult = result);
  return NS_OK;
}

Here is the call graph for this function:

Definition at line 67 of file nsIMediaList.h.

{ return mArray.Count(); }

Here is the call graph for this function:

nsresult nsMediaList::Delete ( const nsAString &  aOldMedium) [protected]

Definition at line 1011 of file nsCSSStyleSheet.cpp.

{
  if (aOldMedium.IsEmpty())
    return NS_ERROR_DOM_NOT_FOUND_ERR;

  nsCOMPtr<nsIAtom> old = do_GetAtom(aOldMedium);
  NS_ENSURE_TRUE(old, NS_ERROR_OUT_OF_MEMORY);

  PRInt32 indx = mArray.IndexOf(old);

  if (indx < 0) {
    return NS_ERROR_DOM_NOT_FOUND_ERR;
  }

  mArray.RemoveObjectAt(indx);

  return NS_OK;
}

Here is the call graph for this function:

void nsIDOMMediaList::deleteMedium ( in DOMString  oldMedium) raises (DOMException) [inherited]
nsresult nsMediaList::GetText ( nsAString &  aMediaText)

Definition at line 832 of file nsCSSStyleSheet.cpp.

{
  aMediaText.Truncate();

  for (PRInt32 i = 0, i_end = mArray.Count(); i < i_end; ++i) {
    nsIAtom* medium = mArray[i];
    NS_ENSURE_TRUE(medium, NS_ERROR_FAILURE);

    nsAutoString buffer;
    medium->ToString(buffer);
    aMediaText.Append(buffer);
    if (i + 1 < i_end) {
      aMediaText.AppendLiteral(", ");
    }
  }

  return NS_OK;
}

Here is the call graph for this function:

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

Definition at line 879 of file nsCSSStyleSheet.cpp.

{
  if (-1 != mArray.IndexOf(aPresContext->Medium()) ||
      -1 != mArray.IndexOf(nsLayoutAtoms::all))
    return PR_TRUE;
  return mArray.Count() == 0;
}

Here is the call graph for this function:

nsIAtom* nsMediaList::MediumAt ( PRInt32  aIndex) [inline]

Definition at line 68 of file nsIMediaList.h.

{ return mArray[aIndex]; }

Definition at line 888 of file nsCSSStyleSheet.cpp.

{
  NS_ASSERTION(aSheet == mStyleSheet || !aSheet || !mStyleSheet,
               "multiple style sheets competing for one media list");
  mStyleSheet = NS_STATIC_CAST(nsCSSStyleSheet*, aSheet);
  return NS_OK;
}
nsresult nsMediaList::SetText ( const nsAString &  aMediaText)

Definition at line 854 of file nsCSSStyleSheet.cpp.

{
  nsCOMPtr<nsICSSParser> parser;
  nsresult rv = NS_NewCSSParser(getter_AddRefs(parser));
  NS_ENSURE_SUCCESS(rv, rv);

  PRBool htmlMode = PR_FALSE;
  nsCOMPtr<nsIDOMStyleSheet> domSheet =
    do_QueryInterface(NS_STATIC_CAST(nsICSSStyleSheet*, mStyleSheet));
  if (domSheet) {
    nsCOMPtr<nsIDOMNode> node;
    domSheet->GetOwnerNode(getter_AddRefs(node));
    htmlMode = !!node;
  }

  return parser->ParseMediaList(nsString(aMediaText), nsnull, 0,
                                this, htmlMode);
}

Here is the call graph for this function:


Member Data Documentation

readonly attribute unsigned long nsIDOMMediaList::length [inherited]

Definition at line 58 of file nsIDOMMediaList.idl.

Definition at line 77 of file nsIMediaList.h.

attribute DOMString nsIDOMMediaList::mediaText [inherited]

Definition at line 55 of file nsIDOMMediaList.idl.

Definition at line 81 of file nsIMediaList.h.


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