зеркало из https://github.com/mozilla/pjs.git
Send out notifications when docshells are created or destroyed. Bug 308438,
r=biesi, sr=darin
This commit is contained in:
Родитель
229152d8f9
Коммит
0ed6c71cf2
|
@ -86,6 +86,7 @@
|
||||||
#include "nsAutoPtr.h"
|
#include "nsAutoPtr.h"
|
||||||
#include "nsIPrefService.h"
|
#include "nsIPrefService.h"
|
||||||
#include "nsIWritablePropertyBag2.h"
|
#include "nsIWritablePropertyBag2.h"
|
||||||
|
#include "nsObserverService.h"
|
||||||
|
|
||||||
// we want to explore making the document own the load group
|
// we want to explore making the document own the load group
|
||||||
// so we can associate the document URI with the load group.
|
// so we can associate the document URI with the load group.
|
||||||
|
@ -3360,6 +3361,9 @@ nsDocShell::InitWindow(nativeWindow parentNativeWindow,
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsDocShell::Create()
|
nsDocShell::Create()
|
||||||
{
|
{
|
||||||
|
NS_ASSERTION(mItemType == typeContent || mItemType == typeChrome,
|
||||||
|
"Unexpected item type in docshell");
|
||||||
|
|
||||||
nsresult rv = NS_ERROR_FAILURE;
|
nsresult rv = NS_ERROR_FAILURE;
|
||||||
mPrefs = do_GetService(NS_PREFSERVICE_CONTRACTID, &rv);
|
mPrefs = do_GetService(NS_PREFSERVICE_CONTRACTID, &rv);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
@ -3385,12 +3389,32 @@ nsDocShell::Create()
|
||||||
if (NS_SUCCEEDED(rv))
|
if (NS_SUCCEEDED(rv))
|
||||||
mUseErrorPages = tmpbool;
|
mUseErrorPages = tmpbool;
|
||||||
|
|
||||||
|
nsCOMPtr<nsIObserverService> serv = do_GetService(NS_OBSERVERSERVICE_CONTRACTID);
|
||||||
|
if (serv) {
|
||||||
|
const char* msg = mItemType == typeContent ?
|
||||||
|
NS_WEBNAVIGATION_CREATE : NS_CHROME_WEBNAVIGATION_CREATE;
|
||||||
|
serv->NotifyObservers(GetAsSupports(this), msg, nsnull);
|
||||||
|
}
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsDocShell::Destroy()
|
nsDocShell::Destroy()
|
||||||
{
|
{
|
||||||
|
NS_ASSERTION(mItemType == typeContent || mItemType == typeChrome,
|
||||||
|
"Unexpected item type in docshell");
|
||||||
|
|
||||||
|
if (!mIsBeingDestroyed) {
|
||||||
|
nsCOMPtr<nsIObserverService> serv =
|
||||||
|
do_GetService(NS_OBSERVERSERVICE_CONTRACTID);
|
||||||
|
if (serv) {
|
||||||
|
const char* msg = mItemType == typeContent ?
|
||||||
|
NS_WEBNAVIGATION_DESTROY : NS_CHROME_WEBNAVIGATION_DESTROY;
|
||||||
|
serv->NotifyObservers(GetAsSupports(this), msg, nsnull);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
mIsBeingDestroyed = PR_TRUE;
|
mIsBeingDestroyed = PR_TRUE;
|
||||||
|
|
||||||
//Fire unload event before we blow anything away.
|
//Fire unload event before we blow anything away.
|
||||||
|
|
|
@ -1120,6 +1120,11 @@ nsWebShell::SelectNone(void)
|
||||||
|
|
||||||
NS_IMETHODIMP nsWebShell::Create()
|
NS_IMETHODIMP nsWebShell::Create()
|
||||||
{
|
{
|
||||||
|
if (mPrefs) {
|
||||||
|
// We've already been created
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
// Remember the current thread (in current and forseeable implementations,
|
// Remember the current thread (in current and forseeable implementations,
|
||||||
// it'll just be the unique UI thread)
|
// it'll just be the unique UI thread)
|
||||||
//
|
//
|
||||||
|
|
|
@ -49,4 +49,40 @@
|
||||||
#define NS_WEBNAVIGATION_INFO_CONTRACTID \
|
#define NS_WEBNAVIGATION_INFO_CONTRACTID \
|
||||||
"@mozilla.org/webnavigation-info;1"
|
"@mozilla.org/webnavigation-info;1"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An observer service topic that can be listened to to catch creation
|
||||||
|
* of content browsing areas (both toplevel ones and subframes). The
|
||||||
|
* subject of the notification will be the nsIWebNavigation being
|
||||||
|
* created. At this time the additional data wstring is not defined
|
||||||
|
* to be anything in particular.
|
||||||
|
*/
|
||||||
|
#define NS_WEBNAVIGATION_CREATE "webnavigation-create"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An observer service topic that can be listened to to catch creation
|
||||||
|
* of chrome browsing areas (both toplevel ones and subframes). The
|
||||||
|
* subject of the notification will be the nsIWebNavigation being
|
||||||
|
* created. At this time the additional data wstring is not defined
|
||||||
|
* to be anything in particular.
|
||||||
|
*/
|
||||||
|
#define NS_CHROME_WEBNAVIGATION_CREATE "chrome-webnavigation-create"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An observer service topic that can be listened to to catch destruction
|
||||||
|
* of content browsing areas (both toplevel ones and subframes). The
|
||||||
|
* subject of the notification will be the nsIWebNavigation being
|
||||||
|
* destroyed. At this time the additional data wstring is not defined
|
||||||
|
* to be anything in particular.
|
||||||
|
*/
|
||||||
|
#define NS_WEBNAVIGATION_DESTROY "webnavigation-destroy"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An observer service topic that can be listened to to catch destruction
|
||||||
|
* of chrome browsing areas (both toplevel ones and subframes). The
|
||||||
|
* subject of the notification will be the nsIWebNavigation being
|
||||||
|
* destroyed. At this time the additional data wstring is not defined
|
||||||
|
* to be anything in particular.
|
||||||
|
*/
|
||||||
|
#define NS_CHROME_WEBNAVIGATION_DESTROY "chrome-webnavigation-destroy"
|
||||||
|
|
||||||
#endif // nsDocShellCID_h__
|
#endif // nsDocShellCID_h__
|
||||||
|
|
|
@ -228,6 +228,15 @@ nsresult nsWebShellWindow::Initialize(nsIXULWindow* aParent,
|
||||||
mDocShell = do_CreateInstance("@mozilla.org/webshell;1");
|
mDocShell = do_CreateInstance("@mozilla.org/webshell;1");
|
||||||
NS_ENSURE_TRUE(mDocShell, NS_ERROR_FAILURE);
|
NS_ENSURE_TRUE(mDocShell, NS_ERROR_FAILURE);
|
||||||
|
|
||||||
|
// Make sure to set the item type on the docshell _before_ calling
|
||||||
|
// Create() so it knows what type it is.
|
||||||
|
nsCOMPtr<nsIDocShellTreeItem> docShellAsItem(do_QueryInterface(mDocShell));
|
||||||
|
NS_ENSURE_TRUE(docShellAsItem, NS_ERROR_FAILURE);
|
||||||
|
NS_ENSURE_SUCCESS(EnsureChromeTreeOwner(), NS_ERROR_FAILURE);
|
||||||
|
|
||||||
|
docShellAsItem->SetTreeOwner(mChromeTreeOwner);
|
||||||
|
docShellAsItem->SetItemType(nsIDocShellTreeItem::typeChrome);
|
||||||
|
|
||||||
r.x = r.y = 0;
|
r.x = r.y = 0;
|
||||||
nsCOMPtr<nsIBaseWindow> docShellAsWin(do_QueryInterface(mDocShell));
|
nsCOMPtr<nsIBaseWindow> docShellAsWin(do_QueryInterface(mDocShell));
|
||||||
NS_ENSURE_SUCCESS(docShellAsWin->InitWindow(nsnull, mWindow,
|
NS_ENSURE_SUCCESS(docShellAsWin->InitWindow(nsnull, mWindow,
|
||||||
|
@ -240,13 +249,6 @@ nsresult nsWebShellWindow::Initialize(nsIXULWindow* aParent,
|
||||||
webProgress->AddProgressListener(this, nsIWebProgress::NOTIFY_STATE_NETWORK);
|
webProgress->AddProgressListener(this, nsIWebProgress::NOTIFY_STATE_NETWORK);
|
||||||
}
|
}
|
||||||
|
|
||||||
nsCOMPtr<nsIDocShellTreeItem> docShellAsItem(do_QueryInterface(mDocShell));
|
|
||||||
NS_ENSURE_TRUE(docShellAsItem, NS_ERROR_FAILURE);
|
|
||||||
NS_ENSURE_SUCCESS(EnsureChromeTreeOwner(), NS_ERROR_FAILURE);
|
|
||||||
|
|
||||||
docShellAsItem->SetTreeOwner(mChromeTreeOwner);
|
|
||||||
docShellAsItem->SetItemType(nsIDocShellTreeItem::typeChrome);
|
|
||||||
|
|
||||||
if (nsnull != aUrl) {
|
if (nsnull != aUrl) {
|
||||||
nsCAutoString tmpStr;
|
nsCAutoString tmpStr;
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче