nsCOMPtr<nsIDocument> doc; aContent->GetDocument(getter_AddRefs(doc));
nsIDocument* doc = aContent->GetDocument();
static PRBool HasMutationListeners(nsIContent* aContent, PRUint32 aType){  nsCOMPtr<nsIDocument> doc;  aContent->GetDocument(getter_AddRefs(doc));  if (!doc)    return PR_FALSE;  nsCOMPtr<nsIScriptGlobalObject> global;  doc->GetScriptGlobalObject(getter_AddRefs(global));  if (!global)    return PR_FALSE;  nsCOMPtr<nsPIDOMWindow> window(do_QueryInterface(global));  if (!window)    return PR_FALSE;  PRBool set;  window->HasMutationListeners(aType, &set);  if (!set)    return PR_FALSE;  // We know a mutation listener is registered, but it might not  // be in our chain.  Check quickly to see.  nsCOMPtr<nsIContent> curr = aContent;  nsCOMPtr<nsIEventListenerManager> manager;  while (curr) {    nsCOMPtr<nsIDOMEventReceiver> rec(do_QueryInterface(curr));    if (rec) {      rec->GetListenerManager(getter_AddRefs(manager));      if (manager) {        PRBool hasMutationListeners = PR_FALSE;        manager->HasMutationListeners(&hasMutationListeners);        if (hasMutationListeners)          return PR_TRUE;      }    }    nsCOMPtr<nsIContent> prev = curr;    prev->GetParent(getter_AddRefs(curr));  }  nsCOMPtr<nsIDOMEventReceiver> rec(do_QueryInterface(doc));  if (rec) {    rec->GetListenerManager(getter_AddRefs(manager));    if (manager) {      PRBool hasMutationListeners = PR_FALSE;      manager->HasMutationListeners(&hasMutationListeners);      if (hasMutationListeners)        return PR_TRUE;    }  }  rec = do_QueryInterface(window);  if (rec) {    rec->GetListenerManager(getter_AddRefs(manager));    if (manager) {      PRBool hasMutationListeners = PR_FALSE;      manager->HasMutationListeners(&hasMutationListeners);      if (hasMutationListeners)        return PR_TRUE;    }  }  return PR_FALSE;}