Extending Gecko
with XBL and XTF

Brian Ryner

Software Engineer, Google

What is Gecko?

Adding to Gecko

Ways to extend Gecko

Anonymous Content

Simple Anonymous Content Example: Scrollbar

XBL Terminology

Structure of a Binding

<?xml version="1.0"?>
<bindings xmlns="http://www.mozilla.org/xbl"
          xmlns:html="http://www.w3.org/1999/xhtml">
  <binding id="mybinding">
    <implementation>
      <constructor>...</constructor>
      <destructor>...</destructor>
      <method name="update">
        <body> ... </body>
      </method>
      <property name="enabled">
        <setter>...</setter>
        <getter>...</getter>
      </property>
    </implementation>
(continued)

Structure of a Binding, continued

<content>
  <html:button>
    <html:img inherits="src=imagesrc"/>
    <childen/>
  </html:button>
</content>
<handlers>
  <handler event="mouseover" action="showTooltip();"/>
</handlers>
</binding>
</bindings>

Attaching a Binding

Advanced XBL features

Advanced XBL features, continued

XBL Demo

Start demo

Demo source
Bindings file source
CSS file source

XBL Demo: CML

Start demo

Demo source
Bindings file source
CSS file source

XTF Overview

XTF Terminology

Structure of an XTFElement

class MyElement : public XTFXMLVisual // : XTFVisual : XTFElement
{
  // XTFElement
  void onDestroyed();
  unsigned long getElementType() { return ELEMENT_TYPE_XML_VISUAL; }
  bool getIsAttributeHandler() { return false; }
  void getScriptingInterfaces(....);

  void willChangeDocument(DOMDocument *newDoc);
  void documentChanged(DOMDocument *newDoc);

  void willChangeParent(DOMElement *newParent);
  void parentChanged(DOMElement *newParent);
  ...
  bool handleDefault(DOMEvent *event);
(continued)

Structure of an XTFElement, continued

  // XTFVisual
  DOMElement* getVisualContent();
  DOMElement* getInsertionPoint();
  bool getApplyDocumentStyleSheets() { return true; }

  void didLayout();

  const char* getClassAttributeName() { return "class"; }

  // XTFXMLVisual
  void onCreated(XTFXMLVisualWrapper *wrapper);
};

XTF Example: XForms


XForms Example


What else could be implemented this way?

Future Direction

Resources




Questions?