Bug 683416 - C: Remove #ifdef TX_EXE codepaths now that it is never defined; r=khuey

This commit is contained in:
Ed Morley 2011-09-01 17:49:25 +01:00
parent 97f0654140
commit 94128974d6
18 changed files with 11 additions and 956 deletions

View File

@ -39,75 +39,10 @@
#ifndef TRANSFRMX_ATOMS_H
#define TRANSFRMX_ATOMS_H
#ifndef TX_EXE
#include "nsGkAtoms.h"
typedef class nsGkAtoms txXPathAtoms;
typedef class nsGkAtoms txXMLAtoms;
typedef class nsGkAtoms txXSLTAtoms;
typedef class nsGkAtoms txHTMLAtoms;
#else
class nsIAtom;
/*
* Declare all atoms
*
* The atom names and values are stored in tx*AtomList.h and
* are brought to you by the magic of C preprocessing.
* Add new atoms to tx*AtomList.h and all support logic will
* be auto-generated.
*/
#define DOM_ATOMS \
TX_ATOM(comment, "#comment") \
TX_ATOM(document, "#document") \
TX_ATOM(text, "#text")
#define XML_ATOMS \
TX_ATOM(_empty, "") \
TX_ATOM(base, "base") \
TX_ATOM(_default, "default") \
TX_ATOM(lang, "lang") \
TX_ATOM(preserve, "preserve") \
TX_ATOM(space, "space") \
TX_ATOM(xml, "xml") \
TX_ATOM(xmlns, "xmlns") \
DOM_ATOMS
#define TX_ATOM(_name, _value) static nsIAtom* _name;
class txXMLAtoms
{
public:
static void init();
XML_ATOMS
};
class txXPathAtoms
{
public:
static void init();
#include "txXPathAtomList.h"
};
class txXSLTAtoms
{
public:
static void init();
#include "txXSLTAtomList.h"
};
class txHTMLAtoms
{
public:
static void init();
#include "txHTMLAtomList.h"
};
#undef TX_ATOM
#endif
#endif

View File

@ -40,9 +40,6 @@
#define MITRE_ERROROBSERVER_H
#include "txCore.h"
#ifdef TX_EXE
#include <iostream.h>
#endif
/**
* A simple interface for observing errors
@ -74,39 +71,4 @@ public:
}; //-- ErrorObserver
#ifdef TX_EXE
/**
* A simple ErrorObserver which allows printing error messages to a stream
**/
class SimpleErrorObserver : public ErrorObserver {
public:
/**
* Creates a new SimpleErrorObserver.
* All errors will be printed to the console (cout).
**/
SimpleErrorObserver();
/**
* Creates a new SimpleErrorObserver.
* All errors will be printed to the given ostream.
**/
SimpleErrorObserver(ostream& errStream);
/**
* Notifies this Error observer of a new error aRes
**/
void receiveError(const nsAString& errorMessage, nsresult aRes);
virtual void suppressWarnings(MBool suppress);
private:
ostream* errStream;
MBool hideWarnings;
}; //-- SimpleErrorObserver
#endif
#endif

View File

