You are here: Editor project page > Editor in Text Widgets
The editor is also used as in XUL and HTML text widgets in Mozilla. This allows us to have a single codebase for text editing, which handles international text input (IME), and allows for stylability with CSS. However, the requirements for the editor in text widgets is somehwat different to its use in composer, so the editor needs to be flexible enough for use in both situations. The main differences are:
|Editor acts on:||Whole document||Document subtree|
|Capabilities:||Rich HTML editing||Plain text only|
|Hosting code:||editor shell||Layout frame & content code|
In text widgets, the editor is created and hosted by the frame (i.e. layout frame object) for text widgets, which is nsGfxTextControlFrame2. This frame creates and registers an event handler for the editor which feeds it keypress and focus events, and gets and sets the value of the text widget by calling the editor API.
The first implementation of the editor-as-text-widget used a heavy weight approach where each text widget has its own subdocument and associcated data structures, and the editor acted on that subdocument (this was the original nsGfxTextControlFrame). More recently, we adopted an approach (commonly referred to as ender lite) in which the contents of the text widget are actually in the parent document, but are anonymous content. Anonymous content is document content that cannot be reached using the standard DOM APIs, but which is accessible for special uses. With ender-lite, the editor is acting on a subtree of the parent document (either an HTML document, for a form control widget, or a XUL document for a XUL text input field). In this case the editor "knows" the root of the content subtree that it is allowed to mess with.
Construction of a frame for text widgets happens when layout
constructs frames after seeing an
in HTML, or a
<textfield> in XUL
(note that this happens on initial page loading, and after anything
else that causes frames to be rebuilt, such as stylesheet changes).
makes the text control frame, and soon after,
gets called (because
This calls is where we build the anonymous content that is to hold
the text field contents, and make the editor on it. We make a
<div> element which gets inserted into the content
tree as an anonymous child of the
Last modified: July 21 2000
Maintained by the editor team: firstname.lastname@example.org