4
edits
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
This page is intended as a general design page (and to a smaller extent, a roadmap) for implementing the [http://www.whatwg.org/specs/web-forms/current-work/ Web Forms 2.0] specification (WF2). The primary tracking bug for this is {{bug|344614}}. | This page is intended as a general design page (and to a smaller extent, a roadmap) for implementing the [http://www.whatwg.org/specs/web-forms/current-work/ Web Forms 2.0] specification (WF2). The primary tracking bug for this is {{bug|344614}}. | ||
Note this page is very, very incomplete at this time. Web Forms 2.0 is a big specification, and implementation will take time. | Note this page is very, very incomplete at this time. Web Forms 2.0 is a big specification, and implementation will take time. | ||
== Current Status == | == Current Status == | ||
Line 9: | Line 9: | ||
* [[DOM:Web_Forms_2.0#Phased_Implementation|Phased Implementation]] | * [[DOM:Web_Forms_2.0#Phased_Implementation|Phased Implementation]] | ||
* Implement new attributes and methods using [[DOM:Web_Forms_2.0#JavaScript_tearoffs|JavaScript tearoffs]] | * Implement new attributes and methods using [[DOM:Web_Forms_2.0#JavaScript_tearoffs|JavaScript tearoffs]] | ||
* Implement visual component of new input controls using XBL/XUL | * Implement visual component of new input controls using XBL/XUL | ||
We are currently waiting to verify that JavaScript tearoffs can coexist with C++ objects. If this can be verified then work will start on implementing new attributes and methods as JavaScript/XPCOM objects. | <strike>We are currently waiting to verify that JavaScript tearoffs can coexist with C++ objects. If this can be verified then work will start on implementing new attributes and methods as JavaScript/XPCOM objects.</strike> | ||
{{bug|383776}} is blocking the development of the visual components of Web Forms 2.0. | <strike>{{bug|383776}} is blocking the development of the visual components of Web Forms 2.0.</strike> | ||
== Key Personnel == | == Key Personnel == | ||
Line 49: | Line 49: | ||
* Phase 1 | * Phase 1 | ||
** implement new <input> types (except those defined by the repetition model) | ** implement new <input> types (except those defined by the repetition model) | ||
** implement the new attributes and methods for <form>, <input> and <fieldset> elements | ** implement the new attributes and methods for <form>, <input>, <label> and <fieldset> elements | ||
** redefine the elements attribute of a <form> element | ** redefine the elements attribute of a <form> element | ||
** implement the <datalist> and <output> elements | ** implement the <datalist> and <output> elements | ||
* Phase 2 | * Phase 2 | ||
* implement the repetition model | ** implement the repetition model | ||
* Phase 3 | * Phase 3 | ||
** implement the remainder of the Web Forms 2.0 specification | ** implement the remainder of the Web Forms 2.0 specification | ||
Line 59: | Line 59: | ||
The remainder of this document will deal only with phase 1 of this implementation. | The remainder of this document will deal only with phase 1 of this implementation. | ||
== | === Phase 1 === | ||
* <b>Form Validation</b> | |||
** "invalid" event | |||
** ValidityState object | |||
** visual feedback for invalidity | |||
** :invalid CSS pseudo class | |||
** affects form submission | |||
* <b>Visual Components</b> | |||
** Visual feedback for invalidity | |||
** XBL extensions for numeric and date/time controls | |||
** disabled state when parent <fieldset> is disabled | |||
** XBL extension for <input> elements with an associated <datalist> | |||
* <b>NodeLists</b> | |||
** The forms/elements/labels/selectedOptions DOM properties return NodeLists. NodeLists are live. How do we fake these using JavaScript? Do we want to fake them with JavaScript? These properties will probably be slow if implemented in JavaScript. | |||
* <b>Form Submission</b> | |||
** The "elements" DOM property (elements can be bound to more than one form) | |||
** validation - should not submit invalid forms. How do we hijack submission and yet allow user scripts to trap the "submit" event also? | |||
** There are various new formats for form submission (phase 3) | |||
== Technologies == | |||
=== JavaScript tearoffs === | === JavaScript tearoffs === | ||
Line 68: | Line 85: | ||
New elements, such as <datalist> have stub implementations in C++ which simply instantiates javascript tearoffs to implement the WF2 functionality. | New elements, such as <datalist> have stub implementations in C++ which simply instantiates javascript tearoffs to implement the WF2 functionality. | ||
This is the first time we've implemented tearoffs using JavaScript, which means that it's not known if it'll work or not. In theory XPCOM supports aggregation which means that it should work, but there may be unknown bugs. In particular we need to make sure that QueryInterface on the tearoff can do the right thing and return the "outer" object for the interfaces the tearoff does not directly implement. | This is the first time we've implemented tearoffs using JavaScript, which means that it's not known if it'll work or not. In theory XPCOM supports aggregation which means that it should work, but there may be unknown bugs. In particular we need to make sure that QueryInterface on the tearoff can do the right thing and return the "outer" object for the interfaces the tearoff does not directly implement. | ||
Line 122: | Line 91: | ||
Make sure that the tearoff holding on to the original element and the original element holding on to the tearoff doesn't cause memory leaks. The cycle collector should take care of this, but it needs to be tested. | Make sure that the tearoff holding on to the original element and the original element holding on to the tearoff doesn't cause memory leaks. The cycle collector should take care of this, but it needs to be tested. | ||
<b>Initial testing suggests that this is a viable solution.</b> | |||
=== IDL === | === IDL === | ||
Line 133: | Line 104: | ||
Note that web pages must not need to QueryInterface to these interfaces in order to use their capabilities. The properties and methods these interfaces provide and define must be available by default. | Note that web pages must not need to QueryInterface to these interfaces in order to use their capabilities. The properties and methods these interfaces provide and define must be available by default. | ||
The interface hierarchy might end up looking like this: | |||
* nsIWF2FormElementTearoff | |||
* nsIWF2FormItem // anything bound to a form | |||
** nsIWF2FieldsetElementTearoff | |||
** nsIWF2FormControl // implements validity | |||
*** nsIWF2InputElementTearoff | |||
*** nsIWF2OutputElementTearoff | |||
** nsIWF2LabelElementTearoff | |||
* nsIWF2ValidityState | |||
These are the current unsolved (by Dean) problems: | |||
* Returning a ValidityState object from a tearoff throws this error | |||
<tt>Error: uncaught exception: Permission denied to create wrapper for object of class UnnamedClass</tt> | |||
* the "valueAsDate" attribute should return a JavaScript Date object. How should the IDL define this type? I'm currently using DOMTimestamp but it returns a number. | |||
=== XBL === | === XBL/XUL === | ||
{{bug|344614}} has been fixed. However there are still some rendering issues. | |||
[picture] | |||
There is also a potential problem with XUL using <html:input> elements under the hood to implement <xul:textbox>. This can lead to infinite recursion. | |||
We will use the following XUL elements. | |||
==== <xul:datepicker> ==== | |||
This handles most of the functionality we need. It would be nice if it could handle ISO formats as that is what WF2 uses but it is not difficult to map between the XUL format and the ISO format. | |||
There are a number of other niggles which I'm sure are easy to fix: | |||
* The <datepicker> does not look like regular O/S chrome | |||
* Its spin buttons do not like the other XUL spin buttons | |||
* There is no way to scroll by year | |||
* There is no highlighting of days as you move the mouse over the control | |||
* It is not accessible by keyboard | |||
* There is an annoying popup of previously submitted values | |||
* There is an occasional bug whereby it is sometimes impossible to click out of the datepicker. | |||
* It would be nice if we could define a range of selection (day, week, month). We could then use it for <input type="week|month">. | |||
* When using the spin controls, the field (day, month or year) that is being changed should be highlighted so that the user knows which field the spin control is affecting. | |||
==== <xul:timepicker> ==== | |||
The spin controls suffer the same drawback as outlined in the last bullet point above. Otherwise, this control works very well. | |||
==== <xul:textbox> ==== | |||
Particularly for <input type="number">. | |||
==== <xul:spinbuttons> ==== | |||
These seem to work fine. We may need to implement <input type="month" with this or use a modified <xul:datepicker>. | |||
=== | ==== <xul:scale> ==== | ||
This works seamlessly. | |||
== | |||
== New objects == | == New objects == | ||
=== DOMWF2ValidityState === | === DOMWF2ValidityState === | ||
This object will be implemented as a JavaScript XPCOM object. There is some initial difficulty returning this property as part of a tearoff. | |||
== New events == | == New events == | ||
Line 179: | Line 161: | ||
* Contributor: Shawn Wilsher | * Contributor: Shawn Wilsher | ||
* Implementation: {{bug|347007}} | * Implementation: {{bug|347007}} | ||
== New elements == | == New elements == | ||
=== <anyNS:anyELM repeat="template | #"> === | === <anyNS:anyELM repeat="template | #"> === | ||
This will be implemented in phase 2. | |||
* Accessibility | * Accessibility | ||
=== <html:datalist> === | === <html:datalist> === | ||
This will be implemented in a similar way to <input> elements. A JavaScript tearoff will manage its DOM properties and methods. The element has no special attributes or methods. | |||
* Accessibility | * Accessibility | ||
This element is not visible to the user. | |||
== | === <html:output> === | ||
This will be implemented in a similar way to <input> elements. A JavaScript tearoff will manage its DOM properties and methods. The element has no special attributes or methods but *must* appear in its form's elements collection. This will mean messing with the elements attribute for a <form>. | |||
* Accessibility | |||
This renders pretty much like a <span> element. | |||
== Changes to HTMLInputElement == | |||
=== Changes To Existing Properties === | |||
{| border="1" cellpadding="5" cellspacing="0" align="left" width="100%" | |||
|- | |||
! style="background:#DDD;color:#000" | Property | |||
! style="background:#DDD;color:#000" | Comments | |||
|- | |||
| form || <input> elements can now be bound to more than one form. The form property should refer to the first bound form. If we implement the "forms" property then we must override this property | |||
|- | |||
| type || we *must* override this property. The standard DOM property returns "text" for unknown types. All of the WF2 types are unknown to the underlying cpp implementation | |||
|} | |||
=== New Properties === | |||
{| border="1" cellpadding="5" cellspacing="0" align="left" width="100%" | |||
|- | |||
! style="background:#DDD;color:#000" | Property | |||
! style="background:#DDD;color:#000" | Comments | |||
|- | |||
| forms || implementable as an array or "fake" NodeList | |||
|- | |||
| min || implementable | |||
|- | |||
| max || implementable | |||
|- | |||
| step || implementable | |||
|- | |||
| pattern || implementable | |||
|- | |||
| autocomplete || is this already implemented? | |||
|- | |||
| autofocus || implementable | |||
|- | |||
| inputmode || ? | |||
|- | |||
| action || ? | |||
|- | |||
| enctype || ? | |||
|- | |||
| method || ? | |||
|- | |||
| target || ? | |||
|- | |||
| replace || ? | |||
|- | |||
| list || implementable | |||
|- | |||
| selectedOptions || implementable as an array or "fake" NodeList | |||
|- | |||
| htmlTemplate || implemented in phase 2 | |||
|- | |||
| labels || implementable as an array or "fake" NodeList. We only need to implement this if we also implement the changes to the <label> element | |||
|- | |||
| valueAsDate || Not sure what to define this as in IDL. How do I return a JavaScript Date object? | |||
|- | |||
| valueAsNumber || implementable | |||
|- | |||
| willValidate || implementable | |||
|- | |||
| validity || implementable but I am having difficulty getting XPCOM to return the right interface | |||
|- | |||
| validationMessage || implementable, requires localization of default messages | |||
|} | |||
A "?" in the comments means that I have not investigated this attribute yet. They are potentially all "phase 3" developments. | |||
{| border="1" cellpadding="5" cellspacing="0" align="left" width="100%" | |||
|- | |||
! style="background:#DDD;color:#000" | Method | |||
! style="background:#DDD;color:#000" | Comments | |||
|- | |||
| checkValidity || implementable | |||
|- | |||
| dispatchChange || implementable | |||
|- | |||
| dispatchFormChange || implementable | |||
|} | |||
=== Comments === | |||
Attributes that return NodeLists will have to return JavaScript NodeLists or these attributes will have to be defined in cpp. | |||
=== <html:input type="number"> === | === <html:input type="number"> === | ||
Maps to XUL element: <xul: | Maps to XUL element: <xul:textbox type="number">. | ||
This requires either a slight fix to numberbox.xml or a larger fix to textbox.xml.xml to prevent infinite recursion for <input type="number">. This is because XUL textboxes inherit the "type" attribute. | |||
* Accessibility | * Accessibility | ||
=== <html:input type="email|url"> === | === <html:input type="email|url"> === | ||
For this, we may just want to use NS_NewURI() to validate the value of the input. | For this, we may just want to use NS_NewURI() to validate the value of the input. This has a disadvantage of not allowing for URI's which we don't support but WF2 allows. The alternative, which I don't quite know how to do, is to validate the value by RFC 3987, as WF2 states. | ||
This has a disadvantage of not allowing for URI's which we don't support but WF2 allows. The alternative, which I don't quite know how to do, is to validate the value by RFC 3987, as WF2 states. | |||
It may be best to allow both - default to NS_NewURI first, then validate by RFC 3987 if that fails. | It may be best to allow both - default to NS_NewURI first, then validate by RFC 3987 if that fails. | ||
We need a way to validate urls and email addresses. | |||
* Accessibility | * Accessibility | ||
Line 246: | Line 282: | ||
=== <html:input type="range"> === | === <html:input type="range"> === | ||
Maps to XUL element: <xul:scale>. | Maps to XUL element: <xul:scale>. | ||
=== <html:input type="date|time|datetime|datetime-local|week|month"> === | === <html:input type="date|time|datetime|datetime-local|week|month"> === | ||
For most of these controls we can map to the XUL elements <xul:datepicker> and/or <xul:timepicker>. <input type="week"> requires a change to <xul:datepicker> to allow range selection. <input type="month"> would probably be best implemented with a modified <xul:datepicker> but could be implemented using <xul:spinbuttons>. | |||
For most of these controls we can map to the XUL elements <xul:datepicker> and/or <xul:timepicker>. <input type="week"> requires a change to <xul:datepicker> to allow range selection. <input type="month"> | |||
* Accessibility | * Accessibility | ||
== Changes to HTMLFormElement == | |||
Implement as a JavaScript tearoff. The main change here is to intercept form submission to prevent the sending of invalid data. | |||
=== | === Changes To Existing Properties === | ||
{| border="1" cellpadding="5" cellspacing="0" align="left" width="100%" | |||
|- | |||
! style="background:#DDD;color:#000" | Property | |||
! style="background:#DDD;color:#000" | Comments | |||
|- | |||
| elements || <input> elements can now be bound to more than one form. The elements collection should include all of the elements bound to it. It should also include any <output> elements. If we implement the <output> element, or the "forms" property of the <input> element, then we must override this property | |||
|- | |||
| length || see above | |||
|} | |||
=== New Properties === | |||
{| border="1" cellpadding="5" cellspacing="0" align="left" width="100%" | |||
|- | |||
! style="background:#DDD;color:#000" | Property | |||
! style="background:#DDD;color:#000" | Comments | |||
|- | |||
| accept || ? | |||
|- | |||
| data || ? | |||
|- | |||
| replace || implementable (possibly phase 2 or 3)? | |||
|} | |||
A "?" in the comments means that I have not investigated this attribute yet. They are potentially all "phase 3" developments. | |||
=== New Methods === | |||
{| border="1" cellpadding="5" cellspacing="0" align="left" width="100%" | |||
|- | |||
! style="background:#DDD;color:#000" | Method | |||
! style="background:#DDD;color:#000" | Comments | |||
|- | |||
| checkValidity || implementable | |||
|- | |||
| dispatchFormChange || implementable | |||
|- | |||
| dispatchFormInput || implementable | |||
|- | |||
| resetFromData || implementable (possibly phase 2 or 3)? | |||
|} | |||
== Changes to HTMLFieldsetElement == | |||
Implement as a JavaScript tearoff. | |||
The Web Forms 2.0 specification adds a "disabled" property to <html:fieldset>. This will require an additional XBL binding for descendant <html:input> elements so that they can also be disabled. | |||
== Changes to HTMLLabelElement == | |||
Implement as a JavaScript tearoff. If we implement these changes then we need to implement the "labels" property for the <input> element. Labels also have form/forms properties. | |||
There is no visual component. | |||
== Security == | |||
Can someone who knows something about security write something here please? :-) | |||
== QA & Testing == | == QA & Testing == | ||
http://webforms2.testsuite.org | http://webforms2.testsuite.org |
edits