Back to index

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

The collection of options in the select (what you get back when you do select.options in DOM) More...

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

List of all members.

Public Member Functions

 nsHTMLOptionCollection (nsHTMLSelectElement *aSelect)
virtual ~nsHTMLOptionCollection ()
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_NSIDOMHTMLOPTIONSCOLLECTION
NS_DECL_NSIDOMNSHTMLOPTIONCOLLECTION
PRBool 
InsertOptionAt (nsIDOMHTMLOptionElement *aOption, PRInt32 aIndex)
 Insert an option.
void RemoveOptionAt (PRInt32 aIndex)
 Remove an option.
nsIDOMHTMLOptionElementItemAsOption (PRInt32 aIndex)
 Get the option at the index.
void Clear ()
 Clears out all options.
PRBool AppendOption (nsIDOMHTMLOptionElement *aOption)
 Append an option to end of array.
void DropReference ()
 Drop the reference to the select.
nsresult GetOptionIndex (nsIDOMHTMLOptionElement *aOption, PRInt32 aStartIndex, PRBool aForward, PRInt32 *aIndex)
 See nsISelectElement.idl for documentation on this method.
nsIDOMNode item (in unsigned long index)
nsIDOMNode namedItem (in DOMString name)
void setOption (in long index, in nsIDOMHTMLOptionElement option)
NS_DECL_ISUPPORTS NS_IMETHOD GetLength (PRUint32 *aLength)=0
NS_IMETHOD Item (PRUint32 aIndex, nsIDOMNode **aReturn)=0
NS_IMETHOD NamedItem (const nsAString &aName, nsIDOMNode **aReturn)=0
nsIDOMNode item (in unsigned long index)
nsIDOMNode namedItem (in DOMString name)

Public Attributes

attribute unsigned long length
attribute long selectedIndex
readonly attribute
nsIDOMHTMLSelectElement 
select
readonly attribute unsigned long length

Private Attributes

nsCOMArray
< nsIDOMHTMLOptionElement
mElements
 The list of options (holds strong references)
nsHTMLSelectElementmSelect
 The select element that contains this array.

Detailed Description

The collection of options in the select (what you get back when you do select.options in DOM)

Definition at line 92 of file nsHTMLSelectElement.cpp.


Constructor & Destructor Documentation

Definition at line 2100 of file nsHTMLSelectElement.cpp.

{
  // Do not maintain a reference counted reference. When
  // the select goes away, it will let us know.
  mSelect = aSelect;
}

Definition at line 2107 of file nsHTMLSelectElement.cpp.

Here is the call graph for this function:


Member Function Documentation

Append an option to end of array.

Definition at line 152 of file nsHTMLSelectElement.cpp.

  {
    return mElements.AppendObject(aOption);
  }

Here is the call graph for this function:

Here is the caller graph for this function:

Clears out all options.

Definition at line 144 of file nsHTMLSelectElement.cpp.

  {
    mElements.Clear();
  }

Here is the call graph for this function:

Drop the reference to the select.

Called during select destruction.

Definition at line 2113 of file nsHTMLSelectElement.cpp.

{
  // Drop our (non ref-counted) reference
  mSelect = nsnull;
}

Here is the caller graph for this function:

Implemented in TableRowsCollection.

nsresult nsHTMLOptionCollection::GetOptionIndex ( nsIDOMHTMLOptionElement aOption,
PRInt32  aStartIndex,
PRBool  aForward,
PRInt32 aIndex 
)

See nsISelectElement.idl for documentation on this method.

Definition at line 2120 of file nsHTMLSelectElement.cpp.

{
  PRInt32 index;

  // Make the common case fast
  if (aStartIndex == 0 && aForward) {
    index = mElements.IndexOf(aOption);
    if (index == -1) {
      return NS_ERROR_FAILURE;
    }
    
    *aIndex = index;
    return NS_OK;
  }

  PRInt32 high = mElements.Count();
  PRInt32 step = aForward ? 1 : -1;

  for (index = aStartIndex; index < high && index > -1; index += step) {
    if (mElements[index] == aOption) {
      *aIndex = index;
      return NS_OK;
    }
  }

  return NS_ERROR_FAILURE;
}

Here is the call graph for this function:

NS_DECL_ISUPPORTS_INHERITED NS_DECL_NSIDOMHTMLOPTIONSCOLLECTION NS_DECL_NSIDOMNSHTMLOPTIONCOLLECTION PRBool nsHTMLOptionCollection::InsertOptionAt ( nsIDOMHTMLOptionElement aOption,
PRInt32  aIndex 
) [inline]

Insert an option.

Parameters:
aOptionthe option to insert
aIndexthe index to insert at

Definition at line 117 of file nsHTMLSelectElement.cpp.

  {
    return mElements.InsertObjectAt(aOption, aIndex);
  }

Here is the call graph for this function:

nsIDOMNode nsIDOMHTMLCollection::item ( in unsigned long  index) [inherited]
nsIDOMNode nsIDOMHTMLOptionsCollection::item ( in unsigned long  index) [inherited]
NS_IMETHOD nsGenericDOMHTMLCollection::Item ( PRUint32  aIndex,
nsIDOMNode **  aReturn 
) [pure virtual, inherited]

Implemented in TableRowsCollection.

Get the option at the index.

Parameters:
aIndexthe index
aReturnthe option returned [OUT]

Definition at line 136 of file nsHTMLSelectElement.cpp.

  {
    return mElements.SafeObjectAt(aIndex);
  }

Here is the call graph for this function:

nsIDOMNode nsIDOMHTMLCollection::namedItem ( in DOMString  name) [inherited]
nsIDOMNode nsIDOMHTMLOptionsCollection::namedItem ( in DOMString  name) [inherited]
NS_IMETHOD nsGenericDOMHTMLCollection::NamedItem ( const nsAString &  aName,
nsIDOMNode **  aReturn 
) [pure virtual, inherited]

Implemented in TableRowsCollection.

Remove an option.

Parameters:
aIndexthe index of the option to remove

Definition at line 126 of file nsHTMLSelectElement.cpp.

  {
    mElements.RemoveObjectAt(aIndex);
  }

Here is the call graph for this function:


Member Data Documentation

Definition at line 55 of file nsIDOMHTMLOptionsCollection.idl.

readonly attribute unsigned long nsIDOMHTMLCollection::length [inherited]

Definition at line 55 of file nsIDOMHTMLCollection.idl.

The list of options (holds strong references)

Definition at line 171 of file nsHTMLSelectElement.cpp.

The select element that contains this array.

Definition at line 173 of file nsHTMLSelectElement.cpp.

Definition at line 53 of file nsIDOMNSHTMLOptionCollectn.idl.

Definition at line 48 of file nsIDOMNSHTMLOptionCollectn.idl.


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