Back to index

lightning-sunbird  0.9+nobinonly
Static Public Member Functions
nsJSNPRuntime Class Reference

#include <nsJSNPRuntime.h>

List of all members.

Static Public Member Functions

static void OnPluginDestroy (NPP npp)

Detailed Description

Definition at line 47 of file nsJSNPRuntime.h.

Member Function Documentation

Definition at line 1425 of file nsJSNPRuntime.cpp.

  if (sJSObjWrappers.ops) {
                           JSObjWrapperPluginDestroyedCallback, npp);

  if (sNPObjWrappers.ops) {
                           NPObjWrapperPluginDestroyedCallback, npp);

  // If this plugin was scripted from a webpage, the plugin's
  // scriptable object will be on the DOM element's prototype
  // chain. Now that the plugin is being destroyed we need to pull the
  // plugin's scriptable object out of that prototype chain.
  JSContext *cx = GetJSContext(npp);
  if (!cx || !npp) {

  // Find the plugin instance so that we can (eventually) get to the
  // DOM element
  ns4xPluginInstance *inst = (ns4xPluginInstance *)npp->ndata;
  if (!inst) {

  nsCOMPtr<nsIPluginInstancePeer> pip;
  nsCOMPtr<nsIPluginTagInfo2> pti2(do_QueryInterface(pip));
  if (!pti2) {

  nsCOMPtr<nsIDOMElement> element;
  if (!element) {

  // Get the DOM element's JS object.
  nsCOMPtr<nsIXPConnect> xpc(do_GetService(nsIXPConnect::GetCID()));
  if (!xpc) {

  // OK.  Now we have to get our hands on the right scope object, since
  // GetWrappedNativeOfNativeObject doesn't call PreCreate and hence won't get
  // the right scope if we pass in something bogus.  The right scope lives on
  // the script global of the element's document.
  // XXXbz we MUST have a better way of doing this... perhaps
  // GetWrappedNativeOfNativeObject _should_ call preCreate?
  nsCOMPtr<nsIContent> content(do_QueryInterface(element));
  if (!content) {

  nsIDocument* doc = content->GetOwnerDoc();
  if (!doc) {

  nsIScriptGlobalObject* sgo = doc->GetScriptGlobalObject();
  if (!sgo) {

  JSObject* globalObj = sgo->GetGlobalJSObject();

#ifdef DEBUG
  nsIScriptContext* scx = sgo->GetContext();
  if (scx) {
    NS_ASSERTION((JSContext *)scx->GetNativeContext() == cx,
                 "Unexpected JS context");

  nsCOMPtr<nsISupports> supp(do_QueryInterface(element));
  nsCOMPtr<nsIXPConnectWrappedNative> holder;
  xpc->GetWrappedNativeOfNativeObject(cx, globalObj, supp,
  if (!holder) {

  JSObject *obj, *proto;

  // Loop over the DOM element's JS object prototype chain and remove
  // all JS objects of the class sNPObjectJSWrapperClass (there should
  // be only one, but remove all instances found in case the page put
  // more than one of the plugin's scriptable objects on the prototype
  // chain).
  while (obj && (proto = ::JS_GetPrototype(cx, obj))) {
    if (JS_GET_CLASS(cx, proto) == &sNPObjectJSWrapperClass) {
      // We found an NPObject on the proto chain, get its prototype...
      proto = ::JS_GetPrototype(cx, proto);

      // ... and pull it out of the chain.
      ::JS_SetPrototype(cx, obj, proto);

    obj = proto;

Here is the call graph for this function:

Here is the caller graph for this function:

The documentation for this class was generated from the following files: