Introduction to XPCOM, XPIDL, XPFE

We are going to dive into three interesting parts of web browsers that in combination provide the necessary funtionality from front-end to back-end, XPCOM, XPIDL, XPEF. ┬áThe browser that our reference complies most is the Mozilla Firefox, so let’s start with an in depth description.

XP stands for cross-platform so it comes to our minds that platorm-independence is the main princile of these particles.

XPCOM, which stands for Cross Platform Component Object Model, is a framework for writing cross-platform, modular software.

What exactly is a COM (Component Object Mode)?

It’s an interface standard for component based development that enables interprocess communication and the development of software components written in multiple computer languages.

So, with XPCOM everything is opened up and components add support for networking, databases, files because it has multiple language bindings (e.g. Javascript, Java, Python) and IDL descriptions so programmers can plug their custom functionality into framework and connect it with other components.

Mozilla’s object library consists mostly of XPCOM components, which provide an amount of core functions and classes e.g. file and memory management, arrays etc. but the majority of components are not part of this core set and is provided by other parts of the platform (e.g. Gecko).

The best part of XPCOM is that it is completely modular and developers have the opportunity to add their custom functionality into the framework and connect with other components (maybe in other programming language) without being trapped in the narrow limits of XML document, whethet it be HTML or XUL.

Image 1 - XPCOM functionality

XPIDL is an Mozilla modified-version Interface Description Language which is used (as we mentioned above) to specify XPCOM interface public methods and properties of a component with a language-neutral way.
The importance of this part consists of:

  • the readability it offers and
  • the language and machine independence of interface description

The XPCOM’s type libraries are binary distribution files which are generated from XPIDL compiler named xpidl. They include XPCOM inteface information, headers for XPCOM objects and XPT type libraries from which objects may be accessed dynamically through XPConnect. It can also generate HTML files for documentation and Java class stubs. Another feature of the XPIDL compiler is the option to generate C++ code stubs. This feature creates nearly all the declaratory C++ code you need when you start a new project, which makes XPIDL useful as a coding wizard that helps you get started.

Image 2 - XPCOM, XPIDL relationship

What is the importance of type libraries?

The separation of interface and implementation is a key distinction of COM programming. We want to maintain compatibility on a binary level so the client code can find and use the library it needs without worrying about linking it. To make this sort of modularity possible at runtime, IDL interfaces are compiled into binary files called type libraries.
Another module of web browsers which is also met in Firefox is XPFE (Cross-Platform Front End). As we can conclude from it’s name XPFE is responsible for the look and feel of the web applications. More specifically, it includes a set of technologies which are used in order for our components to work the same on different computer operating systems. The primary technologies used in creating XPFE applications are Javascript, Cascading Style Sheets, and XUL.

Image 3 - XPFE suite

One benefit of this approach is to isolate the native platform differences into a single location (the widget toolkit) and provide a common set of services for supporting both HTML form widgets and the Front-End graphical user interface.

That’s all for now. More interesting stuff coming soon!!

Includes: Mozilla Source Code Directory Structure

Advertisements