The Mozilla
Organization
At A Glance
Feedback
Get Involved
Newsgroups
License Terms
Newsbot
Developer Docs
Roadmap
Projects
Ports
Module Owners
Hacking
Get the Source
Build It
Testing
Download
Bugzilla
Bug Writing
Tools
View Source
Tree Status
New Checkins
Submit A Bug
FAQ
Search
Event Handling In Mozilla
Alexander Larsson <alex@cendio.se>

When the user presses a key on the keyboard this eventually gets to the Xserver. The Xserver then creates an X events and sends to the focused window.

This event is captured by gtk which creates an GDK event and passes it to any signal handlers registered on the focused GtkWidget.

This signal callback always ends up in handle_key_press_event in nsGtkEventHandler.cpp, which passes control to the correct nsWindow. Then an nsKeyEvent (derived from nsGUIEvent) is created and sent to the EventCallback registered on the widget when it's created.

Most (all) widgets get created with an event callback pointing to HandleEvent() in nsView.cpp. This function locates the correct nsViewManager for the view and calls viewmanager->DispatchEvent() with the event.

The viewmanager the handles certain types of events (NS_SIZE, NS_PAINT and NS_DESTROY), and the rest is passed to view->HandleEvent().

nsView::HandleEvent() recurses down into the view hierarchy to the innermost view that contains the (x, y) point where the event happened. Then each view calls obs->HandleEvent() on the nsIViewObserver that is registered with that view.

The only object that implements nsIViewObserver is nsPresShell. Which means all view events goes to nsPresShell::HandleEvent(), which does the following (in order):

  1. Give event to event manager for pre event state changes and generation of synthetic events: manager->PreHandleEvent()
  2. Give event to the DOM for third party and JS use: focusContent->HandleDOMEvent() or targetContent->HandleDOMEvent()
  3. Give event to the Frames for browser default processing: mCurrentEventFrame->HandleEvent()
  4. Give event to event manager for post event state changes and generation of synthetic events: manager->PostHandleEvent()
Copyright © 1998-2000 The Mozilla Organization.
Last modified October 7, 1999.