@ -42,6 +42,11 @@
#include "nsAString.h"
#include "nsIAtom.h"
#include "nsUnicharUtils.h"
#define TX_ToLowerCase ToLowerCase
typedef nsCaseInsensitiveStringComparator txCaseInsensitiveStringComparator;
/**
* Check equality between a string and an atom containing ASCII.
@ -52,30 +57,6 @@ TX_StringEqualsAtom(const nsASingleFragmentString& aString, nsIAtom* aAtom)
return aAtom->Equals(aString);
}
#ifndef TX_EXE
#include "nsUnicharUtils.h"
typedef nsCaseInsensitiveStringComparator txCaseInsensitiveStringComparator;
#define TX_ToLowerCase ToLowerCase
#else
// These only work for ASCII ranges!
class txCaseInsensitiveStringComparator
: public nsStringComparator
{
public:
virtual int operator()(const char_type*, const char_type*, PRUint32 aLength) const;
virtual int operator()(char_type, char_type) const;
};
void TX_ToLowerCase(nsAString& aString);
void TX_ToLowerCase(const nsAString& aSource, nsAString& aDest);
#endif
inline already_AddRefed<nsIAtom>
TX_ToLowerCaseAtom(nsIAtom* aAtom)
{

View File

@ -38,8 +38,6 @@
* ***** END LICENSE BLOCK ***** */
#include "txURIUtils.h"
#ifndef TX_EXE
#include "nsNetUtil.h"
#include "nsIAttribute.h"
#include "nsIScriptSecurityManager.h"
@ -48,119 +46,12 @@
#include "nsIContent.h"
#include "nsIPrincipal.h"
#include "nsINodeInfo.h"
#endif
/**
* URIUtils
* A set of utilities for handling URIs
**/
#ifdef TX_EXE
//- Constants -/
const char URIUtils::HREF_PATH_SEP = '/';
/**
* Implementation of utility functions for parsing URLs.
* Just file paths for now.
*/
void
txParsedURL::init(const nsAFlatString& aSpec)
{
mPath.Truncate();
mName.Truncate();
mRef.Truncate();
PRUint32 specLength = aSpec.Length();
if (!specLength) {
return;
}
const PRUnichar* start = aSpec.get();
const PRUnichar* end = start + specLength;
const PRUnichar* c = end - 1;
// check for #ref
for (; c >= start; --c) {
if (*c == '#') {
// we could eventually unescape this, too.
mRef = Substring(c + 1, end);
end = c;
--c;
if (c == start) {
// we're done,
return;
}
break;
}
}
for (c = end - 1; c >= start; --c) {
if (*c == '/') {
mName = Substring(c + 1, end);
mPath = Substring(start, c + 1);
return;
}
}
mName = Substring(start, end);
}
void
txParsedURL::resolve(const txParsedURL& aRef, txParsedURL& aDest)
{
/*
* No handling of absolute URLs now.
* These aren't really URLs yet, anyway, but paths with refs
*/
aDest.mPath = mPath + aRef.mPath;
if (aRef.mName.IsEmpty() && aRef.mPath.IsEmpty()) {
// the relative URL is just a fragment identifier
aDest.mName = mName;
if (aRef.mRef.IsEmpty()) {
// and not even that, keep the base ref
aDest.mRef = mRef;
return;
}
aDest.mRef = aRef.mRef;
return;
}
aDest.mName = aRef.mName;
aDest.mRef = aRef.mRef;
}
/**
* Returns an InputStream for the file represented by the href
* argument
* @param href the href of the file to get the input stream for.
* @return an InputStream to the desired resource
* @exception java.io.FileNotFoundException when the file could not be
* found
**/
istream* URIUtils::getInputStream(const nsAString& href, nsAString& errMsg)
{
return new ifstream(NS_LossyConvertUTF16toASCII(href).get(), ios::in);
} //-- getInputStream
/**
* Returns the document base of the href argument
* @return the document base of the given href
**/
void URIUtils::getDocumentBase(const nsAFlatString& href, nsAString& dest)
{
if (href.IsEmpty()) {
return;
}
nsAFlatString::const_char_iterator temp;
href.BeginReading(temp);
PRUint32 iter = href.Length();
while (iter > 0) {
if (temp[--iter] == HREF_PATH_SEP) {
dest.Append(StringHead(href, iter));
break;
}
}
}
#endif
/**
* Resolves the given href argument, using the given documentBase
* if necessary.
@ -176,8 +67,6 @@ void URIUtils::resolveHref(const nsAString& href, const nsAString& base,
dest.Append(base);
return;
}
#ifndef TX_EXE
nsCOMPtr<nsIURI> pURL;
nsAutoString resultHref;
nsresult result = NS_NewURI(getter_AddRefs(pURL), base);
@ -185,23 +74,8 @@ void URIUtils::resolveHref(const nsAString& href, const nsAString& base,
NS_MakeAbsoluteURI(resultHref, href, pURL);
dest.Append(resultHref);
}
#else
nsAutoString documentBase;
getDocumentBase(PromiseFlatString(base), documentBase);
//-- join document base + href
if (!documentBase.IsEmpty()) {
dest.Append(documentBase);
if (documentBase.CharAt(documentBase.Length()-1) != HREF_PATH_SEP)
dest.Append(PRUnichar(HREF_PATH_SEP));
}
dest.Append(href);
#endif
} //-- resolveHref
#ifndef TX_EXE
// static
void
URIUtils::ResetWithSource(nsIDocument *aNewDoc, nsIDOMNode *aSourceNode)
@ -245,5 +119,3 @@ URIUtils::ResetWithSource(nsIDocument *aNewDoc, nsIDOMNode *aSourceNode)
sourceDoc->GetDocumentCharacterSetSource());
aNewDoc->SetDocumentCharacterSet(sourceDoc->GetDocumentCharacterSet());
}
#endif /* TX_EXE */

View File

