A user account is required in order to edit this wiki, but we've had to disable public user registrations due to spam.

To request an account, ask an autoconfirmed user on Chat (such as one of these permanent autoconfirmed members).

RequestAutocomplete

From WHATWG Wiki
Revision as of 23:40, 12 March 2013 by Esprehn (talk | contribs) (Created page with "requestAutocomplete proposed spec (as implemented in Chromium) This document contains a preliminary specification of the requestAutocomplete feature that allows developers to...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

requestAutocomplete proposed spec (as implemented in Chromium)

This document contains a preliminary specification of the requestAutocomplete feature that allows developers to request that the browser fill a form with information based on the autocomplete attributes on the form controls.

Interfaces Additions

 interface HTMLFormElement : HTMLElement {
   ...
   void requestAutocomplete();
 }
 [Constructor(DOMString type, optional AutocompleteErrorEventInit eventInitDict)]
 interface AutocompleteErrorEvent : Event {
   readonly attribute DOMString reason;
 }
 dictionary AutocompleteErrorEventInit : EventInit {
   DOMString reason = “”;
 };

Algorithms

When the requestAutocomplete() method is invoked, the user agent must run the following steps:

  1. If we are not allowed to show a popup then asynchronously fail with the reason “disabled” and abort these steps.
  2. If the requestAutocompleteIsActive flag is true or the form element’s autocomplete attribute evaluates to “off” then asynchronously fail with the reason “disabled” and abort these steps.
  3. Optionally asynchronously fail with the reason “disabled” and abort these steps.
    (For example the user agent may give the user an option to ignore all autocomplete requests.)
  4. Set the requestAutocompleteIsActive flag to true.
  5. Let the pending autofill set be an empty set of autocomplete tuples of the form
    ( autocomplete attribute: string, input: Element )
  6. For each element that has this form element as its form owner add it to the pending autocomplete set with its attribute values if:
    • The autocomplete attribute is specified for its element type.
    • The autocomplete attribute parses to a valid value.
  7. Asynchronously request autocomplete from the user agent for the pending auto fill set for this form element.

When the user agent is said to request autocomplete for a form element it should run the following steps:

  1. Let the autofill set be the set of autocomplete tuples that were passed into this algorithm.
  2. Optionally asynchronously fail with the reason “cancel” and abort these steps. (For example if the user cancels the request.)
  3. For each tuple in the autofill set:
    a. Skip this tuple if the input’s attribute value for autocomplete is different than the one stored in the tuple.
    b. Skip this tuple if the form owner of the input is not this form element.
    c. Autofill the input following the autocomplete rules but allowing the input to suffer from a pattern mismatch.
  4. Statically validate the constraints and:
    a. If the result is negative asynchronously fail with the reason “invalid”.
    b. If the result is positive fire a simple event named “autocomplete” on the form element.
  5. Set the requestAutocompleteIsActive flag to false.

When the user agent is said to asynchronously fail with a reason it queue an event to fire on the form element currently being operated on of a new AutocompleteErrorEvent with the type “autocompleteerror” and the reason specified.