Programming Firefox

Book description

This is your guide to building Internet applications and user interfaces with the Mozilla component framework, which is best known for the Firefox web browser and Thunderbird email client. Programming Firefox demonstrates how to use the XML User Interface Language (XUL) with open source tools in the framework's Cross-Platform Component (XPCOM) library to develop a variety of projects, such as commercial web applications and Firefox extensions.

This book serves as both a programmer's reference and an in-depth tutorial, so not only do you get a comprehensive look at XUL's capabilities--from simple interface design to complex, multitier applications with real-time operations--but you also learn how to build a complete working application with XUL. If you're coming from a Java or .NET environment, you'll be amazed at how quickly large-scale applications can be constructed with XPCOM and XUL.

Topics in Programming Firefox include:

  • An overview of Firefox technology
  • An introduction to the graphical elements that compose a XUL application
  • Firefox development tools and the process used to design and build applications
  • Managing an application with multiple content areas
  • Introduction to Resource Description Files, and how the Firefox interface renders RDF
  • Manipulating XHTML with JavaScript
  • Displaying documents using the Scalable Vector Graphics standard and HTML Canvas
  • The XML Binding Language and interface overlays to extend Firefox
  • Implementing the next-generation forms interface through XForms
Programming Firefox is ideal for the designer or developer charged with delivering innovative standards-based Internet applications, whether they're web server applications or Internet-enabled desktop applications. It's not just a how-to book, but a what-if exploration that encourages you to push the envelope of the Internet experience.

Publisher resources

View/Submit Errata

