mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-26 06:11:37 +00:00
1) Added support for loading an XML document "out of band" from script and manipulating it via dom interfaces.
2) Fixed compile errors in XSL glue code that happened after the recent nsString landing by scc. 3) Added a check for a null URI before de-referencing it in nsCodeBasePrincipal.cpp.
This commit is contained in:
parent
cd3a69b5fc
commit
7e37fb4356
@ -253,7 +253,7 @@ nsresult
|
||||
nsCodebasePrincipal::Init(nsIURI *uri)
|
||||
{
|
||||
char *codebase;
|
||||
if (NS_FAILED(uri->GetSpec(&codebase)))
|
||||
if (uri == nsnull || NS_FAILED(uri->GetSpec(&codebase)))
|
||||
return NS_ERROR_FAILURE;
|
||||
if (NS_FAILED(mJSPrincipals.Init(codebase))) {
|
||||
nsCRT::free(codebase);
|
||||
|
@ -57,6 +57,8 @@ class nsIWordBreaker;
|
||||
class nsIDOMSelection;
|
||||
class nsIChannel;
|
||||
class nsIPrincipal;
|
||||
class nsIDOMDocument;
|
||||
class nsIDOMDocumentType;
|
||||
|
||||
// IID for the nsIDocument interface
|
||||
#define NS_IDOCUMENT_IID \
|
||||
@ -102,7 +104,8 @@ public:
|
||||
nsIChannel* aChannel,
|
||||
nsILoadGroup* aLoadGroup,
|
||||
nsISupports* aContainer,
|
||||
nsIStreamListener **aDocListener) = 0;
|
||||
nsIStreamListener **aDocListener,
|
||||
PRBool aReset) = 0;
|
||||
|
||||
NS_IMETHOD StopDocumentLoad() = 0;
|
||||
|
||||
@ -340,6 +343,12 @@ extern NS_LAYOUT nsresult
|
||||
extern NS_LAYOUT nsresult
|
||||
NS_NewDocumentFragment(nsIDOMDocumentFragment** aInstancePtrResult,
|
||||
nsIDocument* aOwnerDocument);
|
||||
extern NS_LAYOUT nsresult
|
||||
NS_NewDOMDocument(nsIDOMDocument** aInstancePtrResult,
|
||||
const nsString& aNamespaceURI,
|
||||
const nsString& aQualifiedName,
|
||||
nsIDOMDocumentType* aDoctype,
|
||||
nsIURI* aBaseURI);
|
||||
|
||||
// Note: The buffer passed into NewPostData(...) becomes owned by the IPostData
|
||||
// instance and is freed when the instance is destroyed...
|
||||
|
@ -369,7 +369,7 @@ class nsDOMImplementation : public nsIDOMDOMImplementation,
|
||||
public nsIScriptObjectOwner
|
||||
{
|
||||
public:
|
||||
nsDOMImplementation();
|
||||
nsDOMImplementation(nsIDocument* aDocument = nsnull);
|
||||
virtual ~nsDOMImplementation();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
@ -392,12 +392,14 @@ public:
|
||||
|
||||
protected:
|
||||
void *mScriptObject;
|
||||
nsCOMPtr<nsIDocument> mDocument;
|
||||
};
|
||||
|
||||
nsDOMImplementation::nsDOMImplementation()
|
||||
nsDOMImplementation::nsDOMImplementation(nsIDocument* aDocument)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
mScriptObject = nsnull;
|
||||
mDocument = aDocument;
|
||||
}
|
||||
|
||||
nsDOMImplementation::~nsDOMImplementation()
|
||||
@ -477,12 +479,20 @@ nsDOMImplementation::CreateDocument(const nsString& aNamespaceURI,
|
||||
const nsString& aQualifiedName,
|
||||
nsIDOMDocumentType* aDoctype,
|
||||
nsIDOMDocument** aReturn)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aReturn);
|
||||
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aReturn);
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
*aReturn = nsnull;
|
||||
|
||||
return NS_OK;
|
||||
nsIURI* baseURI;
|
||||
rv = mDocument->GetBaseURL(baseURI);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
NS_NewDOMDocument(aReturn, aNamespaceURI, aQualifiedName, aDoctype, baseURI);
|
||||
|
||||
NS_RELEASE(baseURI);
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
@ -788,7 +798,7 @@ NS_IMPL_RELEASE(nsDocument)
|
||||
nsresult nsDocument::Init()
|
||||
{
|
||||
nsresult rv = NS_NewHeapArena(&mArena, nsnull);
|
||||
|
||||
NS_NewNameSpaceManager(&mNameSpaceManager);
|
||||
return rv;
|
||||
}
|
||||
|
||||
@ -878,9 +888,13 @@ nsDocument::StartDocumentLoad(const char* aCommand,
|
||||
nsIChannel* aChannel,
|
||||
nsILoadGroup* aLoadGroup,
|
||||
nsISupports* aContainer,
|
||||
nsIStreamListener **aDocListener)
|
||||
nsIStreamListener **aDocListener,
|
||||
PRBool aReset)
|
||||
{
|
||||
return Reset(aChannel, aLoadGroup);
|
||||
nsresult rv = NS_OK;
|
||||
if (aReset)
|
||||
rv = Reset(aChannel, aLoadGroup);
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
@ -1894,7 +1908,7 @@ nsDocument::GetImplementation(nsIDOMDOMImplementation** aImplementation)
|
||||
{
|
||||
// For now, create a new implementation every time. This shouldn't
|
||||
// be a high bandwidth operation
|
||||
nsDOMImplementation* impl = new nsDOMImplementation();
|
||||
nsDOMImplementation* impl = new nsDOMImplementation(this);
|
||||
if (nsnull == impl) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
@ -2188,6 +2202,12 @@ nsDocument::GetHeight(PRInt32* aHeight)
|
||||
return result;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocument::Load (const nsString& aUrl, const nsString& aMimeType)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
//
|
||||
// nsIDOMNode methods
|
||||
//
|
||||
|
@ -128,7 +128,8 @@ public:
|
||||
nsIChannel* aChannel,
|
||||
nsILoadGroup* aLoadGroup,
|
||||
nsISupports* aContainer,
|
||||
nsIStreamListener **aDocListener);
|
||||
nsIStreamListener **aDocListener,
|
||||
PRBool aReset = PR_TRUE);
|
||||
|
||||
NS_IMETHOD StopDocumentLoad();
|
||||
|
||||
@ -357,6 +358,7 @@ public:
|
||||
NS_IMETHOD CreateRange(nsIDOMRange** aReturn);
|
||||
NS_IMETHOD GetWidth(PRInt32* aWidth);
|
||||
NS_IMETHOD GetHeight(PRInt32* aHeight);
|
||||
NS_IMETHOD Load (const nsString& aUrl, const nsString& aMimeType);
|
||||
|
||||
// nsIDOMNode interface
|
||||
NS_DECL_IDOMNODE
|
||||
|
@ -46,7 +46,8 @@ static char* mEventNames[] = {
|
||||
|
||||
nsDOMEvent::nsDOMEvent(nsIPresContext* aPresContext, nsEvent* aEvent) {
|
||||
mPresContext = aPresContext;
|
||||
NS_ADDREF(mPresContext);
|
||||
if (mPresContext)
|
||||
NS_ADDREF(mPresContext);
|
||||
mEvent = aEvent;
|
||||
mTarget = nsnull;
|
||||
mText = nsnull;
|
||||
@ -82,7 +83,7 @@ nsDOMEvent::nsDOMEvent(nsIPresContext* aPresContext, nsEvent* aEvent) {
|
||||
}
|
||||
|
||||
nsDOMEvent::~nsDOMEvent() {
|
||||
NS_RELEASE(mPresContext);
|
||||
NS_IF_RELEASE(mPresContext);
|
||||
NS_IF_RELEASE(mTarget);
|
||||
NS_IF_RELEASE(mTextRange);
|
||||
|
||||
@ -127,7 +128,7 @@ NS_METHOD nsDOMEvent::GetTarget(nsIDOMNode** aTarget)
|
||||
}
|
||||
|
||||
nsIEventStateManager *manager;
|
||||
nsIContent *targetContent;
|
||||
nsIContent *targetContent;
|
||||
|
||||
if (NS_OK == mPresContext->GetEventStateManager(&manager)) {
|
||||
manager->GetEventTargetContent(mEvent, &targetContent);
|
||||
|
@ -392,7 +392,8 @@ nsHTMLDocument::StartDocumentLoad(const char* aCommand,
|
||||
nsIChannel* aChannel,
|
||||
nsILoadGroup* aLoadGroup,
|
||||
nsISupports* aContainer,
|
||||
nsIStreamListener **aDocListener)
|
||||
nsIStreamListener **aDocListener,
|
||||
PRBool aReset)
|
||||
{
|
||||
PRBool needsParser=PR_TRUE;
|
||||
if (aCommand)
|
||||
@ -406,8 +407,8 @@ nsHTMLDocument::StartDocumentLoad(const char* aCommand,
|
||||
|
||||
nsresult rv = nsDocument::StartDocumentLoad(aCommand,
|
||||
aChannel, aLoadGroup,
|
||||
aContainer,
|
||||
aDocListener);
|
||||
aContainer,
|
||||
aDocListener, aReset);
|
||||
if (NS_FAILED(rv)) { return rv; }
|
||||
|
||||
nsAutoString charset; charset.AssignWithConversion("ISO-8859-1"); // fallback value in case webShell return error
|
||||
|
@ -68,7 +68,8 @@ public:
|
||||
nsIChannel* aChannel,
|
||||
nsILoadGroup* aLoadGroup,
|
||||
nsISupports* aContainer,
|
||||
nsIStreamListener **aDocListener);
|
||||
nsIStreamListener **aDocListener,
|
||||
PRBool aReset = PR_TRUE);
|
||||
|
||||
NS_IMETHOD StopDocumentLoad();
|
||||
|
||||
|
@ -62,7 +62,8 @@ public:
|
||||
nsIChannel* aChannel,
|
||||
nsILoadGroup* aLoadGroup,
|
||||
nsISupports* aContainer,
|
||||
nsIStreamListener **aDocListener);
|
||||
nsIStreamListener **aDocListener,
|
||||
PRBool aReset = PR_TRUE);
|
||||
|
||||
nsresult CreateSyntheticDocument();
|
||||
|
||||
@ -178,12 +179,13 @@ nsImageDocument::StartDocumentLoad(const char* aCommand,
|
||||
nsIChannel* aChannel,
|
||||
nsILoadGroup* aLoadGroup,
|
||||
nsISupports* aContainer,
|
||||
nsIStreamListener **aDocListener)
|
||||
nsIStreamListener **aDocListener,
|
||||
PRBool aReset)
|
||||
{
|
||||
nsresult rv = nsDocument::StartDocumentLoad(aCommand,
|
||||
aChannel, aLoadGroup,
|
||||
aContainer,
|
||||
aDocListener);
|
||||
aDocListener, aReset);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
@ -1132,7 +1132,7 @@ nsXMLContentSink::LoadXSLStyleSheet(nsIURI* aUrl, const nsString& aType)
|
||||
// Hook up the content sink to the parser's output and ask the parser
|
||||
// to start parsing the URL specified by aURL.
|
||||
parser->SetContentSink(sink);
|
||||
nsAutoString utf8("UTF-8");
|
||||
nsAutoString utf8(NS_ConvertASCIItoUCS2("UTF-8"));
|
||||
mDocument->SetDocumentCharacterSet(utf8);
|
||||
parser->SetDocumentCharset(utf8, kCharsetFromDocTypeDefault);
|
||||
parser->Parse(aUrl);
|
||||
@ -1281,7 +1281,7 @@ nsXMLContentSink::AddProcessingInstruction(const nsIParserNode& aNode)
|
||||
result = ProcessCSSStyleLink(node, href, alternate.EqualsWithConversion("yes"),
|
||||
title, type, media);
|
||||
#else
|
||||
result = ProcessStyleLink(node, href, alternate.Equals("yes"),
|
||||
result = ProcessStyleLink(node, href, alternate.EqualsWithConversion("yes"),
|
||||
title, type, media);
|
||||
#endif
|
||||
}
|
||||
|
@ -65,6 +65,7 @@
|
||||
#include "nsCharsetDetectionAdaptorCID.h"
|
||||
#include "nsICharsetAlias.h"
|
||||
#include "nsIParserFilter.h"
|
||||
#include "nsNetUtil.h"
|
||||
|
||||
|
||||
// XXX The XML world depends on the html atoms
|
||||
@ -92,6 +93,7 @@ static PRBool gInitDetector = PR_FALSE;
|
||||
static PRBool gPlugDetector = PR_FALSE;
|
||||
static NS_DEFINE_IID(kIParserFilterIID, NS_IPARSERFILTER_IID);
|
||||
|
||||
static const char* kLoadAsData = "loadAsData";
|
||||
|
||||
// ==================================================================
|
||||
// =
|
||||
@ -121,6 +123,20 @@ MyPrefChangedCallback(const char*aPrefName, void* instance_data)
|
||||
return 0;
|
||||
}
|
||||
|
||||
NS_LAYOUT nsresult
|
||||
NS_NewDOMDocument(nsIDOMDocument** aInstancePtrResult,
|
||||
const nsString& aNamespaceURI,
|
||||
const nsString& aQualifiedName,
|
||||
nsIDOMDocumentType* aDoctype,
|
||||
nsIURI* aBaseURI)
|
||||
{
|
||||
// XXX Ignoring the namespace, qualified name, and doctype parameters for now
|
||||
nsXMLDocument* doc = new nsXMLDocument(aBaseURI);
|
||||
if (doc == nsnull)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
return doc->QueryInterface(kIDOMDocumentIID, (void**) aInstancePtrResult);
|
||||
}
|
||||
|
||||
|
||||
NS_LAYOUT nsresult
|
||||
NS_NewXMLDocument(nsIDocument** aInstancePtrResult)
|
||||
@ -131,13 +147,15 @@ NS_NewXMLDocument(nsIDocument** aInstancePtrResult)
|
||||
return doc->QueryInterface(kIDocumentIID, (void**) aInstancePtrResult);
|
||||
}
|
||||
|
||||
nsXMLDocument::nsXMLDocument()
|
||||
nsXMLDocument::nsXMLDocument(nsIURI* aBaseURI)
|
||||
{
|
||||
mParser = nsnull;
|
||||
mAttrStyleSheet = nsnull;
|
||||
mInlineStyleSheet = nsnull;
|
||||
mCSSLoader = nsnull;
|
||||
|
||||
mDocumentURL = aBaseURI;
|
||||
NS_IF_ADDREF(mDocumentURL);
|
||||
|
||||
#ifdef XSL
|
||||
mTransformMediator = nsnull;
|
||||
#endif
|
||||
@ -234,17 +252,47 @@ nsXMLDocument::GetContentType(nsString& aContentType) const
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXMLDocument::Load(const nsString& aUrl, const nsString& aMimeType)
|
||||
{
|
||||
nsCOMPtr<nsIChannel> channel;
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
// Create a new URI and channel
|
||||
rv = NS_NewURI(getter_AddRefs(uri), aUrl, mDocumentURL);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
rv = NS_OpenURI(getter_AddRefs(channel), uri, nsnull);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// Prepare for loading the XML document "into oneself"
|
||||
nsCOMPtr<nsIStreamListener> listener;
|
||||
if (NS_FAILED(rv = StartDocumentLoad(kLoadAsData, channel,
|
||||
nsnull, nsnull,
|
||||
getter_AddRefs(listener),
|
||||
PR_FALSE))) {
|
||||
NS_ERROR("nsXMLDocument::Load: Failed to start the document load.");
|
||||
return rv;
|
||||
}
|
||||
|
||||
// Start an asynchronous read of the XML document
|
||||
rv = channel->AsyncRead(listener, nsnull);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXMLDocument::StartDocumentLoad(const char* aCommand,
|
||||
nsIChannel* aChannel,
|
||||
nsILoadGroup* aLoadGroup,
|
||||
nsISupports* aContainer,
|
||||
nsIStreamListener **aDocListener)
|
||||
nsIStreamListener **aDocListener,
|
||||
PRBool aReset)
|
||||
{
|
||||
nsresult rv = nsDocument::StartDocumentLoad(aCommand,
|
||||
aChannel, aLoadGroup,
|
||||
aContainer,
|
||||
aDocListener);
|
||||
aDocListener, aReset);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
@ -525,8 +573,20 @@ nsXMLDocument::StartDocumentLoad(const char* aCommand,
|
||||
NS_IMETHODIMP
|
||||
nsXMLDocument::EndLoad()
|
||||
{
|
||||
nsAutoString cmd;
|
||||
mParser->GetCommand(cmd);
|
||||
NS_IF_RELEASE(mParser);
|
||||
return nsDocument::EndLoad();
|
||||
if (cmd.EqualsWithConversion(kLoadAsData)) {
|
||||
// Generate a document load event for the case when an XML document was loaded
|
||||
// as pure data without any presentation attached to it.
|
||||
nsCOMPtr<nsIScriptGlobalObject> scriptGlobal;
|
||||
nsEventStatus status = nsEventStatus_eIgnore;
|
||||
nsMouseEvent event;
|
||||
event.eventStructType = NS_EVENT;
|
||||
event.message = NS_PAGE_LOAD;
|
||||
HandleDOMEvent(nsnull, &event, nsnull, NS_EVENT_FLAG_INIT, &status);
|
||||
}
|
||||
return nsDocument::EndLoad();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -40,7 +40,7 @@ class nsXMLDocument : public nsMarkupDocument,
|
||||
public nsIHTMLContentContainer
|
||||
{
|
||||
public:
|
||||
nsXMLDocument();
|
||||
nsXMLDocument(nsIURI* aBaseURI = nsnull);
|
||||
virtual ~nsXMLDocument();
|
||||
|
||||
NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr);
|
||||
@ -54,7 +54,8 @@ public:
|
||||
nsIChannel* aChannel,
|
||||
nsILoadGroup* aLoadGroup,
|
||||
nsISupports* aContainer,
|
||||
nsIStreamListener **aDocListener);
|
||||
nsIStreamListener **aDocListener,
|
||||
PRBool aReset = PR_TRUE);
|
||||
|
||||
NS_IMETHOD EndLoad();
|
||||
|
||||
@ -82,7 +83,7 @@ public:
|
||||
NS_IMETHOD GetElementsByTagNameNS(const nsString& aNamespaceURI,
|
||||
const nsString& aLocalName,
|
||||
nsIDOMNodeList** aReturn);
|
||||
|
||||
NS_IMETHOD Load(const nsString& aUrl, const nsString& aMimeType);
|
||||
|
||||
// nsIXMLDocument interface
|
||||
NS_IMETHOD GetContentById(const nsString& aName, nsIContent** aContent);
|
||||
|
@ -71,7 +71,7 @@ nsTransformMediator::~nsTransformMediator()
|
||||
static
|
||||
nsresult ConstructProgID(nsString& aProgID, const nsString& aMimeType)
|
||||
{
|
||||
aProgID = kTransformerProgIDPrefix;
|
||||
aProgID.AssignWithConversion(kTransformerProgIDPrefix);
|
||||
aProgID.Append(aMimeType);
|
||||
|
||||
return NS_OK;
|
||||
|
@ -693,7 +693,8 @@ nsXULDocument::StartDocumentLoad(const char* aCommand,
|
||||
nsIChannel* aChannel,
|
||||
nsILoadGroup* aLoadGroup,
|
||||
nsISupports* aContainer,
|
||||
nsIStreamListener **aDocListener)
|
||||
nsIStreamListener **aDocListener,
|
||||
PRBool aReset)
|
||||
{
|
||||
nsresult rv;
|
||||
mCommand.AssignWithConversion(aCommand);
|
||||
@ -2686,6 +2687,13 @@ nsXULDocument::GetHeight(PRInt32* aHeight)
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXULDocument::Load(const nsString& aUrl, const nsString& aMimeType)
|
||||
{
|
||||
NS_NOTREACHED("nsXULDocument::Load");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
//
|
||||
// nsIDOMXULDocument interface
|
||||
|
@ -116,7 +116,8 @@ public:
|
||||
nsIChannel* aChannel,
|
||||
nsILoadGroup* aLoadGroup,
|
||||
nsISupports* aContainer,
|
||||
nsIStreamListener **aDocListener);
|
||||
nsIStreamListener **aDocListener,
|
||||
PRBool aReset);
|
||||
|
||||
NS_IMETHOD StopDocumentLoad();
|
||||
|
||||
@ -343,6 +344,7 @@ public:
|
||||
NS_IMETHOD CreateRange(nsIDOMRange** aRange);
|
||||
NS_IMETHOD GetWidth(PRInt32* aWidth);
|
||||
NS_IMETHOD GetHeight(PRInt32* aHeight);
|
||||
NS_IMETHOD Load (const nsString& aUrl, const nsString& aMimeType);
|
||||
|
||||
// nsIDOMXULDocument interface
|
||||
NS_DECL_IDOMXULDOCUMENT
|
||||
|
@ -294,7 +294,7 @@ nsDocShell::SetDocument(nsIDOMDocument *aDOMDoc, nsIDOMElement *aRootNode)
|
||||
nsCOMPtr<nsIStreamListener> outStreamListener;
|
||||
NS_ENSURE_SUCCESS(doc->StartDocumentLoad("view", dummyChannel, nsnull,
|
||||
NS_STATIC_CAST(nsIContentViewerContainer*, this),
|
||||
getter_AddRefs(outStreamListener)), NS_ERROR_FAILURE);
|
||||
getter_AddRefs(outStreamListener), PR_TRUE), NS_ERROR_FAILURE);
|
||||
NS_ENSURE_SUCCESS(FireStartDocumentLoad(mDocLoader, uri, "load"), NS_ERROR_FAILURE);
|
||||
|
||||
// (5) hook up the document and its content
|
||||
|
@ -1673,8 +1673,12 @@ NS_IMETHODIMP nsWebShell::SetDocument(nsIDOMDocument *aDOMDoc,
|
||||
nsCOMPtr<nsIStreamListener> outStreamListener; // a valid pointer is required for the returned stream listener
|
||||
// XXX: warning: magic cookie! should get string "view delayedContentLoad"
|
||||
// from somewhere, maybe nsIHTMLDocument?
|
||||
NS_ENSURE_SUCCESS(doc->StartDocumentLoad("view delayedContentLoad", dummyChannel, nsnull, NS_STATIC_CAST(nsIContentViewerContainer*, (nsIWebShell*)this),
|
||||
getter_AddRefs(outStreamListener)),
|
||||
NS_ENSURE_SUCCESS(doc->StartDocumentLoad("view delayedContentLoad",
|
||||
dummyChannel,
|
||||
nsnull,
|
||||
NS_STATIC_CAST(nsIContentViewerContainer*, (nsIWebShell*)this),
|
||||
getter_AddRefs(outStreamListener),
|
||||
PR_TRUE),
|
||||
NS_ERROR_FAILURE);
|
||||
NS_ENSURE_SUCCESS(OnStartDocumentLoad(mDocLoader, uri, "load"), NS_ERROR_FAILURE);
|
||||
|
||||
|
@ -48,6 +48,8 @@ public:
|
||||
NS_IMETHOD CreateElementWithNameSpace(const nsString& aTagName, const nsString& aNameSpace, nsIDOMElement** aReturn)=0;
|
||||
|
||||
NS_IMETHOD CreateRange(nsIDOMRange** aReturn)=0;
|
||||
|
||||
NS_IMETHOD Load(const nsString& aUrl, const nsString& aMimeType)=0;
|
||||
};
|
||||
|
||||
|
||||
@ -57,6 +59,7 @@ public:
|
||||
NS_IMETHOD GetCharacterSet(nsString& aCharacterSet); \
|
||||
NS_IMETHOD CreateElementWithNameSpace(const nsString& aTagName, const nsString& aNameSpace, nsIDOMElement** aReturn); \
|
||||
NS_IMETHOD CreateRange(nsIDOMRange** aReturn); \
|
||||
NS_IMETHOD Load(const nsString& aUrl, const nsString& aMimeType); \
|
||||
|
||||
|
||||
|
||||
@ -66,6 +69,7 @@ public:
|
||||
NS_IMETHOD GetCharacterSet(nsString& aCharacterSet) { return _to GetCharacterSet(aCharacterSet); } \
|
||||
NS_IMETHOD CreateElementWithNameSpace(const nsString& aTagName, const nsString& aNameSpace, nsIDOMElement** aReturn) { return _to CreateElementWithNameSpace(aTagName, aNameSpace, aReturn); } \
|
||||
NS_IMETHOD CreateRange(nsIDOMRange** aReturn) { return _to CreateRange(aReturn); } \
|
||||
NS_IMETHOD Load(const nsString& aUrl, const nsString& aMimeType) { return _to Load(aUrl, aMimeType); } \
|
||||
|
||||
|
||||
#endif // nsIDOMNSDocument_h__
|
||||
|
@ -66,5 +66,7 @@ interface NSDocument {
|
||||
Element createElementWithNameSpace(in DOMString tagName,
|
||||
in DOMString nameSpace)
|
||||
raises(DOMException);
|
||||
Range createRange();
|
||||
};
|
||||
Range createRange();
|
||||
void load(in DOMString url,
|
||||
in DOMString mimeType);
|
||||
};
|
@ -717,6 +717,7 @@ enum nsDOMProp {
|
||||
NS_DOM_PROP_NSDOCUMENT_CREATEELEMENTWITHNAMESPACE,
|
||||
NS_DOM_PROP_NSDOCUMENT_CREATERANGE,
|
||||
NS_DOM_PROP_NSDOCUMENT_HEIGHT,
|
||||
NS_DOM_PROP_NSDOCUMENT_LOAD,
|
||||
NS_DOM_PROP_NSDOCUMENT_WIDTH,
|
||||
NS_DOM_PROP_NSHTMLANCHORELEMENT_HASH,
|
||||
NS_DOM_PROP_NSHTMLANCHORELEMENT_HOST,
|
||||
|
@ -716,6 +716,7 @@
|
||||
"nsdocument.createelementwithnamespace", \
|
||||
"nsdocument.createrange", \
|
||||
"nsdocument.height", \
|
||||
"nsdocument.load", \
|
||||
"nsdocument.width", \
|
||||
"nshtmlanchorelement.hash", \
|
||||
"nshtmlanchorelement.host", \
|
||||
|
@ -1016,6 +1016,54 @@ NSDocumentCreateRange(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsv
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Native method Load
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
NSDocumentLoad(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
nsIDOMDocument *privateThis = (nsIDOMDocument*)nsJSUtils::nsGetNativeThis(cx, obj);
|
||||
nsCOMPtr<nsIDOMNSDocument> nativeThis;
|
||||
nsresult result = NS_OK;
|
||||
if (NS_OK != privateThis->QueryInterface(kINSDocumentIID, getter_AddRefs(nativeThis))) {
|
||||
return nsJSUtils::nsReportError(cx, obj, NS_ERROR_DOM_WRONG_TYPE_ERR);
|
||||
}
|
||||
|
||||
nsAutoString b0;
|
||||
nsAutoString b1;
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
if (!nativeThis) {
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
{
|
||||
*rval = JSVAL_NULL;
|
||||
nsIScriptSecurityManager *secMan = nsJSUtils::nsGetSecurityManager(cx, obj);
|
||||
if (!secMan)
|
||||
return PR_FALSE;
|
||||
result = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_NSDOCUMENT_LOAD, PR_FALSE);
|
||||
if (NS_FAILED(result)) {
|
||||
return nsJSUtils::nsReportError(cx, obj, result);
|
||||
}
|
||||
if (argc < 2) {
|
||||
return nsJSUtils::nsReportError(cx, obj, NS_ERROR_DOM_TOO_FEW_PARAMETERS_ERR);
|
||||
}
|
||||
|
||||
nsJSUtils::nsConvertJSValToString(b0, cx, argv[0]);
|
||||
nsJSUtils::nsConvertJSValToString(b1, cx, argv[1]);
|
||||
|
||||
result = nativeThis->Load(b0, b1);
|
||||
if (NS_FAILED(result)) {
|
||||
return nsJSUtils::nsReportError(cx, obj, result);
|
||||
}
|
||||
|
||||
*rval = JSVAL_VOID;
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************/
|
||||
//
|
||||
// class for Document
|
||||
@ -1074,6 +1122,7 @@ static JSFunctionSpec DocumentMethods[] =
|
||||
{"getElementById", DocumentGetElementById, 1},
|
||||
{"createElementWithNameSpace", NSDocumentCreateElementWithNameSpace, 2},
|
||||
{"createRange", NSDocumentCreateRange, 0},
|
||||
{"load", NSDocumentLoad, 2},
|
||||
{0}
|
||||
};
|
||||
|
||||
|
@ -178,7 +178,7 @@ void nsExpatTokenizer::SetupExpatParser(void) {
|
||||
nsExpatTokenizer::nsExpatTokenizer(nsString* aURL) : nsHTMLTokenizer() {
|
||||
NS_INIT_REFCNT();
|
||||
mBytesParsed = 0;
|
||||
mState = new XMLParserState;
|
||||
mState = new XMLParserState;
|
||||
mState->tokenRecycler = (CTokenRecycler*)GetTokenRecycler();
|
||||
mState->cdataToken = nsnull;
|
||||
mState->parser = nsnull;
|
||||
|
@ -149,6 +149,7 @@ class nsIParser : public nsISupports {
|
||||
* @param aCommand -- ptrs to string that contains command
|
||||
* @return nada
|
||||
*/
|
||||
virtual void GetCommand(nsString& aCommand)=0;
|
||||
virtual void SetCommand(const char* aCommand)=0;
|
||||
virtual void SetCommand(eParserCommands aParserCommand)=0;
|
||||
|
||||
|
@ -305,6 +305,11 @@ nsIParserFilter * nsParser::SetParserFilter(nsIParserFilter * aFilter)
|
||||
}
|
||||
|
||||
|
||||
void nsParser::GetCommand(nsString& aCommand)
|
||||
{
|
||||
aCommand = mCommandStr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Call this method once you've created a parser, and want to instruct it
|
||||
* about the command which caused the parser to be constructed. For example,
|
||||
@ -319,6 +324,7 @@ void nsParser::SetCommand(const char* aCommand){
|
||||
if(theCommand.Equals(kViewSourceCommand))
|
||||
mCommand=eViewSource;
|
||||
else mCommand=eViewNormal;
|
||||
mCommandStr.AssignWithConversion(aCommand);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -133,6 +133,7 @@ CLASS_EXPORT_HTMLPARS nsParser : public nsIParser, public nsIStreamListener {
|
||||
* @param aContentSink -- ptr to content sink that will receive output
|
||||
* @return ptr to previously set contentsink (usually null)
|
||||
*/
|
||||
virtual void GetCommand(nsString& aCommand);
|
||||
virtual void SetCommand(const char* aCommand);
|
||||
virtual void SetCommand(eParserCommands aParserCommand);
|
||||
|
||||
@ -384,6 +385,7 @@ protected:
|
||||
nsresult mInternalState;
|
||||
CObserverService mObserverService;
|
||||
PRBool mObserversEnabled;
|
||||
nsString mCommandStr;
|
||||
|
||||
public:
|
||||
MOZ_TIMER_DECLARE(mParseTime)
|
||||
|
@ -57,6 +57,8 @@ class nsIWordBreaker;
|
||||
class nsIDOMSelection;
|
||||
class nsIChannel;
|
||||
class nsIPrincipal;
|
||||
class nsIDOMDocument;
|
||||
class nsIDOMDocumentType;
|
||||
|
||||
// IID for the nsIDocument interface
|
||||
#define NS_IDOCUMENT_IID \
|
||||
@ -102,7 +104,8 @@ public:
|
||||
nsIChannel* aChannel,
|
||||
nsILoadGroup* aLoadGroup,
|
||||
nsISupports* aContainer,
|
||||
nsIStreamListener **aDocListener) = 0;
|
||||
nsIStreamListener **aDocListener,
|
||||
PRBool aReset) = 0;
|
||||
|
||||
NS_IMETHOD StopDocumentLoad() = 0;
|
||||
|
||||
@ -340,6 +343,12 @@ extern NS_LAYOUT nsresult
|
||||
extern NS_LAYOUT nsresult
|
||||
NS_NewDocumentFragment(nsIDOMDocumentFragment** aInstancePtrResult,
|
||||
nsIDocument* aOwnerDocument);
|
||||
extern NS_LAYOUT nsresult
|
||||
NS_NewDOMDocument(nsIDOMDocument** aInstancePtrResult,
|
||||
const nsString& aNamespaceURI,
|
||||
const nsString& aQualifiedName,
|
||||
nsIDOMDocumentType* aDoctype,
|
||||
nsIURI* aBaseURI);
|
||||
|
||||
// Note: The buffer passed into NewPostData(...) becomes owned by the IPostData
|
||||
// instance and is freed when the instance is destroyed...
|
||||
|
@ -369,7 +369,7 @@ class nsDOMImplementation : public nsIDOMDOMImplementation,
|
||||
public nsIScriptObjectOwner
|
||||
{
|
||||
public:
|
||||
nsDOMImplementation();
|
||||
nsDOMImplementation(nsIDocument* aDocument = nsnull);
|
||||
virtual ~nsDOMImplementation();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
@ -392,12 +392,14 @@ public:
|
||||
|
||||
protected:
|
||||
void *mScriptObject;
|
||||
nsCOMPtr<nsIDocument> mDocument;
|
||||
};
|
||||
|
||||
nsDOMImplementation::nsDOMImplementation()
|
||||
nsDOMImplementation::nsDOMImplementation(nsIDocument* aDocument)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
mScriptObject = nsnull;
|
||||
mDocument = aDocument;
|
||||
}
|
||||
|
||||
nsDOMImplementation::~nsDOMImplementation()
|
||||
@ -477,12 +479,20 @@ nsDOMImplementation::CreateDocument(const nsString& aNamespaceURI,
|
||||
const nsString& aQualifiedName,
|
||||
nsIDOMDocumentType* aDoctype,
|
||||
nsIDOMDocument** aReturn)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aReturn);
|
||||
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aReturn);
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
*aReturn = nsnull;
|
||||
|
||||
return NS_OK;
|
||||
nsIURI* baseURI;
|
||||
rv = mDocument->GetBaseURL(baseURI);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
NS_NewDOMDocument(aReturn, aNamespaceURI, aQualifiedName, aDoctype, baseURI);
|
||||
|
||||
NS_RELEASE(baseURI);
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
@ -788,7 +798,7 @@ NS_IMPL_RELEASE(nsDocument)
|
||||
nsresult nsDocument::Init()
|
||||
{
|
||||
nsresult rv = NS_NewHeapArena(&mArena, nsnull);
|
||||
|
||||
NS_NewNameSpaceManager(&mNameSpaceManager);
|
||||
return rv;
|
||||
}
|
||||
|
||||
@ -878,9 +888,13 @@ nsDocument::StartDocumentLoad(const char* aCommand,
|
||||
nsIChannel* aChannel,
|
||||
nsILoadGroup* aLoadGroup,
|
||||
nsISupports* aContainer,
|
||||
nsIStreamListener **aDocListener)
|
||||
nsIStreamListener **aDocListener,
|
||||
PRBool aReset)
|
||||
{
|
||||
return Reset(aChannel, aLoadGroup);
|
||||
nsresult rv = NS_OK;
|
||||
if (aReset)
|
||||
rv = Reset(aChannel, aLoadGroup);
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
@ -1894,7 +1908,7 @@ nsDocument::GetImplementation(nsIDOMDOMImplementation** aImplementation)
|
||||
{
|
||||
// For now, create a new implementation every time. This shouldn't
|
||||
// be a high bandwidth operation
|
||||
nsDOMImplementation* impl = new nsDOMImplementation();
|
||||
nsDOMImplementation* impl = new nsDOMImplementation(this);
|
||||
if (nsnull == impl) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
@ -2188,6 +2202,12 @@ nsDocument::GetHeight(PRInt32* aHeight)
|
||||
return result;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocument::Load (const nsString& aUrl, const nsString& aMimeType)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
//
|
||||
// nsIDOMNode methods
|
||||
//
|
||||
|
@ -128,7 +128,8 @@ public:
|
||||
nsIChannel* aChannel,
|
||||
nsILoadGroup* aLoadGroup,
|
||||
nsISupports* aContainer,
|
||||
nsIStreamListener **aDocListener);
|
||||
nsIStreamListener **aDocListener,
|
||||
PRBool aReset = PR_TRUE);
|
||||
|
||||
NS_IMETHOD StopDocumentLoad();
|
||||
|
||||
@ -357,6 +358,7 @@ public:
|
||||
NS_IMETHOD CreateRange(nsIDOMRange** aReturn);
|
||||
NS_IMETHOD GetWidth(PRInt32* aWidth);
|
||||
NS_IMETHOD GetHeight(PRInt32* aHeight);
|
||||
NS_IMETHOD Load (const nsString& aUrl, const nsString& aMimeType);
|
||||
|
||||
// nsIDOMNode interface
|
||||
NS_DECL_IDOMNODE
|
||||
|
@ -405,7 +405,7 @@ nsLayoutDLF::CreateDocument(const char* aCommand,
|
||||
// Initialize the document to begin loading the data. An
|
||||
// nsIStreamListener connected to the parser is returned in
|
||||
// aDocListener.
|
||||
rv = doc->StartDocumentLoad(aCommand, aChannel, aLoadGroup, aContainer, aDocListener);
|
||||
rv = doc->StartDocumentLoad(aCommand, aChannel, aLoadGroup, aContainer, aDocListener, PR_TRUE);
|
||||
if (NS_FAILED(rv))
|
||||
break;
|
||||
|
||||
@ -496,7 +496,7 @@ nsLayoutDLF::CreateRDFDocument(const char* aCommand,
|
||||
* An nsIStreamListener connected to the parser is returned in
|
||||
* aDocListener.
|
||||
*/
|
||||
rv = doc->StartDocumentLoad(aCommand, aChannel, aLoadGroup, aContainer, aDocListener);
|
||||
rv = doc->StartDocumentLoad(aCommand, aChannel, aLoadGroup, aContainer, aDocListener, PR_TRUE);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
/*
|
||||
* Bind the document to the Content Viewer...
|
||||
|
@ -1,3 +1,5 @@
|
||||
@namespace xlink url("http://www.w3.org/1999/xlink");
|
||||
|
||||
Documentation {
|
||||
display: block;
|
||||
font-family: Verdana, sans-serif;
|
||||
@ -56,12 +58,12 @@ Components {
|
||||
}
|
||||
|
||||
/* workaround for above rule not working */
|
||||
*[xlink:type] {
|
||||
*[xlink|type] {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
/* workaround for above rule not working */
|
||||
*[xlink:show="replace"] {
|
||||
*[xlink|show="replace"] {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
|
@ -46,7 +46,8 @@ static char* mEventNames[] = {
|
||||
|
||||
nsDOMEvent::nsDOMEvent(nsIPresContext* aPresContext, nsEvent* aEvent) {
|
||||
mPresContext = aPresContext;
|
||||
NS_ADDREF(mPresContext);
|
||||
if (mPresContext)
|
||||
NS_ADDREF(mPresContext);
|
||||
mEvent = aEvent;
|
||||
mTarget = nsnull;
|
||||
mText = nsnull;
|
||||
@ -82,7 +83,7 @@ nsDOMEvent::nsDOMEvent(nsIPresContext* aPresContext, nsEvent* aEvent) {
|
||||
}
|
||||
|
||||
nsDOMEvent::~nsDOMEvent() {
|
||||
NS_RELEASE(mPresContext);
|
||||
NS_IF_RELEASE(mPresContext);
|
||||
NS_IF_RELEASE(mTarget);
|
||||
NS_IF_RELEASE(mTextRange);
|
||||
|
||||
@ -127,7 +128,7 @@ NS_METHOD nsDOMEvent::GetTarget(nsIDOMNode** aTarget)
|
||||
}
|
||||
|
||||
nsIEventStateManager *manager;
|
||||
nsIContent *targetContent;
|
||||
nsIContent *targetContent;
|
||||
|
||||
if (NS_OK == mPresContext->GetEventStateManager(&manager)) {
|
||||
manager->GetEventTargetContent(mEvent, &targetContent);
|
||||
|
@ -392,7 +392,8 @@ nsHTMLDocument::StartDocumentLoad(const char* aCommand,
|
||||
nsIChannel* aChannel,
|
||||
nsILoadGroup* aLoadGroup,
|
||||
nsISupports* aContainer,
|
||||
nsIStreamListener **aDocListener)
|
||||
nsIStreamListener **aDocListener,
|
||||
PRBool aReset)
|
||||
{
|
||||
PRBool needsParser=PR_TRUE;
|
||||
if (aCommand)
|
||||
@ -406,8 +407,8 @@ nsHTMLDocument::StartDocumentLoad(const char* aCommand,
|
||||
|
||||
nsresult rv = nsDocument::StartDocumentLoad(aCommand,
|
||||
aChannel, aLoadGroup,
|
||||
aContainer,
|
||||
aDocListener);
|
||||
aContainer,
|
||||
aDocListener, aReset);
|
||||
if (NS_FAILED(rv)) { return rv; }
|
||||
|
||||
nsAutoString charset; charset.AssignWithConversion("ISO-8859-1"); // fallback value in case webShell return error
|
||||
|
@ -68,7 +68,8 @@ public:
|
||||
nsIChannel* aChannel,
|
||||
nsILoadGroup* aLoadGroup,
|
||||
nsISupports* aContainer,
|
||||
nsIStreamListener **aDocListener);
|
||||
nsIStreamListener **aDocListener,
|
||||
PRBool aReset = PR_TRUE);
|
||||
|
||||
NS_IMETHOD StopDocumentLoad();
|
||||
|
||||
|
@ -62,7 +62,8 @@ public:
|
||||
nsIChannel* aChannel,
|
||||
nsILoadGroup* aLoadGroup,
|
||||
nsISupports* aContainer,
|
||||
nsIStreamListener **aDocListener);
|
||||
nsIStreamListener **aDocListener,
|
||||
PRBool aReset = PR_TRUE);
|
||||
|
||||
nsresult CreateSyntheticDocument();
|
||||
|
||||
@ -178,12 +179,13 @@ nsImageDocument::StartDocumentLoad(const char* aCommand,
|
||||
nsIChannel* aChannel,
|
||||
nsILoadGroup* aLoadGroup,
|
||||
nsISupports* aContainer,
|
||||
nsIStreamListener **aDocListener)
|
||||
nsIStreamListener **aDocListener,
|
||||
PRBool aReset)
|
||||
{
|
||||
nsresult rv = nsDocument::StartDocumentLoad(aCommand,
|
||||
aChannel, aLoadGroup,
|
||||
aContainer,
|
||||
aDocListener);
|
||||
aDocListener, aReset);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
@ -69,6 +69,9 @@ LLIBS= \
|
||||
!ifdef MOZ_SVG
|
||||
$(DIST)\lib\raptorsvgbase_s.lib \
|
||||
$(DIST)\lib\raptorsvgcontent_s.lib \
|
||||
!endif
|
||||
!ifdef MOZ_XSL
|
||||
$(DIST)\lib\raptorxsldoc_s.lib \
|
||||
!endif
|
||||
$(DIST)\lib\img32$(VERSION_NUMBER).lib \
|
||||
$(DIST)\lib\util.lib \
|
||||
|
@ -1132,7 +1132,7 @@ nsXMLContentSink::LoadXSLStyleSheet(nsIURI* aUrl, const nsString& aType)
|
||||
// Hook up the content sink to the parser's output and ask the parser
|
||||
// to start parsing the URL specified by aURL.
|
||||
parser->SetContentSink(sink);
|
||||
nsAutoString utf8("UTF-8");
|
||||
nsAutoString utf8(NS_ConvertASCIItoUCS2("UTF-8"));
|
||||
mDocument->SetDocumentCharacterSet(utf8);
|
||||
parser->SetDocumentCharset(utf8, kCharsetFromDocTypeDefault);
|
||||
parser->Parse(aUrl);
|
||||
@ -1281,7 +1281,7 @@ nsXMLContentSink::AddProcessingInstruction(const nsIParserNode& aNode)
|
||||
result = ProcessCSSStyleLink(node, href, alternate.EqualsWithConversion("yes"),
|
||||
title, type, media);
|
||||
#else
|
||||
result = ProcessStyleLink(node, href, alternate.Equals("yes"),
|
||||
result = ProcessStyleLink(node, href, alternate.EqualsWithConversion("yes"),
|
||||
title, type, media);
|
||||
#endif
|
||||
}
|
||||
|
@ -65,6 +65,7 @@
|
||||
#include "nsCharsetDetectionAdaptorCID.h"
|
||||
#include "nsICharsetAlias.h"
|
||||
#include "nsIParserFilter.h"
|
||||
#include "nsNetUtil.h"
|
||||
|
||||
|
||||
// XXX The XML world depends on the html atoms
|
||||
@ -92,6 +93,7 @@ static PRBool gInitDetector = PR_FALSE;
|
||||
static PRBool gPlugDetector = PR_FALSE;
|
||||
static NS_DEFINE_IID(kIParserFilterIID, NS_IPARSERFILTER_IID);
|
||||
|
||||
static const char* kLoadAsData = "loadAsData";
|
||||
|
||||
// ==================================================================
|
||||
// =
|
||||
@ -121,6 +123,20 @@ MyPrefChangedCallback(const char*aPrefName, void* instance_data)
|
||||
return 0;
|
||||
}
|
||||
|
||||
NS_LAYOUT nsresult
|
||||
NS_NewDOMDocument(nsIDOMDocument** aInstancePtrResult,
|
||||
const nsString& aNamespaceURI,
|
||||
const nsString& aQualifiedName,
|
||||
nsIDOMDocumentType* aDoctype,
|
||||
nsIURI* aBaseURI)
|
||||
{
|
||||
// XXX Ignoring the namespace, qualified name, and doctype parameters for now
|
||||
nsXMLDocument* doc = new nsXMLDocument(aBaseURI);
|
||||
if (doc == nsnull)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
return doc->QueryInterface(kIDOMDocumentIID, (void**) aInstancePtrResult);
|
||||
}
|
||||
|
||||
|
||||
NS_LAYOUT nsresult
|
||||
NS_NewXMLDocument(nsIDocument** aInstancePtrResult)
|
||||
@ -131,13 +147,15 @@ NS_NewXMLDocument(nsIDocument** aInstancePtrResult)
|
||||
return doc->QueryInterface(kIDocumentIID, (void**) aInstancePtrResult);
|
||||
}
|
||||
|
||||
nsXMLDocument::nsXMLDocument()
|
||||
nsXMLDocument::nsXMLDocument(nsIURI* aBaseURI)
|
||||
{
|
||||
mParser = nsnull;
|
||||
mAttrStyleSheet = nsnull;
|
||||
mInlineStyleSheet = nsnull;
|
||||
mCSSLoader = nsnull;
|
||||
|
||||
mDocumentURL = aBaseURI;
|
||||
NS_IF_ADDREF(mDocumentURL);
|
||||
|
||||
#ifdef XSL
|
||||
mTransformMediator = nsnull;
|
||||
#endif
|
||||
@ -234,17 +252,47 @@ nsXMLDocument::GetContentType(nsString& aContentType) const
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXMLDocument::Load(const nsString& aUrl, const nsString& aMimeType)
|
||||
{
|
||||
nsCOMPtr<nsIChannel> channel;
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
// Create a new URI and channel
|
||||
rv = NS_NewURI(getter_AddRefs(uri), aUrl, mDocumentURL);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
rv = NS_OpenURI(getter_AddRefs(channel), uri, nsnull);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// Prepare for loading the XML document "into oneself"
|
||||
nsCOMPtr<nsIStreamListener> listener;
|
||||
if (NS_FAILED(rv = StartDocumentLoad(kLoadAsData, channel,
|
||||
nsnull, nsnull,
|
||||
getter_AddRefs(listener),
|
||||
PR_FALSE))) {
|
||||
NS_ERROR("nsXMLDocument::Load: Failed to start the document load.");
|
||||
return rv;
|
||||
}
|
||||
|
||||
// Start an asynchronous read of the XML document
|
||||
rv = channel->AsyncRead(listener, nsnull);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXMLDocument::StartDocumentLoad(const char* aCommand,
|
||||
nsIChannel* aChannel,
|
||||
nsILoadGroup* aLoadGroup,
|
||||
nsISupports* aContainer,
|
||||
nsIStreamListener **aDocListener)
|
||||
nsIStreamListener **aDocListener,
|
||||
PRBool aReset)
|
||||
{
|
||||
nsresult rv = nsDocument::StartDocumentLoad(aCommand,
|
||||
aChannel, aLoadGroup,
|
||||
aContainer,
|
||||
aDocListener);
|
||||
aDocListener, aReset);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
@ -525,8 +573,20 @@ nsXMLDocument::StartDocumentLoad(const char* aCommand,
|
||||
NS_IMETHODIMP
|
||||
nsXMLDocument::EndLoad()
|
||||
{
|
||||
nsAutoString cmd;
|
||||
mParser->GetCommand(cmd);
|
||||
NS_IF_RELEASE(mParser);
|
||||
return nsDocument::EndLoad();
|
||||
if (cmd.EqualsWithConversion(kLoadAsData)) {
|
||||
// Generate a document load event for the case when an XML document was loaded
|
||||
// as pure data without any presentation attached to it.
|
||||
nsCOMPtr<nsIScriptGlobalObject> scriptGlobal;
|
||||
nsEventStatus status = nsEventStatus_eIgnore;
|
||||
nsMouseEvent event;
|
||||
event.eventStructType = NS_EVENT;
|
||||
event.message = NS_PAGE_LOAD;
|
||||
HandleDOMEvent(nsnull, &event, nsnull, NS_EVENT_FLAG_INIT, &status);
|
||||
}
|
||||
return nsDocument::EndLoad();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -40,7 +40,7 @@ class nsXMLDocument : public nsMarkupDocument,
|
||||
public nsIHTMLContentContainer
|
||||
{
|
||||
public:
|
||||
nsXMLDocument();
|
||||
nsXMLDocument(nsIURI* aBaseURI = nsnull);
|
||||
virtual ~nsXMLDocument();
|
||||
|
||||
NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr);
|
||||
@ -54,7 +54,8 @@ public:
|
||||
nsIChannel* aChannel,
|
||||
nsILoadGroup* aLoadGroup,
|
||||
nsISupports* aContainer,
|
||||
nsIStreamListener **aDocListener);
|
||||
nsIStreamListener **aDocListener,
|
||||
PRBool aReset = PR_TRUE);
|
||||
|
||||
NS_IMETHOD EndLoad();
|
||||
|
||||
@ -82,7 +83,7 @@ public:
|
||||
NS_IMETHOD GetElementsByTagNameNS(const nsString& aNamespaceURI,
|
||||
const nsString& aLocalName,
|
||||
nsIDOMNodeList** aReturn);
|
||||
|
||||
NS_IMETHOD Load(const nsString& aUrl, const nsString& aMimeType);
|
||||
|
||||
// nsIXMLDocument interface
|
||||
NS_IMETHOD GetContentById(const nsString& aName, nsIContent** aContent);
|
||||
|
@ -71,7 +71,7 @@ nsTransformMediator::~nsTransformMediator()
|
||||
static
|
||||
nsresult ConstructProgID(nsString& aProgID, const nsString& aMimeType)
|
||||
{
|
||||
aProgID = kTransformerProgIDPrefix;
|
||||
aProgID.AssignWithConversion(kTransformerProgIDPrefix);
|
||||
aProgID.Append(aMimeType);
|
||||
|
||||
return NS_OK;
|
||||
|
@ -178,7 +178,7 @@ void nsExpatTokenizer::SetupExpatParser(void) {
|
||||
nsExpatTokenizer::nsExpatTokenizer(nsString* aURL) : nsHTMLTokenizer() {
|
||||
NS_INIT_REFCNT();
|
||||
mBytesParsed = 0;
|
||||
mState = new XMLParserState;
|
||||
mState = new XMLParserState;
|
||||
mState->tokenRecycler = (CTokenRecycler*)GetTokenRecycler();
|
||||
mState->cdataToken = nsnull;
|
||||
mState->parser = nsnull;
|
||||
|
@ -149,6 +149,7 @@ class nsIParser : public nsISupports {
|
||||
* @param aCommand -- ptrs to string that contains command
|
||||
* @return nada
|
||||
*/
|
||||
virtual void GetCommand(nsString& aCommand)=0;
|
||||
virtual void SetCommand(const char* aCommand)=0;
|
||||
virtual void SetCommand(eParserCommands aParserCommand)=0;
|
||||
|
||||
|
@ -305,6 +305,11 @@ nsIParserFilter * nsParser::SetParserFilter(nsIParserFilter * aFilter)
|
||||
}
|
||||
|
||||
|
||||
void nsParser::GetCommand(nsString& aCommand)
|
||||
{
|
||||
aCommand = mCommandStr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Call this method once you've created a parser, and want to instruct it
|
||||
* about the command which caused the parser to be constructed. For example,
|
||||
@ -319,6 +324,7 @@ void nsParser::SetCommand(const char* aCommand){
|
||||
if(theCommand.Equals(kViewSourceCommand))
|
||||
mCommand=eViewSource;
|
||||
else mCommand=eViewNormal;
|
||||
mCommandStr.AssignWithConversion(aCommand);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -133,6 +133,7 @@ CLASS_EXPORT_HTMLPARS nsParser : public nsIParser, public nsIStreamListener {
|
||||
* @param aContentSink -- ptr to content sink that will receive output
|
||||
* @return ptr to previously set contentsink (usually null)
|
||||
*/
|
||||
virtual void GetCommand(nsString& aCommand);
|
||||
virtual void SetCommand(const char* aCommand);
|
||||
virtual void SetCommand(eParserCommands aParserCommand);
|
||||
|
||||
@ -384,6 +385,7 @@ protected:
|
||||
nsresult mInternalState;
|
||||
CObserverService mObserverService;
|
||||
PRBool mObserversEnabled;
|
||||
nsString mCommandStr;
|
||||
|
||||
public:
|
||||
MOZ_TIMER_DECLARE(mParseTime)
|
||||
|
@ -693,7 +693,8 @@ nsXULDocument::StartDocumentLoad(const char* aCommand,
|
||||
nsIChannel* aChannel,
|
||||
nsILoadGroup* aLoadGroup,
|
||||
nsISupports* aContainer,
|
||||
nsIStreamListener **aDocListener)
|
||||
nsIStreamListener **aDocListener,
|
||||
PRBool aReset)
|
||||
{
|
||||
nsresult rv;
|
||||
mCommand.AssignWithConversion(aCommand);
|
||||
@ -2686,6 +2687,13 @@ nsXULDocument::GetHeight(PRInt32* aHeight)
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXULDocument::Load(const nsString& aUrl, const nsString& aMimeType)
|
||||
{
|
||||
NS_NOTREACHED("nsXULDocument::Load");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
//
|
||||
// nsIDOMXULDocument interface
|
||||
|
@ -116,7 +116,8 @@ public:
|
||||
nsIChannel* aChannel,
|
||||
nsILoadGroup* aLoadGroup,
|
||||
nsISupports* aContainer,
|
||||
nsIStreamListener **aDocListener);
|
||||
nsIStreamListener **aDocListener,
|
||||
PRBool aReset);
|
||||
|
||||
NS_IMETHOD StopDocumentLoad();
|
||||
|
||||
@ -343,6 +344,7 @@ public:
|
||||
NS_IMETHOD CreateRange(nsIDOMRange** aRange);
|
||||
NS_IMETHOD GetWidth(PRInt32* aWidth);
|
||||
NS_IMETHOD GetHeight(PRInt32* aHeight);
|
||||
NS_IMETHOD Load (const nsString& aUrl, const nsString& aMimeType);
|
||||
|
||||
// nsIDOMXULDocument interface
|
||||
NS_DECL_IDOMXULDOCUMENT
|
||||
|
@ -1673,8 +1673,12 @@ NS_IMETHODIMP nsWebShell::SetDocument(nsIDOMDocument *aDOMDoc,
|
||||
nsCOMPtr<nsIStreamListener> outStreamListener; // a valid pointer is required for the returned stream listener
|
||||
// XXX: warning: magic cookie! should get string "view delayedContentLoad"
|
||||
// from somewhere, maybe nsIHTMLDocument?
|
||||
NS_ENSURE_SUCCESS(doc->StartDocumentLoad("view delayedContentLoad", dummyChannel, nsnull, NS_STATIC_CAST(nsIContentViewerContainer*, (nsIWebShell*)this),
|
||||
getter_AddRefs(outStreamListener)),
|
||||
NS_ENSURE_SUCCESS(doc->StartDocumentLoad("view delayedContentLoad",
|
||||
dummyChannel,
|
||||
nsnull,
|
||||
NS_STATIC_CAST(nsIContentViewerContainer*, (nsIWebShell*)this),
|
||||
getter_AddRefs(outStreamListener),
|
||||
PR_TRUE),
|
||||
NS_ERROR_FAILURE);
|
||||
NS_ENSURE_SUCCESS(OnStartDocumentLoad(mDocLoader, uri, "load"), NS_ERROR_FAILURE);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user