@ -39,62 +39,23 @@
#define TRANSFRMX_URIUTILS_H
#include "txCore.h"
#ifdef TX_EXE
#include <fstream.h>
#include <iostream.h>
#include "nsString.h"
#else
class nsIDocument;
class nsIDOMNode;
#endif
/**
* A utility class for URI handling
* Not yet finished, only handles file URI at this point
**/
#ifdef TX_EXE
class txParsedURL
{
public:
void init(const nsAFlatString& aSpec);
void resolve(const txParsedURL& aRef, txParsedURL& aDest);
void getFile(nsString& aResult) const
{
aResult = mPath + mName;
}
nsString mPath, mName, mRef;
};
#endif
class URIUtils {
public:
#ifdef TX_EXE
/**
* the path separator for an URI
**/
static const char HREF_PATH_SEP;
static istream* getInputStream
(const nsAString& href, nsAString& errMsg);
/**
* Returns the document base of the href argument
* The document base will be appended to the given dest String
**/
static void getDocumentBase(const nsAFlatString& href, nsAString& dest);
#else /* TX_EXE */
/**
* Reset the given document with the document of the source node
*/
static void ResetWithSource(nsIDocument *aNewDoc, nsIDOMNode *aSourceNode);
#endif /* TX_EXE */
/**
* Resolves the given href argument, using the given documentBase
* if necessary.

View File

@ -40,50 +40,11 @@
#include "txURIUtils.h"
#include "txXPathTreeWalker.h"
#ifndef TX_EXE
#include "nsIDocument.h"
#include "nsIDOMDocument.h"
#include "nsSyncLoadService.h"
#include "nsNetUtil.h"
#include "nsIPrincipal.h"
#else
#include "expat_config.h"
#include "expat.h"
#include "txXMLUtils.h"
#endif
#ifdef TX_EXE
/**
* Implementation of an In-Memory DOM based XML parser. The actual XML
* parsing is provided by EXPAT.
*/
class txXMLParser
{
public:
nsresult parse(istream& aInputStream, const nsAString& aUri,
txXPathNode** aResultDoc);
const nsAString& getErrorString();
/**
* Expat handlers
*/
int StartElement(const XML_Char *aName, const XML_Char **aAtts);
int EndElement(const XML_Char* aName);
void CharacterData(const XML_Char* aChars, int aLength);
void Comment(const XML_Char* aChars);
int ProcessingInstruction(const XML_Char *aTarget, const XML_Char *aData);
int ExternalEntityRef(const XML_Char *aContext, const XML_Char *aBase,
const XML_Char *aSystemId,
const XML_Char *aPublicId);
protected:
void createErrorString();
nsString mErrorString;
Document* mDocument;
Node* mCurrentNode;
XML_Parser mExpatParser;
};
#endif
nsresult
txParseDocumentFromURI(const nsAString& aHref, const txXPathNode& aLoader,
@ -91,7 +52,6 @@ txParseDocumentFromURI(const nsAString& aHref, const txXPathNode& aLoader,
{
NS_ENSURE_ARG_POINTER(aResult);
*aResult = nsnull;
#ifndef TX_EXE
nsCOMPtr<nsIURI> documentURI;
nsresult rv = NS_NewURI(getter_AddRefs(documentURI), aHref);
NS_ENSURE_SUCCESS(rv, rv);
@ -123,311 +83,4 @@ txParseDocumentFromURI(const nsAString& aHref, const txXPathNode& aLoader,
}
return NS_OK;
#else
istream* xslInput = URIUtils::getInputStream(aHref, aErrMsg);
if (!xslInput) {
return NS_ERROR_FAILURE;
}
return txParseFromStream(*xslInput, aHref, aErrMsg, aResult);
#endif
}
#ifdef TX_EXE
nsresult
txParseFromStream(istream& aInputStream, const nsAString& aUri,
nsAString& aErrorString, txXPathNode** aResult)
{
NS_ENSURE_ARG_POINTER(aResult);
txXMLParser parser;
nsresult rv = parser.parse(aInputStream, aUri, aResult);
aErrorString = parser.getErrorString();
return rv;
}
/**
* expat C stub handlers
*/
// shortcut macro for redirection into txXMLParser method calls
#define TX_XMLPARSER(_userData) static_cast<txXMLParser*>(_userData)
#define TX_ENSURE_DATA(_userData) \
PR_BEGIN_MACRO \
if (!aUserData) { \
NS_WARNING("no userData in comment handler"); \
return; \
} \
PR_END_MACRO
static void
startElement(void *aUserData, const XML_Char *aName, const XML_Char **aAtts)
{
TX_ENSURE_DATA(aUserData);
TX_XMLPARSER(aUserData)->StartElement(aName, aAtts);
}
static void
endElement(void *aUserData, const XML_Char* aName)
{
TX_ENSURE_DATA(aUserData);
TX_XMLPARSER(aUserData)->EndElement(aName);
}
static void
charData(void* aUserData, const XML_Char* aChars, int aLength)
{
TX_ENSURE_DATA(aUserData);
TX_XMLPARSER(aUserData)->CharacterData(aChars, aLength);
}
static void
commentHandler(void* aUserData, const XML_Char* aChars)
{
TX_ENSURE_DATA(aUserData);
TX_XMLPARSER(aUserData)->Comment(aChars);
}
static void
piHandler(void *aUserData, const XML_Char *aTarget, const XML_Char *aData)
{
TX_ENSURE_DATA(aUserData);
TX_XMLPARSER(aUserData)->ProcessingInstruction(aTarget, aData);
}
static int
externalEntityRefHandler(XML_Parser aParser,
const XML_Char *aContext,
const XML_Char *aBase,
const XML_Char *aSystemId,
const XML_Char *aPublicId)
{
// aParser is aUserData is the txXMLParser,
// we set that in txXMLParser::parse
NS_ENSURE_TRUE(aParser, XML_ERROR_NONE);
return ((txXMLParser*)aParser)->ExternalEntityRef(aContext, aBase,
aSystemId, aPublicId);
}
/**
* Parses the given input stream and returns a DOM Document.
* A NULL pointer will be returned if errors occurred
*/
nsresult
txXMLParser::parse(istream& aInputStream, const nsAString& aUri,
txXPathNode** aResultDoc)
{
mErrorString.Truncate();
*aResultDoc = nsnull;
if (!aInputStream) {
mErrorString.AppendLiteral("unable to parse xml: invalid or unopen stream encountered.");
return NS_ERROR_FAILURE;
}
static const XML_Memory_Handling_Suite memsuite = {
(void *(*)(size_t))PR_Malloc,
(void *(*)(void *, size_t))PR_Realloc,
PR_Free
};
static const PRUnichar expatSeparator = kExpatSeparatorChar;
mExpatParser = XML_ParserCreate_MM(nsnull, &memsuite, &expatSeparator);
if (!mExpatParser) {
return NS_ERROR_OUT_OF_MEMORY;
}
mDocument = new Document();
if (!mDocument) {
XML_ParserFree(mExpatParser);
return NS_ERROR_OUT_OF_MEMORY;
}
mDocument->documentBaseURI = aUri;
mCurrentNode = mDocument;
XML_SetReturnNSTriplet(mExpatParser, XML_TRUE);
XML_SetUserData(mExpatParser, this);
XML_SetElementHandler(mExpatParser, startElement, endElement);
XML_SetCharacterDataHandler(mExpatParser, charData);
XML_SetProcessingInstructionHandler(mExpatParser, piHandler);
XML_SetCommentHandler(mExpatParser, commentHandler);
#ifdef XML_DTD
XML_SetParamEntityParsing(mExpatParser, XML_PARAM_ENTITY_PARSING_ALWAYS);
#endif
XML_SetExternalEntityRefHandler(mExpatParser, externalEntityRefHandler);
XML_SetExternalEntityRefHandlerArg(mExpatParser, this);
XML_SetBase(mExpatParser,
(const XML_Char*)(PromiseFlatString(aUri).get()));
const int bufferSize = 1024;
char buf[bufferSize];
PRBool done;
do {
aInputStream.read(buf, bufferSize);
done = aInputStream.eof();
if (!XML_Parse(mExpatParser, buf, aInputStream.gcount(), done)) {
createErrorString();
done = MB_TRUE;
delete mDocument;
mDocument = nsnull;
}
} while (!done);
aInputStream.clear();
// clean up
XML_ParserFree(mExpatParser);
// ownership to the caller
*aResultDoc = txXPathNativeNode::createXPathNode(mDocument);
mDocument = nsnull;
return *aResultDoc ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
}
const nsAString&
txXMLParser::getErrorString()
{
return mErrorString;
}
int
txXMLParser::StartElement(const XML_Char *aName, const XML_Char **aAtts)
{
nsCOMPtr<nsIAtom> prefix, localName;
PRInt32 nsID;
XMLUtils::splitExpatName(aName, getter_AddRefs(prefix),
getter_AddRefs(localName), &nsID);
Element* newElement = mDocument->createElementNS(prefix, localName, nsID);
if (!newElement) {
return XML_ERROR_NO_MEMORY;
}
const XML_Char** theAtts = aAtts;
while (*theAtts) {
XMLUtils::splitExpatName(*theAtts++, getter_AddRefs(prefix),
getter_AddRefs(localName), &nsID);
nsDependentString attValue(*theAtts++);
nsresult rv = newElement->appendAttributeNS(prefix, localName, nsID,
attValue);
if (NS_FAILED(rv)) {
return XML_ERROR_NO_MEMORY;
}
}
int idx;
if ((idx = XML_GetIdAttributeIndex(mExpatParser)) > -1) {
nsDependentString idName((const PRUnichar*)*(aAtts + idx));
nsDependentString idValue((const PRUnichar*)*(aAtts + idx + 1));
// make sure IDs are unique
if (!idValue.IsEmpty()) {
mDocument->setElementID(idValue, newElement);
}
}
mCurrentNode->appendChild(newElement);
mCurrentNode = newElement;
return XML_ERROR_NONE;
}
int
txXMLParser::EndElement(const XML_Char* aName)
{
if (mCurrentNode->getParentNode()) {
mCurrentNode = mCurrentNode->getParentNode();
}
return XML_ERROR_NONE;
}
void
txXMLParser::CharacterData(const XML_Char* aChars, int aLength)
{
Node* prevSib = mCurrentNode->getLastChild();
const PRUnichar* pChars = static_cast<const PRUnichar*>(aChars);
if (prevSib && prevSib->getNodeType() == Node::TEXT_NODE) {
static_cast<NodeDefinition*>(prevSib)->appendData(pChars, aLength);
}
else {
// aChars is not null-terminated so we use Substring here.
Node* node = mDocument->createTextNode(Substring(pChars,
pChars + aLength));
mCurrentNode->appendChild(node);
}
}
void
txXMLParser::Comment(const XML_Char* aChars)
{
Node* node = mDocument->createComment(
nsDependentString(static_cast<const PRUnichar*>(aChars)));
mCurrentNode->appendChild(node);
}
int
txXMLParser::ProcessingInstruction(const XML_Char *aTarget,
const XML_Char *aData)
{
nsCOMPtr<nsIAtom> target = do_GetAtom(aTarget);
nsDependentString data((const PRUnichar*)aData);
Node* node = mDocument->createProcessingInstruction(target, data);
mCurrentNode->appendChild(node);
return XML_ERROR_NONE;
}
int
txXMLParser::ExternalEntityRef(const XML_Char *aContext,
const XML_Char *aBase,
const XML_Char *aSystemId,
const XML_Char *aPublicId)
{
if (aPublicId) {
// not supported, this is "http://some.site.net/foo.dtd" stuff
return XML_ERROR_EXTERNAL_ENTITY_HANDLING;
}
nsAutoString absUrl;
URIUtils::resolveHref(nsDependentString((PRUnichar*)aSystemId),
nsDependentString((PRUnichar*)aBase), absUrl);
istream* extInput = URIUtils::getInputStream(absUrl, mErrorString);
if (!extInput) {
return XML_ERROR_EXTERNAL_ENTITY_HANDLING;
}
XML_Parser parent = mExpatParser;
mExpatParser =
XML_ExternalEntityParserCreate(mExpatParser, aContext, nsnull);
if (!mExpatParser) {
mExpatParser = parent;
delete extInput;
return XML_ERROR_EXTERNAL_ENTITY_HANDLING;
}
XML_SetBase(mExpatParser, absUrl.get());
const int bufSize = 1024;
char buffer[bufSize];
int result;
PRBool done;
do {
extInput->read(buffer, bufSize);
done = extInput->eof();
if (!(result =
XML_Parse(mExpatParser, buffer, extInput->gcount(), done))) {
createErrorString();
mErrorString.Append(PRUnichar('\n'));
done = MB_TRUE;
}
} while (!done);
delete extInput;
XML_ParserFree(mExpatParser);
mExpatParser = parent;
return result;
}
void
txXMLParser::createErrorString()
{
XML_Error errCode = XML_GetErrorCode(mExpatParser);
mErrorString.AppendWithConversion(XML_ErrorString(errCode));
mErrorString.AppendLiteral(" at line ");
mErrorString.AppendInt(XML_GetCurrentLineNumber(mExpatParser));
mErrorString.AppendLiteral(" in ");
mErrorString.Append((const PRUnichar*)XML_GetBase(mExpatParser));
}
#endif

View File

@ -41,10 +41,6 @@
#include "txCore.h"
#ifdef TX_EXE
#include <iostream.h>
#endif
class txXPathNode;
/**
@ -60,12 +56,4 @@ extern "C" nsresult
txParseDocumentFromURI(const nsAString& aHref, const txXPathNode& aLoader,
nsAString& aErrMsg, txXPathNode** aResult);
#ifdef TX_EXE
/**
* Parse a document from the given stream
*/
extern "C" nsresult
txParseFromStream(istream& aInputStream, const nsAString& aUri,
nsAString& aErrorString, txXPathNode** aResult);
#endif
#endif

View File

@ -48,11 +48,8 @@
#include "nsDependentSubstring.h"
#include "nsIAtom.h"
#include "txXPathNode.h"
#ifndef TX_EXE
#include "nsIParserService.h"
#include "nsContentUtils.h"
#endif
#define kExpatSeparatorChar 0xFFFF
@ -114,13 +111,6 @@ public:
nsCOMPtr<nsIAtom> mLocalName;
};
#ifdef TX_EXE
extern "C" int MOZ_XMLCheckQName(const char* ptr, const char* end,
int ns_aware, const char** colon);
extern "C" int MOZ_XMLIsLetter(const char* ptr);
extern "C" int MOZ_XMLIsNCNameChar(const char* ptr);
#endif
class XMLUtils {
public:
@ -157,22 +147,8 @@ public:
static PRBool isValidQName(const nsAFlatString& aQName,
const PRUnichar** aColon)
{
#ifdef TX_EXE
const PRUnichar* end;
aQName.EndReading(end);
const char *colonPtr;
int result = MOZ_XMLCheckQName(reinterpret_cast<const char*>
(aQName.get()),
reinterpret_cast<const char*>
(end),
PR_TRUE, &colonPtr);
*aColon = reinterpret_cast<const PRUnichar*>(colonPtr);
return result == 0;
#else
nsIParserService* ps = nsContentUtils::GetParserService();
return ps && NS_SUCCEEDED(ps->CheckQName(aQName, PR_TRUE, aColon));
#endif
}
/**
@ -180,12 +156,8 @@ public:
*/
static PRBool isLetter(PRUnichar aChar)
{
#ifdef TX_EXE
return MOZ_XMLIsLetter(reinterpret_cast<const char*>(&aChar));
#else
nsIParserService* ps = nsContentUtils::GetParserService();
return ps && ps->IsXMLLetter(aChar);
#endif
}
/**
@ -193,12 +165,8 @@ public:
*/
static PRBool isNCNameChar(PRUnichar aChar)
{
#ifdef TX_EXE
return MOZ_XMLIsNCNameChar(reinterpret_cast<const char*>(&aChar));
#else
nsIParserService* ps = nsContentUtils::GetParserService();
return ps && ps->IsXMLNCNameChar(aChar);
#endif
}
/*

View File

@ -73,10 +73,8 @@ PRBool txNameTest::matches(const txXPathNode& aNode, txIMatchContext* aContext)
// Compare namespaces
if (mNamespace != txXPathNodeUtils::getNamespaceID(aNode)
#ifndef TX_EXE
&& !(mNamespace == kNameSpaceID_None &&
txXPathNodeUtils::isHTMLElementInHTMLDocument(aNode))
#endif
)
return MB_FALSE;

View File

@ -39,22 +39,14 @@
#ifndef txXPathNode_h__
#define txXPathNode_h__
#ifdef TX_EXE
#include "txDOM.h"
#else
#include "nsAutoPtr.h"
#include "nsIContent.h"
#include "nsIDocument.h"
#include "nsIDOMNode.h"
#include "nsINameSpaceManager.h"
#include "nsContentUtils.h"
#endif
#ifdef TX_EXE
typedef Node txXPathNodeType;
#else
typedef nsIDOMNode txXPathNodeType;
#endif
class txXPathNode
{
@ -74,13 +66,6 @@ private:
txXPathNode(const txXPathNode& aNode);
#ifdef TX_EXE
txXPathNode(NodeDefinition* aNode) : mInner(aNode)
{
}
NodeDefinition* mInner;
#else
txXPathNode(nsIDocument* aDocument) : mNode(aDocument),
mRefCountRoot(0),
mIndex(eDocument)
@ -148,7 +133,6 @@ private:
nsINode* mNode;
PRUint32 mRefCountRoot : 1;
PRUint32 mIndex : 31;
#endif
};
class txNamespaceManager
@ -162,36 +146,24 @@ public:
inline PRInt32
txNamespaceManager::getNamespaceID(const nsAString& aNamespaceURI)
{
#ifdef TX_EXE
return txStandaloneNamespaceManager::getNamespaceID(aNamespaceURI);
#else
PRInt32 namespaceID = kNameSpaceID_Unknown;
nsContentUtils::NameSpaceManager()->
RegisterNameSpace(aNamespaceURI, namespaceID);
return namespaceID;
#endif
}
/* static */
inline nsresult
txNamespaceManager::getNamespaceURI(const PRInt32 aID, nsAString& aResult)
{
#ifdef TX_EXE
return txStandaloneNamespaceManager::getNamespaceURI(aID, aResult);
#else
return nsContentUtils::NameSpaceManager()->
GetNameSpaceURI(aID, aResult);
#endif
}
inline PRBool
txXPathNode::operator==(const txXPathNode& aNode) const
{
#ifdef TX_EXE
return (mInner == aNode.mInner);
#else
return mIndex == aNode.mIndex && mNode == aNode.mNode;
#endif
}
#endif /* txXPathNode_h__ */

View File

@ -41,13 +41,12 @@
#include "txCore.h"
#include "txXPathNode.h"
class nsIAtom;
#ifndef TX_EXE
#include "nsINodeInfo.h"
#include "nsTArray.h"
class nsIAtom;
class nsIDOMDocument;
class txUint32Array : public nsTArray<PRUint32>
{
public:
@ -68,9 +67,6 @@ public:
}
};
class nsIDOMDocument;
#endif
class txXPathTreeWalker
{
public:
@ -103,13 +99,11 @@ public:
private:
txXPathNode mPosition;
#ifndef TX_EXE
PRBool moveToValidAttribute(PRUint32 aStartIndex);
PRBool moveToSibling(PRInt32 aDir);
PRUint32 mCurrentIndex;
txUint32Array mDescendants;
#endif
};
class txXPathNodeUtils
@ -144,7 +138,6 @@ public:
static PRBool isProcessingInstruction(const txXPathNode& aNode);
static PRBool isComment(const txXPathNode& aNode);
static PRBool isText(const txXPathNode& aNode);
#ifndef TX_EXE
static inline PRBool isHTMLElementInHTMLDocument(const txXPathNode& aNode)
{
if (!aNode.isContent()) {
@ -153,21 +146,8 @@ public:
nsIContent* content = aNode.Content();
return content->IsHTML() && content->IsInHTMLDocument();
}
#else
private:
static void appendNodeValueHelper(NodeDefinition* aNode, nsAString& aResult);
#endif
};
#ifdef TX_EXE
class txXPathNativeNode
{
public:
static txXPathNode* createXPathNode(Node* aNode);
static nsresult getElement(const txXPathNode& aNode, Element** aResult);
static nsresult getDocument(const txXPathNode& aNode, Document** aResult);
};
#else
class txXPathNativeNode
{
public:
@ -190,8 +170,6 @@ public:
}
};
#endif
inline const txXPathNode&
txXPathTreeWalker::getCurrentPosition() const
{
@ -226,9 +204,6 @@ txXPathTreeWalker::getNodeName(nsAString& aName) const
inline void
txXPathTreeWalker::moveTo(const txXPathTreeWalker& aWalker)
{
#ifdef TX_EXE
mPosition.mInner = aWalker.mPosition.mInner;
#else
nsINode *root = nsnull;
if (mPosition.mRefCountRoot) {
root = mPosition.Root();
@ -247,7 +222,6 @@ txXPathTreeWalker::moveTo(const txXPathTreeWalker& aWalker)
mCurrentIndex = aWalker.mCurrentIndex;
mDescendants.Clear();
#endif
}
inline PRBool
@ -260,24 +234,16 @@ txXPathTreeWalker::isOnNode(const txXPathNode& aNode) const
inline PRInt32
txXPathNodeUtils::getUniqueIdentifier(const txXPathNode& aNode)
{
#ifdef TX_EXE
return NS_PTR_TO_INT32(aNode.mInner);
#else
NS_PRECONDITION(!aNode.isAttribute(),
"Not implemented for attributes.");
return NS_PTR_TO_INT32(aNode.mNode);
#endif
}
/* static */
inline void
txXPathNodeUtils::release(txXPathNode* aNode)
{
#ifdef TX_EXE
delete aNode->mInner;
#else
NS_RELEASE(aNode->mNode);
#endif
}
/* static */
@ -285,12 +251,6 @@ inline PRBool
txXPathNodeUtils::localNameEquals(const txXPathNode& aNode,
nsIAtom* aLocalName)
{
#ifdef TX_EXE
nsCOMPtr<nsIAtom> localName;
aNode.mInner->getLocalName(getter_AddRefs(localName));
return localName == aLocalName;
#else
if (aNode.isContent() &&
aNode.Content()->IsElement()) {
return aNode.Content()->NodeInfo()->Equals(aLocalName);
@ -299,30 +259,21 @@ txXPathNodeUtils::localNameEquals(const txXPathNode& aNode,
nsCOMPtr<nsIAtom> localName = txXPathNodeUtils::getLocalName(aNode);
return localName == aLocalName;
#endif
}
/* static */
inline PRBool
txXPathNodeUtils::isRoot(const txXPathNode& aNode)
{
#ifdef TX_EXE
return aNode.mInner->getNodeType() == Node::DOCUMENT_NODE;
#else
return !aNode.isAttribute() && !aNode.mNode->GetNodeParent();
#endif
}
/* static */
inline PRBool
txXPathNodeUtils::isElement(const txXPathNode& aNode)
{
#ifdef TX_EXE
return aNode.mInner->getNodeType() == Node::ELEMENT_NODE;
#else
return aNode.isContent() &&
aNode.Content()->IsElement();
#endif
}
@ -330,47 +281,31 @@ txXPathNodeUtils::isElement(const txXPathNode& aNode)
inline PRBool
txXPathNodeUtils::isAttribute(const txXPathNode& aNode)
{
#ifdef TX_EXE
return aNode.mInner->getNodeType() == Node::ATTRIBUTE_NODE;
#else
return aNode.isAttribute();
#endif
}
/* static */
inline PRBool
txXPathNodeUtils::isProcessingInstruction(const txXPathNode& aNode)
{
#ifdef TX_EXE
return aNode.mInner->getNodeType() == Node::PROCESSING_INSTRUCTION_NODE;
#else
return aNode.isContent() &&
aNode.Content()->IsNodeOfType(nsINode::ePROCESSING_INSTRUCTION);
#endif
}
/* static */
inline PRBool
txXPathNodeUtils::isComment(const txXPathNode& aNode)
{
#ifdef TX_EXE
return aNode.mInner->getNodeType() == Node::COMMENT_NODE;
#else
return aNode.isContent() &&
aNode.Content()->IsNodeOfType(nsINode::eCOMMENT);
#endif
}
/* static */
inline PRBool
txXPathNodeUtils::isText(const txXPathNode& aNode)
{
#ifdef TX_EXE
return aNode.mInner->getNodeType() == Node::TEXT_NODE;
#else
return aNode.isContent() &&
aNode.Content()->IsNodeOfType(nsINode::eTEXT);
#endif
}
#endif /* txXPathTreeWalker_h__ */

View File

@ -47,15 +47,12 @@
#include "txRtfHandler.h"
#include "txXPathTreeWalker.h"
#include "nsPrintfCString.h"
#ifndef TX_EXE
#include "nsComponentManagerUtils.h"
#include "nsContentCID.h"
#include "nsContentCreatorFunctions.h"
#include "nsIContent.h"
#include "nsIDOMDocumentFragment.h"
#include "txMozillaXMLOutput.h"
#endif
class txStylesheetCompilerState;
@ -76,9 +73,6 @@ convertRtfToNode(txIEvalContext *aContext, txResultTreeFragment *aRtf)
const txXPathNode& document = es->getSourceDocument();
#ifdef TX_EXE
return NS_ERROR_NOT_IMPLEMENTED;
#else
nsIDocument *doc = txXPathNativeNode::getDocument(document);
nsCOMPtr<nsIDOMDocumentFragment> domFragment;
nsresult rv = NS_NewDocumentFragment(getter_AddRefs(domFragment),
@ -102,7 +96,6 @@ convertRtfToNode(txIEvalContext *aContext, txResultTreeFragment *aRtf)
aRtf->setNode(node);
return NS_OK;
#endif
}
static nsresult
@ -119,9 +112,6 @@ createTextNode(txIEvalContext *aContext, nsString& aValue,
const txXPathNode& document = es->getSourceDocument();
#ifdef TX_EXE
return NS_ERROR_NOT_IMPLEMENTED;
#else
nsIDocument *doc = txXPathNativeNode::getDocument(document);
nsCOMPtr<nsIContent> text;
nsresult rv = NS_NewTextNode(getter_AddRefs(text), doc->NodeInfoManager());
@ -134,10 +124,8 @@ createTextNode(txIEvalContext *aContext, nsString& aValue,
NS_ENSURE_TRUE(*aResult, NS_ERROR_OUT_OF_MEMORY);
return NS_OK;
#endif
}
#ifndef TX_EXE
static nsresult
createDocFragment(txIEvalContext *aContext, nsIContent** aResult)
{
@ -195,7 +183,6 @@ createAndAddToResult(nsIAtom* aName, const nsSubstring& aValue,
return NS_OK;
}
#endif
// Need to update this array if types are added to the ResultType enum in
// txAExprResult.

View File

@ -42,16 +42,11 @@
#include "txCore.h"
#include "nsIAtom.h"
class txOutputFormat;
#ifdef TX_EXE
#include <iostream.h>
#else
#define kTXNameSpaceURI "http://www.mozilla.org/TransforMiix"
#define kTXWrapper "transformiix:result"
class txOutputFormat;
class nsIDOMDocument;
#endif
/**
* An interface for handling XML documents, loosely modeled
@ -179,10 +174,6 @@ public:
const PRInt32 aNsID);
#ifdef TX_EXE
typedef txAXMLEventHandler txAOutputXMLEventHandler;
#define TX_DECL_TXAOUTPUTXMLEVENTHANDLER
#else
class txAOutputXMLEventHandler : public txAXMLEventHandler
{
public:
@ -196,7 +187,6 @@ public:
#define TX_DECL_TXAOUTPUTXMLEVENTHANDLER \
virtual void getOutputDocument(nsIDOMDocument** aDocument);
#endif
/**
* Interface used to create the appropriate outputhandler

View File

@ -40,16 +40,12 @@
#include "txXPathResultComparator.h"
#include "txExpr.h"
#include "txCore.h"
#ifndef TX_EXE
#include "nsCollationCID.h"
#include "nsILocale.h"
#include "nsILocaleService.h"
#include "nsIServiceManager.h"
#include "nsLocaleCID.h"
#include "prmem.h"
#else
#include "txStringUtils.h"
#endif
#define kAscending (1<<0)
#define kUpperFirst (1<<1)
@ -63,14 +59,11 @@ txResultStringComparator::txResultStringComparator(MBool aAscending,
mSorting |= kAscending;
if (aUpperFirst)
mSorting |= kUpperFirst;
#ifndef TX_EXE
nsresult rv = init(aLanguage);
if (NS_FAILED(rv))
NS_ERROR("Failed to initialize txResultStringComparator");
#endif
}
#ifndef TX_EXE
nsresult txResultStringComparator::init(const nsAFlatString& aLanguage)
{
nsresult rv;
@ -98,7 +91,6 @@ nsresult txResultStringComparator::init(const nsAFlatString& aLanguage)
return NS_OK;
}
#endif
nsresult
txResultStringComparator::createSortableValue(Expr *aExpr,
@ -110,14 +102,6 @@ txResultStringComparator::createSortableValue(Expr *aExpr,
return NS_ERROR_OUT_OF_MEMORY;
}
nsresult rv;
#ifdef TX_EXE
rv = aExpr->evaluateToString(aContext, val->mStr);
NS_ENSURE_SUCCESS(rv, rv);
// We don't support case-order on standalone
TX_ToLowerCase(val->mStr);
#else
if (!mCollation)
return NS_ERROR_FAILURE;
@ -127,7 +111,7 @@ txResultStringComparator::createSortableValue(Expr *aExpr,
}
nsString& nsCaseKey = *(nsString *)val->mCaseKey;
rv = aExpr->evaluateToString(aContext, nsCaseKey);
nsresult rv = aExpr->evaluateToString(aContext, nsCaseKey);
NS_ENSURE_SUCCESS(rv, rv);
if (nsCaseKey.IsEmpty()) {
@ -139,7 +123,6 @@ txResultStringComparator::createSortableValue(Expr *aExpr,
rv = mCollation->AllocateRawSortKey(nsICollation::kCollationCaseInSensitive,
nsCaseKey, &val->mKey, &val->mLength);
NS_ENSURE_SUCCESS(rv, rv);
#endif
aResult = val.forget();
@ -150,27 +133,7 @@ int txResultStringComparator::compareValues(TxObject* aVal1, TxObject* aVal2)
{
StringValue* strval1 = (StringValue*)aVal1;
StringValue* strval2 = (StringValue*)aVal2;
#ifdef TX_EXE
PRUint32 len1 = strval1->mStr.Length();
PRUint32 len2 = strval2->mStr.Length();
PRUint32 minLength = (len1 < len2) ? len1 : len2;
PRUint32 c = 0;
while (c < minLength) {
PRUnichar ch1 = strval1->mStr.CharAt(c);
PRUnichar ch2 = strval2->mStr.CharAt(c);
if (ch1 < ch2)
return ((mSorting & kAscending) ? 1 : -1) * -1;
if (ch2 < ch1)
return ((mSorting & kAscending) ? 1 : -1) * 1;
c++;
}
if (len1 == len2)
return 0;
return ((mSorting & kAscending) ? 1 : -1) * ((len1 < len2) ? -1 : 1);
#else
if (!mCollation)
return -1;
@ -234,10 +197,8 @@ int txResultStringComparator::compareValues(TxObject* aVal1, TxObject* aVal2)
return ((mSorting & kAscending) ? 1 : -1) *
((mSorting & kUpperFirst) ? -1 : 1) * result;
#endif
}
#ifndef TX_EXE
txResultStringComparator::StringValue::StringValue() : mKey(0),
mCaseKey(0),
mLength(0),
@ -253,7 +214,6 @@ txResultStringComparator::StringValue::~StringValue()
else
delete (nsString*)mCaseKey;
}
#endif
txResultNumberComparator::txResultNumberComparator(MBool aAscending)
{

View File

@ -41,10 +41,8 @@
#define TRANSFRMX_XPATHRESULTCOMPARATOR_H
#include "txCore.h"
#ifndef TX_EXE
#include "nsCOMPtr.h"
#include "nsICollation.h"
#endif
#include "nsString.h"
class Expr;
@ -86,29 +84,23 @@ public:
nsresult createSortableValue(Expr *aExpr, txIEvalContext *aContext,
TxObject *&aResult);
private:
#ifndef TX_EXE
nsCOMPtr<nsICollation> mCollation;
nsresult init(const nsAFlatString& aLanguage);
nsresult createRawSortKey(const PRInt32 aStrength,
const nsString& aString,
PRUint8** aKey,
PRUint32* aLength);
#endif
int mSorting;
class StringValue : public TxObject
{
public:
#ifdef TX_EXE
nsString mStr;
#else
StringValue();
~StringValue();
PRUint8* mKey;
void* mCaseKey;
PRUint32 mLength, mCaseLength;
#endif
};
};

View File

@ -44,9 +44,7 @@
#include "txXMLUtils.h"
#include "txXSLTFunctions.h"
#include "nsWhitespaceTokenizer.h"
#ifndef TX_EXE
#include "nsIContent.h"
#endif
/*
* Returns the default priority of this Pattern.
@ -304,22 +302,10 @@ MBool txIdPattern::matches(const txXPathNode& aNode, txIMatchContext* aContext)
}
// Get a ID attribute, if there is
#ifdef TX_EXE
Element* elem;
nsresult rv = txXPathNativeNode::getElement(aNode, &elem);
NS_ASSERTION(NS_SUCCEEDED(rv), "So why claim it's an element above?");
nsAutoString value;
if (!elem->getIDValue(value)) {
return PR_FALSE;
}
nsCOMPtr<nsIAtom> id = do_GetAtom(value);
#else
nsIContent* content = txXPathNativeNode::getContent(aNode);
NS_ASSERTION(content, "a Element without nsIContent");
nsIAtom* id = content->GetID();
#endif // TX_EXE
return id && mIds.IndexOf(id) > -1;
}

View File

@ -44,9 +44,6 @@
#include "txStylesheetCompiler.h"
#include "txExecutionState.h"
#include "txExprResult.h"
#ifdef TX_EXE
#include "txHTMLOutput.h"
#endif
TX_LG_IMPL
@ -56,20 +53,6 @@ txXSLTProcessor::init()
{
TX_LG_CREATE;
#ifdef TX_EXE
if (!txStandaloneNamespaceManager::init())
return MB_FALSE;
if (NS_FAILED(txHTMLOutput::init())) {
return MB_FALSE;
}
txXMLAtoms::init();
txXPathAtoms::init();
txXSLTAtoms::init();
txHTMLAtoms::init();
#endif
if (!txHandlerTable::init())
return MB_FALSE;
@ -84,11 +67,6 @@ txXSLTProcessor::init()
void
txXSLTProcessor::shutdown()
{
#ifdef TX_EXE
txStandaloneNamespaceManager::shutdown();
txHTMLOutput::shutdown();
#endif
txStylesheetCompilerState::shutdown();
txHandlerTable::shutdown();
}

View File

@ -663,14 +663,6 @@ struct XML_ParserStruct {
/* END MOZILLA CHANGE */
/* BEGIN MOZILLA CHANGE (unused API) */
#ifdef TX_EXE
XML_Parser XMLCALL
XML_ParserCreate(const XML_Char *encodingName)
{
return XML_ParserCreate_MM(encodingName, NULL, NULL);
}
#endif
#if 0
XML_Parser XMLCALL
XML_ParserCreateNS(const XML_Char *encodingName, XML_Char nsSep)
@ -1916,62 +1908,7 @@ XML_DefaultCurrent(XML_Parser parser)
reportDefault(parser, encoding, eventPtr, eventEndPtr);
}
}
#endif
#ifdef TX_EXE
const XML_LChar * XMLCALL
XML_ErrorString(enum XML_Error code)
{
static const XML_LChar* const message[] = {
0,
XML_L("out of memory"),
XML_L("syntax error"),
XML_L("no element found"),
XML_L("not well-formed (invalid token)"),
XML_L("unclosed token"),
XML_L("partial character"),
XML_L("mismatched tag"),
XML_L("duplicate attribute"),
XML_L("junk after document element"),
XML_L("illegal parameter entity reference"),
XML_L("undefined entity"),
XML_L("recursive entity reference"),
XML_L("asynchronous entity"),
XML_L("reference to invalid character number"),
XML_L("reference to binary entity"),
XML_L("reference to external entity in attribute"),
XML_L("XML or text declaration not at start of entity"),
XML_L("unknown encoding"),
XML_L("encoding specified in XML declaration is incorrect"),
XML_L("unclosed CDATA section"),
XML_L("error in processing external entity reference"),
XML_L("document is not standalone"),
XML_L("unexpected parser state - please send a bug report"),
XML_L("entity declared in parameter entity"),
XML_L("requested feature requires XML_DTD support in Expat"),
XML_L("cannot change setting once parsing has begun"),
XML_L("unbound prefix"),
XML_L("must not undeclare prefix"),
XML_L("incomplete markup in parameter entity"),
XML_L("XML declaration not well-formed"),
XML_L("text declaration not well-formed"),
XML_L("illegal character(s) in public id"),
XML_L("parser suspended"),
XML_L("parser not suspended"),
XML_L("parsing aborted"),
XML_L("parsing finished"),
XML_L("cannot suspend in external parameter entity"),
XML_L("reserved prefix (xml) must not be undeclared or bound to another namespace name"),
XML_L("reserved prefix (xmlns) must not be declared or undeclared"),
XML_L("prefix must not be bound to one of the reserved namespace names")
};
if (code > 0 && code < sizeof(message)/sizeof(message[0]))
return message[code];
return NULL;
}
#endif
#if 0
const XML_LChar * XMLCALL
XML_ExpatVersion(void) {