if (wallet_Capture(doc, field, value, vcardValue)) { captureCount++;
wallet_TraversalForRequestToCapture(nsIDOMWindow* win, PRInt32& captureCount) {  nsresult result;  if (nsnull != win) {    nsCOMPtr<nsIDOMDocument> domdoc;    result = win->GetDocument(getter_AddRefs(domdoc));    if (NS_SUCCEEDED(result)) {      nsCOMPtr<nsIDocument> doc = do_QueryInterface(domdoc);      if (doc) {        wallet_Initialize(PR_TRUE);        wallet_InitializeCurrentURL(doc);        nsCOMPtr<nsIDOMHTMLDocument> htmldoc = do_QueryInterface(doc);        if (htmldoc) {          nsCOMPtr<nsIDOMHTMLCollection> forms;          htmldoc->GetForms(getter_AddRefs(forms));          if (forms) {            PRUint32 numForms;            forms->GetLength(&numForms);            for (PRUint32 formX = 0; (formX < numForms) && !gEncryptionFailure; formX++) {              nsCOMPtr<nsIDOMNode> formNode;              forms->Item(formX, getter_AddRefs(formNode));              if (formNode) {                nsCOMPtr<nsIDOMHTMLFormElement> formElement = do_QueryInterface(formNode);                if (formElement) {                  nsCOMPtr<nsIDOMHTMLCollection> elements;                  result = formElement->GetElements(getter_AddRefs(elements));                  if (elements) {                    /* got to the form elements at long last */                    /* now find out how many text fields are on the form */                    PRUint32 numElements;                    elements->GetLength(&numElements);                    for (PRUint32 elementY = 0; (elementY < numElements) && !gEncryptionFailure; elementY++) {                      nsCOMPtr<nsIDOMNode> elementNode;                      elements->Item(elementY, getter_AddRefs(elementNode));                      if (elementNode) {                        nsCOMPtr<nsIDOMHTMLInputElement> inputElement = do_QueryInterface(elementNode);                          if (inputElement) {                          /* it's an input element */                          nsAutoString type;                          result = inputElement->GetType(type);                          if ((NS_SUCCEEDED(result)) &&                              (type.IsEmpty() || (type.CompareWithConversion("text", PR_TRUE) == 0))) {                            nsAutoString field;                            result = inputElement->GetName(field);                            if (NS_SUCCEEDED(result)) {                              nsAutoString value;                              result = inputElement->GetValue(value);                              if (NS_SUCCEEDED(result)) {                                /* get schema name from vcard attribute if it exists */                                nsAutoString vcardValue;                                nsCOMPtr<nsIDOMElement> element = do_QueryInterface(elementNode);                                if (element) {                                  nsAutoString vcardName; vcardName.AssignWithConversion("VCARD_NAME");                                  result = element->GetAttribute(vcardName, vcardValue);                                }                                if (wallet_Capture(doc, field, value, vcardValue)) {                                  captureCount++;                                }                              }                            }                          }                        }                      }                    }                  }                }              }            }          }        }      }    }  }  nsCOMPtr<nsIDOMWindowCollection> frames;  win->GetFrames(getter_AddRefs(frames));  if (frames) {    PRUint32 numFrames;    frames->GetLength(&numFrames);    for (PRUint32 frameX = 0; (frameX < numFrames) && !gEncryptionFailure; frameX++)    {      nsCOMPtr<nsIDOMWindow> frameNode;      frames->Item(frameX, getter_AddRefs(frameNode));      if (frameNode) {        wallet_TraversalForRequestToCapture(frameNode, captureCount);      }    }  }}