mContext = aPresContext; mOwner = aFrame;  nsIContent* content = mOwner->GetContent();
nsIContent* content = aFrame->GetContent();
NS_IMETHODIMP nsPluginInstanceOwner::Init(nsIPresContext* aPresContext, nsObjectFrame *aFrame){  //do not addref to avoid circular refs. MMP  mContext = aPresContext;  mOwner = aFrame;    nsIContent* content = mOwner->GetContent();    // Some plugins require a specific sequence of shutdown and startup when  // a page is reloaded. Shutdown happens usually when the last instance  // is destroyed. Here we make sure the plugin instance in the old  // document is destroyed before we try to create the new one.  nsCOMPtr<nsISupports> container;  aPresContext->GetContainer(getter_AddRefs(container));  if (container) {    // We need to suppress the focus controller so that destroying the old    // content viewer doesn't transfer focus to the toplevel window.    nsCOMPtr<nsPIDOMWindow> privWindow = do_GetInterface(container);    nsCOMPtr<nsIFocusController> fc;    if (privWindow) {      privWindow->GetRootFocusController(getter_AddRefs(fc));      if (fc)        fc->SetSuppressFocus(PR_TRUE, "PluginInstanceOwner::Init Suppression");    }    nsCOMPtr<nsIDocShell> docShell = do_QueryInterface(container);    if (docShell) {      nsCOMPtr<nsIContentViewer> cv;      docShell->GetContentViewer(getter_AddRefs(cv));      if (cv)        cv->Show();    }    if (fc)      fc->SetSuppressFocus(PR_FALSE, "PluginInstanceOwner::Init Suppression");  }  // register context menu listener  mCXMenuListener = new nsPluginDOMContextMenuListener();  if (mCXMenuListener) {        NS_ADDREF(mCXMenuListener);        mCXMenuListener->Init(aFrame);  }  nsCOMPtr<nsIDOMEventReceiver> receiver(do_QueryInterface(content));  if (receiver) {    nsCOMPtr<nsIDOMEventListener> listener;    QueryInterface(NS_GET_IID(nsIDOMEventListener), getter_AddRefs(listener));    // Register focus listener    receiver->AddEventListenerByIID(listener, NS_GET_IID(nsIDOMFocusListener));    // Register mouse listener    receiver->AddEventListenerByIID(listener, NS_GET_IID(nsIDOMMouseListener));    // now do the mouse motion listener    receiver->AddEventListenerByIID(listener, NS_GET_IID(nsIDOMMouseMotionListener));    // Register key listener    receiver->AddEventListener(NS_LITERAL_STRING("keypress"), listener, PR_TRUE);    receiver->AddEventListener(NS_LITERAL_STRING("keydown"), listener, PR_TRUE);    receiver->AddEventListener(NS_LITERAL_STRING("keyup"), listener, PR_TRUE);    // Register drag listener    receiver->AddEventListener(NS_LITERAL_STRING("dragdrop"), listener, PR_TRUE);    receiver->AddEventListener(NS_LITERAL_STRING("dragover"), listener, PR_TRUE);    receiver->AddEventListener(NS_LITERAL_STRING("dragexit"), listener, PR_TRUE);    receiver->AddEventListener(NS_LITERAL_STRING("dragenter"), listener, PR_TRUE);    receiver->AddEventListener(NS_LITERAL_STRING("draggesture"), listener, PR_TRUE);  }    // Register scroll position listener  // We need to register a scroll pos listener on every scrollable  // view up to the top  nsIFrame* parentWithView = mOwner->GetAncestorWithView();  nsIView* curView = parentWithView ? parentWithView->GetView() : nsnull;  while (curView)  {    nsIScrollableView* scrollingView;    if (NS_SUCCEEDED(CallQueryInterface(curView, &scrollingView)))      scrollingView->AddScrollPositionListener((nsIScrollPositionListener *)this);        curView = curView->GetParent();  }  return NS_OK; }