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):
|
2000-02-02 22:24:56 +00:00
|
|
|
* Pierre Phaneuf <pp@ludusdesign.com>
|
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"
|
2000-06-17 01:49:19 +00:00
|
|
|
#include "nsIDOMDocument.h"
|
|
|
|
#include "nsIDOMDocumentType.h"
|
|
|
|
#include "nsIDOMDOMImplementation.h"
|
1998-11-11 22:06:16 +00:00
|
|
|
#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"
|
2000-03-11 00:29:47 +00:00
|
|
|
#include "nsIDocShell.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"
|
2000-06-17 01:49:19 +00:00
|
|
|
#include "nsDOMDocumentType.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"
|
2001-02-19 12:55:42 +00:00
|
|
|
#include "nsContentUtils.h"
|
1999-02-18 00:18:50 +00:00
|
|
|
#include "nsLayoutAtoms.h"
|
2001-02-19 12:55:42 +00:00
|
|
|
#include "nsContentCID.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
|
|
|
#include "nsXSLContentSink.h"
|
|
|
|
#include "nsParserCIID.h"
|
2000-09-02 15:34:07 +00:00
|
|
|
#include "nsIDocumentViewer.h"
|
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-12-27 08:24:04 +00:00
|
|
|
static char kXSLType[] = "text/xsl";
|
|
|
|
|
2000-09-02 15:34:07 +00:00
|
|
|
static NS_DEFINE_CID(kNameSpaceManagerCID, NS_NAMESPACEMANAGER_CID);
|
1999-08-28 07:31:08 +00:00
|
|
|
static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID);
|
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
|
|
|
|
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;
|
|
|
|
}
|
2000-09-02 15:34:07 +00:00
|
|
|
return it->QueryInterface(NS_GET_IID(nsIXMLContentSink), (void **)aResult);
|
1998-11-11 22:06:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
2001-02-03 01:16:20 +00:00
|
|
|
mInTitle = PR_FALSE;
|
1999-05-26 23:58:06 +00:00
|
|
|
mStyleSheetCount = 0;
|
|
|
|
mCSSLoader = nsnull;
|
1999-06-28 14:49:29 +00:00
|
|
|
mXSLTransformMediator = nsnull;
|
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);
|
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);
|
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;
|
2000-09-02 15:34:07 +00:00
|
|
|
if (NS_SUCCEEDED(aDoc->QueryInterface(NS_GET_IID(nsIHTMLContentContainer), (void**)&htmlContainer))) {
|
1999-05-26 23:58:06 +00:00
|
|
|
htmlContainer->GetCSSLoader(mCSSLoader);
|
|
|
|
NS_RELEASE(htmlContainer);
|
|
|
|
}
|
|
|
|
|
2000-05-10 13:13:39 +00:00
|
|
|
return aDoc->GetNodeInfoManager(*getter_AddRefs(mNodeInfoManager));
|
1998-11-11 22:06:16 +00:00
|
|
|
}
|
|
|
|
|
1999-06-28 14:49:29 +00:00
|
|
|
NS_IMPL_THREADSAFE_ADDREF(nsXMLContentSink)
|
|
|
|
NS_IMPL_THREADSAFE_RELEASE(nsXMLContentSink)
|
1999-12-07 14:06:36 +00:00
|
|
|
|
|
|
|
NS_INTERFACE_MAP_BEGIN(nsXMLContentSink)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIXMLContentSink)
|
2000-04-13 12:19:50 +00:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIContentSink)
|
1999-12-07 14:06:36 +00:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIObserver)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
|
2000-02-02 23:04:47 +00:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIStreamLoaderObserver)
|
1999-12-07 14:06:36 +00:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2000-10-24 01:03:31 +00:00
|
|
|
void
|
|
|
|
nsXMLContentSink::ScrollToRef()
|
|
|
|
{
|
|
|
|
if (mRef.Length() > 0)
|
|
|
|
{
|
|
|
|
PRInt32 i, ns = mDocument->GetNumberOfShells();
|
|
|
|
for (i = 0; i < ns; i++) {
|
|
|
|
nsCOMPtr<nsIPresShell> shell(dont_AddRef(mDocument->GetShellAt(i)));
|
|
|
|
if (shell) {
|
|
|
|
shell->FlushPendingNotifications();
|
|
|
|
// Scroll to the anchor
|
|
|
|
shell->GoToAnchor(mRef);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
(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));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-09-02 15:34:07 +00:00
|
|
|
mDocument->SetRootContent(mDocElement);
|
|
|
|
|
2000-11-27 23:23:28 +00:00
|
|
|
nsresult rv = NS_OK;
|
1999-06-28 14:49:29 +00:00
|
|
|
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)) {
|
2000-09-02 15:34:07 +00:00
|
|
|
StartLayout();
|
2000-10-24 01:03:31 +00:00
|
|
|
ScrollToRef();
|
2000-09-02 15:34:07 +00:00
|
|
|
mDocument->EndLoad();
|
1998-11-11 22:06:16 +00:00
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
1999-06-28 14:49:29 +00:00
|
|
|
// 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)
|
|
|
|
{
|
|
|
|
nsresult rv = NS_OK;
|
2000-09-02 15:34:07 +00:00
|
|
|
nsAutoString topic(aTopic);
|
1999-06-28 14:49:29 +00:00
|
|
|
|
2000-09-02 15:34:07 +00:00
|
|
|
if (topic.Equals(NS_LITERAL_STRING("xslt-done"))) {
|
|
|
|
nsCOMPtr<nsIContent> content;
|
1999-06-28 14:49:29 +00:00
|
|
|
|
2000-09-02 15:34:07 +00:00
|
|
|
// Set the output content model on the document
|
|
|
|
content = do_QueryInterface(aSubject, &rv);
|
|
|
|
if (NS_SUCCEEDED(rv)) {
|
|
|
|
nsCOMPtr<nsIDOMDocument> resultDOMDoc;
|
|
|
|
mXSLTransformMediator->GetResultDocument(getter_AddRefs(resultDOMDoc));
|
|
|
|
nsCOMPtr<nsIDocument> resultDoc = do_QueryInterface(resultDOMDoc);
|
|
|
|
|
2000-09-16 20:53:08 +00:00
|
|
|
nsCOMPtr<nsIDocument> sourceDoc = mDocument;
|
2000-09-02 15:34:07 +00:00
|
|
|
NS_RELEASE(mDocument);
|
|
|
|
|
|
|
|
mDocument = resultDoc;
|
|
|
|
NS_ADDREF(mDocument);
|
|
|
|
mDocument->SetRootContent(content);
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(mWebShell));
|
|
|
|
nsCOMPtr<nsIContentViewer> contentViewer;
|
|
|
|
rv = docShell->GetContentViewer(getter_AddRefs(contentViewer));
|
|
|
|
if (NS_SUCCEEDED(rv) && (contentViewer != nsnull)) {
|
|
|
|
contentViewer->SetDOMDocument(resultDOMDoc);
|
|
|
|
}
|
1999-06-28 14:49:29 +00:00
|
|
|
|
2000-09-02 15:34:07 +00:00
|
|
|
// Reset the observer on the transform mediator
|
|
|
|
mXSLTransformMediator->SetTransformObserver(nsnull);
|
2000-09-16 20:53:08 +00:00
|
|
|
|
|
|
|
// Start the layout process
|
|
|
|
StartLayout();
|
|
|
|
sourceDoc->EndLoad();
|
2000-09-02 15:34:07 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Transform failed
|
|
|
|
nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(mWebShell));
|
|
|
|
nsCOMPtr<nsIContentViewer> contentViewer;
|
|
|
|
rv = docShell->GetContentViewer(getter_AddRefs(contentViewer));
|
|
|
|
if (NS_SUCCEEDED(rv) && (contentViewer != nsnull)) {
|
|
|
|
nsCOMPtr<nsIDocumentViewer> documentViewer;
|
|
|
|
documentViewer->SetTransformMediator(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
|
|
|
|
2000-09-02 15:34:07 +00:00
|
|
|
mXSLTransformMediator = nsnull;
|
|
|
|
mDocument->SetRootContent(mDocElement);
|
|
|
|
|
2000-09-16 20:53:08 +00:00
|
|
|
// Start the layout process
|
|
|
|
StartLayout();
|
|
|
|
mDocument->EndLoad();
|
|
|
|
}
|
2000-09-02 15:34:07 +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()
|
|
|
|
{
|
|
|
|
nsresult rv = NS_OK;
|
|
|
|
|
2000-09-02 15:34:07 +00:00
|
|
|
nsCOMPtr<nsIDOMDocument> currentDOMDoc(do_QueryInterface(mDocument));
|
|
|
|
mXSLTransformMediator->SetSourceContentModel(currentDOMDoc);
|
|
|
|
|
|
|
|
// Create the result document
|
|
|
|
nsCOMPtr<nsIDOMDocument> resultDOMDoc;
|
|
|
|
|
|
|
|
nsCOMPtr<nsIURI> url;
|
|
|
|
mDocument->GetBaseURL(*getter_AddRefs(url));
|
|
|
|
|
|
|
|
nsAutoString emptyStr;
|
|
|
|
rv = NS_NewDOMDocument(getter_AddRefs(resultDOMDoc), emptyStr, emptyStr, nsnull, url);
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
|
|
|
|
nsCOMPtr<nsIXMLDocument> resultXMLDoc(do_QueryInterface(resultDOMDoc));
|
|
|
|
resultXMLDoc->SetDefaultStylesheets(url);
|
|
|
|
|
|
|
|
mXSLTransformMediator->SetResultDocument(resultDOMDoc);
|
|
|
|
mXSLTransformMediator->SetTransformObserver(this);
|
1999-06-28 14:49:29 +00:00
|
|
|
|
|
|
|
return 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
|
|
|
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.
|
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
|
2000-09-02 15:34:07 +00:00
|
|
|
nsAutoString name;
|
1998-11-11 22:06:16 +00:00
|
|
|
PRInt32 ac = aNode.GetAttributeCount();
|
|
|
|
for (PRInt32 i = 0; i < ac; i++) {
|
|
|
|
// Get upper-cased key
|
2000-12-12 21:58:13 +00:00
|
|
|
const nsAReadableString& key = aNode.GetKeyAt(i);
|
2000-09-02 15:34:07 +00:00
|
|
|
name.Assign(key);
|
1998-11-11 22:06:16 +00:00
|
|
|
|
2000-06-23 00:21:32 +00:00
|
|
|
nsCOMPtr<nsIAtom> nameSpacePrefix(dont_AddRef(CutNameSpacePrefix(name)));
|
|
|
|
nsCOMPtr<nsIAtom> nameAtom(dont_AddRef(NS_NewAtom(name)));
|
|
|
|
PRInt32 nameSpaceID;
|
2000-09-02 15:34:07 +00:00
|
|
|
|
2000-06-23 00:21:32 +00:00
|
|
|
if (nameSpacePrefix) {
|
|
|
|
nameSpaceID = GetNameSpaceId(nameSpacePrefix);
|
|
|
|
} else {
|
|
|
|
if (nameAtom.get() == nsLayoutAtoms::xmlnsNameSpace)
|
|
|
|
nameSpaceID = kNameSpaceID_XMLNS;
|
|
|
|
else
|
|
|
|
nameSpaceID = kNameSpaceID_None;
|
1999-06-10 05:33:47 +00:00
|
|
|
}
|
2000-06-23 00:21:32 +00:00
|
|
|
|
|
|
|
if (kNameSpaceID_Unknown == nameSpaceID) {
|
|
|
|
nameSpaceID = kNameSpaceID_None;
|
|
|
|
nameAtom = dont_AddRef(NS_NewAtom(key));
|
|
|
|
nameSpacePrefix = nsnull;
|
|
|
|
} else if ((kNameSpaceID_XMLNS == nameSpaceID) && aIsHTML) {
|
2000-04-15 21:18:29 +00:00
|
|
|
name.InsertWithConversion("xmlns:", 0);
|
2000-06-23 00:21:32 +00:00
|
|
|
nameAtom = dont_AddRef(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
|
|
|
|
2000-06-23 00:21:32 +00:00
|
|
|
nsCOMPtr<nsINodeInfo> ni;
|
|
|
|
mNodeInfoManager->GetNodeInfo(nameAtom, nameSpacePrefix, nameSpaceID,
|
|
|
|
*getter_AddRefs(ni));
|
|
|
|
NS_ENSURE_TRUE(ni, NS_ERROR_FAILURE);
|
1998-11-11 22:06:16 +00:00
|
|
|
|
2000-06-23 00:21:32 +00:00
|
|
|
// Add attribute to content
|
2000-09-02 15:34:07 +00:00
|
|
|
aContent->SetAttribute(ni, aNode.GetValueAt(i), PR_FALSE);
|
1998-11-11 22:06:16 +00:00
|
|
|
}
|
2000-05-09 07:30:21 +00:00
|
|
|
|
|
|
|
// Give autoloading links a chance to fire
|
|
|
|
if (mWebShell) {
|
|
|
|
nsCOMPtr<nsIXMLContent> xmlcontent(do_QueryInterface(aContent));
|
|
|
|
if (xmlcontent) {
|
|
|
|
nsresult rv = xmlcontent->MaybeTriggerAutoLink(mWebShell);
|
|
|
|
if (rv == NS_XML_AUTOLINK_REPLACE ||
|
|
|
|
rv == NS_XML_AUTOLINK_UNDEFINED) {
|
|
|
|
// If we do not terminate the parse, we just keep generating link trigger
|
|
|
|
// events. We want to parse only up to the first replace link, and stop.
|
|
|
|
mParser->Terminate();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
2000-09-02 15:34:07 +00:00
|
|
|
nsAutoString k, prefix;
|
1998-11-11 22:06:16 +00:00
|
|
|
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++) {
|
2000-12-12 21:58:13 +00:00
|
|
|
const nsAReadableString& key = aNode.GetKeyAt(i);
|
2000-09-02 15:34:07 +00:00
|
|
|
k.Assign(key);
|
1998-12-11 02:53:49 +00:00
|
|
|
// 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
|
|
|
// Open a local namespace
|
|
|
|
nsIAtom* prefixAtom = ((0 < prefix.Length()) ? NS_NewAtom(prefix) : nsnull);
|
|
|
|
nsINameSpace* child = nsnull;
|
2000-09-02 15:34:07 +00:00
|
|
|
nameSpace->CreateChildNameSpace(prefixAtom, aNode.GetValueAt(i), child);
|
1998-12-11 02:53:49 +00:00
|
|
|
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-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;
|
|
|
|
|
2000-04-15 21:18:29 +00:00
|
|
|
tag.Assign(aNode.GetText());
|
2000-01-19 04:44:10 +00:00
|
|
|
nameSpacePrefix = getter_AddRefs(CutNameSpacePrefix(tag));
|
2001-02-03 01:16:20 +00:00
|
|
|
nsCOMPtr<nsIAtom> tagAtom(dont_AddRef(NS_NewAtom(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
|
|
|
|
2000-08-31 00:36:31 +00:00
|
|
|
PRInt32 nameSpaceID = GetNameSpaceId(nameSpacePrefix);
|
2000-05-10 13:13:39 +00:00
|
|
|
|
|
|
|
nsCOMPtr<nsINodeInfo> nodeInfo;
|
|
|
|
|
|
|
|
mNodeInfoManager->GetNodeInfo(tagAtom, nameSpacePrefix, nameSpaceID,
|
|
|
|
*getter_AddRefs(nodeInfo));
|
|
|
|
|
1998-12-11 02:53:49 +00:00
|
|
|
isHTML = IsHTMLNameSpace(nameSpaceID);
|
1998-11-11 22:06:16 +00:00
|
|
|
|
|
|
|
if (isHTML) {
|
2001-02-03 01:16:20 +00:00
|
|
|
if (tagAtom.get() == nsHTMLAtoms::script) {
|
1998-11-12 23:55:47 +00:00
|
|
|
result = ProcessStartSCRIPTTag(aNode);
|
2001-02-03 01:16:20 +00:00
|
|
|
} else if (tagAtom.get() == nsHTMLAtoms::title) {
|
|
|
|
if (mTitleText.IsEmpty())
|
|
|
|
mInTitle = PR_TRUE; // The first title wins
|
1998-11-12 23:55:47 +00:00
|
|
|
}
|
2000-09-02 15:34:07 +00:00
|
|
|
|
2000-01-19 04:44:10 +00:00
|
|
|
nsCOMPtr<nsIHTMLContent> htmlContent;
|
2000-05-10 13:13:39 +00:00
|
|
|
result = NS_CreateHTMLElement(getter_AddRefs(htmlContent), nodeInfo);
|
2000-01-19 04:44:10 +00:00
|
|
|
content = do_QueryInterface(htmlContent);
|
2001-02-03 01:16:20 +00:00
|
|
|
|
|
|
|
if (tagAtom.get() == nsHTMLAtoms::textarea) {
|
|
|
|
mTextAreaElement = 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).
|
2000-09-13 23:57:52 +00:00
|
|
|
// This is done based off a contractid/namespace scheme.
|
2000-01-19 04:44:10 +00:00
|
|
|
nsCOMPtr<nsIElementFactory> elementFactory;
|
2000-05-10 13:13:39 +00:00
|
|
|
|
|
|
|
// This should *not* be done for every node, only when we find
|
|
|
|
// a new namespace!!! -- jst
|
2000-01-19 04:44:10 +00:00
|
|
|
GetElementFactory(nameSpaceID, getter_AddRefs(elementFactory));
|
|
|
|
if (elementFactory) {
|
|
|
|
// Create the content element using the element factory.
|
2000-05-10 13:13:39 +00:00
|
|
|
elementFactory->CreateInstanceByTag(nodeInfo, getter_AddRefs(content));
|
2000-01-19 04:44:10 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
nsCOMPtr<nsIXMLContent> xmlContent;
|
2000-05-10 13:13:39 +00:00
|
|
|
result = NS_NewXMLElement(getter_AddRefs(xmlContent), nodeInfo);
|
2000-09-02 15:34:07 +00:00
|
|
|
|
2000-01-19 04:44:10 +00:00
|
|
|
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) {
|
2000-03-21 03:25:16 +00:00
|
|
|
PRInt32 id;
|
|
|
|
mDocument->GetAndIncrementContentID(&id);
|
|
|
|
content->SetContentID(id);
|
2000-05-19 04:48:43 +00:00
|
|
|
content->SetDocument(mDocument, PR_FALSE, PR_TRUE);
|
1998-11-11 22:06:16 +00:00
|
|
|
|
|
|
|
// 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.
|
2000-09-02 15:34:07 +00:00
|
|
|
if (!mXSLTransformMediator)
|
|
|
|
mDocument->SetRootContent(mDocElement);
|
1998-11-11 22:06:16 +00:00
|
|
|
}
|
1998-11-12 23:03:35 +00:00
|
|
|
else {
|
2000-01-21 01:32:32 +00:00
|
|
|
nsCOMPtr<nsIContent> parent = getter_AddRefs(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
|
|
|
}
|
2000-08-30 00:35:43 +00:00
|
|
|
|
|
|
|
// Set the ID attribute atom on the node info object for this node
|
|
|
|
nsCOMPtr<nsIAtom> IDAttr;
|
|
|
|
result = aNode.GetIDAttributeAtom(getter_AddRefs(IDAttr));
|
|
|
|
if (IDAttr && NS_SUCCEEDED(result))
|
|
|
|
result = nodeInfo->SetIDAttributeAtom(IDAttr);
|
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;
|
2000-02-23 22:16:03 +00:00
|
|
|
nsCOMPtr<nsIAtom> nameSpacePrefix;
|
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
|
|
|
|
2000-04-15 21:18:29 +00:00
|
|
|
tag.Assign(aNode.GetText());
|
2000-05-10 13:13:39 +00:00
|
|
|
|
2000-02-23 22:16:03 +00:00
|
|
|
nameSpacePrefix = getter_AddRefs(CutNameSpacePrefix(tag));
|
2000-08-31 00:36:31 +00:00
|
|
|
PRInt32 nameSpaceID = GetNameSpaceId(nameSpacePrefix);
|
1998-12-11 02:53:49 +00:00
|
|
|
isHTML = IsHTMLNameSpace(nameSpaceID);
|
1998-11-12 23:55:47 +00:00
|
|
|
|
2001-01-04 00:30:11 +00:00
|
|
|
FlushText();
|
1998-11-11 22:06:16 +00:00
|
|
|
|
1998-11-16 06:16:17 +00:00
|
|
|
if (isHTML) {
|
2001-02-03 01:16:20 +00:00
|
|
|
nsCOMPtr<nsIAtom> tagAtom(dont_AddRef(NS_NewAtom(tag)));
|
|
|
|
|
|
|
|
if (tagAtom.get() == nsHTMLAtoms::script) {
|
1998-11-16 06:16:17 +00:00
|
|
|
result = ProcessEndSCRIPTTag(aNode);
|
2001-02-03 01:16:20 +00:00
|
|
|
} else if (tagAtom.get() == nsHTMLAtoms::title) {
|
|
|
|
if (mInTitle) { // The first title wins
|
|
|
|
nsCOMPtr<nsIXMLDocument> xmlDoc(do_QueryInterface(mDocument));
|
|
|
|
if (xmlDoc) {
|
|
|
|
mTitleText.CompressWhitespace();
|
|
|
|
xmlDoc->SetTitle(mTitleText.GetUnicode());
|
|
|
|
}
|
|
|
|
mInTitle = PR_FALSE;
|
|
|
|
}
|
|
|
|
} else if (tagAtom.get() == nsHTMLAtoms::textarea) {
|
|
|
|
if (mTextAreaElement) {
|
|
|
|
mTextAreaElement->SetDefaultValue(mTextareaText);
|
|
|
|
mTextAreaElement = nsnull;
|
|
|
|
mTextareaText.Truncate();
|
|
|
|
}
|
1998-11-12 23:55:47 +00:00
|
|
|
}
|
1998-11-11 22:06:16 +00:00
|
|
|
}
|
1998-11-16 06:16:17 +00:00
|
|
|
|
2000-01-21 01:32:32 +00:00
|
|
|
nsCOMPtr<nsIContent> content;
|
1998-11-16 06:16:17 +00:00
|
|
|
if (popContent) {
|
2000-01-21 01:32:32 +00:00
|
|
|
content = getter_AddRefs(PopContent());
|
|
|
|
if (content) {
|
2000-01-21 02:30:02 +00:00
|
|
|
if (mDocElement == content.get()) {
|
1998-11-16 06:16:17 +00:00
|
|
|
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();
|
2000-01-21 01:32:32 +00:00
|
|
|
if (content) {
|
|
|
|
nsCOMPtr<nsIXMLContent> xmlContent = do_QueryInterface(content);
|
|
|
|
if (xmlContent) {
|
1999-01-12 16:37:24 +00:00
|
|
|
xmlContent->SetContainingNameSpace(nameSpace);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
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:
|
2001-01-04 00:30:11 +00:00
|
|
|
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
|
|
|
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
|
|
|
{
|
2000-03-30 01:41:48 +00:00
|
|
|
return NS_OK;
|
1999-03-11 05:29:36 +00:00
|
|
|
}
|
|
|
|
|
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
|
2000-10-28 22:17:53 +00:00
|
|
|
printf("nsXMLContentSink::AddXMLDecl\n");
|
1998-11-11 22:06:16 +00:00
|
|
|
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
|
|
|
|
2001-01-25 14:19:38 +00:00
|
|
|
if ((eXMLContentSinkState_InProlog == mState) ||
|
|
|
|
(eXMLContentSinkState_InEpilog == mState)) {
|
|
|
|
nsCOMPtr<nsIDOMDocument> domDoc( do_QueryInterface(mDocument) );
|
|
|
|
nsCOMPtr<nsIDOMNode> trash;
|
|
|
|
nsCOMPtr<nsIDOMNode> child( do_QueryInterface(aContent) );
|
|
|
|
NS_ASSERTION(child, "not a dom node");
|
|
|
|
domDoc->AppendChild(child, getter_AddRefs(trash));
|
1998-11-11 22:06:16 +00:00
|
|
|
}
|
|
|
|
else {
|
2000-01-21 01:32:32 +00:00
|
|
|
nsCOMPtr<nsIContent> parent = getter_AddRefs(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();
|
|
|
|
|
1999-01-14 23:14:02 +00:00
|
|
|
nsIContent *comment;
|
1998-11-11 22:06:16 +00:00
|
|
|
nsIDOMComment *domComment;
|
|
|
|
nsresult result = NS_OK;
|
|
|
|
|
|
|
|
result = NS_NewCommentNode(&comment);
|
|
|
|
if (NS_OK == result) {
|
2000-09-02 15:34:07 +00:00
|
|
|
result = comment->QueryInterface(NS_GET_IID(nsIDOMComment), (void **)&domComment);
|
1998-11-11 22:06:16 +00:00
|
|
|
if (NS_OK == result) {
|
2001-01-04 00:30:11 +00:00
|
|
|
domComment->AppendData(aNode.GetText());
|
1998-11-11 22:06:16 +00:00
|
|
|
NS_RELEASE(domComment);
|
|
|
|
|
2000-05-19 04:48:43 +00:00
|
|
|
comment->SetDocument(mDocument, PR_FALSE, PR_TRUE);
|
1998-11-11 22:06:16 +00:00
|
|
|
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();
|
|
|
|
|
|
|
|
nsIContent *cdata;
|
|
|
|
nsIDOMCDATASection *domCDATA;
|
|
|
|
nsresult result = NS_OK;
|
|
|
|
|
2001-01-04 00:30:11 +00:00
|
|
|
const nsAReadableString& text = aNode.GetText();
|
|
|
|
if (mInScript) {
|
|
|
|
mScriptText.Append(text);
|
|
|
|
}
|
1999-03-31 20:49:25 +00:00
|
|
|
result = NS_NewXMLCDATASection(&cdata);
|
|
|
|
if (NS_OK == result) {
|
2000-09-02 15:34:07 +00:00
|
|
|
result = cdata->QueryInterface(NS_GET_IID(nsIDOMCDATASection), (void **)&domCDATA);
|
1999-03-31 20:49:25 +00:00
|
|
|
if (NS_OK == result) {
|
|
|
|
domCDATA->AppendData(text);
|
|
|
|
NS_RELEASE(domCDATA);
|
|
|
|
|
2000-05-19 04:48:43 +00:00
|
|
|
cdata->SetDocument(mDocument, PR_FALSE, PR_TRUE);
|
1999-03-31 20:49:25 +00:00
|
|
|
result = AddContentAsLeaf(cdata);
|
|
|
|
}
|
|
|
|
NS_RELEASE(cdata);
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2000-03-28 00:18:13 +00:00
|
|
|
// This method starts at aOffSet in aStr and tries to find aChar. It keeps
|
|
|
|
// skipping whitespace till it finds aChar or some other non-whitespace character. If
|
|
|
|
// it finds aChar, it returns aChar's offset. If it finds some other non-whitespace character
|
|
|
|
// or runs into the end of the string, it returns -1.
|
|
|
|
static PRInt32
|
|
|
|
FindWhileSkippingWhitespace(nsString& aStr, PRUnichar aChar, PRInt32 aOffset)
|
1998-11-11 22:06:16 +00:00
|
|
|
{
|
2000-03-28 00:18:13 +00:00
|
|
|
PRInt32 i = aOffset;
|
|
|
|
PRUnichar ch = aStr.CharAt(i);
|
|
|
|
PRInt32 index = -1;
|
1998-11-11 22:06:16 +00:00
|
|
|
|
2000-03-28 00:18:13 +00:00
|
|
|
while (ch == '\n' || ch == '\t' || ch == '\r') {
|
|
|
|
ch = aStr.CharAt(++i);
|
|
|
|
}
|
1998-11-11 22:06:16 +00:00
|
|
|
|
2000-03-28 00:18:13 +00:00
|
|
|
if (ch == aChar)
|
|
|
|
index = i;
|
(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
|
|
|
|
2000-03-28 00:18:13 +00:00
|
|
|
return index;
|
|
|
|
}
|
1998-11-11 22:06:16 +00:00
|
|
|
|
2000-03-28 00:18:13 +00:00
|
|
|
static nsresult
|
|
|
|
GetQuotedAttributeValue(nsString& aSource,
|
|
|
|
const nsString& aAttribute,
|
|
|
|
nsString& aValue)
|
|
|
|
{
|
|
|
|
PRInt32 startOfAttribute = 0; // Index into aSource where the attribute name starts
|
|
|
|
PRInt32 startOfValue = 0; // Index into aSource where the attribute value starts
|
|
|
|
PRInt32 posnOfValueDelimeter = 0;
|
|
|
|
nsresult result = NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
// While there are more characters to look at
|
|
|
|
while (startOfAttribute != -1) {
|
|
|
|
// Find the attribute starting at offset
|
|
|
|
startOfAttribute = aSource.Find(aAttribute, PR_FALSE, startOfAttribute);
|
|
|
|
// If attribute found
|
|
|
|
if (startOfAttribute != -1) {
|
2000-09-02 15:34:07 +00:00
|
|
|
// Find the '=' character while skipping whitespace
|
2000-03-28 00:18:13 +00:00
|
|
|
startOfValue = FindWhileSkippingWhitespace(aSource, '=', startOfAttribute + aAttribute.Length());
|
|
|
|
// If '=' found
|
2000-09-02 15:34:07 +00:00
|
|
|
if (startOfValue != -1) {
|
2000-03-28 00:18:13 +00:00
|
|
|
PRUnichar delimeter = kQuote;
|
|
|
|
// Find the quote or apostrophe while skipping whitespace
|
|
|
|
posnOfValueDelimeter = FindWhileSkippingWhitespace(aSource, kQuote, startOfValue + 1);
|
|
|
|
if (posnOfValueDelimeter == -1) {
|
|
|
|
posnOfValueDelimeter = FindWhileSkippingWhitespace(aSource, kApostrophe, startOfValue + 1);
|
|
|
|
delimeter = kApostrophe;
|
2000-09-02 15:34:07 +00:00
|
|
|
}
|
2000-03-28 00:18:13 +00:00
|
|
|
// If quote or apostrophe found
|
|
|
|
if (posnOfValueDelimeter != -1) {
|
|
|
|
startOfValue = posnOfValueDelimeter + 1;
|
|
|
|
// Find the ending quote or apostrophe
|
|
|
|
posnOfValueDelimeter = aSource.FindChar(delimeter, PR_FALSE, startOfValue);
|
|
|
|
// If found
|
|
|
|
if (posnOfValueDelimeter != -1) {
|
2000-09-02 15:34:07 +00:00
|
|
|
// Set the value of the attibute and exit the loop
|
2000-03-28 00:18:13 +00:00
|
|
|
// The attribute value starts at startOfValue and ends at (posnOfValueDelimeter - 1)
|
|
|
|
aSource.Mid(aValue, startOfValue, posnOfValueDelimeter - startOfValue);
|
|
|
|
result = NS_OK;
|
|
|
|
break;
|
2000-09-02 15:34:07 +00:00
|
|
|
}
|
2000-03-28 00:18:13 +00:00
|
|
|
else {
|
|
|
|
// Try to find the attribute in the remainder of the string
|
|
|
|
startOfAttribute++;
|
|
|
|
continue;
|
|
|
|
} // Endif found
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// Try to find the attribute in the remainder of the string
|
|
|
|
startOfAttribute++;
|
|
|
|
continue;
|
|
|
|
} // Endif quote or apostrophe found
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// Try to find the attribute in the remainder of the string
|
|
|
|
startOfAttribute++;
|
|
|
|
continue;
|
|
|
|
} // Endif '=' found
|
|
|
|
} // Endif attribute found
|
|
|
|
} // End while
|
|
|
|
|
1998-11-11 22:06:16 +00:00
|
|
|
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
|
|
|
|
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,
|
2000-09-04 05:55:00 +00:00
|
|
|
const nsAReadableString& aHref)
|
1998-12-27 08:24:04 +00:00
|
|
|
{
|
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
|
|
|
|
|
|
|
// Create a transform mediator
|
2000-09-02 15:34:07 +00:00
|
|
|
rv = NS_NewTransformMediator(getter_AddRefs(mXSLTransformMediator), aType);
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
// No XSLT processor available, continue normal document loading
|
|
|
|
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
|
|
|
|
2001-02-19 12:55:42 +00:00
|
|
|
static NS_DEFINE_CID(kCParserCID, NS_PARSER_IID);
|
|
|
|
|
|
|
|
// Create the XML parser
|
|
|
|
nsCOMPtr<nsIParser> parser(do_CreateInstance(kCParserCID, &rv));
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
|
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);
|
|
|
|
|
2000-09-02 15:34:07 +00:00
|
|
|
// The document viewer owns the transform mediator.
|
|
|
|
nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(mWebShell));
|
|
|
|
nsCOMPtr<nsIContentViewer> contentViewer;
|
|
|
|
rv = docShell->GetContentViewer(getter_AddRefs(contentViewer));
|
|
|
|
if (NS_SUCCEEDED(rv) && (contentViewer != nsnull)) {
|
|
|
|
nsCOMPtr<nsIDocumentViewer> documentViewer = do_QueryInterface(contentViewer);
|
|
|
|
documentViewer->SetTransformMediator(mXSLTransformMediator);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Create the XSL stylesheet document
|
|
|
|
nsCOMPtr<nsIDOMDocument> styleDOMDoc;
|
|
|
|
nsAutoString emptyStr;
|
|
|
|
emptyStr.Truncate();
|
|
|
|
rv = NS_NewDOMDocument(getter_AddRefs(styleDOMDoc), emptyStr, emptyStr, nsnull, aUrl);
|
1999-08-28 07:31:08 +00:00
|
|
|
if (NS_FAILED(rv)) return rv;
|
2000-09-02 15:34:07 +00:00
|
|
|
nsCOMPtr<nsIDocument> styleDoc(do_QueryInterface(styleDOMDoc));
|
1999-08-28 07:31:08 +00:00
|
|
|
|
|
|
|
// Create the XSL content sink
|
|
|
|
nsCOMPtr<nsIXMLContentSink> sink;
|
2000-09-02 15:34:07 +00:00
|
|
|
rv = NS_NewXSLContentSink(getter_AddRefs(sink), mXSLTransformMediator, styleDoc, 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);
|
2000-05-01 06:58:53 +00:00
|
|
|
nsAutoString utf8(NS_ConvertASCIItoUCS2("UTF-8"));
|
2000-09-02 15:34:07 +00:00
|
|
|
styleDoc->SetDocumentCharacterSet(utf8);
|
1999-08-28 07:31:08 +00:00
|
|
|
parser->SetDocumentCharset(utf8, kCharsetFromDocTypeDefault);
|
|
|
|
parser->Parse(aUrl);
|
|
|
|
|
|
|
|
// Set the parser as the stream listener and start the URL load
|
|
|
|
nsCOMPtr<nsIStreamListener> sl;
|
2000-09-02 15:34:07 +00:00
|
|
|
rv = parser->QueryInterface(NS_GET_IID(nsIStreamListener), (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
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
2000-09-12 01:51:02 +00:00
|
|
|
nsCOMPtr<nsIContent> node;
|
1999-03-31 20:49:25 +00:00
|
|
|
|
|
|
|
FlushText();
|
1998-11-11 22:06:16 +00:00
|
|
|
|
2000-04-15 21:18:29 +00:00
|
|
|
text.Assign(aNode.GetText());
|
1999-03-31 20:49:25 +00:00
|
|
|
ParseProcessingInstruction(text, target, data);
|
2000-09-12 01:51:02 +00:00
|
|
|
result = NS_NewXMLProcessingInstruction(getter_AddRefs(node), target, data);
|
1999-03-31 20:49:25 +00:00
|
|
|
if (NS_OK == result) {
|
2000-05-19 04:48:43 +00:00
|
|
|
node->SetDocument(mDocument, PR_FALSE, PR_TRUE);
|
1999-03-31 20:49:25 +00:00
|
|
|
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...
|
2000-04-15 21:18:29 +00:00
|
|
|
if (target.EqualsWithConversion(kStyleSheetPI)) {
|
|
|
|
result = GetQuotedAttributeValue(text, NS_ConvertASCIItoUCS2("href"), href);
|
1999-03-31 20:49:25 +00:00
|
|
|
// 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
|
|
|
}
|
2000-04-15 21:18:29 +00:00
|
|
|
result = GetQuotedAttributeValue(text, NS_ConvertASCIItoUCS2("type"), type);
|
2000-03-28 00:18:13 +00:00
|
|
|
if (NS_FAILED(result)) {
|
2000-04-15 21:18:29 +00:00
|
|
|
type.AssignWithConversion("text/css"); // Default the type attribute to the mime type for CSS
|
1998-11-11 22:06:16 +00:00
|
|
|
}
|
2000-04-15 21:18:29 +00:00
|
|
|
result = GetQuotedAttributeValue(text, NS_ConvertASCIItoUCS2("title"), title);
|
2000-03-28 00:18:13 +00:00
|
|
|
if (NS_SUCCEEDED(result)) {
|
|
|
|
title.CompressWhitespace();
|
1998-11-11 22:06:16 +00:00
|
|
|
}
|
2000-04-15 21:18:29 +00:00
|
|
|
result = GetQuotedAttributeValue(text, NS_ConvertASCIItoUCS2("media"), media);
|
2000-03-28 00:18:13 +00:00
|
|
|
if (NS_SUCCEEDED(result)) {
|
|
|
|
media.ToLowerCase();
|
1998-12-18 01:36:41 +00:00
|
|
|
}
|
2000-09-02 15:34:07 +00:00
|
|
|
result = GetQuotedAttributeValue(text, NS_ConvertASCIItoUCS2("alternate"), alternate);
|
2000-05-01 06:58:53 +00:00
|
|
|
result = ProcessStyleLink(node, href, alternate.EqualsWithConversion("yes"),
|
1999-05-26 23:58:06 +00:00
|
|
|
title, type, media);
|
1998-11-11 22:06:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
1998-12-27 08:24:04 +00:00
|
|
|
|
2000-06-17 01:49:19 +00:00
|
|
|
|
2000-12-11 22:21:06 +00:00
|
|
|
/**
|
|
|
|
* DOCTYPE declaration is covered with very strict rules, which
|
|
|
|
* makes our life here simpler because the XML parser has already
|
|
|
|
* detected errors. The only slightly problematic case is whitespace
|
|
|
|
* between the tokens. There MUST be whitespace between the tokens
|
|
|
|
* EXCEPT right before > and [.
|
|
|
|
*/
|
|
|
|
static const char* kWhitespace = " \r\n\t\b"; // Optimized for typical cases
|
|
|
|
|
|
|
|
static void
|
2000-06-17 01:49:19 +00:00
|
|
|
GetDocTypeToken(nsString& aStr,
|
|
|
|
nsString& aToken,
|
2000-12-11 22:21:06 +00:00
|
|
|
PRBool aQuotedString)
|
2000-06-17 01:49:19 +00:00
|
|
|
{
|
2000-12-11 22:21:06 +00:00
|
|
|
aStr.Trim(kWhitespace,PR_TRUE,PR_FALSE); // If we don't do this we must look ahead
|
|
|
|
// before Cut() and adjust the cut amount.
|
|
|
|
|
|
|
|
if (aQuotedString) {
|
|
|
|
PRInt32 endQuote = aStr.FindChar(aStr[0],PR_FALSE,1);
|
|
|
|
aStr.Mid(aToken,1,endQuote-1);
|
|
|
|
aStr.Cut(0,endQuote+1);
|
|
|
|
} else {
|
|
|
|
static const char* kDelimiter = " >[\r\n\t\b"; // Optimized for typical cases
|
|
|
|
PRInt32 tokenEnd = aStr.FindCharInSet(kDelimiter);
|
|
|
|
if (tokenEnd > 0) {
|
|
|
|
aStr.Left(aToken, tokenEnd);
|
|
|
|
aStr.Cut(0, tokenEnd);
|
2000-06-17 01:49:19 +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
|
|
|
{
|
2000-06-17 01:49:19 +00:00
|
|
|
nsresult rv = NS_OK;
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDOMDocument> doc(do_QueryInterface(mDocument));
|
|
|
|
if (!doc)
|
|
|
|
return NS_OK;
|
|
|
|
|
2000-12-12 21:58:13 +00:00
|
|
|
nsAutoString docTypeStr(aNode.GetText());
|
2000-06-17 01:49:19 +00:00
|
|
|
nsAutoString str, name, publicId, systemId;
|
|
|
|
|
2000-12-14 06:16:39 +00:00
|
|
|
if (docTypeStr.EqualsWithConversion("<!DOCTYPE", PR_FALSE, 9)) {
|
2000-06-17 01:49:19 +00:00
|
|
|
docTypeStr.Right(str, docTypeStr.Length()-9);
|
|
|
|
}
|
|
|
|
|
2000-12-11 22:21:06 +00:00
|
|
|
GetDocTypeToken(str, name, PR_FALSE);
|
2000-06-17 01:49:19 +00:00
|
|
|
|
2000-12-11 22:21:06 +00:00
|
|
|
nsAutoString token;
|
2000-06-17 01:49:19 +00:00
|
|
|
|
2000-12-11 22:21:06 +00:00
|
|
|
GetDocTypeToken(str, token, PR_FALSE);
|
|
|
|
if (token.Equals(NS_LITERAL_STRING("PUBLIC"))) {
|
|
|
|
GetDocTypeToken(str, publicId, PR_TRUE);
|
|
|
|
GetDocTypeToken(str, systemId, PR_TRUE);
|
|
|
|
}
|
|
|
|
else if (token.Equals(NS_LITERAL_STRING("SYSTEM"))) {
|
|
|
|
GetDocTypeToken(str, systemId, PR_TRUE);
|
2000-06-17 01:49:19 +00:00
|
|
|
}
|
|
|
|
|
2000-12-11 22:21:06 +00:00
|
|
|
// The rest is the internal subset (minus whitespace and the trailing >)
|
|
|
|
str.Truncate(str.Length()-1); // Delete the trailing >
|
|
|
|
str.Trim(kWhitespace);
|
|
|
|
|
2000-06-17 01:49:19 +00:00
|
|
|
nsCOMPtr<nsIDOMDocumentType> oldDocType;
|
|
|
|
nsCOMPtr<nsIDOMDocumentType> docType;
|
|
|
|
|
|
|
|
// Create a new doctype node
|
|
|
|
rv = NS_NewDOMDocumentType(getter_AddRefs(docType),
|
|
|
|
name, nsnull, nsnull,
|
|
|
|
publicId, systemId, str);
|
|
|
|
if (NS_FAILED(rv) || !docType) {
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDOMNode> tmpNode;
|
|
|
|
|
2001-01-04 00:30:11 +00:00
|
|
|
return doc->AppendChild(docType, getter_AddRefs(tmpNode));
|
1998-11-11 22:06:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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
|
2000-05-19 04:48:43 +00:00
|
|
|
content->SetDocument(mDocument, PR_FALSE, 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-11-12 23:55:47 +00:00
|
|
|
// Set the text in the text node
|
|
|
|
nsITextContent* text = nsnull;
|
2000-09-02 15:34:07 +00:00
|
|
|
content->QueryInterface(NS_GET_IID(nsITextContent), (void**) &text);
|
1998-11-12 23:55:47 +00:00
|
|
|
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
|
2000-12-12 21:58:13 +00:00
|
|
|
nsXMLContentSink::AddText(const nsAReadableString& aString)
|
1999-02-26 17:13:51 +00:00
|
|
|
{
|
|
|
|
PRInt32 addLen = aString.Length();
|
1998-11-11 22:06:16 +00:00
|
|
|
if (0 == addLen) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2001-01-04 00:30:11 +00:00
|
|
|
if (mInScript) {
|
|
|
|
mScriptText.Append(aString);
|
2001-02-03 01:16:20 +00:00
|
|
|
} else if (mInTitle) {
|
|
|
|
mTitleText.Append(aString);
|
|
|
|
} else if (mTextAreaElement) {
|
|
|
|
mTextareaText.Append(aString);
|
2001-01-04 00:30:11 +00:00
|
|
|
}
|
|
|
|
|
1998-11-11 22:06:16 +00:00
|
|
|
// 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
|
|
|
}
|
|
|
|
}
|
2001-02-19 12:55:42 +00:00
|
|
|
mTextLength +=
|
|
|
|
nsContentUtils::CopyNewlineNormalizedUnicodeTo(aString, offset,
|
|
|
|
&mText[mTextLength],
|
|
|
|
amount);
|
1998-11-11 22:06:16 +00:00
|
|
|
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)
|
|
|
|
{
|
2000-10-28 22:17:53 +00:00
|
|
|
printf("nsXMLContentSink::AddUnparsedEntity\n");
|
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
|
|
|
NS_IMETHODIMP
|
1998-11-11 22:06:16 +00:00
|
|
|
nsXMLContentSink::AddNotation(const nsIParserNode& aNode)
|
|
|
|
{
|
2000-10-28 22:17:53 +00:00
|
|
|
printf("nsXMLContentSink::AddNotation\n");
|
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
|
|
|
NS_IMETHODIMP
|
1998-11-11 22:06:16 +00:00
|
|
|
nsXMLContentSink::AddEntityReference(const nsIParserNode& aNode)
|
|
|
|
{
|
2000-10-28 22:17:53 +00:00
|
|
|
printf("nsXMLContentSink::AddEntityReference\n");
|
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
|
|
|
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) {
|
2000-01-21 01:32:32 +00:00
|
|
|
PRUint32 count;
|
|
|
|
mContentStack->Count(&count);
|
|
|
|
PR_ASSERT(count);
|
|
|
|
if (count) {
|
|
|
|
return (nsIContent *)mContentStack->ElementAt(count-1);
|
|
|
|
}
|
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)
|
|
|
|
{
|
2000-01-21 01:32:32 +00:00
|
|
|
PRUint32 count;
|
1998-11-11 22:06:16 +00:00
|
|
|
if (nsnull == mContentStack) {
|
2000-01-21 01:32:32 +00:00
|
|
|
NS_NewISupportsArray(getter_AddRefs(mContentStack));
|
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
|
|
|
|
2000-01-21 01:32:32 +00:00
|
|
|
mContentStack->AppendElement(aContent);
|
|
|
|
mContentStack->Count(&count);
|
|
|
|
|
|
|
|
return 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()
|
2000-01-21 00:05:36 +00:00
|
|
|
{
|
1998-12-11 02:53:49 +00:00
|
|
|
nsIContent* content = nsnull;
|
|
|
|
if (nsnull != mContentStack) {
|
2000-01-21 01:32:32 +00:00
|
|
|
PRUint32 index, count;
|
|
|
|
mContentStack->Count(&count);
|
|
|
|
index = count - 1;
|
1998-12-11 02:53:49 +00:00
|
|
|
content = (nsIContent *)mContentStack->ElementAt(index);
|
|
|
|
mContentStack->RemoveElementAt(index);
|
1998-11-11 22:06:16 +00:00
|
|
|
}
|
2000-01-21 00:05:36 +00:00
|
|
|
|
|
|
|
// The caller should NS_RELEASE the returned content object.
|
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.
|
2000-10-24 01:03:31 +00:00
|
|
|
nsXPIDLCString ref;
|
1999-06-26 06:36:26 +00:00
|
|
|
nsIURL* url;
|
2000-02-02 22:24:56 +00:00
|
|
|
nsresult rv = mDocumentURL->QueryInterface(NS_GET_IID(nsIURL), (void**)&url);
|
1999-06-26 06:36:26 +00:00
|
|
|
if (NS_SUCCEEDED(rv)) {
|
2000-10-24 01:03:31 +00:00
|
|
|
rv = url->GetRef(getter_Copies(ref));
|
1999-06-26 06:36:26 +00:00
|
|
|
NS_RELEASE(url);
|
|
|
|
}
|
2000-10-24 01:03:31 +00:00
|
|
|
if (rv == NS_OK) {
|
|
|
|
mRef.AssignWithConversion(ref);
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-10-24 01:03:31 +00:00
|
|
|
if (ref || topLevelFrameset) {
|
1998-11-11 22:06:16 +00:00
|
|
|
// 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;
|
2000-09-02 15:34:07 +00:00
|
|
|
rootView->QueryInterface(NS_GET_IID(nsIScrollableView), (void**) &sview);
|
1998-11-11 22:06:16 +00:00
|
|
|
if (nsnull != sview) {
|
|
|
|
if (topLevelFrameset)
|
|
|
|
mOriginalScrollPreference = nsScrollPreference_kNeverScroll;
|
|
|
|
else
|
|
|
|
sview->GetScrollPreference(mOriginalScrollPreference);
|
|
|
|
sview->SetScrollPreference(nsScrollPreference_kNeverScroll);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
NS_RELEASE(shell);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
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) {
|
2001-02-09 22:36:23 +00:00
|
|
|
mParser->ContinueParsing();
|
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
|
|
|
|
1998-12-18 01:36:41 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2000-06-15 02:22:09 +00:00
|
|
|
nsXMLContentSink::EvaluateScript(nsString& aScript, nsIURI *aScriptURI, 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
|
|
|
|
2000-06-15 02:22:09 +00:00
|
|
|
char* url = nsnull;
|
|
|
|
if (aScriptURI) {
|
|
|
|
rv = aScriptURI->GetSpec(&url);
|
1998-11-12 23:55:47 +00:00
|
|
|
}
|
1998-12-15 06:10:59 +00:00
|
|
|
|
2000-03-28 03:59:46 +00:00
|
|
|
nsCOMPtr<nsIPrincipal> principal;
|
|
|
|
if (NS_SUCCEEDED(rv)) {
|
|
|
|
rv = mDocument->GetPrincipal(getter_AddRefs(principal));
|
|
|
|
NS_ASSERTION(principal, "principal required for document");
|
|
|
|
}
|
|
|
|
|
1999-06-26 06:36:26 +00:00
|
|
|
if (NS_SUCCEEDED(rv)) {
|
|
|
|
nsAutoString val;
|
|
|
|
PRBool isUndefined;
|
1998-12-15 06:10:59 +00:00
|
|
|
|
2000-03-28 03:59:46 +00:00
|
|
|
(void) context->EvaluateString(aScript, nsnull, principal, url, aLineNo, aVersion,
|
1999-09-17 20:16:37 +00:00
|
|
|
val, &isUndefined);
|
2000-06-15 02:22:09 +00:00
|
|
|
}
|
|
|
|
if (url) {
|
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) {
|
2000-06-15 02:22:09 +00:00
|
|
|
nsCOMPtr<nsIURI> docURI( dont_AddRef( mDocument->GetDocumentURL() ) );
|
2001-01-04 00:30:11 +00:00
|
|
|
result = EvaluateScript(mScriptText, docURI, mScriptLineNo, mScriptLanguageVersion);
|
|
|
|
mScriptText.Truncate();
|
1998-11-12 23:55:47 +00:00
|
|
|
mInScript = PR_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
// 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
|
2000-02-02 23:04:47 +00:00
|
|
|
nsXMLContentSink::OnStreamComplete(nsIStreamLoader* aLoader,
|
|
|
|
nsISupports* context,
|
|
|
|
nsresult aStatus,
|
|
|
|
PRUint32 stringLen,
|
|
|
|
const char* string)
|
1998-12-18 01:36:41 +00:00
|
|
|
{
|
1999-11-02 06:49:44 +00:00
|
|
|
nsresult rv = NS_OK;
|
2000-04-15 21:18:29 +00:00
|
|
|
nsString aData; aData.AssignWithConversion(string, stringLen);
|
1998-12-18 01:36:41 +00:00
|
|
|
|
|
|
|
if (NS_OK == aStatus) {
|
2000-06-15 02:22:09 +00:00
|
|
|
{ // scope in block so nsCOMPtr released at one point
|
|
|
|
nsCOMPtr<nsIChannel> channel;
|
2001-02-12 03:14:23 +00:00
|
|
|
aLoader->GetChannel(getter_AddRefs(channel));
|
2000-06-15 02:22:09 +00:00
|
|
|
nsCOMPtr<nsIURI> url;
|
|
|
|
if (channel) {
|
|
|
|
channel->GetURI(getter_AddRefs(url));
|
|
|
|
}
|
2001-02-06 23:31:17 +00:00
|
|
|
|
|
|
|
if(mParser) {
|
|
|
|
mParser->UnblockParser(); // make sure to unblock the parser before evaluating the script
|
|
|
|
}
|
|
|
|
|
2000-06-15 02:22:09 +00:00
|
|
|
rv = EvaluateScript(aData, url, 1, mScriptLanguageVersion);
|
|
|
|
}
|
1999-11-02 06:49:44 +00:00
|
|
|
if (NS_FAILED(rv)) return rv;
|
1998-12-18 01:36:41 +00:00
|
|
|
}
|
|
|
|
|
2001-02-09 22:36:23 +00:00
|
|
|
if(mParser && mParser->IsParserEnabled()){
|
|
|
|
rv=mParser->ContinueParsing();
|
|
|
|
}
|
|
|
|
|
1999-11-02 06:49:44 +00:00
|
|
|
if (NS_FAILED(rv)) return rv;
|
1998-12-18 01:36:41 +00:00
|
|
|
|
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++) {
|
2000-12-12 21:58:13 +00:00
|
|
|
nsAutoString key(aNode.GetKeyAt(i));
|
1998-11-12 23:55:47 +00:00
|
|
|
if (key.EqualsIgnoreCase("src")) {
|
2000-09-02 15:34:07 +00:00
|
|
|
src = aNode.GetValueAt(i);
|
1998-11-12 23:55:47 +00:00
|
|
|
}
|
|
|
|
else if (key.EqualsIgnoreCase("type")) {
|
2000-09-02 15:34:07 +00:00
|
|
|
const nsString& type = aNode.GetValueAt(i);
|
(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-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")) {
|
2000-09-02 15:34:07 +00:00
|
|
|
const nsString& lang = aNode.GetValueAt(i);
|
(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,
|
2000-09-13 23:57:52 +00:00
|
|
|
NS_SCRIPTSECURITYMANAGER_CONTRACTID, &rv);
|
1999-11-16 05:07:31 +00:00
|
|
|
if (NS_FAILED(rv))
|
|
|
|
return rv;
|
2000-10-13 22:59:47 +00:00
|
|
|
rv = securityManager->CheckLoadURI(mDocumentBaseURL, url, nsIScriptSecurityManager::ALLOW_CHROME);
|
1999-11-16 05:07:31 +00:00
|
|
|
if (NS_FAILED(rv))
|
|
|
|
return rv;
|
|
|
|
|
2000-11-06 23:22:44 +00:00
|
|
|
nsCOMPtr<nsIStreamLoader> loader;
|
1999-09-18 06:34:24 +00:00
|
|
|
nsCOMPtr<nsILoadGroup> loadGroup;
|
|
|
|
|
|
|
|
mDocument->GetDocumentLoadGroup(getter_AddRefs(loadGroup));
|
2000-11-06 23:22:44 +00:00
|
|
|
rv = NS_NewStreamLoader(getter_AddRefs(loader), url, this, nsnull,
|
|
|
|
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) {
|
2000-03-11 00:29:47 +00:00
|
|
|
nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(mWebShell));
|
|
|
|
nsCOMPtr<nsIContentViewer> contentViewer;
|
|
|
|
nsresult rv = docShell->GetContentViewer(getter_AddRefs(contentViewer));
|
1999-05-13 20:27:47 +00:00
|
|
|
if (NS_SUCCEEDED(rv) && (contentViewer != nsnull)) {
|
|
|
|
PRBool enabled;
|
|
|
|
contentViewer->GetEnableRendering(&enabled);
|
|
|
|
if (enabled) {
|
2000-02-09 15:48:01 +00:00
|
|
|
vm->EnableRefresh(NS_VMREFRESH_IMMEDIATE);
|
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
|
2000-05-10 13:13:39 +00:00
|
|
|
NS_IMETHOD CreateInstanceByTag(nsINodeInfo *aNodeInfo, 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-05-10 13:13:39 +00:00
|
|
|
XMLElementFactoryImpl::CreateInstanceByTag(nsINodeInfo *aNodeInfo,
|
|
|
|
nsIContent** aResult)
|
1999-10-05 00:12:21 +00:00
|
|
|
{
|
2000-01-19 03:10:45 +00:00
|
|
|
nsCOMPtr<nsIXMLContent> xmlContent;
|
2000-05-10 13:13:39 +00:00
|
|
|
nsresult rv = NS_NewXMLElement(getter_AddRefs(xmlContent), aNodeInfo);
|
2000-01-19 03:10:45 +00:00
|
|
|
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);
|
|
|
|
|
2000-09-13 23:57:52 +00:00
|
|
|
nsCAutoString contractID( NS_ELEMENT_FACTORY_CONTRACTID_PREFIX );
|
|
|
|
contractID.AppendWithConversion(nameSpace);
|
2000-01-19 04:44:10 +00:00
|
|
|
|
|
|
|
// Retrieve the appropriate factory.
|
2000-09-13 23:57:52 +00:00
|
|
|
NS_WITH_SERVICE(nsIElementFactory, elementFactory, contractID, &rv);
|
2000-01-19 04:44:10 +00:00
|
|
|
|
|
|
|
*aResult = elementFactory;
|
|
|
|
NS_IF_ADDREF(*aResult);
|
2000-01-19 19:17:22 +00:00
|
|
|
}
|