From fa81242e104c2bc3796fc09b304376acd1b086f6 Mon Sep 17 00:00:00 2001 From: "hyatt%netscape.com" Date: Thu, 11 Mar 1999 19:49:32 +0000 Subject: [PATCH] Adding in the new document info class and tweaking the builder so that it knows how to use it. --- content/xul/document/src/nsXULDocument.cpp | 2 +- rdf/content/public/MANIFEST | 1 + rdf/content/public/Makefile.in | 1 + rdf/content/public/makefile.win | 1 + rdf/content/src/Makefile.in | 3 +- rdf/content/src/makefile.win | 1 + rdf/content/src/nsRDFXULBuilder.cpp | 82 +++++++++++++--------- rdf/content/src/nsXULDocument.cpp | 2 +- 8 files changed, 57 insertions(+), 36 deletions(-) diff --git a/content/xul/document/src/nsXULDocument.cpp b/content/xul/document/src/nsXULDocument.cpp index b76338574c3..c168b73c304 100644 --- a/content/xul/document/src/nsXULDocument.cpp +++ b/content/xul/document/src/nsXULDocument.cpp @@ -877,7 +877,7 @@ XULDocumentImpl::StartDocumentLoad(nsIURL *aURL, return rv; } - // Create various data sources and builders, but only do this if we're + // Create the composite data source and builder, but only do this if we're // not a XUL fragment. if (mFragmentRoot == nsnull) { diff --git a/rdf/content/public/MANIFEST b/rdf/content/public/MANIFEST index 61f13123e2e..1685173f603 100644 --- a/rdf/content/public/MANIFEST +++ b/rdf/content/public/MANIFEST @@ -8,4 +8,5 @@ nsIRDFDocument.h nsIXULSortService.h nsIXULParentDocument.h nsIXULChildDocument.h +nsIXULDocumentInfo.h diff --git a/rdf/content/public/Makefile.in b/rdf/content/public/Makefile.in index 9046e20af30..4140fe80d72 100644 --- a/rdf/content/public/Makefile.in +++ b/rdf/content/public/Makefile.in @@ -35,6 +35,7 @@ EXPORTS = \ nsIXULSortService.h \ nsIXULParentDocument.h \ nsIXULChildDocument.h \ + nsIXULDocumentInfo.h \ $(NULL) EXPORTS := $(addprefix $(srcdir)/, $(EXPORTS)) diff --git a/rdf/content/public/makefile.win b/rdf/content/public/makefile.win index 5f6d4a81d39..27137a8e710 100644 --- a/rdf/content/public/makefile.win +++ b/rdf/content/public/makefile.win @@ -31,6 +31,7 @@ EXPORTS = \ nsIXULSortService.h \ nsIXULParentDocument.h \ nsIXULChildDocument.h \ + nsIXULDocumentInfo.h \ $(NULL) include <$(DEPTH)/config/rules.mak> diff --git a/rdf/content/src/Makefile.in b/rdf/content/src/Makefile.in index 1f2740cb647..5a239e8048c 100644 --- a/rdf/content/src/Makefile.in +++ b/rdf/content/src/Makefile.in @@ -42,8 +42,9 @@ CPPSRCS = \ nsRDFXULBuilder.cpp \ nsXULAttributes.cpp \ nsXULDocument.cpp \ - nsXULSortService.cpp \ + nsXULSortService.cpp \ nsXULTreeElement.cpp \ + nsXULDocumentInfo.cpp \ $(NULL) EXPORTS = \ diff --git a/rdf/content/src/makefile.win b/rdf/content/src/makefile.win index 054d5a1163c..59425b3ffa2 100644 --- a/rdf/content/src/makefile.win +++ b/rdf/content/src/makefile.win @@ -42,6 +42,7 @@ CPP_OBJS=\ .\$(OBJDIR)\nsRDFTreeBuilder.obj \ .\$(OBJDIR)\nsRDFXULBuilder.obj \ .\$(OBJDIR)\nsXULDocument.obj \ + .\$(OBJDIR)\nsXULDocumentInfo.obj \ .\$(OBJDIR)\nsXULSortService.obj \ .\$(OBJDIR)\nsXULTreeElement.obj \ $(NULL) diff --git a/rdf/content/src/nsRDFXULBuilder.cpp b/rdf/content/src/nsRDFXULBuilder.cpp index cf2fcbd9709..47129a6a250 100644 --- a/rdf/content/src/nsRDFXULBuilder.cpp +++ b/rdf/content/src/nsRDFXULBuilder.cpp @@ -65,7 +65,10 @@ #include "rdfutil.h" #include "nsIDOMXULElement.h" #include "nsIDOMXULDocument.h" +#include "nsIXULDocumentInfo.h" #include "nsIContentViewerContainer.h" +#include "nsIDocumentLoader.h" +#include "nsIWebshell.h" // XXX These are needed as scaffolding until we get to a more // DOM-based solution. @@ -84,6 +87,7 @@ static NS_DEFINE_IID(kIRDFObserverIID, NS_IRDFOBSERVER_IID); static NS_DEFINE_IID(kIRDFResourceIID, NS_IRDFRESOURCE_IID); static NS_DEFINE_IID(kIRDFServiceIID, NS_IRDFSERVICE_IID); static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); +static NS_DEFINE_IID(kIXULDocumentInfoIID, NS_IXULDOCUMENTINFO_IID); static NS_DEFINE_CID(kNameSpaceManagerCID, NS_NAMESPACEMANAGER_CID); static NS_DEFINE_CID(kRDFCompositeDataSourceCID, NS_RDFCOMPOSITEDATASOURCE_CID); @@ -91,7 +95,8 @@ static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID); static NS_DEFINE_CID(kRDFTreeBuilderCID, NS_RDFTREEBUILDER_CID); static NS_DEFINE_CID(kRDFMenuBuilderCID, NS_RDFMENUBUILDER_CID); static NS_DEFINE_CID(kRDFToolbarBuilderCID, NS_RDFTOOLBARBUILDER_CID); -static NS_DEFINE_CID(kCXULDocumentCID, NS_XULDOCUMENT_CID); +static NS_DEFINE_CID(kXULDocumentCID, NS_XULDOCUMENT_CID); +static NS_DEFINE_CID(kXULDocumentInfoCID, NS_XULDOCUMENTINFO_CID); //////////////////////////////////////////////////////////////////////// // standard vocabulary items @@ -581,18 +586,7 @@ RDFXULBuilderImpl::CreateContents(nsIContent* aElement) if (rv == NS_CONTENT_ATTR_HAS_VALUE) { // Build a URL object from the attribute's value. - nsCOMPtr includeURL; - NS_NewURL(getter_AddRefs(includeURL), includeSrc); - - nsCOMPtr subDocument; - if (NS_FAILED(rv = nsComponentManager::CreateInstance(kCXULDocumentCID, - nsnull, - kIDocumentIID, - (void **)getter_AddRefs(subDocument)))) { - NS_ERROR("Unable to initialize a XUL fragment's subdocument."); - return rv; - } - + nsCOMPtr parentDoc; aElement->GetDocument(*getter_AddRefs(parentDoc)); @@ -600,11 +594,7 @@ RDFXULBuilderImpl::CreateContents(nsIContent* aElement) NS_ERROR("Unable to retrieve parent document for a subdocument."); return rv; } - - subDocument->SetParentDocument(parentDoc); - parentDoc->AddSubDocument(subDocument); - - nsCOMPtr streamListener; + nsCOMPtr container; nsCOMPtr xulParentDocument; xulParentDocument = do_QueryInterface(parentDoc); @@ -623,15 +613,6 @@ RDFXULBuilderImpl::CreateContents(nsIContent* aElement) NS_ERROR("Unable to retrieve the command from parent document."); return rv; } - - char* commandChars = command.ToNewCString(); - - nsCOMPtr xulChildDocument; - xulChildDocument = do_QueryInterface(subDocument); - if (xulChildDocument == nsnull) { - NS_ERROR("Unable to retrieve a XUL child document."); - return rv; - } nsCOMPtr xulElement; xulElement = do_QueryInterface(aElement); @@ -646,14 +627,49 @@ RDFXULBuilderImpl::CreateContents(nsIContent* aElement) NS_ERROR("The fragment root doesn't have an RDF resource behind it."); return rv; } - xulChildDocument->SetFragmentRoot(rdfResource); - - if (NS_FAILED(rv = subDocument->StartDocumentLoad(includeURL, container, getter_AddRefs(streamListener), - commandChars))) { - NS_ERROR("Unable to kick off XUL subdocument's document load."); - delete [] commandChars; + + nsCOMPtr docInfo; + if (NS_FAILED(rv = nsComponentManager::CreateInstance(kXULDocumentInfoCID, + nsnull, + kIXULDocumentInfoIID, + (void**) getter_AddRefs(docInfo)))) { + NS_ERROR("unable to create document info object"); return rv; } + + if (NS_FAILED(rv = docInfo->Init(parentDoc, rdfResource))) { + NS_ERROR("unable to initialize doc info object."); + return rv; + } + + nsCOMPtr supportsInfo; + supportsInfo = do_QueryInterface(docInfo); + + // Turn the content viewer into a webshell + nsCOMPtr webshell; + webshell = do_QueryInterface(container); + if (webshell == nsnull) { + NS_ERROR("this isn't a webshell. we're in trouble."); + return rv; + } + + nsCOMPtr docLoader; + if (NS_FAILED(rv = webshell->GetDocumentLoader(*getter_AddRefs(docLoader)))) { + NS_ERROR("unable to obtain the document loader to kick off the load."); + return rv; + } + + char* commandChars = command.ToNewCString(); + + docLoader->LoadDocument(includeSrc, + commandChars, + container, + nsnull, + nsnull, + nsnull, + nsURLReload, + 0);//, + //supportsInfo.get()); delete [] commandChars; } diff --git a/rdf/content/src/nsXULDocument.cpp b/rdf/content/src/nsXULDocument.cpp index b76338574c3..c168b73c304 100644 --- a/rdf/content/src/nsXULDocument.cpp +++ b/rdf/content/src/nsXULDocument.cpp @@ -877,7 +877,7 @@ XULDocumentImpl::StartDocumentLoad(nsIURL *aURL, return rv; } - // Create various data sources and builders, but only do this if we're + // Create the composite data source and builder, but only do this if we're // not a XUL fragment. if (mFragmentRoot == nsnull) {