1998-11-11 22:06:16 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
*
|
1999-11-06 03:40:37 +00:00
|
|
|
* The contents of this file are subject to the Netscape Public
|
|
|
|
* License Version 1.1 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of
|
|
|
|
* the License at http://www.mozilla.org/NPL/
|
1998-11-11 22:06:16 +00:00
|
|
|
*
|
1999-11-06 03:40:37 +00:00
|
|
|
* Software distributed under the License is distributed on an "AS
|
|
|
|
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
|
|
|
* implied. See the License for the specific language governing
|
|
|
|
* rights and limitations under the License.
|
1998-11-11 22:06:16 +00:00
|
|
|
*
|
|
|
|
* The Original Code is Mozilla Communicator client code.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is Netscape Communications
|
1999-11-06 03:40:37 +00:00
|
|
|
* Corporation. Portions created by Netscape are
|
|
|
|
* Copyright (C) 1998 Netscape Communications Corporation. All
|
|
|
|
* Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
1998-11-11 22:06:16 +00:00
|
|
|
*/
|
1999-02-12 17:45:58 +00:00
|
|
|
#include "nsCOMPtr.h"
|
1998-11-11 22:06:16 +00:00
|
|
|
#include "nsXMLContentSink.h"
|
2000-01-19 03:10:45 +00:00
|
|
|
#include "nsIElementFactory.h"
|
1998-12-11 17:02:37 +00:00
|
|
|
#include "nsIParser.h"
|
1998-11-11 22:06:16 +00:00
|
|
|
#include "nsIUnicharInputStream.h"
|
|
|
|
#include "nsIDocument.h"
|
|
|
|
#include "nsIXMLDocument.h"
|
|
|
|
#include "nsIXMLContent.h"
|
|
|
|
#include "nsIScriptObjectOwner.h"
|
1999-12-03 09:24:22 +00:00
|
|
|
#include "nsIScriptGlobalObject.h"
|
1998-11-11 22:06:16 +00:00
|
|
|
#include "nsIURL.h"
|
1999-06-28 15:06:33 +00:00
|
|
|
#include "nsIURL.h"
|
1999-11-30 04:50:42 +00:00
|
|
|
#include "nsNetUtil.h"
|
1998-11-11 22:06:16 +00:00
|
|
|
#include "nsIWebShell.h"
|
1999-12-18 02:09:29 +00:00
|
|
|
#include "nsIDocShellTreeItem.h"
|
1998-11-11 22:06:16 +00:00
|
|
|
#include "nsIContent.h"
|
|
|
|
#include "nsITextContent.h"
|
|
|
|
#include "nsIPresContext.h"
|
|
|
|
#include "nsIPresShell.h"
|
|
|
|
#include "nsIViewManager.h"
|
|
|
|
#include "nsIDOMComment.h"
|
1999-03-31 20:49:25 +00:00
|
|
|
#include "nsIDOMCDATASection.h"
|
1998-11-11 22:06:16 +00:00
|
|
|
#include "nsIHTMLContent.h"
|
(13163, r=alecf, scc, waterson, others; names available on request)
- Fix most of bug 13163 (see TODO for rest). This entails adding a version-string argument to nsIScriptContext::EvaluateString and passing it around lots of places in content sinks.
- Fix leaks and confusion about mSecurityManager and mNameSpaceManager in nsJSEnvironment.cpp. These still need to move from nsJSContext to nsGlobalWindow or thereabouts, jband and vidur are looking at that.
- Added comments and expanded tabs in nsJSEnvironment.cpp, esp. to EvaluateString. Also changed various nsresult vars to be named rv. Also restored brace/style conformity to nsJSProtocolHandler.cpp.
- Factored CompileFunction from AddScriptEventListener to pave the way for brutal sharing of compiled JS event handlers via JS_CloneFunctionObject.
- Lots of nsCOMPtr uses added. I'm using one for mNameSpaceManager. Hold mSecurityManager as a service explicitly, on the other hand (awaiting scc's fix to allow comptrs for services), and release in nsJSContext's dtor (fixing a leak). These two managers should be moved to the window object -- TODO item below.
- Hold JSRuntimeService along with JSRuntime for live of nsJSEnvironment, fix for shaver.
- Fix window.setTimeout etc. so the filename and line number of the timeout expr is propagated. This meant factoring nsJSUtils.cpp code.
- Fix all content sinks to use the same, and up-to-date JavaScript version parsing (whether for script type or for old language attribute); also fix SplitMimeType clones to strip whitespace.
- With waterson, fix bug in brutal-sharing version of XUL content sink: script src= should not evaluate the inline content of its tag.
1999-10-31 00:43:30 +00:00
|
|
|
#include "nsHTMLEntities.h"
|
|
|
|
#include "nsHTMLParts.h"
|
1998-11-11 22:06:16 +00:00
|
|
|
#include "nsVoidArray.h"
|
|
|
|
#include "nsCRT.h"
|
1999-05-26 23:58:06 +00:00
|
|
|
#include "nsICSSLoader.h"
|
1998-11-26 01:34:53 +00:00
|
|
|
#include "nsICSSStyleSheet.h"
|
1999-05-26 23:58:06 +00:00
|
|
|
#include "nsIHTMLContentContainer.h"
|
1998-11-12 23:55:47 +00:00
|
|
|
#include "nsHTMLAtoms.h"
|
1999-02-18 00:18:50 +00:00
|
|
|
#include "nsLayoutAtoms.h"
|
2000-01-19 04:44:10 +00:00
|
|
|
#include "nsLayoutCID.h"
|
1998-11-12 23:55:47 +00:00
|
|
|
#include "nsIScriptContext.h"
|
1998-12-11 02:53:49 +00:00
|
|
|
#include "nsINameSpace.h"
|
|
|
|
#include "nsINameSpaceManager.h"
|
1999-11-16 05:07:31 +00:00
|
|
|
#include "nsIServiceManager.h"
|
|
|
|
#include "nsIScriptSecurityManager.h"
|
1999-05-13 20:27:47 +00:00
|
|
|
#include "nsIContentViewer.h"
|
(13163, r=alecf, scc, waterson, others; names available on request)
- Fix most of bug 13163 (see TODO for rest). This entails adding a version-string argument to nsIScriptContext::EvaluateString and passing it around lots of places in content sinks.
- Fix leaks and confusion about mSecurityManager and mNameSpaceManager in nsJSEnvironment.cpp. These still need to move from nsJSContext to nsGlobalWindow or thereabouts, jband and vidur are looking at that.
- Added comments and expanded tabs in nsJSEnvironment.cpp, esp. to EvaluateString. Also changed various nsresult vars to be named rv. Also restored brace/style conformity to nsJSProtocolHandler.cpp.
- Factored CompileFunction from AddScriptEventListener to pave the way for brutal sharing of compiled JS event handlers via JS_CloneFunctionObject.
- Lots of nsCOMPtr uses added. I'm using one for mNameSpaceManager. Hold mSecurityManager as a service explicitly, on the other hand (awaiting scc's fix to allow comptrs for services), and release in nsJSContext's dtor (fixing a leak). These two managers should be moved to the window object -- TODO item below.
- Hold JSRuntimeService along with JSRuntime for live of nsJSEnvironment, fix for shaver.
- Fix window.setTimeout etc. so the filename and line number of the timeout expr is propagated. This meant factoring nsJSUtils.cpp code.
- Fix all content sinks to use the same, and up-to-date JavaScript version parsing (whether for script type or for old language attribute); also fix SplitMimeType clones to strip whitespace.
- With waterson, fix bug in brutal-sharing version of XUL content sink: script src= should not evaluate the inline content of its tag.
1999-10-31 00:43:30 +00:00
|
|
|
#include "jsapi.h" // for JSVERSION_* and JS_VersionToString
|
1998-11-11 22:06:16 +00:00
|
|
|
#include "prtime.h"
|
|
|
|
#include "prlog.h"
|
1998-11-12 23:55:47 +00:00
|
|
|
#include "prmem.h"
|
1999-06-28 14:49:29 +00:00
|
|
|
#ifdef XSL
|
|
|
|
#include "nsXSLContentSink.h"
|
|
|
|
#include "nsIDOMDocument.h"
|
|
|
|
#include "nsIDOMElement.h"
|
|
|
|
#include <windows.h>
|
|
|
|
#include "nsISupports.h"
|
|
|
|
#include "nsParserCIID.h"
|
1999-08-28 07:31:08 +00:00
|
|
|
#include "nsIIOService.h"
|
|
|
|
#include "nsIServiceManager.h"
|
1999-06-28 14:49:29 +00:00
|
|
|
#endif
|
1998-11-11 22:06:16 +00:00
|
|
|
|
1999-02-26 17:13:51 +00:00
|
|
|
// XXX misnamed header file, but oh well
|
(13163, r=alecf, scc, waterson, others; names available on request)
- Fix most of bug 13163 (see TODO for rest). This entails adding a version-string argument to nsIScriptContext::EvaluateString and passing it around lots of places in content sinks.
- Fix leaks and confusion about mSecurityManager and mNameSpaceManager in nsJSEnvironment.cpp. These still need to move from nsJSContext to nsGlobalWindow or thereabouts, jband and vidur are looking at that.
- Added comments and expanded tabs in nsJSEnvironment.cpp, esp. to EvaluateString. Also changed various nsresult vars to be named rv. Also restored brace/style conformity to nsJSProtocolHandler.cpp.
- Factored CompileFunction from AddScriptEventListener to pave the way for brutal sharing of compiled JS event handlers via JS_CloneFunctionObject.
- Lots of nsCOMPtr uses added. I'm using one for mNameSpaceManager. Hold mSecurityManager as a service explicitly, on the other hand (awaiting scc's fix to allow comptrs for services), and release in nsJSContext's dtor (fixing a leak). These two managers should be moved to the window object -- TODO item below.
- Hold JSRuntimeService along with JSRuntime for live of nsJSEnvironment, fix for shaver.
- Fix window.setTimeout etc. so the filename and line number of the timeout expr is propagated. This meant factoring nsJSUtils.cpp code.
- Fix all content sinks to use the same, and up-to-date JavaScript version parsing (whether for script type or for old language attribute); also fix SplitMimeType clones to strip whitespace.
- With waterson, fix bug in brutal-sharing version of XUL content sink: script src= should not evaluate the inline content of its tag.
1999-10-31 00:43:30 +00:00
|
|
|
#include "nsHTMLTokens.h"
|
1999-02-26 17:13:51 +00:00
|
|
|
|
1999-07-18 00:34:41 +00:00
|
|
|
static char kNameSpaceSeparator = ':';
|
1998-11-11 22:06:16 +00:00
|
|
|
static char kNameSpaceDef[] = "xmlns";
|
1999-03-31 20:49:25 +00:00
|
|
|
static char kStyleSheetPI[] = "xml-stylesheet";
|
1998-11-11 22:06:16 +00:00
|
|
|
|
1998-12-27 08:24:04 +00:00
|
|
|
#ifdef XSL
|
|
|
|
static char kXSLType[] = "text/xsl";
|
|
|
|
#endif
|
|
|
|
|
2000-01-19 04:44:10 +00:00
|
|
|
static NS_DEFINE_CID(kNameSpaceManagerCID, NS_NAMESPACEMANAGER_CID);
|
|
|
|
|
1998-11-11 22:06:16 +00:00
|
|
|
static NS_DEFINE_IID(kIXMLContentSinkIID, NS_IXMLCONTENT_SINK_IID);
|
1999-01-12 16:37:24 +00:00
|
|
|
static NS_DEFINE_IID(kIXMLContentIID, NS_IXMLCONTENT_IID);
|
1999-05-26 23:58:06 +00:00
|
|
|
static NS_DEFINE_IID(kIHTMLContentContainerIID, NS_IHTMLCONTENTCONTAINER_IID);
|
1998-11-11 22:06:16 +00:00
|
|
|
static NS_DEFINE_IID(kIXMLDocumentIID, NS_IXMLDOCUMENT_IID);
|
|
|
|
static NS_DEFINE_IID(kIDOMCommentIID, NS_IDOMCOMMENT_IID);
|
|
|
|
static NS_DEFINE_IID(kIScrollableViewIID, NS_ISCROLLABLEVIEW_IID);
|
1998-12-18 01:36:41 +00:00
|
|
|
static NS_DEFINE_IID(kIDOMNodeIID, NS_IDOMNODE_IID);
|
1999-03-31 20:49:25 +00:00
|
|
|
static NS_DEFINE_IID(kIDOMCDATASectionIID, NS_IDOMCDATASECTION_IID);
|
1999-06-28 14:49:29 +00:00
|
|
|
#ifdef XSL
|
|
|
|
static NS_DEFINE_IID(kIDOMDocumentIID, NS_IDOMDOCUMENT_IID);
|
|
|
|
static NS_DEFINE_IID(kIDOMElementIID, NS_IDOMELEMENT_IID);
|
|
|
|
static NS_DEFINE_IID(kIContentIID, NS_ICONTENT_IID);
|
|
|
|
static NS_DEFINE_IID(kIObserverIID, NS_IOBSERVER_IID);
|
|
|
|
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
1999-08-28 07:31:08 +00:00
|
|
|
static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID);
|
|
|
|
static NS_DEFINE_IID(kIStreamListenerIID, NS_ISTREAMLISTENER_IID);
|
1999-06-28 14:49:29 +00:00
|
|
|
#endif
|
1998-11-11 22:06:16 +00:00
|
|
|
|
2000-01-19 04:44:10 +00:00
|
|
|
nsINameSpaceManager* nsXMLContentSink::gNameSpaceManager = nsnull;
|
|
|
|
PRUint32 nsXMLContentSink::gRefCnt = 0;
|
1999-08-28 07:31:08 +00:00
|
|
|
|
1999-03-11 05:29:36 +00:00
|
|
|
static void SetTextStringOnTextNode(const nsString& aTextString, nsIContent* aTextNode);
|
|
|
|
|
1998-11-14 00:21:19 +00:00
|
|
|
// XXX Open Issues:
|
|
|
|
// 1) html:style - Should we allow inline style? If so, the content
|
|
|
|
// sink needs to process the tag and invoke the CSS parser.
|
|
|
|
// 2) html:base - Should we allow a base tag? If so, the content
|
|
|
|
// sink needs to maintain the base when resolving URLs for
|
|
|
|
// loaded scripts and style sheets. Should it be allowed anywhere?
|
|
|
|
// 3) what's not allowed - We need to figure out which HTML tags
|
|
|
|
// (prefixed with a HTML namespace qualifier) are explicitly not
|
|
|
|
// allowed (if any).
|
|
|
|
// 4) factoring code with nsHTMLContentSink - There's some amount of
|
|
|
|
// common code between this and the HTML content sink. This will
|
|
|
|
// increase as we support more and more HTML elements. How can code
|
|
|
|
// from the code be factored?
|
|
|
|
|
1998-11-11 22:06:16 +00:00
|
|
|
nsresult
|
|
|
|
NS_NewXMLContentSink(nsIXMLContentSink** aResult,
|
|
|
|
nsIDocument* aDoc,
|
1999-06-23 03:29:44 +00:00
|
|
|
nsIURI* aURL,
|
1998-11-11 22:06:16 +00:00
|
|
|
nsIWebShell* aWebShell)
|
|
|
|
{
|
|
|
|
NS_PRECONDITION(nsnull != aResult, "null ptr");
|
|
|
|
if (nsnull == aResult) {
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
|
|
|
nsXMLContentSink* it;
|
|
|
|
NS_NEWXPCOM(it, nsXMLContentSink);
|
|
|
|
if (nsnull == it) {
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
|
|
|
nsresult rv = it->Init(aDoc, aURL, aWebShell);
|
|
|
|
if (NS_OK != rv) {
|
|
|
|
delete it;
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
return it->QueryInterface(kIXMLContentSinkIID, (void **)aResult);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsXMLContentSink::nsXMLContentSink()
|
|
|
|
{
|
|
|
|
NS_INIT_REFCNT();
|
2000-01-19 04:44:10 +00:00
|
|
|
gRefCnt++;
|
|
|
|
if (gRefCnt == 1) {
|
|
|
|
nsresult rv = nsServiceManager::GetService(kNameSpaceManagerCID,
|
|
|
|
NS_GET_IID(nsINameSpaceManager),
|
|
|
|
(nsISupports**) &gNameSpaceManager);
|
|
|
|
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get namespace manager");
|
|
|
|
}
|
|
|
|
|
1998-11-11 22:06:16 +00:00
|
|
|
mDocument = nsnull;
|
|
|
|
mDocumentURL = nsnull;
|
1999-05-26 23:58:06 +00:00
|
|
|
mDocumentBaseURL = nsnull;
|
1998-11-11 22:06:16 +00:00
|
|
|
mWebShell = nsnull;
|
1998-12-11 17:02:37 +00:00
|
|
|
mParser = nsnull;
|
1998-11-11 22:06:16 +00:00
|
|
|
mRootElement = nsnull;
|
|
|
|
mDocElement = nsnull;
|
|
|
|
mContentStack = nsnull;
|
1998-12-11 02:53:49 +00:00
|
|
|
mNameSpaceStack = nsnull;
|
1998-11-11 22:06:16 +00:00
|
|
|
mText = nsnull;
|
|
|
|
mTextLength = 0;
|
|
|
|
mTextSize = 0;
|
1998-11-12 23:55:47 +00:00
|
|
|
mConstrainSize = PR_TRUE;
|
|
|
|
mInScript = PR_FALSE;
|
1999-05-26 23:58:06 +00:00
|
|
|
mStyleSheetCount = 0;
|
|
|
|
mCSSLoader = nsnull;
|
1998-12-27 08:24:04 +00:00
|
|
|
#ifdef XSL
|
1999-06-28 14:49:29 +00:00
|
|
|
mXSLTransformMediator = nsnull;
|
1998-12-27 08:24:04 +00:00
|
|
|
#endif
|
1998-11-11 22:06:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nsXMLContentSink::~nsXMLContentSink()
|
|
|
|
{
|
2000-01-19 04:44:10 +00:00
|
|
|
gRefCnt--;
|
|
|
|
if (gRefCnt == 0) {
|
|
|
|
NS_IF_RELEASE(gNameSpaceManager);
|
|
|
|
}
|
|
|
|
|
1998-11-11 22:06:16 +00:00
|
|
|
NS_IF_RELEASE(mDocument);
|
|
|
|
NS_IF_RELEASE(mDocumentURL);
|
1999-05-26 23:58:06 +00:00
|
|
|
NS_IF_RELEASE(mDocumentBaseURL);
|
1998-11-11 22:06:16 +00:00
|
|
|
NS_IF_RELEASE(mWebShell);
|
1998-12-11 17:02:37 +00:00
|
|
|
NS_IF_RELEASE(mParser);
|
1998-11-11 22:06:16 +00:00
|
|
|
NS_IF_RELEASE(mRootElement);
|
|
|
|
NS_IF_RELEASE(mDocElement);
|
|
|
|
if (nsnull != mContentStack) {
|
1998-12-11 02:53:49 +00:00
|
|
|
// there shouldn't be anything here except in an error condition
|
|
|
|
PRInt32 index = mContentStack->Count();
|
|
|
|
while (0 < index--) {
|
|
|
|
nsIContent* content = (nsIContent*)mContentStack->ElementAt(index);
|
|
|
|
NS_RELEASE(content);
|
|
|
|
}
|
1998-11-11 22:06:16 +00:00
|
|
|
delete mContentStack;
|
|
|
|
}
|
1998-12-11 02:53:49 +00:00
|
|
|
if (nsnull != mNameSpaceStack) {
|
|
|
|
// There shouldn't be any here except in an error condition
|
|
|
|
PRInt32 index = mNameSpaceStack->Count();
|
|
|
|
while (0 < index--) {
|
|
|
|
nsINameSpace* nameSpace = (nsINameSpace*)mNameSpaceStack->ElementAt(index);
|
|
|
|
NS_RELEASE(nameSpace);
|
|
|
|
}
|
|
|
|
delete mNameSpaceStack;
|
|
|
|
}
|
1998-11-11 22:06:16 +00:00
|
|
|
if (nsnull != mText) {
|
1998-11-12 23:55:47 +00:00
|
|
|
PR_FREEIF(mText);
|
1998-11-11 22:06:16 +00:00
|
|
|
}
|
1999-05-26 23:58:06 +00:00
|
|
|
NS_IF_RELEASE(mCSSLoader);
|
(13163, r=alecf, scc, waterson, others; names available on request)
- Fix most of bug 13163 (see TODO for rest). This entails adding a version-string argument to nsIScriptContext::EvaluateString and passing it around lots of places in content sinks.
- Fix leaks and confusion about mSecurityManager and mNameSpaceManager in nsJSEnvironment.cpp. These still need to move from nsJSContext to nsGlobalWindow or thereabouts, jband and vidur are looking at that.
- Added comments and expanded tabs in nsJSEnvironment.cpp, esp. to EvaluateString. Also changed various nsresult vars to be named rv. Also restored brace/style conformity to nsJSProtocolHandler.cpp.
- Factored CompileFunction from AddScriptEventListener to pave the way for brutal sharing of compiled JS event handlers via JS_CloneFunctionObject.
- Lots of nsCOMPtr uses added. I'm using one for mNameSpaceManager. Hold mSecurityManager as a service explicitly, on the other hand (awaiting scc's fix to allow comptrs for services), and release in nsJSContext's dtor (fixing a leak). These two managers should be moved to the window object -- TODO item below.
- Hold JSRuntimeService along with JSRuntime for live of nsJSEnvironment, fix for shaver.
- Fix window.setTimeout etc. so the filename and line number of the timeout expr is propagated. This meant factoring nsJSUtils.cpp code.
- Fix all content sinks to use the same, and up-to-date JavaScript version parsing (whether for script type or for old language attribute); also fix SplitMimeType clones to strip whitespace.
- With waterson, fix bug in brutal-sharing version of XUL content sink: script src= should not evaluate the inline content of its tag.
1999-10-31 00:43:30 +00:00
|
|
|
#ifdef XSL
|
1999-06-28 14:49:29 +00:00
|
|
|
NS_IF_RELEASE(mXSLTransformMediator);
|
|
|
|
#endif
|
1998-11-11 22:06:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsXMLContentSink::Init(nsIDocument* aDoc,
|
1999-06-23 03:29:44 +00:00
|
|
|
nsIURI* aURL,
|
1998-11-11 22:06:16 +00:00
|
|
|
nsIWebShell* aContainer)
|
|
|
|
{
|
|
|
|
NS_PRECONDITION(nsnull != aDoc, "null ptr");
|
|
|
|
NS_PRECONDITION(nsnull != aURL, "null ptr");
|
2000-01-12 10:33:00 +00:00
|
|
|
if ((nsnull == aDoc) || (nsnull == aURL)) {
|
1998-11-11 22:06:16 +00:00
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
|
|
|
|
|
|
|
mDocument = aDoc;
|
|
|
|
NS_ADDREF(aDoc);
|
|
|
|
mDocumentURL = aURL;
|
|
|
|
NS_ADDREF(aURL);
|
1999-05-26 23:58:06 +00:00
|
|
|
mDocumentBaseURL = aURL;
|
|
|
|
NS_ADDREF(aURL);
|
1998-11-11 22:06:16 +00:00
|
|
|
mWebShell = aContainer;
|
2000-01-12 10:33:00 +00:00
|
|
|
NS_IF_ADDREF(aContainer);
|
1998-11-11 22:06:16 +00:00
|
|
|
|
|
|
|
mState = eXMLContentSinkState_InProlog;
|
|
|
|
mDocElement = nsnull;
|
|
|
|
mRootElement = nsnull;
|
|
|
|
|
1999-05-26 23:58:06 +00:00
|
|
|
// XXX this presumes HTTP header info is alread set in document
|
|
|
|
// XXX if it isn't we need to set it here...
|
|
|
|
mDocument->GetHeaderData(nsHTMLAtoms::headerDefaultStyle, mPreferredStyle);
|
|
|
|
|
|
|
|
nsIHTMLContentContainer* htmlContainer = nsnull;
|
|
|
|
if (NS_SUCCEEDED(aDoc->QueryInterface(kIHTMLContentContainerIID, (void**)&htmlContainer))) {
|
|
|
|
htmlContainer->GetCSSLoader(mCSSLoader);
|
|
|
|
NS_RELEASE(htmlContainer);
|
|
|
|
}
|
|
|
|
|
1998-11-11 22:06:16 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-06-28 14:49:29 +00:00
|
|
|
#ifndef XSL
|
1999-11-02 06:49:44 +00:00
|
|
|
|
1999-12-07 14:06:36 +00:00
|
|
|
NS_IMPL_ADDREF(nsXMLContentSink)
|
|
|
|
NS_IMPL_RELEASE(nsXMLContentSink)
|
1999-11-02 06:49:44 +00:00
|
|
|
|
1999-06-28 14:49:29 +00:00
|
|
|
#else
|
|
|
|
|
|
|
|
NS_IMPL_THREADSAFE_ADDREF(nsXMLContentSink)
|
|
|
|
NS_IMPL_THREADSAFE_RELEASE(nsXMLContentSink)
|
1999-12-07 14:06:36 +00:00
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
NS_INTERFACE_MAP_BEGIN(nsXMLContentSink)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIXMLContentSink)
|
|
|
|
#ifdef XSL
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIObserver)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
|
1999-06-28 14:49:29 +00:00
|
|
|
#endif
|
1999-12-07 14:06:36 +00:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIUnicharStreamLoaderObserver)
|
|
|
|
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIXMLContentSink)
|
|
|
|
NS_INTERFACE_MAP_END
|
1998-11-11 22:06:16 +00:00
|
|
|
|
|
|
|
// nsIContentSink
|
(13163, r=alecf, scc, waterson, others; names available on request)
- Fix most of bug 13163 (see TODO for rest). This entails adding a version-string argument to nsIScriptContext::EvaluateString and passing it around lots of places in content sinks.
- Fix leaks and confusion about mSecurityManager and mNameSpaceManager in nsJSEnvironment.cpp. These still need to move from nsJSContext to nsGlobalWindow or thereabouts, jband and vidur are looking at that.
- Added comments and expanded tabs in nsJSEnvironment.cpp, esp. to EvaluateString. Also changed various nsresult vars to be named rv. Also restored brace/style conformity to nsJSProtocolHandler.cpp.
- Factored CompileFunction from AddScriptEventListener to pave the way for brutal sharing of compiled JS event handlers via JS_CloneFunctionObject.
- Lots of nsCOMPtr uses added. I'm using one for mNameSpaceManager. Hold mSecurityManager as a service explicitly, on the other hand (awaiting scc's fix to allow comptrs for services), and release in nsJSContext's dtor (fixing a leak). These two managers should be moved to the window object -- TODO item below.
- Hold JSRuntimeService along with JSRuntime for live of nsJSEnvironment, fix for shaver.
- Fix window.setTimeout etc. so the filename and line number of the timeout expr is propagated. This meant factoring nsJSUtils.cpp code.
- Fix all content sinks to use the same, and up-to-date JavaScript version parsing (whether for script type or for old language attribute); also fix SplitMimeType clones to strip whitespace.
- With waterson, fix bug in brutal-sharing version of XUL content sink: script src= should not evaluate the inline content of its tag.
1999-10-31 00:43:30 +00:00
|
|
|
NS_IMETHODIMP
|
1998-11-11 22:06:16 +00:00
|
|
|
nsXMLContentSink::WillBuildModel(void)
|
|
|
|
{
|
|
|
|
// Notify document that the load is beginning
|
|
|
|
mDocument->BeginLoad();
|
1999-07-14 17:59:19 +00:00
|
|
|
return NS_OK;
|
1998-11-11 22:06:16 +00:00
|
|
|
}
|
|
|
|
|
(13163, r=alecf, scc, waterson, others; names available on request)
- Fix most of bug 13163 (see TODO for rest). This entails adding a version-string argument to nsIScriptContext::EvaluateString and passing it around lots of places in content sinks.
- Fix leaks and confusion about mSecurityManager and mNameSpaceManager in nsJSEnvironment.cpp. These still need to move from nsJSContext to nsGlobalWindow or thereabouts, jband and vidur are looking at that.
- Added comments and expanded tabs in nsJSEnvironment.cpp, esp. to EvaluateString. Also changed various nsresult vars to be named rv. Also restored brace/style conformity to nsJSProtocolHandler.cpp.
- Factored CompileFunction from AddScriptEventListener to pave the way for brutal sharing of compiled JS event handlers via JS_CloneFunctionObject.
- Lots of nsCOMPtr uses added. I'm using one for mNameSpaceManager. Hold mSecurityManager as a service explicitly, on the other hand (awaiting scc's fix to allow comptrs for services), and release in nsJSContext's dtor (fixing a leak). These two managers should be moved to the window object -- TODO item below.
- Hold JSRuntimeService along with JSRuntime for live of nsJSEnvironment, fix for shaver.
- Fix window.setTimeout etc. so the filename and line number of the timeout expr is propagated. This meant factoring nsJSUtils.cpp code.
- Fix all content sinks to use the same, and up-to-date JavaScript version parsing (whether for script type or for old language attribute); also fix SplitMimeType clones to strip whitespace.
- With waterson, fix bug in brutal-sharing version of XUL content sink: script src= should not evaluate the inline content of its tag.
1999-10-31 00:43:30 +00:00
|
|
|
NS_IMETHODIMP
|
1998-11-11 22:06:16 +00:00
|
|
|
nsXMLContentSink::DidBuildModel(PRInt32 aQualityLevel)
|
|
|
|
{
|
|
|
|
// XXX this is silly; who cares?
|
|
|
|
PRInt32 i, ns = mDocument->GetNumberOfShells();
|
|
|
|
for (i = 0; i < ns; i++) {
|
1999-02-18 23:55:10 +00:00
|
|
|
nsCOMPtr<nsIPresShell> shell( dont_AddRef(mDocument->GetShellAt(i)) );
|
1999-02-12 18:41:26 +00:00
|
|
|
if (shell) {
|
1999-02-12 17:45:58 +00:00
|
|
|
nsCOMPtr<nsIViewManager> vm;
|
|
|
|
shell->GetViewManager(getter_AddRefs(vm));
|
1998-11-11 22:06:16 +00:00
|
|
|
if(vm) {
|
|
|
|
vm->SetQuality(nsContentQuality(aQualityLevel));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-06-28 14:49:29 +00:00
|
|
|
#ifndef XSL
|
|
|
|
StartLayoutProcess();
|
|
|
|
#else
|
|
|
|
nsresult rv;
|
|
|
|
if (mXSLTransformMediator) {
|
(13163, r=alecf, scc, waterson, others; names available on request)
- Fix most of bug 13163 (see TODO for rest). This entails adding a version-string argument to nsIScriptContext::EvaluateString and passing it around lots of places in content sinks.
- Fix leaks and confusion about mSecurityManager and mNameSpaceManager in nsJSEnvironment.cpp. These still need to move from nsJSContext to nsGlobalWindow or thereabouts, jband and vidur are looking at that.
- Added comments and expanded tabs in nsJSEnvironment.cpp, esp. to EvaluateString. Also changed various nsresult vars to be named rv. Also restored brace/style conformity to nsJSProtocolHandler.cpp.
- Factored CompileFunction from AddScriptEventListener to pave the way for brutal sharing of compiled JS event handlers via JS_CloneFunctionObject.
- Lots of nsCOMPtr uses added. I'm using one for mNameSpaceManager. Hold mSecurityManager as a service explicitly, on the other hand (awaiting scc's fix to allow comptrs for services), and release in nsJSContext's dtor (fixing a leak). These two managers should be moved to the window object -- TODO item below.
- Hold JSRuntimeService along with JSRuntime for live of nsJSEnvironment, fix for shaver.
- Fix window.setTimeout etc. so the filename and line number of the timeout expr is propagated. This meant factoring nsJSUtils.cpp code.
- Fix all content sinks to use the same, and up-to-date JavaScript version parsing (whether for script type or for old language attribute); also fix SplitMimeType clones to strip whitespace.
- With waterson, fix bug in brutal-sharing version of XUL content sink: script src= should not evaluate the inline content of its tag.
1999-10-31 00:43:30 +00:00
|
|
|
rv = SetupTransformMediator();
|
|
|
|
}
|
1999-06-28 14:49:29 +00:00
|
|
|
|
|
|
|
if (!mXSLTransformMediator || NS_FAILED(rv)) {
|
|
|
|
mDocument->SetRootContent(mDocElement);
|
|
|
|
StartLayoutProcess();
|
1998-11-11 22:06:16 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
1998-12-11 17:02:37 +00:00
|
|
|
// Drop our reference to the parser to get rid of a circular
|
|
|
|
// reference.
|
|
|
|
NS_IF_RELEASE(mParser);
|
1999-06-28 14:49:29 +00:00
|
|
|
|
1998-11-11 22:06:16 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
(13163, r=alecf, scc, waterson, others; names available on request)
- Fix most of bug 13163 (see TODO for rest). This entails adding a version-string argument to nsIScriptContext::EvaluateString and passing it around lots of places in content sinks.
- Fix leaks and confusion about mSecurityManager and mNameSpaceManager in nsJSEnvironment.cpp. These still need to move from nsJSContext to nsGlobalWindow or thereabouts, jband and vidur are looking at that.
- Added comments and expanded tabs in nsJSEnvironment.cpp, esp. to EvaluateString. Also changed various nsresult vars to be named rv. Also restored brace/style conformity to nsJSProtocolHandler.cpp.
- Factored CompileFunction from AddScriptEventListener to pave the way for brutal sharing of compiled JS event handlers via JS_CloneFunctionObject.
- Lots of nsCOMPtr uses added. I'm using one for mNameSpaceManager. Hold mSecurityManager as a service explicitly, on the other hand (awaiting scc's fix to allow comptrs for services), and release in nsJSContext's dtor (fixing a leak). These two managers should be moved to the window object -- TODO item below.
- Hold JSRuntimeService along with JSRuntime for live of nsJSEnvironment, fix for shaver.
- Fix window.setTimeout etc. so the filename and line number of the timeout expr is propagated. This meant factoring nsJSUtils.cpp code.
- Fix all content sinks to use the same, and up-to-date JavaScript version parsing (whether for script type or for old language attribute); also fix SplitMimeType clones to strip whitespace.
- With waterson, fix bug in brutal-sharing version of XUL content sink: script src= should not evaluate the inline content of its tag.
1999-10-31 00:43:30 +00:00
|
|
|
void
|
1999-06-28 14:49:29 +00:00
|
|
|
nsXMLContentSink::StartLayoutProcess()
|
|
|
|
{
|
|
|
|
StartLayout();
|
|
|
|
|
|
|
|
// XXX Should scroll to ref when that makes sense
|
|
|
|
// ScrollToRef();
|
|
|
|
|
|
|
|
mDocument->EndLoad();
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef XSL
|
|
|
|
// The observe method is called on completion of the transform. The nsISupports argument is an
|
|
|
|
// nsIDOMElement interface to the root node of the output content model.
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsXMLContentSink::Observe(nsISupports *aSubject, const PRUnichar *aTopic, const PRUnichar *someData)
|
|
|
|
{
|
|
|
|
nsIContent* content;
|
|
|
|
nsresult rv = NS_OK;
|
|
|
|
|
|
|
|
// Set the output content model on the document
|
|
|
|
rv = aSubject->QueryInterface(kIContentIID, (void **) &content);
|
|
|
|
if (NS_SUCCEEDED(rv)) {
|
|
|
|
mDocument->SetRootContent(content);
|
|
|
|
NS_RELEASE(content);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
mDocument->SetRootContent(mDocElement);
|
|
|
|
|
|
|
|
// Start the layout process
|
|
|
|
StartLayoutProcess();
|
|
|
|
|
|
|
|
// Reset the observer on the transform mediator
|
|
|
|
mXSLTransformMediator->SetTransformObserver(nsnull);
|
(13163, r=alecf, scc, waterson, others; names available on request)
- Fix most of bug 13163 (see TODO for rest). This entails adding a version-string argument to nsIScriptContext::EvaluateString and passing it around lots of places in content sinks.
- Fix leaks and confusion about mSecurityManager and mNameSpaceManager in nsJSEnvironment.cpp. These still need to move from nsJSContext to nsGlobalWindow or thereabouts, jband and vidur are looking at that.
- Added comments and expanded tabs in nsJSEnvironment.cpp, esp. to EvaluateString. Also changed various nsresult vars to be named rv. Also restored brace/style conformity to nsJSProtocolHandler.cpp.
- Factored CompileFunction from AddScriptEventListener to pave the way for brutal sharing of compiled JS event handlers via JS_CloneFunctionObject.
- Lots of nsCOMPtr uses added. I'm using one for mNameSpaceManager. Hold mSecurityManager as a service explicitly, on the other hand (awaiting scc's fix to allow comptrs for services), and release in nsJSContext's dtor (fixing a leak). These two managers should be moved to the window object -- TODO item below.
- Hold JSRuntimeService along with JSRuntime for live of nsJSEnvironment, fix for shaver.
- Fix window.setTimeout etc. so the filename and line number of the timeout expr is propagated. This meant factoring nsJSUtils.cpp code.
- Fix all content sinks to use the same, and up-to-date JavaScript version parsing (whether for script type or for old language attribute); also fix SplitMimeType clones to strip whitespace.
- With waterson, fix bug in brutal-sharing version of XUL content sink: script src= should not evaluate the inline content of its tag.
1999-10-31 00:43:30 +00:00
|
|
|
|
1999-06-28 14:49:29 +00:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Provide the transform mediator with the source document's content
|
(13163, r=alecf, scc, waterson, others; names available on request)
- Fix most of bug 13163 (see TODO for rest). This entails adding a version-string argument to nsIScriptContext::EvaluateString and passing it around lots of places in content sinks.
- Fix leaks and confusion about mSecurityManager and mNameSpaceManager in nsJSEnvironment.cpp. These still need to move from nsJSContext to nsGlobalWindow or thereabouts, jband and vidur are looking at that.
- Added comments and expanded tabs in nsJSEnvironment.cpp, esp. to EvaluateString. Also changed various nsresult vars to be named rv. Also restored brace/style conformity to nsJSProtocolHandler.cpp.
- Factored CompileFunction from AddScriptEventListener to pave the way for brutal sharing of compiled JS event handlers via JS_CloneFunctionObject.
- Lots of nsCOMPtr uses added. I'm using one for mNameSpaceManager. Hold mSecurityManager as a service explicitly, on the other hand (awaiting scc's fix to allow comptrs for services), and release in nsJSContext's dtor (fixing a leak). These two managers should be moved to the window object -- TODO item below.
- Hold JSRuntimeService along with JSRuntime for live of nsJSEnvironment, fix for shaver.
- Fix window.setTimeout etc. so the filename and line number of the timeout expr is propagated. This meant factoring nsJSUtils.cpp code.
- Fix all content sinks to use the same, and up-to-date JavaScript version parsing (whether for script type or for old language attribute); also fix SplitMimeType clones to strip whitespace.
- With waterson, fix bug in brutal-sharing version of XUL content sink: script src= should not evaluate the inline content of its tag.
1999-10-31 00:43:30 +00:00
|
|
|
// model and the output document, and register the XML content sink
|
1999-06-28 14:49:29 +00:00
|
|
|
// as the transform observer. The transform mediator will call
|
|
|
|
// the nsIObserver::Observe() method on the transform observer once
|
|
|
|
// the transform is completed. The nsISupports pointer to the Observe
|
|
|
|
// method will be an nsIDOMElement pointer to the root node of the output
|
|
|
|
// content model.
|
|
|
|
nsresult
|
|
|
|
nsXMLContentSink::SetupTransformMediator()
|
|
|
|
{
|
|
|
|
nsIDOMElement* source;
|
|
|
|
nsIDOMDocument* currentDoc;
|
|
|
|
nsresult rv = NS_OK;
|
|
|
|
|
|
|
|
rv = mDocElement->QueryInterface(kIDOMElementIID, (void **) &source);
|
|
|
|
if (NS_SUCCEEDED(rv)) {
|
|
|
|
mXSLTransformMediator->SetSourceContentModel(source);
|
|
|
|
rv = mDocument->QueryInterface(kIDOMDocumentIID, (void **) ¤tDoc);
|
|
|
|
if (NS_SUCCEEDED(rv)) {
|
|
|
|
mXSLTransformMediator->SetCurrentDocument(currentDoc);
|
|
|
|
mXSLTransformMediator->SetTransformObserver(this);
|
|
|
|
NS_RELEASE(currentDoc);
|
|
|
|
}
|
|
|
|
NS_RELEASE(source);
|
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
(13163, r=alecf, scc, waterson, others; names available on request)
- Fix most of bug 13163 (see TODO for rest). This entails adding a version-string argument to nsIScriptContext::EvaluateString and passing it around lots of places in content sinks.
- Fix leaks and confusion about mSecurityManager and mNameSpaceManager in nsJSEnvironment.cpp. These still need to move from nsJSContext to nsGlobalWindow or thereabouts, jband and vidur are looking at that.
- Added comments and expanded tabs in nsJSEnvironment.cpp, esp. to EvaluateString. Also changed various nsresult vars to be named rv. Also restored brace/style conformity to nsJSProtocolHandler.cpp.
- Factored CompileFunction from AddScriptEventListener to pave the way for brutal sharing of compiled JS event handlers via JS_CloneFunctionObject.
- Lots of nsCOMPtr uses added. I'm using one for mNameSpaceManager. Hold mSecurityManager as a service explicitly, on the other hand (awaiting scc's fix to allow comptrs for services), and release in nsJSContext's dtor (fixing a leak). These two managers should be moved to the window object -- TODO item below.
- Hold JSRuntimeService along with JSRuntime for live of nsJSEnvironment, fix for shaver.
- Fix window.setTimeout etc. so the filename and line number of the timeout expr is propagated. This meant factoring nsJSUtils.cpp code.
- Fix all content sinks to use the same, and up-to-date JavaScript version parsing (whether for script type or for old language attribute); also fix SplitMimeType clones to strip whitespace.
- With waterson, fix bug in brutal-sharing version of XUL content sink: script src= should not evaluate the inline content of its tag.
1999-10-31 00:43:30 +00:00
|
|
|
NS_IMETHODIMP
|
1998-11-11 22:06:16 +00:00
|
|
|
nsXMLContentSink::WillInterrupt(void)
|
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
(13163, r=alecf, scc, waterson, others; names available on request)
- Fix most of bug 13163 (see TODO for rest). This entails adding a version-string argument to nsIScriptContext::EvaluateString and passing it around lots of places in content sinks.
- Fix leaks and confusion about mSecurityManager and mNameSpaceManager in nsJSEnvironment.cpp. These still need to move from nsJSContext to nsGlobalWindow or thereabouts, jband and vidur are looking at that.
- Added comments and expanded tabs in nsJSEnvironment.cpp, esp. to EvaluateString. Also changed various nsresult vars to be named rv. Also restored brace/style conformity to nsJSProtocolHandler.cpp.
- Factored CompileFunction from AddScriptEventListener to pave the way for brutal sharing of compiled JS event handlers via JS_CloneFunctionObject.
- Lots of nsCOMPtr uses added. I'm using one for mNameSpaceManager. Hold mSecurityManager as a service explicitly, on the other hand (awaiting scc's fix to allow comptrs for services), and release in nsJSContext's dtor (fixing a leak). These two managers should be moved to the window object -- TODO item below.
- Hold JSRuntimeService along with JSRuntime for live of nsJSEnvironment, fix for shaver.
- Fix window.setTimeout etc. so the filename and line number of the timeout expr is propagated. This meant factoring nsJSUtils.cpp code.
- Fix all content sinks to use the same, and up-to-date JavaScript version parsing (whether for script type or for old language attribute); also fix SplitMimeType clones to strip whitespace.
- With waterson, fix bug in brutal-sharing version of XUL content sink: script src= should not evaluate the inline content of its tag.
1999-10-31 00:43:30 +00:00
|
|
|
NS_IMETHODIMP
|
1998-11-11 22:06:16 +00:00
|
|
|
nsXMLContentSink::WillResume(void)
|
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-12-11 17:02:37 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsXMLContentSink::SetParser(nsIParser* aParser)
|
|
|
|
{
|
|
|
|
NS_IF_RELEASE(mParser);
|
|
|
|
mParser = aParser;
|
|
|
|
NS_IF_ADDREF(mParser);
|
(13163, r=alecf, scc, waterson, others; names available on request)
- Fix most of bug 13163 (see TODO for rest). This entails adding a version-string argument to nsIScriptContext::EvaluateString and passing it around lots of places in content sinks.
- Fix leaks and confusion about mSecurityManager and mNameSpaceManager in nsJSEnvironment.cpp. These still need to move from nsJSContext to nsGlobalWindow or thereabouts, jband and vidur are looking at that.
- Added comments and expanded tabs in nsJSEnvironment.cpp, esp. to EvaluateString. Also changed various nsresult vars to be named rv. Also restored brace/style conformity to nsJSProtocolHandler.cpp.
- Factored CompileFunction from AddScriptEventListener to pave the way for brutal sharing of compiled JS event handlers via JS_CloneFunctionObject.
- Lots of nsCOMPtr uses added. I'm using one for mNameSpaceManager. Hold mSecurityManager as a service explicitly, on the other hand (awaiting scc's fix to allow comptrs for services), and release in nsJSContext's dtor (fixing a leak). These two managers should be moved to the window object -- TODO item below.
- Hold JSRuntimeService along with JSRuntime for live of nsJSEnvironment, fix for shaver.
- Fix window.setTimeout etc. so the filename and line number of the timeout expr is propagated. This meant factoring nsJSUtils.cpp code.
- Fix all content sinks to use the same, and up-to-date JavaScript version parsing (whether for script type or for old language attribute); also fix SplitMimeType clones to strip whitespace.
- With waterson, fix bug in brutal-sharing version of XUL content sink: script src= should not evaluate the inline content of its tag.
1999-10-31 00:43:30 +00:00
|
|
|
|
1998-12-11 17:02:37 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-11-11 22:06:16 +00:00
|
|
|
// XXX Code copied from nsHTMLContentSink. It should be shared.
|
1999-09-30 22:07:04 +00:00
|
|
|
void
|
|
|
|
nsXMLContentSink::GetAttributeValueAt(const nsIParserNode& aNode,
|
|
|
|
PRInt32 aIndex,
|
|
|
|
nsString& aResult)
|
1998-11-11 22:06:16 +00:00
|
|
|
{
|
|
|
|
// Copy value
|
|
|
|
const nsString& value = aNode.GetValueAt(aIndex);
|
|
|
|
aResult.Truncate();
|
|
|
|
aResult.Append(value);
|
|
|
|
|
|
|
|
// Strip quotes if present
|
|
|
|
PRUnichar first = aResult.First();
|
1999-02-12 17:45:58 +00:00
|
|
|
if ((first == '\"') || (first == '\'')) {
|
1998-11-11 22:06:16 +00:00
|
|
|
if (aResult.Last() == first) {
|
|
|
|
aResult.Cut(0, 1);
|
|
|
|
PRInt32 pos = aResult.Length() - 1;
|
|
|
|
if (pos >= 0) {
|
|
|
|
aResult.Cut(pos, 1);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// Mismatched quotes - leave them in
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-09-30 22:07:04 +00:00
|
|
|
if (mParser) {
|
|
|
|
nsCOMPtr<nsIDTD> dtd;
|
(13163, r=alecf, scc, waterson, others; names available on request)
- Fix most of bug 13163 (see TODO for rest). This entails adding a version-string argument to nsIScriptContext::EvaluateString and passing it around lots of places in content sinks.
- Fix leaks and confusion about mSecurityManager and mNameSpaceManager in nsJSEnvironment.cpp. These still need to move from nsJSContext to nsGlobalWindow or thereabouts, jband and vidur are looking at that.
- Added comments and expanded tabs in nsJSEnvironment.cpp, esp. to EvaluateString. Also changed various nsresult vars to be named rv. Also restored brace/style conformity to nsJSProtocolHandler.cpp.
- Factored CompileFunction from AddScriptEventListener to pave the way for brutal sharing of compiled JS event handlers via JS_CloneFunctionObject.
- Lots of nsCOMPtr uses added. I'm using one for mNameSpaceManager. Hold mSecurityManager as a service explicitly, on the other hand (awaiting scc's fix to allow comptrs for services), and release in nsJSContext's dtor (fixing a leak). These two managers should be moved to the window object -- TODO item below.
- Hold JSRuntimeService along with JSRuntime for live of nsJSEnvironment, fix for shaver.
- Fix window.setTimeout etc. so the filename and line number of the timeout expr is propagated. This meant factoring nsJSUtils.cpp code.
- Fix all content sinks to use the same, and up-to-date JavaScript version parsing (whether for script type or for old language attribute); also fix SplitMimeType clones to strip whitespace.
- With waterson, fix bug in brutal-sharing version of XUL content sink: script src= should not evaluate the inline content of its tag.
1999-10-31 00:43:30 +00:00
|
|
|
|
1999-09-30 22:07:04 +00:00
|
|
|
nsresult rv = mParser->GetDTD(getter_AddRefs(dtd));
|
(13163, r=alecf, scc, waterson, others; names available on request)
- Fix most of bug 13163 (see TODO for rest). This entails adding a version-string argument to nsIScriptContext::EvaluateString and passing it around lots of places in content sinks.
- Fix leaks and confusion about mSecurityManager and mNameSpaceManager in nsJSEnvironment.cpp. These still need to move from nsJSContext to nsGlobalWindow or thereabouts, jband and vidur are looking at that.
- Added comments and expanded tabs in nsJSEnvironment.cpp, esp. to EvaluateString. Also changed various nsresult vars to be named rv. Also restored brace/style conformity to nsJSProtocolHandler.cpp.
- Factored CompileFunction from AddScriptEventListener to pave the way for brutal sharing of compiled JS event handlers via JS_CloneFunctionObject.
- Lots of nsCOMPtr uses added. I'm using one for mNameSpaceManager. Hold mSecurityManager as a service explicitly, on the other hand (awaiting scc's fix to allow comptrs for services), and release in nsJSContext's dtor (fixing a leak). These two managers should be moved to the window object -- TODO item below.
- Hold JSRuntimeService along with JSRuntime for live of nsJSEnvironment, fix for shaver.
- Fix window.setTimeout etc. so the filename and line number of the timeout expr is propagated. This meant factoring nsJSUtils.cpp code.
- Fix all content sinks to use the same, and up-to-date JavaScript version parsing (whether for script type or for old language attribute); also fix SplitMimeType clones to strip whitespace.
- With waterson, fix bug in brutal-sharing version of XUL content sink: script src= should not evaluate the inline content of its tag.
1999-10-31 00:43:30 +00:00
|
|
|
|
1999-09-30 22:07:04 +00:00
|
|
|
if (NS_SUCCEEDED(rv)) {
|
(13163, r=alecf, scc, waterson, others; names available on request)
- Fix most of bug 13163 (see TODO for rest). This entails adding a version-string argument to nsIScriptContext::EvaluateString and passing it around lots of places in content sinks.
- Fix leaks and confusion about mSecurityManager and mNameSpaceManager in nsJSEnvironment.cpp. These still need to move from nsJSContext to nsGlobalWindow or thereabouts, jband and vidur are looking at that.
- Added comments and expanded tabs in nsJSEnvironment.cpp, esp. to EvaluateString. Also changed various nsresult vars to be named rv. Also restored brace/style conformity to nsJSProtocolHandler.cpp.
- Factored CompileFunction from AddScriptEventListener to pave the way for brutal sharing of compiled JS event handlers via JS_CloneFunctionObject.
- Lots of nsCOMPtr uses added. I'm using one for mNameSpaceManager. Hold mSecurityManager as a service explicitly, on the other hand (awaiting scc's fix to allow comptrs for services), and release in nsJSContext's dtor (fixing a leak). These two managers should be moved to the window object -- TODO item below.
- Hold JSRuntimeService along with JSRuntime for live of nsJSEnvironment, fix for shaver.
- Fix window.setTimeout etc. so the filename and line number of the timeout expr is propagated. This meant factoring nsJSUtils.cpp code.
- Fix all content sinks to use the same, and up-to-date JavaScript version parsing (whether for script type or for old language attribute); also fix SplitMimeType clones to strip whitespace.
- With waterson, fix bug in brutal-sharing version of XUL content sink: script src= should not evaluate the inline content of its tag.
1999-10-31 00:43:30 +00:00
|
|
|
|
1999-09-30 22:07:04 +00:00
|
|
|
// Reduce any entities
|
|
|
|
// XXX Note: as coded today, this will only convert well formed
|
|
|
|
// entities. This may not be compatible enough.
|
|
|
|
// XXX there is a table in navigator that translates some numeric entities
|
|
|
|
// should we be doing that? If so then it needs to live in two places (bad)
|
|
|
|
// so we should add a translate numeric entity method from the parser...
|
|
|
|
char cbuf[100];
|
|
|
|
PRInt32 index = 0;
|
|
|
|
while (index < aResult.Length()) {
|
|
|
|
// If we have the start of an entity (and it's not at the end of
|
|
|
|
// our string) then translate the entity into it's unicode value.
|
|
|
|
if ((aResult.CharAt(index++) == '&') && (index < aResult.Length())) {
|
|
|
|
PRInt32 start = index - 1;
|
|
|
|
PRUnichar e = aResult.CharAt(index);
|
|
|
|
if (e == '#') {
|
|
|
|
// Convert a numeric character reference
|
1998-11-11 22:06:16 +00:00
|
|
|
index++;
|
1999-09-30 22:07:04 +00:00
|
|
|
char* cp = cbuf;
|
|
|
|
char* limit = cp + sizeof(cbuf) - 1;
|
|
|
|
PRBool ok = PR_FALSE;
|
|
|
|
PRInt32 slen = aResult.Length();
|
|
|
|
while ((index < slen) && (cp < limit)) {
|
|
|
|
PRUnichar ch = aResult.CharAt(index);
|
|
|
|
if (ch == ';') {
|
|
|
|
index++;
|
|
|
|
ok = PR_TRUE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if ((ch >= '0') && (ch <= '9')) {
|
|
|
|
*cp++ = char(ch);
|
|
|
|
index++;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (!ok || (cp == cbuf)) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
*cp = '\0';
|
|
|
|
if (cp - cbuf > 5) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
PRInt32 ch = PRInt32( ::atoi(cbuf) );
|
|
|
|
if (ch > 65535) {
|
|
|
|
continue;
|
|
|
|
}
|
(13163, r=alecf, scc, waterson, others; names available on request)
- Fix most of bug 13163 (see TODO for rest). This entails adding a version-string argument to nsIScriptContext::EvaluateString and passing it around lots of places in content sinks.
- Fix leaks and confusion about mSecurityManager and mNameSpaceManager in nsJSEnvironment.cpp. These still need to move from nsJSContext to nsGlobalWindow or thereabouts, jband and vidur are looking at that.
- Added comments and expanded tabs in nsJSEnvironment.cpp, esp. to EvaluateString. Also changed various nsresult vars to be named rv. Also restored brace/style conformity to nsJSProtocolHandler.cpp.
- Factored CompileFunction from AddScriptEventListener to pave the way for brutal sharing of compiled JS event handlers via JS_CloneFunctionObject.
- Lots of nsCOMPtr uses added. I'm using one for mNameSpaceManager. Hold mSecurityManager as a service explicitly, on the other hand (awaiting scc's fix to allow comptrs for services), and release in nsJSContext's dtor (fixing a leak). These two managers should be moved to the window object -- TODO item below.
- Hold JSRuntimeService along with JSRuntime for live of nsJSEnvironment, fix for shaver.
- Fix window.setTimeout etc. so the filename and line number of the timeout expr is propagated. This meant factoring nsJSUtils.cpp code.
- Fix all content sinks to use the same, and up-to-date JavaScript version parsing (whether for script type or for old language attribute); also fix SplitMimeType clones to strip whitespace.
- With waterson, fix bug in brutal-sharing version of XUL content sink: script src= should not evaluate the inline content of its tag.
1999-10-31 00:43:30 +00:00
|
|
|
|
1999-09-30 22:07:04 +00:00
|
|
|
// Remove entity from string and replace it with the integer
|
|
|
|
// value.
|
|
|
|
aResult.Cut(start, index - start);
|
|
|
|
aResult.Insert(PRUnichar(ch), start);
|
|
|
|
index = start + 1;
|
1998-11-11 22:06:16 +00:00
|
|
|
}
|
1999-09-30 22:07:04 +00:00
|
|
|
else if (((e >= 'A') && (e <= 'Z')) ||
|
|
|
|
((e >= 'a') && (e <= 'z'))) {
|
|
|
|
// Convert a named entity
|
1998-11-11 22:06:16 +00:00
|
|
|
index++;
|
1999-09-30 22:07:04 +00:00
|
|
|
char* cp = cbuf;
|
|
|
|
char* limit = cp + sizeof(cbuf) - 1;
|
|
|
|
*cp++ = char(e);
|
|
|
|
PRBool ok = PR_FALSE;
|
|
|
|
PRInt32 slen = aResult.Length();
|
|
|
|
while ((index < slen) && (cp < limit)) {
|
|
|
|
PRUnichar ch = aResult.CharAt(index);
|
|
|
|
if (ch == ';') {
|
|
|
|
index++;
|
|
|
|
ok = PR_TRUE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (((ch >= '0') && (ch <= '9')) ||
|
|
|
|
((ch >= 'A') && (ch <= 'Z')) ||
|
|
|
|
((ch >= 'a') && (ch <= 'z'))) {
|
|
|
|
*cp++ = char(ch);
|
|
|
|
index++;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (!ok || (cp == cbuf)) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
*cp = '\0';
|
|
|
|
PRInt32 ch;
|
|
|
|
nsAutoString str(cbuf);
|
|
|
|
dtd->ConvertEntityToUnicode(str, &ch);
|
|
|
|
if (ch < 0) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Remove entity from string and replace it with the integer
|
|
|
|
// value.
|
|
|
|
aResult.Cut(start, index - start);
|
|
|
|
aResult.Insert(PRUnichar(ch), start);
|
|
|
|
index = start + 1;
|
1998-11-11 22:06:16 +00:00
|
|
|
}
|
1999-09-30 22:07:04 +00:00
|
|
|
else if (e == '{') {
|
|
|
|
// Convert a script entity
|
|
|
|
// XXX write me!
|
1998-11-11 22:06:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// XXX Code copied from nsHTMLContentSink. It should be shared.
|
1998-12-20 01:21:23 +00:00
|
|
|
nsresult
|
|
|
|
nsXMLContentSink::AddAttributes(const nsIParserNode& aNode,
|
|
|
|
nsIContent* aContent,
|
|
|
|
PRBool aIsHTML)
|
1998-11-11 22:06:16 +00:00
|
|
|
{
|
|
|
|
// Add tag attributes to the content attributes
|
1998-12-20 01:21:23 +00:00
|
|
|
nsAutoString name, v;
|
1998-11-11 22:06:16 +00:00
|
|
|
PRInt32 ac = aNode.GetAttributeCount();
|
|
|
|
for (PRInt32 i = 0; i < ac; i++) {
|
|
|
|
// Get upper-cased key
|
|
|
|
const nsString& key = aNode.GetKeyAt(i);
|
1998-12-20 01:21:23 +00:00
|
|
|
name.Truncate();
|
|
|
|
name.Append(key);
|
1998-11-11 22:06:16 +00:00
|
|
|
|
1998-12-20 01:21:23 +00:00
|
|
|
nsIAtom* nameSpacePrefix = CutNameSpacePrefix(name);
|
|
|
|
nsIAtom* nameAtom = NS_NewAtom(name);
|
1999-06-04 01:16:18 +00:00
|
|
|
PRInt32 nameSpaceID = (nsnull == nameSpacePrefix) ? kNameSpaceID_None : GetNameSpaceId(nameSpacePrefix);
|
1999-06-10 05:33:47 +00:00
|
|
|
if (kNameSpaceID_Unknown == nameSpaceID) {
|
|
|
|
nameSpaceID = kNameSpaceID_None; // XXX is this correct? or is it a bad document?
|
|
|
|
}
|
1999-02-18 00:18:50 +00:00
|
|
|
if ((kNameSpaceID_XMLNS == nameSpaceID) && aIsHTML) {
|
|
|
|
NS_RELEASE(nameAtom);
|
|
|
|
name.Insert("xmlns:", 0);
|
|
|
|
nameAtom = NS_NewAtom(name);
|
1999-06-10 05:33:47 +00:00
|
|
|
nameSpaceID = kNameSpaceID_HTML; // XXX this is wrong, but necessary until HTML can store other namespaces for attrs
|
1998-12-21 05:59:40 +00:00
|
|
|
}
|
1998-11-11 22:06:16 +00:00
|
|
|
|
|
|
|
nsAutoString value;
|
(13163, r=alecf, scc, waterson, others; names available on request)
- Fix most of bug 13163 (see TODO for rest). This entails adding a version-string argument to nsIScriptContext::EvaluateString and passing it around lots of places in content sinks.
- Fix leaks and confusion about mSecurityManager and mNameSpaceManager in nsJSEnvironment.cpp. These still need to move from nsJSContext to nsGlobalWindow or thereabouts, jband and vidur are looking at that.
- Added comments and expanded tabs in nsJSEnvironment.cpp, esp. to EvaluateString. Also changed various nsresult vars to be named rv. Also restored brace/style conformity to nsJSProtocolHandler.cpp.
- Factored CompileFunction from AddScriptEventListener to pave the way for brutal sharing of compiled JS event handlers via JS_CloneFunctionObject.
- Lots of nsCOMPtr uses added. I'm using one for mNameSpaceManager. Hold mSecurityManager as a service explicitly, on the other hand (awaiting scc's fix to allow comptrs for services), and release in nsJSContext's dtor (fixing a leak). These two managers should be moved to the window object -- TODO item below.
- Hold JSRuntimeService along with JSRuntime for live of nsJSEnvironment, fix for shaver.
- Fix window.setTimeout etc. so the filename and line number of the timeout expr is propagated. This meant factoring nsJSUtils.cpp code.
- Fix all content sinks to use the same, and up-to-date JavaScript version parsing (whether for script type or for old language attribute); also fix SplitMimeType clones to strip whitespace.
- With waterson, fix bug in brutal-sharing version of XUL content sink: script src= should not evaluate the inline content of its tag.
1999-10-31 00:43:30 +00:00
|
|
|
if (NS_CONTENT_ATTR_NOT_THERE ==
|
1998-12-20 01:21:23 +00:00
|
|
|
aContent->GetAttribute(nameSpaceID, nameAtom, value)) {
|
1998-11-11 22:06:16 +00:00
|
|
|
// Get value and remove mandatory quotes
|
|
|
|
GetAttributeValueAt(aNode, i, v);
|
|
|
|
|
|
|
|
// Add attribute to content
|
1998-12-20 01:21:23 +00:00
|
|
|
aContent->SetAttribute(nameSpaceID, nameAtom, v, PR_FALSE);
|
1998-11-11 22:06:16 +00:00
|
|
|
}
|
1998-12-20 01:21:23 +00:00
|
|
|
NS_RELEASE(nameAtom);
|
|
|
|
NS_IF_RELEASE(nameSpacePrefix);
|
1998-11-11 22:06:16 +00:00
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
1998-12-11 02:53:49 +00:00
|
|
|
nsXMLContentSink::PushNameSpacesFrom(const nsIParserNode& aNode)
|
1998-11-11 22:06:16 +00:00
|
|
|
{
|
|
|
|
nsAutoString k, uri, prefix;
|
|
|
|
PRInt32 ac = aNode.GetAttributeCount();
|
|
|
|
PRInt32 offset;
|
1998-12-11 02:53:49 +00:00
|
|
|
nsINameSpace* nameSpace = nsnull;
|
1998-11-11 22:06:16 +00:00
|
|
|
|
1998-12-11 02:53:49 +00:00
|
|
|
if ((nsnull != mNameSpaceStack) && (0 < mNameSpaceStack->Count())) {
|
|
|
|
nameSpace = (nsINameSpace*)mNameSpaceStack->ElementAt(mNameSpaceStack->Count() - 1);
|
|
|
|
NS_ADDREF(nameSpace);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
nsINameSpaceManager* manager = nsnull;
|
|
|
|
mDocument->GetNameSpaceManager(manager);
|
|
|
|
NS_ASSERTION(nsnull != manager, "no name space manager in document");
|
|
|
|
if (nsnull != manager) {
|
|
|
|
manager->CreateRootNameSpace(nameSpace);
|
|
|
|
NS_RELEASE(manager);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (nsnull != nameSpace) {
|
|
|
|
for (PRInt32 i = 0; i < ac; i++) {
|
|
|
|
const nsString& key = aNode.GetKeyAt(i);
|
|
|
|
k.Truncate();
|
|
|
|
k.Append(key);
|
|
|
|
// Look for "xmlns" at the start of the attribute name
|
|
|
|
offset = k.Find(kNameSpaceDef);
|
|
|
|
if (0 == offset) {
|
1999-01-21 19:33:03 +00:00
|
|
|
if (k.Length() == (sizeof(kNameSpaceDef)-1)) {
|
|
|
|
// If there's nothing left, this is a default namespace
|
|
|
|
prefix.Truncate();
|
1998-12-11 02:53:49 +00:00
|
|
|
}
|
|
|
|
else {
|
1999-01-21 19:33:03 +00:00
|
|
|
PRUnichar next = k.CharAt(sizeof(kNameSpaceDef)-1);
|
|
|
|
// If the next character is a :, there is a namespace prefix
|
|
|
|
if (':' == next) {
|
1999-02-02 03:24:56 +00:00
|
|
|
prefix.Truncate();
|
1999-01-21 19:33:03 +00:00
|
|
|
k.Right(prefix, k.Length()-sizeof(kNameSpaceDef));
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
continue;
|
|
|
|
}
|
1998-12-11 02:53:49 +00:00
|
|
|
}
|
1998-11-11 22:06:16 +00:00
|
|
|
|
1998-12-11 02:53:49 +00:00
|
|
|
// Get the attribute value (the URI for the namespace)
|
|
|
|
GetAttributeValueAt(aNode, i, uri);
|
(13163, r=alecf, scc, waterson, others; names available on request)
- Fix most of bug 13163 (see TODO for rest). This entails adding a version-string argument to nsIScriptContext::EvaluateString and passing it around lots of places in content sinks.
- Fix leaks and confusion about mSecurityManager and mNameSpaceManager in nsJSEnvironment.cpp. These still need to move from nsJSContext to nsGlobalWindow or thereabouts, jband and vidur are looking at that.
- Added comments and expanded tabs in nsJSEnvironment.cpp, esp. to EvaluateString. Also changed various nsresult vars to be named rv. Also restored brace/style conformity to nsJSProtocolHandler.cpp.
- Factored CompileFunction from AddScriptEventListener to pave the way for brutal sharing of compiled JS event handlers via JS_CloneFunctionObject.
- Lots of nsCOMPtr uses added. I'm using one for mNameSpaceManager. Hold mSecurityManager as a service explicitly, on the other hand (awaiting scc's fix to allow comptrs for services), and release in nsJSContext's dtor (fixing a leak). These two managers should be moved to the window object -- TODO item below.
- Hold JSRuntimeService along with JSRuntime for live of nsJSEnvironment, fix for shaver.
- Fix window.setTimeout etc. so the filename and line number of the timeout expr is propagated. This meant factoring nsJSUtils.cpp code.
- Fix all content sinks to use the same, and up-to-date JavaScript version parsing (whether for script type or for old language attribute); also fix SplitMimeType clones to strip whitespace.
- With waterson, fix bug in brutal-sharing version of XUL content sink: script src= should not evaluate the inline content of its tag.
1999-10-31 00:43:30 +00:00
|
|
|
|
1998-12-11 02:53:49 +00:00
|
|
|
// Open a local namespace
|
|
|
|
nsIAtom* prefixAtom = ((0 < prefix.Length()) ? NS_NewAtom(prefix) : nsnull);
|
|
|
|
nsINameSpace* child = nsnull;
|
|
|
|
nameSpace->CreateChildNameSpace(prefixAtom, uri, child);
|
|
|
|
if (nsnull != child) {
|
|
|
|
NS_RELEASE(nameSpace);
|
|
|
|
nameSpace = child;
|
|
|
|
}
|
|
|
|
NS_IF_RELEASE(prefixAtom);
|
|
|
|
}
|
1998-11-11 22:06:16 +00:00
|
|
|
}
|
1998-12-11 02:53:49 +00:00
|
|
|
if (nsnull == mNameSpaceStack) {
|
|
|
|
mNameSpaceStack = new nsVoidArray();
|
|
|
|
}
|
|
|
|
mNameSpaceStack->AppendElement(nameSpace);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
nsIAtom* nsXMLContentSink::CutNameSpacePrefix(nsString& aString)
|
|
|
|
{
|
|
|
|
nsAutoString prefix;
|
1999-07-18 00:34:41 +00:00
|
|
|
PRInt32 nsoffset = aString.FindChar(kNameSpaceSeparator);
|
1998-12-11 02:53:49 +00:00
|
|
|
if (-1 != nsoffset) {
|
|
|
|
aString.Left(prefix, nsoffset);
|
|
|
|
aString.Cut(0, nsoffset+1);
|
|
|
|
}
|
|
|
|
if (0 < prefix.Length()) {
|
|
|
|
return NS_NewAtom(prefix);
|
1998-11-11 22:06:16 +00:00
|
|
|
}
|
1998-12-11 02:53:49 +00:00
|
|
|
return nsnull;
|
1998-11-11 22:06:16 +00:00
|
|
|
}
|
|
|
|
|
(13163, r=alecf, scc, waterson, others; names available on request)
- Fix most of bug 13163 (see TODO for rest). This entails adding a version-string argument to nsIScriptContext::EvaluateString and passing it around lots of places in content sinks.
- Fix leaks and confusion about mSecurityManager and mNameSpaceManager in nsJSEnvironment.cpp. These still need to move from nsJSContext to nsGlobalWindow or thereabouts, jband and vidur are looking at that.
- Added comments and expanded tabs in nsJSEnvironment.cpp, esp. to EvaluateString. Also changed various nsresult vars to be named rv. Also restored brace/style conformity to nsJSProtocolHandler.cpp.
- Factored CompileFunction from AddScriptEventListener to pave the way for brutal sharing of compiled JS event handlers via JS_CloneFunctionObject.
- Lots of nsCOMPtr uses added. I'm using one for mNameSpaceManager. Hold mSecurityManager as a service explicitly, on the other hand (awaiting scc's fix to allow comptrs for services), and release in nsJSContext's dtor (fixing a leak). These two managers should be moved to the window object -- TODO item below.
- Hold JSRuntimeService along with JSRuntime for live of nsJSEnvironment, fix for shaver.
- Fix window.setTimeout etc. so the filename and line number of the timeout expr is propagated. This meant factoring nsJSUtils.cpp code.
- Fix all content sinks to use the same, and up-to-date JavaScript version parsing (whether for script type or for old language attribute); also fix SplitMimeType clones to strip whitespace.
- With waterson, fix bug in brutal-sharing version of XUL content sink: script src= should not evaluate the inline content of its tag.
1999-10-31 00:43:30 +00:00
|
|
|
NS_IMETHODIMP
|
1998-11-11 22:06:16 +00:00
|
|
|
nsXMLContentSink::OpenContainer(const nsIParserNode& aNode)
|
|
|
|
{
|
|
|
|
nsresult result = NS_OK;
|
1998-12-11 02:53:49 +00:00
|
|
|
nsAutoString tag;
|
2000-01-19 04:44:10 +00:00
|
|
|
nsCOMPtr<nsIAtom> nameSpacePrefix;
|
1998-12-11 02:53:49 +00:00
|
|
|
PRInt32 nameSpaceID = kNameSpaceID_Unknown;
|
1998-11-16 06:16:17 +00:00
|
|
|
PRBool isHTML = PR_FALSE;
|
|
|
|
PRBool pushContent = PR_TRUE;
|
2000-01-19 04:44:10 +00:00
|
|
|
nsCOMPtr<nsIContent> content;
|
1998-11-11 22:06:16 +00:00
|
|
|
|
|
|
|
// XXX Hopefully the parser will flag this before we get
|
|
|
|
// here. If we're in the epilog, there should be no
|
|
|
|
// new elements
|
|
|
|
PR_ASSERT(eXMLContentSinkState_InEpilog != mState);
|
|
|
|
|
|
|
|
FlushText();
|
|
|
|
|
|
|
|
mState = eXMLContentSinkState_InDocumentElement;
|
|
|
|
|
|
|
|
tag = aNode.GetText();
|
2000-01-19 04:44:10 +00:00
|
|
|
nameSpacePrefix = getter_AddRefs(CutNameSpacePrefix(tag));
|
1998-11-11 22:06:16 +00:00
|
|
|
|
|
|
|
// We must register namespace declarations found in the attribute list
|
|
|
|
// of an element before creating the element. This is because the
|
|
|
|
// namespace prefix for an element might be declared within the attribute
|
|
|
|
// list.
|
1998-12-11 02:53:49 +00:00
|
|
|
PushNameSpacesFrom(aNode);
|
1998-11-11 22:06:16 +00:00
|
|
|
|
1998-12-11 02:53:49 +00:00
|
|
|
nameSpaceID = GetNameSpaceId(nameSpacePrefix);
|
|
|
|
isHTML = IsHTMLNameSpace(nameSpaceID);
|
1998-11-11 22:06:16 +00:00
|
|
|
|
|
|
|
if (isHTML) {
|
2000-01-19 04:44:10 +00:00
|
|
|
nsCOMPtr<nsIAtom> tagAtom = getter_AddRefs(NS_NewAtom(tag));
|
|
|
|
if (nsHTMLAtoms::script == tagAtom.get()) {
|
1998-11-12 23:55:47 +00:00
|
|
|
result = ProcessStartSCRIPTTag(aNode);
|
|
|
|
}
|
2000-01-19 04:44:10 +00:00
|
|
|
|
|
|
|
nsCOMPtr<nsIHTMLContent> htmlContent;
|
|
|
|
result = NS_CreateHTMLElement(getter_AddRefs(htmlContent), tag);
|
|
|
|
content = do_QueryInterface(htmlContent);
|
1998-11-11 22:06:16 +00:00
|
|
|
}
|
|
|
|
else {
|
2000-01-19 04:44:10 +00:00
|
|
|
// The first step here is to see if someone has provided their
|
|
|
|
// own content element implementation (e.g., XUL or MathML).
|
|
|
|
// This is done based off a progid/namespace scheme.
|
|
|
|
nsCOMPtr<nsIElementFactory> elementFactory;
|
|
|
|
GetElementFactory(nameSpaceID, getter_AddRefs(elementFactory));
|
|
|
|
if (elementFactory) {
|
|
|
|
// Create the content element using the element factory.
|
|
|
|
elementFactory->CreateInstanceByTag(tag, getter_AddRefs(content));
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
nsCOMPtr<nsIAtom> tagAtom = getter_AddRefs(NS_NewAtom(tag));
|
|
|
|
nsCOMPtr<nsIXMLContent> xmlContent;
|
|
|
|
result = NS_NewXMLElement(getter_AddRefs(xmlContent), tagAtom);
|
|
|
|
|
|
|
|
// For XML elements, set the namespace
|
|
|
|
if (NS_OK == result) {
|
|
|
|
xmlContent->SetNameSpacePrefix(nameSpacePrefix);
|
|
|
|
xmlContent->SetNameSpaceID(nameSpaceID);
|
|
|
|
}
|
|
|
|
content = do_QueryInterface(xmlContent);
|
1998-11-11 22:06:16 +00:00
|
|
|
}
|
|
|
|
}
|
2000-01-19 04:44:10 +00:00
|
|
|
|
1998-11-11 22:06:16 +00:00
|
|
|
if (NS_OK == result) {
|
|
|
|
content->SetDocument(mDocument, PR_FALSE);
|
|
|
|
|
|
|
|
// Set the attributes on the new content element
|
|
|
|
result = AddAttributes(aNode, content, isHTML);
|
|
|
|
if (NS_OK == result) {
|
|
|
|
// If this is the document element
|
|
|
|
if (nsnull == mDocElement) {
|
|
|
|
mDocElement = content;
|
|
|
|
NS_ADDREF(mDocElement);
|
1999-06-28 14:49:29 +00:00
|
|
|
|
(13163, r=alecf, scc, waterson, others; names available on request)
- Fix most of bug 13163 (see TODO for rest). This entails adding a version-string argument to nsIScriptContext::EvaluateString and passing it around lots of places in content sinks.
- Fix leaks and confusion about mSecurityManager and mNameSpaceManager in nsJSEnvironment.cpp. These still need to move from nsJSContext to nsGlobalWindow or thereabouts, jband and vidur are looking at that.
- Added comments and expanded tabs in nsJSEnvironment.cpp, esp. to EvaluateString. Also changed various nsresult vars to be named rv. Also restored brace/style conformity to nsJSProtocolHandler.cpp.
- Factored CompileFunction from AddScriptEventListener to pave the way for brutal sharing of compiled JS event handlers via JS_CloneFunctionObject.
- Lots of nsCOMPtr uses added. I'm using one for mNameSpaceManager. Hold mSecurityManager as a service explicitly, on the other hand (awaiting scc's fix to allow comptrs for services), and release in nsJSContext's dtor (fixing a leak). These two managers should be moved to the window object -- TODO item below.
- Hold JSRuntimeService along with JSRuntime for live of nsJSEnvironment, fix for shaver.
- Fix window.setTimeout etc. so the filename and line number of the timeout expr is propagated. This meant factoring nsJSUtils.cpp code.
- Fix all content sinks to use the same, and up-to-date JavaScript version parsing (whether for script type or for old language attribute); also fix SplitMimeType clones to strip whitespace.
- With waterson, fix bug in brutal-sharing version of XUL content sink: script src= should not evaluate the inline content of its tag.
1999-10-31 00:43:30 +00:00
|
|
|
// For XSL, we need to wait till after the transform
|
1999-06-28 14:49:29 +00:00
|
|
|
// to set the root content object. Hence, the following
|
|
|
|
// ifndef.
|
(13163, r=alecf, scc, waterson, others; names available on request)
- Fix most of bug 13163 (see TODO for rest). This entails adding a version-string argument to nsIScriptContext::EvaluateString and passing it around lots of places in content sinks.
- Fix leaks and confusion about mSecurityManager and mNameSpaceManager in nsJSEnvironment.cpp. These still need to move from nsJSContext to nsGlobalWindow or thereabouts, jband and vidur are looking at that.
- Added comments and expanded tabs in nsJSEnvironment.cpp, esp. to EvaluateString. Also changed various nsresult vars to be named rv. Also restored brace/style conformity to nsJSProtocolHandler.cpp.
- Factored CompileFunction from AddScriptEventListener to pave the way for brutal sharing of compiled JS event handlers via JS_CloneFunctionObject.
- Lots of nsCOMPtr uses added. I'm using one for mNameSpaceManager. Hold mSecurityManager as a service explicitly, on the other hand (awaiting scc's fix to allow comptrs for services), and release in nsJSContext's dtor (fixing a leak). These two managers should be moved to the window object -- TODO item below.
- Hold JSRuntimeService along with JSRuntime for live of nsJSEnvironment, fix for shaver.
- Fix window.setTimeout etc. so the filename and line number of the timeout expr is propagated. This meant factoring nsJSUtils.cpp code.
- Fix all content sinks to use the same, and up-to-date JavaScript version parsing (whether for script type or for old language attribute); also fix SplitMimeType clones to strip whitespace.
- With waterson, fix bug in brutal-sharing version of XUL content sink: script src= should not evaluate the inline content of its tag.
1999-10-31 00:43:30 +00:00
|
|
|
#ifndef XSL
|
1998-11-12 23:55:47 +00:00
|
|
|
mDocument->SetRootContent(mDocElement);
|
1999-06-28 14:49:29 +00:00
|
|
|
#endif
|
1998-11-11 22:06:16 +00:00
|
|
|
}
|
1998-11-12 23:03:35 +00:00
|
|
|
else {
|
|
|
|
nsIContent *parent = GetCurrentContent();
|
1998-11-11 22:06:16 +00:00
|
|
|
|
1998-11-12 23:03:35 +00:00
|
|
|
parent->AppendChildTo(content, PR_FALSE);
|
|
|
|
}
|
1998-11-16 06:16:17 +00:00
|
|
|
if (pushContent) {
|
|
|
|
PushContent(content);
|
|
|
|
}
|
1998-11-11 22:06:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
(13163, r=alecf, scc, waterson, others; names available on request)
- Fix most of bug 13163 (see TODO for rest). This entails adding a version-string argument to nsIScriptContext::EvaluateString and passing it around lots of places in content sinks.
- Fix leaks and confusion about mSecurityManager and mNameSpaceManager in nsJSEnvironment.cpp. These still need to move from nsJSContext to nsGlobalWindow or thereabouts, jband and vidur are looking at that.
- Added comments and expanded tabs in nsJSEnvironment.cpp, esp. to EvaluateString. Also changed various nsresult vars to be named rv. Also restored brace/style conformity to nsJSProtocolHandler.cpp.
- Factored CompileFunction from AddScriptEventListener to pave the way for brutal sharing of compiled JS event handlers via JS_CloneFunctionObject.
- Lots of nsCOMPtr uses added. I'm using one for mNameSpaceManager. Hold mSecurityManager as a service explicitly, on the other hand (awaiting scc's fix to allow comptrs for services), and release in nsJSContext's dtor (fixing a leak). These two managers should be moved to the window object -- TODO item below.
- Hold JSRuntimeService along with JSRuntime for live of nsJSEnvironment, fix for shaver.
- Fix window.setTimeout etc. so the filename and line number of the timeout expr is propagated. This meant factoring nsJSUtils.cpp code.
- Fix all content sinks to use the same, and up-to-date JavaScript version parsing (whether for script type or for old language attribute); also fix SplitMimeType clones to strip whitespace.
- With waterson, fix bug in brutal-sharing version of XUL content sink: script src= should not evaluate the inline content of its tag.
1999-10-31 00:43:30 +00:00
|
|
|
NS_IMETHODIMP
|
1998-11-11 22:06:16 +00:00
|
|
|
nsXMLContentSink::CloseContainer(const nsIParserNode& aNode)
|
|
|
|
{
|
|
|
|
nsresult result = NS_OK;
|
1998-12-11 02:53:49 +00:00
|
|
|
nsAutoString tag;
|
|
|
|
nsIAtom* nameSpacePrefix;
|
|
|
|
PRInt32 nameSpaceID = kNameSpaceID_Unknown;
|
1998-11-16 06:16:17 +00:00
|
|
|
PRBool isHTML = PR_FALSE;
|
|
|
|
PRBool popContent = PR_TRUE;
|
1998-11-11 22:06:16 +00:00
|
|
|
|
|
|
|
// XXX Hopefully the parser will flag this before we get
|
|
|
|
// here. If we're in the prolog or epilog, there should be
|
|
|
|
// no close tags for elements.
|
|
|
|
PR_ASSERT(eXMLContentSinkState_InDocumentElement == mState);
|
1998-11-12 23:55:47 +00:00
|
|
|
|
|
|
|
tag = aNode.GetText();
|
1998-12-11 02:53:49 +00:00
|
|
|
nameSpacePrefix = CutNameSpacePrefix(tag);
|
|
|
|
nameSpaceID = GetNameSpaceId(nameSpacePrefix);
|
|
|
|
isHTML = IsHTMLNameSpace(nameSpaceID);
|
1998-11-12 23:55:47 +00:00
|
|
|
|
|
|
|
if (!mInScript) {
|
|
|
|
FlushText();
|
|
|
|
}
|
1998-11-11 22:06:16 +00:00
|
|
|
|
1998-11-16 06:16:17 +00:00
|
|
|
if (isHTML) {
|
|
|
|
nsIAtom* tagAtom = NS_NewAtom(tag);
|
|
|
|
if (nsHTMLAtoms::script == tagAtom) {
|
|
|
|
result = ProcessEndSCRIPTTag(aNode);
|
1998-11-12 23:55:47 +00:00
|
|
|
}
|
1998-11-16 06:16:17 +00:00
|
|
|
NS_RELEASE(tagAtom);
|
1998-11-11 22:06:16 +00:00
|
|
|
}
|
1998-11-16 06:16:17 +00:00
|
|
|
|
1999-01-12 16:37:24 +00:00
|
|
|
nsIContent* content = nsnull;
|
1998-11-16 06:16:17 +00:00
|
|
|
if (popContent) {
|
1999-01-12 16:37:24 +00:00
|
|
|
content = PopContent();
|
1998-11-16 06:16:17 +00:00
|
|
|
if (nsnull != content) {
|
|
|
|
if (mDocElement == content) {
|
|
|
|
mState = eXMLContentSinkState_InEpilog;
|
1998-12-11 02:53:49 +00:00
|
|
|
}
|
1998-11-16 06:16:17 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
// XXX Again, the parser should catch unmatched tags and
|
|
|
|
// we should never get here.
|
|
|
|
PR_ASSERT(0);
|
|
|
|
}
|
1998-11-11 22:06:16 +00:00
|
|
|
}
|
1999-01-12 16:37:24 +00:00
|
|
|
nsINameSpace* nameSpace = PopNameSpaces();
|
|
|
|
if (nsnull != content) {
|
|
|
|
nsIXMLContent* xmlContent;
|
(13163, r=alecf, scc, waterson, others; names available on request)
- Fix most of bug 13163 (see TODO for rest). This entails adding a version-string argument to nsIScriptContext::EvaluateString and passing it around lots of places in content sinks.
- Fix leaks and confusion about mSecurityManager and mNameSpaceManager in nsJSEnvironment.cpp. These still need to move from nsJSContext to nsGlobalWindow or thereabouts, jband and vidur are looking at that.
- Added comments and expanded tabs in nsJSEnvironment.cpp, esp. to EvaluateString. Also changed various nsresult vars to be named rv. Also restored brace/style conformity to nsJSProtocolHandler.cpp.
- Factored CompileFunction from AddScriptEventListener to pave the way for brutal sharing of compiled JS event handlers via JS_CloneFunctionObject.
- Lots of nsCOMPtr uses added. I'm using one for mNameSpaceManager. Hold mSecurityManager as a service explicitly, on the other hand (awaiting scc's fix to allow comptrs for services), and release in nsJSContext's dtor (fixing a leak). These two managers should be moved to the window object -- TODO item below.
- Hold JSRuntimeService along with JSRuntime for live of nsJSEnvironment, fix for shaver.
- Fix window.setTimeout etc. so the filename and line number of the timeout expr is propagated. This meant factoring nsJSUtils.cpp code.
- Fix all content sinks to use the same, and up-to-date JavaScript version parsing (whether for script type or for old language attribute); also fix SplitMimeType clones to strip whitespace.
- With waterson, fix bug in brutal-sharing version of XUL content sink: script src= should not evaluate the inline content of its tag.
1999-10-31 00:43:30 +00:00
|
|
|
if (NS_OK == content->QueryInterface(kIXMLContentIID,
|
1999-01-12 16:37:24 +00:00
|
|
|
(void **)&xmlContent)) {
|
|
|
|
xmlContent->SetContainingNameSpace(nameSpace);
|
|
|
|
NS_RELEASE(xmlContent);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
NS_IF_RELEASE(nameSpace);
|
1998-11-11 22:06:16 +00:00
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
(13163, r=alecf, scc, waterson, others; names available on request)
- Fix most of bug 13163 (see TODO for rest). This entails adding a version-string argument to nsIScriptContext::EvaluateString and passing it around lots of places in content sinks.
- Fix leaks and confusion about mSecurityManager and mNameSpaceManager in nsJSEnvironment.cpp. These still need to move from nsJSContext to nsGlobalWindow or thereabouts, jband and vidur are looking at that.
- Added comments and expanded tabs in nsJSEnvironment.cpp, esp. to EvaluateString. Also changed various nsresult vars to be named rv. Also restored brace/style conformity to nsJSProtocolHandler.cpp.
- Factored CompileFunction from AddScriptEventListener to pave the way for brutal sharing of compiled JS event handlers via JS_CloneFunctionObject.
- Lots of nsCOMPtr uses added. I'm using one for mNameSpaceManager. Hold mSecurityManager as a service explicitly, on the other hand (awaiting scc's fix to allow comptrs for services), and release in nsJSContext's dtor (fixing a leak). These two managers should be moved to the window object -- TODO item below.
- Hold JSRuntimeService along with JSRuntime for live of nsJSEnvironment, fix for shaver.
- Fix window.setTimeout etc. so the filename and line number of the timeout expr is propagated. This meant factoring nsJSUtils.cpp code.
- Fix all content sinks to use the same, and up-to-date JavaScript version parsing (whether for script type or for old language attribute); also fix SplitMimeType clones to strip whitespace.
- With waterson, fix bug in brutal-sharing version of XUL content sink: script src= should not evaluate the inline content of its tag.
1999-10-31 00:43:30 +00:00
|
|
|
NS_IMETHODIMP
|
1998-11-11 22:06:16 +00:00
|
|
|
nsXMLContentSink::AddLeaf(const nsIParserNode& aNode)
|
|
|
|
{
|
|
|
|
// XXX For now, all leaf content is character data
|
1998-12-11 02:53:49 +00:00
|
|
|
// XXX make sure to push/pop name spaces here too (for attributes)
|
1999-02-26 17:13:51 +00:00
|
|
|
switch (aNode.GetTokenType()) {
|
1999-03-02 23:22:05 +00:00
|
|
|
case eToken_text:
|
|
|
|
case eToken_whitespace:
|
|
|
|
case eToken_newline:
|
|
|
|
AddText(aNode.GetText());
|
|
|
|
break;
|
|
|
|
|
1999-03-31 20:49:25 +00:00
|
|
|
case eToken_cdatasection:
|
1999-10-28 01:50:37 +00:00
|
|
|
/*
|
|
|
|
* If we're inside a <html:script> tag we add the data as text so that
|
|
|
|
* the script can be processed.
|
|
|
|
*
|
|
|
|
* -- jst@citec.fi
|
|
|
|
*/
|
|
|
|
if (mInScript) {
|
|
|
|
AddText(aNode.GetText());
|
|
|
|
} else {
|
|
|
|
AddCDATASection(aNode);
|
|
|
|
}
|
|
|
|
|
1999-03-31 20:49:25 +00:00
|
|
|
break;
|
|
|
|
|
1999-03-02 23:22:05 +00:00
|
|
|
case eToken_entity:
|
|
|
|
{
|
|
|
|
nsAutoString tmp;
|
|
|
|
PRInt32 unicode = aNode.TranslateToUnicodeStr(tmp);
|
|
|
|
if (unicode < 0) {
|
|
|
|
return AddText(aNode.GetText());
|
|
|
|
}
|
|
|
|
return AddText(tmp);
|
1999-02-26 17:13:51 +00:00
|
|
|
}
|
|
|
|
}
|
1998-11-11 22:06:16 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-03-11 05:29:36 +00:00
|
|
|
nsresult nsXMLContentSink::CreateErrorText(const nsParserError* aError, nsString& aErrorString)
|
(13163, r=alecf, scc, waterson, others; names available on request)
- Fix most of bug 13163 (see TODO for rest). This entails adding a version-string argument to nsIScriptContext::EvaluateString and passing it around lots of places in content sinks.
- Fix leaks and confusion about mSecurityManager and mNameSpaceManager in nsJSEnvironment.cpp. These still need to move from nsJSContext to nsGlobalWindow or thereabouts, jband and vidur are looking at that.
- Added comments and expanded tabs in nsJSEnvironment.cpp, esp. to EvaluateString. Also changed various nsresult vars to be named rv. Also restored brace/style conformity to nsJSProtocolHandler.cpp.
- Factored CompileFunction from AddScriptEventListener to pave the way for brutal sharing of compiled JS event handlers via JS_CloneFunctionObject.
- Lots of nsCOMPtr uses added. I'm using one for mNameSpaceManager. Hold mSecurityManager as a service explicitly, on the other hand (awaiting scc's fix to allow comptrs for services), and release in nsJSContext's dtor (fixing a leak). These two managers should be moved to the window object -- TODO item below.
- Hold JSRuntimeService along with JSRuntime for live of nsJSEnvironment, fix for shaver.
- Fix window.setTimeout etc. so the filename and line number of the timeout expr is propagated. This meant factoring nsJSUtils.cpp code.
- Fix all content sinks to use the same, and up-to-date JavaScript version parsing (whether for script type or for old language attribute); also fix SplitMimeType clones to strip whitespace.
- With waterson, fix bug in brutal-sharing version of XUL content sink: script src= should not evaluate the inline content of its tag.
1999-10-31 00:43:30 +00:00
|
|
|
{
|
1999-03-11 05:29:36 +00:00
|
|
|
nsString errorText("XML Parsing Error: ");
|
1999-03-06 02:01:11 +00:00
|
|
|
|
|
|
|
if (aError) {
|
|
|
|
errorText.Append(aError->description);
|
1999-03-11 05:29:36 +00:00
|
|
|
errorText.Append("\nLine Number ");
|
1999-03-06 02:01:11 +00:00
|
|
|
errorText.Append(aError->lineNumber, 10);
|
1999-03-11 05:29:36 +00:00
|
|
|
errorText.Append(", Column ");
|
1999-03-06 02:01:11 +00:00
|
|
|
errorText.Append(aError->colNumber, 10);
|
1999-03-11 05:29:36 +00:00
|
|
|
errorText.Append(":");
|
1999-03-06 02:01:11 +00:00
|
|
|
}
|
(13163, r=alecf, scc, waterson, others; names available on request)
- Fix most of bug 13163 (see TODO for rest). This entails adding a version-string argument to nsIScriptContext::EvaluateString and passing it around lots of places in content sinks.
- Fix leaks and confusion about mSecurityManager and mNameSpaceManager in nsJSEnvironment.cpp. These still need to move from nsJSContext to nsGlobalWindow or thereabouts, jband and vidur are looking at that.
- Added comments and expanded tabs in nsJSEnvironment.cpp, esp. to EvaluateString. Also changed various nsresult vars to be named rv. Also restored brace/style conformity to nsJSProtocolHandler.cpp.
- Factored CompileFunction from AddScriptEventListener to pave the way for brutal sharing of compiled JS event handlers via JS_CloneFunctionObject.
- Lots of nsCOMPtr uses added. I'm using one for mNameSpaceManager. Hold mSecurityManager as a service explicitly, on the other hand (awaiting scc's fix to allow comptrs for services), and release in nsJSContext's dtor (fixing a leak). These two managers should be moved to the window object -- TODO item below.
- Hold JSRuntimeService along with JSRuntime for live of nsJSEnvironment, fix for shaver.
- Fix window.setTimeout etc. so the filename and line number of the timeout expr is propagated. This meant factoring nsJSUtils.cpp code.
- Fix all content sinks to use the same, and up-to-date JavaScript version parsing (whether for script type or for old language attribute); also fix SplitMimeType clones to strip whitespace.
- With waterson, fix bug in brutal-sharing version of XUL content sink: script src= should not evaluate the inline content of its tag.
1999-10-31 00:43:30 +00:00
|
|
|
|
1999-03-11 05:29:36 +00:00
|
|
|
aErrorString = errorText;
|
(13163, r=alecf, scc, waterson, others; names available on request)
- Fix most of bug 13163 (see TODO for rest). This entails adding a version-string argument to nsIScriptContext::EvaluateString and passing it around lots of places in content sinks.
- Fix leaks and confusion about mSecurityManager and mNameSpaceManager in nsJSEnvironment.cpp. These still need to move from nsJSContext to nsGlobalWindow or thereabouts, jband and vidur are looking at that.
- Added comments and expanded tabs in nsJSEnvironment.cpp, esp. to EvaluateString. Also changed various nsresult vars to be named rv. Also restored brace/style conformity to nsJSProtocolHandler.cpp.
- Factored CompileFunction from AddScriptEventListener to pave the way for brutal sharing of compiled JS event handlers via JS_CloneFunctionObject.
- Lots of nsCOMPtr uses added. I'm using one for mNameSpaceManager. Hold mSecurityManager as a service explicitly, on the other hand (awaiting scc's fix to allow comptrs for services), and release in nsJSContext's dtor (fixing a leak). These two managers should be moved to the window object -- TODO item below.
- Hold JSRuntimeService along with JSRuntime for live of nsJSEnvironment, fix for shaver.
- Fix window.setTimeout etc. so the filename and line number of the timeout expr is propagated. This meant factoring nsJSUtils.cpp code.
- Fix all content sinks to use the same, and up-to-date JavaScript version parsing (whether for script type or for old language attribute); also fix SplitMimeType clones to strip whitespace.
- With waterson, fix bug in brutal-sharing version of XUL content sink: script src= should not evaluate the inline content of its tag.
1999-10-31 00:43:30 +00:00
|
|
|
|
1999-03-11 05:29:36 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult nsXMLContentSink::CreateSourceText(const nsParserError* aError, nsString& aSourceString)
|
(13163, r=alecf, scc, waterson, others; names available on request)
- Fix most of bug 13163 (see TODO for rest). This entails adding a version-string argument to nsIScriptContext::EvaluateString and passing it around lots of places in content sinks.
- Fix leaks and confusion about mSecurityManager and mNameSpaceManager in nsJSEnvironment.cpp. These still need to move from nsJSContext to nsGlobalWindow or thereabouts, jband and vidur are looking at that.
- Added comments and expanded tabs in nsJSEnvironment.cpp, esp. to EvaluateString. Also changed various nsresult vars to be named rv. Also restored brace/style conformity to nsJSProtocolHandler.cpp.
- Factored CompileFunction from AddScriptEventListener to pave the way for brutal sharing of compiled JS event handlers via JS_CloneFunctionObject.
- Lots of nsCOMPtr uses added. I'm using one for mNameSpaceManager. Hold mSecurityManager as a service explicitly, on the other hand (awaiting scc's fix to allow comptrs for services), and release in nsJSContext's dtor (fixing a leak). These two managers should be moved to the window object -- TODO item below.
- Hold JSRuntimeService along with JSRuntime for live of nsJSEnvironment, fix for shaver.
- Fix window.setTimeout etc. so the filename and line number of the timeout expr is propagated. This meant factoring nsJSUtils.cpp code.
- Fix all content sinks to use the same, and up-to-date JavaScript version parsing (whether for script type or for old language attribute); also fix SplitMimeType clones to strip whitespace.
- With waterson, fix bug in brutal-sharing version of XUL content sink: script src= should not evaluate the inline content of its tag.
1999-10-31 00:43:30 +00:00
|
|
|
{
|
1999-03-11 05:29:36 +00:00
|
|
|
nsString sourceText;
|
|
|
|
PRInt32 errorPosition = aError->colNumber;
|
|
|
|
|
|
|
|
sourceText.Append(aError->sourceLine);
|
|
|
|
sourceText.Append("\n");
|
1999-04-24 10:23:39 +00:00
|
|
|
for (int i = 0; i < errorPosition; i++)
|
1999-03-11 05:29:36 +00:00
|
|
|
sourceText.Append("-");
|
|
|
|
sourceText.Append("^");
|
|
|
|
|
|
|
|
aSourceString = sourceText;
|
1999-03-06 02:01:11 +00:00
|
|
|
|
1998-11-11 22:06:16 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-03-11 05:29:36 +00:00
|
|
|
static void SetTextStringOnTextNode(const nsString& aTextString, nsIContent* aTextNode)
|
|
|
|
{
|
|
|
|
nsITextContent* text = nsnull;
|
|
|
|
PRUnichar *tempUnicode = aTextString.ToNewUnicode();
|
|
|
|
static NS_DEFINE_IID(kITextContentIID, NS_ITEXT_CONTENT_IID);
|
|
|
|
|
|
|
|
aTextNode->QueryInterface(kITextContentIID, (void**) &text);
|
|
|
|
text->SetText(tempUnicode, aTextString.Length(), PR_FALSE);
|
|
|
|
delete [] tempUnicode;
|
|
|
|
NS_RELEASE(text);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* We create the following XML snippet programmatically and
|
|
|
|
* insert it into the content model:
|
|
|
|
*
|
|
|
|
* <ParserError>
|
|
|
|
* XML Error: "contents of aError->description"
|
|
|
|
* Line Number: "contents of aError->lineNumber"
|
|
|
|
* <SourceText>
|
|
|
|
* "Contents of aError->sourceLine"
|
|
|
|
* "^ pointing at the error location"
|
|
|
|
* </SourceText>
|
|
|
|
* </ParserError>
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsXMLContentSink::NotifyError(const nsParserError* aError)
|
(13163, r=alecf, scc, waterson, others; names available on request)
- Fix most of bug 13163 (see TODO for rest). This entails adding a version-string argument to nsIScriptContext::EvaluateString and passing it around lots of places in content sinks.
- Fix leaks and confusion about mSecurityManager and mNameSpaceManager in nsJSEnvironment.cpp. These still need to move from nsJSContext to nsGlobalWindow or thereabouts, jband and vidur are looking at that.
- Added comments and expanded tabs in nsJSEnvironment.cpp, esp. to EvaluateString. Also changed various nsresult vars to be named rv. Also restored brace/style conformity to nsJSProtocolHandler.cpp.
- Factored CompileFunction from AddScriptEventListener to pave the way for brutal sharing of compiled JS event handlers via JS_CloneFunctionObject.
- Lots of nsCOMPtr uses added. I'm using one for mNameSpaceManager. Hold mSecurityManager as a service explicitly, on the other hand (awaiting scc's fix to allow comptrs for services), and release in nsJSContext's dtor (fixing a leak). These two managers should be moved to the window object -- TODO item below.
- Hold JSRuntimeService along with JSRuntime for live of nsJSEnvironment, fix for shaver.
- Fix window.setTimeout etc. so the filename and line number of the timeout expr is propagated. This meant factoring nsJSUtils.cpp code.
- Fix all content sinks to use the same, and up-to-date JavaScript version parsing (whether for script type or for old language attribute); also fix SplitMimeType clones to strip whitespace.
- With waterson, fix bug in brutal-sharing version of XUL content sink: script src= should not evaluate the inline content of its tag.
1999-10-31 00:43:30 +00:00
|
|
|
{
|
1999-03-11 05:29:36 +00:00
|
|
|
nsresult result = NS_OK;
|
|
|
|
nsAutoString parserErrorTag = "parsererror";
|
|
|
|
nsAutoString sourceTextTag = "sourcetext";
|
(13163, r=alecf, scc, waterson, others; names available on request)
- Fix most of bug 13163 (see TODO for rest). This entails adding a version-string argument to nsIScriptContext::EvaluateString and passing it around lots of places in content sinks.
- Fix leaks and confusion about mSecurityManager and mNameSpaceManager in nsJSEnvironment.cpp. These still need to move from nsJSContext to nsGlobalWindow or thereabouts, jband and vidur are looking at that.
- Added comments and expanded tabs in nsJSEnvironment.cpp, esp. to EvaluateString. Also changed various nsresult vars to be named rv. Also restored brace/style conformity to nsJSProtocolHandler.cpp.
- Factored CompileFunction from AddScriptEventListener to pave the way for brutal sharing of compiled JS event handlers via JS_CloneFunctionObject.
- Lots of nsCOMPtr uses added. I'm using one for mNameSpaceManager. Hold mSecurityManager as a service explicitly, on the other hand (awaiting scc's fix to allow comptrs for services), and release in nsJSContext's dtor (fixing a leak). These two managers should be moved to the window object -- TODO item below.
- Hold JSRuntimeService along with JSRuntime for live of nsJSEnvironment, fix for shaver.
- Fix window.setTimeout etc. so the filename and line number of the timeout expr is propagated. This meant factoring nsJSUtils.cpp code.
- Fix all content sinks to use the same, and up-to-date JavaScript version parsing (whether for script type or for old language attribute); also fix SplitMimeType clones to strip whitespace.
- With waterson, fix bug in brutal-sharing version of XUL content sink: script src= should not evaluate the inline content of its tag.
1999-10-31 00:43:30 +00:00
|
|
|
nsString errorText;
|
1999-03-11 05:29:36 +00:00
|
|
|
nsString sourceText;
|
|
|
|
nsIHTMLContent* errorContainerNode = nsnull;
|
|
|
|
nsIHTMLContent* sourceContainerNode = nsnull;
|
|
|
|
nsIContent* errorTextNode = nsnull;
|
|
|
|
nsIContent* sourceTextNode = nsnull;
|
|
|
|
|
|
|
|
/* Create container and text content nodes */
|
1999-06-15 06:22:46 +00:00
|
|
|
result = NS_CreateHTMLElement(&errorContainerNode, parserErrorTag); // XXX these should NOT be in the HTML namespace
|
(13163, r=alecf, scc, waterson, others; names available on request)
- Fix most of bug 13163 (see TODO for rest). This entails adding a version-string argument to nsIScriptContext::EvaluateString and passing it around lots of places in content sinks.
- Fix leaks and confusion about mSecurityManager and mNameSpaceManager in nsJSEnvironment.cpp. These still need to move from nsJSContext to nsGlobalWindow or thereabouts, jband and vidur are looking at that.
- Added comments and expanded tabs in nsJSEnvironment.cpp, esp. to EvaluateString. Also changed various nsresult vars to be named rv. Also restored brace/style conformity to nsJSProtocolHandler.cpp.
- Factored CompileFunction from AddScriptEventListener to pave the way for brutal sharing of compiled JS event handlers via JS_CloneFunctionObject.
- Lots of nsCOMPtr uses added. I'm using one for mNameSpaceManager. Hold mSecurityManager as a service explicitly, on the other hand (awaiting scc's fix to allow comptrs for services), and release in nsJSContext's dtor (fixing a leak). These two managers should be moved to the window object -- TODO item below.
- Hold JSRuntimeService along with JSRuntime for live of nsJSEnvironment, fix for shaver.
- Fix window.setTimeout etc. so the filename and line number of the timeout expr is propagated. This meant factoring nsJSUtils.cpp code.
- Fix all content sinks to use the same, and up-to-date JavaScript version parsing (whether for script type or for old language attribute); also fix SplitMimeType clones to strip whitespace.
- With waterson, fix bug in brutal-sharing version of XUL content sink: script src= should not evaluate the inline content of its tag.
1999-10-31 00:43:30 +00:00
|
|
|
if (NS_OK == result) {
|
1999-03-11 05:29:36 +00:00
|
|
|
result = NS_NewTextNode(&errorTextNode);
|
(13163, r=alecf, scc, waterson, others; names available on request)
- Fix most of bug 13163 (see TODO for rest). This entails adding a version-string argument to nsIScriptContext::EvaluateString and passing it around lots of places in content sinks.
- Fix leaks and confusion about mSecurityManager and mNameSpaceManager in nsJSEnvironment.cpp. These still need to move from nsJSContext to nsGlobalWindow or thereabouts, jband and vidur are looking at that.
- Added comments and expanded tabs in nsJSEnvironment.cpp, esp. to EvaluateString. Also changed various nsresult vars to be named rv. Also restored brace/style conformity to nsJSProtocolHandler.cpp.
- Factored CompileFunction from AddScriptEventListener to pave the way for brutal sharing of compiled JS event handlers via JS_CloneFunctionObject.
- Lots of nsCOMPtr uses added. I'm using one for mNameSpaceManager. Hold mSecurityManager as a service explicitly, on the other hand (awaiting scc's fix to allow comptrs for services), and release in nsJSContext's dtor (fixing a leak). These two managers should be moved to the window object -- TODO item below.
- Hold JSRuntimeService along with JSRuntime for live of nsJSEnvironment, fix for shaver.
- Fix window.setTimeout etc. so the filename and line number of the timeout expr is propagated. This meant factoring nsJSUtils.cpp code.
- Fix all content sinks to use the same, and up-to-date JavaScript version parsing (whether for script type or for old language attribute); also fix SplitMimeType clones to strip whitespace.
- With waterson, fix bug in brutal-sharing version of XUL content sink: script src= should not evaluate the inline content of its tag.
1999-10-31 00:43:30 +00:00
|
|
|
if (NS_OK == result) {
|
1999-03-11 05:29:36 +00:00
|
|
|
result = NS_CreateHTMLElement(&sourceContainerNode, sourceTextTag);
|
|
|
|
if (NS_OK == result) {
|
|
|
|
result = NS_NewTextNode(&sourceTextNode);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Create the error text string and source text string
|
|
|
|
and set the text strings into the text nodes. */
|
|
|
|
result = CreateErrorText(aError, errorText);
|
|
|
|
if (NS_OK == result) {
|
|
|
|
SetTextStringOnTextNode(errorText, errorTextNode);
|
|
|
|
}
|
|
|
|
|
|
|
|
result = CreateSourceText(aError, sourceText);
|
|
|
|
if (NS_OK == result) {
|
|
|
|
SetTextStringOnTextNode(sourceText, sourceTextNode);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Hook the content nodes up to the document and to each other */
|
|
|
|
if (NS_OK == result) {
|
|
|
|
errorContainerNode->SetDocument(mDocument, PR_FALSE);
|
|
|
|
errorTextNode->SetDocument(mDocument, PR_FALSE);
|
|
|
|
sourceContainerNode->SetDocument(mDocument, PR_FALSE);
|
|
|
|
sourceTextNode->SetDocument(mDocument, PR_FALSE);
|
|
|
|
|
|
|
|
if (nsnull == mDocElement) {
|
|
|
|
mDocElement = errorContainerNode;
|
|
|
|
NS_ADDREF(mDocElement);
|
|
|
|
mDocument->SetRootContent(mDocElement);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
mDocElement->AppendChildTo(errorContainerNode, PR_FALSE);
|
|
|
|
}
|
|
|
|
errorContainerNode->AppendChildTo(errorTextNode, PR_FALSE);
|
|
|
|
errorContainerNode->AppendChildTo(sourceContainerNode, PR_FALSE);
|
|
|
|
sourceContainerNode->AppendChildTo(sourceTextNode, PR_FALSE);
|
|
|
|
}
|
(13163, r=alecf, scc, waterson, others; names available on request)
- Fix most of bug 13163 (see TODO for rest). This entails adding a version-string argument to nsIScriptContext::EvaluateString and passing it around lots of places in content sinks.
- Fix leaks and confusion about mSecurityManager and mNameSpaceManager in nsJSEnvironment.cpp. These still need to move from nsJSContext to nsGlobalWindow or thereabouts, jband and vidur are looking at that.
- Added comments and expanded tabs in nsJSEnvironment.cpp, esp. to EvaluateString. Also changed various nsresult vars to be named rv. Also restored brace/style conformity to nsJSProtocolHandler.cpp.
- Factored CompileFunction from AddScriptEventListener to pave the way for brutal sharing of compiled JS event handlers via JS_CloneFunctionObject.
- Lots of nsCOMPtr uses added. I'm using one for mNameSpaceManager. Hold mSecurityManager as a service explicitly, on the other hand (awaiting scc's fix to allow comptrs for services), and release in nsJSContext's dtor (fixing a leak). These two managers should be moved to the window object -- TODO item below.
- Hold JSRuntimeService along with JSRuntime for live of nsJSEnvironment, fix for shaver.
- Fix window.setTimeout etc. so the filename and line number of the timeout expr is propagated. This meant factoring nsJSUtils.cpp code.
- Fix all content sinks to use the same, and up-to-date JavaScript version parsing (whether for script type or for old language attribute); also fix SplitMimeType clones to strip whitespace.
- With waterson, fix bug in brutal-sharing version of XUL content sink: script src= should not evaluate the inline content of its tag.
1999-10-31 00:43:30 +00:00
|
|
|
|
1999-03-11 05:29:36 +00:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
1998-11-11 22:06:16 +00:00
|
|
|
// nsIXMLContentSink
|
(13163, r=alecf, scc, waterson, others; names available on request)
- Fix most of bug 13163 (see TODO for rest). This entails adding a version-string argument to nsIScriptContext::EvaluateString and passing it around lots of places in content sinks.
- Fix leaks and confusion about mSecurityManager and mNameSpaceManager in nsJSEnvironment.cpp. These still need to move from nsJSContext to nsGlobalWindow or thereabouts, jband and vidur are looking at that.
- Added comments and expanded tabs in nsJSEnvironment.cpp, esp. to EvaluateString. Also changed various nsresult vars to be named rv. Also restored brace/style conformity to nsJSProtocolHandler.cpp.
- Factored CompileFunction from AddScriptEventListener to pave the way for brutal sharing of compiled JS event handlers via JS_CloneFunctionObject.
- Lots of nsCOMPtr uses added. I'm using one for mNameSpaceManager. Hold mSecurityManager as a service explicitly, on the other hand (awaiting scc's fix to allow comptrs for services), and release in nsJSContext's dtor (fixing a leak). These two managers should be moved to the window object -- TODO item below.
- Hold JSRuntimeService along with JSRuntime for live of nsJSEnvironment, fix for shaver.
- Fix window.setTimeout etc. so the filename and line number of the timeout expr is propagated. This meant factoring nsJSUtils.cpp code.
- Fix all content sinks to use the same, and up-to-date JavaScript version parsing (whether for script type or for old language attribute); also fix SplitMimeType clones to strip whitespace.
- With waterson, fix bug in brutal-sharing version of XUL content sink: script src= should not evaluate the inline content of its tag.
1999-10-31 00:43:30 +00:00
|
|
|
NS_IMETHODIMP
|
1998-11-11 22:06:16 +00:00
|
|
|
nsXMLContentSink::AddXMLDecl(const nsIParserNode& aNode)
|
|
|
|
{
|
|
|
|
// XXX We'll ignore it for now
|
|
|
|
printf("nsXMLContentSink::AddXMLDecl\n");
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsXMLContentSink::AddContentAsLeaf(nsIContent *aContent)
|
(13163, r=alecf, scc, waterson, others; names available on request)
- Fix most of bug 13163 (see TODO for rest). This entails adding a version-string argument to nsIScriptContext::EvaluateString and passing it around lots of places in content sinks.
- Fix leaks and confusion about mSecurityManager and mNameSpaceManager in nsJSEnvironment.cpp. These still need to move from nsJSContext to nsGlobalWindow or thereabouts, jband and vidur are looking at that.
- Added comments and expanded tabs in nsJSEnvironment.cpp, esp. to EvaluateString. Also changed various nsresult vars to be named rv. Also restored brace/style conformity to nsJSProtocolHandler.cpp.
- Factored CompileFunction from AddScriptEventListener to pave the way for brutal sharing of compiled JS event handlers via JS_CloneFunctionObject.
- Lots of nsCOMPtr uses added. I'm using one for mNameSpaceManager. Hold mSecurityManager as a service explicitly, on the other hand (awaiting scc's fix to allow comptrs for services), and release in nsJSContext's dtor (fixing a leak). These two managers should be moved to the window object -- TODO item below.
- Hold JSRuntimeService along with JSRuntime for live of nsJSEnvironment, fix for shaver.
- Fix window.setTimeout etc. so the filename and line number of the timeout expr is propagated. This meant factoring nsJSUtils.cpp code.
- Fix all content sinks to use the same, and up-to-date JavaScript version parsing (whether for script type or for old language attribute); also fix SplitMimeType clones to strip whitespace.
- With waterson, fix bug in brutal-sharing version of XUL content sink: script src= should not evaluate the inline content of its tag.
1999-10-31 00:43:30 +00:00
|
|
|
{
|
1999-03-31 20:49:25 +00:00
|
|
|
nsresult result = NS_OK;
|
1998-11-11 22:06:16 +00:00
|
|
|
|
|
|
|
if (eXMLContentSinkState_InProlog == mState) {
|
1999-03-31 20:49:25 +00:00
|
|
|
result = mDocument->AppendToProlog(aContent);
|
1998-11-11 22:06:16 +00:00
|
|
|
}
|
(13163, r=alecf, scc, waterson, others; names available on request)
- Fix most of bug 13163 (see TODO for rest). This entails adding a version-string argument to nsIScriptContext::EvaluateString and passing it around lots of places in content sinks.
- Fix leaks and confusion about mSecurityManager and mNameSpaceManager in nsJSEnvironment.cpp. These still need to move from nsJSContext to nsGlobalWindow or thereabouts, jband and vidur are looking at that.
- Added comments and expanded tabs in nsJSEnvironment.cpp, esp. to EvaluateString. Also changed various nsresult vars to be named rv. Also restored brace/style conformity to nsJSProtocolHandler.cpp.
- Factored CompileFunction from AddScriptEventListener to pave the way for brutal sharing of compiled JS event handlers via JS_CloneFunctionObject.
- Lots of nsCOMPtr uses added. I'm using one for mNameSpaceManager. Hold mSecurityManager as a service explicitly, on the other hand (awaiting scc's fix to allow comptrs for services), and release in nsJSContext's dtor (fixing a leak). These two managers should be moved to the window object -- TODO item below.
- Hold JSRuntimeService along with JSRuntime for live of nsJSEnvironment, fix for shaver.
- Fix window.setTimeout etc. so the filename and line number of the timeout expr is propagated. This meant factoring nsJSUtils.cpp code.
- Fix all content sinks to use the same, and up-to-date JavaScript version parsing (whether for script type or for old language attribute); also fix SplitMimeType clones to strip whitespace.
- With waterson, fix bug in brutal-sharing version of XUL content sink: script src= should not evaluate the inline content of its tag.
1999-10-31 00:43:30 +00:00
|
|
|
else if (eXMLContentSinkState_InEpilog == mState) {
|
1999-03-31 20:49:25 +00:00
|
|
|
result = mDocument->AppendToEpilog(aContent);
|
1998-11-11 22:06:16 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
nsIContent *parent = GetCurrentContent();
|
(13163, r=alecf, scc, waterson, others; names available on request)
- Fix most of bug 13163 (see TODO for rest). This entails adding a version-string argument to nsIScriptContext::EvaluateString and passing it around lots of places in content sinks.
- Fix leaks and confusion about mSecurityManager and mNameSpaceManager in nsJSEnvironment.cpp. These still need to move from nsJSContext to nsGlobalWindow or thereabouts, jband and vidur are looking at that.
- Added comments and expanded tabs in nsJSEnvironment.cpp, esp. to EvaluateString. Also changed various nsresult vars to be named rv. Also restored brace/style conformity to nsJSProtocolHandler.cpp.
- Factored CompileFunction from AddScriptEventListener to pave the way for brutal sharing of compiled JS event handlers via JS_CloneFunctionObject.
- Lots of nsCOMPtr uses added. I'm using one for mNameSpaceManager. Hold mSecurityManager as a service explicitly, on the other hand (awaiting scc's fix to allow comptrs for services), and release in nsJSContext's dtor (fixing a leak). These two managers should be moved to the window object -- TODO item below.
- Hold JSRuntimeService along with JSRuntime for live of nsJSEnvironment, fix for shaver.
- Fix window.setTimeout etc. so the filename and line number of the timeout expr is propagated. This meant factoring nsJSUtils.cpp code.
- Fix all content sinks to use the same, and up-to-date JavaScript version parsing (whether for script type or for old language attribute); also fix SplitMimeType clones to strip whitespace.
- With waterson, fix bug in brutal-sharing version of XUL content sink: script src= should not evaluate the inline content of its tag.
1999-10-31 00:43:30 +00:00
|
|
|
|
1998-11-11 22:06:16 +00:00
|
|
|
if (nsnull != parent) {
|
|
|
|
result = parent->AppendChildTo(aContent, PR_FALSE);
|
|
|
|
}
|
|
|
|
}
|
(13163, r=alecf, scc, waterson, others; names available on request)
- Fix most of bug 13163 (see TODO for rest). This entails adding a version-string argument to nsIScriptContext::EvaluateString and passing it around lots of places in content sinks.
- Fix leaks and confusion about mSecurityManager and mNameSpaceManager in nsJSEnvironment.cpp. These still need to move from nsJSContext to nsGlobalWindow or thereabouts, jband and vidur are looking at that.
- Added comments and expanded tabs in nsJSEnvironment.cpp, esp. to EvaluateString. Also changed various nsresult vars to be named rv. Also restored brace/style conformity to nsJSProtocolHandler.cpp.
- Factored CompileFunction from AddScriptEventListener to pave the way for brutal sharing of compiled JS event handlers via JS_CloneFunctionObject.
- Lots of nsCOMPtr uses added. I'm using one for mNameSpaceManager. Hold mSecurityManager as a service explicitly, on the other hand (awaiting scc's fix to allow comptrs for services), and release in nsJSContext's dtor (fixing a leak). These two managers should be moved to the window object -- TODO item below.
- Hold JSRuntimeService along with JSRuntime for live of nsJSEnvironment, fix for shaver.
- Fix window.setTimeout etc. so the filename and line number of the timeout expr is propagated. This meant factoring nsJSUtils.cpp code.
- Fix all content sinks to use the same, and up-to-date JavaScript version parsing (whether for script type or for old language attribute); also fix SplitMimeType clones to strip whitespace.
- With waterson, fix bug in brutal-sharing version of XUL content sink: script src= should not evaluate the inline content of its tag.
1999-10-31 00:43:30 +00:00
|
|
|
|
1998-11-11 22:06:16 +00:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
(13163, r=alecf, scc, waterson, others; names available on request)
- Fix most of bug 13163 (see TODO for rest). This entails adding a version-string argument to nsIScriptContext::EvaluateString and passing it around lots of places in content sinks.
- Fix leaks and confusion about mSecurityManager and mNameSpaceManager in nsJSEnvironment.cpp. These still need to move from nsJSContext to nsGlobalWindow or thereabouts, jband and vidur are looking at that.
- Added comments and expanded tabs in nsJSEnvironment.cpp, esp. to EvaluateString. Also changed various nsresult vars to be named rv. Also restored brace/style conformity to nsJSProtocolHandler.cpp.
- Factored CompileFunction from AddScriptEventListener to pave the way for brutal sharing of compiled JS event handlers via JS_CloneFunctionObject.
- Lots of nsCOMPtr uses added. I'm using one for mNameSpaceManager. Hold mSecurityManager as a service explicitly, on the other hand (awaiting scc's fix to allow comptrs for services), and release in nsJSContext's dtor (fixing a leak). These two managers should be moved to the window object -- TODO item below.
- Hold JSRuntimeService along with JSRuntime for live of nsJSEnvironment, fix for shaver.
- Fix window.setTimeout etc. so the filename and line number of the timeout expr is propagated. This meant factoring nsJSUtils.cpp code.
- Fix all content sinks to use the same, and up-to-date JavaScript version parsing (whether for script type or for old language attribute); also fix SplitMimeType clones to strip whitespace.
- With waterson, fix bug in brutal-sharing version of XUL content sink: script src= should not evaluate the inline content of its tag.
1999-10-31 00:43:30 +00:00
|
|
|
NS_IMETHODIMP
|
1998-11-11 22:06:16 +00:00
|
|
|
nsXMLContentSink::AddComment(const nsIParserNode& aNode)
|
|
|
|
{
|
|
|
|
FlushText();
|
|
|
|
|
|
|
|
nsAutoString text;
|
1999-01-14 23:14:02 +00:00
|
|
|
nsIContent *comment;
|
1998-11-11 22:06:16 +00:00
|
|
|
nsIDOMComment *domComment;
|
|
|
|
nsresult result = NS_OK;
|
|
|
|
|
|
|
|
text = aNode.GetText();
|
|
|
|
result = NS_NewCommentNode(&comment);
|
|
|
|
if (NS_OK == result) {
|
|
|
|
result = comment->QueryInterface(kIDOMCommentIID, (void **)&domComment);
|
|
|
|
if (NS_OK == result) {
|
|
|
|
domComment->AppendData(text);
|
|
|
|
NS_RELEASE(domComment);
|
|
|
|
|
|
|
|
comment->SetDocument(mDocument, PR_FALSE);
|
|
|
|
result = AddContentAsLeaf(comment);
|
|
|
|
}
|
|
|
|
NS_RELEASE(comment);
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
(13163, r=alecf, scc, waterson, others; names available on request)
- Fix most of bug 13163 (see TODO for rest). This entails adding a version-string argument to nsIScriptContext::EvaluateString and passing it around lots of places in content sinks.
- Fix leaks and confusion about mSecurityManager and mNameSpaceManager in nsJSEnvironment.cpp. These still need to move from nsJSContext to nsGlobalWindow or thereabouts, jband and vidur are looking at that.
- Added comments and expanded tabs in nsJSEnvironment.cpp, esp. to EvaluateString. Also changed various nsresult vars to be named rv. Also restored brace/style conformity to nsJSProtocolHandler.cpp.
- Factored CompileFunction from AddScriptEventListener to pave the way for brutal sharing of compiled JS event handlers via JS_CloneFunctionObject.
- Lots of nsCOMPtr uses added. I'm using one for mNameSpaceManager. Hold mSecurityManager as a service explicitly, on the other hand (awaiting scc's fix to allow comptrs for services), and release in nsJSContext's dtor (fixing a leak). These two managers should be moved to the window object -- TODO item below.
- Hold JSRuntimeService along with JSRuntime for live of nsJSEnvironment, fix for shaver.
- Fix window.setTimeout etc. so the filename and line number of the timeout expr is propagated. This meant factoring nsJSUtils.cpp code.
- Fix all content sinks to use the same, and up-to-date JavaScript version parsing (whether for script type or for old language attribute); also fix SplitMimeType clones to strip whitespace.
- With waterson, fix bug in brutal-sharing version of XUL content sink: script src= should not evaluate the inline content of its tag.
1999-10-31 00:43:30 +00:00
|
|
|
NS_IMETHODIMP
|
1999-03-31 20:49:25 +00:00
|
|
|
nsXMLContentSink::AddCDATASection(const nsIParserNode& aNode)
|
|
|
|
{
|
|
|
|
FlushText();
|
|
|
|
|
|
|
|
nsAutoString text;
|
|
|
|
nsIContent *cdata;
|
|
|
|
nsIDOMCDATASection *domCDATA;
|
|
|
|
nsresult result = NS_OK;
|
|
|
|
|
|
|
|
text = aNode.GetText();
|
|
|
|
result = NS_NewXMLCDATASection(&cdata);
|
|
|
|
if (NS_OK == result) {
|
|
|
|
result = cdata->QueryInterface(kIDOMCDATASectionIID, (void **)&domCDATA);
|
|
|
|
if (NS_OK == result) {
|
|
|
|
domCDATA->AppendData(text);
|
|
|
|
NS_RELEASE(domCDATA);
|
|
|
|
|
|
|
|
cdata->SetDocument(mDocument, PR_FALSE);
|
|
|
|
result = AddContentAsLeaf(cdata);
|
|
|
|
}
|
|
|
|
NS_RELEASE(cdata);
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
1998-11-11 22:06:16 +00:00
|
|
|
|
|
|
|
static nsresult
|
(13163, r=alecf, scc, waterson, others; names available on request)
- Fix most of bug 13163 (see TODO for rest). This entails adding a version-string argument to nsIScriptContext::EvaluateString and passing it around lots of places in content sinks.
- Fix leaks and confusion about mSecurityManager and mNameSpaceManager in nsJSEnvironment.cpp. These still need to move from nsJSContext to nsGlobalWindow or thereabouts, jband and vidur are looking at that.
- Added comments and expanded tabs in nsJSEnvironment.cpp, esp. to EvaluateString. Also changed various nsresult vars to be named rv. Also restored brace/style conformity to nsJSProtocolHandler.cpp.
- Factored CompileFunction from AddScriptEventListener to pave the way for brutal sharing of compiled JS event handlers via JS_CloneFunctionObject.
- Lots of nsCOMPtr uses added. I'm using one for mNameSpaceManager. Hold mSecurityManager as a service explicitly, on the other hand (awaiting scc's fix to allow comptrs for services), and release in nsJSContext's dtor (fixing a leak). These two managers should be moved to the window object -- TODO item below.
- Hold JSRuntimeService along with JSRuntime for live of nsJSEnvironment, fix for shaver.
- Fix window.setTimeout etc. so the filename and line number of the timeout expr is propagated. This meant factoring nsJSUtils.cpp code.
- Fix all content sinks to use the same, and up-to-date JavaScript version parsing (whether for script type or for old language attribute); also fix SplitMimeType clones to strip whitespace.
- With waterson, fix bug in brutal-sharing version of XUL content sink: script src= should not evaluate the inline content of its tag.
1999-10-31 00:43:30 +00:00
|
|
|
GetQuotedAttributeValue(nsString& aSource,
|
1998-11-11 22:06:16 +00:00
|
|
|
const nsString& aAttribute,
|
|
|
|
nsString& aValue)
|
|
|
|
{
|
|
|
|
PRInt32 offset;
|
|
|
|
PRInt32 endOffset = -1;
|
|
|
|
nsresult result = NS_OK;
|
|
|
|
|
|
|
|
offset = aSource.Find(aAttribute);
|
|
|
|
if (-1 != offset) {
|
1999-07-26 00:37:24 +00:00
|
|
|
offset = aSource.FindChar('=', PR_FALSE,offset);
|
1998-11-11 22:06:16 +00:00
|
|
|
|
|
|
|
PRUnichar next = aSource.CharAt(++offset);
|
|
|
|
if (kQuote == next) {
|
1999-07-26 00:37:24 +00:00
|
|
|
endOffset = aSource.FindChar(kQuote,PR_FALSE, ++offset);
|
1998-11-11 22:06:16 +00:00
|
|
|
}
|
|
|
|
else if (kApostrophe == next) {
|
(13163, r=alecf, scc, waterson, others; names available on request)
- Fix most of bug 13163 (see TODO for rest). This entails adding a version-string argument to nsIScriptContext::EvaluateString and passing it around lots of places in content sinks.
- Fix leaks and confusion about mSecurityManager and mNameSpaceManager in nsJSEnvironment.cpp. These still need to move from nsJSContext to nsGlobalWindow or thereabouts, jband and vidur are looking at that.
- Added comments and expanded tabs in nsJSEnvironment.cpp, esp. to EvaluateString. Also changed various nsresult vars to be named rv. Also restored brace/style conformity to nsJSProtocolHandler.cpp.
- Factored CompileFunction from AddScriptEventListener to pave the way for brutal sharing of compiled JS event handlers via JS_CloneFunctionObject.
- Lots of nsCOMPtr uses added. I'm using one for mNameSpaceManager. Hold mSecurityManager as a service explicitly, on the other hand (awaiting scc's fix to allow comptrs for services), and release in nsJSContext's dtor (fixing a leak). These two managers should be moved to the window object -- TODO item below.
- Hold JSRuntimeService along with JSRuntime for live of nsJSEnvironment, fix for shaver.
- Fix window.setTimeout etc. so the filename and line number of the timeout expr is propagated. This meant factoring nsJSUtils.cpp code.
- Fix all content sinks to use the same, and up-to-date JavaScript version parsing (whether for script type or for old language attribute); also fix SplitMimeType clones to strip whitespace.
- With waterson, fix bug in brutal-sharing version of XUL content sink: script src= should not evaluate the inline content of its tag.
1999-10-31 00:43:30 +00:00
|
|
|
endOffset = aSource.FindChar(kApostrophe, PR_FALSE,++offset);
|
1998-11-11 22:06:16 +00:00
|
|
|
}
|
(13163, r=alecf, scc, waterson, others; names available on request)
- Fix most of bug 13163 (see TODO for rest). This entails adding a version-string argument to nsIScriptContext::EvaluateString and passing it around lots of places in content sinks.
- Fix leaks and confusion about mSecurityManager and mNameSpaceManager in nsJSEnvironment.cpp. These still need to move from nsJSContext to nsGlobalWindow or thereabouts, jband and vidur are looking at that.
- Added comments and expanded tabs in nsJSEnvironment.cpp, esp. to EvaluateString. Also changed various nsresult vars to be named rv. Also restored brace/style conformity to nsJSProtocolHandler.cpp.
- Factored CompileFunction from AddScriptEventListener to pave the way for brutal sharing of compiled JS event handlers via JS_CloneFunctionObject.
- Lots of nsCOMPtr uses added. I'm using one for mNameSpaceManager. Hold mSecurityManager as a service explicitly, on the other hand (awaiting scc's fix to allow comptrs for services), and release in nsJSContext's dtor (fixing a leak). These two managers should be moved to the window object -- TODO item below.
- Hold JSRuntimeService along with JSRuntime for live of nsJSEnvironment, fix for shaver.
- Fix window.setTimeout etc. so the filename and line number of the timeout expr is propagated. This meant factoring nsJSUtils.cpp code.
- Fix all content sinks to use the same, and up-to-date JavaScript version parsing (whether for script type or for old language attribute); also fix SplitMimeType clones to strip whitespace.
- With waterson, fix bug in brutal-sharing version of XUL content sink: script src= should not evaluate the inline content of its tag.
1999-10-31 00:43:30 +00:00
|
|
|
|
1998-11-11 22:06:16 +00:00
|
|
|
if (-1 != endOffset) {
|
|
|
|
aSource.Mid(aValue, offset, endOffset-offset);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// Mismatched quotes - return an error
|
|
|
|
result = NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
aValue.Truncate();
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
1999-06-28 14:49:29 +00:00
|
|
|
static void
|
|
|
|
ParseProcessingInstruction(const nsString& aText,
|
|
|
|
nsString& aTarget,
|
|
|
|
nsString& aData)
|
|
|
|
{
|
|
|
|
PRInt32 offset;
|
|
|
|
|
|
|
|
aTarget.Truncate();
|
|
|
|
aData.Truncate();
|
|
|
|
|
|
|
|
offset = aText.FindCharInSet(" \n\r\t");
|
|
|
|
if (-1 != offset) {
|
|
|
|
aText.Mid(aTarget, 2, offset-2);
|
|
|
|
aText.Mid(aData, offset+1, aText.Length()-offset-3);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void SplitMimeType(const nsString& aValue, nsString& aType, nsString& aParams)
|
|
|
|
{
|
|
|
|
aType.Truncate();
|
|
|
|
aParams.Truncate();
|
1999-07-26 00:37:24 +00:00
|
|
|
PRInt32 semiIndex = aValue.FindChar(PRUnichar(';'));
|
1999-06-28 14:49:29 +00:00
|
|
|
if (-1 != semiIndex) {
|
|
|
|
aValue.Left(aType, semiIndex);
|
|
|
|
aValue.Right(aParams, (aValue.Length() - semiIndex) - 1);
|
(13163, r=alecf, scc, waterson, others; names available on request)
- Fix most of bug 13163 (see TODO for rest). This entails adding a version-string argument to nsIScriptContext::EvaluateString and passing it around lots of places in content sinks.
- Fix leaks and confusion about mSecurityManager and mNameSpaceManager in nsJSEnvironment.cpp. These still need to move from nsJSContext to nsGlobalWindow or thereabouts, jband and vidur are looking at that.
- Added comments and expanded tabs in nsJSEnvironment.cpp, esp. to EvaluateString. Also changed various nsresult vars to be named rv. Also restored brace/style conformity to nsJSProtocolHandler.cpp.
- Factored CompileFunction from AddScriptEventListener to pave the way for brutal sharing of compiled JS event handlers via JS_CloneFunctionObject.
- Lots of nsCOMPtr uses added. I'm using one for mNameSpaceManager. Hold mSecurityManager as a service explicitly, on the other hand (awaiting scc's fix to allow comptrs for services), and release in nsJSContext's dtor (fixing a leak). These two managers should be moved to the window object -- TODO item below.
- Hold JSRuntimeService along with JSRuntime for live of nsJSEnvironment, fix for shaver.
- Fix window.setTimeout etc. so the filename and line number of the timeout expr is propagated. This meant factoring nsJSUtils.cpp code.
- Fix all content sinks to use the same, and up-to-date JavaScript version parsing (whether for script type or for old language attribute); also fix SplitMimeType clones to strip whitespace.
- With waterson, fix bug in brutal-sharing version of XUL content sink: script src= should not evaluate the inline content of its tag.
1999-10-31 00:43:30 +00:00
|
|
|
aParams.StripWhitespace();
|
1999-06-28 14:49:29 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
aType = aValue;
|
|
|
|
}
|
(13163, r=alecf, scc, waterson, others; names available on request)
- Fix most of bug 13163 (see TODO for rest). This entails adding a version-string argument to nsIScriptContext::EvaluateString and passing it around lots of places in content sinks.
- Fix leaks and confusion about mSecurityManager and mNameSpaceManager in nsJSEnvironment.cpp. These still need to move from nsJSContext to nsGlobalWindow or thereabouts, jband and vidur are looking at that.
- Added comments and expanded tabs in nsJSEnvironment.cpp, esp. to EvaluateString. Also changed various nsresult vars to be named rv. Also restored brace/style conformity to nsJSProtocolHandler.cpp.
- Factored CompileFunction from AddScriptEventListener to pave the way for brutal sharing of compiled JS event handlers via JS_CloneFunctionObject.
- Lots of nsCOMPtr uses added. I'm using one for mNameSpaceManager. Hold mSecurityManager as a service explicitly, on the other hand (awaiting scc's fix to allow comptrs for services), and release in nsJSContext's dtor (fixing a leak). These two managers should be moved to the window object -- TODO item below.
- Hold JSRuntimeService along with JSRuntime for live of nsJSEnvironment, fix for shaver.
- Fix window.setTimeout etc. so the filename and line number of the timeout expr is propagated. This meant factoring nsJSUtils.cpp code.
- Fix all content sinks to use the same, and up-to-date JavaScript version parsing (whether for script type or for old language attribute); also fix SplitMimeType clones to strip whitespace.
- With waterson, fix bug in brutal-sharing version of XUL content sink: script src= should not evaluate the inline content of its tag.
1999-10-31 00:43:30 +00:00
|
|
|
aType.StripWhitespace();
|
1999-06-28 14:49:29 +00:00
|
|
|
}
|
1998-12-18 01:36:41 +00:00
|
|
|
|
1998-12-27 08:24:04 +00:00
|
|
|
#ifdef XSL
|
1999-08-28 07:31:08 +00:00
|
|
|
nsresult
|
(13163, r=alecf, scc, waterson, others; names available on request)
- Fix most of bug 13163 (see TODO for rest). This entails adding a version-string argument to nsIScriptContext::EvaluateString and passing it around lots of places in content sinks.
- Fix leaks and confusion about mSecurityManager and mNameSpaceManager in nsJSEnvironment.cpp. These still need to move from nsJSContext to nsGlobalWindow or thereabouts, jband and vidur are looking at that.
- Added comments and expanded tabs in nsJSEnvironment.cpp, esp. to EvaluateString. Also changed various nsresult vars to be named rv. Also restored brace/style conformity to nsJSProtocolHandler.cpp.
- Factored CompileFunction from AddScriptEventListener to pave the way for brutal sharing of compiled JS event handlers via JS_CloneFunctionObject.
- Lots of nsCOMPtr uses added. I'm using one for mNameSpaceManager. Hold mSecurityManager as a service explicitly, on the other hand (awaiting scc's fix to allow comptrs for services), and release in nsJSContext's dtor (fixing a leak). These two managers should be moved to the window object -- TODO item below.
- Hold JSRuntimeService along with JSRuntime for live of nsJSEnvironment, fix for shaver.
- Fix window.setTimeout etc. so the filename and line number of the timeout expr is propagated. This meant factoring nsJSUtils.cpp code.
- Fix all content sinks to use the same, and up-to-date JavaScript version parsing (whether for script type or for old language attribute); also fix SplitMimeType clones to strip whitespace.
- With waterson, fix bug in brutal-sharing version of XUL content sink: script src= should not evaluate the inline content of its tag.
1999-10-31 00:43:30 +00:00
|
|
|
nsXMLContentSink::CreateStyleSheetURL(nsIURI** aUrl,
|
1998-12-27 08:24:04 +00:00
|
|
|
const nsAutoString& aHref)
|
|
|
|
{
|
1999-08-28 07:31:08 +00:00
|
|
|
nsresult result = NS_OK;
|
|
|
|
result = NS_NewURI(aUrl, aHref, mDocumentBaseURL);
|
|
|
|
return result;
|
|
|
|
|
1998-12-27 08:24:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Create an XML parser and an XSL content sink and start parsing
|
|
|
|
// the XSL stylesheet located at the given URL.
|
|
|
|
nsresult
|
1999-06-28 14:49:29 +00:00
|
|
|
nsXMLContentSink::LoadXSLStyleSheet(nsIURI* aUrl, const nsString& aType)
|
(13163, r=alecf, scc, waterson, others; names available on request)
- Fix most of bug 13163 (see TODO for rest). This entails adding a version-string argument to nsIScriptContext::EvaluateString and passing it around lots of places in content sinks.
- Fix leaks and confusion about mSecurityManager and mNameSpaceManager in nsJSEnvironment.cpp. These still need to move from nsJSContext to nsGlobalWindow or thereabouts, jband and vidur are looking at that.
- Added comments and expanded tabs in nsJSEnvironment.cpp, esp. to EvaluateString. Also changed various nsresult vars to be named rv. Also restored brace/style conformity to nsJSProtocolHandler.cpp.
- Factored CompileFunction from AddScriptEventListener to pave the way for brutal sharing of compiled JS event handlers via JS_CloneFunctionObject.
- Lots of nsCOMPtr uses added. I'm using one for mNameSpaceManager. Hold mSecurityManager as a service explicitly, on the other hand (awaiting scc's fix to allow comptrs for services), and release in nsJSContext's dtor (fixing a leak). These two managers should be moved to the window object -- TODO item below.
- Hold JSRuntimeService along with JSRuntime for live of nsJSEnvironment, fix for shaver.
- Fix window.setTimeout etc. so the filename and line number of the timeout expr is propagated. This meant factoring nsJSUtils.cpp code.
- Fix all content sinks to use the same, and up-to-date JavaScript version parsing (whether for script type or for old language attribute); also fix SplitMimeType clones to strip whitespace.
- With waterson, fix bug in brutal-sharing version of XUL content sink: script src= should not evaluate the inline content of its tag.
1999-10-31 00:43:30 +00:00
|
|
|
{
|
1998-12-27 08:24:04 +00:00
|
|
|
nsresult rv = NS_OK;
|
1999-08-28 07:31:08 +00:00
|
|
|
nsCOMPtr<nsIParser> parser;
|
1998-12-27 08:24:04 +00:00
|
|
|
|
|
|
|
static NS_DEFINE_IID(kCParserIID, NS_IPARSER_IID);
|
|
|
|
static NS_DEFINE_IID(kCParserCID, NS_PARSER_IID);
|
|
|
|
|
|
|
|
// Create the XML parser
|
(13163, r=alecf, scc, waterson, others; names available on request)
- Fix most of bug 13163 (see TODO for rest). This entails adding a version-string argument to nsIScriptContext::EvaluateString and passing it around lots of places in content sinks.
- Fix leaks and confusion about mSecurityManager and mNameSpaceManager in nsJSEnvironment.cpp. These still need to move from nsJSContext to nsGlobalWindow or thereabouts, jband and vidur are looking at that.
- Added comments and expanded tabs in nsJSEnvironment.cpp, esp. to EvaluateString. Also changed various nsresult vars to be named rv. Also restored brace/style conformity to nsJSProtocolHandler.cpp.
- Factored CompileFunction from AddScriptEventListener to pave the way for brutal sharing of compiled JS event handlers via JS_CloneFunctionObject.
- Lots of nsCOMPtr uses added. I'm using one for mNameSpaceManager. Hold mSecurityManager as a service explicitly, on the other hand (awaiting scc's fix to allow comptrs for services), and release in nsJSContext's dtor (fixing a leak). These two managers should be moved to the window object -- TODO item below.
- Hold JSRuntimeService along with JSRuntime for live of nsJSEnvironment, fix for shaver.
- Fix window.setTimeout etc. so the filename and line number of the timeout expr is propagated. This meant factoring nsJSUtils.cpp code.
- Fix all content sinks to use the same, and up-to-date JavaScript version parsing (whether for script type or for old language attribute); also fix SplitMimeType clones to strip whitespace.
- With waterson, fix bug in brutal-sharing version of XUL content sink: script src= should not evaluate the inline content of its tag.
1999-10-31 00:43:30 +00:00
|
|
|
rv = nsComponentManager::CreateInstance(kCParserCID,
|
|
|
|
nsnull,
|
|
|
|
kCParserIID,
|
1999-08-28 07:31:08 +00:00
|
|
|
getter_AddRefs(parser));
|
1999-06-28 14:49:29 +00:00
|
|
|
|
1999-08-28 07:31:08 +00:00
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
|
|
|
|
// Create a transform mediator
|
|
|
|
rv = NS_NewTransformMediator(&mXSLTransformMediator, aType);
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
1999-06-28 14:49:29 +00:00
|
|
|
|
(13163, r=alecf, scc, waterson, others; names available on request)
- Fix most of bug 13163 (see TODO for rest). This entails adding a version-string argument to nsIScriptContext::EvaluateString and passing it around lots of places in content sinks.
- Fix leaks and confusion about mSecurityManager and mNameSpaceManager in nsJSEnvironment.cpp. These still need to move from nsJSContext to nsGlobalWindow or thereabouts, jband and vidur are looking at that.
- Added comments and expanded tabs in nsJSEnvironment.cpp, esp. to EvaluateString. Also changed various nsresult vars to be named rv. Also restored brace/style conformity to nsJSProtocolHandler.cpp.
- Factored CompileFunction from AddScriptEventListener to pave the way for brutal sharing of compiled JS event handlers via JS_CloneFunctionObject.
- Lots of nsCOMPtr uses added. I'm using one for mNameSpaceManager. Hold mSecurityManager as a service explicitly, on the other hand (awaiting scc's fix to allow comptrs for services), and release in nsJSContext's dtor (fixing a leak). These two managers should be moved to the window object -- TODO item below.
- Hold JSRuntimeService along with JSRuntime for live of nsJSEnvironment, fix for shaver.
- Fix window.setTimeout etc. so the filename and line number of the timeout expr is propagated. This meant factoring nsJSUtils.cpp code.
- Fix all content sinks to use the same, and up-to-date JavaScript version parsing (whether for script type or for old language attribute); also fix SplitMimeType clones to strip whitespace.
- With waterson, fix bug in brutal-sharing version of XUL content sink: script src= should not evaluate the inline content of its tag.
1999-10-31 00:43:30 +00:00
|
|
|
|
1999-08-28 07:31:08 +00:00
|
|
|
// Enable the transform mediator. It will start the transform
|
|
|
|
// as soon as it has enough state to do so. The state needed is
|
|
|
|
// the source content model, the style content model, the current
|
(13163, r=alecf, scc, waterson, others; names available on request)
- Fix most of bug 13163 (see TODO for rest). This entails adding a version-string argument to nsIScriptContext::EvaluateString and passing it around lots of places in content sinks.
- Fix leaks and confusion about mSecurityManager and mNameSpaceManager in nsJSEnvironment.cpp. These still need to move from nsJSContext to nsGlobalWindow or thereabouts, jband and vidur are looking at that.
- Added comments and expanded tabs in nsJSEnvironment.cpp, esp. to EvaluateString. Also changed various nsresult vars to be named rv. Also restored brace/style conformity to nsJSProtocolHandler.cpp.
- Factored CompileFunction from AddScriptEventListener to pave the way for brutal sharing of compiled JS event handlers via JS_CloneFunctionObject.
- Lots of nsCOMPtr uses added. I'm using one for mNameSpaceManager. Hold mSecurityManager as a service explicitly, on the other hand (awaiting scc's fix to allow comptrs for services), and release in nsJSContext's dtor (fixing a leak). These two managers should be moved to the window object -- TODO item below.
- Hold JSRuntimeService along with JSRuntime for live of nsJSEnvironment, fix for shaver.
- Fix window.setTimeout etc. so the filename and line number of the timeout expr is propagated. This meant factoring nsJSUtils.cpp code.
- Fix all content sinks to use the same, and up-to-date JavaScript version parsing (whether for script type or for old language attribute); also fix SplitMimeType clones to strip whitespace.
- With waterson, fix bug in brutal-sharing version of XUL content sink: script src= should not evaluate the inline content of its tag.
1999-10-31 00:43:30 +00:00
|
|
|
// document, and an observer. The XML and XSL content sinks provide
|
1999-08-28 07:31:08 +00:00
|
|
|
// this state by calling the various setters on nsITransformMediator.
|
|
|
|
mXSLTransformMediator->SetEnabled(PR_TRUE);
|
|
|
|
|
|
|
|
// The XML document owns the transform mediator. Give the mediator to
|
|
|
|
// the XML document.
|
|
|
|
nsCOMPtr<nsIXMLDocument> xmlDoc;
|
(13163, r=alecf, scc, waterson, others; names available on request)
- Fix most of bug 13163 (see TODO for rest). This entails adding a version-string argument to nsIScriptContext::EvaluateString and passing it around lots of places in content sinks.
- Fix leaks and confusion about mSecurityManager and mNameSpaceManager in nsJSEnvironment.cpp. These still need to move from nsJSContext to nsGlobalWindow or thereabouts, jband and vidur are looking at that.
- Added comments and expanded tabs in nsJSEnvironment.cpp, esp. to EvaluateString. Also changed various nsresult vars to be named rv. Also restored brace/style conformity to nsJSProtocolHandler.cpp.
- Factored CompileFunction from AddScriptEventListener to pave the way for brutal sharing of compiled JS event handlers via JS_CloneFunctionObject.
- Lots of nsCOMPtr uses added. I'm using one for mNameSpaceManager. Hold mSecurityManager as a service explicitly, on the other hand (awaiting scc's fix to allow comptrs for services), and release in nsJSContext's dtor (fixing a leak). These two managers should be moved to the window object -- TODO item below.
- Hold JSRuntimeService along with JSRuntime for live of nsJSEnvironment, fix for shaver.
- Fix window.setTimeout etc. so the filename and line number of the timeout expr is propagated. This meant factoring nsJSUtils.cpp code.
- Fix all content sinks to use the same, and up-to-date JavaScript version parsing (whether for script type or for old language attribute); also fix SplitMimeType clones to strip whitespace.
- With waterson, fix bug in brutal-sharing version of XUL content sink: script src= should not evaluate the inline content of its tag.
1999-10-31 00:43:30 +00:00
|
|
|
rv = mDocument->QueryInterface(kIXMLDocumentIID, (void**) getter_AddRefs(xmlDoc));
|
1999-08-28 07:31:08 +00:00
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
xmlDoc->SetTransformMediator(mXSLTransformMediator);
|
|
|
|
|
|
|
|
// Create the XSL content sink
|
|
|
|
nsCOMPtr<nsIXMLContentSink> sink;
|
|
|
|
rv = NS_NewXSLContentSink(getter_AddRefs(sink), mXSLTransformMediator, mDocument, aUrl, mWebShell);
|
(13163, r=alecf, scc, waterson, others; names available on request)
- Fix most of bug 13163 (see TODO for rest). This entails adding a version-string argument to nsIScriptContext::EvaluateString and passing it around lots of places in content sinks.
- Fix leaks and confusion about mSecurityManager and mNameSpaceManager in nsJSEnvironment.cpp. These still need to move from nsJSContext to nsGlobalWindow or thereabouts, jband and vidur are looking at that.
- Added comments and expanded tabs in nsJSEnvironment.cpp, esp. to EvaluateString. Also changed various nsresult vars to be named rv. Also restored brace/style conformity to nsJSProtocolHandler.cpp.
- Factored CompileFunction from AddScriptEventListener to pave the way for brutal sharing of compiled JS event handlers via JS_CloneFunctionObject.
- Lots of nsCOMPtr uses added. I'm using one for mNameSpaceManager. Hold mSecurityManager as a service explicitly, on the other hand (awaiting scc's fix to allow comptrs for services), and release in nsJSContext's dtor (fixing a leak). These two managers should be moved to the window object -- TODO item below.
- Hold JSRuntimeService along with JSRuntime for live of nsJSEnvironment, fix for shaver.
- Fix window.setTimeout etc. so the filename and line number of the timeout expr is propagated. This meant factoring nsJSUtils.cpp code.
- Fix all content sinks to use the same, and up-to-date JavaScript version parsing (whether for script type or for old language attribute); also fix SplitMimeType clones to strip whitespace.
- With waterson, fix bug in brutal-sharing version of XUL content sink: script src= should not evaluate the inline content of its tag.
1999-10-31 00:43:30 +00:00
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
|
1999-08-28 07:31:08 +00:00
|
|
|
// Hook up the content sink to the parser's output and ask the parser
|
(13163, r=alecf, scc, waterson, others; names available on request)
- Fix most of bug 13163 (see TODO for rest). This entails adding a version-string argument to nsIScriptContext::EvaluateString and passing it around lots of places in content sinks.
- Fix leaks and confusion about mSecurityManager and mNameSpaceManager in nsJSEnvironment.cpp. These still need to move from nsJSContext to nsGlobalWindow or thereabouts, jband and vidur are looking at that.
- Added comments and expanded tabs in nsJSEnvironment.cpp, esp. to EvaluateString. Also changed various nsresult vars to be named rv. Also restored brace/style conformity to nsJSProtocolHandler.cpp.
- Factored CompileFunction from AddScriptEventListener to pave the way for brutal sharing of compiled JS event handlers via JS_CloneFunctionObject.
- Lots of nsCOMPtr uses added. I'm using one for mNameSpaceManager. Hold mSecurityManager as a service explicitly, on the other hand (awaiting scc's fix to allow comptrs for services), and release in nsJSContext's dtor (fixing a leak). These two managers should be moved to the window object -- TODO item below.
- Hold JSRuntimeService along with JSRuntime for live of nsJSEnvironment, fix for shaver.
- Fix window.setTimeout etc. so the filename and line number of the timeout expr is propagated. This meant factoring nsJSUtils.cpp code.
- Fix all content sinks to use the same, and up-to-date JavaScript version parsing (whether for script type or for old language attribute); also fix SplitMimeType clones to strip whitespace.
- With waterson, fix bug in brutal-sharing version of XUL content sink: script src= should not evaluate the inline content of its tag.
1999-10-31 00:43:30 +00:00
|
|
|
// to start parsing the URL specified by aURL.
|
1999-08-28 07:31:08 +00:00
|
|
|
parser->SetContentSink(sink);
|
|
|
|
nsAutoString utf8("UTF-8");
|
|
|
|
mDocument->SetDocumentCharacterSet(utf8);
|
|
|
|
parser->SetDocumentCharset(utf8, kCharsetFromDocTypeDefault);
|
|
|
|
parser->Parse(aUrl);
|
|
|
|
|
|
|
|
// Set the parser as the stream listener and start the URL load
|
|
|
|
nsCOMPtr<nsIStreamListener> sl;
|
|
|
|
rv = mParser->QueryInterface(kIStreamListenerIID, (void**)getter_AddRefs(sl));
|
(13163, r=alecf, scc, waterson, others; names available on request)
- Fix most of bug 13163 (see TODO for rest). This entails adding a version-string argument to nsIScriptContext::EvaluateString and passing it around lots of places in content sinks.
- Fix leaks and confusion about mSecurityManager and mNameSpaceManager in nsJSEnvironment.cpp. These still need to move from nsJSContext to nsGlobalWindow or thereabouts, jband and vidur are looking at that.
- Added comments and expanded tabs in nsJSEnvironment.cpp, esp. to EvaluateString. Also changed various nsresult vars to be named rv. Also restored brace/style conformity to nsJSProtocolHandler.cpp.
- Factored CompileFunction from AddScriptEventListener to pave the way for brutal sharing of compiled JS event handlers via JS_CloneFunctionObject.
- Lots of nsCOMPtr uses added. I'm using one for mNameSpaceManager. Hold mSecurityManager as a service explicitly, on the other hand (awaiting scc's fix to allow comptrs for services), and release in nsJSContext's dtor (fixing a leak). These two managers should be moved to the window object -- TODO item below.
- Hold JSRuntimeService along with JSRuntime for live of nsJSEnvironment, fix for shaver.
- Fix window.setTimeout etc. so the filename and line number of the timeout expr is propagated. This meant factoring nsJSUtils.cpp code.
- Fix all content sinks to use the same, and up-to-date JavaScript version parsing (whether for script type or for old language attribute); also fix SplitMimeType clones to strip whitespace.
- With waterson, fix bug in brutal-sharing version of XUL content sink: script src= should not evaluate the inline content of its tag.
1999-10-31 00:43:30 +00:00
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
|
|
|
|
rv = NS_OpenURI(sl, nsnull, aUrl);
|
1999-08-28 07:31:08 +00:00
|
|
|
|
1998-12-27 08:24:04 +00:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
1999-06-28 14:49:29 +00:00
|
|
|
nsresult
|
|
|
|
nsXMLContentSink::ProcessStyleLink(nsIContent* aElement,
|
|
|
|
const nsString& aHref, PRBool aAlternate,
|
|
|
|
const nsString& aTitle, const nsString& aType,
|
|
|
|
const nsString& aMedia)
|
1999-03-31 20:49:25 +00:00
|
|
|
{
|
1999-06-28 14:49:29 +00:00
|
|
|
nsresult rv = NS_OK;
|
1999-03-31 20:49:25 +00:00
|
|
|
|
1999-06-28 14:49:29 +00:00
|
|
|
if (aType.EqualsIgnoreCase(kXSLType))
|
|
|
|
rv = ProcessXSLStyleLink(aElement, aHref, aAlternate, aTitle, aType, aMedia);
|
|
|
|
else
|
|
|
|
rv = ProcessCSSStyleLink(aElement, aHref, aAlternate, aTitle, aType, aMedia);
|
1999-03-31 20:49:25 +00:00
|
|
|
|
1999-06-28 14:49:29 +00:00
|
|
|
return rv;
|
1999-03-31 20:49:25 +00:00
|
|
|
}
|
|
|
|
|
1999-06-28 14:49:29 +00:00
|
|
|
nsresult
|
|
|
|
nsXMLContentSink::ProcessXSLStyleLink(nsIContent* aElement,
|
|
|
|
const nsString& aHref, PRBool aAlternate,
|
|
|
|
const nsString& aTitle, const nsString& aType,
|
|
|
|
const nsString& aMedia)
|
1999-05-26 23:58:06 +00:00
|
|
|
{
|
1999-06-28 14:49:29 +00:00
|
|
|
nsresult rv = NS_OK;
|
|
|
|
nsIURI* url;
|
(13163, r=alecf, scc, waterson, others; names available on request)
- Fix most of bug 13163 (see TODO for rest). This entails adding a version-string argument to nsIScriptContext::EvaluateString and passing it around lots of places in content sinks.
- Fix leaks and confusion about mSecurityManager and mNameSpaceManager in nsJSEnvironment.cpp. These still need to move from nsJSContext to nsGlobalWindow or thereabouts, jband and vidur are looking at that.
- Added comments and expanded tabs in nsJSEnvironment.cpp, esp. to EvaluateString. Also changed various nsresult vars to be named rv. Also restored brace/style conformity to nsJSProtocolHandler.cpp.
- Factored CompileFunction from AddScriptEventListener to pave the way for brutal sharing of compiled JS event handlers via JS_CloneFunctionObject.
- Lots of nsCOMPtr uses added. I'm using one for mNameSpaceManager. Hold mSecurityManager as a service explicitly, on the other hand (awaiting scc's fix to allow comptrs for services), and release in nsJSContext's dtor (fixing a leak). These two managers should be moved to the window object -- TODO item below.
- Hold JSRuntimeService along with JSRuntime for live of nsJSEnvironment, fix for shaver.
- Fix window.setTimeout etc. so the filename and line number of the timeout expr is propagated. This meant factoring nsJSUtils.cpp code.
- Fix all content sinks to use the same, and up-to-date JavaScript version parsing (whether for script type or for old language attribute); also fix SplitMimeType clones to strip whitespace.
- With waterson, fix bug in brutal-sharing version of XUL content sink: script src= should not evaluate the inline content of its tag.
1999-10-31 00:43:30 +00:00
|
|
|
|
1999-06-28 14:49:29 +00:00
|
|
|
rv = CreateStyleSheetURL(&url, aHref);
|
|
|
|
if (NS_SUCCEEDED(rv)) {
|
|
|
|
rv = LoadXSLStyleSheet(url, aType);
|
|
|
|
NS_RELEASE(url);
|
1999-05-26 23:58:06 +00:00
|
|
|
}
|
(13163, r=alecf, scc, waterson, others; names available on request)
- Fix most of bug 13163 (see TODO for rest). This entails adding a version-string argument to nsIScriptContext::EvaluateString and passing it around lots of places in content sinks.
- Fix leaks and confusion about mSecurityManager and mNameSpaceManager in nsJSEnvironment.cpp. These still need to move from nsJSContext to nsGlobalWindow or thereabouts, jband and vidur are looking at that.
- Added comments and expanded tabs in nsJSEnvironment.cpp, esp. to EvaluateString. Also changed various nsresult vars to be named rv. Also restored brace/style conformity to nsJSProtocolHandler.cpp.
- Factored CompileFunction from AddScriptEventListener to pave the way for brutal sharing of compiled JS event handlers via JS_CloneFunctionObject.
- Lots of nsCOMPtr uses added. I'm using one for mNameSpaceManager. Hold mSecurityManager as a service explicitly, on the other hand (awaiting scc's fix to allow comptrs for services), and release in nsJSContext's dtor (fixing a leak). These two managers should be moved to the window object -- TODO item below.
- Hold JSRuntimeService along with JSRuntime for live of nsJSEnvironment, fix for shaver.
- Fix window.setTimeout etc. so the filename and line number of the timeout expr is propagated. This meant factoring nsJSUtils.cpp code.
- Fix all content sinks to use the same, and up-to-date JavaScript version parsing (whether for script type or for old language attribute); also fix SplitMimeType clones to strip whitespace.
- With waterson, fix bug in brutal-sharing version of XUL content sink: script src= should not evaluate the inline content of its tag.
1999-10-31 00:43:30 +00:00
|
|
|
|
1999-06-28 14:49:29 +00:00
|
|
|
return rv;
|
1999-05-26 23:58:06 +00:00
|
|
|
}
|
1999-06-28 14:49:29 +00:00
|
|
|
#endif
|
1999-05-26 23:58:06 +00:00
|
|
|
|
|
|
|
nsresult
|
1999-06-28 14:49:29 +00:00
|
|
|
nsXMLContentSink::ProcessCSSStyleLink(nsIContent* aElement,
|
1999-05-26 23:58:06 +00:00
|
|
|
const nsString& aHref, PRBool aAlternate,
|
|
|
|
const nsString& aTitle, const nsString& aType,
|
|
|
|
const nsString& aMedia)
|
|
|
|
{
|
|
|
|
nsresult result = NS_OK;
|
|
|
|
|
|
|
|
if (aAlternate) { // if alternate, does it have title?
|
|
|
|
if (0 == aTitle.Length()) { // alternates must have title
|
|
|
|
return NS_OK; //return without error, for now
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
nsAutoString mimeType;
|
|
|
|
nsAutoString params;
|
|
|
|
SplitMimeType(aType, mimeType, params);
|
|
|
|
|
|
|
|
if ((0 == mimeType.Length()) || mimeType.EqualsIgnoreCase("text/css")) {
|
1999-06-23 03:29:44 +00:00
|
|
|
nsIURI* url = nsnull;
|
1999-11-02 23:34:03 +00:00
|
|
|
// XXX we need to get passed in the nsILoadGroup here!
|
1999-07-01 19:30:20 +00:00
|
|
|
// nsILoadGroup* group = mDocument->GetDocumentLoadGroup();
|
1999-06-26 06:36:26 +00:00
|
|
|
result = NS_NewURI(&url, aHref, mDocumentBaseURL/*, group*/);
|
1999-05-26 23:58:06 +00:00
|
|
|
if (NS_OK != result) {
|
|
|
|
return NS_OK; // The URL is bad, move along, don't propogate the error (for now)
|
|
|
|
}
|
|
|
|
|
|
|
|
PRBool blockParser = PR_FALSE;
|
|
|
|
if (! aAlternate) {
|
|
|
|
if (0 < aTitle.Length()) { // possibly preferred sheet
|
|
|
|
if (0 == mPreferredStyle.Length()) {
|
|
|
|
mPreferredStyle = aTitle;
|
|
|
|
mCSSLoader->SetPreferredSheet(aTitle);
|
|
|
|
mDocument->SetHeaderData(nsHTMLAtoms::headerDefaultStyle, aTitle);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else { // persistent sheet, block
|
|
|
|
blockParser = PR_TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
PRBool doneLoading;
|
1999-06-15 06:22:46 +00:00
|
|
|
result = mCSSLoader->LoadStyleLink(aElement, url, aTitle, aMedia, kNameSpaceID_Unknown,
|
(13163, r=alecf, scc, waterson, others; names available on request)
- Fix most of bug 13163 (see TODO for rest). This entails adding a version-string argument to nsIScriptContext::EvaluateString and passing it around lots of places in content sinks.
- Fix leaks and confusion about mSecurityManager and mNameSpaceManager in nsJSEnvironment.cpp. These still need to move from nsJSContext to nsGlobalWindow or thereabouts, jband and vidur are looking at that.
- Added comments and expanded tabs in nsJSEnvironment.cpp, esp. to EvaluateString. Also changed various nsresult vars to be named rv. Also restored brace/style conformity to nsJSProtocolHandler.cpp.
- Factored CompileFunction from AddScriptEventListener to pave the way for brutal sharing of compiled JS event handlers via JS_CloneFunctionObject.
- Lots of nsCOMPtr uses added. I'm using one for mNameSpaceManager. Hold mSecurityManager as a service explicitly, on the other hand (awaiting scc's fix to allow comptrs for services), and release in nsJSContext's dtor (fixing a leak). These two managers should be moved to the window object -- TODO item below.
- Hold JSRuntimeService along with JSRuntime for live of nsJSEnvironment, fix for shaver.
- Fix window.setTimeout etc. so the filename and line number of the timeout expr is propagated. This meant factoring nsJSUtils.cpp code.
- Fix all content sinks to use the same, and up-to-date JavaScript version parsing (whether for script type or for old language attribute); also fix SplitMimeType clones to strip whitespace.
- With waterson, fix bug in brutal-sharing version of XUL content sink: script src= should not evaluate the inline content of its tag.
1999-10-31 00:43:30 +00:00
|
|
|
mStyleSheetCount++,
|
1999-12-04 01:29:18 +00:00
|
|
|
((blockParser) ? mParser : nsnull),
|
|
|
|
doneLoading, nsnull);
|
1999-05-26 23:58:06 +00:00
|
|
|
NS_RELEASE(url);
|
|
|
|
if (NS_SUCCEEDED(result) && blockParser && (! doneLoading)) {
|
|
|
|
result = NS_ERROR_HTMLPARSER_BLOCK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
(13163, r=alecf, scc, waterson, others; names available on request)
- Fix most of bug 13163 (see TODO for rest). This entails adding a version-string argument to nsIScriptContext::EvaluateString and passing it around lots of places in content sinks.
- Fix leaks and confusion about mSecurityManager and mNameSpaceManager in nsJSEnvironment.cpp. These still need to move from nsJSContext to nsGlobalWindow or thereabouts, jband and vidur are looking at that.
- Added comments and expanded tabs in nsJSEnvironment.cpp, esp. to EvaluateString. Also changed various nsresult vars to be named rv. Also restored brace/style conformity to nsJSProtocolHandler.cpp.
- Factored CompileFunction from AddScriptEventListener to pave the way for brutal sharing of compiled JS event handlers via JS_CloneFunctionObject.
- Lots of nsCOMPtr uses added. I'm using one for mNameSpaceManager. Hold mSecurityManager as a service explicitly, on the other hand (awaiting scc's fix to allow comptrs for services), and release in nsJSContext's dtor (fixing a leak). These two managers should be moved to the window object -- TODO item below.
- Hold JSRuntimeService along with JSRuntime for live of nsJSEnvironment, fix for shaver.
- Fix window.setTimeout etc. so the filename and line number of the timeout expr is propagated. This meant factoring nsJSUtils.cpp code.
- Fix all content sinks to use the same, and up-to-date JavaScript version parsing (whether for script type or for old language attribute); also fix SplitMimeType clones to strip whitespace.
- With waterson, fix bug in brutal-sharing version of XUL content sink: script src= should not evaluate the inline content of its tag.
1999-10-31 00:43:30 +00:00
|
|
|
NS_IMETHODIMP
|
1998-11-11 22:06:16 +00:00
|
|
|
nsXMLContentSink::AddProcessingInstruction(const nsIParserNode& aNode)
|
|
|
|
{
|
|
|
|
nsresult result = NS_OK;
|
1999-03-31 20:49:25 +00:00
|
|
|
nsAutoString text, target, data;
|
|
|
|
nsIContent* node;
|
|
|
|
|
|
|
|
FlushText();
|
1998-11-11 22:06:16 +00:00
|
|
|
|
|
|
|
text = aNode.GetText();
|
1999-03-31 20:49:25 +00:00
|
|
|
ParseProcessingInstruction(text, target, data);
|
|
|
|
result = NS_NewXMLProcessingInstruction(&node, target, data);
|
|
|
|
if (NS_OK == result) {
|
|
|
|
node->SetDocument(mDocument, PR_FALSE);
|
|
|
|
result = AddContentAsLeaf(node);
|
|
|
|
}
|
1998-11-11 22:06:16 +00:00
|
|
|
|
1999-03-31 20:49:25 +00:00
|
|
|
if (NS_OK == result) {
|
1999-05-26 23:58:06 +00:00
|
|
|
nsAutoString type, href, title, media, alternate;
|
(13163, r=alecf, scc, waterson, others; names available on request)
- Fix most of bug 13163 (see TODO for rest). This entails adding a version-string argument to nsIScriptContext::EvaluateString and passing it around lots of places in content sinks.
- Fix leaks and confusion about mSecurityManager and mNameSpaceManager in nsJSEnvironment.cpp. These still need to move from nsJSContext to nsGlobalWindow or thereabouts, jband and vidur are looking at that.
- Added comments and expanded tabs in nsJSEnvironment.cpp, esp. to EvaluateString. Also changed various nsresult vars to be named rv. Also restored brace/style conformity to nsJSProtocolHandler.cpp.
- Factored CompileFunction from AddScriptEventListener to pave the way for brutal sharing of compiled JS event handlers via JS_CloneFunctionObject.
- Lots of nsCOMPtr uses added. I'm using one for mNameSpaceManager. Hold mSecurityManager as a service explicitly, on the other hand (awaiting scc's fix to allow comptrs for services), and release in nsJSContext's dtor (fixing a leak). These two managers should be moved to the window object -- TODO item below.
- Hold JSRuntimeService along with JSRuntime for live of nsJSEnvironment, fix for shaver.
- Fix window.setTimeout etc. so the filename and line number of the timeout expr is propagated. This meant factoring nsJSUtils.cpp code.
- Fix all content sinks to use the same, and up-to-date JavaScript version parsing (whether for script type or for old language attribute); also fix SplitMimeType clones to strip whitespace.
- With waterson, fix bug in brutal-sharing version of XUL content sink: script src= should not evaluate the inline content of its tag.
1999-10-31 00:43:30 +00:00
|
|
|
|
1999-03-31 20:49:25 +00:00
|
|
|
// If it's a stylesheet PI...
|
1999-11-02 05:49:57 +00:00
|
|
|
if (target.Equals(kStyleSheetPI)) {
|
1999-03-31 20:49:25 +00:00
|
|
|
result = GetQuotedAttributeValue(text, "href", href);
|
|
|
|
// If there was an error or there's no href, we can't do
|
|
|
|
// anything with this PI
|
|
|
|
if ((NS_OK != result) || (0 == href.Length())) {
|
|
|
|
return result;
|
1998-11-11 22:06:16 +00:00
|
|
|
}
|
(13163, r=alecf, scc, waterson, others; names available on request)
- Fix most of bug 13163 (see TODO for rest). This entails adding a version-string argument to nsIScriptContext::EvaluateString and passing it around lots of places in content sinks.
- Fix leaks and confusion about mSecurityManager and mNameSpaceManager in nsJSEnvironment.cpp. These still need to move from nsJSContext to nsGlobalWindow or thereabouts, jband and vidur are looking at that.
- Added comments and expanded tabs in nsJSEnvironment.cpp, esp. to EvaluateString. Also changed various nsresult vars to be named rv. Also restored brace/style conformity to nsJSProtocolHandler.cpp.
- Factored CompileFunction from AddScriptEventListener to pave the way for brutal sharing of compiled JS event handlers via JS_CloneFunctionObject.
- Lots of nsCOMPtr uses added. I'm using one for mNameSpaceManager. Hold mSecurityManager as a service explicitly, on the other hand (awaiting scc's fix to allow comptrs for services), and release in nsJSContext's dtor (fixing a leak). These two managers should be moved to the window object -- TODO item below.
- Hold JSRuntimeService along with JSRuntime for live of nsJSEnvironment, fix for shaver.
- Fix window.setTimeout etc. so the filename and line number of the timeout expr is propagated. This meant factoring nsJSUtils.cpp code.
- Fix all content sinks to use the same, and up-to-date JavaScript version parsing (whether for script type or for old language attribute); also fix SplitMimeType clones to strip whitespace.
- With waterson, fix bug in brutal-sharing version of XUL content sink: script src= should not evaluate the inline content of its tag.
1999-10-31 00:43:30 +00:00
|
|
|
|
1999-03-31 20:49:25 +00:00
|
|
|
result = GetQuotedAttributeValue(text, "type", type);
|
|
|
|
if (NS_OK != result) {
|
|
|
|
return result;
|
1998-11-11 22:06:16 +00:00
|
|
|
}
|
1999-03-31 20:49:25 +00:00
|
|
|
result = GetQuotedAttributeValue(text, "title", title);
|
1998-12-16 05:40:20 +00:00
|
|
|
if (NS_OK != result) {
|
|
|
|
return result;
|
1998-11-11 22:06:16 +00:00
|
|
|
}
|
1999-03-31 20:49:25 +00:00
|
|
|
title.CompressWhitespace();
|
|
|
|
result = GetQuotedAttributeValue(text, "media", media);
|
|
|
|
if (NS_OK != result) {
|
|
|
|
return result;
|
1998-11-11 22:06:16 +00:00
|
|
|
}
|
1999-05-26 23:58:06 +00:00
|
|
|
media.ToLowerCase();
|
|
|
|
result = GetQuotedAttributeValue(text, "alternate", alternate);
|
|
|
|
if (NS_OK != result) {
|
|
|
|
return result;
|
1998-12-18 01:36:41 +00:00
|
|
|
}
|
(13163, r=alecf, scc, waterson, others; names available on request)
- Fix most of bug 13163 (see TODO for rest). This entails adding a version-string argument to nsIScriptContext::EvaluateString and passing it around lots of places in content sinks.
- Fix leaks and confusion about mSecurityManager and mNameSpaceManager in nsJSEnvironment.cpp. These still need to move from nsJSContext to nsGlobalWindow or thereabouts, jband and vidur are looking at that.
- Added comments and expanded tabs in nsJSEnvironment.cpp, esp. to EvaluateString. Also changed various nsresult vars to be named rv. Also restored brace/style conformity to nsJSProtocolHandler.cpp.
- Factored CompileFunction from AddScriptEventListener to pave the way for brutal sharing of compiled JS event handlers via JS_CloneFunctionObject.
- Lots of nsCOMPtr uses added. I'm using one for mNameSpaceManager. Hold mSecurityManager as a service explicitly, on the other hand (awaiting scc's fix to allow comptrs for services), and release in nsJSContext's dtor (fixing a leak). These two managers should be moved to the window object -- TODO item below.
- Hold JSRuntimeService along with JSRuntime for live of nsJSEnvironment, fix for shaver.
- Fix window.setTimeout etc. so the filename and line number of the timeout expr is propagated. This meant factoring nsJSUtils.cpp code.
- Fix all content sinks to use the same, and up-to-date JavaScript version parsing (whether for script type or for old language attribute); also fix SplitMimeType clones to strip whitespace.
- With waterson, fix bug in brutal-sharing version of XUL content sink: script src= should not evaluate the inline content of its tag.
1999-10-31 00:43:30 +00:00
|
|
|
#ifndef XSL
|
1999-06-28 14:49:29 +00:00
|
|
|
result = ProcessCSSStyleLink(node, href, alternate.Equals("yes"),
|
|
|
|
title, type, media);
|
|
|
|
#else
|
1999-05-26 23:58:06 +00:00
|
|
|
result = ProcessStyleLink(node, href, alternate.Equals("yes"),
|
|
|
|
title, type, media);
|
1999-06-28 14:49:29 +00:00
|
|
|
#endif
|
1998-11-11 22:06:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
1998-12-27 08:24:04 +00:00
|
|
|
|
1998-11-11 22:06:16 +00:00
|
|
|
|
(13163, r=alecf, scc, waterson, others; names available on request)
- Fix most of bug 13163 (see TODO for rest). This entails adding a version-string argument to nsIScriptContext::EvaluateString and passing it around lots of places in content sinks.
- Fix leaks and confusion about mSecurityManager and mNameSpaceManager in nsJSEnvironment.cpp. These still need to move from nsJSContext to nsGlobalWindow or thereabouts, jband and vidur are looking at that.
- Added comments and expanded tabs in nsJSEnvironment.cpp, esp. to EvaluateString. Also changed various nsresult vars to be named rv. Also restored brace/style conformity to nsJSProtocolHandler.cpp.
- Factored CompileFunction from AddScriptEventListener to pave the way for brutal sharing of compiled JS event handlers via JS_CloneFunctionObject.
- Lots of nsCOMPtr uses added. I'm using one for mNameSpaceManager. Hold mSecurityManager as a service explicitly, on the other hand (awaiting scc's fix to allow comptrs for services), and release in nsJSContext's dtor (fixing a leak). These two managers should be moved to the window object -- TODO item below.
- Hold JSRuntimeService along with JSRuntime for live of nsJSEnvironment, fix for shaver.
- Fix window.setTimeout etc. so the filename and line number of the timeout expr is propagated. This meant factoring nsJSUtils.cpp code.
- Fix all content sinks to use the same, and up-to-date JavaScript version parsing (whether for script type or for old language attribute); also fix SplitMimeType clones to strip whitespace.
- With waterson, fix bug in brutal-sharing version of XUL content sink: script src= should not evaluate the inline content of its tag.
1999-10-31 00:43:30 +00:00
|
|
|
NS_IMETHODIMP
|
1999-07-28 06:56:05 +00:00
|
|
|
nsXMLContentSink::AddDocTypeDecl(const nsIParserNode& aNode, PRInt32 aMode)
|
1998-11-11 22:06:16 +00:00
|
|
|
{
|
|
|
|
printf("nsXMLContentSink::AddDocTypeDecl\n");
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
1998-11-12 23:55:47 +00:00
|
|
|
nsXMLContentSink::FlushText(PRBool aCreateTextNode, PRBool* aDidFlush)
|
1998-11-11 22:06:16 +00:00
|
|
|
{
|
|
|
|
nsresult rv = NS_OK;
|
|
|
|
PRBool didFlush = PR_FALSE;
|
|
|
|
if (0 != mTextLength) {
|
1998-11-12 23:55:47 +00:00
|
|
|
if (aCreateTextNode) {
|
1999-01-14 23:14:02 +00:00
|
|
|
nsIContent* content;
|
1998-11-12 23:55:47 +00:00
|
|
|
rv = NS_NewTextNode(&content);
|
|
|
|
if (NS_OK == rv) {
|
|
|
|
// Set the content's document
|
|
|
|
content->SetDocument(mDocument, PR_FALSE);
|
(13163, r=alecf, scc, waterson, others; names available on request)
- Fix most of bug 13163 (see TODO for rest). This entails adding a version-string argument to nsIScriptContext::EvaluateString and passing it around lots of places in content sinks.
- Fix leaks and confusion about mSecurityManager and mNameSpaceManager in nsJSEnvironment.cpp. These still need to move from nsJSContext to nsGlobalWindow or thereabouts, jband and vidur are looking at that.
- Added comments and expanded tabs in nsJSEnvironment.cpp, esp. to EvaluateString. Also changed various nsresult vars to be named rv. Also restored brace/style conformity to nsJSProtocolHandler.cpp.
- Factored CompileFunction from AddScriptEventListener to pave the way for brutal sharing of compiled JS event handlers via JS_CloneFunctionObject.
- Lots of nsCOMPtr uses added. I'm using one for mNameSpaceManager. Hold mSecurityManager as a service explicitly, on the other hand (awaiting scc's fix to allow comptrs for services), and release in nsJSContext's dtor (fixing a leak). These two managers should be moved to the window object -- TODO item below.
- Hold JSRuntimeService along with JSRuntime for live of nsJSEnvironment, fix for shaver.
- Fix window.setTimeout etc. so the filename and line number of the timeout expr is propagated. This meant factoring nsJSUtils.cpp code.
- Fix all content sinks to use the same, and up-to-date JavaScript version parsing (whether for script type or for old language attribute); also fix SplitMimeType clones to strip whitespace.
- With waterson, fix bug in brutal-sharing version of XUL content sink: script src= should not evaluate the inline content of its tag.
1999-10-31 00:43:30 +00:00
|
|
|
|
1998-11-12 23:55:47 +00:00
|
|
|
// Set the text in the text node
|
|
|
|
static NS_DEFINE_IID(kITextContentIID, NS_ITEXT_CONTENT_IID);
|
|
|
|
nsITextContent* text = nsnull;
|
|
|
|
content->QueryInterface(kITextContentIID, (void**) &text);
|
|
|
|
text->SetText(mText, mTextLength, PR_FALSE);
|
|
|
|
NS_RELEASE(text);
|
|
|
|
|
|
|
|
// Add text to its parent
|
(13163, r=alecf, scc, waterson, others; names available on request)
- Fix most of bug 13163 (see TODO for rest). This entails adding a version-string argument to nsIScriptContext::EvaluateString and passing it around lots of places in content sinks.
- Fix leaks and confusion about mSecurityManager and mNameSpaceManager in nsJSEnvironment.cpp. These still need to move from nsJSContext to nsGlobalWindow or thereabouts, jband and vidur are looking at that.
- Added comments and expanded tabs in nsJSEnvironment.cpp, esp. to EvaluateString. Also changed various nsresult vars to be named rv. Also restored brace/style conformity to nsJSProtocolHandler.cpp.
- Factored CompileFunction from AddScriptEventListener to pave the way for brutal sharing of compiled JS event handlers via JS_CloneFunctionObject.
- Lots of nsCOMPtr uses added. I'm using one for mNameSpaceManager. Hold mSecurityManager as a service explicitly, on the other hand (awaiting scc's fix to allow comptrs for services), and release in nsJSContext's dtor (fixing a leak). These two managers should be moved to the window object -- TODO item below.
- Hold JSRuntimeService along with JSRuntime for live of nsJSEnvironment, fix for shaver.
- Fix window.setTimeout etc. so the filename and line number of the timeout expr is propagated. This meant factoring nsJSUtils.cpp code.
- Fix all content sinks to use the same, and up-to-date JavaScript version parsing (whether for script type or for old language attribute); also fix SplitMimeType clones to strip whitespace.
- With waterson, fix bug in brutal-sharing version of XUL content sink: script src= should not evaluate the inline content of its tag.
1999-10-31 00:43:30 +00:00
|
|
|
AddContentAsLeaf(content);
|
1998-11-12 23:55:47 +00:00
|
|
|
NS_RELEASE(content);
|
|
|
|
}
|
1998-11-11 22:06:16 +00:00
|
|
|
}
|
|
|
|
mTextLength = 0;
|
|
|
|
didFlush = PR_TRUE;
|
|
|
|
}
|
|
|
|
if (nsnull != aDidFlush) {
|
|
|
|
*aDidFlush = didFlush;
|
|
|
|
}
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
1998-12-18 01:36:41 +00:00
|
|
|
#define NS_ACCUMULATION_BUFFER_SIZE 4096
|
|
|
|
|
(13163, r=alecf, scc, waterson, others; names available on request)
- Fix most of bug 13163 (see TODO for rest). This entails adding a version-string argument to nsIScriptContext::EvaluateString and passing it around lots of places in content sinks.
- Fix leaks and confusion about mSecurityManager and mNameSpaceManager in nsJSEnvironment.cpp. These still need to move from nsJSContext to nsGlobalWindow or thereabouts, jband and vidur are looking at that.
- Added comments and expanded tabs in nsJSEnvironment.cpp, esp. to EvaluateString. Also changed various nsresult vars to be named rv. Also restored brace/style conformity to nsJSProtocolHandler.cpp.
- Factored CompileFunction from AddScriptEventListener to pave the way for brutal sharing of compiled JS event handlers via JS_CloneFunctionObject.
- Lots of nsCOMPtr uses added. I'm using one for mNameSpaceManager. Hold mSecurityManager as a service explicitly, on the other hand (awaiting scc's fix to allow comptrs for services), and release in nsJSContext's dtor (fixing a leak). These two managers should be moved to the window object -- TODO item below.
- Hold JSRuntimeService along with JSRuntime for live of nsJSEnvironment, fix for shaver.
- Fix window.setTimeout etc. so the filename and line number of the timeout expr is propagated. This meant factoring nsJSUtils.cpp code.
- Fix all content sinks to use the same, and up-to-date JavaScript version parsing (whether for script type or for old language attribute); also fix SplitMimeType clones to strip whitespace.
- With waterson, fix bug in brutal-sharing version of XUL content sink: script src= should not evaluate the inline content of its tag.
1999-10-31 00:43:30 +00:00
|
|
|
NS_IMETHODIMP
|
1998-11-11 22:06:16 +00:00
|
|
|
nsXMLContentSink::AddCharacterData(const nsIParserNode& aNode)
|
|
|
|
{
|
1999-02-26 17:13:51 +00:00
|
|
|
return AddText(aNode.GetText());
|
|
|
|
}
|
1998-11-11 22:06:16 +00:00
|
|
|
|
1999-02-26 17:13:51 +00:00
|
|
|
nsresult
|
|
|
|
nsXMLContentSink::AddText(const nsString& aString)
|
|
|
|
{
|
|
|
|
PRInt32 addLen = aString.Length();
|
1998-11-11 22:06:16 +00:00
|
|
|
if (0 == addLen) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Create buffer when we first need it
|
|
|
|
if (0 == mTextSize) {
|
1998-12-18 01:36:41 +00:00
|
|
|
mText = (PRUnichar *) PR_MALLOC(sizeof(PRUnichar) * NS_ACCUMULATION_BUFFER_SIZE);
|
1998-11-11 22:06:16 +00:00
|
|
|
if (nsnull == mText) {
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
1998-12-18 01:36:41 +00:00
|
|
|
mTextSize = NS_ACCUMULATION_BUFFER_SIZE;
|
1998-11-11 22:06:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Copy data from string into our buffer; flush buffer when it fills up
|
|
|
|
PRInt32 offset = 0;
|
|
|
|
while (0 != addLen) {
|
|
|
|
PRInt32 amount = mTextSize - mTextLength;
|
|
|
|
if (amount > addLen) {
|
|
|
|
amount = addLen;
|
|
|
|
}
|
|
|
|
if (0 == amount) {
|
1998-11-12 23:55:47 +00:00
|
|
|
if (mConstrainSize) {
|
|
|
|
nsresult rv = FlushText();
|
|
|
|
if (NS_OK != rv) {
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
mTextSize += addLen;
|
|
|
|
mText = (PRUnichar *) PR_REALLOC(mText, sizeof(PRUnichar) * mTextSize);
|
|
|
|
if (nsnull == mText) {
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
1998-11-11 22:06:16 +00:00
|
|
|
}
|
|
|
|
}
|
1999-02-26 17:13:51 +00:00
|
|
|
memcpy(&mText[mTextLength], aString.GetUnicode() + offset,
|
1998-11-11 22:06:16 +00:00
|
|
|
sizeof(PRUnichar) * amount);
|
|
|
|
mTextLength += amount;
|
|
|
|
offset += amount;
|
|
|
|
addLen -= amount;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
(13163, r=alecf, scc, waterson, others; names available on request)
- Fix most of bug 13163 (see TODO for rest). This entails adding a version-string argument to nsIScriptContext::EvaluateString and passing it around lots of places in content sinks.
- Fix leaks and confusion about mSecurityManager and mNameSpaceManager in nsJSEnvironment.cpp. These still need to move from nsJSContext to nsGlobalWindow or thereabouts, jband and vidur are looking at that.
- Added comments and expanded tabs in nsJSEnvironment.cpp, esp. to EvaluateString. Also changed various nsresult vars to be named rv. Also restored brace/style conformity to nsJSProtocolHandler.cpp.
- Factored CompileFunction from AddScriptEventListener to pave the way for brutal sharing of compiled JS event handlers via JS_CloneFunctionObject.
- Lots of nsCOMPtr uses added. I'm using one for mNameSpaceManager. Hold mSecurityManager as a service explicitly, on the other hand (awaiting scc's fix to allow comptrs for services), and release in nsJSContext's dtor (fixing a leak). These two managers should be moved to the window object -- TODO item below.
- Hold JSRuntimeService along with JSRuntime for live of nsJSEnvironment, fix for shaver.
- Fix window.setTimeout etc. so the filename and line number of the timeout expr is propagated. This meant factoring nsJSUtils.cpp code.
- Fix all content sinks to use the same, and up-to-date JavaScript version parsing (whether for script type or for old language attribute); also fix SplitMimeType clones to strip whitespace.
- With waterson, fix bug in brutal-sharing version of XUL content sink: script src= should not evaluate the inline content of its tag.
1999-10-31 00:43:30 +00:00
|
|
|
NS_IMETHODIMP
|
1998-11-11 22:06:16 +00:00
|
|
|
nsXMLContentSink::AddUnparsedEntity(const nsIParserNode& aNode)
|
|
|
|
{
|
|
|
|
printf("nsXMLContentSink::AddUnparsedEntity\n");
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
(13163, r=alecf, scc, waterson, others; names available on request)
- Fix most of bug 13163 (see TODO for rest). This entails adding a version-string argument to nsIScriptContext::EvaluateString and passing it around lots of places in content sinks.
- Fix leaks and confusion about mSecurityManager and mNameSpaceManager in nsJSEnvironment.cpp. These still need to move from nsJSContext to nsGlobalWindow or thereabouts, jband and vidur are looking at that.
- Added comments and expanded tabs in nsJSEnvironment.cpp, esp. to EvaluateString. Also changed various nsresult vars to be named rv. Also restored brace/style conformity to nsJSProtocolHandler.cpp.
- Factored CompileFunction from AddScriptEventListener to pave the way for brutal sharing of compiled JS event handlers via JS_CloneFunctionObject.
- Lots of nsCOMPtr uses added. I'm using one for mNameSpaceManager. Hold mSecurityManager as a service explicitly, on the other hand (awaiting scc's fix to allow comptrs for services), and release in nsJSContext's dtor (fixing a leak). These two managers should be moved to the window object -- TODO item below.
- Hold JSRuntimeService along with JSRuntime for live of nsJSEnvironment, fix for shaver.
- Fix window.setTimeout etc. so the filename and line number of the timeout expr is propagated. This meant factoring nsJSUtils.cpp code.
- Fix all content sinks to use the same, and up-to-date JavaScript version parsing (whether for script type or for old language attribute); also fix SplitMimeType clones to strip whitespace.
- With waterson, fix bug in brutal-sharing version of XUL content sink: script src= should not evaluate the inline content of its tag.
1999-10-31 00:43:30 +00:00
|
|
|
NS_IMETHODIMP
|
1998-11-11 22:06:16 +00:00
|
|
|
nsXMLContentSink::AddNotation(const nsIParserNode& aNode)
|
|
|
|
{
|
|
|
|
printf("nsXMLContentSink::AddNotation\n");
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
(13163, r=alecf, scc, waterson, others; names available on request)
- Fix most of bug 13163 (see TODO for rest). This entails adding a version-string argument to nsIScriptContext::EvaluateString and passing it around lots of places in content sinks.
- Fix leaks and confusion about mSecurityManager and mNameSpaceManager in nsJSEnvironment.cpp. These still need to move from nsJSContext to nsGlobalWindow or thereabouts, jband and vidur are looking at that.
- Added comments and expanded tabs in nsJSEnvironment.cpp, esp. to EvaluateString. Also changed various nsresult vars to be named rv. Also restored brace/style conformity to nsJSProtocolHandler.cpp.
- Factored CompileFunction from AddScriptEventListener to pave the way for brutal sharing of compiled JS event handlers via JS_CloneFunctionObject.
- Lots of nsCOMPtr uses added. I'm using one for mNameSpaceManager. Hold mSecurityManager as a service explicitly, on the other hand (awaiting scc's fix to allow comptrs for services), and release in nsJSContext's dtor (fixing a leak). These two managers should be moved to the window object -- TODO item below.
- Hold JSRuntimeService along with JSRuntime for live of nsJSEnvironment, fix for shaver.
- Fix window.setTimeout etc. so the filename and line number of the timeout expr is propagated. This meant factoring nsJSUtils.cpp code.
- Fix all content sinks to use the same, and up-to-date JavaScript version parsing (whether for script type or for old language attribute); also fix SplitMimeType clones to strip whitespace.
- With waterson, fix bug in brutal-sharing version of XUL content sink: script src= should not evaluate the inline content of its tag.
1999-10-31 00:43:30 +00:00
|
|
|
NS_IMETHODIMP
|
1998-11-11 22:06:16 +00:00
|
|
|
nsXMLContentSink::AddEntityReference(const nsIParserNode& aNode)
|
|
|
|
{
|
|
|
|
printf("nsXMLContentSink::AddEntityReference\n");
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
(13163, r=alecf, scc, waterson, others; names available on request)
- Fix most of bug 13163 (see TODO for rest). This entails adding a version-string argument to nsIScriptContext::EvaluateString and passing it around lots of places in content sinks.
- Fix leaks and confusion about mSecurityManager and mNameSpaceManager in nsJSEnvironment.cpp. These still need to move from nsJSContext to nsGlobalWindow or thereabouts, jband and vidur are looking at that.
- Added comments and expanded tabs in nsJSEnvironment.cpp, esp. to EvaluateString. Also changed various nsresult vars to be named rv. Also restored brace/style conformity to nsJSProtocolHandler.cpp.
- Factored CompileFunction from AddScriptEventListener to pave the way for brutal sharing of compiled JS event handlers via JS_CloneFunctionObject.
- Lots of nsCOMPtr uses added. I'm using one for mNameSpaceManager. Hold mSecurityManager as a service explicitly, on the other hand (awaiting scc's fix to allow comptrs for services), and release in nsJSContext's dtor (fixing a leak). These two managers should be moved to the window object -- TODO item below.
- Hold JSRuntimeService along with JSRuntime for live of nsJSEnvironment, fix for shaver.
- Fix window.setTimeout etc. so the filename and line number of the timeout expr is propagated. This meant factoring nsJSUtils.cpp code.
- Fix all content sinks to use the same, and up-to-date JavaScript version parsing (whether for script type or for old language attribute); also fix SplitMimeType clones to strip whitespace.
- With waterson, fix bug in brutal-sharing version of XUL content sink: script src= should not evaluate the inline content of its tag.
1999-10-31 00:43:30 +00:00
|
|
|
PRInt32
|
1998-12-11 02:53:49 +00:00
|
|
|
nsXMLContentSink::GetNameSpaceId(nsIAtom* aPrefix)
|
1998-11-11 22:06:16 +00:00
|
|
|
{
|
1999-01-21 19:33:03 +00:00
|
|
|
PRInt32 id = (nsnull == aPrefix) ? kNameSpaceID_None : kNameSpaceID_Unknown;
|
1998-12-11 02:53:49 +00:00
|
|
|
if ((nsnull != mNameSpaceStack) && (0 < mNameSpaceStack->Count())) {
|
|
|
|
PRInt32 index = mNameSpaceStack->Count() - 1;
|
|
|
|
nsINameSpace* nameSpace = (nsINameSpace*)mNameSpaceStack->ElementAt(index);
|
|
|
|
nameSpace->FindNameSpaceID(aPrefix, id);
|
1998-11-11 22:06:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return id;
|
|
|
|
}
|
|
|
|
|
(13163, r=alecf, scc, waterson, others; names available on request)
- Fix most of bug 13163 (see TODO for rest). This entails adding a version-string argument to nsIScriptContext::EvaluateString and passing it around lots of places in content sinks.
- Fix leaks and confusion about mSecurityManager and mNameSpaceManager in nsJSEnvironment.cpp. These still need to move from nsJSContext to nsGlobalWindow or thereabouts, jband and vidur are looking at that.
- Added comments and expanded tabs in nsJSEnvironment.cpp, esp. to EvaluateString. Also changed various nsresult vars to be named rv. Also restored brace/style conformity to nsJSProtocolHandler.cpp.
- Factored CompileFunction from AddScriptEventListener to pave the way for brutal sharing of compiled JS event handlers via JS_CloneFunctionObject.
- Lots of nsCOMPtr uses added. I'm using one for mNameSpaceManager. Hold mSecurityManager as a service explicitly, on the other hand (awaiting scc's fix to allow comptrs for services), and release in nsJSContext's dtor (fixing a leak). These two managers should be moved to the window object -- TODO item below.
- Hold JSRuntimeService along with JSRuntime for live of nsJSEnvironment, fix for shaver.
- Fix window.setTimeout etc. so the filename and line number of the timeout expr is propagated. This meant factoring nsJSUtils.cpp code.
- Fix all content sinks to use the same, and up-to-date JavaScript version parsing (whether for script type or for old language attribute); also fix SplitMimeType clones to strip whitespace.
- With waterson, fix bug in brutal-sharing version of XUL content sink: script src= should not evaluate the inline content of its tag.
1999-10-31 00:43:30 +00:00
|
|
|
nsINameSpace*
|
1998-12-11 02:53:49 +00:00
|
|
|
nsXMLContentSink::PopNameSpaces()
|
1998-11-11 22:06:16 +00:00
|
|
|
{
|
1998-12-11 02:53:49 +00:00
|
|
|
if ((nsnull != mNameSpaceStack) && (0 < mNameSpaceStack->Count())) {
|
|
|
|
PRInt32 index = mNameSpaceStack->Count() - 1;
|
|
|
|
nsINameSpace* nameSpace = (nsINameSpace*)mNameSpaceStack->ElementAt(index);
|
|
|
|
mNameSpaceStack->RemoveElementAt(index);
|
1999-01-12 16:37:24 +00:00
|
|
|
return nameSpace;
|
1998-11-11 22:06:16 +00:00
|
|
|
}
|
1999-01-12 16:37:24 +00:00
|
|
|
|
|
|
|
return nsnull;
|
1998-11-11 22:06:16 +00:00
|
|
|
}
|
|
|
|
|
(13163, r=alecf, scc, waterson, others; names available on request)
- Fix most of bug 13163 (see TODO for rest). This entails adding a version-string argument to nsIScriptContext::EvaluateString and passing it around lots of places in content sinks.
- Fix leaks and confusion about mSecurityManager and mNameSpaceManager in nsJSEnvironment.cpp. These still need to move from nsJSContext to nsGlobalWindow or thereabouts, jband and vidur are looking at that.
- Added comments and expanded tabs in nsJSEnvironment.cpp, esp. to EvaluateString. Also changed various nsresult vars to be named rv. Also restored brace/style conformity to nsJSProtocolHandler.cpp.
- Factored CompileFunction from AddScriptEventListener to pave the way for brutal sharing of compiled JS event handlers via JS_CloneFunctionObject.
- Lots of nsCOMPtr uses added. I'm using one for mNameSpaceManager. Hold mSecurityManager as a service explicitly, on the other hand (awaiting scc's fix to allow comptrs for services), and release in nsJSContext's dtor (fixing a leak). These two managers should be moved to the window object -- TODO item below.
- Hold JSRuntimeService along with JSRuntime for live of nsJSEnvironment, fix for shaver.
- Fix window.setTimeout etc. so the filename and line number of the timeout expr is propagated. This meant factoring nsJSUtils.cpp code.
- Fix all content sinks to use the same, and up-to-date JavaScript version parsing (whether for script type or for old language attribute); also fix SplitMimeType clones to strip whitespace.
- With waterson, fix bug in brutal-sharing version of XUL content sink: script src= should not evaluate the inline content of its tag.
1999-10-31 00:43:30 +00:00
|
|
|
PRBool
|
1998-12-11 02:53:49 +00:00
|
|
|
nsXMLContentSink::IsHTMLNameSpace(PRInt32 aID)
|
1998-11-11 22:06:16 +00:00
|
|
|
{
|
1998-12-11 02:53:49 +00:00
|
|
|
return PRBool(kNameSpaceID_HTML == aID);
|
1998-11-11 22:06:16 +00:00
|
|
|
}
|
|
|
|
|
(13163, r=alecf, scc, waterson, others; names available on request)
- Fix most of bug 13163 (see TODO for rest). This entails adding a version-string argument to nsIScriptContext::EvaluateString and passing it around lots of places in content sinks.
- Fix leaks and confusion about mSecurityManager and mNameSpaceManager in nsJSEnvironment.cpp. These still need to move from nsJSContext to nsGlobalWindow or thereabouts, jband and vidur are looking at that.
- Added comments and expanded tabs in nsJSEnvironment.cpp, esp. to EvaluateString. Also changed various nsresult vars to be named rv. Also restored brace/style conformity to nsJSProtocolHandler.cpp.
- Factored CompileFunction from AddScriptEventListener to pave the way for brutal sharing of compiled JS event handlers via JS_CloneFunctionObject.
- Lots of nsCOMPtr uses added. I'm using one for mNameSpaceManager. Hold mSecurityManager as a service explicitly, on the other hand (awaiting scc's fix to allow comptrs for services), and release in nsJSContext's dtor (fixing a leak). These two managers should be moved to the window object -- TODO item below.
- Hold JSRuntimeService along with JSRuntime for live of nsJSEnvironment, fix for shaver.
- Fix window.setTimeout etc. so the filename and line number of the timeout expr is propagated. This meant factoring nsJSUtils.cpp code.
- Fix all content sinks to use the same, and up-to-date JavaScript version parsing (whether for script type or for old language attribute); also fix SplitMimeType clones to strip whitespace.
- With waterson, fix bug in brutal-sharing version of XUL content sink: script src= should not evaluate the inline content of its tag.
1999-10-31 00:43:30 +00:00
|
|
|
nsIContent*
|
1998-11-11 22:06:16 +00:00
|
|
|
nsXMLContentSink::GetCurrentContent()
|
|
|
|
{
|
1998-12-11 02:53:49 +00:00
|
|
|
if (nsnull != mContentStack) {
|
|
|
|
PRInt32 index = mContentStack->Count() - 1;
|
|
|
|
return (nsIContent *)mContentStack->ElementAt(index);
|
1998-11-11 22:06:16 +00:00
|
|
|
}
|
1998-12-11 02:53:49 +00:00
|
|
|
return nsnull;
|
1998-11-11 22:06:16 +00:00
|
|
|
}
|
|
|
|
|
(13163, r=alecf, scc, waterson, others; names available on request)
- Fix most of bug 13163 (see TODO for rest). This entails adding a version-string argument to nsIScriptContext::EvaluateString and passing it around lots of places in content sinks.
- Fix leaks and confusion about mSecurityManager and mNameSpaceManager in nsJSEnvironment.cpp. These still need to move from nsJSContext to nsGlobalWindow or thereabouts, jband and vidur are looking at that.
- Added comments and expanded tabs in nsJSEnvironment.cpp, esp. to EvaluateString. Also changed various nsresult vars to be named rv. Also restored brace/style conformity to nsJSProtocolHandler.cpp.
- Factored CompileFunction from AddScriptEventListener to pave the way for brutal sharing of compiled JS event handlers via JS_CloneFunctionObject.
- Lots of nsCOMPtr uses added. I'm using one for mNameSpaceManager. Hold mSecurityManager as a service explicitly, on the other hand (awaiting scc's fix to allow comptrs for services), and release in nsJSContext's dtor (fixing a leak). These two managers should be moved to the window object -- TODO item below.
- Hold JSRuntimeService along with JSRuntime for live of nsJSEnvironment, fix for shaver.
- Fix window.setTimeout etc. so the filename and line number of the timeout expr is propagated. This meant factoring nsJSUtils.cpp code.
- Fix all content sinks to use the same, and up-to-date JavaScript version parsing (whether for script type or for old language attribute); also fix SplitMimeType clones to strip whitespace.
- With waterson, fix bug in brutal-sharing version of XUL content sink: script src= should not evaluate the inline content of its tag.
1999-10-31 00:43:30 +00:00
|
|
|
PRInt32
|
1998-11-11 22:06:16 +00:00
|
|
|
nsXMLContentSink::PushContent(nsIContent *aContent)
|
|
|
|
{
|
|
|
|
if (nsnull == mContentStack) {
|
|
|
|
mContentStack = new nsVoidArray();
|
|
|
|
}
|
(13163, r=alecf, scc, waterson, others; names available on request)
- Fix most of bug 13163 (see TODO for rest). This entails adding a version-string argument to nsIScriptContext::EvaluateString and passing it around lots of places in content sinks.
- Fix leaks and confusion about mSecurityManager and mNameSpaceManager in nsJSEnvironment.cpp. These still need to move from nsJSContext to nsGlobalWindow or thereabouts, jband and vidur are looking at that.
- Added comments and expanded tabs in nsJSEnvironment.cpp, esp. to EvaluateString. Also changed various nsresult vars to be named rv. Also restored brace/style conformity to nsJSProtocolHandler.cpp.
- Factored CompileFunction from AddScriptEventListener to pave the way for brutal sharing of compiled JS event handlers via JS_CloneFunctionObject.
- Lots of nsCOMPtr uses added. I'm using one for mNameSpaceManager. Hold mSecurityManager as a service explicitly, on the other hand (awaiting scc's fix to allow comptrs for services), and release in nsJSContext's dtor (fixing a leak). These two managers should be moved to the window object -- TODO item below.
- Hold JSRuntimeService along with JSRuntime for live of nsJSEnvironment, fix for shaver.
- Fix window.setTimeout etc. so the filename and line number of the timeout expr is propagated. This meant factoring nsJSUtils.cpp code.
- Fix all content sinks to use the same, and up-to-date JavaScript version parsing (whether for script type or for old language attribute); also fix SplitMimeType clones to strip whitespace.
- With waterson, fix bug in brutal-sharing version of XUL content sink: script src= should not evaluate the inline content of its tag.
1999-10-31 00:43:30 +00:00
|
|
|
|
1998-11-11 22:06:16 +00:00
|
|
|
mContentStack->AppendElement((void *)aContent);
|
1998-12-11 02:53:49 +00:00
|
|
|
return mContentStack->Count();
|
1998-11-11 22:06:16 +00:00
|
|
|
}
|
(13163, r=alecf, scc, waterson, others; names available on request)
- Fix most of bug 13163 (see TODO for rest). This entails adding a version-string argument to nsIScriptContext::EvaluateString and passing it around lots of places in content sinks.
- Fix leaks and confusion about mSecurityManager and mNameSpaceManager in nsJSEnvironment.cpp. These still need to move from nsJSContext to nsGlobalWindow or thereabouts, jband and vidur are looking at that.
- Added comments and expanded tabs in nsJSEnvironment.cpp, esp. to EvaluateString. Also changed various nsresult vars to be named rv. Also restored brace/style conformity to nsJSProtocolHandler.cpp.
- Factored CompileFunction from AddScriptEventListener to pave the way for brutal sharing of compiled JS event handlers via JS_CloneFunctionObject.
- Lots of nsCOMPtr uses added. I'm using one for mNameSpaceManager. Hold mSecurityManager as a service explicitly, on the other hand (awaiting scc's fix to allow comptrs for services), and release in nsJSContext's dtor (fixing a leak). These two managers should be moved to the window object -- TODO item below.
- Hold JSRuntimeService along with JSRuntime for live of nsJSEnvironment, fix for shaver.
- Fix window.setTimeout etc. so the filename and line number of the timeout expr is propagated. This meant factoring nsJSUtils.cpp code.
- Fix all content sinks to use the same, and up-to-date JavaScript version parsing (whether for script type or for old language attribute); also fix SplitMimeType clones to strip whitespace.
- With waterson, fix bug in brutal-sharing version of XUL content sink: script src= should not evaluate the inline content of its tag.
1999-10-31 00:43:30 +00:00
|
|
|
|
1998-11-11 22:06:16 +00:00
|
|
|
nsIContent*
|
|
|
|
nsXMLContentSink::PopContent()
|
|
|
|
{
|
1998-12-11 02:53:49 +00:00
|
|
|
nsIContent* content = nsnull;
|
|
|
|
if (nsnull != mContentStack) {
|
|
|
|
PRInt32 index = mContentStack->Count() - 1;
|
|
|
|
content = (nsIContent *)mContentStack->ElementAt(index);
|
|
|
|
mContentStack->RemoveElementAt(index);
|
1998-11-11 22:06:16 +00:00
|
|
|
}
|
|
|
|
return content;
|
|
|
|
}
|
(13163, r=alecf, scc, waterson, others; names available on request)
- Fix most of bug 13163 (see TODO for rest). This entails adding a version-string argument to nsIScriptContext::EvaluateString and passing it around lots of places in content sinks.
- Fix leaks and confusion about mSecurityManager and mNameSpaceManager in nsJSEnvironment.cpp. These still need to move from nsJSContext to nsGlobalWindow or thereabouts, jband and vidur are looking at that.
- Added comments and expanded tabs in nsJSEnvironment.cpp, esp. to EvaluateString. Also changed various nsresult vars to be named rv. Also restored brace/style conformity to nsJSProtocolHandler.cpp.
- Factored CompileFunction from AddScriptEventListener to pave the way for brutal sharing of compiled JS event handlers via JS_CloneFunctionObject.
- Lots of nsCOMPtr uses added. I'm using one for mNameSpaceManager. Hold mSecurityManager as a service explicitly, on the other hand (awaiting scc's fix to allow comptrs for services), and release in nsJSContext's dtor (fixing a leak). These two managers should be moved to the window object -- TODO item below.
- Hold JSRuntimeService along with JSRuntime for live of nsJSEnvironment, fix for shaver.
- Fix window.setTimeout etc. so the filename and line number of the timeout expr is propagated. This meant factoring nsJSUtils.cpp code.
- Fix all content sinks to use the same, and up-to-date JavaScript version parsing (whether for script type or for old language attribute); also fix SplitMimeType clones to strip whitespace.
- With waterson, fix bug in brutal-sharing version of XUL content sink: script src= should not evaluate the inline content of its tag.
1999-10-31 00:43:30 +00:00
|
|
|
|
1998-11-11 22:06:16 +00:00
|
|
|
void
|
|
|
|
nsXMLContentSink::StartLayout()
|
|
|
|
{
|
|
|
|
PRInt32 i, ns = mDocument->GetNumberOfShells();
|
|
|
|
for (i = 0; i < ns; i++) {
|
|
|
|
nsIPresShell* shell = mDocument->GetShellAt(i);
|
|
|
|
if (nsnull != shell) {
|
|
|
|
// Make shell an observer for next time
|
|
|
|
shell->BeginObservingDocument();
|
|
|
|
|
|
|
|
// Resize-reflow this time
|
1999-02-12 17:45:58 +00:00
|
|
|
nsCOMPtr<nsIPresContext> cx;
|
|
|
|
shell->GetPresContext(getter_AddRefs(cx));
|
1998-11-11 22:06:16 +00:00
|
|
|
nsRect r;
|
|
|
|
cx->GetVisibleArea(r);
|
|
|
|
shell->InitialReflow(r.width, r.height);
|
|
|
|
|
|
|
|
// Now trigger a refresh
|
1999-02-12 17:45:58 +00:00
|
|
|
nsCOMPtr<nsIViewManager> vm;
|
|
|
|
shell->GetViewManager(getter_AddRefs(vm));
|
1999-02-12 18:41:26 +00:00
|
|
|
if (vm) {
|
1999-05-13 20:27:47 +00:00
|
|
|
RefreshIfEnabled(vm);
|
1998-11-11 22:06:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_RELEASE(shell);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// If the document we are loading has a reference or it is a top level
|
|
|
|
// frameset document, disable the scroll bars on the views.
|
1999-06-26 06:36:26 +00:00
|
|
|
char* ref = nsnull;
|
|
|
|
nsIURL* url;
|
|
|
|
nsresult rv = mDocumentURL->QueryInterface(nsIURL::GetIID(), (void**)&url);
|
|
|
|
if (NS_SUCCEEDED(rv)) {
|
|
|
|
rv = url->GetRef(&ref);
|
|
|
|
NS_RELEASE(url);
|
|
|
|
}
|
1998-11-11 22:06:16 +00:00
|
|
|
PRBool topLevelFrameset = PR_FALSE;
|
1999-12-18 02:09:29 +00:00
|
|
|
nsCOMPtr<nsIDocShellTreeItem> docShellAsItem(do_QueryInterface(mWebShell));
|
|
|
|
if (docShellAsItem) {
|
|
|
|
nsCOMPtr<nsIDocShellTreeItem> root;
|
|
|
|
docShellAsItem->GetSameTypeRootTreeItem(getter_AddRefs(root));
|
|
|
|
if(docShellAsItem.get() == root.get()) {
|
1998-11-11 22:06:16 +00:00
|
|
|
topLevelFrameset = PR_TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((nsnull != ref) || topLevelFrameset) {
|
|
|
|
// XXX support more than one presentation-shell here
|
|
|
|
|
|
|
|
// Get initial scroll preference and save it away; disable the
|
|
|
|
// scroll bars.
|
1999-09-17 20:16:37 +00:00
|
|
|
ns = mDocument->GetNumberOfShells();
|
1998-11-11 22:06:16 +00:00
|
|
|
for (i = 0; i < ns; i++) {
|
|
|
|
nsIPresShell* shell = mDocument->GetShellAt(i);
|
|
|
|
if (nsnull != shell) {
|
1999-02-12 17:45:58 +00:00
|
|
|
nsCOMPtr<nsIViewManager>vm;
|
|
|
|
shell->GetViewManager(getter_AddRefs(vm));
|
1999-02-12 18:41:26 +00:00
|
|
|
if (vm) {
|
1998-11-11 22:06:16 +00:00
|
|
|
nsIView* rootView = nsnull;
|
|
|
|
vm->GetRootView(rootView);
|
|
|
|
if (nsnull != rootView) {
|
|
|
|
nsIScrollableView* sview = nsnull;
|
|
|
|
rootView->QueryInterface(kIScrollableViewIID, (void**) &sview);
|
|
|
|
if (nsnull != sview) {
|
|
|
|
if (topLevelFrameset)
|
|
|
|
mOriginalScrollPreference = nsScrollPreference_kNeverScroll;
|
|
|
|
else
|
|
|
|
sview->GetScrollPreference(mOriginalScrollPreference);
|
|
|
|
sview->SetScrollPreference(nsScrollPreference_kNeverScroll);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
NS_RELEASE(shell);
|
|
|
|
}
|
|
|
|
}
|
1999-06-26 06:36:26 +00:00
|
|
|
// XXX who actually uses ref here anyway?
|
|
|
|
nsCRT::free(ref);
|
1998-11-11 22:06:16 +00:00
|
|
|
}
|
|
|
|
}
|
1998-11-12 23:55:47 +00:00
|
|
|
|
1998-12-18 01:36:41 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsXMLContentSink::ResumeParsing()
|
|
|
|
{
|
1999-12-04 01:29:18 +00:00
|
|
|
if (mParser) {
|
1998-12-18 01:36:41 +00:00
|
|
|
mParser->EnableParser(PR_TRUE);
|
|
|
|
}
|
(13163, r=alecf, scc, waterson, others; names available on request)
- Fix most of bug 13163 (see TODO for rest). This entails adding a version-string argument to nsIScriptContext::EvaluateString and passing it around lots of places in content sinks.
- Fix leaks and confusion about mSecurityManager and mNameSpaceManager in nsJSEnvironment.cpp. These still need to move from nsJSContext to nsGlobalWindow or thereabouts, jband and vidur are looking at that.
- Added comments and expanded tabs in nsJSEnvironment.cpp, esp. to EvaluateString. Also changed various nsresult vars to be named rv. Also restored brace/style conformity to nsJSProtocolHandler.cpp.
- Factored CompileFunction from AddScriptEventListener to pave the way for brutal sharing of compiled JS event handlers via JS_CloneFunctionObject.
- Lots of nsCOMPtr uses added. I'm using one for mNameSpaceManager. Hold mSecurityManager as a service explicitly, on the other hand (awaiting scc's fix to allow comptrs for services), and release in nsJSContext's dtor (fixing a leak). These two managers should be moved to the window object -- TODO item below.
- Hold JSRuntimeService along with JSRuntime for live of nsJSEnvironment, fix for shaver.
- Fix window.setTimeout etc. so the filename and line number of the timeout expr is propagated. This meant factoring nsJSUtils.cpp code.
- Fix all content sinks to use the same, and up-to-date JavaScript version parsing (whether for script type or for old language attribute); also fix SplitMimeType clones to strip whitespace.
- With waterson, fix bug in brutal-sharing version of XUL content sink: script src= should not evaluate the inline content of its tag.
1999-10-31 00:43:30 +00:00
|
|
|
|
1998-12-18 01:36:41 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
(13163, r=alecf, scc, waterson, others; names available on request)
- Fix most of bug 13163 (see TODO for rest). This entails adding a version-string argument to nsIScriptContext::EvaluateString and passing it around lots of places in content sinks.
- Fix leaks and confusion about mSecurityManager and mNameSpaceManager in nsJSEnvironment.cpp. These still need to move from nsJSContext to nsGlobalWindow or thereabouts, jband and vidur are looking at that.
- Added comments and expanded tabs in nsJSEnvironment.cpp, esp. to EvaluateString. Also changed various nsresult vars to be named rv. Also restored brace/style conformity to nsJSProtocolHandler.cpp.
- Factored CompileFunction from AddScriptEventListener to pave the way for brutal sharing of compiled JS event handlers via JS_CloneFunctionObject.
- Lots of nsCOMPtr uses added. I'm using one for mNameSpaceManager. Hold mSecurityManager as a service explicitly, on the other hand (awaiting scc's fix to allow comptrs for services), and release in nsJSContext's dtor (fixing a leak). These two managers should be moved to the window object -- TODO item below.
- Hold JSRuntimeService along with JSRuntime for live of nsJSEnvironment, fix for shaver.
- Fix window.setTimeout etc. so the filename and line number of the timeout expr is propagated. This meant factoring nsJSUtils.cpp code.
- Fix all content sinks to use the same, and up-to-date JavaScript version parsing (whether for script type or for old language attribute); also fix SplitMimeType clones to strip whitespace.
- With waterson, fix bug in brutal-sharing version of XUL content sink: script src= should not evaluate the inline content of its tag.
1999-10-31 00:43:30 +00:00
|
|
|
nsXMLContentSink::EvaluateScript(nsString& aScript, PRUint32 aLineNo, const char* aVersion)
|
1998-11-12 23:55:47 +00:00
|
|
|
{
|
|
|
|
nsresult rv = NS_OK;
|
|
|
|
|
|
|
|
if (0 < aScript.Length()) {
|
1999-12-03 09:24:22 +00:00
|
|
|
nsCOMPtr<nsIScriptGlobalObject> scriptGlobal;
|
|
|
|
mDocument->GetScriptGlobalObject(getter_AddRefs(scriptGlobal));
|
|
|
|
if (scriptGlobal) {
|
|
|
|
nsCOMPtr<nsIScriptContext> context;
|
|
|
|
NS_ENSURE_SUCCESS(scriptGlobal->GetContext(getter_AddRefs(context)),
|
|
|
|
NS_ERROR_FAILURE);
|
(13163, r=alecf, scc, waterson, others; names available on request)
- Fix most of bug 13163 (see TODO for rest). This entails adding a version-string argument to nsIScriptContext::EvaluateString and passing it around lots of places in content sinks.
- Fix leaks and confusion about mSecurityManager and mNameSpaceManager in nsJSEnvironment.cpp. These still need to move from nsJSContext to nsGlobalWindow or thereabouts, jband and vidur are looking at that.
- Added comments and expanded tabs in nsJSEnvironment.cpp, esp. to EvaluateString. Also changed various nsresult vars to be named rv. Also restored brace/style conformity to nsJSProtocolHandler.cpp.
- Factored CompileFunction from AddScriptEventListener to pave the way for brutal sharing of compiled JS event handlers via JS_CloneFunctionObject.
- Lots of nsCOMPtr uses added. I'm using one for mNameSpaceManager. Hold mSecurityManager as a service explicitly, on the other hand (awaiting scc's fix to allow comptrs for services), and release in nsJSContext's dtor (fixing a leak). These two managers should be moved to the window object -- TODO item below.
- Hold JSRuntimeService along with JSRuntime for live of nsJSEnvironment, fix for shaver.
- Fix window.setTimeout etc. so the filename and line number of the timeout expr is propagated. This meant factoring nsJSUtils.cpp code.
- Fix all content sinks to use the same, and up-to-date JavaScript version parsing (whether for script type or for old language attribute); also fix SplitMimeType clones to strip whitespace.
- With waterson, fix bug in brutal-sharing version of XUL content sink: script src= should not evaluate the inline content of its tag.
1999-10-31 00:43:30 +00:00
|
|
|
|
1999-06-23 03:29:44 +00:00
|
|
|
nsIURI* docURL = mDocument->GetDocumentURL();
|
1999-06-26 06:36:26 +00:00
|
|
|
char* url;
|
1999-01-21 19:33:03 +00:00
|
|
|
if (docURL) {
|
1999-06-26 06:36:26 +00:00
|
|
|
rv = docURL->GetSpec(&url);
|
1998-11-12 23:55:47 +00:00
|
|
|
}
|
1998-12-15 06:10:59 +00:00
|
|
|
|
1999-06-26 06:36:26 +00:00
|
|
|
if (NS_SUCCEEDED(rv)) {
|
|
|
|
nsAutoString val;
|
|
|
|
PRBool isUndefined;
|
1998-12-15 06:10:59 +00:00
|
|
|
|
(13163, r=alecf, scc, waterson, others; names available on request)
- Fix most of bug 13163 (see TODO for rest). This entails adding a version-string argument to nsIScriptContext::EvaluateString and passing it around lots of places in content sinks.
- Fix leaks and confusion about mSecurityManager and mNameSpaceManager in nsJSEnvironment.cpp. These still need to move from nsJSContext to nsGlobalWindow or thereabouts, jband and vidur are looking at that.
- Added comments and expanded tabs in nsJSEnvironment.cpp, esp. to EvaluateString. Also changed various nsresult vars to be named rv. Also restored brace/style conformity to nsJSProtocolHandler.cpp.
- Factored CompileFunction from AddScriptEventListener to pave the way for brutal sharing of compiled JS event handlers via JS_CloneFunctionObject.
- Lots of nsCOMPtr uses added. I'm using one for mNameSpaceManager. Hold mSecurityManager as a service explicitly, on the other hand (awaiting scc's fix to allow comptrs for services), and release in nsJSContext's dtor (fixing a leak). These two managers should be moved to the window object -- TODO item below.
- Hold JSRuntimeService along with JSRuntime for live of nsJSEnvironment, fix for shaver.
- Fix window.setTimeout etc. so the filename and line number of the timeout expr is propagated. This meant factoring nsJSUtils.cpp code.
- Fix all content sinks to use the same, and up-to-date JavaScript version parsing (whether for script type or for old language attribute); also fix SplitMimeType clones to strip whitespace.
- With waterson, fix bug in brutal-sharing version of XUL content sink: script src= should not evaluate the inline content of its tag.
1999-10-31 00:43:30 +00:00
|
|
|
(void) context->EvaluateString(aScript, url, aLineNo, aVersion,
|
1999-09-17 20:16:37 +00:00
|
|
|
val, &isUndefined);
|
(13163, r=alecf, scc, waterson, others; names available on request)
- Fix most of bug 13163 (see TODO for rest). This entails adding a version-string argument to nsIScriptContext::EvaluateString and passing it around lots of places in content sinks.
- Fix leaks and confusion about mSecurityManager and mNameSpaceManager in nsJSEnvironment.cpp. These still need to move from nsJSContext to nsGlobalWindow or thereabouts, jband and vidur are looking at that.
- Added comments and expanded tabs in nsJSEnvironment.cpp, esp. to EvaluateString. Also changed various nsresult vars to be named rv. Also restored brace/style conformity to nsJSProtocolHandler.cpp.
- Factored CompileFunction from AddScriptEventListener to pave the way for brutal sharing of compiled JS event handlers via JS_CloneFunctionObject.
- Lots of nsCOMPtr uses added. I'm using one for mNameSpaceManager. Hold mSecurityManager as a service explicitly, on the other hand (awaiting scc's fix to allow comptrs for services), and release in nsJSContext's dtor (fixing a leak). These two managers should be moved to the window object -- TODO item below.
- Hold JSRuntimeService along with JSRuntime for live of nsJSEnvironment, fix for shaver.
- Fix window.setTimeout etc. so the filename and line number of the timeout expr is propagated. This meant factoring nsJSUtils.cpp code.
- Fix all content sinks to use the same, and up-to-date JavaScript version parsing (whether for script type or for old language attribute); also fix SplitMimeType clones to strip whitespace.
- With waterson, fix bug in brutal-sharing version of XUL content sink: script src= should not evaluate the inline content of its tag.
1999-10-31 00:43:30 +00:00
|
|
|
|
1999-06-26 06:36:26 +00:00
|
|
|
NS_IF_RELEASE(docURL);
|
(13163, r=alecf, scc, waterson, others; names available on request)
- Fix most of bug 13163 (see TODO for rest). This entails adding a version-string argument to nsIScriptContext::EvaluateString and passing it around lots of places in content sinks.
- Fix leaks and confusion about mSecurityManager and mNameSpaceManager in nsJSEnvironment.cpp. These still need to move from nsJSContext to nsGlobalWindow or thereabouts, jband and vidur are looking at that.
- Added comments and expanded tabs in nsJSEnvironment.cpp, esp. to EvaluateString. Also changed various nsresult vars to be named rv. Also restored brace/style conformity to nsJSProtocolHandler.cpp.
- Factored CompileFunction from AddScriptEventListener to pave the way for brutal sharing of compiled JS event handlers via JS_CloneFunctionObject.
- Lots of nsCOMPtr uses added. I'm using one for mNameSpaceManager. Hold mSecurityManager as a service explicitly, on the other hand (awaiting scc's fix to allow comptrs for services), and release in nsJSContext's dtor (fixing a leak). These two managers should be moved to the window object -- TODO item below.
- Hold JSRuntimeService along with JSRuntime for live of nsJSEnvironment, fix for shaver.
- Fix window.setTimeout etc. so the filename and line number of the timeout expr is propagated. This meant factoring nsJSUtils.cpp code.
- Fix all content sinks to use the same, and up-to-date JavaScript version parsing (whether for script type or for old language attribute); also fix SplitMimeType clones to strip whitespace.
- With waterson, fix bug in brutal-sharing version of XUL content sink: script src= should not evaluate the inline content of its tag.
1999-10-31 00:43:30 +00:00
|
|
|
|
1999-06-26 06:36:26 +00:00
|
|
|
nsCRT::free(url);
|
|
|
|
}
|
1998-11-12 23:55:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-06-26 06:36:26 +00:00
|
|
|
return rv;
|
1998-11-12 23:55:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsXMLContentSink::ProcessEndSCRIPTTag(const nsIParserNode& aNode)
|
|
|
|
{
|
|
|
|
nsresult result = NS_OK;
|
|
|
|
if (mInScript) {
|
|
|
|
nsAutoString script;
|
|
|
|
script.SetString(mText, mTextLength);
|
(13163, r=alecf, scc, waterson, others; names available on request)
- Fix most of bug 13163 (see TODO for rest). This entails adding a version-string argument to nsIScriptContext::EvaluateString and passing it around lots of places in content sinks.
- Fix leaks and confusion about mSecurityManager and mNameSpaceManager in nsJSEnvironment.cpp. These still need to move from nsJSContext to nsGlobalWindow or thereabouts, jband and vidur are looking at that.
- Added comments and expanded tabs in nsJSEnvironment.cpp, esp. to EvaluateString. Also changed various nsresult vars to be named rv. Also restored brace/style conformity to nsJSProtocolHandler.cpp.
- Factored CompileFunction from AddScriptEventListener to pave the way for brutal sharing of compiled JS event handlers via JS_CloneFunctionObject.
- Lots of nsCOMPtr uses added. I'm using one for mNameSpaceManager. Hold mSecurityManager as a service explicitly, on the other hand (awaiting scc's fix to allow comptrs for services), and release in nsJSContext's dtor (fixing a leak). These two managers should be moved to the window object -- TODO item below.
- Hold JSRuntimeService along with JSRuntime for live of nsJSEnvironment, fix for shaver.
- Fix window.setTimeout etc. so the filename and line number of the timeout expr is propagated. This meant factoring nsJSUtils.cpp code.
- Fix all content sinks to use the same, and up-to-date JavaScript version parsing (whether for script type or for old language attribute); also fix SplitMimeType clones to strip whitespace.
- With waterson, fix bug in brutal-sharing version of XUL content sink: script src= should not evaluate the inline content of its tag.
1999-10-31 00:43:30 +00:00
|
|
|
result = EvaluateScript(script, mScriptLineNo, mScriptLanguageVersion);
|
1998-11-12 23:55:47 +00:00
|
|
|
FlushText(PR_FALSE);
|
|
|
|
mInScript = PR_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
#define SCRIPT_BUF_SIZE 1024
|
|
|
|
|
|
|
|
// XXX Stolen from nsHTMLContentSink. Needs to be shared.
|
(13163, r=alecf, scc, waterson, others; names available on request)
- Fix most of bug 13163 (see TODO for rest). This entails adding a version-string argument to nsIScriptContext::EvaluateString and passing it around lots of places in content sinks.
- Fix leaks and confusion about mSecurityManager and mNameSpaceManager in nsJSEnvironment.cpp. These still need to move from nsJSContext to nsGlobalWindow or thereabouts, jband and vidur are looking at that.
- Added comments and expanded tabs in nsJSEnvironment.cpp, esp. to EvaluateString. Also changed various nsresult vars to be named rv. Also restored brace/style conformity to nsJSProtocolHandler.cpp.
- Factored CompileFunction from AddScriptEventListener to pave the way for brutal sharing of compiled JS event handlers via JS_CloneFunctionObject.
- Lots of nsCOMPtr uses added. I'm using one for mNameSpaceManager. Hold mSecurityManager as a service explicitly, on the other hand (awaiting scc's fix to allow comptrs for services), and release in nsJSContext's dtor (fixing a leak). These two managers should be moved to the window object -- TODO item below.
- Hold JSRuntimeService along with JSRuntime for live of nsJSEnvironment, fix for shaver.
- Fix window.setTimeout etc. so the filename and line number of the timeout expr is propagated. This meant factoring nsJSUtils.cpp code.
- Fix all content sinks to use the same, and up-to-date JavaScript version parsing (whether for script type or for old language attribute); also fix SplitMimeType clones to strip whitespace.
- With waterson, fix bug in brutal-sharing version of XUL content sink: script src= should not evaluate the inline content of its tag.
1999-10-31 00:43:30 +00:00
|
|
|
// XXXbe share also with nsRDFParserUtils.cpp and nsHTMLContentSink.cpp
|
1998-11-12 23:55:47 +00:00
|
|
|
// Returns PR_TRUE if the language name is a version of JavaScript and
|
|
|
|
// PR_FALSE otherwise
|
|
|
|
static PRBool
|
(13163, r=alecf, scc, waterson, others; names available on request)
- Fix most of bug 13163 (see TODO for rest). This entails adding a version-string argument to nsIScriptContext::EvaluateString and passing it around lots of places in content sinks.
- Fix leaks and confusion about mSecurityManager and mNameSpaceManager in nsJSEnvironment.cpp. These still need to move from nsJSContext to nsGlobalWindow or thereabouts, jband and vidur are looking at that.
- Added comments and expanded tabs in nsJSEnvironment.cpp, esp. to EvaluateString. Also changed various nsresult vars to be named rv. Also restored brace/style conformity to nsJSProtocolHandler.cpp.
- Factored CompileFunction from AddScriptEventListener to pave the way for brutal sharing of compiled JS event handlers via JS_CloneFunctionObject.
- Lots of nsCOMPtr uses added. I'm using one for mNameSpaceManager. Hold mSecurityManager as a service explicitly, on the other hand (awaiting scc's fix to allow comptrs for services), and release in nsJSContext's dtor (fixing a leak). These two managers should be moved to the window object -- TODO item below.
- Hold JSRuntimeService along with JSRuntime for live of nsJSEnvironment, fix for shaver.
- Fix window.setTimeout etc. so the filename and line number of the timeout expr is propagated. This meant factoring nsJSUtils.cpp code.
- Fix all content sinks to use the same, and up-to-date JavaScript version parsing (whether for script type or for old language attribute); also fix SplitMimeType clones to strip whitespace.
- With waterson, fix bug in brutal-sharing version of XUL content sink: script src= should not evaluate the inline content of its tag.
1999-10-31 00:43:30 +00:00
|
|
|
IsJavaScriptLanguage(const nsString& aName, const char* *aVersion)
|
1998-11-12 23:55:47 +00:00
|
|
|
{
|
(13163, r=alecf, scc, waterson, others; names available on request)
- Fix most of bug 13163 (see TODO for rest). This entails adding a version-string argument to nsIScriptContext::EvaluateString and passing it around lots of places in content sinks.
- Fix leaks and confusion about mSecurityManager and mNameSpaceManager in nsJSEnvironment.cpp. These still need to move from nsJSContext to nsGlobalWindow or thereabouts, jband and vidur are looking at that.
- Added comments and expanded tabs in nsJSEnvironment.cpp, esp. to EvaluateString. Also changed various nsresult vars to be named rv. Also restored brace/style conformity to nsJSProtocolHandler.cpp.
- Factored CompileFunction from AddScriptEventListener to pave the way for brutal sharing of compiled JS event handlers via JS_CloneFunctionObject.
- Lots of nsCOMPtr uses added. I'm using one for mNameSpaceManager. Hold mSecurityManager as a service explicitly, on the other hand (awaiting scc's fix to allow comptrs for services), and release in nsJSContext's dtor (fixing a leak). These two managers should be moved to the window object -- TODO item below.
- Hold JSRuntimeService along with JSRuntime for live of nsJSEnvironment, fix for shaver.
- Fix window.setTimeout etc. so the filename and line number of the timeout expr is propagated. This meant factoring nsJSUtils.cpp code.
- Fix all content sinks to use the same, and up-to-date JavaScript version parsing (whether for script type or for old language attribute); also fix SplitMimeType clones to strip whitespace.
- With waterson, fix bug in brutal-sharing version of XUL content sink: script src= should not evaluate the inline content of its tag.
1999-10-31 00:43:30 +00:00
|
|
|
JSVersion version = JSVERSION_UNKNOWN;
|
|
|
|
|
|
|
|
if (aName.EqualsIgnoreCase("JavaScript") ||
|
|
|
|
aName.EqualsIgnoreCase("LiveScript") ||
|
|
|
|
aName.EqualsIgnoreCase("Mocha")) {
|
|
|
|
version = JSVERSION_DEFAULT;
|
|
|
|
}
|
|
|
|
else if (aName.EqualsIgnoreCase("JavaScript1.1")) {
|
|
|
|
version = JSVERSION_1_1;
|
|
|
|
}
|
|
|
|
else if (aName.EqualsIgnoreCase("JavaScript1.2")) {
|
|
|
|
version = JSVERSION_1_2;
|
|
|
|
}
|
|
|
|
else if (aName.EqualsIgnoreCase("JavaScript1.3")) {
|
|
|
|
version = JSVERSION_1_3;
|
|
|
|
}
|
|
|
|
else if (aName.EqualsIgnoreCase("JavaScript1.4")) {
|
|
|
|
version = JSVERSION_1_4;
|
|
|
|
}
|
|
|
|
else if (aName.EqualsIgnoreCase("JavaScript1.5")) {
|
|
|
|
version = JSVERSION_1_5;
|
|
|
|
}
|
|
|
|
if (version == JSVERSION_UNKNOWN)
|
1998-11-12 23:55:47 +00:00
|
|
|
return PR_FALSE;
|
(13163, r=alecf, scc, waterson, others; names available on request)
- Fix most of bug 13163 (see TODO for rest). This entails adding a version-string argument to nsIScriptContext::EvaluateString and passing it around lots of places in content sinks.
- Fix leaks and confusion about mSecurityManager and mNameSpaceManager in nsJSEnvironment.cpp. These still need to move from nsJSContext to nsGlobalWindow or thereabouts, jband and vidur are looking at that.
- Added comments and expanded tabs in nsJSEnvironment.cpp, esp. to EvaluateString. Also changed various nsresult vars to be named rv. Also restored brace/style conformity to nsJSProtocolHandler.cpp.
- Factored CompileFunction from AddScriptEventListener to pave the way for brutal sharing of compiled JS event handlers via JS_CloneFunctionObject.
- Lots of nsCOMPtr uses added. I'm using one for mNameSpaceManager. Hold mSecurityManager as a service explicitly, on the other hand (awaiting scc's fix to allow comptrs for services), and release in nsJSContext's dtor (fixing a leak). These two managers should be moved to the window object -- TODO item below.
- Hold JSRuntimeService along with JSRuntime for live of nsJSEnvironment, fix for shaver.
- Fix window.setTimeout etc. so the filename and line number of the timeout expr is propagated. This meant factoring nsJSUtils.cpp code.
- Fix all content sinks to use the same, and up-to-date JavaScript version parsing (whether for script type or for old language attribute); also fix SplitMimeType clones to strip whitespace.
- With waterson, fix bug in brutal-sharing version of XUL content sink: script src= should not evaluate the inline content of its tag.
1999-10-31 00:43:30 +00:00
|
|
|
*aVersion = JS_VersionToString(version);
|
|
|
|
return PR_TRUE;
|
1998-11-12 23:55:47 +00:00
|
|
|
}
|
|
|
|
|
1999-11-02 06:49:44 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsXMLContentSink::OnUnicharStreamComplete(nsIUnicharStreamLoader* aLoader,
|
|
|
|
nsresult aStatus,
|
1999-11-30 04:50:42 +00:00
|
|
|
PRUint32 stringLen,
|
1999-11-02 06:49:44 +00:00
|
|
|
const PRUnichar* string)
|
1998-12-18 01:36:41 +00:00
|
|
|
{
|
1999-11-02 06:49:44 +00:00
|
|
|
nsresult rv = NS_OK;
|
1999-11-30 04:50:42 +00:00
|
|
|
nsString aData(string, stringLen);
|
1998-12-18 01:36:41 +00:00
|
|
|
|
|
|
|
if (NS_OK == aStatus) {
|
1999-11-02 06:49:44 +00:00
|
|
|
rv = EvaluateScript(aData, 0, mScriptLanguageVersion);
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
1998-12-18 01:36:41 +00:00
|
|
|
}
|
|
|
|
|
1999-11-02 06:49:44 +00:00
|
|
|
rv = ResumeParsing();
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
1998-12-18 01:36:41 +00:00
|
|
|
|
|
|
|
// We added a reference when the loader was created. This
|
|
|
|
// release should destroy it.
|
|
|
|
NS_RELEASE(aLoader);
|
1999-11-02 06:49:44 +00:00
|
|
|
|
|
|
|
return rv;
|
1998-12-18 01:36:41 +00:00
|
|
|
}
|
|
|
|
|
1998-11-12 23:55:47 +00:00
|
|
|
nsresult
|
|
|
|
nsXMLContentSink::ProcessStartSCRIPTTag(const nsIParserNode& aNode)
|
|
|
|
{
|
|
|
|
nsresult rv = NS_OK;
|
(13163, r=alecf, scc, waterson, others; names available on request)
- Fix most of bug 13163 (see TODO for rest). This entails adding a version-string argument to nsIScriptContext::EvaluateString and passing it around lots of places in content sinks.
- Fix leaks and confusion about mSecurityManager and mNameSpaceManager in nsJSEnvironment.cpp. These still need to move from nsJSContext to nsGlobalWindow or thereabouts, jband and vidur are looking at that.
- Added comments and expanded tabs in nsJSEnvironment.cpp, esp. to EvaluateString. Also changed various nsresult vars to be named rv. Also restored brace/style conformity to nsJSProtocolHandler.cpp.
- Factored CompileFunction from AddScriptEventListener to pave the way for brutal sharing of compiled JS event handlers via JS_CloneFunctionObject.
- Lots of nsCOMPtr uses added. I'm using one for mNameSpaceManager. Hold mSecurityManager as a service explicitly, on the other hand (awaiting scc's fix to allow comptrs for services), and release in nsJSContext's dtor (fixing a leak). These two managers should be moved to the window object -- TODO item below.
- Hold JSRuntimeService along with JSRuntime for live of nsJSEnvironment, fix for shaver.
- Fix window.setTimeout etc. so the filename and line number of the timeout expr is propagated. This meant factoring nsJSUtils.cpp code.
- Fix all content sinks to use the same, and up-to-date JavaScript version parsing (whether for script type or for old language attribute); also fix SplitMimeType clones to strip whitespace.
- With waterson, fix bug in brutal-sharing version of XUL content sink: script src= should not evaluate the inline content of its tag.
1999-10-31 00:43:30 +00:00
|
|
|
PRBool isJavaScript = PR_TRUE;
|
|
|
|
const char* jsVersionString = nsnull;
|
1998-11-12 23:55:47 +00:00
|
|
|
PRInt32 i, ac = aNode.GetAttributeCount();
|
|
|
|
|
|
|
|
// Look for SRC attribute and look for a LANGUAGE attribute
|
|
|
|
nsAutoString src;
|
|
|
|
for (i = 0; i < ac; i++) {
|
|
|
|
const nsString& key = aNode.GetKeyAt(i);
|
|
|
|
if (key.EqualsIgnoreCase("src")) {
|
1998-12-18 01:36:41 +00:00
|
|
|
GetAttributeValueAt(aNode, i, src);
|
1998-11-12 23:55:47 +00:00
|
|
|
}
|
|
|
|
else if (key.EqualsIgnoreCase("type")) {
|
|
|
|
nsAutoString type;
|
(13163, r=alecf, scc, waterson, others; names available on request)
- Fix most of bug 13163 (see TODO for rest). This entails adding a version-string argument to nsIScriptContext::EvaluateString and passing it around lots of places in content sinks.
- Fix leaks and confusion about mSecurityManager and mNameSpaceManager in nsJSEnvironment.cpp. These still need to move from nsJSContext to nsGlobalWindow or thereabouts, jband and vidur are looking at that.
- Added comments and expanded tabs in nsJSEnvironment.cpp, esp. to EvaluateString. Also changed various nsresult vars to be named rv. Also restored brace/style conformity to nsJSProtocolHandler.cpp.
- Factored CompileFunction from AddScriptEventListener to pave the way for brutal sharing of compiled JS event handlers via JS_CloneFunctionObject.
- Lots of nsCOMPtr uses added. I'm using one for mNameSpaceManager. Hold mSecurityManager as a service explicitly, on the other hand (awaiting scc's fix to allow comptrs for services), and release in nsJSContext's dtor (fixing a leak). These two managers should be moved to the window object -- TODO item below.
- Hold JSRuntimeService along with JSRuntime for live of nsJSEnvironment, fix for shaver.
- Fix window.setTimeout etc. so the filename and line number of the timeout expr is propagated. This meant factoring nsJSUtils.cpp code.
- Fix all content sinks to use the same, and up-to-date JavaScript version parsing (whether for script type or for old language attribute); also fix SplitMimeType clones to strip whitespace.
- With waterson, fix bug in brutal-sharing version of XUL content sink: script src= should not evaluate the inline content of its tag.
1999-10-31 00:43:30 +00:00
|
|
|
|
1998-11-12 23:55:47 +00:00
|
|
|
GetAttributeValueAt(aNode, i, type);
|
1999-05-26 23:58:06 +00:00
|
|
|
nsAutoString mimeType;
|
|
|
|
nsAutoString params;
|
|
|
|
SplitMimeType(type, mimeType, params);
|
|
|
|
|
|
|
|
isJavaScript = mimeType.EqualsIgnoreCase("text/javascript");
|
(13163, r=alecf, scc, waterson, others; names available on request)
- Fix most of bug 13163 (see TODO for rest). This entails adding a version-string argument to nsIScriptContext::EvaluateString and passing it around lots of places in content sinks.
- Fix leaks and confusion about mSecurityManager and mNameSpaceManager in nsJSEnvironment.cpp. These still need to move from nsJSContext to nsGlobalWindow or thereabouts, jband and vidur are looking at that.
- Added comments and expanded tabs in nsJSEnvironment.cpp, esp. to EvaluateString. Also changed various nsresult vars to be named rv. Also restored brace/style conformity to nsJSProtocolHandler.cpp.
- Factored CompileFunction from AddScriptEventListener to pave the way for brutal sharing of compiled JS event handlers via JS_CloneFunctionObject.
- Lots of nsCOMPtr uses added. I'm using one for mNameSpaceManager. Hold mSecurityManager as a service explicitly, on the other hand (awaiting scc's fix to allow comptrs for services), and release in nsJSContext's dtor (fixing a leak). These two managers should be moved to the window object -- TODO item below.
- Hold JSRuntimeService along with JSRuntime for live of nsJSEnvironment, fix for shaver.
- Fix window.setTimeout etc. so the filename and line number of the timeout expr is propagated. This meant factoring nsJSUtils.cpp code.
- Fix all content sinks to use the same, and up-to-date JavaScript version parsing (whether for script type or for old language attribute); also fix SplitMimeType clones to strip whitespace.
- With waterson, fix bug in brutal-sharing version of XUL content sink: script src= should not evaluate the inline content of its tag.
1999-10-31 00:43:30 +00:00
|
|
|
if (isJavaScript) {
|
|
|
|
JSVersion jsVersion = JSVERSION_DEFAULT;
|
|
|
|
if (params.Find("version=", PR_TRUE) == 0) {
|
|
|
|
if (params.Length() != 11 || params[8] != '1' || params[9] != '.')
|
|
|
|
jsVersion = JSVERSION_UNKNOWN;
|
|
|
|
else switch (params[10]) {
|
|
|
|
case '0': jsVersion = JSVERSION_1_0; break;
|
|
|
|
case '1': jsVersion = JSVERSION_1_1; break;
|
|
|
|
case '2': jsVersion = JSVERSION_1_2; break;
|
|
|
|
case '3': jsVersion = JSVERSION_1_3; break;
|
|
|
|
case '4': jsVersion = JSVERSION_1_4; break;
|
|
|
|
case '5': jsVersion = JSVERSION_1_5; break;
|
|
|
|
default: jsVersion = JSVERSION_UNKNOWN;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
jsVersionString = JS_VersionToString(jsVersion);
|
|
|
|
}
|
1998-11-12 23:55:47 +00:00
|
|
|
}
|
|
|
|
else if (key.EqualsIgnoreCase("language")) {
|
|
|
|
nsAutoString lang;
|
(13163, r=alecf, scc, waterson, others; names available on request)
- Fix most of bug 13163 (see TODO for rest). This entails adding a version-string argument to nsIScriptContext::EvaluateString and passing it around lots of places in content sinks.
- Fix leaks and confusion about mSecurityManager and mNameSpaceManager in nsJSEnvironment.cpp. These still need to move from nsJSContext to nsGlobalWindow or thereabouts, jband and vidur are looking at that.
- Added comments and expanded tabs in nsJSEnvironment.cpp, esp. to EvaluateString. Also changed various nsresult vars to be named rv. Also restored brace/style conformity to nsJSProtocolHandler.cpp.
- Factored CompileFunction from AddScriptEventListener to pave the way for brutal sharing of compiled JS event handlers via JS_CloneFunctionObject.
- Lots of nsCOMPtr uses added. I'm using one for mNameSpaceManager. Hold mSecurityManager as a service explicitly, on the other hand (awaiting scc's fix to allow comptrs for services), and release in nsJSContext's dtor (fixing a leak). These two managers should be moved to the window object -- TODO item below.
- Hold JSRuntimeService along with JSRuntime for live of nsJSEnvironment, fix for shaver.
- Fix window.setTimeout etc. so the filename and line number of the timeout expr is propagated. This meant factoring nsJSUtils.cpp code.
- Fix all content sinks to use the same, and up-to-date JavaScript version parsing (whether for script type or for old language attribute); also fix SplitMimeType clones to strip whitespace.
- With waterson, fix bug in brutal-sharing version of XUL content sink: script src= should not evaluate the inline content of its tag.
1999-10-31 00:43:30 +00:00
|
|
|
|
1998-11-12 23:55:47 +00:00
|
|
|
GetAttributeValueAt(aNode, i, lang);
|
(13163, r=alecf, scc, waterson, others; names available on request)
- Fix most of bug 13163 (see TODO for rest). This entails adding a version-string argument to nsIScriptContext::EvaluateString and passing it around lots of places in content sinks.
- Fix leaks and confusion about mSecurityManager and mNameSpaceManager in nsJSEnvironment.cpp. These still need to move from nsJSContext to nsGlobalWindow or thereabouts, jband and vidur are looking at that.
- Added comments and expanded tabs in nsJSEnvironment.cpp, esp. to EvaluateString. Also changed various nsresult vars to be named rv. Also restored brace/style conformity to nsJSProtocolHandler.cpp.
- Factored CompileFunction from AddScriptEventListener to pave the way for brutal sharing of compiled JS event handlers via JS_CloneFunctionObject.
- Lots of nsCOMPtr uses added. I'm using one for mNameSpaceManager. Hold mSecurityManager as a service explicitly, on the other hand (awaiting scc's fix to allow comptrs for services), and release in nsJSContext's dtor (fixing a leak). These two managers should be moved to the window object -- TODO item below.
- Hold JSRuntimeService along with JSRuntime for live of nsJSEnvironment, fix for shaver.
- Fix window.setTimeout etc. so the filename and line number of the timeout expr is propagated. This meant factoring nsJSUtils.cpp code.
- Fix all content sinks to use the same, and up-to-date JavaScript version parsing (whether for script type or for old language attribute); also fix SplitMimeType clones to strip whitespace.
- With waterson, fix bug in brutal-sharing version of XUL content sink: script src= should not evaluate the inline content of its tag.
1999-10-31 00:43:30 +00:00
|
|
|
isJavaScript = IsJavaScriptLanguage(lang, &jsVersionString);
|
1998-11-12 23:55:47 +00:00
|
|
|
}
|
|
|
|
}
|
(13163, r=alecf, scc, waterson, others; names available on request)
- Fix most of bug 13163 (see TODO for rest). This entails adding a version-string argument to nsIScriptContext::EvaluateString and passing it around lots of places in content sinks.
- Fix leaks and confusion about mSecurityManager and mNameSpaceManager in nsJSEnvironment.cpp. These still need to move from nsJSContext to nsGlobalWindow or thereabouts, jband and vidur are looking at that.
- Added comments and expanded tabs in nsJSEnvironment.cpp, esp. to EvaluateString. Also changed various nsresult vars to be named rv. Also restored brace/style conformity to nsJSProtocolHandler.cpp.
- Factored CompileFunction from AddScriptEventListener to pave the way for brutal sharing of compiled JS event handlers via JS_CloneFunctionObject.
- Lots of nsCOMPtr uses added. I'm using one for mNameSpaceManager. Hold mSecurityManager as a service explicitly, on the other hand (awaiting scc's fix to allow comptrs for services), and release in nsJSContext's dtor (fixing a leak). These two managers should be moved to the window object -- TODO item below.
- Hold JSRuntimeService along with JSRuntime for live of nsJSEnvironment, fix for shaver.
- Fix window.setTimeout etc. so the filename and line number of the timeout expr is propagated. This meant factoring nsJSUtils.cpp code.
- Fix all content sinks to use the same, and up-to-date JavaScript version parsing (whether for script type or for old language attribute); also fix SplitMimeType clones to strip whitespace.
- With waterson, fix bug in brutal-sharing version of XUL content sink: script src= should not evaluate the inline content of its tag.
1999-10-31 00:43:30 +00:00
|
|
|
|
1998-11-12 23:55:47 +00:00
|
|
|
// Don't process scripts that aren't JavaScript
|
|
|
|
if (isJavaScript) {
|
(13163, r=alecf, scc, waterson, others; names available on request)
- Fix most of bug 13163 (see TODO for rest). This entails adding a version-string argument to nsIScriptContext::EvaluateString and passing it around lots of places in content sinks.
- Fix leaks and confusion about mSecurityManager and mNameSpaceManager in nsJSEnvironment.cpp. These still need to move from nsJSContext to nsGlobalWindow or thereabouts, jband and vidur are looking at that.
- Added comments and expanded tabs in nsJSEnvironment.cpp, esp. to EvaluateString. Also changed various nsresult vars to be named rv. Also restored brace/style conformity to nsJSProtocolHandler.cpp.
- Factored CompileFunction from AddScriptEventListener to pave the way for brutal sharing of compiled JS event handlers via JS_CloneFunctionObject.
- Lots of nsCOMPtr uses added. I'm using one for mNameSpaceManager. Hold mSecurityManager as a service explicitly, on the other hand (awaiting scc's fix to allow comptrs for services), and release in nsJSContext's dtor (fixing a leak). These two managers should be moved to the window object -- TODO item below.
- Hold JSRuntimeService along with JSRuntime for live of nsJSEnvironment, fix for shaver.
- Fix window.setTimeout etc. so the filename and line number of the timeout expr is propagated. This meant factoring nsJSUtils.cpp code.
- Fix all content sinks to use the same, and up-to-date JavaScript version parsing (whether for script type or for old language attribute); also fix SplitMimeType clones to strip whitespace.
- With waterson, fix bug in brutal-sharing version of XUL content sink: script src= should not evaluate the inline content of its tag.
1999-10-31 00:43:30 +00:00
|
|
|
mScriptLanguageVersion = jsVersionString;
|
1998-12-18 01:36:41 +00:00
|
|
|
|
|
|
|
// If there is a SRC attribute...
|
|
|
|
if (src.Length() > 0) {
|
|
|
|
// Use the SRC attribute value to load the URL
|
1999-06-23 03:29:44 +00:00
|
|
|
nsIURI* url = nsnull;
|
1998-11-12 23:55:47 +00:00
|
|
|
nsAutoString absURL;
|
1999-11-02 23:34:03 +00:00
|
|
|
// XXX we need to get passed in the nsILoadGroup here!
|
1999-07-01 19:30:20 +00:00
|
|
|
// nsILoadGroup* group = mDocument->GetDocumentLoadGroup();
|
1999-08-11 23:24:59 +00:00
|
|
|
rv = NS_NewURI(&url, src, mDocumentBaseURL);
|
1998-12-16 05:40:20 +00:00
|
|
|
if (NS_OK != rv) {
|
|
|
|
return rv;
|
1998-11-12 23:55:47 +00:00
|
|
|
}
|
1998-12-18 01:36:41 +00:00
|
|
|
|
1999-11-16 05:07:31 +00:00
|
|
|
// Check that this page is allowed to load this URI.
|
|
|
|
NS_WITH_SERVICE(nsIScriptSecurityManager, securityManager,
|
|
|
|
NS_SCRIPTSECURITYMANAGER_PROGID, &rv);
|
|
|
|
if (NS_FAILED(rv))
|
|
|
|
return rv;
|
|
|
|
rv = securityManager->CheckLoadURI(mDocumentBaseURL, url);
|
|
|
|
if (NS_FAILED(rv))
|
|
|
|
return rv;
|
|
|
|
|
1998-12-18 01:36:41 +00:00
|
|
|
nsIUnicharStreamLoader* loader;
|
1999-09-18 06:34:24 +00:00
|
|
|
nsCOMPtr<nsILoadGroup> loadGroup;
|
|
|
|
|
|
|
|
mDocument->GetDocumentLoadGroup(getter_AddRefs(loadGroup));
|
1999-11-17 08:14:52 +00:00
|
|
|
rv = NS_NewUnicharStreamLoader(&loader, url, this, loadGroup);
|
1998-11-12 23:55:47 +00:00
|
|
|
NS_RELEASE(url);
|
1998-12-18 01:36:41 +00:00
|
|
|
if (NS_OK == rv) {
|
|
|
|
rv = NS_ERROR_HTMLPARSER_BLOCK;
|
|
|
|
}
|
1998-11-12 23:55:47 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
// Wait until we get the script content
|
|
|
|
mInScript = PR_TRUE;
|
|
|
|
mConstrainSize = PR_FALSE;
|
|
|
|
mScriptLineNo = (PRUint32)aNode.GetSourceLineNumber();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
1999-05-13 20:27:47 +00:00
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsXMLContentSink::RefreshIfEnabled(nsIViewManager* vm)
|
|
|
|
{
|
|
|
|
if (vm) {
|
|
|
|
nsIContentViewer* contentViewer = nsnull;
|
|
|
|
nsresult rv = mWebShell->GetContentViewer(&contentViewer);
|
|
|
|
if (NS_SUCCEEDED(rv) && (contentViewer != nsnull)) {
|
|
|
|
PRBool enabled;
|
|
|
|
contentViewer->GetEnableRendering(&enabled);
|
|
|
|
if (enabled) {
|
|
|
|
vm->EnableRefresh();
|
|
|
|
}
|
(13163, r=alecf, scc, waterson, others; names available on request)
- Fix most of bug 13163 (see TODO for rest). This entails adding a version-string argument to nsIScriptContext::EvaluateString and passing it around lots of places in content sinks.
- Fix leaks and confusion about mSecurityManager and mNameSpaceManager in nsJSEnvironment.cpp. These still need to move from nsJSContext to nsGlobalWindow or thereabouts, jband and vidur are looking at that.
- Added comments and expanded tabs in nsJSEnvironment.cpp, esp. to EvaluateString. Also changed various nsresult vars to be named rv. Also restored brace/style conformity to nsJSProtocolHandler.cpp.
- Factored CompileFunction from AddScriptEventListener to pave the way for brutal sharing of compiled JS event handlers via JS_CloneFunctionObject.
- Lots of nsCOMPtr uses added. I'm using one for mNameSpaceManager. Hold mSecurityManager as a service explicitly, on the other hand (awaiting scc's fix to allow comptrs for services), and release in nsJSContext's dtor (fixing a leak). These two managers should be moved to the window object -- TODO item below.
- Hold JSRuntimeService along with JSRuntime for live of nsJSEnvironment, fix for shaver.
- Fix window.setTimeout etc. so the filename and line number of the timeout expr is propagated. This meant factoring nsJSUtils.cpp code.
- Fix all content sinks to use the same, and up-to-date JavaScript version parsing (whether for script type or for old language attribute); also fix SplitMimeType clones to strip whitespace.
- With waterson, fix bug in brutal-sharing version of XUL content sink: script src= should not evaluate the inline content of its tag.
1999-10-31 00:43:30 +00:00
|
|
|
NS_RELEASE(contentViewer);
|
1999-05-13 20:27:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
1999-10-05 00:12:21 +00:00
|
|
|
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// XML Element Factory
|
|
|
|
//
|
|
|
|
|
2000-01-19 03:10:45 +00:00
|
|
|
class XMLElementFactoryImpl : public nsIElementFactory
|
1999-10-05 00:12:21 +00:00
|
|
|
{
|
|
|
|
protected:
|
|
|
|
XMLElementFactoryImpl();
|
|
|
|
virtual ~XMLElementFactoryImpl();
|
|
|
|
|
|
|
|
public:
|
|
|
|
friend
|
|
|
|
nsresult
|
2000-01-19 03:10:45 +00:00
|
|
|
NS_NewXMLElementFactory(nsIElementFactory** aResult);
|
1999-10-05 00:12:21 +00:00
|
|
|
|
|
|
|
// nsISupports interface
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
|
2000-01-19 03:10:45 +00:00
|
|
|
// nsIElementFactory interface
|
|
|
|
NS_IMETHOD CreateInstanceByTag(const nsString& aTag, nsIContent** aResult);
|
1999-10-05 00:12:21 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
XMLElementFactoryImpl::XMLElementFactoryImpl()
|
|
|
|
{
|
|
|
|
NS_INIT_REFCNT();
|
|
|
|
}
|
|
|
|
|
|
|
|
XMLElementFactoryImpl::~XMLElementFactoryImpl()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-01-19 03:10:45 +00:00
|
|
|
NS_IMPL_ISUPPORTS(XMLElementFactoryImpl, NS_GET_IID(nsIElementFactory));
|
1999-10-05 00:12:21 +00:00
|
|
|
|
|
|
|
|
|
|
|
nsresult
|
2000-01-19 03:10:45 +00:00
|
|
|
NS_NewXMLElementFactory(nsIElementFactory** aResult)
|
1999-10-05 00:12:21 +00:00
|
|
|
{
|
|
|
|
NS_PRECONDITION(aResult != nsnull, "null ptr");
|
|
|
|
if (! aResult)
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
|
|
|
|
XMLElementFactoryImpl* result = new XMLElementFactoryImpl();
|
|
|
|
if (! result)
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
|
|
|
|
NS_ADDREF(result);
|
|
|
|
*aResult = result;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2000-01-19 03:10:45 +00:00
|
|
|
XMLElementFactoryImpl::CreateInstanceByTag(const nsString& aTag, nsIContent** aResult)
|
1999-10-05 00:12:21 +00:00
|
|
|
{
|
|
|
|
nsCOMPtr<nsIAtom> tag = dont_AddRef(NS_NewAtom(aTag));
|
|
|
|
if (! tag)
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
|
2000-01-19 03:10:45 +00:00
|
|
|
nsCOMPtr<nsIXMLContent> xmlContent;
|
|
|
|
nsresult rv = NS_NewXMLElement(getter_AddRefs(xmlContent), tag);
|
|
|
|
nsCOMPtr<nsIContent> result = do_QueryInterface(xmlContent);
|
|
|
|
*aResult = result;
|
|
|
|
NS_IF_ADDREF(*aResult);
|
|
|
|
return rv;
|
1999-10-05 00:12:21 +00:00
|
|
|
}
|
|
|
|
|
2000-01-19 04:44:10 +00:00
|
|
|
void
|
|
|
|
nsXMLContentSink::GetElementFactory(PRInt32 aNameSpaceID, nsIElementFactory** aResult)
|
|
|
|
{
|
|
|
|
nsresult rv;
|
|
|
|
nsAutoString nameSpace;
|
|
|
|
gNameSpaceManager->GetNameSpaceURI(aNameSpaceID, nameSpace);
|
|
|
|
|
|
|
|
nsCAutoString progID = NS_ELEMENT_FACTORY_PROGID_PREFIX;
|
|
|
|
progID += nameSpace;
|
|
|
|
|
|
|
|
// Retrieve the appropriate factory.
|
|
|
|
NS_WITH_SERVICE(nsIElementFactory, elementFactory, progID, &rv);
|
|
|
|
|
|
|
|
*aResult = elementFactory;
|
|
|
|
NS_IF_ADDREF(*aResult);
|
2000-01-19 19:17:22 +00:00
|
|
|
}
|