From dbd5b7ffad1a76188e2a824d8a25a33ea5660708 Mon Sep 17 00:00:00 2001 From: "alecf%netscape.com" Date: Thu, 25 Apr 2002 22:48:07 +0000 Subject: [PATCH] more tweaks to windowDS - migrate some code over from the window mediator to get window attributes, etc. not part of build git-svn-id: svn://10.0.0.236/trunk@119897 18797224-902f-48f8-a5cc-f745e15eee43 --- .../windowds/nsWindowDataSource.cpp | 25 ++++++++++++++++--- .../components/windowds/nsWindowDataSource.h | 6 +++++ 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/mozilla/xpfe/components/windowds/nsWindowDataSource.cpp b/mozilla/xpfe/components/windowds/nsWindowDataSource.cpp index a2e118ebaf3..870982f1bcd 100644 --- a/mozilla/xpfe/components/windowds/nsWindowDataSource.cpp +++ b/mozilla/xpfe/components/windowds/nsWindowDataSource.cpp @@ -42,6 +42,7 @@ #include "nsIServiceManager.h" #include "nsReadableUtils.h" +#include "nsIWindowMediator.h" // we need all these for GetAttribute() - *sigh* #include "nsIDocShell.h" @@ -73,7 +74,8 @@ static void GetAttribute( nsIXULWindow* inWindow, const nsAString& inAttribute, nsAString& outValue); -static nsIDOMNode* GetDOMNodeFromDocShell(nsIDocShell* aShell); +static already_AddRefed +GetDOMNodeFromDocShell(nsIDocShell* aShell); nsresult @@ -100,6 +102,13 @@ nsWindowDataSource::Init() rv = rdfc->MakeSeq(this, kNC_WindowRoot, &mContainer); if (NS_FAILED(rv)) return rv; + nsCOMPtr windowMediator = + do_GetService(NS_WINDOWMEDIATOR_CONTRACTID, &rv); + if (NS_FAILED(rv)) return rv; + + rv = windowMediator->AddListener(this); + if (NS_FAILED(rv)) return rv; + return NS_OK; } @@ -467,10 +476,10 @@ GetAttribute( nsIXULWindow* inWindow, } } -nsIDOMNode* +already_AddRefed GetDOMNodeFromDocShell(nsIDocShell *aShell) { - nsCOMPtr node; + nsIDOMNode* node = nsnull; nsCOMPtr cv; aShell->GetContentViewer(getter_AddRefs(cv)); @@ -485,7 +494,7 @@ GetDOMNodeFromDocShell(nsIDocShell *aShell) nsCOMPtr element; domdoc->GetDocumentElement(getter_AddRefs(element)); if (element) - node = do_QueryInterface(element); + CallQueryInterface(element, &node); } } } @@ -495,3 +504,11 @@ GetDOMNodeFromDocShell(nsIDocShell *aShell) } +#if 0 +// this is how we need to be registered: + { "Window Mediator", + NS_WINDOWDATASOURCE_CID, + NS_RDF_DATASOURCE_CONTRACTID_PREFIX "window-mediator", + nsWindowDataSourceConstructor, + }, +#endif diff --git a/mozilla/xpfe/components/windowds/nsWindowDataSource.h b/mozilla/xpfe/components/windowds/nsWindowDataSource.h index 03127f91c91..1eed55127a8 100644 --- a/mozilla/xpfe/components/windowds/nsWindowDataSource.h +++ b/mozilla/xpfe/components/windowds/nsWindowDataSource.h @@ -46,6 +46,12 @@ #include "nsIRDFContainer.h" #include "nsHashtable.h" +// {C744CA3D-840B-460a-8D70-7CE63C51C958} +#define NS_WINDOWDATASOURCE_CID \ +{ 0xc744ca3d, 0x840b, 0x460a, \ + { 0x8d, 0x70, 0x7c, 0xe6, 0x3c, 0x51, 0xc9, 0x58 } } + + class nsWindowDataSource : public nsIRDFDataSource, public nsIWindowMediatorListener, public nsIWindowDataSource