Ejemplo n.º 1
0
NS_IMETHODIMP
nsFormFillController::Focus(nsIDOMEvent* aEvent)
{
  // Drop untrusted events from content
  if (!IsEventTrusted(aEvent))
    return NS_OK;
  nsCOMPtr<nsIDOMEventTarget> target;
  aEvent->GetTarget(getter_AddRefs(target));

  nsCOMPtr<nsIDOMHTMLInputElement> input = do_QueryInterface(target);
  if (!input)
    return NS_OK;

  PRBool isReadOnly = PR_FALSE;
  input->GetReadOnly(&isReadOnly);

  nsAutoString autocomplete;
  input->GetAttribute(NS_LITERAL_STRING("autocomplete"), autocomplete);

  PRInt32 dummy;
  PRBool isPwmgrInput = PR_FALSE;
  if (mPwmgrInputs.Get(input, &dummy))
      isPwmgrInput = PR_TRUE;

  nsCOMPtr<nsIFormControl> formControl = do_QueryInterface(input);
  if (formControl && formControl->IsSingleLineTextControl(PR_TRUE) &&
      !isReadOnly || isPwmgrInput) {
    StartControllingInput(input);
  }

  return NS_OK;
}
nsresult
nsFormFillController::Focus(nsIDOMEvent* aEvent)
{
  nsCOMPtr<nsIDOMEventTarget> target;
  aEvent->GetTarget(getter_AddRefs(target));

  nsCOMPtr<nsIDOMHTMLInputElement> input = do_QueryInterface(target);
  if (!input)
    return NS_OK;

  bool isReadOnly = false;
  input->GetReadOnly(&isReadOnly);

  bool autocomplete = nsContentUtils::IsAutocompleteEnabled(input);

  nsCOMPtr<nsIDOMHTMLElement> datalist;
  input->GetList(getter_AddRefs(datalist));
  bool hasList = datalist != nsnull;

  PRInt32 dummy;
  bool isPwmgrInput = false;
  if (mPwmgrInputs.Get(input, &dummy))
      isPwmgrInput = true;

  nsCOMPtr<nsIFormControl> formControl = do_QueryInterface(input);
  if (isPwmgrInput || (formControl &&
                       formControl->IsSingleLineTextControl(PR_TRUE) &&
                       (hasList || autocomplete) && !isReadOnly)) {
    StartControllingInput(input);
  }

  return NS_OK;
}
Ejemplo n.º 3
0
nsresult
nsFormFillController::Focus(nsIDOMEvent* aEvent)
{
  nsCOMPtr<nsIDOMEventTarget> target;
  aEvent->GetTarget(getter_AddRefs(target));

  nsCOMPtr<nsIDOMHTMLInputElement> input = do_QueryInterface(target);
  if (!input)
    return NS_OK;

  bool isReadOnly = false;
  input->GetReadOnly(&isReadOnly);

  nsAutoString autocomplete;
  input->GetAttribute(NS_LITERAL_STRING("autocomplete"), autocomplete);

  PRInt32 dummy;
  bool isPwmgrInput = false;
  if (mPwmgrInputs.Get(input, &dummy))
      isPwmgrInput = true;

  nsCOMPtr<nsIFormControl> formControl = do_QueryInterface(input);
  if (formControl && formControl->IsSingleLineTextControl(true) &&
      !isReadOnly || isPwmgrInput) {
    StartControllingInput(input);
  }

  return NS_OK;
}