mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-26 14:22:01 +00:00
making the chrome registry work with dynamic overlays r=pavlov
This commit is contained in:
parent
2dc0208ac7
commit
e092fcee6b
@ -30,17 +30,13 @@
|
||||
#include "nsRDFCID.h"
|
||||
#include "nsIRDFResource.h"
|
||||
#include "nsIRDFDataSource.h"
|
||||
#include "nsIRDFContainer.h"
|
||||
#include "nsHashtable.h"
|
||||
#include "nsString.h"
|
||||
#include "nsXPIDLString.h"
|
||||
#include "nsISimpleEnumerator.h"
|
||||
#include "nsNeckoUtil.h"
|
||||
|
||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
static NS_DEFINE_IID(kIRDFResourceIID, NS_IRDFRESOURCE_IID);
|
||||
static NS_DEFINE_IID(kIRDFLiteralIID, NS_IRDFLITERAL_IID);
|
||||
static NS_DEFINE_IID(kIRDFServiceIID, NS_IRDFSERVICE_IID);
|
||||
static NS_DEFINE_IID(kIRDFDataSourceIID, NS_IRDFDATASOURCE_IID);
|
||||
static NS_DEFINE_IID(kIRDFIntIID, NS_IRDFINT_IID);
|
||||
static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
|
||||
static NS_DEFINE_CID(kRDFXMLDataSourceCID, NS_RDFXMLDATASOURCE_CID);
|
||||
|
||||
@ -88,11 +84,50 @@ nsOverlayEnumerator::~nsOverlayEnumerator()
|
||||
|
||||
NS_IMETHODIMP nsOverlayEnumerator::HasMoreElements(PRBool *aIsTrue)
|
||||
{
|
||||
return NS_OK;
|
||||
return mArcs->HasMoreElements(aIsTrue);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsOverlayEnumerator::GetNext(nsISupports **aResult)
|
||||
{
|
||||
nsresult rv;
|
||||
*aResult = nsnull;
|
||||
|
||||
if (!mArcs)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsISupports> supports;
|
||||
mArcs->GetNext(getter_AddRefs(supports));
|
||||
|
||||
nsCOMPtr<nsIRDFLiteral> value = do_QueryInterface(supports, &rv);
|
||||
if (NS_FAILED(rv))
|
||||
return NS_OK;
|
||||
|
||||
const PRUnichar* valueStr;
|
||||
rv = value->GetValueConst(&valueStr);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
nsCOMPtr<nsIURL> url;
|
||||
|
||||
rv = nsComponentManager::CreateInstance("component://netscape/network/standard-url",
|
||||
nsnull,
|
||||
NS_GET_IID(nsIURL),
|
||||
getter_AddRefs(url));
|
||||
|
||||
if (NS_FAILED(rv))
|
||||
return NS_OK;
|
||||
|
||||
nsCAutoString str(valueStr);
|
||||
url->SetSpec(str);
|
||||
|
||||
nsCOMPtr<nsISupports> sup;
|
||||
sup = do_QueryInterface(url, &rv);
|
||||
if (NS_FAILED(rv))
|
||||
return NS_OK;
|
||||
|
||||
*aResult = sup;
|
||||
NS_ADDREF(*aResult);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -160,7 +195,7 @@ nsChromeRegistry::nsChromeRegistry()
|
||||
if (gRefCnt == 1) {
|
||||
nsresult rv;
|
||||
rv = nsServiceManager::GetService(kRDFServiceCID,
|
||||
kIRDFServiceIID,
|
||||
NS_GET_IID(nsIRDFService),
|
||||
(nsISupports**)&gRDFService);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get RDF service");
|
||||
|
||||
@ -425,20 +460,8 @@ NS_IMETHODIMP nsChromeRegistry::GetOverlays(nsIURI *aChromeURL, nsISimpleEnumera
|
||||
// Construct the lookup string-
|
||||
// which is basically chrome:// + package + provider
|
||||
|
||||
nsAutoString lookup("chrome://");
|
||||
|
||||
lookup += package; // no trailing slash here
|
||||
|
||||
NS_ASSERTION(*provider == '/', "No leading slash here!");
|
||||
|
||||
//definitely have a leading slash...
|
||||
if (*provider != '/')
|
||||
lookup += '/';
|
||||
lookup += provider;
|
||||
|
||||
// end it on a slash if none is present
|
||||
if (lookup.CharAt(lookup.Length()-1) != '/')
|
||||
lookup += '/';
|
||||
char *lookup;
|
||||
aChromeURL->GetSpec(&lookup);
|
||||
|
||||
// Get the chromeResource from this lookup string
|
||||
nsCOMPtr<nsIRDFResource> chromeResource;
|
||||
@ -446,6 +469,8 @@ NS_IMETHODIMP nsChromeRegistry::GetOverlays(nsIURI *aChromeURL, nsISimpleEnumera
|
||||
NS_ERROR("Unable to retrieve the resource corresponding to the chrome skin or content.");
|
||||
return rv;
|
||||
}
|
||||
// XXX free this?
|
||||
// nsAllocator::Free(lookup);
|
||||
|
||||
nsCAutoString overlayFile;
|
||||
|
||||
@ -465,8 +490,21 @@ NS_IMETHODIMP nsChromeRegistry::GetOverlays(nsIURI *aChromeURL, nsISimpleEnumera
|
||||
dataSource = do_QueryInterface(supports);
|
||||
if (dataSource)
|
||||
{
|
||||
nsCOMPtr<nsIRDFContainer> container;
|
||||
nsresult rv = nsComponentManager::CreateInstance("component://netscape/rdf/container",
|
||||
nsnull,
|
||||
NS_GET_IID(nsIRDFContainer),
|
||||
getter_AddRefs(container));
|
||||
if (NS_FAILED(rv))
|
||||
return NS_OK;
|
||||
|
||||
if (NS_FAILED(container->Init(dataSource, chromeResource)))
|
||||
return NS_OK;
|
||||
|
||||
|
||||
nsCOMPtr<nsISimpleEnumerator> arcs;
|
||||
dataSource->ArcLabelsOut(chromeResource, getter_AddRefs(arcs));
|
||||
if (NS_FAILED(container->GetElements(getter_AddRefs(arcs))))
|
||||
return NS_OK;
|
||||
|
||||
*aResult = new nsOverlayEnumerator(arcs);
|
||||
|
||||
@ -475,6 +513,7 @@ NS_IMETHODIMP nsChromeRegistry::GetOverlays(nsIURI *aChromeURL, nsISimpleEnumera
|
||||
|
||||
}
|
||||
|
||||
nsAllocator::Free(lookup);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
@ -595,13 +634,13 @@ nsChromeRegistry::GetChromeResource(nsIRDFDataSource *aDataSource,
|
||||
nsCOMPtr<nsIRDFResource> resource;
|
||||
nsCOMPtr<nsIRDFLiteral> literal;
|
||||
|
||||
if (NS_SUCCEEDED(rv = chromeBase->QueryInterface(kIRDFResourceIID,
|
||||
if (NS_SUCCEEDED(rv = chromeBase->QueryInterface(NS_GET_IID(nsIRDFResource),
|
||||
(void**) getter_AddRefs(resource)))) {
|
||||
nsXPIDLCString uri;
|
||||
resource->GetValue( getter_Copies(uri) );
|
||||
aResult = uri;
|
||||
}
|
||||
else if (NS_SUCCEEDED(rv = chromeBase->QueryInterface(kIRDFLiteralIID,
|
||||
else if (NS_SUCCEEDED(rv = chromeBase->QueryInterface(NS_GET_IID(nsIRDFLiteral),
|
||||
(void**) getter_AddRefs(literal)))) {
|
||||
nsXPIDLString s;
|
||||
literal->GetValue( getter_Copies(s) );
|
||||
|
@ -40,6 +40,7 @@
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsForwardReference.h"
|
||||
#include "nsIChromeRegistry.h"
|
||||
#include "nsICSSLoader.h"
|
||||
#include "nsICSSStyleSheet.h"
|
||||
#include "nsIContent.h"
|
||||
@ -116,6 +117,7 @@ static NS_DEFINE_CID(kXULContentUtilsCID, NS_XULCONTENTUTILS_CID);
|
||||
static NS_DEFINE_CID(kXULDocumentInfoCID, NS_XULDOCUMENTINFO_CID);
|
||||
static NS_DEFINE_CID(kXULKeyListenerCID, NS_XULKEYLISTENER_CID);
|
||||
static NS_DEFINE_CID(kXULTemplateBuilderCID, NS_XULTEMPLATEBUILDER_CID);
|
||||
static NS_DEFINE_CID(kChromeRegistryCID, NS_CHROMEREGISTRY_CID);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@ -187,6 +189,7 @@ protected:
|
||||
void PushNameSpacesFrom(const nsIParserNode& aNode);
|
||||
void PopNameSpaces(void);
|
||||
nsresult GetTopNameSpace(nsCOMPtr<nsINameSpace>* aNameSpace);
|
||||
NS_IMETHOD GetChromeOverlays();
|
||||
|
||||
nsVoidArray mNameSpaceStack;
|
||||
|
||||
@ -299,6 +302,7 @@ protected:
|
||||
|
||||
// Overlays
|
||||
nsCOMPtr<nsIDocument> mDocument; // [OWNER]
|
||||
nsCOMPtr<nsIDocument> mActualDocument;
|
||||
nsIParser* mParser; // [OWNER] We use regular pointer b/c of funky exports on nsIParser
|
||||
|
||||
PRInt32 mUnprocessedOverlayCount;
|
||||
@ -882,6 +886,9 @@ XULContentSinkImpl::CloseContainer(const nsIParserNode& aNode)
|
||||
|
||||
// We're about to finish parsing. Now we want to kick off the processing
|
||||
// of our child overlays.
|
||||
|
||||
GetChromeOverlays();
|
||||
|
||||
PRInt32 count;
|
||||
if ((count = mOverlayArray.Count()) != 0) {
|
||||
// Block the parser. It will only be unblocked after all
|
||||
@ -1271,6 +1278,8 @@ XULContentSinkImpl::Init(nsIDocument* aDocument)
|
||||
|
||||
nsresult rv;
|
||||
|
||||
mActualDocument = aDocument;
|
||||
|
||||
// We could potentially be an overlay; if we are, then our
|
||||
// nsIXULChildDocument interface will have a content sink set.
|
||||
nsCOMPtr<nsIXULChildDocument> overlay = do_QueryInterface(aDocument);
|
||||
@ -2498,6 +2507,60 @@ XULContentSinkImpl::UpdateOverlayCounters(PRInt32 aDelta)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP XULContentSinkImpl::GetChromeOverlays()
|
||||
{
|
||||
nsresult rv;
|
||||
NS_WITH_SERVICE(nsIChromeRegistry, reg, kChromeRegistryCID, &rv);
|
||||
|
||||
if (NS_FAILED(rv))
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsIXULDocument> xuldoc = do_QueryInterface(mActualDocument, &rv);
|
||||
if (NS_FAILED(rv))
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsIChannel> channel;
|
||||
if (NS_FAILED(xuldoc->GetChannel(getter_AddRefs(channel))))
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
if (NS_FAILED(channel->GetOriginalURI(getter_AddRefs(uri))))
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsISimpleEnumerator> oe;
|
||||
reg->GetOverlays(uri, getter_AddRefs(oe));
|
||||
|
||||
if (!oe)
|
||||
return NS_OK;
|
||||
|
||||
PRBool moreElements;
|
||||
oe->HasMoreElements(&moreElements);
|
||||
|
||||
while (moreElements)
|
||||
{
|
||||
nsCOMPtr<nsISupports> next;
|
||||
oe->GetNext(getter_AddRefs(next));
|
||||
if (!next)
|
||||
return NS_OK;
|
||||
|
||||
nsCOMPtr<nsIURI> uri = do_QueryInterface(next);
|
||||
if (!uri)
|
||||
return NS_OK;
|
||||
|
||||
char *spec;
|
||||
uri->GetSpec(&spec);
|
||||
|
||||
nsString *str = new nsString(spec);
|
||||
|
||||
mOverlayArray.AppendElement(str);
|
||||
|
||||
oe->HasMoreElements(&moreElements);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
nsresult
|
||||
|
@ -473,6 +473,9 @@ public:
|
||||
NS_IMETHOD GetAttributeStyleSheet(nsIHTMLStyleSheet** aResult);
|
||||
NS_IMETHOD GetInlineStyleSheet(nsIHTMLCSSStyleSheet** aResult);
|
||||
|
||||
// needed by the XUL Content Sink to do URL conversions
|
||||
NS_IMETHOD GetChannel(nsIChannel **aResult);
|
||||
|
||||
protected:
|
||||
// Implementation methods
|
||||
friend nsresult
|
||||
@ -610,6 +613,10 @@ protected:
|
||||
nsCOMPtr<nsIDOMHTMLFormElement> mHiddenForm; // [OWNER] of this content element
|
||||
nsCOMPtr<nsIDOMXULCommandDispatcher> mCommandDispatcher; // [OWNER] of the focus tracker
|
||||
|
||||
|
||||
nsCOMPtr<nsIChannel> mChannel; // ?? channel we are currently using
|
||||
|
||||
|
||||
nsVoidArray mForwardReferences;
|
||||
PRBool mForwardReferencesResolved;
|
||||
|
||||
@ -1073,6 +1080,7 @@ XULDocumentImpl::StartDocumentLoad(const char* aCommand,
|
||||
nsresult status;
|
||||
nsCOMPtr<nsIParser> parser;
|
||||
#ifdef NECKO
|
||||
mChannel = aChannel;
|
||||
nsCOMPtr<nsIURI> aURL;
|
||||
status = aChannel->GetURI(getter_AddRefs(aURL));
|
||||
if (NS_FAILED(status)) return status;
|
||||
@ -4398,3 +4406,10 @@ XULDocumentImpl::ApplyPersistentAttributesToElements(nsIRDFResource* aResource,
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
XULDocumentImpl::GetChannel(nsIChannel **aResult)
|
||||
{
|
||||
*aResult = mChannel;
|
||||
NS_ADDREF(*aResult);
|
||||
return NS_OK;
|
||||
}
|
@ -30,17 +30,13 @@
|
||||
#include "nsRDFCID.h"
|
||||
#include "nsIRDFResource.h"
|
||||
#include "nsIRDFDataSource.h"
|
||||
#include "nsIRDFContainer.h"
|
||||
#include "nsHashtable.h"
|
||||
#include "nsString.h"
|
||||
#include "nsXPIDLString.h"
|
||||
#include "nsISimpleEnumerator.h"
|
||||
#include "nsNeckoUtil.h"
|
||||
|
||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
static NS_DEFINE_IID(kIRDFResourceIID, NS_IRDFRESOURCE_IID);
|
||||
static NS_DEFINE_IID(kIRDFLiteralIID, NS_IRDFLITERAL_IID);
|
||||
static NS_DEFINE_IID(kIRDFServiceIID, NS_IRDFSERVICE_IID);
|
||||
static NS_DEFINE_IID(kIRDFDataSourceIID, NS_IRDFDATASOURCE_IID);
|
||||
static NS_DEFINE_IID(kIRDFIntIID, NS_IRDFINT_IID);
|
||||
static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
|
||||
static NS_DEFINE_CID(kRDFXMLDataSourceCID, NS_RDFXMLDATASOURCE_CID);
|
||||
|
||||
@ -88,11 +84,50 @@ nsOverlayEnumerator::~nsOverlayEnumerator()
|
||||
|
||||
NS_IMETHODIMP nsOverlayEnumerator::HasMoreElements(PRBool *aIsTrue)
|
||||
{
|
||||
return NS_OK;
|
||||
return mArcs->HasMoreElements(aIsTrue);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsOverlayEnumerator::GetNext(nsISupports **aResult)
|
||||
{
|
||||
nsresult rv;
|
||||
*aResult = nsnull;
|
||||
|
||||
if (!mArcs)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsISupports> supports;
|
||||
mArcs->GetNext(getter_AddRefs(supports));
|
||||
|
||||
nsCOMPtr<nsIRDFLiteral> value = do_QueryInterface(supports, &rv);
|
||||
if (NS_FAILED(rv))
|
||||
return NS_OK;
|
||||
|
||||
const PRUnichar* valueStr;
|
||||
rv = value->GetValueConst(&valueStr);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
nsCOMPtr<nsIURL> url;
|
||||
|
||||
rv = nsComponentManager::CreateInstance("component://netscape/network/standard-url",
|
||||
nsnull,
|
||||
NS_GET_IID(nsIURL),
|
||||
getter_AddRefs(url));
|
||||
|
||||
if (NS_FAILED(rv))
|
||||
return NS_OK;
|
||||
|
||||
nsCAutoString str(valueStr);
|
||||
url->SetSpec(str);
|
||||
|
||||
nsCOMPtr<nsISupports> sup;
|
||||
sup = do_QueryInterface(url, &rv);
|
||||
if (NS_FAILED(rv))
|
||||
return NS_OK;
|
||||
|
||||
*aResult = sup;
|
||||
NS_ADDREF(*aResult);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -160,7 +195,7 @@ nsChromeRegistry::nsChromeRegistry()
|
||||
if (gRefCnt == 1) {
|
||||
nsresult rv;
|
||||
rv = nsServiceManager::GetService(kRDFServiceCID,
|
||||
kIRDFServiceIID,
|
||||
NS_GET_IID(nsIRDFService),
|
||||
(nsISupports**)&gRDFService);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get RDF service");
|
||||
|
||||
@ -425,20 +460,8 @@ NS_IMETHODIMP nsChromeRegistry::GetOverlays(nsIURI *aChromeURL, nsISimpleEnumera
|
||||
// Construct the lookup string-
|
||||
// which is basically chrome:// + package + provider
|
||||
|
||||
nsAutoString lookup("chrome://");
|
||||
|
||||
lookup += package; // no trailing slash here
|
||||
|
||||
NS_ASSERTION(*provider == '/', "No leading slash here!");
|
||||
|
||||
//definitely have a leading slash...
|
||||
if (*provider != '/')
|
||||
lookup += '/';
|
||||
lookup += provider;
|
||||
|
||||
// end it on a slash if none is present
|
||||
if (lookup.CharAt(lookup.Length()-1) != '/')
|
||||
lookup += '/';
|
||||
char *lookup;
|
||||
aChromeURL->GetSpec(&lookup);
|
||||
|
||||
// Get the chromeResource from this lookup string
|
||||
nsCOMPtr<nsIRDFResource> chromeResource;
|
||||
@ -446,6 +469,8 @@ NS_IMETHODIMP nsChromeRegistry::GetOverlays(nsIURI *aChromeURL, nsISimpleEnumera
|
||||
NS_ERROR("Unable to retrieve the resource corresponding to the chrome skin or content.");
|
||||
return rv;
|
||||
}
|
||||
// XXX free this?
|
||||
// nsAllocator::Free(lookup);
|
||||
|
||||
nsCAutoString overlayFile;
|
||||
|
||||
@ -465,8 +490,21 @@ NS_IMETHODIMP nsChromeRegistry::GetOverlays(nsIURI *aChromeURL, nsISimpleEnumera
|
||||
dataSource = do_QueryInterface(supports);
|
||||
if (dataSource)
|
||||
{
|
||||
nsCOMPtr<nsIRDFContainer> container;
|
||||
nsresult rv = nsComponentManager::CreateInstance("component://netscape/rdf/container",
|
||||
nsnull,
|
||||
NS_GET_IID(nsIRDFContainer),
|
||||
getter_AddRefs(container));
|
||||
if (NS_FAILED(rv))
|
||||
return NS_OK;
|
||||
|
||||
if (NS_FAILED(container->Init(dataSource, chromeResource)))
|
||||
return NS_OK;
|
||||
|
||||
|
||||
nsCOMPtr<nsISimpleEnumerator> arcs;
|
||||
dataSource->ArcLabelsOut(chromeResource, getter_AddRefs(arcs));
|
||||
if (NS_FAILED(container->GetElements(getter_AddRefs(arcs))))
|
||||
return NS_OK;
|
||||
|
||||
*aResult = new nsOverlayEnumerator(arcs);
|
||||
|
||||
@ -475,6 +513,7 @@ NS_IMETHODIMP nsChromeRegistry::GetOverlays(nsIURI *aChromeURL, nsISimpleEnumera
|
||||
|
||||
}
|
||||
|
||||
nsAllocator::Free(lookup);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
@ -595,13 +634,13 @@ nsChromeRegistry::GetChromeResource(nsIRDFDataSource *aDataSource,
|
||||
nsCOMPtr<nsIRDFResource> resource;
|
||||
nsCOMPtr<nsIRDFLiteral> literal;
|
||||
|
||||
if (NS_SUCCEEDED(rv = chromeBase->QueryInterface(kIRDFResourceIID,
|
||||
if (NS_SUCCEEDED(rv = chromeBase->QueryInterface(NS_GET_IID(nsIRDFResource),
|
||||
(void**) getter_AddRefs(resource)))) {
|
||||
nsXPIDLCString uri;
|
||||
resource->GetValue( getter_Copies(uri) );
|
||||
aResult = uri;
|
||||
}
|
||||
else if (NS_SUCCEEDED(rv = chromeBase->QueryInterface(kIRDFLiteralIID,
|
||||
else if (NS_SUCCEEDED(rv = chromeBase->QueryInterface(NS_GET_IID(nsIRDFLiteral),
|
||||
(void**) getter_AddRefs(literal)))) {
|
||||
nsXPIDLString s;
|
||||
literal->GetValue( getter_Copies(s) );
|
||||
|
@ -43,6 +43,7 @@ class nsISupportsArray;
|
||||
class nsIRDFResource;
|
||||
class nsIDOMElement;
|
||||
class nsIDOMHTMLFormElement;
|
||||
class nsIChannel;
|
||||
|
||||
// {954F0811-81DC-11d2-B52A-000000000000}
|
||||
#define NS_IRDFDOCUMENT_IID \
|
||||
@ -99,6 +100,8 @@ public:
|
||||
NS_IMETHOD AddForwardReference(nsForwardReference* aForwardReference) = 0;
|
||||
|
||||
NS_IMETHOD ResolveForwardReferences() = 0;
|
||||
|
||||
NS_IMETHOD GetChannel(nsIChannel **aResult) = 0;
|
||||
};
|
||||
|
||||
// factory functions
|
||||
|
@ -40,6 +40,7 @@
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsForwardReference.h"
|
||||
#include "nsIChromeRegistry.h"
|
||||
#include "nsICSSLoader.h"
|
||||
#include "nsICSSStyleSheet.h"
|
||||
#include "nsIContent.h"
|
||||
@ -116,6 +117,7 @@ static NS_DEFINE_CID(kXULContentUtilsCID, NS_XULCONTENTUTILS_CID);
|
||||
static NS_DEFINE_CID(kXULDocumentInfoCID, NS_XULDOCUMENTINFO_CID);
|
||||
static NS_DEFINE_CID(kXULKeyListenerCID, NS_XULKEYLISTENER_CID);
|
||||
static NS_DEFINE_CID(kXULTemplateBuilderCID, NS_XULTEMPLATEBUILDER_CID);
|
||||
static NS_DEFINE_CID(kChromeRegistryCID, NS_CHROMEREGISTRY_CID);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@ -187,6 +189,7 @@ protected:
|
||||
void PushNameSpacesFrom(const nsIParserNode& aNode);
|
||||
void PopNameSpaces(void);
|
||||
nsresult GetTopNameSpace(nsCOMPtr<nsINameSpace>* aNameSpace);
|
||||
NS_IMETHOD GetChromeOverlays();
|
||||
|
||||
nsVoidArray mNameSpaceStack;
|
||||
|
||||
@ -299,6 +302,7 @@ protected:
|
||||
|
||||
// Overlays
|
||||
nsCOMPtr<nsIDocument> mDocument; // [OWNER]
|
||||
nsCOMPtr<nsIDocument> mActualDocument;
|
||||
nsIParser* mParser; // [OWNER] We use regular pointer b/c of funky exports on nsIParser
|
||||
|
||||
PRInt32 mUnprocessedOverlayCount;
|
||||
@ -882,6 +886,9 @@ XULContentSinkImpl::CloseContainer(const nsIParserNode& aNode)
|
||||
|
||||
// We're about to finish parsing. Now we want to kick off the processing
|
||||
// of our child overlays.
|
||||
|
||||
GetChromeOverlays();
|
||||
|
||||
PRInt32 count;
|
||||
if ((count = mOverlayArray.Count()) != 0) {
|
||||
// Block the parser. It will only be unblocked after all
|
||||
@ -1271,6 +1278,8 @@ XULContentSinkImpl::Init(nsIDocument* aDocument)
|
||||
|
||||
nsresult rv;
|
||||
|
||||
mActualDocument = aDocument;
|
||||
|
||||
// We could potentially be an overlay; if we are, then our
|
||||
// nsIXULChildDocument interface will have a content sink set.
|
||||
nsCOMPtr<nsIXULChildDocument> overlay = do_QueryInterface(aDocument);
|
||||
@ -2498,6 +2507,60 @@ XULContentSinkImpl::UpdateOverlayCounters(PRInt32 aDelta)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP XULContentSinkImpl::GetChromeOverlays()
|
||||
{
|
||||
nsresult rv;
|
||||
NS_WITH_SERVICE(nsIChromeRegistry, reg, kChromeRegistryCID, &rv);
|
||||
|
||||
if (NS_FAILED(rv))
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsIXULDocument> xuldoc = do_QueryInterface(mActualDocument, &rv);
|
||||
if (NS_FAILED(rv))
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsIChannel> channel;
|
||||
if (NS_FAILED(xuldoc->GetChannel(getter_AddRefs(channel))))
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
if (NS_FAILED(channel->GetOriginalURI(getter_AddRefs(uri))))
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsISimpleEnumerator> oe;
|
||||
reg->GetOverlays(uri, getter_AddRefs(oe));
|
||||
|
||||
if (!oe)
|
||||
return NS_OK;
|
||||
|
||||
PRBool moreElements;
|
||||
oe->HasMoreElements(&moreElements);
|
||||
|
||||
while (moreElements)
|
||||
{
|
||||
nsCOMPtr<nsISupports> next;
|
||||
oe->GetNext(getter_AddRefs(next));
|
||||
if (!next)
|
||||
return NS_OK;
|
||||
|
||||
nsCOMPtr<nsIURI> uri = do_QueryInterface(next);
|
||||
if (!uri)
|
||||
return NS_OK;
|
||||
|
||||
char *spec;
|
||||
uri->GetSpec(&spec);
|
||||
|
||||
nsString *str = new nsString(spec);
|
||||
|
||||
mOverlayArray.AppendElement(str);
|
||||
|
||||
oe->HasMoreElements(&moreElements);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
nsresult
|
||||
|
@ -473,6 +473,9 @@ public:
|
||||
NS_IMETHOD GetAttributeStyleSheet(nsIHTMLStyleSheet** aResult);
|
||||
NS_IMETHOD GetInlineStyleSheet(nsIHTMLCSSStyleSheet** aResult);
|
||||
|
||||
// needed by the XUL Content Sink to do URL conversions
|
||||
NS_IMETHOD GetChannel(nsIChannel **aResult);
|
||||
|
||||
protected:
|
||||
// Implementation methods
|
||||
friend nsresult
|
||||
@ -610,6 +613,10 @@ protected:
|
||||
nsCOMPtr<nsIDOMHTMLFormElement> mHiddenForm; // [OWNER] of this content element
|
||||
nsCOMPtr<nsIDOMXULCommandDispatcher> mCommandDispatcher; // [OWNER] of the focus tracker
|
||||
|
||||
|
||||
nsCOMPtr<nsIChannel> mChannel; // ?? channel we are currently using
|
||||
|
||||
|
||||
nsVoidArray mForwardReferences;
|
||||
PRBool mForwardReferencesResolved;
|
||||
|
||||
@ -1073,6 +1080,7 @@ XULDocumentImpl::StartDocumentLoad(const char* aCommand,
|
||||
nsresult status;
|
||||
nsCOMPtr<nsIParser> parser;
|
||||
#ifdef NECKO
|
||||
mChannel = aChannel;
|
||||
nsCOMPtr<nsIURI> aURL;
|
||||
status = aChannel->GetURI(getter_AddRefs(aURL));
|
||||
if (NS_FAILED(status)) return status;
|
||||
@ -4398,3 +4406,10 @@ XULDocumentImpl::ApplyPersistentAttributesToElements(nsIRDFResource* aResource,
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
XULDocumentImpl::GetChannel(nsIChannel **aResult)
|
||||
{
|
||||
*aResult = mChannel;
|
||||
NS_ADDREF(*aResult);
|
||||
return NS_OK;
|
||||
}
|
Loading…
Reference in New Issue
Block a user