зеркало из https://github.com/mozilla/pjs.git
Made nsIUnicharStreamLoader be scriptable and deal with an xpcom observer instead of a proc pointer and void*. Part of bug#11159. r=nisheeth,kipp,pierre
This commit is contained in:
Родитель
e09ae8d711
Коммит
2a827fc8c2
|
@ -20,7 +20,6 @@
|
|||
#include "nsIParser.h"
|
||||
#include "nsICSSStyleSheet.h"
|
||||
#include "nsICSSLoader.h"
|
||||
#include "nsIUnicharInputStream.h"
|
||||
#include "nsIHTMLContent.h"
|
||||
#include "nsIHTMLContentContainer.h"
|
||||
#include "nsIURL.h"
|
||||
|
@ -126,7 +125,9 @@ static PRLogModuleInfo* gSinkLogModuleInfo;
|
|||
|
||||
class SinkContext;
|
||||
|
||||
class HTMLContentSink : public nsIHTMLContentSink {
|
||||
class HTMLContentSink : public nsIHTMLContentSink,
|
||||
public nsIUnicharStreamLoaderObserver
|
||||
{
|
||||
public:
|
||||
HTMLContentSink();
|
||||
virtual ~HTMLContentSink();
|
||||
|
@ -139,6 +140,7 @@ public:
|
|||
|
||||
// nsISupports
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIUNICHARSTREAMLOADEROBSERVER
|
||||
|
||||
// nsIContentSink
|
||||
NS_IMETHOD WillBuildModel(void);
|
||||
|
@ -1904,7 +1906,7 @@ HTMLContentSink::~HTMLContentSink()
|
|||
}
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS(HTMLContentSink, kIHTMLContentSinkIID)
|
||||
NS_IMPL_ISUPPORTS2(HTMLContentSink, nsIHTMLContentSink, nsIUnicharStreamLoaderObserver)
|
||||
|
||||
nsresult
|
||||
HTMLContentSink::Init(nsIDocument* aDoc,
|
||||
|
@ -3582,31 +3584,31 @@ HTMLContentSink::EvaluateScript(nsString& aScript,
|
|||
return rv;
|
||||
}
|
||||
|
||||
static void
|
||||
nsDoneLoadingScript(nsIUnicharStreamLoader* aLoader,
|
||||
nsString& aData,
|
||||
void* aRef,
|
||||
nsresult aStatus)
|
||||
NS_IMETHODIMP
|
||||
HTMLContentSink::OnUnicharStreamComplete(nsIUnicharStreamLoader* aLoader,
|
||||
nsresult aStatus,
|
||||
const PRUnichar* string)
|
||||
{
|
||||
HTMLContentSink* sink = (HTMLContentSink*)aRef;
|
||||
nsresult rv = NS_OK;
|
||||
nsString aData(string);
|
||||
|
||||
if (NS_OK == aStatus) {
|
||||
PRBool bodyPresent = sink->PreEvaluateScript();
|
||||
PRBool bodyPresent = PreEvaluateScript();
|
||||
|
||||
// XXX We have no way of indicating failure. Silently fail?
|
||||
sink->EvaluateScript(aData, 0, sink->mScriptLanguageVersion);
|
||||
rv = EvaluateScript(aData, 0, mScriptLanguageVersion);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
sink->PostEvaluateScript(bodyPresent);
|
||||
PostEvaluateScript(bodyPresent);
|
||||
}
|
||||
|
||||
sink->ResumeParsing();
|
||||
|
||||
// The url loader held a reference to the sink
|
||||
NS_RELEASE(sink);
|
||||
rv = ResumeParsing();
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// We added a reference when the loader was created. This
|
||||
// release should destroy it.
|
||||
NS_RELEASE(aLoader);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
@ -3737,19 +3739,11 @@ HTMLContentSink::ProcessSCRIPTTag(const nsIParserNode& aNode)
|
|||
return rv;
|
||||
}
|
||||
|
||||
// Add a reference to this since the url loader is holding
|
||||
// onto it as opaque data.
|
||||
NS_ADDREF(this);
|
||||
|
||||
nsCOMPtr<nsILoadGroup> loadGroup;
|
||||
nsIUnicharStreamLoader* loader;
|
||||
|
||||
mDocument->GetDocumentLoadGroup(getter_AddRefs(loadGroup));
|
||||
rv = NS_NewUnicharStreamLoader(&loader,
|
||||
url,
|
||||
loadGroup,
|
||||
(nsStreamCompleteFunc)nsDoneLoadingScript,
|
||||
(void *)this);
|
||||
rv = NS_NewUnicharStreamLoader(&loader, url, loadGroup, this);
|
||||
NS_RELEASE(url);
|
||||
if (NS_OK == rv) {
|
||||
rv = NS_ERROR_HTMLPARSER_BLOCK;
|
||||
|
|
|
@ -149,7 +149,12 @@ public:
|
|||
nsISupports* mSupports;
|
||||
};
|
||||
|
||||
struct SheetLoadData {
|
||||
class SheetLoadData : public nsIUnicharStreamLoaderObserver
|
||||
{
|
||||
protected:
|
||||
~SheetLoadData(void);
|
||||
|
||||
public:
|
||||
SheetLoadData(CSSLoaderImpl* aLoader, nsIURI* aURL,
|
||||
const nsString& aTitle, const nsString& aMedia,
|
||||
PRInt32 aDefaultNameSpaceID,
|
||||
|
@ -160,7 +165,9 @@ struct SheetLoadData {
|
|||
nsICSSStyleSheet* aParentSheet, PRInt32 aSheetIndex);
|
||||
SheetLoadData(CSSLoaderImpl* aLoader, nsIURI* aURL, nsCSSLoaderCallbackFunc aCallback,
|
||||
void* aData);
|
||||
~SheetLoadData(void);
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIUNICHARSTREAMLOADEROBSERVER
|
||||
|
||||
CSSLoaderImpl* mLoader;
|
||||
nsIURI* mURL;
|
||||
|
@ -188,6 +195,8 @@ struct SheetLoadData {
|
|||
void* mCallbackData;
|
||||
};
|
||||
|
||||
NS_IMPL_ISUPPORTS1(SheetLoadData, nsIUnicharStreamLoaderObserver);
|
||||
|
||||
MOZ_DECL_CTOR_COUNTER(PendingSheetData);
|
||||
|
||||
struct PendingSheetData {
|
||||
|
@ -317,8 +326,6 @@ public:
|
|||
#endif
|
||||
};
|
||||
|
||||
MOZ_DECL_CTOR_COUNTER(SheetLoadData);
|
||||
|
||||
SheetLoadData::SheetLoadData(CSSLoaderImpl* aLoader, nsIURI* aURL,
|
||||
const nsString& aTitle, const nsString& aMedia,
|
||||
PRInt32 aDefaultNameSpaceID,
|
||||
|
@ -343,7 +350,7 @@ SheetLoadData::SheetLoadData(CSSLoaderImpl* aLoader, nsIURI* aURL,
|
|||
mCallback(nsnull),
|
||||
mCallbackData(nsnull)
|
||||
{
|
||||
MOZ_COUNT_CTOR(SheetLoadData);
|
||||
NS_INIT_REFCNT();
|
||||
NS_ADDREF(mLoader);
|
||||
NS_ADDREF(mURL);
|
||||
NS_IF_ADDREF(mOwningElement);
|
||||
|
@ -373,7 +380,7 @@ SheetLoadData::SheetLoadData(CSSLoaderImpl* aLoader, nsIURI* aURL,
|
|||
mCallback(nsnull),
|
||||
mCallbackData(nsnull)
|
||||
{
|
||||
MOZ_COUNT_CTOR(SheetLoadData);
|
||||
NS_INIT_REFCNT();
|
||||
NS_ADDREF(mLoader);
|
||||
NS_ADDREF(mURL);
|
||||
NS_ADDREF(mParentSheet);
|
||||
|
@ -400,7 +407,7 @@ SheetLoadData::SheetLoadData(CSSLoaderImpl* aLoader, nsIURI* aURL,
|
|||
mCallback(aCallback),
|
||||
mCallbackData(nsnull)
|
||||
{
|
||||
MOZ_COUNT_CTOR(SheetLoadData);
|
||||
NS_INIT_REFCNT();
|
||||
NS_ADDREF(mLoader);
|
||||
NS_ADDREF(mURL);
|
||||
}
|
||||
|
@ -408,7 +415,6 @@ SheetLoadData::SheetLoadData(CSSLoaderImpl* aLoader, nsIURI* aURL,
|
|||
|
||||
SheetLoadData::~SheetLoadData(void)
|
||||
{
|
||||
MOZ_COUNT_DTOR(SheetLoadData);
|
||||
NS_RELEASE(mLoader);
|
||||
NS_RELEASE(mURL);
|
||||
NS_IF_RELEASE(mOwningElement);
|
||||
|
@ -438,7 +444,7 @@ static PRBool ReleaseSheet(nsHashKey* aKey, void* aData, void* aClosure)
|
|||
static PRBool DeleteHashLoadData(nsHashKey* aKey, void* aData, void* aClosure)
|
||||
{
|
||||
SheetLoadData* data = (SheetLoadData*)aData;
|
||||
delete data;
|
||||
NS_RELEASE(data);
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
|
@ -452,7 +458,7 @@ static PRBool DeletePendingData(void* aData, void* aClosure)
|
|||
static PRBool DeleteLoadData(void* aData, void* aClosure)
|
||||
{
|
||||
SheetLoadData* data = (SheetLoadData*)aData;
|
||||
delete data;
|
||||
NS_RELEASE(data);
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
|
@ -582,17 +588,18 @@ CSSLoaderImpl::RecycleParser(nsICSSParser* aParser)
|
|||
return result;
|
||||
}
|
||||
|
||||
static void
|
||||
DoneLoadingStyle(nsIUnicharStreamLoader* aLoader,
|
||||
nsString& aStyleData,
|
||||
void* aLoadData,
|
||||
nsresult aStatus)
|
||||
NS_IMETHODIMP
|
||||
SheetLoadData::OnUnicharStreamComplete(nsIUnicharStreamLoader* aLoader,
|
||||
nsresult aStatus,
|
||||
const PRUnichar* string)
|
||||
{
|
||||
SheetLoadData* data = (SheetLoadData*)aLoadData;
|
||||
data->mLoader->DidLoadStyle(aLoader, aStyleData, data, aStatus);
|
||||
nsString aStyleData(string);
|
||||
mLoader->DidLoadStyle(aLoader, aStyleData, this, aStatus);
|
||||
|
||||
// We added a reference when the loader was created. This
|
||||
// release should destroy it.
|
||||
NS_RELEASE(aLoader);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
static PRBool
|
||||
|
@ -671,7 +678,7 @@ CSSLoaderImpl::Cleanup(URLKey& aKey, SheetLoadData* aLoadData)
|
|||
}
|
||||
}
|
||||
|
||||
delete aLoadData; // delete data last, it may have last ref on loader...
|
||||
NS_RELEASE(aLoadData); // delete data last, it may have last ref on loader...
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
@ -1088,9 +1095,7 @@ CSSLoaderImpl::LoadSheet(URLKey& aKey, SheetLoadData* aData)
|
|||
nsCOMPtr<nsILoadGroup> loadGroup;
|
||||
mDocument->GetDocumentLoadGroup(getter_AddRefs(loadGroup));
|
||||
|
||||
result = NS_NewUnicharStreamLoader(&loader, urlClone,
|
||||
loadGroup,
|
||||
DoneLoadingStyle, aData);
|
||||
result = NS_NewUnicharStreamLoader(&loader, urlClone, loadGroup, aData);
|
||||
#ifdef NS_DEBUG
|
||||
mSyncCallback = PR_FALSE;
|
||||
#endif
|
||||
|
@ -1118,7 +1123,7 @@ CSSLoaderImpl::LoadSheet(URLKey& aKey, SheetLoadData* aData)
|
|||
}
|
||||
}
|
||||
else { // document gone, no point in starting the load
|
||||
delete aData;
|
||||
NS_RELEASE(aData);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
@ -1148,11 +1153,17 @@ CSSLoaderImpl::LoadInlineStyle(nsIContent* aElement,
|
|||
aElement,
|
||||
aDocIndex, aParserToUnblock,
|
||||
PR_TRUE);
|
||||
nsICSSStyleSheet* sheet;
|
||||
result = ParseSheet(aIn, data, aCompleted, sheet);
|
||||
NS_IF_RELEASE(sheet);
|
||||
if ((! aCompleted) && (aParserToUnblock)) {
|
||||
data->mDidBlockParser = PR_TRUE;
|
||||
if (data == nsnull) {
|
||||
result = NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
else {
|
||||
NS_ADDREF(data);
|
||||
nsICSSStyleSheet* sheet;
|
||||
result = ParseSheet(aIn, data, aCompleted, sheet);
|
||||
NS_IF_RELEASE(sheet);
|
||||
if ((! aCompleted) && (aParserToUnblock)) {
|
||||
data->mDidBlockParser = PR_TRUE;
|
||||
}
|
||||
}
|
||||
NS_RELEASE(docURL);
|
||||
}
|
||||
|
@ -1205,17 +1216,23 @@ CSSLoaderImpl::LoadStyleLink(nsIContent* aElement,
|
|||
SheetLoadData* data = new SheetLoadData(this, aURL, aTitle, aMedia, aDefaultNameSpaceID,
|
||||
aElement, aDocIndex,
|
||||
aParserToUnblock, PR_FALSE);
|
||||
if (IsAlternate(aTitle) && mLoadingSheets.Count() &&
|
||||
(! mLoadingSheets.Get(&key)) && (! aParserToUnblock)) {
|
||||
// this is an alternate, and we're already loading others, but not loading this, defer it
|
||||
mPendingAlternateSheets.AppendElement(data);
|
||||
result = NS_OK;
|
||||
if (data == nsnull) {
|
||||
result = NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
else {
|
||||
if (aParserToUnblock) {
|
||||
data->mDidBlockParser = PR_TRUE;
|
||||
NS_ADDREF(data);
|
||||
if (IsAlternate(aTitle) && mLoadingSheets.Count() &&
|
||||
(! mLoadingSheets.Get(&key)) && (! aParserToUnblock)) {
|
||||
// this is an alternate, and we're already loading others, but not loading this, defer it
|
||||
mPendingAlternateSheets.AppendElement(data);
|
||||
result = NS_OK;
|
||||
}
|
||||
else {
|
||||
if (aParserToUnblock) {
|
||||
data->mDidBlockParser = PR_TRUE;
|
||||
}
|
||||
result = LoadSheet(key, data);
|
||||
}
|
||||
result = LoadSheet(key, data);
|
||||
}
|
||||
aCompleted = PR_FALSE;
|
||||
}
|
||||
|
@ -1252,30 +1269,35 @@ CSSLoaderImpl::LoadChildSheet(nsICSSStyleSheet* aParentSheet,
|
|||
else {
|
||||
SheetLoadData* data = new SheetLoadData(this, aURL, aMedia, aDefaultNameSpaceID,
|
||||
aParentSheet, aIndex);
|
||||
|
||||
PRInt32 count = mParsingData.Count();
|
||||
if (count) { // still parsing the parent (expected for @import)
|
||||
// XXX assert that last parsing == parent sheet
|
||||
SheetLoadData* parentData = (SheetLoadData*)mParsingData.ElementAt(count - 1);
|
||||
data->mParentData = parentData;
|
||||
data->mIsAgent = parentData->mIsAgent;
|
||||
data->mSyncLoad = parentData->mSyncLoad;
|
||||
|
||||
// verify that sheet doesn't have new child as a parent
|
||||
do {
|
||||
PRBool equals;
|
||||
result = parentData->mURL->Equals(aURL, &equals);
|
||||
if (NS_SUCCEEDED(result) && equals) { // houston, we have a loop, blow off this child
|
||||
data->mParentData = nsnull;
|
||||
delete data;
|
||||
return NS_OK;
|
||||
}
|
||||
parentData = parentData->mParentData;
|
||||
} while (parentData);
|
||||
|
||||
(data->mParentData->mPendingChildren)++;
|
||||
if (data == nsnull) {
|
||||
result = NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
else {
|
||||
NS_ADDREF(data);
|
||||
PRInt32 count = mParsingData.Count();
|
||||
if (count) { // still parsing the parent (expected for @import)
|
||||
// XXX assert that last parsing == parent sheet
|
||||
SheetLoadData* parentData = (SheetLoadData*)mParsingData.ElementAt(count - 1);
|
||||
data->mParentData = parentData;
|
||||
data->mIsAgent = parentData->mIsAgent;
|
||||
data->mSyncLoad = parentData->mSyncLoad;
|
||||
|
||||
// verify that sheet doesn't have new child as a parent
|
||||
do {
|
||||
PRBool equals;
|
||||
result = parentData->mURL->Equals(aURL, &equals);
|
||||
if (NS_SUCCEEDED(result) && equals) { // houston, we have a loop, blow off this child
|
||||
data->mParentData = nsnull;
|
||||
NS_RELEASE(data);
|
||||
return NS_OK;
|
||||
}
|
||||
parentData = parentData->mParentData;
|
||||
} while (parentData);
|
||||
|
||||
(data->mParentData->mPendingChildren)++;
|
||||
}
|
||||
result = LoadSheet(key, data);
|
||||
}
|
||||
result = LoadSheet(key, data);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
@ -1303,9 +1325,15 @@ CSSLoaderImpl::LoadAgentSheet(nsIURI* aURL,
|
|||
result = NS_NewConverterStream(&uin, nsnull, in);
|
||||
if (NS_SUCCEEDED(result)) {
|
||||
SheetLoadData* data = new SheetLoadData(this, aURL, aCallback, aData);
|
||||
URLKey key(aURL);
|
||||
mLoadingSheets.Put(&key, data);
|
||||
result = ParseSheet(uin, data, aCompleted, aSheet);
|
||||
if (data == nsnull) {
|
||||
result = NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
else {
|
||||
NS_ADDREF(data);
|
||||
URLKey key(aURL);
|
||||
mLoadingSheets.Put(&key, data);
|
||||
result = ParseSheet(uin, data, aCompleted, aSheet);
|
||||
}
|
||||
NS_RELEASE(uin);
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -21,7 +21,6 @@
|
|||
#include "nsIXMLElementFactory.h"
|
||||
#include "nsIParser.h"
|
||||
#include "nsIUnicharInputStream.h"
|
||||
#include "nsIUnicharStreamLoader.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIXMLDocument.h"
|
||||
#include "nsIXMLContent.h"
|
||||
|
@ -239,39 +238,21 @@ nsXMLContentSink::Init(nsIDocument* aDoc,
|
|||
}
|
||||
|
||||
#ifndef XSL
|
||||
// nsISupports
|
||||
NS_IMPL_ISUPPORTS(nsXMLContentSink, kIXMLContentSinkIID)
|
||||
|
||||
NS_IMPL_ISUPPORTS3(nsXMLContentSink,
|
||||
nsIXMLContentSink,
|
||||
nsIContentSink,
|
||||
nsIUnicharStreamLoaderObserver)
|
||||
|
||||
#else
|
||||
|
||||
NS_IMPL_THREADSAFE_ADDREF(nsXMLContentSink)
|
||||
NS_IMPL_THREADSAFE_RELEASE(nsXMLContentSink)
|
||||
|
||||
nsresult
|
||||
nsXMLContentSink::QueryInterface(REFNSIID aIID, void** aInstancePtr)
|
||||
{
|
||||
nsresult rv = NS_NOINTERFACE;
|
||||
|
||||
if (NULL == aInstancePtr) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
if (aIID.Equals(kIXMLContentSinkIID)) {
|
||||
*aInstancePtr = (void*)(nsIXMLContentSink*)this;
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
if (aIID.Equals(kIObserverIID)) {
|
||||
*aInstancePtr = (void*)(nsIObserver*)this;
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
if (aIID.Equals(kISupportsIID)) {
|
||||
*aInstancePtr = (void*)(nsISupports*)(nsIXMLContentSink*)this;
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
NS_IMPL_QUERY_INTERFACE4(nsXMLContentSink,
|
||||
nsIXMLContentSink,
|
||||
nsIContentSink,
|
||||
nsIObserver,
|
||||
nsIUnicharStreamLoaderObserver)
|
||||
#endif
|
||||
|
||||
// nsIContentSink
|
||||
|
@ -1773,27 +1754,27 @@ IsJavaScriptLanguage(const nsString& aName, const char* *aVersion)
|
|||
return PR_TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
nsDoneLoadingScript(nsIUnicharStreamLoader* aLoader,
|
||||
nsString& aData,
|
||||
void* aRef,
|
||||
nsresult aStatus)
|
||||
NS_IMETHODIMP
|
||||
nsXMLContentSink::OnUnicharStreamComplete(nsIUnicharStreamLoader* aLoader,
|
||||
nsresult aStatus,
|
||||
const PRUnichar* string)
|
||||
{
|
||||
nsXMLContentSink* sink = (nsXMLContentSink*)aRef;
|
||||
nsresult rv = NS_OK;
|
||||
nsString aData(string);
|
||||
|
||||
if (NS_OK == aStatus) {
|
||||
// XXX We have no way of indicating failure. Silently fail?
|
||||
sink->EvaluateScript(aData, 0, sink->mScriptLanguageVersion);
|
||||
rv = EvaluateScript(aData, 0, mScriptLanguageVersion);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
|
||||
sink->ResumeParsing();
|
||||
|
||||
// The url loader held a reference to the sink
|
||||
NS_RELEASE(sink);
|
||||
rv = ResumeParsing();
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// We added a reference when the loader was created. This
|
||||
// release should destroy it.
|
||||
NS_RELEASE(aLoader);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
@ -1875,19 +1856,11 @@ nsXMLContentSink::ProcessStartSCRIPTTag(const nsIParserNode& aNode)
|
|||
return rv;
|
||||
}
|
||||
|
||||
// Add a reference to this since the url loader is holding
|
||||
// onto it as opaque data.
|
||||
NS_ADDREF(this);
|
||||
|
||||
nsIUnicharStreamLoader* loader;
|
||||
nsCOMPtr<nsILoadGroup> loadGroup;
|
||||
|
||||
mDocument->GetDocumentLoadGroup(getter_AddRefs(loadGroup));
|
||||
rv = NS_NewUnicharStreamLoader(&loader,
|
||||
url,
|
||||
loadGroup,
|
||||
(nsStreamCompleteFunc)nsDoneLoadingScript,
|
||||
(void *)this);
|
||||
rv = NS_NewUnicharStreamLoader(&loader, url, loadGroup, this);
|
||||
NS_RELEASE(url);
|
||||
if (NS_OK == rv) {
|
||||
rv = NS_ERROR_HTMLPARSER_BLOCK;
|
||||
|
|
|
@ -27,6 +27,8 @@
|
|||
#include "nsIObserver.h"
|
||||
#include "nsITransformMediator.h"
|
||||
#endif
|
||||
#include "nsIUnicharInputStream.h"
|
||||
#include "nsIUnicharStreamLoader.h"
|
||||
|
||||
class nsIDocument;
|
||||
class nsIScriptObjectOwner;
|
||||
|
@ -48,11 +50,11 @@ typedef enum {
|
|||
|
||||
// XXX Till the parser knows a little bit more about XML,
|
||||
// this is a HTMLContentSink.
|
||||
class nsXMLContentSink : public nsIXMLContentSink
|
||||
class nsXMLContentSink : public nsIXMLContentSink,
|
||||
#ifdef XSL
|
||||
,
|
||||
public nsIObserver
|
||||
public nsIObserver,
|
||||
#endif
|
||||
public nsIUnicharStreamLoaderObserver
|
||||
{
|
||||
public:
|
||||
nsXMLContentSink();
|
||||
|
@ -64,6 +66,7 @@ public:
|
|||
|
||||
// nsISupports
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIUNICHARSTREAMLOADEROBSERVER
|
||||
|
||||
// nsIContentSink
|
||||
NS_IMETHOD WillBuildModel(void);
|
||||
|
|
|
@ -61,7 +61,6 @@
|
|||
#include "nsIServiceManager.h"
|
||||
#include "nsITextContent.h"
|
||||
#include "nsIURL.h"
|
||||
#include "nsIUnicharStreamLoader.h"
|
||||
#include "nsIViewManager.h"
|
||||
#include "nsIWebShell.h"
|
||||
#include "nsIXMLContent.h"
|
||||
|
@ -502,28 +501,10 @@ XULContentSinkImpl::~XULContentSinkImpl()
|
|||
//----------------------------------------------------------------------
|
||||
// nsISupports interface
|
||||
|
||||
NS_IMPL_ADDREF(XULContentSinkImpl);
|
||||
NS_IMPL_RELEASE(XULContentSinkImpl);
|
||||
|
||||
NS_IMETHODIMP
|
||||
XULContentSinkImpl::QueryInterface(REFNSIID iid, void** result)
|
||||
{
|
||||
NS_PRECONDITION(result, "null ptr");
|
||||
if (! result)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
*result = nsnull;
|
||||
if (iid.Equals(NS_GET_IID(nsIXULContentSink)) ||
|
||||
iid.Equals(NS_GET_IID(nsIXMLContentSink)) ||
|
||||
iid.Equals(NS_GET_IID(nsIContentSink)) ||
|
||||
iid.Equals(NS_GET_IID(nsISupports))) {
|
||||
*result = NS_STATIC_CAST(nsIXMLContentSink*, this);
|
||||
AddRef();
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS3(XULContentSinkImpl,
|
||||
nsIXULContentSink,
|
||||
nsIXMLContentSink,
|
||||
nsIContentSink)
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsIContentSink interface
|
||||
|
|
|
@ -89,7 +89,6 @@
|
|||
#include "nsIStyleSheet.h"
|
||||
#include "nsITextContent.h"
|
||||
#include "nsIURL.h"
|
||||
#include "nsIUnicharStreamLoader.h"
|
||||
#include "nsIWebShell.h"
|
||||
#include "nsIXMLContent.h"
|
||||
#include "nsIXMLElementFactory.h"
|
||||
|
@ -415,6 +414,9 @@ nsXULDocument::QueryInterface(REFNSIID iid, void** result)
|
|||
else if (iid.Equals(NS_GET_IID(nsISupportsWeakReference))) {
|
||||
*result = NS_STATIC_CAST(nsISupportsWeakReference*, this);
|
||||
}
|
||||
else if (iid.Equals(NS_GET_IID(nsIUnicharStreamLoaderObserver))) {
|
||||
*result = NS_STATIC_CAST(nsIUnicharStreamLoaderObserver*, this);
|
||||
}
|
||||
else {
|
||||
*result = nsnull;
|
||||
return NS_NOINTERFACE;
|
||||
|
@ -4585,17 +4587,9 @@ nsXULDocument::LoadScript(nsIURI* aURI, const char* aVersion, PRBool* aBlock)
|
|||
|
||||
// N.B., the loader will be released in DoneLoadingScript()
|
||||
nsIUnicharStreamLoader* loader;
|
||||
rv = NS_NewUnicharStreamLoader(&loader,
|
||||
aURI,
|
||||
group,
|
||||
(nsStreamCompleteFunc)DoneLoadingScript,
|
||||
this);
|
||||
rv = NS_NewUnicharStreamLoader(&loader, aURI, group, this);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// AddRef ourself so that the completion routine will be able
|
||||
// to find us.
|
||||
NS_ADDREF(this);
|
||||
|
||||
*aBlock = PR_TRUE;
|
||||
}
|
||||
|
||||
|
@ -4604,35 +4598,32 @@ nsXULDocument::LoadScript(nsIURI* aURI, const char* aVersion, PRBool* aBlock)
|
|||
|
||||
|
||||
nsresult
|
||||
nsXULDocument::DoneLoadingScript(nsIUnicharStreamLoader* aLoader,
|
||||
nsString& aData,
|
||||
void* aRef,
|
||||
nsresult aStatus)
|
||||
nsXULDocument::OnUnicharStreamComplete(nsIUnicharStreamLoader* aLoader,
|
||||
nsresult aStatus,
|
||||
const PRUnichar* string)
|
||||
{
|
||||
nsString aData(string);
|
||||
// This is the completion routine that will be called when a
|
||||
// transcluded script completes. Evaluate the script if the load
|
||||
// was successful, then continue building content from the
|
||||
// prototype.
|
||||
nsresult rv;
|
||||
nsXULDocument* doc = NS_REINTERPRET_CAST(nsXULDocument*, aRef);
|
||||
|
||||
if (NS_SUCCEEDED(aStatus)) {
|
||||
rv = doc->EvaluateScript(doc->mCurrentScriptURL, aData, 1,
|
||||
doc->mCurrentScriptLanguageVersion);
|
||||
rv = EvaluateScript(mCurrentScriptURL, aData, 1,
|
||||
mCurrentScriptLanguageVersion);
|
||||
|
||||
if (IsChromeURI(doc->mDocumentURL)) {
|
||||
gXULCache->PutScript(doc->mCurrentScriptURL,
|
||||
if (IsChromeURI(mDocumentURL)) {
|
||||
gXULCache->PutScript(mCurrentScriptURL,
|
||||
aData,
|
||||
doc->mCurrentScriptLanguageVersion);
|
||||
mCurrentScriptLanguageVersion);
|
||||
}
|
||||
}
|
||||
|
||||
// balance the addref we added in LoadScript()
|
||||
NS_RELEASE(aLoader);
|
||||
|
||||
rv = doc->ResumeWalk();
|
||||
|
||||
NS_RELEASE(doc);
|
||||
rv = ResumeWalk();
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
|
|
@ -55,6 +55,7 @@
|
|||
#include "nsVoidArray.h"
|
||||
#include "nsWeakPtr.h"
|
||||
#include "nsWeakReference.h"
|
||||
#include "nsIUnicharStreamLoader.h"
|
||||
|
||||
class nsIAtom;
|
||||
class nsIHTMLElementFactory;
|
||||
|
@ -81,6 +82,7 @@ class nsXULDocument : public nsIDocument,
|
|||
public nsIJSScriptObject,
|
||||
public nsIScriptObjectOwner,
|
||||
public nsIHTMLContentContainer,
|
||||
public nsIUnicharStreamLoaderObserver,
|
||||
public nsSupportsWeakReference
|
||||
{
|
||||
public:
|
||||
|
@ -89,6 +91,7 @@ public:
|
|||
|
||||
// nsISupports interface
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIUNICHARSTREAMLOADEROBSERVER
|
||||
|
||||
// nsIDocument interface
|
||||
virtual nsIArena* GetArena();
|
||||
|
@ -602,15 +605,6 @@ protected:
|
|||
*/
|
||||
nsresult AddAttributes(nsXULPrototypeElement* aPrototype, nsIContent* aElement);
|
||||
|
||||
/**
|
||||
* Callback invoked when a transcluded script completes loading.
|
||||
*/
|
||||
static nsresult
|
||||
DoneLoadingScript(nsIUnicharStreamLoader* aLoader,
|
||||
nsString& aData,
|
||||
void* aRef,
|
||||
nsresult aStatus);
|
||||
|
||||
/**
|
||||
* The URL of the current transcluded script that is being loaded.
|
||||
* For document.write('<script src="nestedwrite.js"><\/script>') to work,
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
#include "nsIParser.h"
|
||||
#include "nsICSSStyleSheet.h"
|
||||
#include "nsICSSLoader.h"
|
||||
#include "nsIUnicharInputStream.h"
|
||||
#include "nsIHTMLContent.h"
|
||||
#include "nsIHTMLContentContainer.h"
|
||||
#include "nsIURL.h"
|
||||
|
@ -126,7 +125,9 @@ static PRLogModuleInfo* gSinkLogModuleInfo;
|
|||
|
||||
class SinkContext;
|
||||
|
||||
class HTMLContentSink : public nsIHTMLContentSink {
|
||||
class HTMLContentSink : public nsIHTMLContentSink,
|
||||
public nsIUnicharStreamLoaderObserver
|
||||
{
|
||||
public:
|
||||
HTMLContentSink();
|
||||
virtual ~HTMLContentSink();
|
||||
|
@ -139,6 +140,7 @@ public:
|
|||
|
||||
// nsISupports
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIUNICHARSTREAMLOADEROBSERVER
|
||||
|
||||
// nsIContentSink
|
||||
NS_IMETHOD WillBuildModel(void);
|
||||
|
@ -1904,7 +1906,7 @@ HTMLContentSink::~HTMLContentSink()
|
|||
}
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS(HTMLContentSink, kIHTMLContentSinkIID)
|
||||
NS_IMPL_ISUPPORTS2(HTMLContentSink, nsIHTMLContentSink, nsIUnicharStreamLoaderObserver)
|
||||
|
||||
nsresult
|
||||
HTMLContentSink::Init(nsIDocument* aDoc,
|
||||
|
@ -3582,31 +3584,31 @@ HTMLContentSink::EvaluateScript(nsString& aScript,
|
|||
return rv;
|
||||
}
|
||||
|
||||
static void
|
||||
nsDoneLoadingScript(nsIUnicharStreamLoader* aLoader,
|
||||
nsString& aData,
|
||||
void* aRef,
|
||||
nsresult aStatus)
|
||||
NS_IMETHODIMP
|
||||
HTMLContentSink::OnUnicharStreamComplete(nsIUnicharStreamLoader* aLoader,
|
||||
nsresult aStatus,
|
||||
const PRUnichar* string)
|
||||
{
|
||||
HTMLContentSink* sink = (HTMLContentSink*)aRef;
|
||||
nsresult rv = NS_OK;
|
||||
nsString aData(string);
|
||||
|
||||
if (NS_OK == aStatus) {
|
||||
PRBool bodyPresent = sink->PreEvaluateScript();
|
||||
PRBool bodyPresent = PreEvaluateScript();
|
||||
|
||||
// XXX We have no way of indicating failure. Silently fail?
|
||||
sink->EvaluateScript(aData, 0, sink->mScriptLanguageVersion);
|
||||
rv = EvaluateScript(aData, 0, mScriptLanguageVersion);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
sink->PostEvaluateScript(bodyPresent);
|
||||
PostEvaluateScript(bodyPresent);
|
||||
}
|
||||
|
||||
sink->ResumeParsing();
|
||||
|
||||
// The url loader held a reference to the sink
|
||||
NS_RELEASE(sink);
|
||||
rv = ResumeParsing();
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// We added a reference when the loader was created. This
|
||||
// release should destroy it.
|
||||
NS_RELEASE(aLoader);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
@ -3737,19 +3739,11 @@ HTMLContentSink::ProcessSCRIPTTag(const nsIParserNode& aNode)
|
|||
return rv;
|
||||
}
|
||||
|
||||
// Add a reference to this since the url loader is holding
|
||||
// onto it as opaque data.
|
||||
NS_ADDREF(this);
|
||||
|
||||
nsCOMPtr<nsILoadGroup> loadGroup;
|
||||
nsIUnicharStreamLoader* loader;
|
||||
|
||||
mDocument->GetDocumentLoadGroup(getter_AddRefs(loadGroup));
|
||||
rv = NS_NewUnicharStreamLoader(&loader,
|
||||
url,
|
||||
loadGroup,
|
||||
(nsStreamCompleteFunc)nsDoneLoadingScript,
|
||||
(void *)this);
|
||||
rv = NS_NewUnicharStreamLoader(&loader, url, loadGroup, this);
|
||||
NS_RELEASE(url);
|
||||
if (NS_OK == rv) {
|
||||
rv = NS_ERROR_HTMLPARSER_BLOCK;
|
||||
|
|
|
@ -149,7 +149,12 @@ public:
|
|||
nsISupports* mSupports;
|
||||
};
|
||||
|
||||
struct SheetLoadData {
|
||||
class SheetLoadData : public nsIUnicharStreamLoaderObserver
|
||||
{
|
||||
protected:
|
||||
~SheetLoadData(void);
|
||||
|
||||
public:
|
||||
SheetLoadData(CSSLoaderImpl* aLoader, nsIURI* aURL,
|
||||
const nsString& aTitle, const nsString& aMedia,
|
||||
PRInt32 aDefaultNameSpaceID,
|
||||
|
@ -160,7 +165,9 @@ struct SheetLoadData {
|
|||
nsICSSStyleSheet* aParentSheet, PRInt32 aSheetIndex);
|
||||
SheetLoadData(CSSLoaderImpl* aLoader, nsIURI* aURL, nsCSSLoaderCallbackFunc aCallback,
|
||||
void* aData);
|
||||
~SheetLoadData(void);
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIUNICHARSTREAMLOADEROBSERVER
|
||||
|
||||
CSSLoaderImpl* mLoader;
|
||||
nsIURI* mURL;
|
||||
|
@ -188,6 +195,8 @@ struct SheetLoadData {
|
|||
void* mCallbackData;
|
||||
};
|
||||
|
||||
NS_IMPL_ISUPPORTS1(SheetLoadData, nsIUnicharStreamLoaderObserver);
|
||||
|
||||
MOZ_DECL_CTOR_COUNTER(PendingSheetData);
|
||||
|
||||
struct PendingSheetData {
|
||||
|
@ -317,8 +326,6 @@ public:
|
|||
#endif
|
||||
};
|
||||
|
||||
MOZ_DECL_CTOR_COUNTER(SheetLoadData);
|
||||
|
||||
SheetLoadData::SheetLoadData(CSSLoaderImpl* aLoader, nsIURI* aURL,
|
||||
const nsString& aTitle, const nsString& aMedia,
|
||||
PRInt32 aDefaultNameSpaceID,
|
||||
|
@ -343,7 +350,7 @@ SheetLoadData::SheetLoadData(CSSLoaderImpl* aLoader, nsIURI* aURL,
|
|||
mCallback(nsnull),
|
||||
mCallbackData(nsnull)
|
||||
{
|
||||
MOZ_COUNT_CTOR(SheetLoadData);
|
||||
NS_INIT_REFCNT();
|
||||
NS_ADDREF(mLoader);
|
||||
NS_ADDREF(mURL);
|
||||
NS_IF_ADDREF(mOwningElement);
|
||||
|
@ -373,7 +380,7 @@ SheetLoadData::SheetLoadData(CSSLoaderImpl* aLoader, nsIURI* aURL,
|
|||
mCallback(nsnull),
|
||||
mCallbackData(nsnull)
|
||||
{
|
||||
MOZ_COUNT_CTOR(SheetLoadData);
|
||||
NS_INIT_REFCNT();
|
||||
NS_ADDREF(mLoader);
|
||||
NS_ADDREF(mURL);
|
||||
NS_ADDREF(mParentSheet);
|
||||
|
@ -400,7 +407,7 @@ SheetLoadData::SheetLoadData(CSSLoaderImpl* aLoader, nsIURI* aURL,
|
|||
mCallback(aCallback),
|
||||
mCallbackData(nsnull)
|
||||
{
|
||||
MOZ_COUNT_CTOR(SheetLoadData);
|
||||
NS_INIT_REFCNT();
|
||||
NS_ADDREF(mLoader);
|
||||
NS_ADDREF(mURL);
|
||||
}
|
||||
|
@ -408,7 +415,6 @@ SheetLoadData::SheetLoadData(CSSLoaderImpl* aLoader, nsIURI* aURL,
|
|||
|
||||
SheetLoadData::~SheetLoadData(void)
|
||||
{
|
||||
MOZ_COUNT_DTOR(SheetLoadData);
|
||||
NS_RELEASE(mLoader);
|
||||
NS_RELEASE(mURL);
|
||||
NS_IF_RELEASE(mOwningElement);
|
||||
|
@ -438,7 +444,7 @@ static PRBool ReleaseSheet(nsHashKey* aKey, void* aData, void* aClosure)
|
|||
static PRBool DeleteHashLoadData(nsHashKey* aKey, void* aData, void* aClosure)
|
||||
{
|
||||
SheetLoadData* data = (SheetLoadData*)aData;
|
||||
delete data;
|
||||
NS_RELEASE(data);
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
|
@ -452,7 +458,7 @@ static PRBool DeletePendingData(void* aData, void* aClosure)
|
|||
static PRBool DeleteLoadData(void* aData, void* aClosure)
|
||||
{
|
||||
SheetLoadData* data = (SheetLoadData*)aData;
|
||||
delete data;
|
||||
NS_RELEASE(data);
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
|
@ -582,17 +588,18 @@ CSSLoaderImpl::RecycleParser(nsICSSParser* aParser)
|
|||
return result;
|
||||
}
|
||||
|
||||
static void
|
||||
DoneLoadingStyle(nsIUnicharStreamLoader* aLoader,
|
||||
nsString& aStyleData,
|
||||
void* aLoadData,
|
||||
nsresult aStatus)
|
||||
NS_IMETHODIMP
|
||||
SheetLoadData::OnUnicharStreamComplete(nsIUnicharStreamLoader* aLoader,
|
||||
nsresult aStatus,
|
||||
const PRUnichar* string)
|
||||
{
|
||||
SheetLoadData* data = (SheetLoadData*)aLoadData;
|
||||
data->mLoader->DidLoadStyle(aLoader, aStyleData, data, aStatus);
|
||||
nsString aStyleData(string);
|
||||
mLoader->DidLoadStyle(aLoader, aStyleData, this, aStatus);
|
||||
|
||||
// We added a reference when the loader was created. This
|
||||
// release should destroy it.
|
||||
NS_RELEASE(aLoader);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
static PRBool
|
||||
|
@ -671,7 +678,7 @@ CSSLoaderImpl::Cleanup(URLKey& aKey, SheetLoadData* aLoadData)
|
|||
}
|
||||
}
|
||||
|
||||
delete aLoadData; // delete data last, it may have last ref on loader...
|
||||
NS_RELEASE(aLoadData); // delete data last, it may have last ref on loader...
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
@ -1088,9 +1095,7 @@ CSSLoaderImpl::LoadSheet(URLKey& aKey, SheetLoadData* aData)
|
|||
nsCOMPtr<nsILoadGroup> loadGroup;
|
||||
mDocument->GetDocumentLoadGroup(getter_AddRefs(loadGroup));
|
||||
|
||||
result = NS_NewUnicharStreamLoader(&loader, urlClone,
|
||||
loadGroup,
|
||||
DoneLoadingStyle, aData);
|
||||
result = NS_NewUnicharStreamLoader(&loader, urlClone, loadGroup, aData);
|
||||
#ifdef NS_DEBUG
|
||||
mSyncCallback = PR_FALSE;
|
||||
#endif
|
||||
|
@ -1118,7 +1123,7 @@ CSSLoaderImpl::LoadSheet(URLKey& aKey, SheetLoadData* aData)
|
|||
}
|
||||
}
|
||||
else { // document gone, no point in starting the load
|
||||
delete aData;
|
||||
NS_RELEASE(aData);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
@ -1148,11 +1153,17 @@ CSSLoaderImpl::LoadInlineStyle(nsIContent* aElement,
|
|||
aElement,
|
||||
aDocIndex, aParserToUnblock,
|
||||
PR_TRUE);
|
||||
nsICSSStyleSheet* sheet;
|
||||
result = ParseSheet(aIn, data, aCompleted, sheet);
|
||||
NS_IF_RELEASE(sheet);
|
||||
if ((! aCompleted) && (aParserToUnblock)) {
|
||||
data->mDidBlockParser = PR_TRUE;
|
||||
if (data == nsnull) {
|
||||
result = NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
else {
|
||||
NS_ADDREF(data);
|
||||
nsICSSStyleSheet* sheet;
|
||||
result = ParseSheet(aIn, data, aCompleted, sheet);
|
||||
NS_IF_RELEASE(sheet);
|
||||
if ((! aCompleted) && (aParserToUnblock)) {
|
||||
data->mDidBlockParser = PR_TRUE;
|
||||
}
|
||||
}
|
||||
NS_RELEASE(docURL);
|
||||
}
|
||||
|
@ -1205,17 +1216,23 @@ CSSLoaderImpl::LoadStyleLink(nsIContent* aElement,
|
|||
SheetLoadData* data = new SheetLoadData(this, aURL, aTitle, aMedia, aDefaultNameSpaceID,
|
||||
aElement, aDocIndex,
|
||||
aParserToUnblock, PR_FALSE);
|
||||
if (IsAlternate(aTitle) && mLoadingSheets.Count() &&
|
||||
(! mLoadingSheets.Get(&key)) && (! aParserToUnblock)) {
|
||||
// this is an alternate, and we're already loading others, but not loading this, defer it
|
||||
mPendingAlternateSheets.AppendElement(data);
|
||||
result = NS_OK;
|
||||
if (data == nsnull) {
|
||||
result = NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
else {
|
||||
if (aParserToUnblock) {
|
||||
data->mDidBlockParser = PR_TRUE;
|
||||
NS_ADDREF(data);
|
||||
if (IsAlternate(aTitle) && mLoadingSheets.Count() &&
|
||||
(! mLoadingSheets.Get(&key)) && (! aParserToUnblock)) {
|
||||
// this is an alternate, and we're already loading others, but not loading this, defer it
|
||||
mPendingAlternateSheets.AppendElement(data);
|
||||
result = NS_OK;
|
||||
}
|
||||
else {
|
||||
if (aParserToUnblock) {
|
||||
data->mDidBlockParser = PR_TRUE;
|
||||
}
|
||||
result = LoadSheet(key, data);
|
||||
}
|
||||
result = LoadSheet(key, data);
|
||||
}
|
||||
aCompleted = PR_FALSE;
|
||||
}
|
||||
|
@ -1252,30 +1269,35 @@ CSSLoaderImpl::LoadChildSheet(nsICSSStyleSheet* aParentSheet,
|
|||
else {
|
||||
SheetLoadData* data = new SheetLoadData(this, aURL, aMedia, aDefaultNameSpaceID,
|
||||
aParentSheet, aIndex);
|
||||
|
||||
PRInt32 count = mParsingData.Count();
|
||||
if (count) { // still parsing the parent (expected for @import)
|
||||
// XXX assert that last parsing == parent sheet
|
||||
SheetLoadData* parentData = (SheetLoadData*)mParsingData.ElementAt(count - 1);
|
||||
data->mParentData = parentData;
|
||||
data->mIsAgent = parentData->mIsAgent;
|
||||
data->mSyncLoad = parentData->mSyncLoad;
|
||||
|
||||
// verify that sheet doesn't have new child as a parent
|
||||
do {
|
||||
PRBool equals;
|
||||
result = parentData->mURL->Equals(aURL, &equals);
|
||||
if (NS_SUCCEEDED(result) && equals) { // houston, we have a loop, blow off this child
|
||||
data->mParentData = nsnull;
|
||||
delete data;
|
||||
return NS_OK;
|
||||
}
|
||||
parentData = parentData->mParentData;
|
||||
} while (parentData);
|
||||
|
||||
(data->mParentData->mPendingChildren)++;
|
||||
if (data == nsnull) {
|
||||
result = NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
else {
|
||||
NS_ADDREF(data);
|
||||
PRInt32 count = mParsingData.Count();
|
||||
if (count) { // still parsing the parent (expected for @import)
|
||||
// XXX assert that last parsing == parent sheet
|
||||
SheetLoadData* parentData = (SheetLoadData*)mParsingData.ElementAt(count - 1);
|
||||
data->mParentData = parentData;
|
||||
data->mIsAgent = parentData->mIsAgent;
|
||||
data->mSyncLoad = parentData->mSyncLoad;
|
||||
|
||||
// verify that sheet doesn't have new child as a parent
|
||||
do {
|
||||
PRBool equals;
|
||||
result = parentData->mURL->Equals(aURL, &equals);
|
||||
if (NS_SUCCEEDED(result) && equals) { // houston, we have a loop, blow off this child
|
||||
data->mParentData = nsnull;
|
||||
NS_RELEASE(data);
|
||||
return NS_OK;
|
||||
}
|
||||
parentData = parentData->mParentData;
|
||||
} while (parentData);
|
||||
|
||||
(data->mParentData->mPendingChildren)++;
|
||||
}
|
||||
result = LoadSheet(key, data);
|
||||
}
|
||||
result = LoadSheet(key, data);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
@ -1303,9 +1325,15 @@ CSSLoaderImpl::LoadAgentSheet(nsIURI* aURL,
|
|||
result = NS_NewConverterStream(&uin, nsnull, in);
|
||||
if (NS_SUCCEEDED(result)) {
|
||||
SheetLoadData* data = new SheetLoadData(this, aURL, aCallback, aData);
|
||||
URLKey key(aURL);
|
||||
mLoadingSheets.Put(&key, data);
|
||||
result = ParseSheet(uin, data, aCompleted, aSheet);
|
||||
if (data == nsnull) {
|
||||
result = NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
else {
|
||||
NS_ADDREF(data);
|
||||
URLKey key(aURL);
|
||||
mLoadingSheets.Put(&key, data);
|
||||
result = ParseSheet(uin, data, aCompleted, aSheet);
|
||||
}
|
||||
NS_RELEASE(uin);
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -149,7 +149,12 @@ public:
|
|||
nsISupports* mSupports;
|
||||
};
|
||||
|
||||
struct SheetLoadData {
|
||||
class SheetLoadData : public nsIUnicharStreamLoaderObserver
|
||||
{
|
||||
protected:
|
||||
~SheetLoadData(void);
|
||||
|
||||
public:
|
||||
SheetLoadData(CSSLoaderImpl* aLoader, nsIURI* aURL,
|
||||
const nsString& aTitle, const nsString& aMedia,
|
||||
PRInt32 aDefaultNameSpaceID,
|
||||
|
@ -160,7 +165,9 @@ struct SheetLoadData {
|
|||
nsICSSStyleSheet* aParentSheet, PRInt32 aSheetIndex);
|
||||
SheetLoadData(CSSLoaderImpl* aLoader, nsIURI* aURL, nsCSSLoaderCallbackFunc aCallback,
|
||||
void* aData);
|
||||
~SheetLoadData(void);
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIUNICHARSTREAMLOADEROBSERVER
|
||||
|
||||
CSSLoaderImpl* mLoader;
|
||||
nsIURI* mURL;
|
||||
|
@ -188,6 +195,8 @@ struct SheetLoadData {
|
|||
void* mCallbackData;
|
||||
};
|
||||
|
||||
NS_IMPL_ISUPPORTS1(SheetLoadData, nsIUnicharStreamLoaderObserver);
|
||||
|
||||
MOZ_DECL_CTOR_COUNTER(PendingSheetData);
|
||||
|
||||
struct PendingSheetData {
|
||||
|
@ -317,8 +326,6 @@ public:
|
|||
#endif
|
||||
};
|
||||
|
||||
MOZ_DECL_CTOR_COUNTER(SheetLoadData);
|
||||
|
||||
SheetLoadData::SheetLoadData(CSSLoaderImpl* aLoader, nsIURI* aURL,
|
||||
const nsString& aTitle, const nsString& aMedia,
|
||||
PRInt32 aDefaultNameSpaceID,
|
||||
|
@ -343,7 +350,7 @@ SheetLoadData::SheetLoadData(CSSLoaderImpl* aLoader, nsIURI* aURL,
|
|||
mCallback(nsnull),
|
||||
mCallbackData(nsnull)
|
||||
{
|
||||
MOZ_COUNT_CTOR(SheetLoadData);
|
||||
NS_INIT_REFCNT();
|
||||
NS_ADDREF(mLoader);
|
||||
NS_ADDREF(mURL);
|
||||
NS_IF_ADDREF(mOwningElement);
|
||||
|
@ -373,7 +380,7 @@ SheetLoadData::SheetLoadData(CSSLoaderImpl* aLoader, nsIURI* aURL,
|
|||
mCallback(nsnull),
|
||||
mCallbackData(nsnull)
|
||||
{
|
||||
MOZ_COUNT_CTOR(SheetLoadData);
|
||||
NS_INIT_REFCNT();
|
||||
NS_ADDREF(mLoader);
|
||||
NS_ADDREF(mURL);
|
||||
NS_ADDREF(mParentSheet);
|
||||
|
@ -400,7 +407,7 @@ SheetLoadData::SheetLoadData(CSSLoaderImpl* aLoader, nsIURI* aURL,
|
|||
mCallback(aCallback),
|
||||
mCallbackData(nsnull)
|
||||
{
|
||||
MOZ_COUNT_CTOR(SheetLoadData);
|
||||
NS_INIT_REFCNT();
|
||||
NS_ADDREF(mLoader);
|
||||
NS_ADDREF(mURL);
|
||||
}
|
||||
|
@ -408,7 +415,6 @@ SheetLoadData::SheetLoadData(CSSLoaderImpl* aLoader, nsIURI* aURL,
|
|||
|
||||
SheetLoadData::~SheetLoadData(void)
|
||||
{
|
||||
MOZ_COUNT_DTOR(SheetLoadData);
|
||||
NS_RELEASE(mLoader);
|
||||
NS_RELEASE(mURL);
|
||||
NS_IF_RELEASE(mOwningElement);
|
||||
|
@ -438,7 +444,7 @@ static PRBool ReleaseSheet(nsHashKey* aKey, void* aData, void* aClosure)
|
|||
static PRBool DeleteHashLoadData(nsHashKey* aKey, void* aData, void* aClosure)
|
||||
{
|
||||
SheetLoadData* data = (SheetLoadData*)aData;
|
||||
delete data;
|
||||
NS_RELEASE(data);
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
|
@ -452,7 +458,7 @@ static PRBool DeletePendingData(void* aData, void* aClosure)
|
|||
static PRBool DeleteLoadData(void* aData, void* aClosure)
|
||||
{
|
||||
SheetLoadData* data = (SheetLoadData*)aData;
|
||||
delete data;
|
||||
NS_RELEASE(data);
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
|
@ -582,17 +588,18 @@ CSSLoaderImpl::RecycleParser(nsICSSParser* aParser)
|
|||
return result;
|
||||
}
|
||||
|
||||
static void
|
||||
DoneLoadingStyle(nsIUnicharStreamLoader* aLoader,
|
||||
nsString& aStyleData,
|
||||
void* aLoadData,
|
||||
nsresult aStatus)
|
||||
NS_IMETHODIMP
|
||||
SheetLoadData::OnUnicharStreamComplete(nsIUnicharStreamLoader* aLoader,
|
||||
nsresult aStatus,
|
||||
const PRUnichar* string)
|
||||
{
|
||||
SheetLoadData* data = (SheetLoadData*)aLoadData;
|
||||
data->mLoader->DidLoadStyle(aLoader, aStyleData, data, aStatus);
|
||||
nsString aStyleData(string);
|
||||
mLoader->DidLoadStyle(aLoader, aStyleData, this, aStatus);
|
||||
|
||||
// We added a reference when the loader was created. This
|
||||
// release should destroy it.
|
||||
NS_RELEASE(aLoader);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
static PRBool
|
||||
|
@ -671,7 +678,7 @@ CSSLoaderImpl::Cleanup(URLKey& aKey, SheetLoadData* aLoadData)
|
|||
}
|
||||
}
|
||||
|
||||
delete aLoadData; // delete data last, it may have last ref on loader...
|
||||
NS_RELEASE(aLoadData); // delete data last, it may have last ref on loader...
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
@ -1088,9 +1095,7 @@ CSSLoaderImpl::LoadSheet(URLKey& aKey, SheetLoadData* aData)
|
|||
nsCOMPtr<nsILoadGroup> loadGroup;
|
||||
mDocument->GetDocumentLoadGroup(getter_AddRefs(loadGroup));
|
||||
|
||||
result = NS_NewUnicharStreamLoader(&loader, urlClone,
|
||||
loadGroup,
|
||||
DoneLoadingStyle, aData);
|
||||
result = NS_NewUnicharStreamLoader(&loader, urlClone, loadGroup, aData);
|
||||
#ifdef NS_DEBUG
|
||||
mSyncCallback = PR_FALSE;
|
||||
#endif
|
||||
|
@ -1118,7 +1123,7 @@ CSSLoaderImpl::LoadSheet(URLKey& aKey, SheetLoadData* aData)
|
|||
}
|
||||
}
|
||||
else { // document gone, no point in starting the load
|
||||
delete aData;
|
||||
NS_RELEASE(aData);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
@ -1148,11 +1153,17 @@ CSSLoaderImpl::LoadInlineStyle(nsIContent* aElement,
|
|||
aElement,
|
||||
aDocIndex, aParserToUnblock,
|
||||
PR_TRUE);
|
||||
nsICSSStyleSheet* sheet;
|
||||
result = ParseSheet(aIn, data, aCompleted, sheet);
|
||||
NS_IF_RELEASE(sheet);
|
||||
if ((! aCompleted) && (aParserToUnblock)) {
|
||||
data->mDidBlockParser = PR_TRUE;
|
||||
if (data == nsnull) {
|
||||
result = NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
else {
|
||||
NS_ADDREF(data);
|
||||
nsICSSStyleSheet* sheet;
|
||||
result = ParseSheet(aIn, data, aCompleted, sheet);
|
||||
NS_IF_RELEASE(sheet);
|
||||
if ((! aCompleted) && (aParserToUnblock)) {
|
||||
data->mDidBlockParser = PR_TRUE;
|
||||
}
|
||||
}
|
||||
NS_RELEASE(docURL);
|
||||
}
|
||||
|
@ -1205,17 +1216,23 @@ CSSLoaderImpl::LoadStyleLink(nsIContent* aElement,
|
|||
SheetLoadData* data = new SheetLoadData(this, aURL, aTitle, aMedia, aDefaultNameSpaceID,
|
||||
aElement, aDocIndex,
|
||||
aParserToUnblock, PR_FALSE);
|
||||
if (IsAlternate(aTitle) && mLoadingSheets.Count() &&
|
||||
(! mLoadingSheets.Get(&key)) && (! aParserToUnblock)) {
|
||||
// this is an alternate, and we're already loading others, but not loading this, defer it
|
||||
mPendingAlternateSheets.AppendElement(data);
|
||||
result = NS_OK;
|
||||
if (data == nsnull) {
|
||||
result = NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
else {
|
||||
if (aParserToUnblock) {
|
||||
data->mDidBlockParser = PR_TRUE;
|
||||
NS_ADDREF(data);
|
||||
if (IsAlternate(aTitle) && mLoadingSheets.Count() &&
|
||||
(! mLoadingSheets.Get(&key)) && (! aParserToUnblock)) {
|
||||
// this is an alternate, and we're already loading others, but not loading this, defer it
|
||||
mPendingAlternateSheets.AppendElement(data);
|
||||
result = NS_OK;
|
||||
}
|
||||
else {
|
||||
if (aParserToUnblock) {
|
||||
data->mDidBlockParser = PR_TRUE;
|
||||
}
|
||||
result = LoadSheet(key, data);
|
||||
}
|
||||
result = LoadSheet(key, data);
|
||||
}
|
||||
aCompleted = PR_FALSE;
|
||||
}
|
||||
|
@ -1252,30 +1269,35 @@ CSSLoaderImpl::LoadChildSheet(nsICSSStyleSheet* aParentSheet,
|
|||
else {
|
||||
SheetLoadData* data = new SheetLoadData(this, aURL, aMedia, aDefaultNameSpaceID,
|
||||
aParentSheet, aIndex);
|
||||
|
||||
PRInt32 count = mParsingData.Count();
|
||||
if (count) { // still parsing the parent (expected for @import)
|
||||
// XXX assert that last parsing == parent sheet
|
||||
SheetLoadData* parentData = (SheetLoadData*)mParsingData.ElementAt(count - 1);
|
||||
data->mParentData = parentData;
|
||||
data->mIsAgent = parentData->mIsAgent;
|
||||
data->mSyncLoad = parentData->mSyncLoad;
|
||||
|
||||
// verify that sheet doesn't have new child as a parent
|
||||
do {
|
||||
PRBool equals;
|
||||
result = parentData->mURL->Equals(aURL, &equals);
|
||||
if (NS_SUCCEEDED(result) && equals) { // houston, we have a loop, blow off this child
|
||||
data->mParentData = nsnull;
|
||||
delete data;
|
||||
return NS_OK;
|
||||
}
|
||||
parentData = parentData->mParentData;
|
||||
} while (parentData);
|
||||
|
||||
(data->mParentData->mPendingChildren)++;
|
||||
if (data == nsnull) {
|
||||
result = NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
else {
|
||||
NS_ADDREF(data);
|
||||
PRInt32 count = mParsingData.Count();
|
||||
if (count) { // still parsing the parent (expected for @import)
|
||||
// XXX assert that last parsing == parent sheet
|
||||
SheetLoadData* parentData = (SheetLoadData*)mParsingData.ElementAt(count - 1);
|
||||
data->mParentData = parentData;
|
||||
data->mIsAgent = parentData->mIsAgent;
|
||||
data->mSyncLoad = parentData->mSyncLoad;
|
||||
|
||||
// verify that sheet doesn't have new child as a parent
|
||||
do {
|
||||
PRBool equals;
|
||||
result = parentData->mURL->Equals(aURL, &equals);
|
||||
if (NS_SUCCEEDED(result) && equals) { // houston, we have a loop, blow off this child
|
||||
data->mParentData = nsnull;
|
||||
NS_RELEASE(data);
|
||||
return NS_OK;
|
||||
}
|
||||
parentData = parentData->mParentData;
|
||||
} while (parentData);
|
||||
|
||||
(data->mParentData->mPendingChildren)++;
|
||||
}
|
||||
result = LoadSheet(key, data);
|
||||
}
|
||||
result = LoadSheet(key, data);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
@ -1303,9 +1325,15 @@ CSSLoaderImpl::LoadAgentSheet(nsIURI* aURL,
|
|||
result = NS_NewConverterStream(&uin, nsnull, in);
|
||||
if (NS_SUCCEEDED(result)) {
|
||||
SheetLoadData* data = new SheetLoadData(this, aURL, aCallback, aData);
|
||||
URLKey key(aURL);
|
||||
mLoadingSheets.Put(&key, data);
|
||||
result = ParseSheet(uin, data, aCompleted, aSheet);
|
||||
if (data == nsnull) {
|
||||
result = NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
else {
|
||||
NS_ADDREF(data);
|
||||
URLKey key(aURL);
|
||||
mLoadingSheets.Put(&key, data);
|
||||
result = ParseSheet(uin, data, aCompleted, aSheet);
|
||||
}
|
||||
NS_RELEASE(uin);
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -21,7 +21,6 @@
|
|||
#include "nsIXMLElementFactory.h"
|
||||
#include "nsIParser.h"
|
||||
#include "nsIUnicharInputStream.h"
|
||||
#include "nsIUnicharStreamLoader.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIXMLDocument.h"
|
||||
#include "nsIXMLContent.h"
|
||||
|
@ -239,39 +238,21 @@ nsXMLContentSink::Init(nsIDocument* aDoc,
|
|||
}
|
||||
|
||||
#ifndef XSL
|
||||
// nsISupports
|
||||
NS_IMPL_ISUPPORTS(nsXMLContentSink, kIXMLContentSinkIID)
|
||||
|
||||
NS_IMPL_ISUPPORTS3(nsXMLContentSink,
|
||||
nsIXMLContentSink,
|
||||
nsIContentSink,
|
||||
nsIUnicharStreamLoaderObserver)
|
||||
|
||||
#else
|
||||
|
||||
NS_IMPL_THREADSAFE_ADDREF(nsXMLContentSink)
|
||||
NS_IMPL_THREADSAFE_RELEASE(nsXMLContentSink)
|
||||
|
||||
nsresult
|
||||
nsXMLContentSink::QueryInterface(REFNSIID aIID, void** aInstancePtr)
|
||||
{
|
||||
nsresult rv = NS_NOINTERFACE;
|
||||
|
||||
if (NULL == aInstancePtr) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
if (aIID.Equals(kIXMLContentSinkIID)) {
|
||||
*aInstancePtr = (void*)(nsIXMLContentSink*)this;
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
if (aIID.Equals(kIObserverIID)) {
|
||||
*aInstancePtr = (void*)(nsIObserver*)this;
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
if (aIID.Equals(kISupportsIID)) {
|
||||
*aInstancePtr = (void*)(nsISupports*)(nsIXMLContentSink*)this;
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
NS_IMPL_QUERY_INTERFACE4(nsXMLContentSink,
|
||||
nsIXMLContentSink,
|
||||
nsIContentSink,
|
||||
nsIObserver,
|
||||
nsIUnicharStreamLoaderObserver)
|
||||
#endif
|
||||
|
||||
// nsIContentSink
|
||||
|
@ -1773,27 +1754,27 @@ IsJavaScriptLanguage(const nsString& aName, const char* *aVersion)
|
|||
return PR_TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
nsDoneLoadingScript(nsIUnicharStreamLoader* aLoader,
|
||||
nsString& aData,
|
||||
void* aRef,
|
||||
nsresult aStatus)
|
||||
NS_IMETHODIMP
|
||||
nsXMLContentSink::OnUnicharStreamComplete(nsIUnicharStreamLoader* aLoader,
|
||||
nsresult aStatus,
|
||||
const PRUnichar* string)
|
||||
{
|
||||
nsXMLContentSink* sink = (nsXMLContentSink*)aRef;
|
||||
nsresult rv = NS_OK;
|
||||
nsString aData(string);
|
||||
|
||||
if (NS_OK == aStatus) {
|
||||
// XXX We have no way of indicating failure. Silently fail?
|
||||
sink->EvaluateScript(aData, 0, sink->mScriptLanguageVersion);
|
||||
rv = EvaluateScript(aData, 0, mScriptLanguageVersion);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
|
||||
sink->ResumeParsing();
|
||||
|
||||
// The url loader held a reference to the sink
|
||||
NS_RELEASE(sink);
|
||||
rv = ResumeParsing();
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// We added a reference when the loader was created. This
|
||||
// release should destroy it.
|
||||
NS_RELEASE(aLoader);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
@ -1875,19 +1856,11 @@ nsXMLContentSink::ProcessStartSCRIPTTag(const nsIParserNode& aNode)
|
|||
return rv;
|
||||
}
|
||||
|
||||
// Add a reference to this since the url loader is holding
|
||||
// onto it as opaque data.
|
||||
NS_ADDREF(this);
|
||||
|
||||
nsIUnicharStreamLoader* loader;
|
||||
nsCOMPtr<nsILoadGroup> loadGroup;
|
||||
|
||||
mDocument->GetDocumentLoadGroup(getter_AddRefs(loadGroup));
|
||||
rv = NS_NewUnicharStreamLoader(&loader,
|
||||
url,
|
||||
loadGroup,
|
||||
(nsStreamCompleteFunc)nsDoneLoadingScript,
|
||||
(void *)this);
|
||||
rv = NS_NewUnicharStreamLoader(&loader, url, loadGroup, this);
|
||||
NS_RELEASE(url);
|
||||
if (NS_OK == rv) {
|
||||
rv = NS_ERROR_HTMLPARSER_BLOCK;
|
||||
|
|
|
@ -27,6 +27,8 @@
|
|||
#include "nsIObserver.h"
|
||||
#include "nsITransformMediator.h"
|
||||
#endif
|
||||
#include "nsIUnicharInputStream.h"
|
||||
#include "nsIUnicharStreamLoader.h"
|
||||
|
||||
class nsIDocument;
|
||||
class nsIScriptObjectOwner;
|
||||
|
@ -48,11 +50,11 @@ typedef enum {
|
|||
|
||||
// XXX Till the parser knows a little bit more about XML,
|
||||
// this is a HTMLContentSink.
|
||||
class nsXMLContentSink : public nsIXMLContentSink
|
||||
class nsXMLContentSink : public nsIXMLContentSink,
|
||||
#ifdef XSL
|
||||
,
|
||||
public nsIObserver
|
||||
public nsIObserver,
|
||||
#endif
|
||||
public nsIUnicharStreamLoaderObserver
|
||||
{
|
||||
public:
|
||||
nsXMLContentSink();
|
||||
|
@ -64,6 +66,7 @@ public:
|
|||
|
||||
// nsISupports
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIUNICHARSTREAMLOADEROBSERVER
|
||||
|
||||
// nsIContentSink
|
||||
NS_IMETHOD WillBuildModel(void);
|
||||
|
|
|
@ -11,5 +11,4 @@ nsIRequest.idl
|
|||
nsISocketTransportService.idl
|
||||
nsIFileTransportService.idl
|
||||
nsIFileSystem.idl
|
||||
|
||||
|
||||
nsIUnicharStreamLoader.idl
|
||||
|
|
|
@ -48,6 +48,7 @@ XPIDLSRCS = \
|
|||
nsIContentHandler.idl \
|
||||
nsIURIDispatcher.idl \
|
||||
nsIURIContentListener.idl \
|
||||
nsIUnicharStreamLoader.idl \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS = \
|
||||
|
|
|
@ -45,6 +45,7 @@ XPIDLSRCS = \
|
|||
.\nsIFileTransportService.idl \
|
||||
.\nsIStatusCodeEventSink.idl \
|
||||
.\nsIFileSystem.idl \
|
||||
.\nsIUnicharStreamLoader.idl \
|
||||
$(NULL)
|
||||
|
||||
include <$(DEPTH)/config/rules.mak>
|
||||
|
|
|
@ -40,7 +40,8 @@ CPPSRCS = \
|
|||
nsLoadGroup.cpp \
|
||||
nsInputStreamChannel.cpp \
|
||||
nsDirectoryIndexStream.cpp \
|
||||
nsURIDispatcher.cpp \
|
||||
nsURIDispatcher.cpp \
|
||||
nsUnicharStreamLoader.cpp \
|
||||
$(NULL)
|
||||
|
||||
# we don't want the shared lib, but we want to force the creation of a
|
||||
|
|
|
@ -37,6 +37,7 @@ CPP_OBJS = \
|
|||
.\$(OBJDIR)\nsLoadGroup.obj \
|
||||
.\$(OBJDIR)\nsInputStreamChannel.obj \
|
||||
.\$(OBJDIR)\nsDirectoryIndexStream.obj \
|
||||
.\$(OBJDIR)\nsUnicharStreamLoader.obj \
|
||||
$(NULL)
|
||||
|
||||
INCS = $(INCS) \
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
#include "nsDnsService.h"
|
||||
#include "nsLoadGroup.h"
|
||||
#include "nsInputStreamChannel.h"
|
||||
#include "nsUnicharStreamLoader.h"
|
||||
|
||||
static NS_DEFINE_CID(kComponentManagerCID, NS_COMPONENTMANAGER_CID);
|
||||
static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID);
|
||||
|
@ -43,6 +44,7 @@ static NS_DEFINE_CID(kExternalModuleManagerCID, NS_NETMODULEMGR_CID);
|
|||
static NS_DEFINE_CID(kDNSServiceCID, NS_DNSSERVICE_CID);
|
||||
static NS_DEFINE_CID(kLoadGroupCID, NS_LOADGROUP_CID);
|
||||
static NS_DEFINE_CID(kInputStreamChannelCID, NS_INPUTSTREAMCHANNEL_CID);
|
||||
static NS_DEFINE_CID(kUnicharStreamLoaderCID, NS_UNICHARSTREAMLOADER_CID);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
@ -73,6 +75,7 @@ protected:
|
|||
nsCOMPtr<nsIGenericFactory> mExternalModuleManagerFactory;
|
||||
nsCOMPtr<nsIGenericFactory> mLoadGroupFactory;
|
||||
nsCOMPtr<nsIGenericFactory> mInputStreamChannelFactory;
|
||||
nsCOMPtr<nsIGenericFactory> mUnicharStreamLoaderFactory;
|
||||
};
|
||||
|
||||
static NS_DEFINE_IID(kIModuleIID, NS_IMODULE_IID);
|
||||
|
@ -116,6 +119,7 @@ nsNetModule::Shutdown()
|
|||
mExternalModuleManagerFactory = nsnull;
|
||||
mLoadGroupFactory = nsnull;
|
||||
mInputStreamChannelFactory = nsnull;
|
||||
mUnicharStreamLoaderFactory = nsnull;
|
||||
}
|
||||
|
||||
// Create a factory object for creating instances of aClass.
|
||||
|
@ -201,8 +205,6 @@ nsNetModule::GetClassObject(nsIComponentManager *aCompMgr,
|
|||
}
|
||||
fact = mExternalModuleManagerFactory;
|
||||
}
|
||||
// XXX not registered!
|
||||
#if 1
|
||||
else if (aClass.Equals(kLoadGroupCID)) {
|
||||
if (!mLoadGroupFactory) {
|
||||
rv = NS_NewGenericFactory(getter_AddRefs(mLoadGroupFactory),
|
||||
|
@ -210,7 +212,6 @@ nsNetModule::GetClassObject(nsIComponentManager *aCompMgr,
|
|||
}
|
||||
fact = mLoadGroupFactory;
|
||||
}
|
||||
#endif
|
||||
else if (aClass.Equals(kInputStreamChannelCID)) {
|
||||
if (!mInputStreamChannelFactory) {
|
||||
rv = NS_NewGenericFactory(getter_AddRefs(mInputStreamChannelFactory),
|
||||
|
@ -218,6 +219,13 @@ nsNetModule::GetClassObject(nsIComponentManager *aCompMgr,
|
|||
}
|
||||
fact = mInputStreamChannelFactory;
|
||||
}
|
||||
else if (aClass.Equals(kUnicharStreamLoaderCID)) {
|
||||
if (!mUnicharStreamLoaderFactory) {
|
||||
rv = NS_NewGenericFactory(getter_AddRefs(mUnicharStreamLoaderFactory),
|
||||
nsUnicharStreamLoader::Create);
|
||||
}
|
||||
fact = mUnicharStreamLoaderFactory;
|
||||
}
|
||||
else {
|
||||
rv = NS_ERROR_FACTORY_NOT_REGISTERED;
|
||||
#ifdef DEBUG
|
||||
|
@ -262,6 +270,10 @@ static Components gComponents[] = {
|
|||
"component://netscape/network/net-extern-mod", },
|
||||
{ "Input Stream Channel", &kInputStreamChannelCID,
|
||||
"component://netscape/network/input-stream-channel", },
|
||||
{ "Unichar Stream Loader", &kUnicharStreamLoaderCID,
|
||||
"component://netscape/network/unichar-stream-loader", },
|
||||
{ "Load Group", &kLoadGroupCID,
|
||||
"component://netscape/network/load-group", },
|
||||
};
|
||||
#define NUM_COMPONENTS (sizeof(gComponents) / sizeof(gComponents[0]))
|
||||
|
||||
|
|
Двоичные данные
netwerk/macbuild/netwerk.mcp
Двоичные данные
netwerk/macbuild/netwerk.mcp
Двоичный файл не отображается.
Двоичные данные
netwerk/macbuild/netwerkIDL.mcp
Двоичные данные
netwerk/macbuild/netwerkIDL.mcp
Двоичный файл не отображается.
Двоичные данные
netwerk/util/macbuild/netwerkUtil.mcp
Двоичные данные
netwerk/util/macbuild/netwerkUtil.mcp
Двоичный файл не отображается.
|
@ -3,5 +3,4 @@
|
|||
#
|
||||
|
||||
nsIBlockingNotification.h
|
||||
nsIUnicharStreamLoader.h
|
||||
nsNeckoUtil.h
|
||||
nsNeckoUtil.h
|
||||
|
|
|
@ -26,7 +26,6 @@ MODULE = necko
|
|||
|
||||
EXPORTS = \
|
||||
nsNeckoUtil.h \
|
||||
nsIUnicharStreamLoader.h \
|
||||
nsIBlockingNotification.h \
|
||||
$(NULL)
|
||||
|
||||
|
|
|
@ -22,7 +22,6 @@ include <$(DEPTH)/config/config.mak>
|
|||
|
||||
EXPORTS = \
|
||||
nsNeckoUtil.h \
|
||||
nsIUnicharStreamLoader.h \
|
||||
nsIBlockingNotification.h \
|
||||
$(NULL)
|
||||
|
||||
|
|
|
@ -26,7 +26,6 @@ MODULE = necko
|
|||
LIBRARY_NAME = neckoutil_s
|
||||
|
||||
CPPSRCS = \
|
||||
nsNetStreamLoader.cpp \
|
||||
nsNeckoUtil.cpp \
|
||||
$(NULL)
|
||||
|
||||
|
|
|
@ -23,7 +23,6 @@ LCFLAGS = -DWIN32_LEAN_AND_MEAN -D_IMPL_NS_NET
|
|||
LIBRARY_NAME=neckoutil_s
|
||||
|
||||
CPP_OBJS = \
|
||||
.\$(OBJDIR)\nsNetStreamLoader.obj \
|
||||
.\$(OBJDIR)\nsNeckoUtil.obj \
|
||||
$(NULL)
|
||||
|
||||
|
|
|
@ -61,7 +61,6 @@
|
|||
#include "nsIServiceManager.h"
|
||||
#include "nsITextContent.h"
|
||||
#include "nsIURL.h"
|
||||
#include "nsIUnicharStreamLoader.h"
|
||||
#include "nsIViewManager.h"
|
||||
#include "nsIWebShell.h"
|
||||
#include "nsIXMLContent.h"
|
||||
|
@ -502,28 +501,10 @@ XULContentSinkImpl::~XULContentSinkImpl()
|
|||
//----------------------------------------------------------------------
|
||||
// nsISupports interface
|
||||
|
||||
NS_IMPL_ADDREF(XULContentSinkImpl);
|
||||
NS_IMPL_RELEASE(XULContentSinkImpl);
|
||||
|
||||
NS_IMETHODIMP
|
||||
XULContentSinkImpl::QueryInterface(REFNSIID iid, void** result)
|
||||
{
|
||||
NS_PRECONDITION(result, "null ptr");
|
||||
if (! result)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
*result = nsnull;
|
||||
if (iid.Equals(NS_GET_IID(nsIXULContentSink)) ||
|
||||
iid.Equals(NS_GET_IID(nsIXMLContentSink)) ||
|
||||
iid.Equals(NS_GET_IID(nsIContentSink)) ||
|
||||
iid.Equals(NS_GET_IID(nsISupports))) {
|
||||
*result = NS_STATIC_CAST(nsIXMLContentSink*, this);
|
||||
AddRef();
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS3(XULContentSinkImpl,
|
||||
nsIXULContentSink,
|
||||
nsIXMLContentSink,
|
||||
nsIContentSink)
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsIContentSink interface
|
||||
|
|
|
@ -89,7 +89,6 @@
|
|||
#include "nsIStyleSheet.h"
|
||||
#include "nsITextContent.h"
|
||||
#include "nsIURL.h"
|
||||
#include "nsIUnicharStreamLoader.h"
|
||||
#include "nsIWebShell.h"
|
||||
#include "nsIXMLContent.h"
|
||||
#include "nsIXMLElementFactory.h"
|
||||
|
@ -415,6 +414,9 @@ nsXULDocument::QueryInterface(REFNSIID iid, void** result)
|
|||
else if (iid.Equals(NS_GET_IID(nsISupportsWeakReference))) {
|
||||
*result = NS_STATIC_CAST(nsISupportsWeakReference*, this);
|
||||
}
|
||||
else if (iid.Equals(NS_GET_IID(nsIUnicharStreamLoaderObserver))) {
|
||||
*result = NS_STATIC_CAST(nsIUnicharStreamLoaderObserver*, this);
|
||||
}
|
||||
else {
|
||||
*result = nsnull;
|
||||
return NS_NOINTERFACE;
|
||||
|
@ -4585,17 +4587,9 @@ nsXULDocument::LoadScript(nsIURI* aURI, const char* aVersion, PRBool* aBlock)
|
|||
|
||||
// N.B., the loader will be released in DoneLoadingScript()
|
||||
nsIUnicharStreamLoader* loader;
|
||||
rv = NS_NewUnicharStreamLoader(&loader,
|
||||
aURI,
|
||||
group,
|
||||
(nsStreamCompleteFunc)DoneLoadingScript,
|
||||
this);
|
||||
rv = NS_NewUnicharStreamLoader(&loader, aURI, group, this);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// AddRef ourself so that the completion routine will be able
|
||||
// to find us.
|
||||
NS_ADDREF(this);
|
||||
|
||||
*aBlock = PR_TRUE;
|
||||
}
|
||||
|
||||
|
@ -4604,35 +4598,32 @@ nsXULDocument::LoadScript(nsIURI* aURI, const char* aVersion, PRBool* aBlock)
|
|||
|
||||
|
||||
nsresult
|
||||
nsXULDocument::DoneLoadingScript(nsIUnicharStreamLoader* aLoader,
|
||||
nsString& aData,
|
||||
void* aRef,
|
||||
nsresult aStatus)
|
||||
nsXULDocument::OnUnicharStreamComplete(nsIUnicharStreamLoader* aLoader,
|
||||
nsresult aStatus,
|
||||
const PRUnichar* string)
|
||||
{
|
||||
nsString aData(string);
|
||||
// This is the completion routine that will be called when a
|
||||
// transcluded script completes. Evaluate the script if the load
|
||||
// was successful, then continue building content from the
|
||||
// prototype.
|
||||
nsresult rv;
|
||||
nsXULDocument* doc = NS_REINTERPRET_CAST(nsXULDocument*, aRef);
|
||||
|
||||
if (NS_SUCCEEDED(aStatus)) {
|
||||
rv = doc->EvaluateScript(doc->mCurrentScriptURL, aData, 1,
|
||||
doc->mCurrentScriptLanguageVersion);
|
||||
rv = EvaluateScript(mCurrentScriptURL, aData, 1,
|
||||
mCurrentScriptLanguageVersion);
|
||||
|
||||
if (IsChromeURI(doc->mDocumentURL)) {
|
||||
gXULCache->PutScript(doc->mCurrentScriptURL,
|
||||
if (IsChromeURI(mDocumentURL)) {
|
||||
gXULCache->PutScript(mCurrentScriptURL,
|
||||
aData,
|
||||
doc->mCurrentScriptLanguageVersion);
|
||||
mCurrentScriptLanguageVersion);
|
||||
}
|
||||
}
|
||||
|
||||
// balance the addref we added in LoadScript()
|
||||
NS_RELEASE(aLoader);
|
||||
|
||||
rv = doc->ResumeWalk();
|
||||
|
||||
NS_RELEASE(doc);
|
||||
rv = ResumeWalk();
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
|
|
@ -55,6 +55,7 @@
|
|||
#include "nsVoidArray.h"
|
||||
#include "nsWeakPtr.h"
|
||||
#include "nsWeakReference.h"
|
||||
#include "nsIUnicharStreamLoader.h"
|
||||
|
||||
class nsIAtom;
|
||||
class nsIHTMLElementFactory;
|
||||
|
@ -81,6 +82,7 @@ class nsXULDocument : public nsIDocument,
|
|||
public nsIJSScriptObject,
|
||||
public nsIScriptObjectOwner,
|
||||
public nsIHTMLContentContainer,
|
||||
public nsIUnicharStreamLoaderObserver,
|
||||
public nsSupportsWeakReference
|
||||
{
|
||||
public:
|
||||
|
@ -89,6 +91,7 @@ public:
|
|||
|
||||
// nsISupports interface
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIUNICHARSTREAMLOADEROBSERVER
|
||||
|
||||
// nsIDocument interface
|
||||
virtual nsIArena* GetArena();
|
||||
|
@ -602,15 +605,6 @@ protected:
|
|||
*/
|
||||
nsresult AddAttributes(nsXULPrototypeElement* aPrototype, nsIContent* aElement);
|
||||
|
||||
/**
|
||||
* Callback invoked when a transcluded script completes loading.
|
||||
*/
|
||||
static nsresult
|
||||
DoneLoadingScript(nsIUnicharStreamLoader* aLoader,
|
||||
nsString& aData,
|
||||
void* aRef,
|
||||
nsresult aStatus);
|
||||
|
||||
/**
|
||||
* The URL of the current transcluded script that is being loaded.
|
||||
* For document.write('<script src="nestedwrite.js"><\/script>') to work,
|
||||
|
|
Загрузка…
Ссылка в новой задаче