From 77ba81f47507227275bb693adde1e52f1b889020 Mon Sep 17 00:00:00 2001 From: "bryner%netscape.com" Date: Wed, 2 Apr 2003 21:26:29 +0000 Subject: [PATCH] On second thought, let's not unsuppress painting early for pages with object/embed/applet elements. Instead, go back to calling Show() on the document viewer, but suppress the focus controller while doing so. Bug 199927, r=peterl, sr=bzbarsky. --- layout/generic/nsObjectFrame.cpp | 32 ++++++++++++++++++++++---- layout/html/base/src/nsObjectFrame.cpp | 32 ++++++++++++++++++++++---- 2 files changed, 56 insertions(+), 8 deletions(-) diff --git a/layout/generic/nsObjectFrame.cpp b/layout/generic/nsObjectFrame.cpp index b4559da9878..9c732f1ce7b 100644 --- a/layout/generic/nsObjectFrame.cpp +++ b/layout/generic/nsObjectFrame.cpp @@ -108,6 +108,8 @@ #include "nsUnicharUtils.h" #include "nsTransform2D.h" #include "nsIImageLoadingContent.h" +#include "nsIFocusController.h" +#include "nsPIDOMWindow.h" // headers for plugin scriptability #include "nsIScriptGlobalObject.h" @@ -3962,10 +3964,32 @@ NS_IMETHODIMP nsPluginInstanceOwner::Init(nsIPresContext* aPresContext, nsObject // 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 shell; - mContext->GetShell(getter_AddRefs(shell)); - if (shell) - shell->UnsuppressPainting(); + + nsCOMPtr 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 privWindow = do_GetInterface(container); + nsCOMPtr fc; + if (privWindow) { + privWindow->GetRootFocusController(getter_AddRefs(fc)); + if (fc) + fc->SetSuppressFocus(PR_TRUE, "PluginInstanceOwner::Init Suppression"); + } + + nsCOMPtr docShell = do_QueryInterface(container); + if (docShell) { + nsCOMPtr 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(); diff --git a/layout/html/base/src/nsObjectFrame.cpp b/layout/html/base/src/nsObjectFrame.cpp index b4559da9878..9c732f1ce7b 100644 --- a/layout/html/base/src/nsObjectFrame.cpp +++ b/layout/html/base/src/nsObjectFrame.cpp @@ -108,6 +108,8 @@ #include "nsUnicharUtils.h" #include "nsTransform2D.h" #include "nsIImageLoadingContent.h" +#include "nsIFocusController.h" +#include "nsPIDOMWindow.h" // headers for plugin scriptability #include "nsIScriptGlobalObject.h" @@ -3962,10 +3964,32 @@ NS_IMETHODIMP nsPluginInstanceOwner::Init(nsIPresContext* aPresContext, nsObject // 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 shell; - mContext->GetShell(getter_AddRefs(shell)); - if (shell) - shell->UnsuppressPainting(); + + nsCOMPtr 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 privWindow = do_GetInterface(container); + nsCOMPtr fc; + if (privWindow) { + privWindow->GetRootFocusController(getter_AddRefs(fc)); + if (fc) + fc->SetSuppressFocus(PR_TRUE, "PluginInstanceOwner::Init Suppression"); + } + + nsCOMPtr docShell = do_QueryInterface(container); + if (docShell) { + nsCOMPtr 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();