- Home
- » Resources
- » Whitepapers
Whitepapers
February | 2008
Firefox Browser running on top of GTK – DFB
Introduction
GTK+ has been constantly evolving in the gnome environment, and the latest to be added is GTK+ porting on Direct Frame Buffer (DFB). The GDK library inside GTK+ toolkit has been used for rendering into DFB Windowing system rather than using the general X-Windows. This advantage can be derived by the embedded systems market which has many resource constraints, because of the removal of the X Server overhead but still taking advantage of the GUI rich GTK+ environment.
So, to make use of this, the existing GTK based gnome applications have to be moved from GTK-X11 to GTK-DFB. As part of this process, we have developed the Firefox Browser to work under the GTK-DFB environment. This whitepaper talks about the steps that need to be taken for converting the existing Firefox Browser code based on GTK-X11 architecture to work in GTK-DFB environment.
Firefox Overview:
Mozilla Firefox is an open source web browser, based on Mozilla technology, licensed under the Mozilla Public License (MPL), the GNU General Public License (GPL), and the GNU Lesser General Public License (LGPL). Refer Copyright/Trademark Policy Information at the end of this document for more details.
The default Firefox browser, available for Linux desktop, is built using the GTK+ for X-windows. Firefox can be built to run on GTK-DFB with a few changes to X-Windows calls. Such a port can be used in embedded environment like STB, IPTV etc, where X11 libraries are not available.
This document provides details about porting of Firefox browser to a Linux desktop running GTK+ Direct Frame Buffer (DFB). Same port can be cross compiled to run on any other platform like ARM, MIPS etc
Setting the Development Environment:
The Direct FB package needs a Linux Frame buffer configured with 32-bit depth for the desktop. So, the development was carried out on a Redhat linux desktop with the Frame Buffer support enabled.
By default, the Redhat Enterprise 4 linux comes with the frame buffer enabled, in the kernel, as loadable module. The Frame buffer supported kernel, can be loaded at boot time, by using boot options in the “/etc/grub.conf”:
Before starting with Firefox port, Direct FB and GTK along with the following packages need to be installed. The required packages are listed below and can be obtained from respective sites. Firefox dependencies for installing the packages based on the features that have been chosen for Firefox needs to be taken care off while installing the packages. The order of installation as listed below should be strictly followed.
After the packages are installed, make sure everything runs as expected by running some gtk samples (eg: gtk-demo) with Direct FB support.
Firefox Code:
The firefox source code for GTK-X11 can be obtained from the Firefox site:
http://releases.mozilla.org/pub/mozilla.org/firefox/releases/2.0.0.7/source
And at the time of this work Firefox-2.0.0.7 was latest and the same has been used for the entire development. But the steps/procedure described in this document will/should be applicable to any version of the Firefox with the appropriate changes for the packages listed above.
Firefox Source Code Changes:
Configuration Setup:
The firefox code, by default, configured for X11 packages and doesn’t have the “directfb” configuration. The “configuration” & “configuration.in” script files in the mozilla directory of the firefox code consists the configuration steps and also the configuration options to compile.
First step is to add the option “enable-directfb” in the “configuration” & “configuration.in”. When the script is run it will check for all the dependencies for GTK–DFB. And it will also enable the necessary macros for DirectFB. Delete any references to the X based libraries; this can be done by disabling any code under macro “MOZ_X11”.
The modifications involve the following:
Initial Code Development:
The firefox development for GTK-DFB requires more than 50 files to be changed. It also requires some changes in the GTK code base, for the RGB pixel transformations.
The GUI related code for firefox is present in the dir “./gfx/src/gtk”. The files take care of the window creation, menu bars, buttons etc. The X11 based API’s are replaced with equivalent GDK API’s in these files.
The pango and cairo modules play the major part in the image decoding and the display. Incase of GTK-X11 port, the XFT module play a major role in interfacing the pango modules. So, the XFT modules support has to be disabled for GTK-DFB this can be done by “disable-xft”. For example, given below is the pango related change
The corresponding header files changes are as follows:
The pango-xft module dependencies are replaced with pango-cairo modules which aid in display of images properly.
The RGB pixel representation for foreground, by default is done with direct pixel point exchange, incase of GTK-DFB it has to be changed to compare R, G and B
The X11 API’s have to be replaced with relevant GDK API’s. Like the XImage calls have been replaced with GdkImage calls as given below:
The other major graphics changes were in “widget/src/gtk2”. These files mainly deal with widget creation and management.
Plug-in Module Inclusion:
The Plug-in module can be included / excluded in the firefox code by changing the config option “enable-plugins” in the “.mozconfig” file. Any changes in the configuration have to be followed by “make all”.
Run-Time Modifications:
The firefox built on GTK-DFB had a few problems on the display; the image memory was getting corrupted which had to be changed for better display as:
The parameter “windowing_data” would not get the data memory in pixels because of which the display transparency would not be correct. So, in “mem”, a GdkImage parameter was used which returns the corresponding memory pointer in pixels.
The Profile file plays the major part in running the firefox browser. The absence of profile information may crash the firefox browser. So, need to set automatic mozilla profile, which can be made by following changes:
The same parameter is supplied to the main function of Firefox browser. The profile migration option removes the need for automatic new profile creation. And this has to be turned off for the base profile creation.
The firefox preferences to run mozilla can be provided in “pref.js” file. This file also has the entries for delayed timer and proxy settings for the network over which the browser would be using for communication.
Pros & Cons:
The development was to eliminate the X-windows from the original firefox code and modify the code to adopt the GTK–DFB environment. The major advantage would be related to the removal of X, which usually adds its own set of huge run-time libraries over the firefox code and makes it look a big in size. By eliminating X, we tried to reduce this library dependency and also at the same time improve the performance of the browser which otherwise depended on the X library features for blitting/rendering.
This also adds the advantage of deleting the X-dependency for entering the web world and adding more value to the Frame buffer devices available in the linux environment. Also it takes the first step for porting firefox browser on embedded devices without the X-Windows support.
Even though many browsers like GEKO, MiniMo etc are available in the market, none of them have the full features of the normal desktop browsers which this particular development supports.
The disadvantages are related to the event handling, which might not be as easy as under the normal X-windowing system because of the event handling mechanism in DFB environment, does not have any APIs related to event handling. This is handled directly by X, in the normal GTK-X11 environment.
And also the font support would be minimal as the DFB environment does not support all the fonts which are available under the GTK-X11 environment.
Conclusion:
The cross-compilation for different platforms would require some package related changes in the “.mozconfig” file. The browser code for GTK-DFB has been tested on ARM platform as well. The cross-compilation would require libIDL in addition to the basic packages. The performances of firefox over various versions of GTK ranging from 2.10.1 to 2.10.14 are consistent and satisfactory.
Copyright/Trademark Policy Information:
This document /source code is based on Mozilla Technology, for further information on the Mozilla Trademark, licensing and other policies related to Mozilla which are applicable to Firefox browser source code/binaries, please visit the following sites:
http://www.mozilla.org/foundation/trademarks/policy.html
The Mozilla trademarks include, among others, the names Mozilla®, mozilla.org®, Firefox®, Bugzilla™, as well as the Firefox logo and the Mozilla red lizard logo. For all other open source packages, please refer to the respective copyright policies.


Del.icio.us
Digg It