Back to index

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

List of all members.

Public Member Functions

 nsFormControlEnumerator (nsHTMLFormElement *aForm)
virtual ~nsFormControlEnumerator ()
boolean hasMoreElements ()
 Called to determine whether or not the enumerator has any elements that can be returned via getNext().
nsISupports getNext ()
 Called to retrieve the next element in the enumerator.

Private Attributes

nsHTMLFormElementmForm
PRUint32 mElementsIndex
nsSupportsArray mNotInElementsSorted
PRUint32 mNotInElementsIndex

Detailed Description

Definition at line 360 of file nsHTMLFormElement.cpp.


Constructor & Destructor Documentation

Definition at line 2062 of file nsHTMLFormElement.cpp.

  : mForm(aForm), mElementsIndex(0), mNotInElementsIndex(0)
{

  // Create the sorted mNotInElementsSorted array
  PRInt32 len = aForm->mControls->mNotInElements.Count();
  for (PRInt32 indexToAdd=0; indexToAdd < len; indexToAdd++) {
    // Ref doesn't need to be strong, don't bother making it so
    nsIFormControl* controlToAdd = NS_STATIC_CAST(nsIFormControl*,
        aForm->mControls->mNotInElements.ElementAt(indexToAdd));

    // Go through the array and insert the element at the first place where
    // it is less than the element already in the array
    nsCOMPtr<nsIDOMNode> controlToAddNode = do_QueryInterface(controlToAdd);
    nsCOMPtr<nsIDOMNode> existingNode;
    PRBool inserted = PR_FALSE;
    // Loop over all elements backwards (from indexToAdd to 0)
    // indexToAdd is equal to the array length because we've been adding to it
    // constantly
    PRUint32 i = indexToAdd;
    while (i > 0) {
      i--;
      existingNode = do_QueryElementAt(&mNotInElementsSorted, i);
      PRInt32 comparison;
      if (NS_FAILED(nsHTMLFormElement::CompareNodes(controlToAddNode,
                                                    existingNode,
                                                    &comparison))) {
        break;
      }
      if (comparison > 0) {
        if (mNotInElementsSorted.InsertElementAt(controlToAdd, i+1)) {
          inserted = PR_TRUE;
        }
        break;
      }
    }

    // If it wasn't inserted yet, it is greater than everything in the array
    // and must be appended.
    if (!inserted) {
      if (!mNotInElementsSorted.InsertElementAt(controlToAdd,0)) {
        break;
      }
    }
  }
}

Here is the call graph for this function:

Definition at line 363 of file nsHTMLFormElement.cpp.

{ };

Member Function Documentation

nsISupports nsISimpleEnumerator::getNext ( ) [inherited]

Called to retrieve the next element in the enumerator.

The "next" element is the first element upon the first call. Must be pre-ceeded by a call to hasMoreElements() which returns PR_TRUE. This method is generally called within a loop to iterate over the elements in the enumerator.

See also:
hasMoreElements()
Returns:
NS_OK if the call succeeded in returning a non-null value through the out parameter. NS_ERROR_FAILURE if there are no more elements to enumerate.
the next element in the enumeration.

Here is the caller graph for this function:

Called to determine whether or not the enumerator has any elements that can be returned via getNext().

This method is generally used to determine whether or not to initiate or continue iteration over the enumerator, though it can be called without subsequent getNext() calls. Does not affect internal state of enumerator.

See also:
getNext()
Returns:
PR_TRUE if there are remaining elements in the enumerator. PR_FALSE if there are no more elements in the enumerator.

Here is the caller graph for this function:


Member Data Documentation

Definition at line 370 of file nsHTMLFormElement.cpp.

Definition at line 363 of file nsHTMLFormElement.cpp.

Definition at line 372 of file nsHTMLFormElement.cpp.

Definition at line 371 of file nsHTMLFormElement.cpp.


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