if (anonymous) anonymous->SetDocument(aNewDocument, PR_TRUE, AllowScripts());
if (anonymous) { if (mIsStyleBinding) anonymous->SetDocument(nsnull, PR_TRUE, AllowScripts()); else anonymous->SetDocument(aNewDocument, PR_TRUE, AllowScripts()); }
nsXBLBinding::ChangeDocument(nsIDocument* aOldDocument, nsIDocument* aNewDocument){  if (aOldDocument != aNewDocument) {    if (mNextBinding)      mNextBinding->ChangeDocument(aOldDocument, aNewDocument);    // Only style bindings get their prototypes unhooked.    // XXX Stay in sync! What if a layered binding has an <interface>?!    if (!aNewDocument && !mIsStyleBinding) {      // Now the binding dies.  Unhook our prototypes.      nsCOMPtr<nsIContent> interfaceElement;      GetImmediateChild(kInterfaceAtom, getter_AddRefs(interfaceElement));      if (interfaceElement) {           nsCOMPtr<nsIScriptGlobalObject> global;        aOldDocument->GetScriptGlobalObject(getter_AddRefs(global));        if (global) {          nsCOMPtr<nsIScriptContext> context;          global->GetContext(getter_AddRefs(context));          if (context) {            JSObject* scriptObject;            nsCOMPtr<nsIScriptObjectOwner> owner(do_QueryInterface(mBoundElement));            owner->GetScriptObject(context, (void**)&scriptObject);            if (scriptObject) {              // XXX Sanity check to make sure our class name matches              // Pull ourselves out of the proto chain.              JSContext* jscontext = (JSContext*)context->GetNativeContext();              JSObject* ourProto = JS_GetPrototype(jscontext, scriptObject);              JSObject* grandProto = JS_GetPrototype(jscontext, ourProto);              JS_SetPrototype(jscontext, scriptObject, grandProto);            }          }        }      }    }    // Update the anonymous content.    nsCOMPtr<nsIContent> anonymous;    GetAnonymousContent(getter_AddRefs(anonymous));    if (anonymous)      anonymous->SetDocument(aNewDocument, PR_TRUE, AllowScripts());  }  return NS_OK;}