Please note, this is a STATIC archive of website from 03 Nov 2016, does not collect or store any user information, there is no "phishing" involved.

Plugin Architecture

This page contains some notes on how plugins work internally in Gecko. It is mainly of interest to Gecko developers.

Note: This document documents how trunk works, i.e. Gecko 1.9. No released product uses this specific architecture.

Note: This document describes how things are, not necessarily how things should be. It is not set in stone. Do not use this document for deciding what plugins can rely on. The described sequences are subject to change at any time.


There are some classes involved in plugins:

  • nsObjectLoadingContent
    • embed, object and applet nodes inherit from that class, which provides services for loading various kinds of objects. It takes care of most of the work involved in loading the data and instantiating plugins.
  • nsObjectFrame
    • The frame responsible for displaying plugins
  • nsPluginInstanceOwner
    • Glue between plugin code (modules/plugin) and layout code (layout/generic). A refcounted object, contrary to nsObjectFrame.

Note that while nsObjectLoadingContent also deals with images and documents, this document concentrates on plugins.

Sequence of events

In content

  • A content node for a plugin DOM element gets created
  • In BindToTree (usually) or another function, it calls LoadObject
  • LoadObject either notices directly that it is dealing with a plugin, or it starts a network request and notices this in OnStartRequest
  • When it realizes that, it tries to create a frame, if aNotify is true and no frame exists yet
  • If a frame exists now, it is asked to instantiate the plugin

That was the normal case. If a frame comes into existance independent of that, it tells the content node that it exists now (nsIObjectLoadingContent::hasNewFrame). That function will post an event and when that fires, asks the frame to instantiate the plugin. (The event is necessary because by the time HasNewFrame is called, the frame isn't fully set up yet)

In layout

Note: Some of this should move to content

  • An instance owner is created
  • The window passed to the plugin is adjusted (The NPWindow,
  • The plugin host is asked to instantiate the plugin
  • This will call back to the instance owner / the object frame in order to create a widget to draw to (if the plugin is not windowless)
    • nsPluginInstanceOwner::SetWindow
  • SetWindow is called on the plugin

Document Tags and Contributors

 Contributors to this page: teoli, kscarfone, Dria, NickolayBot, Nickolay, Biesi
 Last updated by: Dria,