You are currently viewing a snapshot of taken on April 21, 2008. Most of this content is highly out of date (some pages haven't been updated since the project began in 1998) and exists for historical purposes only. If there are any pages on this archive site that you think should be added back to, please file a bug.

Author: Chris Karnaze
Updated: 12 Oct. 1998


Forms consist of the content and layout classes supporting <FORM>, <INPUT>, <LABEL>, <BUTTON>, <SELECT>, <OPTION>, <OPTGROUP>, <TEXTAREA>, <ISINDEX>, <FIELDSET>, <LEGEND> tags. The content classes have graphical representations such as buttons, checkboxes, pull down lists, radio buttons, etc. which are laid out and rendered by the corresponding layout classes. The content class except for <FORM> are referred to as form controls.

nsIFormManager specifies a manager on the layout side that coordinates activities among the various form control layout classes. The manager is primarily responsible for submitting the data that the user enters into the controls to a server for processing.
Major Components

The various tags (see above) are comprised of content classes (e.g. nsHTMLFormElement, nsHTMLInputElement, etc.) and layout classes including nsFormFrame, nsFormControlFrame, nsButtonControlFrame, nsHTMLButtonControlFrame, nsCheckBoxControlFrame, nsRadioControlFrame, nsTextControlFrame, nsSelectControlFrame, nsFileControlFrame, nsFieldSetFrame, nsLegendFrame.

The content classes are fairly light weight and provide basic getters and setters of their attributes. nsHTMLFormElement implements nsIForm which allows for the addition of form controls (the level 1 DOM implementation does not provide this). Each of the form controls implements nsIFormControl which provides a consistent way to treat form controls for gettting/setting their forms, getting their types, etc.

The layout classes provide general layout behavior for forms and form controls as well as additional operations. nsFormFrame implements nsIFormManager which specifies adding, removing, retrieving nsIFormControls plus methods for responding to events triggered by form control layout classes such as reset, submit, and user return. nsFormFame is also referred to as the form manager. nsFormControlFrame implements nsIFormControlFrame and serves as a base class class to nsButtonControlFrame, nsCheckBoxControlFrame, nsRadioControlFrame, nsSelectControlFrame, nsTextControlFrame. The form control layout classes implement nsIFormControlFrame but don't necssarily derive from nsFormControl.

Forms and form controls, and their associated layout classes interact with other modules in a number of ways. The html content sink creates forms and  form controls as the html tags are interpreted. HTMLStyleSheetImpl creates the appropriate frames for the forms and form controls as the layout engine prepares for layout. The form and form control layout classes render and handle events using the view system together with the widget library.


nsFormFrame has responsibility to (1) responds to a submit button press and submit the form control data to a server, (2) respond to a reset button press and reset all of the form controls to their initial values, and (3) manage radio button groups so that only one button in the group is active at any given time.

nsIFormControlFrame defines GetType, GetName, MouseClicked, Reset, IsSuccessful, GetMaxNumValues, GetNamesValues. GetNamesValues gathers the name value pairs (nsSelectControlFrames and nsButtonControlFrames representing an image submit button can have multiple pairs). MouseClicked provides a hook to do additional processing if necessary; for example, a submit button will notify the form manager to submit data. IsSuccessful indicates whether submission for a control should occur.

nsFormControlFrame adds additional methods including PostCreateWidget, CalculateSize, GetTextSize, GetWidgetInitData. GetWidgetInitData gathers data which the view system will use to initialize a widget. PostCreateWidget allows for processing after the widget is created; for example, initial values can be used to set the widget to the appropriate state. CalculateSize is a static method that determines the size of a control based on CSS settings, local size attributes, attribute values that may affect size, and default values. It is general enough to be used for nearly all of the widget based form controls. GetTextSize calculates the size of a string based on CSS.

Many form control frames have their own view which contains a widget from the cross-platform widget library. There are exceptions; a hidden element, represented as nsButtonControlFrame, does not have its own view; an nsFileControlFrame does not have its own view but contains an nsTextControlFrame and an nsButtonControl Frame each having its own view; an image submit button, represented as nsButtonControlFrame, does not have its own view; nsHTMLButtonControlFrame has its own view but the view does not have a widget; nsFieldSetControlFrame and nsLegendControlFrame do not have their own views.

Forms are dependent on many other modules including xpcom, netlib, layout, style, gfx, view, widget, dom/javascript.


In May, most of html 3.2 features were completed except for internationalization support. There was be a break in the schedule during the summer to allow dependencies to catch up and to work on frames. In October, the remaining areas including html 4 features will be completed. Other integration changes due to dependencies may likely continue beyond that time.
Known Bugs

There are existing bugs in bugzilla, but the most serious ones include limitations of the underlying widget set and may not be addressed in the first release.