Table of contents

  1. A Note Regarding Supplemental Files
  2. Preface
    1. Intended Audience
    2. Why Buy This Book?
    3. Conventions Used in This Book
    4. Terms and Usage
      1. A Tag or an Element?
    5. How This Book Is Organized
      1. Demonstration Platforms
    6. Using Code Examples
    7. Comments and Questions
    8. Safari® Enabled
    9. Acknowledgments
  3. 1. Firefox and Friends
    1. 1.1. Mozilla to Firefox and Thunderbird
    2. 1.2. XML Technologies
      1. 1.2.1. XML History
      2. 1.2.2. XSLT and XPath
      3. 1.2.3. RDF
      4. 1.2.4. CSS
    3. 1.3. At the Top of It All: The DOM
    4. 1.4. Mixing Document Types
    5. 1.5. Getting Started
      1. 1.5.1. Supporting Tools
        1. 1.5.1.1. Apache web server
        2. 1.5.1.2. PHP
        3. 1.5.1.3. MySQL
      2. 1.5.2. Getting the Browser
  4. 2. XUL Basics
    1. 2.1. File Structure
    2. 2.2. XUL Widgets
      1. 2.2.1. Boxes
      2. 2.2.2. Adding Styling
      3. 2.2.3. Box Sizes
      4. 2.2.4. The Flex, Pack, and Align Attributes
        1. 2.2.4.1. Flex
        2. 2.2.4.2. Pack
        3. 2.2.4.3. Align
    3. 2.3. Introducing Input Controls
      1. 2.3.1. Labels and Buttons
      2. 2.3.2. Text Entry
      3. 2.3.3. Menus and Toolboxes
    4. 2.4. More Complex Containers
      1. 2.4.1. Lists
      2. 2.4.2. Trees
      3. 2.4.3. Grids
      4. 2.4.4. Group Boxes
    5. 2.5. Managing the Display Space
      1. 2.5.1. Tab Boxes
      2. 2.5.2. Splitters
    6. 2.6. Content Display Panels
    7. 2.7. Miscellaneous Widgets
    8. 2.8. Helper Features
    9. 2.9. Mozilla Style Declarations
      1. 2.9.1. Pseudoproperties
      2. 2.9.2. Pseudoclasses
    10. 2.10. Summary
  5. 3. Coding and Testing for the Real World
    1. 3.1. Defining a Target Application
    2. 3.2. Adding Logic
      1. 3.2.1. JavaScript, Events, and DOM Nodes
      2. 3.2.2. The Document Object Model
        1. 3.2.2.1. Interfaces
        2. 3.2.2.2. Moving from widgets to document nodes
      3. 3.2.3. Events
        1. 3.2.3.1. Inline event handlers
        2. 3.2.3.2. Dynamic assignment of attributes
        3. 3.2.3.3. Dynamic addition of event listeners
        4. 3.2.3.4. External script files
        5. 3.2.3.5. The event parameter
      4. 3.2.4. Modifying Node Contents
    3. 3.3. Simple Authentication Script
      1. 3.3.1. XUL Input Widgets
        1. 3.3.1.1. Modifying node styles
        2. 3.3.1.2. Removing and adding document nodes
    4. 3.4. When Things Don’t Work
      1. 3.4.1. Looking for the Obvious: Bad Typing
        1. 3.4.1.1. The JavaScript console
      2. 3.4.2. Programming and Design Errors
        1. 3.4.2.1. The console dump( ) command
        2. 3.4.2.2. The Venkman debugger
        3. 3.4.2.3. The DOM Inspector
    5. 3.5. Summary
  6. 4. Configuring for Chrome and a Server
    1. 4.1. Chrome Overview
    2. 4.2. Running as a Local Installation
      1. 4.2.1. Chrome Directory Structure
      2. 4.2.2. Package Registration
    3. 4.3. XUL-to-Server Communications
      1. 4.3.1. Configuring the Server
      2. 4.3.2. The Client/Server Protocol
        1. 4.3.2.1. The client-side request
        2. 4.3.2.2. The server-side response
      3. 4.3.3. When Things Go Wrong
      4. 4.3.4. Adding a Database
        1. 4.3.4.1. Creating the database
        2. 4.3.4.2. Creating account tables
        3. 4.3.4.3. Creating database user accounts
        4. 4.3.4.4. Connecting PHP to MySQL
        5. 4.3.4.5. Calling the MySQLi API
      5. 4.3.5. When Things Go Wrong
    4. 4.4. Serving XUL Files
      1. 4.4.1. Creating a XUL File to Be Served
      2. 4.4.2. Configuring the Server
      3. 4.4.3. PHP Serving XUL
        1. 4.4.3.1. Using PHP require( )
        2. 4.4.3.2. PHP serving XUL files
        3. 4.4.3.3. Logic changes
    5. 4.5. Summary
  7. 5. Multiframe XUL
    1. 5.1. Dividing the Display Area
    2. 5.2. Editing Documents
      1. 5.2.1. HTML Documents, Windows, and iframes
      2. 5.2.2. XUL Documents, Windows, and iframes
      3. 5.2.3. XUL Windows and Content Type
      4. 5.2.4. Other Content Panels
        1. 5.2.4.1. <editor>
        2. 5.2.4.2. <browser>
      5. 5.2.5. Dealing with Events
        1. 5.2.5.1. Event phases
      6. 5.2.6. Synchronizing Interface Widgets and Frames
        1. 5.2.6.1. Adding state transitions
        2. 5.2.6.2. An event handler too many
        3. 5.2.6.3. Event generation: XUL events and HTML events
        4. 5.2.6.4. Responding to the “right” event target
        5. 5.2.6.5. Managing events in iframes
      7. 5.2.7. Adding Pull-Down Menus
        1. 5.2.7.1. Operating system caveats
    3. 5.3. Adding Dialog Windows
    4. 5.4. Summary
  8. 6. Trees, Templates, and Datasources
    1. 6.1. Trees
      1. 6.1.1. Tree Structure
      2. 6.1.2. Different Types of Tree Content
      3. 6.1.3. Selecting Tree Items
      4. 6.1.4. Multiple Selections
        1. 6.1.4.1. Parsing ranges
      5. 6.1.5. Templates and RDF (Simple View)
        1. 6.1.5.1. RDF tags and attributes
        2. 6.1.5.2. Templates (simple form)
        3. 6.1.5.3. Hierarchical output
        4. 6.1.5.4. Adding rules
      6. 6.1.6. More Complex Templates
        1. 6.1.6.1. Formal RDF terminology
          1. 6.1.6.1.1. Conditions
          2. 6.1.6.1.2. Actions
      7. 6.1.7. Using Templates for Conditional Processing
        1. 6.1.7.1. IDs and URIs
        2. 6.1.7.2. Template forms: Summary
    2. 6.2. Modifying Datasources
      1. 6.2.1. RDF Statements: A Closer Look
      2. 6.2.2. RDF Interfaces and Services
      3. 6.2.3. RDF Datasource Details
        1. 6.2.3.1. Accessing datasources
        2. 6.2.3.2. Modifying datasources: Creating and removing RDF statements
        3. 6.2.3.3. Modifying containers
        4. 6.2.3.4. Removing resources and containers
      4. 6.2.4. Moving to Code
        1. 6.2.4.1. Adding dialogs
      5. 6.2.5. Tying Everything Together
    3. 6.3. Summary
  9. 7. DOM Manipulation and Input/Output
    1. 7.1. A Design Review
    2. 7.2. Browser Elements
      1. 7.2.1. Properties and Native Wrappers
      2. 7.2.2. Selection and Range Objects
      3. 7.2.3. Manipulating Selections and Ranges
    3. 7.3. Moving Text Between Frames
    4. 7.4. Exporting Note Document Content
      1. 7.4.1. File Services
        1. 7.4.1.1. Selecting a destination file
        2. 7.4.1.2. Writing document content to a file
        3. 7.4.1.3. Reading document content from a file
      2. 7.4.2. Emailing Note Document Contents
        1. 7.4.2.1. Mixing XUL and HTML
        2. 7.4.2.2. Synthesizing DOM events
        3. 7.4.2.3. Clearing content
    5. 7.5. Adding Interactivity to DOM Elements
    6. 7.6. Summary
  10. 8. Graphics
    1. 8.1. A Sample Graphing Project
    2. 8.2. XHTML Review
      1. 8.2.1. Combining XHTML and SVG Namespaces
        1. 8.2.1.1. File type and content type
        2. 8.2.1.2. DOCTYPE and validation
    3. 8.3. SVG Overview
      1. 8.3.1. SVG Drawing
      2. 8.3.2. Appearance Properties
      3. 8.3.3. Graphical Elements
      4. 8.3.4. Transform, Translate, and Scale
    4. 8.4. Data-to-Graphics Transformation
      1. 8.4.1. Using XSLT
        1. 8.4.1.1. The source document
        2. 8.4.1.2. A transformation stylesheet
        3. 8.4.1.3. The resulting XHTML file
      2. 8.4.2. Style Information
      3. 8.4.3. Adding Interactivity
    5. 8.5. HTML Canvas
      1. 8.5.1. Canvas Drawing
        1. 8.5.1.1. Program algorithm
        2. 8.5.1.2. Text
      2. 8.5.2. Program Code
    6. 8.6. Summary
  11. 9. Extending the Interface
    1. 9.1. Overlay Files
      1. 9.1.1. Overlay File Structure
        1. 9.1.1.1. Element positioning
        2. 9.1.1.2. Dynamic loading
      2. 9.1.2. Overlays and the Browser
    2. 9.2. Adding Logic
    3. 9.3. XBL
      1. 9.3.1. XBL Structure
      2. 9.3.2. XBL Content
        1. 9.3.2.1. Passing attributes to XBL content
      3. 9.3.3. Implementation
        1. 9.3.3.1. Anonymous content
      4. 9.3.4. Event Handlers
      5. 9.3.5. An Expanded Example
    4. 9.4. HTTP Request Widget
      1. 9.4.1. Extending Bindings
    5. 9.5. Summary
  12. 10. XForms
    1. 10.1. Basic XForms Structure
    2. 10.2. An Example Transfer to the Server
      1. 10.2.1. The Stylesheet
      2. 10.2.2. The Server Script
      3. 10.2.3. An Overview of an XForms Document
      4. 10.2.4. XForms Controls
    3. 10.3. XForms Validation Features
      1. 10.3.1. Pseudoclasses and Conditional Styling
        1. 10.3.1.1. Pseudoclasses
        2. 10.3.1.2. Required entries
        3. 10.3.1.3. Data validation
      2. 10.3.2. Beyond Styling: Manipulating Content and Structure
        1. 10.3.2.1. Calculating field values
        2. 10.3.2.2. Relevant and conditional appearance
      3. 10.3.3. User Interface Elements
      4. 10.3.4. Repeating Interface Markup
    4. 10.4. XForms Events and Actions
      1. 10.4.1. XML Events
      2. 10.4.2. XForms Actions
    5. 10.5. User Interaction and Dynamic Presentation
      1. 10.5.1. Dynamic Insertion and Removal of Entries
      2. 10.5.2. Changes in Form Structure
    6. 10.6. What to Do When Things Go Wrong
    7. 10.7. Summary
  13. 11. Installation and Deployment
    1. 11.1. Deploying Standalone Applications
      1. 11.1.1. Chrome Registry Revisited
      2. 11.1.2. XULRunner Applications
        1. 11.1.2.1. Directory structure
        2. 11.1.2.2. Downloading XULRunner
        3. 11.1.2.3. XULRunner deployment package
        4. 11.1.2.4. Hiworld in a directory
        5. 11.1.2.5. Moving from directory to JAR file
        6. 11.1.2.6. Building necessary startup files
          1. 11.1.2.6.1. application.ini
          2. 11.1.2.6.2. prefs.js
          3. 11.1.2.6.3. chrome.manifest
    2. 11.2. Deploying Themes and Skins
      1. 11.2.1. File Structure
      2. 11.2.2. Creating the Stylesheet
      3. 11.2.3. Registering the Skin
    3. 11.3. Adding Locales
      1. 11.3.1. Setting Up for Locale Development
      2. 11.3.2. Text String Mapping
        1. 11.3.2.1. DTD and entity mapping
        2. 11.3.2.2. Creating the entities
        3. 11.3.2.3. Moving to JAR files
    4. 11.4. Deploying Extensions
      1. 11.4.1. Extension Interfaces: Overlays Revisited
        1. 11.4.1.1. Filesystem implementation
      2. 11.4.2. Locales and Scripting Variables
        1. 11.4.2.1. String bundles
        2. 11.4.2.2. String bundles in overlays
    5. 11.5. Deploying the Extension
      1. 11.5.1. Installation Manifest: install.rdf
      2. 11.5.2. Extensions and the Manifest File
      3. 11.5.3. Installing and Testing
    6. 11.6. What to Do When Things Go Wrong
      1. 11.6.1. Were the Files Installed?
      2. 11.6.2. Chrome Problems
      3. 11.6.3. Integration Problems
      4. 11.6.4. Iterative Deployment
    7. 11.7. Summary
  14. 12. XUL Widget Reference
    1. 12.1. Browser Package Files
      1. 12.1.1. Following the Files
    2. 12.2. Developer Reference
      1. 12.2.1. JavaScript Widgets, Attributes, and Properties
      2. 12.2.2. Component Interfaces
      3. 12.2.3. Widget-Specific Attributes, Properties, and Methods
        1. 12.2.3.1. Common attributes, properties, and methods
      4. 12.2.4. Base XBL Bindings
  15. XUL Widgets: Attributes, Properties, and Methods
  16. About the Author
  17. Colophon
  18. Copyright

Product information

  • Title: Programming Firefox
  • Author(s): Kenneth C. Feldt
  • Release date: April 2007
  • Publisher(s): O'Reilly Media, Inc.
  • ISBN: 9780596102432