void
nsFormFillController::StopControllingInput()
{
  RemoveKeyListener();

  if(mFocusedInput) {
    nsCOMPtr<nsIDOMHTMLElement> list;
    mFocusedInput->GetList(getter_AddRefs(list));

    nsCOMPtr<nsINode> node = do_QueryInterface(list);
    if (node) {
      node->RemoveMutationObserver(this);
    }
  }

  // Reset the controller's input, but not if it has been switched
  // to another input already, which might happen if the user switches
  // focus by clicking another autocomplete textbox
  nsCOMPtr<nsIAutoCompleteInput> input;
  mController->GetInput(getter_AddRefs(input));
  if (input == this)
    mController->SetInput(nsnull);

  mFocusedInput = nsnull;
  mFocusedPopup = nsnull;
}
void
nsFormFillController::StopControllingInput()
{
  RemoveKeyListener();

  if (mListNode) {
    mListNode->RemoveMutationObserver(this);
    mListNode = nullptr;
  }

  // Reset the controller's input, but not if it has been switched
  // to another input already, which might happen if the user switches
  // focus by clicking another autocomplete textbox
  nsCOMPtr<nsIAutoCompleteInput> input;
  mController->GetInput(getter_AddRefs(input));
  if (input == this)
    mController->SetInput(nullptr);

  if (mFocusedInputNode) {
    MaybeRemoveMutationObserver(mFocusedInputNode);
    mFocusedInputNode = nullptr;
    mFocusedInput = nullptr;
  }
  mFocusedPopup = nullptr;
}