Mozilla research-Xul Window Creation and Event Processing

Source: Internet
Author: User

Mozilla research-Xul Window Creation and Event Processing

 

Reprinted please indicate the source and the author contact: http://blog.csdn.net/absurd

Contact information of the author: Li xianjing <xianjimli at Hotmail dot com>

Last Updated: 2007-3-25

 

Mozilla is a browser-centered software platform, which plays an important role in our platform. We use it to implement applications such as Web browsers, WAP browsers, mail systems, e-books, and help readers. For this reason, I recently spent a lot of time reading Mozilla code and documentation. I will write a series of blogs as my notes for reference by friends who need them. This topic describes Window Creation and event processing.

 

Window Creation

1. For the prompt window, which is opened by functions such as alert/confirm in JavaScript. The process is as follows: nspromptservice: dodialog à ns1_wwatcher: OpenWindow à nsxulwindow: showmodal. If you want to customize the behavior of the prompt window, such as the prompt in the command line, you can re-implement the nsipromptservice2/nspipromptservice interface.

2. For normal windows, the creation process is as follows: ns1_wwatcher: OpenWindow à windowcreator: createchromewindow2 à nswindowconstructor.

 

Close Window

1. Call the close function in JavaScript to close the window.

2. Call nsglobalwindow: Close through xpconnect.

3. nsglobalwindow: Close call nsglobalwindow: reallyclosewindow to close the window.

 

Event registration

1. After the XUL document is parsed, nsxuldocument: preparetowalk creates all nsxulelements.

2. nsxulelement: create calls nsxulelement: addscripteventlistener to register the event handler.

3. nsxulelement: addscripteventlistener calls nseventlistenermanager: addscripteventlistener to register the event handler.

4. nseventlistenermanager: addscripteventlistener through nsjscontext, finally calls ns_newjseventlistener to package the Javascript event processing function into nsidomeventlistener and register it with nseventlistenermanager.

 

Event Distribution

1. functions such as xxx_event_cb in nswindow. cpp forward GTK + events to the nswindow: onxxxevent function.

2. nscommonwidget: dispatchevent forwards the event to the handleevent callback function registered by the view.

3. nsview. cpp: handleevent: locate the current view through the event widget, find the corresponding ViewManager, and send messages through nsviewmanager: dispatchevent.

4. nsviewmanager forwards messages to the corresponding nsxulelement through presshell.

5. nsxulelement forwards messages to nsjseventlistener through nseventlistenermanager.

6. nsjseventlistener: handleevent is then called by the javascript interpreter to handle JavaScript events.

 

~~ End ~~

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.