Date post: | 03-Jun-2018 |
Category: |
Documents |
Upload: | luis-yanez |
View: | 218 times |
Download: | 0 times |
of 40
8/12/2019 RAD with Mozilla
1/40
RDF
JavJavaScript
ContractID
NSPR
Digital
Certificates
Mozilla
registry
Preferences Type
libraries
JSlib
XPIDL
definitions
Class
libraries
RDFlib
ComputerOperatingSystem
Security
XPCOM
JVM
Plugins
Components
JNI OJI
Portability
XPConnect
AppDevMozilla-01 Page 0 Thursday, December 4, 2003 6:22 PM
8/12/2019 RAD with Mozilla
2/40
1
C H A P T E R
RDF
JavaScriptcript
URL
TemplatesOverlays
Overlaydatabase
XBLdefinitions
DOM
EventsFrames
GesturesText Keycodes
MouseKeyboard
Widgets
Desktop
themes
GUItoolkits
Fonts
DefaultCSS
W3Cstandards
DTDs
Skins
XBL
Screen
1
Fundamental Concepts
AppDevMozilla-01 Page 1 Thursday, December 4, 2003 6:22 PM
8/12/2019 RAD with Mozilla
3/40
2 Fundamental Concepts Chap. 1
This cha pter is a n overview of Mozilla a rchitecture an d concepts, a nd it con-
ta ins only a lit t le code. If you are new to Mozilla , this chapter provides orien-ta tion and explains w ha t you get for your t ime and effort . I t explains w ha t the
pla t form is , how Mozil la fi ts in w ith XML t echnologies, and how i t supports
rapid application development. If you already appreciate some of the architec-
ture, skip directly t o Cha pter 2, XUL Lay out.
The Ha nds On session in this cha pter conta ins some tr ivia l program-
ming exa mples. It pokes ar ound inside a n existing Mozilla-based applicat ion,
wr ites a tra dit ional hello, world program, a nd begins the NoteTa ker project
tha t runs throughout t his book.
The NPA (Not Perfectly Accura te) dia gra m a t t he sta rt of this cha pter is a
structura l diagra m of the Mozilla platform. Each rectangula r box is a complex
subsyst em tha t represents a chunk of technology. Ea ch chunk is a bout equal in
size to one or more softwa re sta nda rds. These recta ngula r boxes a re embedded
inside the program t ha t ma kes up the Mozilla plat form; they ar e not par ticu-lar ly sepa ra te. The sma ll sta cked rectangles represent fi les tha t sit in a com-
puters fi le system. The platform rea ds a nd w rites to these fi les as necessa ry.
Without knowing anything much yet , it can be seen from the NPA dia-
gra m tha t th ere is a funda menta l split in the platform. On the right (the front
)
are the more user-oriented, XML-like technologies like events, CSS (Cascad-
ing S tyle S heet) styles, a nd t he DOM (Document Object Model). URL s (U ni-
form R esource Loca ters), the ba sis of t he World Wide Web, are a key a ccess
point to th ese technologies. On the left (th e back
) are th e more system -ori-
ented, object-like technologies, such a s components. C ontra ct I Ds (a Mozilla
concept) are a key access point to these technologies. The two halves of the
pla t form are united by a program ming language, J ava Scr ipt , and a da ta for-
ma t , RDF (the Resource Descr ipt ion Fra mework). J ava Scr ip t i s very we l l
suited to the technologies inside the Mozilla Platform.
It is easy to see these two parts of the platform. Open a window on any
Mozilla-ba sed product, for exa mple th e Netsca pe 7.0 Web browser or ema il cli-
ent, and everything y ou see in tha t w indow will be made from XML. Writing a
sma ll piece of J av a Script code th a t subm its a n HTML form t o a Web server is
a tr ivial exam ple of using objects a ssociat ed with the ba ck of the plat form.
The view provided by the NPA diagra m does not t ra nslat e into a t r icky or
radica l programm ing system. P rogram ming with t he Mozilla P la t form is the
sa me a s w ith a ny programm ing environmentyou ty pe l ines of code into a
fi le. U nlike the rest rict ive environment of a Web page, you a re free to work
wit h a very broad ra nge of services.
1.1 U
NDERSTANDING
M
OZILLA
P
RODUCT
N
AMES
The w ord Mozi l la
wa s origina lly a project na me. Proposed by J am ie Zaw inski,
a n employee of Netsca pe Commun icat ions, in t he 1990s, Mozi l la
wa s a lso the
name of the green reptile mascot for that project. It is a contraction of Mosaic
AppDevMozilla-01 Page 2 Thursday, December 4, 2003 6:22 PM
8/12/2019 RAD with Mozilla
4/40
1.1 Understanding Mozilla Product Names 3
K i l le r, coined in th e sp ir i t o f compet i t ive so f tw a re pro jec t s . The Mosa ic
browser w a s th e predecessor of th e Netscape 1.0 brow ser.Since then, the term Mozi l la
has because increasingly overused. At one
time it st ood for a project, a product, an d a pla tform; an d mozi l la.org
came to
stand for an organization. Now, Mozilla is a generic term for a cluster of tech-
nologies, just a s J ava an d .NET ar e . Other terms a re a lso used for products
a nd t echnologies w ith in th a t clust er. Mozillas home on the Web, still referred
to casua lly as mozilla .org, can be found a t
www.mozilla.org
Mozil la fi rst ga ined public visibil i ty w hen th e Netscape Communicat or
5.0 Web application suite was announced as an Open Source project in 1998.
The open source tr a dition a llow s for public scrutiny, public cont ribut ions, and
f ree use . As t im e passed , Moz i ll a beca me a ca t ch-a l l t e rm for every th ing
related to that 5.0 project. After more time, Mozilla 1.0 was declared ready inJ une 2002. Tha t 1.0 release ren a med t he 5.0 project to M ozi l la 1.0
. The 5.0
sta tus of tha t project can st ill be seen in the user-agent string of the browser
(type about:mozilla
into the Location bar to inspect this).
Now, versions 6.0, 6.5, 7.0, and onward refer to the st i l l-proprietary
Netsca pe-bra nded products, like Netsca pe Na viga tor. Versions 1.0, 1.1, 1.2,
an d onwa rd refer to the Mozilla P latform version, as well as to the Web appli-
cations built by mozilla .org, that originate from the Netscape Communicator
Web application suite.
In this book, the terms Mozi l la
and M ozi l l a Plat form
mean the same
th ingthe plat form. Any Mozilla-based a pplica tion (e.g., an ema il client) uses
and depends upon a copy of the Mozilla Platform. The platform itself consists
of an executa ble program , some librar ies, an d some support fi les. If t he plat-
form executa ble is run by itself, without st ar t ing a ny a pplicat ion, then nothing
happens.
The separ a t ion betw een th e Mozil la P la t form a nd mozil la .org a pplica-
tions ha s become more obvious w ith t ime. Wha t w a s once considered to be a
very large application suite is now considered to be a large platform on which
a set of smaller applications are built .
Un t i l a t leas t vers ion 1 .4, these sma l le r app l ica t ions s t i l l ca r ry th e i r
Netscape names
Navigator
,Composer
, an dM essenger
. They a re a lso tight ly
integra ted w ith each other. On one ha nd, this integra t ion presents a unifi ed
face to the user, a face rich in functiona lity. On the other ha nd, this int egra tion
is ine ffi c ien t to ma in t a in because changes to one par t can a f fec t the o ther
par t s . For tha t reason , the browser and ema i l app l ica t ions have been re-
invented a s separa te non in tegra ted product s a t a bout vers ion 1 .5. Thesereplacement applica t ions h ave t he na mes M ozi l la Br owser (project name:
Firebird) an d M ozi l l a M a i l (project na me: Thund erbird). The in tegra ted suite
continues to be ava ilable as w ell.
This split-up of the suite is not a funda menta l change of any kind. B oth
integra ted a nd de-integra ted browsers sh a re the sam e plat form. Toolkits used
AppDevMozilla-01 Page 3 Thursday, December 4, 2003 6:22 PM
8/12/2019 RAD with Mozilla
5/40
4 Fundamental Concepts Chap. 1
by old an d new browsers a re a lso very sim ilar. The a pplica tion logic for old a nd
new browsers does differ ma rkedly, however.B ecause th e new nonintegra ted applicat ions a re st ill in fl ux, an d because
they are narrow in focus, this book uses the older, integrated applications as a
re ference poin t an d t each ing t ool . Those in tegra ted a pplica t ions a re w e l l
tested, demonstra te near ly a l l o f the pla t form technology , are bet ter docu-
mented, an d a re st ill up-to-dat e. They a re a useful tra ining ground for gra sp-
ing Mozilla technology.
In this book, Cl assi c Br owser
means the es t a b l ished and in tegra t ed
mozilla .org browser t ha t is part of an a pplicat ion suite.Classic M ozi l la means
the w hole application suit e. Navigator means a Netscape-branded browser
such as 7.0 or 4.79. The Cla ssic Brow ser ma y display i t s content using th e
Cla ssic theme (which looks like Netsca pe 4.x suite of products) or t he Modern
th eme (w hich looks like t he 5.0 suite of products). The C las sic th eme is t here-
fore one step older than the Classic Browser.
A fin a l product of the Mozilla project is Gecko
, also ca lled the Gecko Run -
t im e Engine
. This is a str ipped-down version of the plat form tha t conta ins only
a core set of display technology. It has not yet emerged as a clearly separate
product, but w ith increa sed use of this na me, it is likely tha t G ecko w ill be rec-
ognized separately.
To summarise a ll tha t na ming deta il , this book is about the Mozilla P lat -
form only. I t uses th e Cla ssic Browser a nd other par t s o f Classic Mozil la t o
explain how the platform w orks, but it is a bout building applicat ions separa te
from th ose applica tions. The NoteTa ker runn ing exam ple adds a tool to the
Cla ssic Browser because it is too small to be an a pplication of its own. If you
download a nyth ing for this book, downloa d t he 1.4 release of Cla ssic Mozilla ,
wh ich contains the version 1.4 Mozilla P lat form.The rema inder of this t opic looks at some of th e other na mes a ssociat ed
w ith Mozilla t echnology.
1.1.1 Platform Versions
Funda menta l to Mozilla is the Cla ssic Mozilla softw ar e release. Many versions
o f th is combina t ion o f p la t fo rm and Web appl ica t ion su i te ex is t . Cla ss ic
Mozilla conta ins a la rge subset of all features wit h w hich the plat form is capa-
ble of dealing. The rema ining fea tures a re una va ilable. The ma in versions of
Classic Mozilla follow:
Stable or major releases
. These a re versions x.0 or x.0.y; th ey provide
a guara ntee tha t crit ical features (interfaces) wont change unt il the next
major release. Examples: 1.0, 1.01.
Feature or minor releases
. These ha ve versions a.b, wh ere b is great er
tha n 0. Feat ure releases provide enhan cements a nd bug fi xes to ma jor
releases. E xam ple: 1.4.
AppDevMozilla-01 Page 4 Thursday, December 4, 2003 6:22 PM
8/12/2019 RAD with Mozilla
6/40
1.1 Understanding Mozilla Product Names 5
Alpha, Beta, and Release Candidate releases
. Before version 1.4 is
fi nished, versions 1.4alpha an d 1.4beta ar e versions of 1.3 tha t a re moret h a n 1 . 3 , b u t n e i t h e r fi n i sh e d n o r a p p r ove d f o r r e lea s e a s 1 . 4. Th e
Release Candidate versions are near-complete beta versions that might
become fina l releases if t hey pass la st-minute testing.
Talkback releases
. Alternate versions of any release might include
Talkba ck technology, which captures t he browser sta te w hen it cra shes
an d ema ils the result back to mozil la .org . This is used for mea n-t ime-
betw een-failur es engineering metrics a nd for debugging purposes.
Nightly and debug releases
. Relea ses created night ly a re compiled
from the very la test chan ges and a re the relea ses leas t l ikely to work.
They a re compiled w ith a ddit ional debugging feat ures turn ed on, wh ich
very t echn ica l users can use a s a na lys is t ools . B o th the p la t fo rm a nd
applicat ions conta in debugging feat ures.
Custom versions
. Because the source code is freely available, anyone
with a suitable computer can compile the platform. Numerous compile
time options cha nge the set of feat ures included in the fi na l binary fi les.
By modify ing the default set o f fea tures, custom pla t forms run a r isk.
Th e r i sk is t h a t t h e m a j or i t y o f f or w a r d p r og r e ss a s su m e s t h a t t h e
default features are always available. Special custom versions must live
with t he fact tha t t hey may not keep up with ma instream changes to the
platform an d ma y not run some Mozilla a pplicat ions.
This book uses final, minor, or major releases of the standard platform.
1.1.2 Example Applications
Some of the bett er-known Web applicat ions built on th e Mozilla plat form follow :
Netscape 7.0
. This is t he commercia l edition of Mozilla a nd in cludes fea-
tur es to su pport AOL Time Wa rners business goa ls in the Web a nd Int er-
ne t s pace . The ma in t echn ica l d i f fe rences a r e : suppor t fo r the AOL
concept of screen na me; integra tion w ith AOLs s erver-side fa cilities; la ck
of popup win dow suppression; custom cookie han dling; an d a genera l
cleanup of the user inter face . Netscape 7.0 is based on Mozil la 1.01.
Netsca pe 6.x is a lso based on Mozilla; how ever, it is ba sed on version 0.94
an d is highly buggy.
Compuserve 7.0
. AOL a lso own s t his o lder Web an d In ternet cl ient-
bas ed service, which st ill has a lar ge user ba se. Version 7.0 is a Mozilla
1.01based tool.
AOL 8.0 for MacOS X
. This is AOLs flagship Web and Internet client,
wit h a very large user ba se and a highly custom interface. With version
8 . 0, t h e M a c in t o sh ve r s io n o f A OL h a s b e e n m o ve d f r o m I n t e r n e t
Explorer to Mozilla 1.01.
AppDevMozilla-01 Page 5 Thursday, December 4, 2003 6:22 PM
8/12/2019 RAD with Mozilla
7/40
6 Fundamental Concepts Chap. 1
Mozilla Browser
. This m ozilla.org Web brow ser is to be m ore compa ct
and streamlined than the Classic Browser.
Two very ex tensive exam ples o f non-Web a ppl ica t ions a re g iven by
OEone and ActiveSta te.
OEone (
www.oeone.com
) produces products int ended to ma ke persona l
computers easily u seable by n ovices. Their OE one HomeBa se product is a cus-
tom combina t ion of Linux and a n enha nced version of the Mozil la pla t form
called Penzilla. It provides a complete system for interacting with a computer.
Figure 1.1 shows an ar ran gement of this Mozilla-based desktop.
ActiveState (
www.activestate.com
) produces integrated development
environment (IDE) tools for software developers. Their Komodo product is
based on the Mozilla platform. Figure 1.2 is a screenshot of that product.
In a ddition t o Web an d non-Web applicat ions, highly customized a pplica -
tions a re possible. The sta nda rd Mozilla P lat form provides the sa me interfaceon every desktop, which involves some compromise. There have been a num-
ber of at tempts t o creat e browser products t ha t m at ch the exact look an d feel
of one specifi c pla t form. These a re deeply customized of fshoots of Mozil la .
Su ch offshoots use embedding technology not covered in t his book:
Fig. 1.1 OEone HomeB ase desktop. Used by permission of OEone Corpora tion(www.oeone.com).
AppDevMozilla-01 Page 6 Thursday, December 4, 2003 6:22 PM
8/12/2019 RAD with Mozilla
8/40
1.1 Understanding Mozilla Product Names 7
Chimera
. A Ma cintosh Ma cOS X browser ba sed on the C ocoa int erface,
with tradit ional Macintosh menus.
Galeon, Nautilus
. Browsing too ls in tegra ted c losely w i th t he GNU /
Linux GNOME desktop interface. Some of this integration is addressed
in the st an dar d plat form w ith forthcoming support for G TK 2.0.
K-Meleon
. A Microso f t Windows browser t ha t turn s Moz i l la in to a n
ActiveX control. Toolbar s a re very sim ilar to a simple Int ernet E xplorer.
The number of applica t ions based on the Mozil la pla t form is steadily
growing, with announcements every month or so. The community newscenter
www.mozi l lazine.org
is a good pla ce to pick up ann ouncement s of new M ozilla
products.
1.1.3 Jargon Buster
Moz il l a cu l ture an d m oz il l a .o rg documenta t ion con ta ins some convo lu ted
sla ng. Covering it all is a hopeless ta sk. Refer to www .mozi l l a .org/ docs/ jar-
gon.html
and t ohttp : / / devsupport .mozdev.org/ QA/ thesaurus/
. A few of themore visible terms follow:
XP
. Cross pla t form, meaning por ta ble, as in XP COM, XP FE , XP Insta l l ,
XPIDL.
FE
. Front end, the gra phical display part of Mozilla .
Fig. 1.2 ActiveSta tes K omode 2.0 IDE . Used by permission a nd courtesy ofActiveSta te (www.activestate.com).
AppDevMozilla-01 Page 7 Thursday, December 4, 2003 6:22 PM
8/12/2019 RAD with Mozilla
9/40
8 Fundamental Concepts Chap. 1
BE
. Ba ck end, the netw orking par t of Mozilla .
I18n
. Internat iona lization = I + 18 chara cters + n. Multilocale support .
L10n
. Local iza t ion = L + 10 chara cters + n . Customizat ions for a g iven
locale.
The tree
. The Mozilla source code an d compilation sy stem.
Bloat
. The tendency for an y program undergoing enhan cement t o get
bigger.
Landed
. Usua lly landed funct ionali ty : adding fi nished changes to t he
tree.
Dogfood
. From ea t your own d og food: test in g wh ere you t r ia l your
own fi xes.
Porkjockeys
. Der ived fr om fl ying pigs. Those wh o seek to redesignMozilla radically.
r=ada
. Cha nges reviewed a nd a ccepted by Ada.
sr=ada
. C h a n g e s s u p e r -r e v i e w e d (a r c h i t e c t u r a l l y r e v i e w e d ) a n d
a ccepted by Ada .
Zarro Boogs
. Zero bugs; no current defect report s.
Fina lly, there is an end less list of overlapping t echnica l terms for th e core
capa bilit ies of Mozilla : S eam onkey, NG La yout, Necko, a nd more. Very few of
these terms map cleanly to a single, obvious application technology, so they
are generally avoided in this book.
1.2 T
HE
XML E
NVIRONMENT
XML (the E xtensible Markup La ngua ge) is a hugely successful sta nda rd from
the World Wide Web Consortium (the W3C, at www.w3.org
). Mozilla has exten-
sive support for XML, so we briefly review wh at tha t st a nda rd is good for.
The pr imar y goa l o f XML is to provide a no t a t ion fo r descr ib ing a nd
structuring content
. Content is just da ta or informa tion of a ny kind. The cen-
tra l XML sta nda rds provide a toolkit of concepts a nd synt ax. Tha t t oolkit can
be used to creat e a s et of descriptive terms t ha t a pply t o one type of content,
like vector graphics. Such a set of terms is ca lled an appl ication
of XML . The
most well-known XML application is XHTML, which is the XML version of
plain HTML.
XHTML describes content that contains text , images, and references toother XHTML documents, commonly known as links. Any particular example
of this content is called an instance
or a document
. Thus, XH TML defi nes
hypertext
document s, as opposed to a ny other kind of document. There a re
ma ny other publicly defin ed XML applicat ions, such a s S VG (
vector graph ics
content),Ma thML(
mathematical content),andRDF(
r esour cedescription con-
AppDevMozilla-01 Page 8 Thursday, December 4, 2003 6:22 PM
8/12/2019 RAD with Mozilla
10/40
1.2 The XML Environment 9
tent ). Mozillas own XUL specifi esgraph ical u ser in terf ace cont ent. As a n XML
exam ple, List ing 1.1 is a tr ivial S VG document.
Listing 1.1
A document that is an instance of SVG 1.0, an XML application.
A Rectangle
The first five lines of this example specify the document type; the rest is
the document content. U sing a n XML a pplicat ion defi nition, programmers cre-a t e sof twa re tha t can process documents of tha t a pplica t ion t ype. Such pro-
cessing can be ei th er quit e simple or complex. In t he case of Figure 1.1, a
progra m might t ake this document a nd display a r ecta ngle with th e words A
Recta ngle inside it. A Web browser is a n exam ple of such a program . Pr ocess-
ing o f such documents can be very sophis t ica t ed . XML documents can be
t r a nsformed, t r an smit t ed , crea t ed , chopped up , and combined , a s w e l l a s
merely displayed.
The grea t s uccess of XML rests on the follow ing few simple principles.
1.2.1 Common Underlying Format
All XML documents, rega rdless of applica tion, have t he sa me underlying for-ma t . This common format ma kes ana lysis o f a l l such documents similar . I t
saves a great deal o f energy tha t would otherwise be wasted arguing about
synta x. Such argum ents typically have lit t le bearing on the actua l informa tion
that those formats contain. That saved energy can be put to more important
tasks, and software no longer needs special adaptors to read the special for-
ma ts of other systems.
A furth er consequence of this common format is th a t it promotes reuse
and enhancement of software tools. Common operations on the XML format
ar e now w ell known. Consequent ly, findin g or making a tool tha t processes
XML is easier. P rogrammers ca n rely on th ese feat ures being present in m ost
modern t ools, including Mozilla .
1.2.2 The Open-Closed Principle
The open-closed principle originates from the world of object-oriented (OO)
program ming. It captures the idea th at a piece of softw ar e can be both fi nished
(closed) and yet st ill available for further change (open). This thinking also
applies to XML. The core XML sta nda rds a re fi nished and certa in, as a re vari-
AppDevMozilla-01 Page 9 Thursday, December 4, 2003 6:22 PM
8/12/2019 RAD with Mozilla
11/40
10 Fundamental Concepts Chap. 1
ous applications of XML; nevertheless, anyone can create a new XML applica-
tion at an y t ime. This is a highly fl exible arra ngement. Furthermore, the XMLsta nda rds a llow pa rtia l insta nces of XML a pplicat ions (called docum ent fr ag-
ments
) to be mixed t ogether in one document . One document might conta in
both XHTML and SVG content. That is also highly flexible.
Such fl exibility is a highly fl uid situa tion and provides fert ile ground for
innovat ion. Document a uthors ar e free to make any insta nce of a par t icular
XML application, which is just common sense. Software developers, however,
a re free to make a ny XML applicat ion defi nition. New a pplication definit ions
can be the ba sis for a wh ole range of new document insta nces in a new content
or application area .
Mozil la benefi ts from th is fl exibil i ty. I t implements severa l innovat ive
XML a pplica t ions, pr ima r i ly XUL (XML U ser-inter face Lan guage) and XBL
(XML Binding Language), upon which many special-purpose XML documents
are based. It allows programmers to process generic XML content and many
specific XML applications, like RDF and XHTML.
1.2.3 Beyond English
Another benefi t of XML is its a bility t o be expressed universa lly.
The U nicode sta nda rd is a list of every char acter concept used in huma n
writ ing. When a Un icode chara cter reference and a font ar e combined, a visual
chara cter (also called a glyph) can be displayed. XML documents can r efer t o
an y entry in the U nicode sta nda rd, so XML is a useful wa y to express informa -
t ion in any la nguage on Ea r th .
E a r l y su ccesse s in t h e m o d e r n w o r ld of com p u t in g o ccu r r e d in t h e
En glish-speaking part of the West, some at the U niversity of Ca lifornia , Ber-keley C am pus, and some at AT&T. It seemed at the t ime tha t eight bits (one
byte) was suffi cient to capture a l l the glyphs in common English t ext . This
resulted in the ASC II char acter set , the C lan guages char
type, and process-
ing technology in the UNIX operating system all being fixed to one byte. This
legacy has created a hurdle for the Unicode standard, which overall requires
two bytes per character . XML is one way around this hurdle since i t s tar ts
aga in from the beginning with a new forma t based on Unicode standa rds.
Mozilla is an example of a tool that handles internationalization issues
by rely ing on XML and Unicode technology . I t s main supported language,
J ava Script , is a lso based on U nicode.
1.2.4 Hierarchical Thinking
The fi na l st rength of XML is in i t s int ernal st r ucture. Documents crea ted to
XML sta nda rds consist of fra gments of content nested inside each other, in a
hierarchical w ay. Hiera rchical organiza tion is a concept th at huma ns fi nd easy
to gra sp. As th e riddle goes, the ma n from S t.Yves had seven w ives, each wife
AppDevMozilla-01 Page 10 Thursday, December 4, 2003 6:22 PM
8/12/2019 RAD with Mozilla
12/40
1.3 Platform Concepts 11
with seven sa cks, each sa ck containing seven cats, each cat wit h seven kit tens.
Tha t is hierarchical thinking.Simple concepts are especially important in computing because working
wit h computers is a n a bstra ct ta sk. Even outside computers (e.g., this book),
hierarchical orga niza tion brings order to complex masses of informa tion. For
computer program mers , the h iera r ch ica l na ture o f XML is a n easy wa y to
express solutions t o problems a nd get something d one.
1.3 P
LATFORM
C
ONCEPTS
Let s now t urn t o the na ture of the Mozilla P latform itself . A softwa re platform
is a piece of software that programmers use as a stepping stone. By standing
on the featu res of the platform (relying on the softwa re), the ta sk of creat ing
high-level funct ionali ty is made easier . Programmers need not waste t imema king basic functionality using la ngua ges like C.
The four big stepping stones in Mozilla a re XUL, J ava Script , RDF, an d
XPC OM. XUL is an XML dialect used t o construct user interfaces, Ja vaS cript
is a scripting language with syntax akin to C, RDF is an XML dialect used to
store dat a , and XP COM (Cross Pla tform C omponent Object Model) is an object
discovery and management system. Those four i tems are discussed exten-
sively throughout this book. Here we look at the overall environment in which
th ey live.
From beginning t o end, the Mozilla P lat forms ma in strength is in build-
ing visual, interactive applicat ions. It is n ot intended to be used to write driv-
ers, servers, or batch processing systems. It can easily provide a front end for
such systems.
1.3.1 Architecture
Netscape Web products prior to Mozilla were built in a hurry and were not as
structured or as open as might be desired. This history heavily limited the use
and future of those products, and held Netscape back when its 4.x products
were competing with Microsoft s Internet Explorer and Outlook Express for
functionality.
Since then, Netscape, mozilla .org, and volunteer progra mmers h ave ha d
the time, the ta lent, and t he freedom to break a lot of tha t ea rly technology down
into smaller, more flexible pieces. They have also replaced some poorly conceived
technology w ith better solutions. These pieces together ma ke up t he modern
Mozilla P lat form a nd a re better organized tha n in the past . This flexibility qua l-ifies Mozilla as a platform rat her tha n as a highly customizable product.
1.3.1.1 A Layered Approach Th e M oz i l l a P l a t f or m a t t e m p t s t o m e et t h e
needs of several different types of programmers, and the result is that it has
been conceived a s a set of semi-independent la yers.
AppDevMozilla-01 Page 11 Thursday, December 4, 2003 6:22 PM
8/12/2019 RAD with Mozilla
13/40
12 Fundamental Concepts Chap. 1
The lowest layer of the pla tform ma na ges and im plements a large set of
objects. These objects all cooperate inside a single executable according to abuil t-in media t ion system. Mozil la needs a media t ion syst em tha t is highly
porta ble, s ince i t runs on ma ny pla t forms. In th e end, a custom syst em wa s
designed for t he purpose. I t is ca l led XPC OM an d is a t t he core of the pla t-
form. Direct a ccess to XP COM is only possible from th e C a nd C+ + langua ges.
The XPC OM system is w rit t en very car efully so tha t it compiles and ru ns on
ma ny different operating sy stems. Files holding objects ma na ged by XPC OM
can be seen in the components directory of the sta nda rd Mozilla insta llat ion.
On top of XPC OM is a very thin la yer called XP Connect. XPC onnect pro-
vides a JavaScript interface to XPCOM. The JavaScript language is a flexible
an d loosely typed language th at can ma nipula t e XPCOM objects very easi ly
an d in a porta ble way. This layer provides a n a pplicat ion programmer w ith a n
a ccessible and la rge object l ibra ry. Tha t l ibra ry consists o f a l l th e XPC OM
objects in the pla tform. Debug releases of the pla tform include a t esting t oolca l led xpcshell, which a l lows programmers to code direct ly a t th is level ,
alt hough tha t is less commonly done.
Some of the objects ava ilable in the plat form a re large a nd sophisticat ed
and can process XML content. These objects can present a high-level view of
XML conten t to the programm er. Such v iews a re based on the W3C D OM
standa rds, ava i lable a t www.w3.org . This means tha t instea d of par sing XML
tex t d i rec t ly w i th ha ndmade J ava Scr ipt programs, a programmer can a sk a
sophist ica ted object t o swallow a nd digest a n XML document a nd in return
receive a high-level set of interfaces, like the D OM 1 Document int erface. In
th is wa y, Ja va Script scripts need only to consult t he XPC OM object broker for
a few powerful objects. From th en on, scripts can w ork directly on th e large set
of DOM objects produced wh en th ose few objects a re given a n XML document.
This D OM lay er of functionalit y is common in most program ming envi-
ronment s w here XML is processed, including in XH TML Web pages w hen
Dyna mic HTML scripts ar e creat ed. In a Web page, there is no hint t ha t t hese
objects originate from XPCOM, but that is still the case. It is common for this
DOM la yer to be slightly enha nced so th a t it in cludes oth er useful objects, like
thewindow and navigatorobjects present in Web-ba sed J a va Script. S ome-
times security constraints are imposed as well. All this is done in Mozilla, and
that slightly enhanced layer provides an environment for a number of XML-
based content types, plus HTML. Most importantly, Mozilla s own XUL has
such an environment. This layer is the sta rt ing point for the G UI s (gra phical
user interfaces) that application developers need to create. An example of the
DOM La yer can be seen in any H TML page tha t con ta ins Dyna mic HTML
scripting.S o m e X PC O M o bj ec t s p e r f or m t h e i r ow n so ph i s t i c a t e d G U I d i sp l a y
ta sks, nota bly layout an d render ing. The G ecko por t ion of the Mozilla P la t -
form is a collection of objects that do this. These high-level objects automate
th e display of XML document s, graphics, and text . When a n a pplication pro-
gra mmer needs to d isp lay some con ten t , a scr ip t can t hrow t he con ten t to
AppDevMozilla-01 Page 12 Thursday, December 4, 2003 6:22 PM
8/12/2019 RAD with Mozilla
14/40
1.3 Platform Concepts 13
these layout an d rendering objects a nd display a utomat ically ha ppens w ithout
a ny furt her program mer effort . This topmost, visual a spect of the platform canbe seen in a ny Web browser w indow.
Finally, XML content and XPCOM objects can be tied together. This can
b e d on e w i t h a n X B L b i n d i n g , a n X U L t e m p la t e , o r ot h e r l e s s o b v io u s
approaches. These Mozil la -specifi c ta ct ics extend t he a utoma t ic processing
done by sophist ica t ed XPC OM objects so tha t even high-level ta sks require
o n ly sm a l l a m o u n t s o f s c r ipt in g . Th e t a b b e d n a v ig a t i o n f ea t u r e o f t h e
Mozilla browser is a n exam ple of a t a g/object combina tion creat ed in XBL .
I f tha t w ere a l l of the Mozil la P la t form, then the pla t form would be no
more than a J ava Scr ipt int erpreter and a huge object l ibrarynot m uch dif-
ferent t ha n P erl, Tcl, Visua l B a sic, or even J av a. The plat form, however, a lso
includes at the topmost level an appl i cati on shel l. This shell is a ma ss of plat -
form code that binds ma ny of the XP COM objects t ogether int o an executa ble
program . This program is able to aut omate a nd coordina te ma ny t asks, l ikeconnections to server softw ar e, basic document m an agement , and inst alla t ion
processes. The application shell, plus many special-purpose XPCOM objects,
represen t s a ready-ma de deve lopment f r amew ork . I t i s more immedia te ly
useful tha n a passive set o f l ibrar ies tha t can t do anyth ing unt i l a program-
mer chooses to use them. The application shell provides the organization and
integra tion fea tures th at allow a pplications to run on top of the platform. It is
a l s o t h e p l a t f o r m s a p p l i ca t i o n e x e c u t i o n e n g i n e . Th emozilla (o r
mozilla.exe) executa ble is a copy of the pla tform w ra pped up in a n exten-
sive application shell.
A substantial portion of a programmers work can be done merely by cre-
a ting XML d ocument s. These ar e then supplied to the a pplica tion shell.
These layers of the platform do not hide each other from the program-
mer. An a pplica tion programmers script can perform operat ions a t an y level,
in a ny order, subject t o security constr aint s. Common ta sks tha t a re in keep-
ing wit h th e interact ive , visua l or ienta t ion of the pla t form can be achieved
with very l i t t le code tha t exploits t he highest layers of the pla t form. Highly
applica t ion-specific tasks require a more t radit ional programming sty le in
w hich lower-level objects a re combined for a n end r esult.
The remainder of this discussion of architecture considers some of these
layers in m ore deta il .
1.3.1.2 XPCOM Component Model A great strength of Mozilla is its int ernalstructure.
At t he lowest level , the pla t form i tself is wr i t ten in the C an d C+ + pro-
gram ming langua ges. In t he case of a simple C/C+ + program , adding function-a l i t y mean s compi l ing an d l ink ing in more objec t s o r funct ions . For l a rge
projects, this is an impractical a nd na ve approach for ma ny rea sons.
One reason is that the result ing program will grow huge and inefficient
to run. I t is a lso impra ct ica l beca use keeping t ra ck of a l l t he implemented
objects is difficult. Finally, if several different projects are to use the software,
AppDevMozilla-01 Page 13 Thursday, December 4, 2003 6:22 PM
8/12/2019 RAD with Mozilla
15/40
14 Fundamental Concepts Chap. 1
each one might require only a por t ion of the pla t form. In other words, each
project must h eavily modify th e pla tform for its own ends or live with a miscel-la ny of objects th a t it ha s no use for. There needs to be a cleverer approach,
an d there is.
An object broker (also ca lled a n object d irectory, object na me ser vice, or
object discovery service) is a piece of code that finds objects and makes them
ava ilable. If a ll objects built provide a sta nda rd or common interface tha t t he
broker can use, then all members of a large set of objects ca n be ha ndled the
sa me wa y. Tha t im poses some uniformit y on objects.
Mozilla objects are organized into individual components. Components
a re built out of objects an d interfa ces. A component registr y (a sm a ll dat a ba se)
ma inta ins a l ist o f a l l t he ava i lable components. A component n am e service
that turns a component name into an object (in object-oriented terms it is a
factory) is also ava ilable, as a re a t housand components a nd a thousand int er-
fa ces. H ere is an exa mple of a component na me, w ritt en in Contr act ID form.The trailing digit is a version number:
@mozilla.org/browser/httpindex-service;1
Th e in f r a s t r u c t u r e o n w h ich t h e se com p o n en t s a r e s t a n d a r d i z e d i s
XPC OM. XP COM is a lit t le like CORB A an d a lot like COM, two other object
broking systems.
CORBA (Common Object Request Broker Architecture) is a system for
gluing together objects w rit ten in a ny of a number of programming la ngua ges.
In order to do tha t it describes all object int erfaces using a la ngua ge-neutra l
synta x called IDL (Interfa ce Defi nition Langua ge). Mozilla includes a var iant
of the CORBA IDL specifica t ion technology . The Mozil la version is ca l led
X PI D L ( Cr o ss P l a t f o r m I D L ) . I t i s a p o r t a b le (h a r d w a r e - a n d o pe r a t in g -
system-independent) langua ge tha t is used to genera te porta ble code an d t ype
libraries.
COM (Common Object Ma na gement) is a system for gluing together dif-
ferent objects wr it ten under Microsoft Windows. Mozilla a lso includes a var i-
an t of COM, called XPC OM (Cross P latform COM). XP IDL an d XPC OM work
together in Mozilla a s a hybrid system t ha t a cts on COM-like objects t ha t a re
described by CORB A-like specifica tions. There is no at tempt to ma ke XPC OM
a dist r ibuted sys tem, l ike DC OM (Dist r ibuted COM). I t is restr icted to one
computer alone, and currently to one executable. Although object specifica-
t ions a re CORB A-like, the XPC OM system du plica tes th e fea t ures of COM
qu ite closely.
Nearly all of Mozilla is reduced to XPCOM components, and nearly all of
these components a re scripta ble via J ava Script . Many components implementWeb protocols or o ther net working sta nda rds. This component m odel plus
available network components makes Mozilla look like a miniature version of
Microsofts .NE T fra mew ork. If plat form component s ar e writt en in C/C+ + , as
most a re, then t hey must be writ t en according to strict portability guidelines,
just as XPC OM is.
AppDevMozilla-01 Page 14 Thursday, December 4, 2003 6:22 PM
8/12/2019 RAD with Mozilla
16/40
1.3 Platform Concepts 15
1.3.1.3 Support for XML Softwa re support for XML stan dar ds is a ma tter of
degree. A program might merely be able to read an XML document, like a filefil ter , or i t may have i ts ent ire purpose dedica ted to XML analysis , l ike an
XML database server. Mozilla lies somewhere between these two extremes.
Mozilla does a better job of supporting XML st an dar ds th an just reading
documents of tha t format . Mozilla ha s considerable infrastructure for man age-
ment of retrieved XML documents; in pa rticular , it ha s a simple but sophisti-
cat ed processing m odel for RD F. The best wa y t o view Mozillas XML support
is as a system that can get XML from hereand put i t there. To assist tha t pro-
cess, a num ber of t ra nsformat ion t echniques can be applied. Exa mple tech-
n i q u e s i n c l u d e m e r g i n g a n d fi l t e r i n g d o c u m e n t s , m a n a g i n g d o c u m e n t
fragm ents, and performing fi ne-gra ined insert , upda te, and delete operations
on the document st ructure and its content.
A fairly complete list of Mozilla-supported XML applications is: XML,
X M L N a m e sp a ce s , X L in k , X HT M L ( a n d HT M L ) , M a t h M L , S V G , X S L T(Extensible Stylesheet Language Transformations), RDF, SOAP, WSDL (Web
Services Description La ngua ge), and XML Schema.
Mozilla also supports two XML applications unique to the platform: XUL
and XBL. XUL documents specify arrangements of graphica l widgets . XBL
documents represen t b ind ings tha t b lend toge ther a J ava Scr ipt object a nd
XML cont ent int o a new piece of cont ent. XUL is a crucial technology for a ppli-
cation developers. Look a t a ny C las sic Mozilla w indow or dia log boxevery-
th ing you see (except for any displayed H TML) is XUL content.
Mozilla supports DTDs (document type defi nit ions) for ma ny of th ese
sta nda rds. It supports XML S chema defin itions for none of them. Of the sup-
p or t e d s t a n d a r d s , t h e on ly o n es t h a t a r e in t e n d e d fo r v isu a l d i sp l a y a r e
XHTML/HTML, S VG, Ma thM L, XUL , an d XB L. The rest a re used only for
data processing purposes.
1.3.1.4 Gecko Content Display Model To show t he user XML cont ent, some
kind of display sy stem is required. Tha t is the job of th e render ing objects
inside the plat form t ha t form part of the Gecko display subsyst em.
The rules tha t determine the lay out of XML documents (an d pa rticularly
layout of HTML) have been shift ing in th e last few yea rs. Where those rules
used to appear in st an dar ds such a s H TML, they now a re collected into the
styling standards, such as CSS, DSSSL (Document Style Semantics and Spec-
ifica t ion Language), and XSL-FO (XSL Format t ing Objects) . This t rend is
reflected in the Mozilla Platform, where all layout is controlled by a modern
CSS2 implementation, which includes many Mozilla-specific enhancements.
The pow erful CS S2 engine inside Mozilla is a lso the hear t of the G ecko lay outsystem. Mozilla a lso uses C SS 2 for printing.
XML documents ar e not immut able. If delivered from a remote location,
they can ar rive incrementally. If a cted on by a program mer, they ma y grow or
shrink. Modern display t ools need a sophisticated content m odel to support all
kinds of dyna mic content changes during display. Mozilla ha s a third-generation
AppDevMozilla-01 Page 15 Thursday, December 4, 2003 6:22 PM
8/12/2019 RAD with Mozilla
17/40
16 Fundamental Concepts Chap. 1
content display system, also part of Gecko, whose architecture is contrasted
a gainst earlier approaches in th is short list. Although the list refers to XML, themost obvious example of a display syst em is one tha t displays HTML.
Mark I strategy. Read a n XML document s ta gs one a t a t ime and dis-
p lay a s you go. Pa use the d isp lay process w hen no t enough t a gs ha ve
a r r ived to figur e ou t t he nex t s tep , ma king the user wa i t . Very ea r ly
browsers d id this w ith H TML, like Netsca pe 1.0.
Mark Ib strategy. Read a ll of a d ocument s XML ta gs into memory, put-
ting the user on hold. Ana lyze the document. Display t he entire document
at once. No popular browsers ever did this, but XSLT performs batch pro-
cessing in a similar way when used in specialist printing software.
Mark II strategy. Read XML t a gs one a t a t ime and d isp lay t he page
using placeholders for content th at is a nticipat ed but n ot yet r ead. Whenthat content arrives, dynamically replace the placeholders with the real
content . Shuffl e everyth ing a round to clean u p cha nges each t ime place-
holders ar e filled. Internet Explorer 4.0+ an d Mozilla 1.0+ do this.
Mark I II strategy. Read XML ta gs a s for Mark II , but possibly read con-
trol informa t ion as w ell. When the user or the server ma nipula tes t he
contr ol informat ion, fe tch or remove matching content a nd upda te th e
display w ith it . Do this even after t he document is fully loaded. Mozilla
1.0+ , which uses RDF as the control informa tion, does this.
It requires a complex design to implement a Mark III display model, and
Mozilla s interna ls ar e quite sophisticat ed in this a rea.
1.3.1.5 Support for Web Standards F or t r a d i t i o n a l We b p a g e d i s p l a y ,Mozillas Web st a nda rds support is th e best yet seen in a Web client . The clos-
est curr ent competit or is th e Opera Web browser. Alth ough t his book is not
about HTML, a br ief review is not ent irely ir relevant , s ince HTML can be
combined with XU L in several wa ys.
In t he world of HTML, Mozilla ha s a legacy compati bil i t y m ode, a str ict ly
standards-compl iantmode, andanearlystandards-compl iantmode .Theleg-
a cy compa tibility mode does its best t o support old HTML 4.01 and ea rlier doc-
ument s. The st r ict m ode support s t he new er XH TML 1.0 only. The nea r ly
strict mode is the sa me as the st rict m ode, except t ha t it provides a migrat ion
path for older Web pages that look bad when displayed strict ly according to
sta nda rds. Direct ives a t the sta r t o f a Web page determine which mode wil l
process tha t document . In a l l modes , enhancements to the s t andards a reallowed a nd some exist .
Mozilla supports complementa ry Web sta nda rds s uch as HTTP 1.1; CSS 2;
DOM 0, 1, and 2; and E CMAScript Edit ion 3 (J ava Script). Mozillas Ca scading
St y le Sheet (CS S2) support has received a great deal o f standa rds a t tent ion,
and a number of Mozilla extensions look forward to CSS3, or are merely inno-
AppDevMozilla-01 Page 16 Thursday, December 4, 2003 6:22 PM
8/12/2019 RAD with Mozilla
18/40
1.3 Platform Concepts 17
vative in their own right . Only some parts of DOM 3 are supported. Mozilla
supports some of th e accessibility st a tements ma de by th e W3C.The world of HTML is being reduced to a num ber of sma ll, separa te sta n-
dar ds an d s t a nda rds modules tha t toge ther make up the who le o f HTML.
Mozilla supports XLink but not XForms. Similar ly, some of th e DOM 3 mod-
ules ar e supported, w hile others a rent . Sin ce Internet Explorer 6.0 supports
on ly the DOM st a ndards to DOM 1, Moz i ll a i s w e ll ahead in the s t a ndards
adopt ion ga me. Cha pter 5, Scr ipt ing, explores sta nda rds compliance for t he
DOM standards in more detail .
Mozilla su pport for Ma thML an d S VG is n ot complete. The Ma thML sup-
port is close to being complete a nd is exten sive enough to be fully functiona l, but
the SVG support is only partia lly implemented and is not a vaila ble by default.
1.3.1.6 Custom Tags and Objects Mozi l la provides a specifi ca t ion mecha-
nism for pairin g textua l XML ta gs a nd compiled objects. This specifi cat ion lan-guage is called XBL, a n XML a pplicat ion invented for Mozilla . XB L is a ssisted
by J ava Scr ipt , CSS, and other XML standa rds.
With the he lp of XBL, a new XML t ag th a t i s not ma nda t ed anywh ere
else can be defi ned. This ta g ca n be h ooked up t o processin g logic. The W3C
calls this logic an action , but it is bett er known by the Microsoft t erm behavior .
In Mozilla, such logic is created in t he form of a full object-oriented object defi -
nition. The connection betw een the new ta g a nd t he processing logic is called a
b ind ing. The object logic can be writ ten t o ta ke adva nta ge of any of the ser-
vices ava i lable to the pla t form, including a l l t he XPC OM objects a nd other
custom ta gs tha t possess their own bindings.
B ecause XB L a l lows n ew ta gs to be specified, Mozil la must be par t icu-
la r ly l ibera l w hen process ing con ten t . Any XML t a g migh t h ave mea n ing
defin ed somewhere. XBL con t r ibu t es to th e near-zero va l ida t ion a spect o f
Mozilla, discussed under the heading Consequences.
1.3.2 Innovations
The Mozilla P la tform does not reduce to a s et of objects a nd a set of XML sta n-
dar ds t icks. It also includes infrast ructure tha t holds together processing a nd
applications designed to exploit those objects and standards.
Some of this infra structure conta ins new a nd innovat ive ideas. Most of it
is required if application programs are to be created, installed, and operated
correctly.
1.3.2.1 Chrome and Toolkits The installation of a Mozilla application can bedivided into three par ts . One par t is a set o f fi les specifi c to the user of the
appl ica t ion , such as ema i l addresses a nd bookma rks . One par t i s a se t o f
binar y fi les conta ining t he executa ble programs of the pla t form, plus a few
confi gura t ion fi les. The fi na l par t is a set o f applica t ion fi les stored under a
d i rectory w i th t he name chrome. Chrome is a centr a l concept for Mozil la-
AppDevMozilla-01 Page 17 Thursday, December 4, 2003 6:22 PM
8/12/2019 RAD with Mozilla
19/40
18 Fundamental Concepts Chap. 1
ba sed a pplicat ions. An explora tion of the chrome directory is included in th e
Ha nds On session in this chapter.Inside the chrome directory there are many subdirector ies, da ta fi les,
document s, scripts, images a nd oth er content . Togeth er, the su m of th e chrome
cont ent, merely ca lled th e chrome, represents a set of resources. This set of
resources is responsible for a ll the user int erface element s presented by t he
applications installed in the platform. An application may exist entirely as a
set of files in t he chrome.
M o z i ll a r e f e r s t o fi l e s in t h e ch r o m e w i t h t h e sp e ci a l U RL sch e m e
chrome:. An exa mple of a chrome UR L is
chrome://notetaker/content/NoteTaker.xul
A chrome:U RL i s u su a l l y a sp e ci a l c a se of a resource: UR L. The
Mozil la-specific resource: URL scheme po in t s to the t op of th e p la t fo rm
insta llat ion area, so this URL is usua lly equivalent to the preceding URL :
resource://chrome/notetaker/content/NoteTaker.xul
B o t h resource: a n d chrome: U R L s r e p r e s e n t a s u b s e t o f a l l t h e
r e s ou r c e s t h a t c a n b e l oc a t e d u s i n g a file:U R L . Th e chrome : a n d
resource: URL schemes, however, are processed specially by the platform,
a n d a file:U RL cannot a lways be used as a subst i tute .
Genera l ly speaking , every th ing in the chrome d irec tory i s por t ab le .
Although there a re alw ays exceptions, an a pplication insta lled in the chrome
of Mozilla on Microsoft Windows sh ould have fi les nearly ident ical to the sa me
applica t ion inst a l led in chrome on U NIX or Macintosh. XUL documents a re
usually stored in the chrome.
Chrome is more than a desktop theme, since it can conta in both G UI ele-ment s a nd genera l application logic. It is more like a sophisticated X11 win dow
ma na ger such as the G NOME desktops S aw fi sh (used on Linux/UNI X), or a n
a dva nced theme engine on Microsoft Windows. Take t he example of Sa wfi sh.
Sa wfi sh can be confi gured using scr ipts wr i t t en in a program ming langua ge.
This typically results in the addition of buttons and decorations to a windows
t i t le ba r . Sawfi sh canno t rea ch ins ide the w indows i t decora t es ; i t can on ly
place decorations on the outside of those windows. Mozilla s chrome, on the
other ha nd, cannot rea ch outside th e edges of a w indow, but it can modify all
th e element s inside it . If Microsoft Word were implemented u sing Mozilla a nd
ra n on U NIX, Sa wfi sh could remove the stylized W from the t op left corner of
the title bar, but it couldnt change any of Words toolbars. Mozillas chrome, on
th e other ha nd, couldnt remove the st ylized W, but it could cha nge th e tool-
bars. Figure 1.3 shows a combinat ion of these G UI elements t ogether in a sin-gle window. The window contains Sawfish window decorations, Mozilla chrome
sta tus ba r a nd toolbars, and a simple HTML document.
S a w fi sh a d d s a f a n cy t i t l e b a r w i t h a t l ea s t f ou r b u t t o n s. F i le s in t h e
chrome add a t least two toolbars, a menu bar , a sta tus bar , and a collapsed
sidebar. The rest is HTML.
AppDevMozilla-01 Page 18 Thursday, December 4, 2003 6:22 PM
8/12/2019 RAD with Mozilla
20/40
1.3 Platform Concepts 19
The chrome also contains a special file named toolkit.jar. This fi le is
a n a rchive tha t conta ins a collection of commonly used fi les. The most im por-
ta nt th ing in this archive is a set of definitions that sta te which XUL t ags exist
an d w ha t t hey do. Since Mozil la applica t ions a re buil t out o f XUL, the pres-
ence and content o f th is fi le is of vi ta l in terest t o applica t ion progra mmers,
an d l i t t le can be done wit hout i t . This t oolkit is supplied w ith a l l complete
releases of the platform. It is undergoing minor change during the develop-
ment of the new Mozilla B rowser.
1.3.2.2 Themes, Skins, and Locales The Mozilla P lat form supports a themesystem tha t a llows t he appear an ce of an a pplicat ion to be varied an d a local-
ization system tha t a llows t he langua ge that an a pplicat ion is expressed in to
be varied. Both systems work inside the chrome directory.
Individual t hemes in the t heme system a re built out of skins. A skini s a
fi le specifying the nonstr uctura l as pects of a Mozilla win dow, such as colors,
fonts , and images. Skin fi les a re a subset o f the chrome tha t is a utomat ica l ly
selected by the current browser theme. Theme in the language of Mozilla
means All skins st ored un der th e na me of this t heme. Some Mozil la a dvo-cates are passionate about designing their skins. In the commercia l wor ld,
skins are a way to package and brand applications with corporate colors and
ma rks or to ma ke them fi t look-an d-feel or desktop integration sta nda rds.
Chrome URL s a re modifi ed by the current browser langua ge (the locale)
as w ell as by t he current t heme. This means t ha t supporting both a n En glish
Fig. 1.3 G NU/Linux Mozilla w ith S aw fi sh Window Ma na ger. Used by permission ofArlo Rose.
AppDevMozilla-01 Page 19 Thursday, December 4, 2003 6:22 PM
8/12/2019 RAD with Mozilla
21/40
20 Fundamental Concepts Chap. 1
an d a Russian B ack button is just a ma tter of having chrome fi les expressed in
both la nguages.
1.3.2.3 Data Sources and Content Sinks An innovative system used exten-sively inside the plat form is the P roducer an d C onsumer design pa ttern. This
pattern is normally seen inside object-oriented libraries and languages. The
Mozil la P la t form includes infrastr ucture support for a number of P roducer/
Consumer combinat ions, with special a t tent ion to ha ndling of RDF-style dat a.
The P roducer/Cons umer a pproach ded icat es pieces of code to supplyin g
da ta (i.e., P roducers, ca lled dat a sour ces in M ozilla ) and other pieces of code to
a bsorbing it (i.e., Consum ers, ca lled cont ent sin ks in Mozilla). This sepa ra tion
o f supply and demand a l lows in forma t ion to be pumped a round ins ide the
platform in a fl exible wa y.
RD F is one of th e more obscure W3C t echnologies, an d litt le more can be
sa id in this cha pter without sta rt ing a long discussion. Dat a sources an d sinksinside the platform give the programm er an opportun ity t o drive informat ion
ar ound an a pplicat ion using operations tha t a re not so different from dat aba se
operat ions. This in t urn a llows the plat form t o beha ve a lit t le like a 4G L t ool
used to build dat aba se client softwa re.
The most sophistica ted use of dat a sources a nd sin ks involves pooling up
RDF da ta for special processing. Inside the Mozilla B rowser, RDF sources a nd
sinks can be connected by intermediary processing that acts like a sophisti-
ca ted fi l ter. This fi l ter a l lows t he content in RD F da ta fl ows to be combined
and split . This is done after the data flow is sourced but before it is sunk. In
computer science terms, this is a simple knowledge processing syst em th at is
unusual for browser-like software.
1.3.2.4 Competitive Features In addition to good design, the Mozilla Platformseeks to provide a competit ive a lterna tive t o Microsofts I nt ernet Explorer. To
tha t end, it needs features th at give it a n edge over tha t Microsoft browser.
Mozillas ma in st rengt h is complia nce with W3C st a nda rds. The problem
is tha t s t an da rds compl iance is invis ib le to end userswhen th ings go a s
expected, there is nothing to note. So Mozilla also has fl ash y features t ha t can
compete in t he end-user ma rket. Some exam ples of th ese featur es follow:
Auto-completion of forms. Mozil la can remember wh at you typed inlast t ime.
Type-ahead find. You can reach a link or any content on a page by typ-ing text .
Quick launch. Moz i l la h as caches and op t ions tha t ma ke it s t a r t upfaster.
Image resizing. Mozilla proves size controls for images displayed bythemselves.
J unk email filtering. Mozilla ha s a fi ltering system to combat spam .
AppDevMozilla-01 Page 20 Thursday, December 4, 2003 6:22 PM
8/12/2019 RAD with Mozilla
22/40
1.3 Platform Concepts 21
The Mozilla engineering staff also maintains a set of performance objec-
tives for the product based on competitive benchmarks with Internet Explorera nd Opera. There are regula r initia tives designed solely to trim ineffi cient pro-
cessing from the platform, and from the browsers built upon it.
1.3.2.5 Remotely Sourced Applications The Mozil la P la t form conta ins tw o
meth ods of access to Mozilla-ba sed a pplica tions locat ed on a remote Web server.
The simpler of the two methods is the ability to download an application
an d run i t immedia tely. J ust a s a remote HTML document can be displayed
locally, giving the user the option of filling in and submitting a form, or click-
ing a link, so too can a remote XUL document be displayed locally, giving the
user the option of working with a forms- and menu-driven window that acts
like a locally inst alled program. This a spect of the platform is m ost similar to
th a t of Microsofts .NET initia tives.
The other met hod is to use t he plat forms XP Ins ta ll technology. This is aremote insta llat ion system th at downloads an ar chive from a remote Web site
an d inst a lls it in t he local chrome directory perma nently. A script guides the
insta llat ion process, and t he archive can conta in XUL-based a pplications an d
other files of any kind.
In both cases, the remote source applications have some security restric-
tions, although those restrictions can be lifted if the correct approach is taken.
1.3.3 Consequences
Finally, some aspects of the Mozilla Platform emerge from the sum of many
sma ll cha nges.
1.3.3.1 GUI Integration Mozilla is a display-oriented t ool, which is very dif-
ferent fr om other Open S ource tools like Apache. Apache just sits on a simple
network connection an d w ait s. Mozilla is intima tely connected to the user a nd
the users environment. It contains several strategies for working with GUIs
an d desktops.
At t he lowest level, Mozilla relies on G UI widgets from a suita ble native
toolkit for th e current plat form. This m ean s G TK on L inux, Win32 on Win-
dows, and t he Macintosh toolkit . A port of Mozilla tha t uses t he Qt w idget set
exists , but i t hasn t been mainta ined for a long t ime. There is no raw X11
implementation. The platform abstracts user input away from operating sys-
tem format s using the DOM 2 Events sta ndard.
At the desktop level , Mozil la r esponds normally to w indow opera t ions
such as focus, iconiza t ion, and exit opera t ions. I t is well behaved on U NIXunder most X11 window ma na gers. Recent versions of Mozilla support na tive
desktop themes in Windows XP and in GNOME 2.0. Mozilla supports content
se lec t ion a nd cu t n pas te to a degree, bu t th is must somet imes be ha nd-
implemented , and on ly happens au t omat ica l ly in t he most obvious ca ses .
Mozilla also supports multiformat clipboard copying. This means that some of
AppDevMozilla-01 Page 21 Thursday, December 4, 2003 6:22 PM
8/12/2019 RAD with Mozilla
23/40
22 Fundamental Concepts Chap. 1
th e forma tt ing in a piece of selected cont ent can be preserved wh en it is past ed
to another application, such as Microsoft Word. Mozilla supports drag-and-drop mouse operations w ithin t he context of the a pplication, but aga in, some
ha nd-implementa tion is r equired. Simia rly, objects can be dra gged from else-
where on the desktop to a Mozil la window Without hand-implementa t ion,
nothing w ill happen, and n o visual feedback will a ppea r. Most Mozilla-bas ed
a pplica tions include logic tha t s upports some dra g ndrop operat ions.
Fina l ly, a t the a pplica t ion level, one of Mozil la s grea t st rength s is i t s
XUL widget descr ipt ion la nguage, which a l lows G UI elements t o be brought
together in a very simple an d efficient wa y.
1.3.3.2 Portability Mozi l la runs on ma ny d i f fe ren t opera t ing sys tems a nddeskt ops. At www.mozi l la.org , th e Mozilla B rowser P lat form is test-compiled
every night , and the results are bundled into downloadable and insta l lable
fi les. At least the following operating systems ar e supported:
UNIX: Linux i386/P owerP C, FreeB SD , HP -U X, Solar is i386/S PARC , AIX,Irix
Mini computers: OpenVMS
Personal computers: Win dow s 95/98/Me /NT/XP, Ma cOS 9.x/X, O S /2,BeOS
There are also experimental ports to other platforms such as the Amiga.
Mozil la ha s w ell-esta blished support for t he G NU /Linux opera t ing syst em,
a nd G NU /Linux is w ide ly por ted i t se l f. I t i s probably feas ib le to por t the
Mozilla softwa re to most G NU/Linux ha rdwa re.
Mozillas portability extends beyond mere platform availability. Most fea-
tures supported a re intended to be ident ica l a cross pla t forms. In par t icular ,
the file types required to build a Mozilla application (XUL, CSS, DTD, proper-
t ies , J ava Scr ip t , RDF, et c . ) a re a l l en t i re ly por t a b le forma ts . In t heory, a
Mozi l la app l ica t ion should run on a l l opera t ing sys tems t ha t t he p la t fo rm
runs on, wit hout a porting cost . In pra ctice, minor differences mea n t ha t very
few a pplicat ions a re 100%porta ble without some testing an d occasiona l fi xes.
1.3.3.3 Near Zero Validation In the world of communications programming,
a fundamenta l design is this : Transmit st r ict ly according to standards, but
wh en receiving, accept an ything tha t it is possible to comprehend. This st ra t-
egy is designed to increas e stan dar ds usa ge in new syst ems without isolating
older systems.
The Mozil la P la t form is a commun icat ion device, f requent ly r eceivingWeb pages, email, and other messages. It follows a communication design and
that design is visible to a programmer. Except in the case of strict mode for
HTML, the platform interprets received XML and other documents very liber-
ally, ada pting to or ignoring m an y simple mista kes, omissions, and add it ions.
For a n end user l ike a Web sur fer, th is l ibera l interpreta t ion is a good
idea because irrita t ing error messages ar e kept to a minimum. For a progra m-
AppDevMozilla-01 Page 22 Thursday, December 4, 2003 6:22 PM
8/12/2019 RAD with Mozilla
24/40
1.4 The RAD Environment 23
mer, this l ibera l interpreta t ion is a bi t o f a nightma re. I t is very easy to add
information to a Mozilla application, only to have it silently ignored or silentlyrecorded. This s ilence could result if supplied ad ditions a re not im plemented,
contain typos, or are simply incorrect . As a programmer, an extra degree of
alertness is required when writing code for Mozilla.
Fortuna tely Mozilla does th e most ba sic of checks correctly: XML cont ent
must be well formed, and J ava Scr ipt a nd CS S code must a t least pa rse prop-
erly. Tha t is a beginning, but it is cold comfort for more adva nced ar eas w here
errors a re more obscure.
1.3.3.4 Extensibility A strength of Mozilla is tha t it is a platform, not just a
product. Alas, a wea kness is tha t it is only version 1 so far , and t he platform is
not a s fl exible or as complete a s one might h ope.
Never theless, i t is suffi cient ly fl exible tha t i t can be extended in ma ny
wa ys, from tr ivia l t o funda menta l . New objects can be ad ded, even XPC OM
objects ; new XML ta gs can be added; an d new themes or loca les or a pplica-
t ions can be a dded. There is no need t o register a nyth ing wit h some centra l
body or to fi t it in w ith someone elses logic.
B ecau se the platforms source code is ava ilable, a ny enha ncement a t a ll
is possible . Because Mozil la s chrome and XPCOM system are easy to use,
ma ny exper iments ca n be per formed w ith ease . Some exper iments a re done
within the Mozilla organization itself , like attempts to produce a
tag for XUL. Many other people experimenting with Mozilla extensions can be
found at www.mozdev.org .
1.3.3.5 Security Mozi l la suppor t s the secur i t y fea tures o f Netscape 4 .x ,
including the powerful Same Origin policy. That policy insists that insecureoperat ions, l ike w rit ing a fi le , be heavily rest r icted. An insecure opera t ion
retrieved from a given internet location (a URL) can be attempted only on a
resource tha t comes f rom t he sa me loca t ion . This res t r ic t ion a l lows J ava
applets to speak to their server of origin only. Similarly, it allows HTML or
XUL a pplicat ions to submit da ta to the Web server at wh ich th ey originated.
The most noteworthy aspect of security in the platform is that applica-
t ions ins t a l led in t he chrome ha ve no secur i t y r es t r ict ions a t a l l . Secur it y
restrictions imposed by the operating system still apply.
The plat form ha s severa l security models to pick from; they a re described
in Chapter 16, XPCOM Objects. The standard platform installat ion includes
support for most digita l encryption sta nda rds a nd certifi cate aut hority certifi-
cates.
1.4 THERAD ENVIRONMENT
Ha ving covered th e platform br iefly, lets look at the ra pid applicat ion develop-
ment (RAD) style of software development and see what it consists of.
AppDevMozilla-01 Page 23 Thursday, December 4, 2003 6:22 PM
8/12/2019 RAD with Mozilla
25/40
24 Fundamental Concepts Chap. 1
RAD projects hav e some unique char a cteristics. The prima ry cha ra cteris-
tic is just w ha t it sa ys: rapid a pplicat ion development. RAD projects ha ve fastdelivery of fi nished work as a primary goal.
The Mozil la P la t form i t self is not a RAD project . I t is a n Open Source
project , where peer review, innovation, and a rchitectura l stra tegy a re a t lea st
a s im p or t a n t a s f a s t d e l ive r y. F u r t h e r m o r e , t h e p l a t f or m ca n b e u se d in
embedded software projects, a topic not covered in this book. Embedded soft-
wa re has a s i t s ma in constra ints footpr int size , robustness, and low m aint e-
nance. Fast delivery is not a critical priority for embedded software either.
B ecaus e there are alt ernat ives, speedy development is not just a ma tt er
of adopting t he platform. It is both a mindset a nd a process. Here are some of
the essential characteristics of RAD projects.
1.4.1 Less Time, Same Effect
The quickest solution you can fi nd t ha t a chieves a desired end is probably t he
best solution. This is a n essentia l cha ra cterist ic of RAD projectsthere is no
a llegia nce to any rigid r ules. Wha tever does th e job fastest , w ins. Even if the
technique you chose isn t t ha t beaut i ful, isn t t ha t sophist ica t ed, and ma ybe
isnt even tha t fl exible, the fact tha t i t gets t he job done is essent ia l . I f your
labor can be polished up afterwa rd, tha t is a plus.
Dont a gonize for yea rs over the perfect design. Ma ke someth ing w ork.
1.4.2 Visual Prototypes
Hum an users a re the ult ima te challenge in softwa re development. They cant
be progra mmed relia bly, and t heir subjective processes go str a ight t hrough th estructured rules of sof tware . I t t akes t ime and many exper iments before a
user an d a user interface are ha ppy w ith each other. In th e acronym R AD, the
A for appl ication gua ra nt ees the need for fl exible user-interfa ce experiment s.
RAD projects need the a bility to creat e visual prototypes effi cient ly.
RAD projects are not based on the concept build it and they will come.
Flexible, cha ngea ble user demos are critical.
1.4.3 Vertical Solutions
RAD projects a re used to build products tha t have a na rrow purpose, wheth er
i t be a museum ca ta log or a stock a na lysis package. Those products ar e so-
called vertica l solutions. There is usua lly no need to ma ke the product so flexi-ble it can be applied to oth er uses. Tha t can be a la ter goal if th e product w orks
a s is. So w hy in sist on a low-level, generic tool, such a s C + + , Perl, or Tcl/Tk, as
the ba sis for a product tha t is a point solution? Use instea d a specialized tool
tha t fi ts t he problem spaceone tha t is suited to the ta sk wil l be more effi -
cient. Mozilla is specifically aimed at several vertical problem spaces.
AppDevMozilla-01 Page 24 Thursday, December 4, 2003 6:22 PM
8/12/2019 RAD with Mozilla
26/40
1.5 Effective RAD Projects with Mozilla 25
RAD projects can be built on a na rrow technology ba se. Very generic tools
ar ent a lway s better.
1.4.4 COTS Software Versus Home Grown
The not invented here arg ument of softwa re development, in wh ich progra m-
mers object to using other peoples software, is becoming harder and harder to
susta in . As t he to ta l a mount of code in t he world increas es, the chan ce tha t
your job has been done for you also increases. Using COTS (common-off-the-
sh e l f ) so ft w a r e i s a g o od t e ch n iq u e f or s a v in g t im e a n d e f f or t . I t g r e a t l y
reduces the amount of pure programming labor and gets you a result . Using
COTS s oftwa re ma kes perfect sense for RAD projects.
RAD pro ject s use o ther peoples w ork fi r s t an d bu i ld t h ings by ha nd
second.
1.4.5 Destructured Testing
The constraints of low-level programming languages like C are well known.
Pointer problems and strong typing make the use of a good compiler essential.
The a rgum ent goes tha t us ing t he compi la t ion phase w i l l save t ime la te r
beca use it is a r igorous process. Less hum an testin g will be needed if a com-
piler with a --pedanticoption is used.
If progra mmers ha ve a fi xed defect ra te per hour, this a rgument is proba-
bly correct , even if the la ngua ge is a scripting la ngua ge. This a rgument, how-
ever , assumes that a nontr ivia l program is being developed. In the case of
RAD, using a large existing tool (like Mozilla) means adding small program
fragments ra t her tha n big sta ndalone chunks of code. A small program frag-ment is easier to crea te correct ly a t the sta r t because i t conta ins few bra nch
points (few ifstatements). When program fragments reside in a larger tool,
the tool also acts a s a perma nent test h ar ness. Highly formal testing in such a
case ca n be overkill.
RAD destructures testing because many small code fragments are more
likely to be correct th a n one big progra m.
1.5 EFFECTIVERAD PROJECTSWITHMOZILLA
Mozilla might be an efficient development tool, but it also comes with a catch:
th ere is too much slow informa tion. Mozillas source code ta kes too much timet o u n d e r s t a n d . M oz i l l a s b u g d a t a b a se i s a j u n g le t o g et l o s t in , a n d t h e
mozilla .org Web site freely mixes new a nd old documenta tion w ithout r egard
for a ccura cy or a ge. Att empting to a bsorb all this ca n undermine t he reasons
for choosing Mozilla in th e fi rst pla ce. To keep the RAD benefi ts of Mozilla
intact, so that you can get something done, here are some recommendations.
AppDevMozilla-01 Page 25 Thursday, December 4, 2003 6:22 PM
8/12/2019 RAD with Mozilla
27/40
26 Fundamental Concepts Chap. 1
Most importa ntly, grab the documents listed in th e Ha nds On section in
th e intr oduction of th is book. Those document s, plus a decent book, ar e enoughdocumentation to get going. For a RAD project, it s rare to need a copy of the
Mozilla source code.
You will occasiona lly need to peek a t a pplica tion fi les in th e chrome to see
how other people solved a problem youve encountered. If you want to search
chrome files effectively, get one snapshot of the Mozilla source and index it
wit h a tool like UNIXs glimpseindex(1); or just ind ex a s et of una rchived
chrome files.
When building user int er faces wit h XUL , avoid per fect ion. I f you fi nd
yourself set t ing out windows to exact pixel measu rements, you a re doing i t
incorrectly. Do everything very roughly, and only ma ke fi ne a djustments a t the
very end. Dont fight the tool; use it the easy way. If, for example, you find that
you dont like t he tag, but theres nothing else appropriate, just make
d o w i t h a nywa y. Alwa ys d isp lay t he J ava Scr ip t conso le, bu t don twr ite a line of J ava Script code until your customer has seen th e XUL screens
youve creat ed.
When prototyping or experimenting, dont be too clever with XPCOM.
Most processing can be han dled just by subm itt ing a n H TML form t o a Web
server. Keep it ba s ic, and don t t r y t o mast er a l l t he XPC OM components .
Youll never use t hem a ll. If you ha ve no server, use th e execute()method to
run a separ at e program . Dont w orry about it being ugly, you can n eaten it up
later.
When s t uck on a t echn ica l problem, t r y n o t to become d is t r a c ted by
unhelpful deta il . Most problems are lit t le more tha n synt ax errors or misun-
dersta ndings. Everything in the plat form is interpreted from XML to CS S, and
synt a x errors creep in everywh ere. The source code w il l not help you w ith
theseit t akes a month of study before the source ma kes any s ense, anyw ay.
The Bugzilla bug dat aba se (at http://bugzilla.mozilla.org) can a lso be
very distra cting and t ime consuming.
A bett er a pproach t o problems is t o make a copy of your code a nd chop
bits off unt il the problem a rea is clear. Then look a t a book, or post t o a new s-
group. If th e problem wont go awa y, at lea st y ou have a n effective test case for
the B ugzilla da ta base, and someone might respond quickly if you lodge a bug.
If you cha nge your code slightly, it ma y w ell go aw a y. Becau se of th e platforms
near-zero validation behavior and poorly documented Mozilla internals, you
wont a lways have a deep reason whysome tr ivia l change ma de something
work a gain . Theres a lwa ys a ra t ional explana t ion, but i t o f ten ta kes a long
tim e to fin d. Move on.
I f , however, you ar e pass ionat e a bout Open Source, then dont expectworking on the Mozilla Platform itself to be a RAD project . Working on the
platform is the same a s working on a ny C or C+ + project . You can ma ke a dif-
ference month by m onth, not da y by da y. Unless you a re lucky enough t o get
paid for it, it s a very long-term hobby. Applications can be rapidly developed
with Mozilla, but the platform itself is not as easily developed.
AppDevMozilla-01 Page 26 Thursday, December 4, 2003 6:22 PM
8/12/2019 RAD with Mozilla
28/40
1.6 Hands On: Cranking Up the Platform 27
1.6 HANDSON: CRANKINGUPTHEPLATFORM
This Ha nds On session provides a fi rst explora tion of the Mozilla P lat -
form an d more steps tha t set u p the NoteTa ker project.
1.6.1 Installation
This book recommends dow nloading the 1.4 release of t he pla t form, which
includes Cla ssic Mozil la a nd th e pla t form. La ter releases ar e a lso probably
fi ne. You might w a nt t o checkwww.nigelmcfarlane.com for recent upda tes if
this book ha s been in print a wh ile.
The installat ion notes on mozilla .org are quite complete and should be
read for your plat form. They can be reviewed from th e offi cial download pages.
Some less obvious effects a re briefl y covered here.
On Wind ows 95/98/Me, your user pr ofi le wi ll be inst a lled in t his obscur elocation:
C:\Windows\Application Data\Mozilla
U nd er Wind ows N T/2000/XP techn ology, look in t he equ iva lent pa th for
th e current user. On UNI X, the profi le ca n be found h ere:
~/.mozilla
I t s recommended tha t y ou do two wh ole insta l la t ions of Mozil la , each
into a separa te directory. One wil l be your rel iable version; one w il l be for
development. On Windows a nd U NIX, if you ha ve only th e default us er profi le,
tha t profile w ill be sha red by both insta llat ions. Alterna tively, creat e a differ-
ent profile name for each installation. If you do this, disable email on the pro-
fi le for th e development ins ta llat ion, or confusion w ill result. Two inst a llat ionsgive you two sets of chrome, one of which you can experiment on, leaving the
other inta ct and w orking.
If you install Mozilla twice, or if you install two versions, be very careful
wh en runn ing th em together. You can t ell the differences between th em from
the da te in th e t i t le ba r (on Windows), bu t s t a r t ing one when t he o ther i s
a l r e a d y r u n n in g i s con f u s in g , e spe ci a l l y d u r in g t e s t in g . Th i s i s b e ca u s e
Mozilla uses a signaling mechanism. The version you started might signal a
running copy of Mozilla and then die straight away. That running copy then
opens a new w indow. It looks like you sta rt a new w indow a nd a n ew insta nce
of the pla t form, but you rea l ly just opened a nother w indow of the exist ing,
running p la t fo rm. I f y ou a re a ccustomed to v iewing Web pages w hi le you
develop, then th e cleanest w ay to do tha t on Windows is t o insta l l Internet
Explorer as w ell. Us e tha t for viewing documenta tion. On UN IX, it is easy t o
run separa te insta nces of the platformjust use the comma nd line.
This book a ssumes st a nda rd inst alla t ion directories. On Microsoft Win-
dows 95/98/Me, th e ins ta ll dir ectory is h ere:
C:\Program Files\Mozilla
AppDevMozilla-01 Page 27 Thursday, December 4, 2003 6:22 PM
8/12/2019 RAD with Mozilla
29/40
28 Fundamental Concepts Chap. 1
U nder UNI X, insta lling applicat ions into /usris overrat ed and ma kes subse-
quent version control tasks ha rder. Ask a ny sy stem a dministra tor. The insta l-lation directory is assumed to be here:
/local/install/mozilla
In both cases, Mozillas chrome is stored in a chromesubdirectory underneat h
th ese directories.
I f you do two U NIX ins t a l l a t ions , you need to review the ins t a l l a t ion
notes about setting the environment variable MOZILLA_FIVE_HOME. If you
wa nt t o run the program from a G NOME icon, read the insta llat ion notes. The
GNOME Panel is the bar across the bot tom of the desktop. You can drag a
new ly ma de icon from th e panel directly onto the desktop.
The following systems were used to test this book: Microsoft Windows
98SE with Int ernet Explorer 6.0 an d pat ches; Red Ha t G NU/Linux 7.2 with
G NOME 2.02. We also briefly tested w ith Microsoft Windows XP an d Ma cOS X.
1.6.2 Command Line Options
Co m m a n d -l in e h e lp f or t h e M o zi l l a B r o w se r i s a va i l a b le on U N I X u s in g
--help. On Microsoft Windows, -hor -helpwill display a h elp message but
only if Mozilla s output is sent t o a fi le. Ta ble 1.1 shows t he av a ilable options,
but not a ll are ava ilable on a ll plat forms.
1.6.3 Chrome Directories and the Address Book
The quickest wa y to see wha t Mozilla a pplica tion development is like is to see
something working. The Address Book of Classic Mozilla is an easy start ingpoin t . L ike many P ersona l In forma t ion Ma na gers (P IMs) , i t s jus t a se t o f
names and contact points, including email addresses. The address book is tied
to the C las sic Mail & Newsgroup client , from which it a utoma tically collects
new na mes . I t s da t a base of con ta c t s a l so a ss is t s the user when the Mai l &
Newsgroup client tries to auto-complete a partially typed-in address.
St ructura l ly, the a ddress book is a piece of th e Mail & News package.
That package is written entirely as a RAD client, using Mozillas chrome con-
cept . That means i t conta ins no C or C+ + , a l though i t makes heavy use of C/
C+ + XPC OM components. I t a lso means th a t you can customize and rew rite
th e interfa ce of the Cla ssic Mail & News client a s you see fi t. The interfa ce is
w rit t en in J av aS cript an d XUL, plus some complementa ry t echnologies. The
Classic Mail & News Client is stored in the chrome.
The chrome directory conta ins plain textfi les and J AR fi les. J AR sta ndsfor J av a Archive. It d erives from Su n Microsystems Ja va project. For Mozilla,
such fi les are in pla in ZIP format on Windows a nd U NIX. On Windows, i t s
convenient t o associa te t hese fi les wit h a tool like WinZip, or e lse the J ava
J VM will tr y t o execute t hem w hen t hey a re double-clicked. File associat ions
w ith WinZip are a litt le tricky. If double-clicking a J AR fi le zips it up a second
AppDevMozilla-01 Page 28 Thursday, December 4, 2003 6:22 PM
8/12/2019 RAD with Mozilla
30/40
1.6 Hands On: Cranking Up the Platform 29
t ime , then fi x tha t w i th t he WinZip Comma nd Line S uppor t Add-on f rom
www.winzip.com . In t he a bsence of the a dd-on, just use File | Open Archivet oinspect the J AR fi le. On UNIX, zip/unzipa re th e correct t ools, not gzip/
gunzip. On the Ma cintosh, StuffIt ! or a similar t ool is required.
Figure 1.4 shows a typical example of the chrome directory on Microsoft
Windows.
Table 1.1 Command-line option for Mozilla
Option name Mozilla starts with
-a ddressbook t he ema il a ddress book
-cha t t he IRC cha t client , if inst a lled
-compose fi eld1= va l1,fi eld2= val2,etc
the ema il message composer
-chrome U RL a chrome w indow, cont ent s a t U RL
-console a n addit iona l comma nd-line w indow tha t displa ys dia g-nostic messages an d th e output of dump()
-con ten t Loca le L a n or ma l w in dow bu t H TML con ten t loca le set t o L
-Crea teProfile PNAME a normal window, under a new p