The NGLayout Event Model
Authors: Tom Pixley
Last update: October 7, 1998
The NGLayout engine will implement
a union of the DOM Level 0 and DOM Level 2 Event Models. DOM Level
0 is itself a combination of the Communicator
4.0 Event Model and Microsoft's Internet Explorer 4.0 event model.
It will attempt to maintain backwards compatibilty, whenever possible,
and be fully compliant with the forthcoming DOM Event Model specification.
Additionally, sufficient enhancements will be provided to meet all requirements
of DOM clients such as the Composer product.
The major components of the NGLayout event model consist of the event listener interfaces by which customers of the event model receive events and the internal event dispatch system which handles event bubbling, capturing, and ordering of event delivery.
Event Listener Interfaces
The event listener interfaces are separated by event class into a number of interfaces, each containing a group of related event handlers. The current event listeners consist of the following interfaces:
- nsIDOMEventListener - The main event listener interface from which the others derive.
Objects which can dispatch events implement the nsIDOMEventReceiver interface. All content objects, the document object (nsDocument), and the window object (nsGlobalWindow) implement this nsIDOMEventReceiver. Through this interface, an event model customer wishing to receive events of a given class dispatched by that element can register the appropriate event listener interface through the nsIDOMEventReceiver::AddEventListener interface. The registered interface will then receive all events of the appropriate type dispatched by that object. Currently, ordering of event delivery among multiple event listeners on the same object is determined by the order in which the customers register themselves.
Event Dispatch System
Internally, the nsIDOMEvent interface
is implemented by the nsDOMEvent object. When an nsDOMEvent is created
it takes a pointer to an nsGUIEvent struct. The nsGUIEvent struct
is the main event struct used internally inside NGLayout. The nsDOMEvent
holds onto this pointer and accesses its contents when queried for information.
The nsGUIEvent struct is temporary object and must be copied to make it
persistent when the lifetime of the nsDOMEvent exceeds the initial event
Remaining design issues
Additionally, the full level of backwards
compatibility has not been decided. The combination of the bubbling
and capturing has created some small changes in the behavior of the event
model as compared to Netscape Communicator 4.0. Design decisions
made for NGLayout have also had an effect on the event system. Whether
these changes are significant has not yet been fully determined.
If the variations are found to have a large effect on backwards compatibility
with existing content, changes will be considered.
- Event capture has not yet been implemented.
- Some events currently bubble which are specified as non-bubbling.
- Some data fields in the Event object are currently inaccurate.
- Currently unimplemented events: