NS_INIT_ISUPPORTS();
nsFormControlEnumerator::nsFormControlEnumerator(nsHTMLFormElement* aForm)  : mForm(aForm), mElementsIndex(0), mNotInElementsIndex(0){  NS_INIT_ISUPPORTS();  // 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;      }    }  }}