File:  [mozdev] / books / www / chapters / ch00.html
Revision 1.21: download - view: text, annotated - select for diffs - revision graph
Fri Apr 4 16:27:40 2003 UTC (17 years, 2 months ago) by cdn
Branches: MAIN
CVS tags: HEAD

    1:     <link rel="next" href="" />
    3:     <style type="text/css">
    4:       div.c5 {font-weight: bold; text-align: center}
    5:     </style>
    7:     <h1><a name="77001"></a> Preface</h1>
    8:     <p>Mozilla is not just a web browser. It is also a framework
    9:     for building cross-platform applications using standards such
   10:     as Cascading Style Sheets (CSS), XML languages such as the
   11:     XML-based User-interface Language (XUL), eXtensible Binding
   12:     Language (XBL), and Resource Description Framework (RDF).</p>
   13:     <p>Gecko, Mozilla's rendering engine, is used as part of the
   14:     framework, along with other technologies such as XPConnect and
   15:     XPCOM, Mozilla's component model. The Mozilla development
   16:     framework also uses programming languages such as JavaScript,
   17:     C++, C, Python, and Interface Definition Language (IDL).</p>
   18:     <p>The Mozilla framework is used to create Netscape's
   19:     Mozilla-based browsers (Netscape 6.x and 7.x), other browsers
   20:     such as Galeon and Camino, and chat clients like ChatZilla and
   21:     JabberZilla. Developers also use Mozilla to create development
   22:     tools, browser enhancements, games, and other types of add-ons
   23:     and applications.</p>
   24:     <p>This book explains how applications are created with Mozilla
   25:     and provides step-by-step information that shows how to create
   26:     your own programs using Mozilla's powerful cross-platform
   27:     development framework. It also includes examples of different
   28:     existing applications to demonstrate the possibilities of
   29:     Mozilla development.</p>
   30:     <h2><a name="77002"></a> Mozilla Background</h2>
   31:     <p>When <!--INDEX Netscape --> Netscape Communications
   32:     Corporation was founded, it planned to create a better version
   33:     of NCSA's Mosaic browser, the first application that made
   34:     accessing the Internet possible for ordinary users. This new
   35:     application would be a Mosaic Killer. In time, the word
   36:     "Mozilla" became the shortened version of this phrase and the
   37:     code word for Netscape's browsers.</p>
   38:     <p>Mozilla has become more than a reference to one of
   39:     Netscape's products. On March 31, 1998, <i><a href=
   40:     ""></a></i> was
   41:     launched as the site where the development of Netscape's
   42:     next-generation Communicator 5.0 browser suite would take
   43:     place. At that point, Mozilla became an open source project and
   44:     began to take on a life of its own beyond its origins at
   45:     Netscape.</p>
   46:     <p>When <!--INDEX Netscape --> Netscape released its
   47:     Communicator code to the open source community, it did
   48:     something that was never done before: no other major software
   49:     company had given away the source code to a proprietary
   50:     product. At the time, many people in the software industry and
   51:     the press debated the wisdom of this decision.</p>
   52:     <p>Many other companies have followed Netscape's lead and
   53:     released their own products to the open source community. Sun
   54:     Microsystems sponsors several projects, including <i><a href=
   55:     ""></a></i>
   56:     and <i><a href=
   57:     ""></a></i>.
   58:     Apple also bases the core of its new operating system on an
   59:     open source project called Darwin, hosted at <i><a href=
   60:     ""></a></i>.</p>
   61:     <p>A year after the Mozilla source code was released, Mike
   62:     Homer, a senior executive at Netscape, made the following
   63:     comments: "Mozilla is larger than Netscape, and that was its
   64:     intention. Mozilla is essentially a collaborative project that
   65:     was sponsored by a commercial entity. Some of the people that
   66:     staff are Netscape employees, and the code that was
   67:     contributed was code previously owned by Netscape. However,
   68:     it's also true that the code base will take on a life of its
   69:     own someday."</p>
   70:     <p>Since the project's launch, many people outside Netscape
   71:     have joined the community, although many Netscape (now AOL)
   72:     employees still contribute to its advancement. The Mozilla
   73:     community is growing beyond the original home of
   74:     Other community resources worth examining include <i><a href=
   75:     ""></a></i>,
   76:     an advocacy and news site, and <i><a href=
   77:     ""></a></i>, a
   78:     project-hosting site for Mozilla applications.</p>
   79:     <p>Several companies, including IBM, Red Hat, ActiveState, and
   80:     Sun Microsystems have also contributed to the Mozilla
   81:     community. For instance, Red Hat has provided support for
   82:     Mozilla because it wants to help drive development of an open
   83:     source alternative to the closed source Netscape 4.x browser
   84:     suite that they had included in their Linux distribution. AOL
   85:     has also explored the use of Mozilla in its latest CompuServe
   86:     and AOL clients.</p>
   87:     <p>Because all Mozilla source code is made available to anyone
   88:     who is interested, the community benefits from an increase in
   89:     the number of suggestions, bug reports, patches, and new
   90:     developers. Along with the people who were involved with the
   91:     project when it was first released as open source, the new
   92:     people and companies that joined the community have helped
   93:     shape the direction and outcome of the Mozilla project.</p>
   94:     <h2><a name="77003"></a> The State of Mozilla</h2>
   95:     <p>Mozilla 1.0 was released on June 5, 2002, after more than
   96:     four years of development as an open source project. This book
   97:     was written so that all examples will work with this release
   98:     and any 1.0.x maintenance release.</p>
   99:     <p>After the 1.0 release, two main development branches of
  100:     Mozilla were created. The stable, long-lived 1.0 branch is
  101:     dedicated to fixing bugs in the code of the 1.0 release. From
  102:     this branch, periodic maintenance releases are labeled as
  103:     Version 1.0.x. Every 1.0.x release is designed to be fully
  104:     compatible with (though less buggy than) the original 1.0
  105:     release.</p>
  106:     <p>The other development branch is from the Mozilla CVS trunk.
  107:     New releases from this development effort are labeled as 1.x
  108:     and may include new features, changes to architecture, or other
  109:     additions that help Mozilla evolve as a project.</p>
  110:     <p>These new 1.x releases may not be fully compatible with
  111:     applications created to work with Mozilla 1.0 and the 1.0.x
  112:     releases, but made a commitment to preserve frozen
  113:     API compatibility (including XUL and XBL syntax) throughout the
  114:     1.x series until a future 2.0 release. See <i><a href=
  115:     ""></a></i>
  116:     for details.</p>
  117:     <p>Because Mozilla itself is under active development,
  118:     applications built on the framework may be affected when new
  119:     versions of Mozilla are released. We recommend that you refer
  120:     to's development road map for the latest
  121:     information about the state of Mozilla; see <i><a href=
  122:     ""></a></i>.</p>
  123:     <p>We also recommend that you use Mozilla 1.0.x versions when
  124:     working with examples in this book. We encourage you to use the
  125:     latest 1.x release as well so you can stay involved with the
  126:     latest and greatest that Mozilla has to offer.</p>
  127:     <h2><a name="77004"></a> Who Should Read This Book</h2>
  128:     <p>This book is primarily aimed at programmers (and would-be
  129:     programmers) interested in exploring this brand-new
  130:     platform-the Mozilla development framework. However, you do not
  131:     need to be a professional programmer to create your own
  132:     cross-platform Mozilla-based applications.</p>
  133:     <p>As shown in the coming chapters, all you need to get started
  134:     is a basic understanding of a few technologies that are already
  135:     familiar to most web developers: CSS, XML, and JavaScript. In
  136:     fact, this is one of the great advantages to developing a
  137:     Mozilla-based application: the learning curve isn't as steep as
  138:     most alternatives, such as C, C++, or even Java.</p>
  139:     <p>Your applications will be cross-platform automatically
  140:     (although you can create platform-specific applications as
  141:     well) and easily installable over the Internet by anyone
  142:     running Mozilla on their computer. What more could you ask for
  143:     in a development platform?</p>
  144:     <p>This book assumes that the reader has some level of
  145:     familiarity with JavaScript, CSS, HTML, and XML. Reading this
  146:     book in conjunction with other books that are devoted
  147:     specifically to these topics may be useful if you are not
  148:     already comfortable using these technologies. Some useful
  149:     O'Reilly &amp; Associates titles include <i>JavaScript: The
  150:     Definitive Guide</i>, <i>Cascading Style Sheets: The Definitive
  151:     Guide</i>, <i>HTML &amp; DHTML: The Definitive Guide</i>,
  152:     <i>Learning XML</i>, and <i>XML in a Nutshell, Second
  153:     Edition</i>. Concepts and technologies that are new to Mozilla
  154:     or used with Mozilla in a new way are explained in detail
  155:     throughout the book.</p>
  156:     <p>This book also assumes that the reader has access to a
  157:     computer with Mozilla 1.0 or later installed on it, plus any
  158:     text editor or word processor. Mozilla runs on almost any type
  159:     of personal computer available today, so finding a compatible
  160:     platform shouldn't be difficult. The full system requirements
  161:     for any Mozilla release can be found on the
  162:     site.</p>
  163:     <h2><a name="77005"></a> Platform and Applications</h2>
  164:     <p>Some developers work on Mozilla to improve the way it
  165:     functions and other developers use Mozilla to create new
  166:     applications. These two approaches reflect the dual nature of
  167:     Mozilla as a development project and a framework for creating
  168:     applications, but the line between the two isn't always
  169:     clear.</p>
  170:     <p>People often start developing an application with Mozilla
  171:     and then notice a way to make Mozilla itself work better, which
  172:     will in turn make their application work better. In these
  173:     cases, the developer works on both Mozilla applications and the
  174:     Mozilla development framework that provides the plumbing those
  175:     applications run on top of.</p>
  176:     <p>This distinction between platform and applications is
  177:     important. This book provides in-depth information about
  178:     application development using Mozilla, but it does not directly
  179:     describe anything relating to the development of Mozilla
  180:     itself.</p>
  181:     <p>If you are interested in learning how to become a Mozilla
  182:     developer (and actually hacking the code), we can suggest a
  183:     couple of starting points. <i>Getting Your Work Into
  184:     Mozilla</i> is an article written by two authors who chronicled
  185:     their own experiences about becoming a part of the Mozilla
  186:     community, and is available at <i><a href=
  187:     ""></a></i>.
  188:     There is also great information about getting started with
  189:     development on Mozilla from the site at <i><a href=
  190:     ""></a></i>.</p>
  191:     <h2><a name="77006"></a> Structure of the Book</h2>
  192:     <p>This book is structured so you can create and distribute a
  193:     simple Mozilla application after reading through <a href=
  194:     "ch06.html#77063">Chapter 6</a>. You should read Chapters 1-6
  195:     in order and work through the examples. The later chapters
  196:     provide information about advanced aspects of application
  197:     development that allow you to take full advantage of what
  198:     Mozilla has to offer. If you wish, you can read Chapters 7-12
  199:     out of order, depending on your needs and interests.</p>
  200:     <p><a href="ch01.html#77011">Chapter 1, <i>Mozilla as
  201:     Platform</i></a>, provides an introduction to Mozilla and its
  202:     advantages as a development framework. Conceptually, the
  203:     chapter gives you a thorough understanding of how JavaScript,
  204:     CSS, and XUL are used to create cross-platform
  205:     applications.</p>
  206:     <p><a href="ch02.html#77048">Chapter 2, <i>Getting
  207:     Started</i></a>, goes into the initial technical details about
  208:     creating Mozilla applications. Two "Hello World" examples are
  209:     presented to show you how to build an application shell.</p>
  210:     <p><a href="ch03.html#77084">Chapter 3, <i>XUL Elements and
  211:     Features</i></a>, introduces the XML-based User-interface
  212:     Language, shows you how to create custom XUL documents, and
  213:     explains how to use the XUL tag set to build out your
  214:     application shell.</p>
  215:     <p><a href="ch04.html#77060">Chapter 4, <i>CSS in Mozilla
  216:     Applications</i></a>, shows how Cascading Style Sheets are used
  217:     to create the look and feel of an application and how custom
  218:     CSS files work together with XUL files in your application
  219:     shell.</p>
  220:     <p><a href="ch05.html#77037">Chapter 5, <i>Scripting
  221:     Mozilla</i></a>, describes how to add functionality to your
  222:     application by using JavaScript and how custom JS files added
  223:     to your application shell interact with existing XUL and CSS
  224:     files.</p>
  225:     <p><a href="ch06.html#77063">Chapter 6, <i>Packaging and
  226:     Installing Applications</i></a>, explains how to package an
  227:     application so it can be installed on different computers. Once
  228:     you create your custom XUL, CSS, and JS files, you can package
  229:     and distribute them to users as your Mozilla application after
  230:     reading this chapter.</p>
  231:     <p><a href="ch07.html#77027">Chapter 7, <i>Extending the UI
  232:     with XBL</i></a>, is the first of the more advanced chapters
  233:     that show you how to extend the basic application framework
  234:     described in Chapters 1-6. This chapter explains how to use the
  235:     eXtensible Binding Language to create reusable widgets that
  236:     will help organize a complicated application.</p>
  237:     <p><a href="ch08.html#77048">Chapter 8, <i>XPCOM</i></a>,
  238:     examines Mozilla's cross-platform component object model. After
  239:     reading this chapter, you should be able to find and use
  240:     existing scriptable components in your own application and
  241:     create a simple XPCOM component using JavaScript or C++.</p>
  242:     <p><a href="ch09.html#77034">Chapter 9, <i>XUL
  243:     Templates</i></a>, explains how to include dynamic information
  244:     in your application that can be updated from a database, user
  245:     input, or other sources. XUL templates rely on RDF, but it is
  246:     not necessary to fully understand RDF to be able to use XUL
  247:     templates.</p>
  248:     <p><a href="ch10.html#77061">Chapter 10, <i>RDF, RDF Tools, and
  249:     the Content Model</i></a>, looks more closely at how Mozilla
  250:     configures and uses datasources with the Resource Description
  251:     Framework. RDF is used in XUL templates, but it is also used
  252:     throughout Mozilla and Mozilla applications. Although it is
  253:     considered to be one of the most difficult technologies to
  254:     learn and use, RDF is worth the effort.</p>
  255:     <p><a href="ch11.html#77028">Chapter 11,
  256:     <i>Localization</i></a>, shows how to make your application
  257:     more accessible by localizing it into any number of different
  258:     languages. This chapter shows you how to use Document Type
  259:     Definitions and string bundles to provide translations of your
  260:     application's interface and other content, such as the Help
  261:     documents you may provide in your application.</p>
  262:     <p><a href="ch12.html#77066">Chapter 12, <i>Remote
  263:     Applications</i></a>, explores an alternate distribution method
  264:     that has several advantages over the direct installation method
  265:     discussed in <a href="ch06.html#77063">Chapter 6</a>. By
  266:     serving your application from a server, you may be able to add
  267:     extra features that wouldn't be possible otherwise.</p>
  268:     <p>The book's three appendixes contain supplemental information
  269:     not directly applicable to any of the different chapters. <a
  270:     href="appa.html#90096">Appendix A, <i>Getting and Building the
  271:     Mozilla Source</i></a>, explains how to start using the Mozilla
  272:     source code. <a href="appb.html#77021">Appendix B,
  273:     <i>Development Tools</i></a>, describes projects that will
  274:     assist you with your application development. <a href=
  275:     "appc.html#77003">Appendix C, <i>Programmer's
  276:     Reference</i></a>, provides a convenient reference useful for
  277:     quickly locating specific XUL and XBL elements and event
  278:     attributes.</p>
  279:     <p>This book was written so that a reader who does not want to
  280:     read about each aspect of application creation can read just
  281:     the chapters that interest them and still get useful
  282:     information. For instance, a graphic designer can read the
  283:     chapters about XUL and CSS and learn how to create an
  284:     application interface to which a programmer can then add
  285:     functionality.</p>
  286:     <h2><a name="77007"></a> How This Book Was Written</h2>
  287:     <p>This book was created as a collaborative project hosted at
  288:     <i><a href=
  289:     ""></a></i>. The
  290:     authors of the book have become aware of the benefits of
  291:     creating a project in an open source method while working
  292:     within the Mozilla community and wanted to extend these
  293:     benefits to the creation of the book itself.</p>
  294:     <p>The content of this book was released under the Open
  295:     Publication License (OPL) and is available at the site
  296:     mentioned in the previous paragraph and at <i><a href=
  297:     ""></a></i>.
  298:     Anyone interested in contributing to the further development of
  299:     this book is encouraged to visit the site; they can help us
  300:     make sure that this book lives on as an active document that
  301:     will continue to be useful to the Mozilla community.</p>
  302:     <p>The examples used throughout the book contain code fragments
  303:     that were created specifically as examples to highlight the use
  304:     of a particular aspect of Mozilla application development.
  305:     Several existing Mozilla applications are also used as examples
  306:     and more information about each is provided in the chapters
  307:     where they are used. All numbered examples in the book can be
  308:     found online at <i><a href=
  309:     ""></a></i>
  310:     and <i><a href=
  311:     ""></a></i>.</p>
  312:     <h2><a name="77008"></a> Mozilla Licensing Information</h2>
  313:     <p>The Mozilla source code is all publicly available and
  314:     released under several different licenses. The details of
  315:     Mozilla's licensing scheme aren't discussed here, but we
  316:     provide information and pointers to where additional
  317:     information can be found.</p>
  318:     <p>Several licenses are used in conjunction with the Mozilla
  319:     source code, including the 
  320:     <!--INDEX Mozilla Public License (MPL);MPL (Mozilla Public License) -->
  321:     Mozilla Public License (MPL), Netscape Public License (NPL),
  322:     GNU General Public License (GPL), and the GNU Lesser General
  323:     Public License (LGPL). This wide selection of licenses was
  324:     chosen to make the source available to as large a group of
  325:     developers as possible.</p>
  326:     <p>Any code that is checked into the Mozilla source code tree
  327:     needs to comply with's licensing policy. Because
  328:     Mozilla applications can be created and stored anywhere,
  329:     however, there are many different options for how to license
  330:     and distribute a Mozilla-based application. One option is to
  331:     sell your application with or without making all of the source
  332:     available.</p>
  333:     <p>For more information about Mozilla's licensing scheme and
  334:     the license options available to Mozilla applications, visit
  335:'s license page at <i><a href=
  336:     ""></a></i>.
  337:     Questions about licensing issues can also be answered by
  338:     posting to the license newsgroup
  339:     <i>netscape.public.mozilla.license</i> or the license mailing
  340:     list <i><a href=
  341:     ""></a></i>.</p>
  342:     <h2><a name="77009"></a> Conventions</h2>
  343:     <p>The following conventions are used in this book:</p>
  344:     <p><tt>Constant Width</tt> is used for:</p>
  345:     <ul>
  346:       <li>Code examples and fragments</li>
  347:       <li>Anything that might appear in an HTML document, including
  348:       element names, tags, attribute values, entity references, and
  349:       processing instructions</li>
  350:       <li>Anything that might appear in a program, including
  351:       keywords, operators, method names, class names, commands, and
  352:       literals</li>
  353:     </ul>
  354:     <p>Constant-Width Bold is used for:</p>
  355:     <ul>
  356:       <li>User input in code examples</li>
  357:       <li>To highlight certain code in examples</li>
  358:     </ul>
  359:     <p><i>Italics</i> is used for:</p>
  360:     <ul>
  361:       <li>New terms where they are defined</li>
  362:       <li>Host and domain names (<i><a href=
  363:       ""></a></i>)</li>
  364:       <li>URLs (<i><a href=
  365:       ""></a></i>)</li>
  366:       <li>Interface names and variable names</li>
  367:     </ul>
  368:     <p><tt><i>Constant Width Italic</i></tt> is used for
  369:     replaceable items, such as variables or optional elements,
  370:     within syntax lines of code.</p>
  371:     <p>You should pay special attention to notes set apart from the
  372:     text with the following icons:</p>
  373:     <blockquote>
  374:       <div class="c5">
  375:         NOTE
  376:       </div>
  377:       <p>This is a tip, suggestion, or a general note. It contains
  378:       useful supplementary information about the topic at hand.</p>
  379:       <div class="c5">
  380:         WARNING
  381:       </div>
  382:       <p>This indicates a warning or caution. It will help you
  383:       solve and avoid annoying problems.</p>
  384:     </blockquote>
  385:     <p>Significant code fragments, complete programs, and documents
  386:     are generally placed into a separate paragraph like this:</p>
  387: <pre>
  388: &lt;?xml version="1.0"?&gt;
  389: &lt;!DOCTYPE window&gt;
  390: &lt;window
  391: xmlns:html="<a href=
  392: ""></a>"
  393: xmlns="<a href=
  394: ""></a>"&gt;
  395: &lt;/window&gt;
  396: </pre>
  397:     <h2><a name="77010"></a> Comments and Questions</h2>
  398:     <p>Please address comments and questions concerning this book
  399:     to the publisher:</p>
  400:     <blockquote>
  401:       O'Reilly &amp; Associates, Inc. 1005 Gravenstein Highway
  402:       North Sebastopol, CA 95472 1-800-998-9938 (in the United
  403:       States or Canada) 1-707-829-0515 (international/local)
  404:       1-707-829-0104 (fax)
  405:     </blockquote>
  406:     <p>There is a web page for this book, which lists errata,
  407:     examples, or any additional information. You can access this
  408:     page at:</p>
  409:     <blockquote>
  410:       <a href=
  411:       ""></a>
  412:     </blockquote>
  413:     <p>To comment or ask technical questions about this book, send
  414:     email to:</p>
  415:     <blockquote>
  416:       <a href=
  417:       ""></a>
  418:     </blockquote>
  419:     <p>For more information about books, conferences, Resource
  420:     Centers, and the O'Reilly Network, see the O'Reilly web
  421:     site:</p>
  422:     <blockquote>
  423:       <a href=""></a>
  424:     </blockquote>
  425:     <h2><a name="77011"></a> Acknowledgments</h2>
  426:     <p>This book was made possible by the help and contributions of
  427:     many different people. Laurie Petrycki and Paula Ferguson are
  428:     the editors at O'Reilly who helped create and shape this book.
  429:     Their guidance and feedback has been crucial throughout this
  430:     entire process. We would also like to thank Ann Schirmer, Mary
  431:     Brady, Betsy Waliszewski, and David Chu at O'Reilly for their
  432:     work on helping to create and promote this book.</p>
  433:     <p>Many other people have contributed their suggestions, ideas,
  434:     and feedback, including Martin Kutschker, Andreas Otte, Andy
  435:     Edmonds, Mike Potter, Chris Waterson, Mark Murphy, Pavol
  436:     Vaskovic, Andrew Wooldridge, Doug Turner, Tao Cheng, Michael
  437:     Ang, Neil Rashbrook, Rob Ginda, Steve Rudman, Kathleen Brade,
  438:     Zach Lipton, Cameron Barrett, Chiko Chow, Jan Varga, Axel
  439:     Hecht, David Ascher, Michael Gannon, David McNamara, and Mark
  440:     Hammond.</p>
  441:     <p>Several Mozilla application developers have allowed us to
  442:     use their projects in the book as examples. We would like to
  443:     thank Rob Ginda for allowing us to feature his IRC client
  444:     ChatZilla, his JavaScript Debugger Venkman and his XULKit
  445:     development tools, David Gillen for his Snake game, Neil
  446:     Rashbrook for his XULMine game, Andy Edmonds and Pavol Vaskovic
  447:     for the Optimoz and Mouse Gestures projects, Henrik Lynggaard
  448:     for MozillaTranslator, David Hyatt and Mike Pinkerton for the
  449:     Camino browser, and Gervase Markham for letting us reference
  450:     Patch Maker.</p>
  451:     <p>We would like to thank Joshua Lerner, who helped with the
  452:     creation of the book's original plans and also helped as a
  453:     reviewer (Joshua and Kerry Fitzpatrick also let a couple of
  454:     their employees at Alphanumerica work on Mozilla projects
  455:     during their day job and funded the first Mozilla Developer
  456:     Conference). We would like to thank Julia Kleyman for creating
  457:     several of the illustrations used throughout the book,
  458:     including the xFly logo (not to mention the FruityGum skin).
  459:     Thanks also to Eoin Campbell for supporting Mozilla developers
  460:     and having the vision to use Mozilla for application
  461:     development from its very early days.</p>
  462:     <p>We would also like to thank the people who have supported us
  463:     during the time this book was written, including Kim Steckler,
  464:     Rachel Oeschger, and Priscilla, Dylan, and Devon Collins.</p>
  465:     <hr>
  466:     <br>
  467:     <br>
  468:     File a <a href=
  469:     "">Bug</a>
  470:     for the preface. 
  471:     <?php $hide_text_control=1; $post_to_list=NO; $author=''; // require(NOTES); ?>

FreeBSD-CVSweb <>