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: Difference between revisions
(Created page with "requestAutocomplete proposed spec (as implemented in Chromium) This document contains a preliminary specification of the requestAutocomplete feature that allows developers to...") |
No edit summary |
||
(10 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
Something based on this is now in the HTML standard: http://www.whatwg.org/specs/web-apps/current-work/#dom-form-requestautocomplete | |||
The remainder of this page is for the historical record: | |||
requestAutocomplete proposed spec (as implemented in Chromium) | 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. | 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. | ||
== Issues == | |||
This should really use a promise: http://dom.spec.whatwg.org/#promises (http://crbug.com/343630). | |||
== Interfaces Additions== | == Interfaces Additions== | ||
Line 8: | Line 16: | ||
... | ... | ||
void requestAutocomplete(); | void requestAutocomplete(); | ||
} | }; | ||
enum AutoCompleteErrorReason { | |||
"", | |||
"cancel", | |||
"disabled", | |||
"invalid" | |||
}; | |||
[Constructor(DOMString type, optional AutocompleteErrorEventInit eventInitDict)] | [Constructor(DOMString type, optional AutocompleteErrorEventInit eventInitDict)] | ||
interface '''AutocompleteErrorEvent''' : Event { | interface '''AutocompleteErrorEvent''' : Event { | ||
readonly attribute | readonly attribute AutoCompleteErrorReason reason; | ||
} | }; | ||
dictionary '''AutocompleteErrorEventInit''' : EventInit { | dictionary '''AutocompleteErrorEventInit''' : EventInit { | ||
AutoCompleteErrorReason reason = ""; | |||
}; | }; | ||
Line 23: | Line 38: | ||
When the '''requestAutocomplete'''() method is invoked, the user agent must run the following steps: | When the '''requestAutocomplete'''() method is invoked, the user agent must run the following steps: | ||
# If we are not allowed to show a popup then asynchronously fail with the reason | # If we are not allowed to show a popup then asynchronously fail with the reason "disabled" and abort these steps. | ||
# If the ''requestAutocompleteIsActive'' flag is true or the form | # 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. | ||
# Optionally asynchronously fail with the reason | # 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.) | #: (For example the user agent may give the user an option to ignore all autocomplete requests.) | ||
# Set the ''requestAutocompleteIsActive'' flag to true. | # Set the ''requestAutocompleteIsActive'' flag to true. | ||
Line 38: | Line 53: | ||
# Let the autofill set be the set of autocomplete tuples that were passed into this algorithm. | # Let the autofill set be the set of autocomplete tuples that were passed into this algorithm. | ||
# Optionally asynchronously fail with the reason | # Optionally asynchronously fail with the reason "cancel" and abort these steps. (For example if the user cancels the request.) | ||
# For each tuple in the autofill set: | # For each tuple in the autofill set: | ||
#: a. Skip this tuple if the | #: 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. | #: 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. | #: c. Autofill the input following the autocomplete rules but allowing the input to suffer from a pattern mismatch. | ||
# Statically validate the constraints and: | # Statically validate the constraints and: | ||
#: a. If the result is negative asynchronously fail with the reason | #: a. If the result is negative asynchronously fail with the reason "invalid". | ||
#: b. If the result is positive fire a simple event named | #: b. If the result is positive fire a simple event named "autocomplete" that bubbles on the form element. | ||
# Set the requestAutocompleteIsActive flag to false. | # Set the requestAutocompleteIsActive flag to false. | ||
When the user agent is said to asynchronously fail with a reason it | When the user agent is said to asynchronously fail with a reason, it queues an event to fire on the form element currently being operated on of a new AutocompleteErrorEvent with the type "autocompleteerror" and the reason specified. | ||
[[Category:Proposals]] | [[Category:Proposals]] |
Latest revision as of 21:56, 9 April 2014
Something based on this is now in the HTML standard: http://www.whatwg.org/specs/web-apps/current-work/#dom-form-requestautocomplete
The remainder of this page is for the historical record:
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.
Issues
This should really use a promise: http://dom.spec.whatwg.org/#promises (http://crbug.com/343630).
Interfaces Additions
interface HTMLFormElement : HTMLElement { ... void requestAutocomplete(); };
enum AutoCompleteErrorReason { "", "cancel", "disabled", "invalid" };
[Constructor(DOMString type, optional AutocompleteErrorEventInit eventInitDict)] interface AutocompleteErrorEvent : Event { readonly attribute AutoCompleteErrorReason reason; };
dictionary AutocompleteErrorEventInit : EventInit { AutoCompleteErrorReason reason = ""; };
Algorithms
When the requestAutocomplete() method is invoked, the user agent must run the following steps:
- If we are not allowed to show a popup then asynchronously fail with the reason "disabled" and abort these steps.
- 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.
- 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.)
- Set the requestAutocompleteIsActive flag to true.
- Let the pending autofill set be an empty set of autocomplete tuples of the form
- ( autocomplete attribute: string, input: Element )
- 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.
- 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:
- Let the autofill set be the set of autocomplete tuples that were passed into this algorithm.
- Optionally asynchronously fail with the reason "cancel" and abort these steps. (For example if the user cancels the request.)
- 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.
- 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" that bubbles on the form element.
- Set the requestAutocompleteIsActive flag to false.
When the user agent is said to asynchronously fail with a reason, it queues an event to fire on the form element currently being operated on of a new AutocompleteErrorEvent with the type "autocompleteerror" and the reason specified.