This commit was manufactured by cvs2svn to create branch

'AVIARY_1_0_20040515_BRANCH'.

git-svn-id: svn://10.0.0.236/branches/AVIARY_1_0_20040515_BRANCH@156431 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
(no author)
2004-05-15 19:32:54 +00:00
parent 6c06bfad8c
commit b4b70055bb
25186 changed files with 5675670 additions and 0 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,402 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* 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/
*
* 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.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
/**
* MODULE NOTES:
* @update gess 7/15/98
*
* NavDTD is an implementation of the nsIDTD interface.
* In particular, this class captures the behaviors of the original
* Navigator parser productions.
*
* This DTD, like any other in NGLayout, provides a few basic services:
* - First, the DTD collaborates with the Parser class to convert plain
* text into a sequence of HTMLTokens.
* - Second, the DTD describes containment rules for known elements.
* - Third the DTD controls and coordinates the interaction between the
* parsing system and content sink. (The content sink is the interface
* that serves as a proxy for content model).
* - Fourth the DTD maintains an internal style-stack to handle residual (leaky)
* style tags.
*
* You're most likely working in this class file because
* you want to add or change a behavior inherent in this DTD. The remainder
* of this section will describe what you need to do to affect the kind of
* change you want in this DTD.
*
* RESIDUAL-STYLE HANDLNG:
* There are a number of ways to represent style in an HTML document.
* 1) explicit style tags (<B>, <I> etc)
* 2) implicit styles (like those implicit in <Hn>)
* 3) CSS based styles
*
* Residual style handling results from explicit style tags that are
* not closed. Consider this example: <p>text <b>bold </p>
* When the <p> tag closes, the <b> tag is NOT automatically closed.
* Unclosed style tags are handled by the process we call residual-style
* tag handling.
*
* There are two aspects to residual style tag handling. The first is the
* construction and managing of a stack of residual style tags. The
* second is the automatic emission of residual style tags onto leaf content
* in subsequent portions of the document.This step is necessary to propagate
* the expected style behavior to subsequent portions of the document.
*
* Construction and managing the residual style stack is an inline process that
* occurs during the model building phase of the parse process. During the model-
* building phase of the parse process, a content stack is maintained which tracks
* the open container hierarchy. If a style tag(s) fails to be closed when a normal
* container is closed, that style tag is placed onto the residual style stack. If
* that style tag is subsequently closed (in most contexts), it is popped off the
* residual style stack -- and are of no further concern.
*
* Residual style tag emission occurs when the style stack is not empty, and leaf
* content occurs. In our earlier example, the <b> tag "leaked" out of the <p>
* container. Just before the next leaf is emitted (in this or another container) the
* style tags that are on the stack are emitted in succession. These same residual
* style tags get closed automatically when the leaf's container closes, or if a
* child container is opened.
*
*
*/
#ifndef NS_NAVHTMLDTD__
#define NS_NAVHTMLDTD__
#include "nsIDTD.h"
#include "nsISupports.h"
#include "nsIParser.h"
#include "nsHTMLTags.h"
#include "nsVoidArray.h"
#include "nsDeque.h"
#include "nsParserCIID.h"
#include "nsTime.h"
#include "nsDTDUtils.h"
#define NS_INAVHTML_DTD_IID \
{0x5c5cce40, 0xcfd6, 0x11d1, \
{0xaa, 0xda, 0x00, 0x80, 0x5f, 0x8a, 0x3e, 0x14}}
class nsIHTMLContentSink;
class nsIParserNode;
class nsParser;
class nsDTDContext;
class nsEntryStack;
class nsITokenizer;
class nsCParserNode;
class nsTokenAllocator;
/***************************************************************
Now the main event: CNavDTD.
This not so simple class performs all the duties of token
construction and model building. It works in conjunction with
an nsParser.
***************************************************************/
#ifdef _MSC_VER
#pragma warning( disable : 4275 )
#endif
class CNavDTD : public nsIDTD
{
#ifdef _MSC_VER
#pragma warning( default : 4275 )
#endif
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIDTD
/**
* Common constructor for navdtd. You probably want to call
* NS_NewNavHTMLDTD().
*
* @update gess 7/9/98
*/
CNavDTD();
virtual ~CNavDTD();
/**
* This method is called to determine whether or not a tag
* of one type can contain a tag of another type.
*
* @update gess 3/25/98
* @param aParent -- int tag of parent container
* @param aChild -- int tag of child container
* @return PR_TRUE if parent can contain child
*/
virtual PRBool CanPropagate(eHTMLTags aParent,
eHTMLTags aChild,
PRBool aParentContains) ;
/**
* This method gets called to determine whether a given
* child tag can be omitted by the given parent.
*
* @update gess 3/25/98
* @param aParent -- parent tag being asked about omitting given child
* @param aChild -- child tag being tested for omittability by parent
* @param aParentContains -- can be 0,1,-1 (false,true, unknown)
* @return PR_TRUE if given tag can be omitted
*/
virtual PRBool CanOmit(eHTMLTags aParent,
eHTMLTags aChild,
PRBool& aParentContains);
/**
* This method tries to design a context map (without actually
* changing our parser state) from the parent down to the
* child.
*
* @update gess4/6/98
* @param aParent -- tag type of parent
* @param aChild -- tag type of child
* @return True if closure was achieved -- other false
*/
virtual PRBool ForwardPropagate(nsString& aSequence,
eHTMLTags aParent,
eHTMLTags aChild);
/**
* This method tries to design a context map (without actually
* changing our parser state) from the child up to the parent.
*
* @update gess4/6/98
* @param aParent -- tag type of parent
* @param aChild -- tag type of child
* @return True if closure was achieved -- other false
*/
virtual PRBool BackwardPropagate(nsString& aSequence,
eHTMLTags aParent,
eHTMLTags aChild) const;
/**
* Attempt forward and/or backward propagation for the given
* child within the current context vector stack.
* @update gess5/11/98
* @param aChild -- type of child to be propagated.
* @return TRUE if succeeds, otherwise FALSE
*/
nsresult CreateContextStackFor(eHTMLTags aChild);
/**
* Ask parser if a given container is open ANYWHERE on stack
* @update gess5/11/98
* @param id of container you want to test for
* @return TRUE if the given container type is open -- otherwise FALSE
*/
virtual PRBool HasOpenContainer(eHTMLTags aContainer) const;
/**
* Ask parser if a given container is open ANYWHERE on stack
* @update gess5/11/98
* @param id of container you want to test for
* @return TRUE if the given container type is open -- otherwise FALSE
*/
virtual PRBool HasOpenContainer(const eHTMLTags aTagSet[],PRInt32 aCount) const;
/**
* Accessor that retrieves the tag type of the topmost item on context
* vector stack.
*
* @update gess5/11/98
* @return tag type (may be unknown)
*/
virtual eHTMLTags GetTopNode() const;
/**
* Finds the topmost occurance of given tag within context vector stack.
* @update gess5/11/98
* @param tag to be found
* @return index of topmost tag occurance -- may be -1 (kNotFound).
*/
// virtual PRInt32 GetTopmostIndexOf(eHTMLTags aTag) const;
/**
* Finds the topmost occurance of given tag within context vector stack.
* @update gess5/11/98
* @param tag to be found
* @return index of topmost tag occurance -- may be -1 (kNotFound).
*/
virtual PRInt32 LastOf(eHTMLTags aTagSet[],PRInt32 aCount) const;
/**
* The following set of methods are used to partially construct
* the content model (via the sink) according to the type of token.
* @update gess5/11/98
* @param aToken is the token (of a given type) to be handled
* @return error code representing construction state; usually 0.
*/
nsresult HandleStartToken(CToken* aToken);
nsresult HandleDefaultStartToken(CToken* aToken, eHTMLTags aChildTag,
nsCParserNode *aNode);
nsresult HandleEndToken(CToken* aToken);
nsresult HandleEntityToken(CToken* aToken);
nsresult HandleCommentToken(CToken* aToken);
nsresult HandleAttributeToken(CToken* aToken);
nsresult HandleScriptToken(const nsIParserNode *aNode);
nsresult HandleProcessingInstructionToken(CToken* aToken);
nsresult HandleDocTypeDeclToken(CToken* aToken);
nsresult BuildNeglectedTarget(eHTMLTags aTarget, eHTMLTokenTypes aType,
nsIParser* aParser, nsIContentSink* aSink);
//*************************************************
//these cover methods mimic the sink, and are used
//by the parser to manage its context-stack.
//*************************************************
/**
* The next set of method open given HTML elements of
* various types.
*
* @update gess5/11/98
* @param node to be opened in content sink.
* @return error code representing error condition-- usually 0.
*/
nsresult OpenHTML(const nsCParserNode *aNode);
nsresult OpenHead(const nsIParserNode *aNode);
nsresult OpenBody(const nsCParserNode *aNode);
nsresult OpenForm(const nsIParserNode *aNode);
nsresult OpenMap(const nsCParserNode *aNode);
nsresult OpenFrameset(const nsCParserNode *aNode);
nsresult OpenContainer(const nsCParserNode *aNode,
eHTMLTags aTag,
PRBool aClosedByStartTag,
nsEntryStack* aStyleStack=0);
/**
* The next set of methods close the given HTML element.
*
* @update gess5/11/98
* @param HTML (node) to be opened in content sink.
* @return error code - 0 if all went well.
*/
nsresult CloseHTML();
nsresult CloseHead();
nsresult CloseBody();
nsresult CloseForm();
nsresult CloseMap();
nsresult CloseFrameset();
/**
* The special purpose methods automatically close
* one or more open containers.
* @update gess5/11/98
* @return error code - 0 if all went well.
*/
nsresult CloseContainer(const eHTMLTags aTag,
eHTMLTags aTarget,
PRBool aClosedByStartTag);
nsresult CloseContainersTo(eHTMLTags aTag,
PRBool aClosedByStartTag);
nsresult CloseContainersTo(PRInt32 anIndex,
eHTMLTags aTag,
PRBool aClosedByStartTag);
/**
* Causes leaf to be added to sink at current vector pos.
* @update gess5/11/98
* @param aNode is leaf node to be added.
* @return error code - 0 if all went well.
*/
nsresult AddLeaf(const nsIParserNode *aNode);
nsresult AddHeadLeaf(nsIParserNode *aNode);
/**
* This set of methods is used to create and manage the set of
* transient styles that occur as a result of poorly formed HTML
* or bugs in the original navigator.
*
* @update gess5/11/98
* @param aTag -- represents the transient style tag to be handled.
* @return error code -- usually 0
*/
nsresult OpenTransientStyles(eHTMLTags aChildTag);
nsresult CloseTransientStyles(eHTMLTags aChildTag);
nsresult PopStyle(eHTMLTags aTag);
nsresult PushIntoMisplacedStack(CToken* aToken)
{
NS_ENSURE_ARG_POINTER(aToken);
aToken->SetNewlineCount(0); // Note: We have already counted the newlines for these tokens
mMisplacedContent.Push(aToken);
return NS_OK;
}
protected:
nsresult CollectAttributes(nsIParserNode& aNode,eHTMLTags aTag,PRInt32 aCount);
nsresult CollectSkippedContent(nsIParserNode& aNode,PRInt32& aCount);
nsresult WillHandleStartTag(CToken* aToken,eHTMLTags aChildTag,nsIParserNode& aNode);
nsresult DidHandleStartTag(nsIParserNode& aNode,eHTMLTags aChildTag);
nsresult HandleOmittedTag(CToken* aToken,eHTMLTags aChildTag,eHTMLTags aParent,nsIParserNode *aNode);
nsresult HandleSavedTokens(PRInt32 anIndex);
nsresult HandleKeyGen(nsIParserNode *aNode);
nsDeque mMisplacedContent;
nsDeque mSkippedContent;
nsIHTMLContentSink* mSink;
nsTokenAllocator* mTokenAllocator;
nsDTDContext* mBodyContext;
nsDTDContext* mTempContext;
nsParser* mParser;
nsITokenizer* mTokenizer; // weak
nsString mFilename;
nsString mScratch; //used for various purposes; non-persistent
nsCString mMimeType;
nsNodeAllocator mNodeAllocator;
nsDTDMode mDTDMode;
eParserDocType mDocType;
eParserCommands mParserCommand; //tells us to viewcontent/viewsource/viewerrors...
eHTMLTags mSkipTarget;
PRInt32 mLineNumber;
PRInt32 mOpenMapCount;
PRUint16 mFlags;
#ifdef ENABLE_CRC
PRUint32 mComputedCRC32;
PRUint32 mExpectedCRC32;
#endif
};
inline nsresult NS_NewNavHTMLDTD(nsIDTD** aInstancePtrResult)
{
NS_DEFINE_CID(kNavDTDCID, NS_CNAVDTD_CID);
return nsComponentManager::CreateInstance(kNavDTDCID,
nsnull,
NS_GET_IID(nsIDTD),
(void**)aInstancePtrResult);
}
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,208 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* 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/
*
* 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.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
/**
* MODULE NOTES:
* @update gess 7/15/98
*
* NavDTD is an implementation of the nsIDTD interface.
* In particular, this class captures the behaviors of the original
* Navigator parser productions.
*
* This DTD, like any other in NGLayout, provides a few basic services:
* - First, the DTD collaborates with the Parser class to convert plain
* text into a sequence of HTMLTokens.
* - Second, the DTD describes containment rules for known elements.
* - Third the DTD controls and coordinates the interaction between the
* parsing system and content sink. (The content sink is the interface
* that serves as a proxy for content model).
* - Fourth the DTD maintains an internal style-stack to handle residual (leaky)
* style tags.
*
* You're most likely working in this class file because
* you want to add or change a behavior inherent in this DTD. The remainder
* of this section will describe what you need to do to affect the kind of
* change you want in this DTD.
*
* RESIDUAL-STYLE HANDLNG:
* There are a number of ways to represent style in an HTML document.
* 1) explicit style tags (<B>, <I> etc)
* 2) implicit styles (like those implicit in <Hn>)
* 3) CSS based styles
*
* Residual style handling results from explicit style tags that are
* not closed. Consider this example: <p>text <b>bold </p>
* When the <p> tag closes, the <b> tag is NOT automatically closed.
* Unclosed style tags are handled by the process we call residual-style
* tag handling.
*
* There are two aspects to residual style tag handling. The first is the
* construction and managing of a stack of residual style tags. The
* second is the automatic emission of residual style tags onto leaf content
* in subsequent portions of the document.This step is necessary to propagate
* the expected style behavior to subsequent portions of the document.
*
* Construction and managing the residual style stack is an inline process that
* occurs during the model building phase of the parse process. During the model-
* building phase of the parse process, a content stack is maintained which tracks
* the open container hierarchy. If a style tag(s) fails to be closed when a normal
* container is closed, that style tag is placed onto the residual style stack. If
* that style tag is subsequently closed (in most contexts), it is popped off the
* residual style stack -- and are of no further concern.
*
* Residual style tag emission occurs when the style stack is not empty, and leaf
* content occurs. In our earlier example, the <b> tag "leaked" out of the <p>
* container. Just before the next leaf is emitted (in this or another container) the
* style tags that are on the stack are emitted in succession. These same residual
* style tags get closed automatically when the leaf's container closes, or if a
* child container is opened.
*
*
*/
#ifndef NS_OTHERDTD__
#define NS_OTHERDTD__
#include "nsIDTD.h"
#include "nsISupports.h"
#include "nsIParser.h"
#include "nsHTMLTokens.h"
#include "nsVoidArray.h"
#include "nsDeque.h"
#include "nsParserCIID.h"
#define NS_IOTHERHTML_DTD_IID \
{0x8a5e89c0, 0xd16d, 0x11d1, \
{0x80, 0x22, 0x00, 0x60, 0x8, 0x14, 0x98, 0x89}}
class nsIHTMLContentSink;
class nsIParserNode;
class nsParser;
class nsDTDContext;
class nsEntryStack;
class nsITokenizer;
class nsIParserNode;
class nsTokenAllocator;
class nsNodeAllocator;
/***************************************************************
Now the main event: COtherDTD.
This not so simple class performs all the duties of token
construction and model building. It works in conjunction with
an nsParser.
***************************************************************/
#ifdef _MSC_VER
#pragma warning( disable : 4275 )
#endif
class COtherDTD : public nsIDTD
{
#ifdef _MSC_VER
#pragma warning( default : 4275 )
#endif
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIDTD
/**
* Common constructor for navdtd. You probably want to call
* NS_NewNavHTMLDTD().
*
* @update gess 7/9/98
*/
COtherDTD();
/**
* Virtual destructor -- you know what to do
* @update gess 7/9/98
*/
virtual ~COtherDTD();
/**
* The following set of methods are used to partially construct
* the content model (via the sink) according to the type of token.
* @update gess5/11/98
* @param aToken is the token (of a given type) to be handled
* @return error code representing construction state; usually 0.
*/
nsresult HandleStartToken(CToken* aToken);
nsresult HandleEndToken(CToken* aToken);
nsresult HandleEntityToken(CToken* aToken);
//*************************************************
//these cover methods mimic the sink, and are used
//by the parser to manage its context-stack.
//*************************************************
protected:
nsresult CollectAttributes(nsIParserNode& aNode,eHTMLTags aTag,PRInt32 aCount);
nsresult WillHandleStartTag(CToken* aToken,eHTMLTags aTag,nsIParserNode& aNode);
nsresult DidHandleStartTag(nsIParserNode& aNode,eHTMLTags aChildTag);
nsIParserNode* CreateNode(CToken* aToken=nsnull,PRInt32 aLineNumber=1,nsTokenAllocator* aTokenAllocator=0);
nsIHTMLContentSink* mSink;
nsDTDContext* mBodyContext;
PRInt32 mHasOpenHead;
PRPackedBool mHasOpenForm;
PRPackedBool mHasOpenMap;
PRPackedBool mHasOpenBody;
PRPackedBool mHadFrameset;
PRPackedBool mHadBody;
PRPackedBool mHasOpenScript;
PRPackedBool mEnableStrict;
nsString mFilename;
PRInt32 mLineNumber;
nsParser* mParser;
nsITokenizer* mTokenizer; // weak
nsTokenAllocator* mTokenAllocator;
nsNodeAllocator* mNodeAllocator;
eHTMLTags mSkipTarget;
nsresult mDTDState;
nsDTDMode mDTDMode;
eParserCommands mParserCommand; //tells us to viewcontent/viewsource/viewerrors...
PRUint32 mComputedCRC32;
PRUint32 mExpectedCRC32;
nsString mScratch; //used for various purposes; non-persistent
eParserDocType mDocType;
};
extern nsresult NS_NewOtherHTMLDTD(nsIDTD** aInstancePtrResult);
class CTransitionalDTD : public COtherDTD
{
public:
CTransitionalDTD();
virtual ~CTransitionalDTD();
};
#endif //NS_OTHERDTD__

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,191 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* 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/
*
* 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.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsIAtom.h"
#include "CParserContext.h"
#include "nsToken.h"
#include "prenv.h"
#include "nsHTMLTokenizer.h"
#include "nsExpatDriver.h"
MOZ_DECL_CTOR_COUNTER(CParserContext)
/**
* Your friendly little constructor. Ok, it's not the friendly, but the only guy
* using it is the parser.
* @update gess7/23/98
* @param aScanner
* @param aKey
* @param aListener
*/
CParserContext::CParserContext(nsScanner* aScanner,
void *aKey,
eParserCommands aCommand,
nsIRequestObserver* aListener,
nsIDTD *aDTD,
eAutoDetectResult aStatus,
PRBool aCopyUnused)
{
MOZ_COUNT_CTOR(CParserContext);
mScanner=aScanner;
mKey=aKey;
mPrevContext=0;
mListener=aListener;
NS_IF_ADDREF(mListener);
mDTDMode=eDTDMode_unknown;
mAutoDetectStatus=aStatus;
mTransferBuffer=0;
mDTD=aDTD;
NS_IF_ADDREF(mDTD);
mTokenizer = 0;
mTransferBufferSize=eTransferBufferSize;
mStreamListenerState=eNone;
mMultipart=PR_TRUE;
mContextType=eCTNone;
mCopyUnused=aCopyUnused;
mParserCommand=aCommand;
mRequest=0;
}
/**
* Your friendly little constructor. Ok, it's not the friendly, but the only guy
* using it is the parser.
* @update gess7/23/98
* @param aScanner
* @param aKey
* @param aListener
*/
CParserContext::CParserContext(const CParserContext &aContext) : mMimeType() {
MOZ_COUNT_CTOR(CParserContext);
mScanner=aContext.mScanner;
mKey=aContext.mKey;
mPrevContext=0;
mListener=aContext.mListener;
NS_IF_ADDREF(mListener);
mDTDMode=aContext.mDTDMode;
mAutoDetectStatus=aContext.mAutoDetectStatus;
mTransferBuffer=aContext.mTransferBuffer;
mDTD=aContext.mDTD;
NS_IF_ADDREF(mDTD);
mTokenizer = aContext.mTokenizer;
NS_IF_ADDREF(mTokenizer);
mTransferBufferSize=eTransferBufferSize;
mStreamListenerState=aContext.mStreamListenerState;
mMultipart=aContext.mMultipart;
mContextType=aContext.mContextType;
mRequest=aContext.mRequest;
mParserCommand=aContext.mParserCommand;
SetMimeType(aContext.mMimeType);
}
/**
* Destructor for parser context
* NOTE: DO NOT destroy the dtd here.
* @update gess7/11/98
*/
CParserContext::~CParserContext(){
MOZ_COUNT_DTOR(CParserContext);
if(mScanner) {
delete mScanner;
mScanner=nsnull;
}
if(mTransferBuffer)
delete [] mTransferBuffer;
NS_IF_RELEASE(mDTD);
NS_IF_RELEASE(mListener);
NS_IF_RELEASE(mTokenizer);
//Remember that it's ok to simply ingore the PrevContext.
}
/**
* Set's the mimetype for this context
* @update rickg 03.18.2000
*/
void CParserContext::SetMimeType(const nsACString& aMimeType){
mMimeType.Assign(aMimeType);
mDocType=ePlainText;
if(mMimeType.Equals(NS_LITERAL_CSTRING(kHTMLTextContentType)))
mDocType=eHTML_Strict;
else if (mMimeType.Equals(NS_LITERAL_CSTRING(kXMLTextContentType)) ||
mMimeType.Equals(NS_LITERAL_CSTRING(kXMLApplicationContentType)) ||
mMimeType.Equals(NS_LITERAL_CSTRING(kXHTMLApplicationContentType)) ||
mMimeType.Equals(NS_LITERAL_CSTRING(kXULTextContentType)) ||
#ifdef MOZ_SVG
mMimeType.Equals(NS_LITERAL_CSTRING(kSVGTextContentType)) ||
#endif
mMimeType.Equals(NS_LITERAL_CSTRING(kRDFTextContentType)))
mDocType=eXML;
}
nsresult
CParserContext::GetTokenizer(PRInt32 aType, nsITokenizer*& aTokenizer) {
nsresult result = NS_OK;
if(!mTokenizer) {
if (aType == NS_IPARSER_FLAG_HTML || mParserCommand == eViewSource) {
result = NS_NewHTMLTokenizer(&mTokenizer,mDTDMode,mDocType,mParserCommand);
// Propagate tokenizer state so that information is preserved
// between document.write. This fixes bug 99467
if (mTokenizer && mPrevContext)
mTokenizer->CopyState(mPrevContext->mTokenizer);
}
else if (aType == NS_IPARSER_FLAG_XML)
{
result = CallQueryInterface(mDTD, &mTokenizer);
}
}
aTokenizer = mTokenizer;
return result;
}

View File

@@ -0,0 +1,111 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* 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/
*
* 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.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/**
* MODULE NOTES:
* @update gess 4/1/98
*
*/
#ifndef __CParserContext
#define __CParserContext
#include "nsIParser.h"
#include "nsIURL.h"
#include "nsIDTD.h"
#include "nsIStreamListener.h"
#include "nsIRequest.h"
#include "nsScanner.h"
#include "nsString.h"
#include "nsCOMPtr.h"
/**
* Note that the parser is given FULL access to all
* data in a parsercontext. Hey, that what it's for!
*/
class CParserContext {
public:
enum {eTransferBufferSize=4096};
enum eContextType {eCTNone,eCTURL,eCTString,eCTStream};
CParserContext( nsScanner* aScanner,
void* aKey=0,
eParserCommands aCommand=eViewNormal,
nsIRequestObserver* aListener=0,
nsIDTD *aDTD=0,
eAutoDetectResult aStatus=eUnknownDetect,
PRBool aCopyUnused=PR_FALSE);
CParserContext( const CParserContext& aContext);
~CParserContext();
nsresult GetTokenizer(PRInt32 aType, nsITokenizer*& aTokenizer);
void SetMimeType(const nsACString& aMimeType);
nsCOMPtr<nsIRequest> mRequest; // provided by necko to differnciate different input streams
// why is mRequest strongly referenced? see bug 102376.
nsIDTD* mDTD;
nsIRequestObserver* mListener;
char* mTransferBuffer;
void* mKey;
nsITokenizer* mTokenizer;
CParserContext* mPrevContext;
nsScanner* mScanner;
nsCString mMimeType;
nsDTDMode mDTDMode;
eParserDocType mDocType;
eStreamState mStreamListenerState; //this is really only here for debug purposes.
eContextType mContextType;
eAutoDetectResult mAutoDetectStatus;
eParserCommands mParserCommand; //tells us to viewcontent/viewsource/viewerrors...
PRPackedBool mMultipart;
PRPackedBool mCopyUnused;
PRUint32 mTransferBufferSize;
};
#endif

View File

@@ -0,0 +1,103 @@
# 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/
#
# 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.
#
# The Original Code is mozilla.org code.
#
# The Initial Developer of the Original Code is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s):
#
DEPTH = ../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
MODULE = htmlparser
LIBRARY_NAME = htmlpars
EXPORT_LIBRARY = 1
IS_COMPONENT = 1
MODULE_NAME = nsParserModule
SHORT_LIBNAME = gkparser
GRE_MODULE = 1
PACKAGE_FILE = parser.pkg
REQUIRES = xpcom \
string \
necko \
util \
uconv \
unicharutil \
expat \
layout \
dom \
pref \
nkcache \
intl \
$(NULL)
SHARED_LIBRARY_LIBS = \
$(DIST)/lib/$(LIB_PREFIX)expat_s.$(LIB_SUFFIX) \
$(DIST)/lib/$(LIB_PREFIX)xmltok_s.$(LIB_SUFFIX) \
$(NULL)
ifdef MOZ_PERF_METRICS
EXTRA_DSO_LIBS += mozutil_s
endif
CPPSRCS = \
nsScannerString.cpp \
nsDTDUtils.cpp \
nsHTMLTokenizer.cpp \
nsElementTable.cpp \
nsExpatDriver.cpp \
CNavDTD.cpp \
COtherDTD.cpp \
nsHTMLEntities.cpp \
nsHTMLTags.cpp \
nsHTMLTokens.cpp \
nsParser.cpp \
CParserContext.cpp \
nsParserService.cpp \
nsParserModule.cpp \
nsParserNode.cpp \
nsScanner.cpp \
nsToken.cpp \
nsParserMsgUtils.cpp\
$(NULL)
ifdef MOZ_VIEW_SOURCE
CPPSRCS += \
nsViewSourceHTML.cpp \
$(NULL)
endif
ifdef MOZ_DEBUG
CPPSRCS += \
nsLoggingSink.cpp \
$(NULL)
endif
EXTRA_DSO_LDOPTS += \
$(LIBS_DIR) \
$(EXTRA_DSO_LIBS) \
$(MOZ_UNICHARUTIL_LIBS) \
$(MOZ_COMPONENT_LIBS) \
$(NULL)
include $(topsrcdir)/config/rules.mk
DEFINES += -DXML_DTD

View File

@@ -0,0 +1,2 @@
en-US.jar:
locale/en-US/communicator/layout/xmlparser.properties

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,657 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* 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/
*
* 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.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/**
* MODULE NOTES:
* @update gess 4/1/98
*
*/
#ifndef DTDUTILS_
#define DTDUTILS_
#include "nsHTMLTags.h"
#include "nsHTMLTokens.h"
#include "nsIParser.h"
#include "nsCRT.h"
#include "nsDeque.h"
#include "nsIDTD.h"
#include "nsITokenizer.h"
#include "nsString.h"
#include "nsIParserNode.h"
#include "nsFixedSizeAllocator.h"
#include "nsVoidArray.h"
#include "nsIParserService.h"
#include "nsReadableUtils.h"
#define IF_HOLD(_ptr) \
PR_BEGIN_MACRO \
if(_ptr) { \
_ptr->AddRef(); \
} \
PR_END_MACRO
// recycles _ptr
#define IF_FREE(_ptr, _allocator) \
PR_BEGIN_MACRO \
if(_ptr && _allocator) { \
_ptr->Release((_allocator)->GetArenaPool()); \
_ptr=0; \
} \
PR_END_MACRO
// release objects and destroy _ptr
#define IF_DELETE(_ptr, _allocator) \
PR_BEGIN_MACRO \
if(_ptr) { \
_ptr->ReleaseAll(_allocator); \
delete(_ptr); \
_ptr=0; \
} \
PR_END_MACRO
class nsIParserNode;
class nsCParserNode;
class nsNodeAllocator;
#ifdef DEBUG
void DebugDumpContainmentRules(nsIDTD& theDTD,const char* aFilename,const char* aTitle);
void DebugDumpContainmentRules2(nsIDTD& theDTD,const char* aFilename,const char* aTitle);
#endif
PRUint32 AccumulateCRC(PRUint32 crc_accum, char *data_blk_ptr, int data_blk_size);
/***************************************************************
First, define the tagstack class
***************************************************************/
class nsEntryStack; //forware declare to make compilers happy.
struct nsTagEntry {
nsTagEntry ()
: mTag(eHTMLTag_unknown), mNode(0), mParent(0), mStyles(0){}
eHTMLTags mTag; //for speedier access to tag id
nsCParserNode* mNode;
nsEntryStack* mParent;
nsEntryStack* mStyles;
};
class nsEntryStack {
public:
nsEntryStack();
~nsEntryStack();
nsTagEntry* PopEntry();
void PushEntry(nsTagEntry* aEntry, PRBool aRefCntNode = PR_TRUE);
void EnsureCapacityFor(PRInt32 aNewMax, PRInt32 aShiftOffset=0);
void Push(nsCParserNode* aNode,nsEntryStack* aStyleStack=0, PRBool aRefCntNode = PR_TRUE);
void PushFront(nsCParserNode* aNode,nsEntryStack* aStyleStack=0, PRBool aRefCntNode = PR_TRUE);
void Append(nsEntryStack *aStack);
nsCParserNode* Pop(void);
nsCParserNode* Remove(PRInt32 anIndex,eHTMLTags aTag);
nsCParserNode* NodeAt(PRInt32 anIndex) const;
eHTMLTags First() const;
eHTMLTags TagAt(PRInt32 anIndex) const;
nsTagEntry* EntryAt(PRInt32 anIndex) const;
eHTMLTags operator[](PRInt32 anIndex) const;
eHTMLTags Last() const;
void Empty(void);
/*
* Release all objects in the entry stack
*/
void ReleaseAll(nsNodeAllocator* aNodeAllocator);
/**
* Find the first instance of given tag on the stack.
* @update gess 12/14/99
* @param aTag
* @return index of tag, or kNotFound if not found
*/
inline PRInt32 FirstOf(eHTMLTags aTag) const {
PRInt32 index=-1;
if(0<mCount) {
while(++index<mCount) {
if(aTag==mEntries[index].mTag) {
return index;
}
} //while
}
return kNotFound;
}
/**
* Find the last instance of given tag on the stack.
* @update gess 12/14/99
* @param aTag
* @return index of tag, or kNotFound if not found
*/
inline PRInt32 LastOf(eHTMLTags aTag) const {
PRInt32 index=mCount;
while(--index>=0) {
if(aTag==mEntries[index].mTag) {
return index;
}
}
return kNotFound;
}
nsTagEntry* mEntries;
PRInt32 mCount;
PRInt32 mCapacity;
};
/**********************************************************
The table state class is used to store info about each
table that is opened on the stack. As tables open and
close on the context, we update these objects to track
what has/hasn't been seen on a per table basis.
**********************************************************/
class CTableState {
public:
CTableState(CTableState *aPreviousState=0) {
mHasCaption=PR_FALSE;
mHasCols=PR_FALSE;
mHasTHead=PR_FALSE;
mHasTFoot=PR_FALSE;
mHasTBody=PR_FALSE;
mPrevious=aPreviousState;
}
PRBool CanOpenCaption() {
PRBool result=!(mHasCaption || mHasCols || mHasTHead || mHasTFoot || mHasTBody);
return result;
}
PRBool CanOpenCols() {
PRBool result=!(mHasCols || mHasTHead || mHasTFoot || mHasTBody);
return result;
}
PRBool CanOpenTBody() {
PRBool result=!(mHasTBody);
return result;
}
PRBool CanOpenTHead() {
PRBool result=!(mHasTHead || mHasTFoot || mHasTBody);
return result;
}
PRBool CanOpenTFoot() {
PRBool result=!(mHasTFoot || mHasTBody);
return result;
}
PRPackedBool mHasCaption;
PRPackedBool mHasCols;
PRPackedBool mHasTHead;
PRPackedBool mHasTFoot;
PRPackedBool mHasTBody;
CTableState *mPrevious;
};
#ifdef DEBUG
//used for named entities and counters (XXX debug only)
class CNamedEntity {
public:
CNamedEntity(const nsAString& aName,const nsAString& aValue) : mName(), mValue() {
PRUnichar theFirst=aName.First();
PRUnichar theLast=aName.Last();
PRInt32 theLen=aName.Length();
if((2<theLen) && (theFirst==theLast) && (kQuote==theFirst)) {
mName = Substring(aName, 1, theLen - 2);
}
else mName=aName;
theFirst=aValue.First();
theLast=aValue.Last();
theLen=aValue.Length();
if((2<theLen) && (theFirst==theLast) && (kQuote==theFirst)) {
mValue = Substring(aValue, 1, theLen - 2);
}
else mValue=aValue;
}
nsString mName;
nsString mValue;
PRInt32 mOrdinal;
};
#endif
/************************************************************************
nsTokenAllocator class implementation.
This class is used to recycle tokens.
By using this simple class, we cut WAY down on the number of tokens
that get created during the run of the system.
Note: The allocator is created per document. It's been shared
( but not ref. counted ) by objects, tokenizer,dtd,and dtd context,
that cease to exist when the document is destroyed.
************************************************************************/
class nsTokenAllocator {
public:
nsTokenAllocator();
virtual ~nsTokenAllocator();
virtual CToken* CreateTokenOfType(eHTMLTokenTypes aType,eHTMLTags aTag, const nsAString& aString);
virtual CToken* CreateTokenOfType(eHTMLTokenTypes aType,eHTMLTags aTag);
nsFixedSizeAllocator& GetArenaPool() { return mArenaPool; }
protected:
nsFixedSizeAllocator mArenaPool;
#ifdef NS_DEBUG
int mTotals[eToken_last-1];
#endif
};
/************************************************************************
CNodeRecycler class implementation.
This class is used to recycle nodes.
By using this simple class, we cut down on the number of nodes
that get created during the run of the system.
************************************************************************/
#ifndef HEAP_ALLOCATED_NODES
class nsCParserNode;
#endif
class nsNodeAllocator {
public:
nsNodeAllocator();
virtual ~nsNodeAllocator();
virtual nsCParserNode* CreateNode(CToken* aToken=nsnull, nsTokenAllocator* aTokenAllocator=0);
nsFixedSizeAllocator& GetArenaPool() { return mNodePool; }
#ifdef HEAP_ALLOCATED_NODES
void Recycle(nsCParserNode* aNode) { mSharedNodes.Push(NS_STATIC_CAST(void*,aNode)); }
protected:
nsDeque mSharedNodes;
#ifdef DEBUG_TRACK_NODES
PRInt32 mCount;
#endif
#endif
protected:
nsFixedSizeAllocator mNodePool;
};
/************************************************************************
The dtdcontext class defines an ordered list of tags (a context).
************************************************************************/
class nsDTDContext {
public:
nsDTDContext();
~nsDTDContext();
nsTagEntry* PopEntry();
void PushEntry(nsTagEntry* aEntry, PRBool aRefCntNode = PR_TRUE);
void MoveEntries(nsDTDContext& aDest, PRInt32 aCount);
void Push(nsCParserNode* aNode,nsEntryStack* aStyleStack=0, PRBool aRefCntNode = PR_TRUE);
nsCParserNode* Pop(nsEntryStack*& aChildStack);
nsCParserNode* Pop();
nsCParserNode* PeekNode() { return mStack.NodeAt(mStack.mCount-1); }
eHTMLTags First(void) const;
eHTMLTags Last(void) const;
nsTagEntry* LastEntry(void) const;
eHTMLTags TagAt(PRInt32 anIndex) const;
eHTMLTags operator[](PRInt32 anIndex) const {return TagAt(anIndex);}
PRBool HasOpenContainer(eHTMLTags aTag) const;
PRInt32 FirstOf(eHTMLTags aTag) const {return mStack.FirstOf(aTag);}
PRInt32 LastOf(eHTMLTags aTag) const {return mStack.LastOf(aTag);}
void Empty(void);
PRInt32 GetCount(void) {return mStack.mCount;}
PRInt32 GetResidualStyleCount(void) {return mResidualStyleCount;}
nsEntryStack* GetStylesAt(PRInt32 anIndex) const;
void PushStyle(nsCParserNode* aNode);
void PushStyles(nsEntryStack *aStyles);
nsCParserNode* PopStyle(void);
nsCParserNode* PopStyle(eHTMLTags aTag);
void RemoveStyle(eHTMLTags aTag);
static void ReleaseGlobalObjects(void);
void SetTokenAllocator(nsTokenAllocator* aTokenAllocator) { mTokenAllocator=aTokenAllocator; }
void SetNodeAllocator(nsNodeAllocator* aNodeAllocator) { mNodeAllocator=aNodeAllocator; }
nsEntryStack mStack; //this will hold a list of tagentries...
PRInt32 mResidualStyleCount;
PRInt32 mContextTopIndex;
//break this struct out separately so that lame compilers don't gack.
//By using these bits instead of bools, we have a bit-o-memory.
struct CFlags {
PRUint8 mHadBody:1;
PRUint8 mHadFrameset:1;
PRUint8 mHasOpenHead:1;
PRUint8 mTransitional:1;
};
union {
PRUint32 mAllBits;
CFlags mFlags;
};
nsTokenAllocator *mTokenAllocator;
nsNodeAllocator *mNodeAllocator;
CTableState *mTableStates;
nsDeque mEntities;
#ifdef NS_DEBUG
enum { eMaxTags = 100 };
eHTMLTags mXTags[eMaxTags];
PRInt32 *mCounters;
void ResetCounters(void);
void AllocateCounters(void);
PRInt32 IncrementCounter(eHTMLTags aTag,nsIParserNode& aNode,nsString& aResult);
CNamedEntity* RegisterEntity(const nsAString& aName,const nsAString& aValue);
CNamedEntity* GetEntity(const nsAString& aName) const;
#endif
};
/**************************************************************
Now define the token deallocator class...
**************************************************************/
class CTokenDeallocator: public nsDequeFunctor{
protected:
nsFixedSizeAllocator& mArenaPool;
public:
CTokenDeallocator(nsFixedSizeAllocator& aArenaPool)
: mArenaPool(aArenaPool) {}
virtual void* operator()(void* anObject) {
CToken* aToken = (CToken*)anObject;
CToken::Destroy(aToken, mArenaPool);
return 0;
}
};
/************************************************************************
ITagHandler class offers an API for taking care of specific tokens.
************************************************************************/
class nsITagHandler {
public:
virtual void SetString(const nsString &aTheString)=0;
virtual nsString* GetString()=0;
virtual PRBool HandleToken(CToken* aToken,nsIDTD* aDTD)=0;
virtual PRBool HandleCapturedTokens(CToken* aToken,nsIDTD* aDTD)=0;
};
/************************************************************************
Here are a few useful utility methods...
************************************************************************/
/**
* This method quickly scans the given set of tags,
* looking for the given tag.
* @update gess8/27/98
* @param aTag -- tag to be search for in set
* @param aTagSet -- set of tags to be searched
* @return
*/
inline PRInt32 IndexOfTagInSet(PRInt32 aTag,const eHTMLTags* aTagSet,PRInt32 aCount) {
const eHTMLTags* theEnd=aTagSet+aCount;
const eHTMLTags* theTag=aTagSet;
while(theTag<theEnd) {
if(aTag==*theTag) {
return theTag-aTagSet;
}
++theTag;
}
return kNotFound;
}
/**
* This method quickly scans the given set of tags,
* looking for the given tag.
* @update gess8/27/98
* @param aTag -- tag to be search for in set
* @param aTagSet -- set of tags to be searched
* @return
*/
inline PRBool FindTagInSet(PRInt32 aTag,const eHTMLTags *aTagSet,PRInt32 aCount) {
return PRBool(-1<IndexOfTagInSet(aTag,aTagSet,aCount));
}
/**
* Called from various DTD's to determine the type of data in the buffer...
* @update gess 06Jun2000
* @param aBuffer: contains a string with first block of html from source document
* @param aHasXMLFragment: tells us whether we detect XML in the buffer (based on PI)
* @return TRUE if we find HTML
*/
// This really doesn't need to be inline!
inline PRBool BufferContainsHTML(const nsString& aBuffer,
PRBool& aHasXMLFragment)
{
PRBool result=PR_FALSE;
aHasXMLFragment=PRBool(-1!=aBuffer.Find("<?XML",PR_TRUE,100));
PRInt32 theDocTypePos=aBuffer.Find("DOCTYPE",PR_TRUE,0,200);
if(-1!=theDocTypePos) {
PRInt32 theHTMLPos=aBuffer.Find("HTML",PR_TRUE,theDocTypePos+8,200);
if(-1==theHTMLPos) {
theHTMLPos=aBuffer.Find("ISO/IEC 15445",PR_TRUE,theDocTypePos+8,200);
if(-1==theHTMLPos) {
theHTMLPos=aBuffer.Find("HYPERTEXT MARKUP",PR_TRUE,theDocTypePos+8,200);
}
}
result=PRBool(-1!=theHTMLPos);
}
else {
//worst case scenario: let's look for a few HTML tags...
PRInt32 theCount = 0;
PRInt32 theTagCount = 0;
nsAString::const_iterator iter, end;
aBuffer.BeginReading(iter);
aBuffer.EndReading(end);
if (Distance(iter, end) > 200) {
end = iter;
end.advance(200);
}
for(theCount = 0; theCount < 5; ++theCount) {
if (!FindCharInReadable('<', iter, end)) {
break;
}
// we found what may be a start tag...
++iter; // step over the '<' character
nsAString::const_iterator tag_end(iter);
aBuffer.EndReading(end);
while (tag_end != end) {
const PRUnichar c = *tag_end;
if (c == ' ' || c == '>' || c == '"') {
break;
}
++tag_end;
}
nsHTMLTag theTag = nsHTMLTags::LookupTag(Substring(iter, tag_end));
if (theTag != eHTMLTag_userdefined) {
++theTagCount;
}
iter = tag_end;
}
// Claim HTML if we find at least 2 real html tags...
result = (2 <= theTagCount);
}
return result;
}
/******************************************************************************
This little structure is used to compute CRC32 values for our debug validator
******************************************************************************/
struct CRCStruct {
CRCStruct(eHTMLTags aTag,PRInt32 anOp) {mTag=aTag; mOperation=anOp;}
eHTMLTags mTag;
PRInt32 mOperation; //usually open or close
};
/**************************************************************
This defines the topic object used by the observer service.
The observerService uses a list of these, 1 per topic when
registering tags.
**************************************************************/
class nsObserverEntry : public nsIObserverEntry {
public:
NS_DECL_ISUPPORTS
nsObserverEntry(const nsAString& aString);
virtual ~nsObserverEntry();
NS_IMETHOD Notify(nsIParserNode* aNode,
nsIParser* aParser,
nsISupports* aWebShell,
const PRUint32 aFlags);
nsresult AddObserver(nsIElementObserver* aObserver,eHTMLTags aTag);
void RemoveObserver(nsIElementObserver* aObserver);
PRBool Matches(const nsAString& aTopic);
protected:
nsAutoString mTopic; // This will rarely be empty, so make it an auto string
nsVoidArray* mObservers[NS_HTML_TAG_MAX + 1];
friend class nsMatchesTopic;
};
/*********************************************************************************************/
struct TagList {
PRUint32 mCount;
const eHTMLTags *mTags;
};
/**
* Find the last member of given taglist on the given context
* @update gess 12/14/99
* @param aContext
* @param aTagList
* @return index of tag, or kNotFound if not found
*/
inline PRInt32 LastOf(nsDTDContext& aContext, const TagList& aTagList){
int max = aContext.GetCount();
int index;
for(index=max-1;index>=0;index--){
PRBool result=FindTagInSet(aContext[index],aTagList.mTags,aTagList.mCount);
if(result) {
return index;
}
}
return kNotFound;
}
/**
* Find the first member of given taglist on the given context
* @update gess 12/14/99
* @param aContext
* @param aStartOffset
* @param aTagList
* @return index of tag, or kNotFound if not found
*/
inline PRInt32 FirstOf(nsDTDContext& aContext,PRInt32 aStartOffset,TagList& aTagList){
int max = aContext.GetCount();
int index;
for(index=aStartOffset;index<max;++index){
PRBool result=FindTagInSet(aContext[index],aTagList.mTags,aTagList.mCount);
if(result) {
return index;
}
}
return kNotFound;
}
/**
* Call this to find out whether the DTD thinks the tag requires an END tag </xxx>
* @update gess 01/04/99
* @param id of tag
* @return TRUE of the element's end tag is optional
*/
inline PRBool HasOptionalEndTag(eHTMLTags aTag) {
static eHTMLTags gHasOptionalEndTags[]={eHTMLTag_body,eHTMLTag_colgroup,eHTMLTag_dd,eHTMLTag_dt,
eHTMLTag_head,eHTMLTag_li,eHTMLTag_option,
eHTMLTag_p,eHTMLTag_tbody,eHTMLTag_td,eHTMLTag_tfoot,
eHTMLTag_th,eHTMLTag_thead,eHTMLTag_tr,
eHTMLTag_userdefined,eHTMLTag_unknown};
return FindTagInSet(aTag,gHasOptionalEndTags,sizeof(gHasOptionalEndTags)/sizeof(eHTMLTag_body));
}
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,279 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* 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/
*
* 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.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/**
* MODULE NOTES:
* @update gess 4/1/98
*
*/
#ifndef _NSELEMENTABLE
#define _NSELEMENTABLE
#include "nsHTMLTokens.h"
#include "nsDTDUtils.h"
//*********************************************************************************************
// The following ints define the standard groups of HTML elements...
//*********************************************************************************************
static const int kNone= 0x0;
static const int kHTMLContent = 0x0001; // HEAD, (FRAMESET | BODY)
static const int kHeadContent = 0x0002; // TITLE, ISINDEX, BASE
static const int kHeadMisc = 0x0004; // SCRIPT, STYLE, META, LINK, OBJECT
static const int kSpecial = 0x0008; // A, IMG, APPLET, OBJECT, FONT, BASEFONT, BR, SCRIPT,
// MAP, Q, SUB, SUP, SPAN, BDO, IFRAME
static const int kFormControl = 0x0010; // INPUT SELECT TEXTAREA LABEL BUTTON
static const int kPreformatted = 0x0020; // PRE
static const int kPreExclusion = 0x0040; // IMG, OBJECT, APPLET, BIG, SMALL, SUB, SUP, FONT, BASEFONT
static const int kFontStyle = 0x0080; // TT, I, B, U, S, STRIKE, BIG, SMALL, BLINK
static const int kPhrase = 0x0100; // EM, STRONG, DFN, CODE, SAMP, KBD, VAR, CITE, ABBR, ACRONYM
static const int kHeading = 0x0200; // H1..H6
static const int kBlockMisc = 0x0400; // OBJECT, SCRIPT
static const int kBlock = 0x0800; // ADDRESS, BLOCKQUOTE, CENTER, DIV, DL, FIELDSET, FORM,
// ISINDEX, HR, NOSCRIPT, NOFRAMES, P, TABLE
static const int kList = 0x1000; // UL, OL, DIR, MENU
static const int kPCDATA = 0x2000; // plain text and entities...
static const int kSelf = 0x4000; // whatever THIS tag is...
static const int kExtensions = 0x8000; // BGSOUND, WBR, NOBR
static const int kTable = 0x10000;// TR,TD,THEAD,TBODY,TFOOT,CAPTION,TH
static const int kDLChild = 0x20000;// DL, DT
static const int kCDATA = 0x40000;// just plain text...
static const int kInlineEntity = (kPCDATA|kFontStyle|kPhrase|kSpecial|kFormControl|kExtensions); // #PCDATA, %fontstyle, %phrase, %special, %formctrl
static const int kBlockEntity = (kHeading|kList|kPreformatted|kBlock); // %heading, %list, %preformatted, %block
static const int kFlowEntity = (kBlockEntity|kInlineEntity); // %blockentity, %inlineentity
static const int kAllTags = 0xffffff;
//*********************************************************************************************
// The following ints define the standard groups of HTML elements...
//*********************************************************************************************
extern void InitializeElementTable(void);
extern void DeleteElementTable(void);
typedef PRBool (*ContainFunc)(eHTMLTags aTag,nsDTDContext &aContext);
/**
* We're asking the question: is aTest a member of bitset.
*
* @update gess 01/04/99
* @param
* @return TRUE or FALSE
*/
inline PRBool TestBits(int aBitset,int aTest) {
if(aTest) {
PRInt32 result=(aBitset & aTest);
return PRBool(result==aTest);
}
return PR_FALSE;
}
/**
*
* @update gess 01/04/99
* @param
* @return
*/
struct nsHTMLElement {
#ifdef DEBUG
static void DebugDumpMembership(const char* aFilename);
static void DebugDumpContainment(const char* aFilename,const char* aTitle);
static void DebugDumpContainType(const char* aFilename);
#endif
static PRBool IsInlineEntity(eHTMLTags aTag);
static PRBool IsFlowEntity(eHTMLTags aTag);
static PRBool IsBlockCloser(eHTMLTags aTag);
inline PRBool IsBlock(void) {
if((mTagID>=eHTMLTag_unknown) & (mTagID<=eHTMLTag_xmp)){
return TestBits(mParentBits,kBlock);
}
return PR_FALSE;
}
inline PRBool IsBlockEntity(void) {
if((mTagID>=eHTMLTag_unknown) & (mTagID<=eHTMLTag_xmp)){
return TestBits(mParentBits,kBlockEntity);
}
return PR_FALSE;
}
inline PRBool IsSpecialEntity(void) {
if((mTagID>=eHTMLTag_unknown) & (mTagID<=eHTMLTag_xmp)){
return TestBits(mParentBits,kSpecial);
}
return PR_FALSE;
}
inline PRBool IsPhraseEntity(void) {
if((mTagID>=eHTMLTag_unknown) & (mTagID<=eHTMLTag_xmp)){
return TestBits(mParentBits,kPhrase);
}
return PR_FALSE;
}
inline PRBool IsFontStyleEntity(void) {
if((mTagID>=eHTMLTag_unknown) & (mTagID<=eHTMLTag_xmp)){
return TestBits(mParentBits,kFontStyle);
}
return PR_FALSE;
}
inline PRBool IsTableElement(void) { //return yes if it's a table or child of a table...
PRBool result=PR_FALSE;
switch(mTagID) {
case eHTMLTag_table:
case eHTMLTag_thead:
case eHTMLTag_tbody:
case eHTMLTag_tfoot:
case eHTMLTag_caption:
case eHTMLTag_tr:
case eHTMLTag_td:
case eHTMLTag_th:
case eHTMLTag_col:
case eHTMLTag_colgroup:
result=PR_TRUE;
break;
default:
result=PR_FALSE;
}
return result;
}
static int GetSynonymousGroups(eHTMLTags aTag);
static PRInt32 GetIndexOfChildOrSynonym(nsDTDContext& aContext,eHTMLTags aChildTag);
const TagList* GetSynonymousTags(void) const {return mSynonymousTags;}
const TagList* GetRootTags(void) const {return mRootNodes;}
const TagList* GetEndRootTags(void) const {return mEndRootNodes;}
const TagList* GetAutoCloseStartTags(void) const {return mAutocloseStart;}
const TagList* GetAutoCloseEndTags(void) const {return mAutocloseEnd;}
eHTMLTags GetCloseTargetForEndTag(nsDTDContext& aContext,PRInt32 anIndex,nsDTDMode aMode) const;
const TagList* GetSpecialChildren(void) const {return mSpecialKids;}
const TagList* GetSpecialParents(void) const {return mSpecialParents;}
PRBool IsMemberOf(PRInt32 aType) const;
PRBool ContainsSet(PRInt32 aType) const;
PRBool CanContainType(PRInt32 aType) const;
eHTMLTags GetTag(void) const {return mTagID;}
PRBool CanContain(eHTMLTags aChild,nsDTDMode aMode) const;
PRBool CanExclude(eHTMLTags aChild) const;
PRBool CanOmitStartTag(eHTMLTags aChild) const;
PRBool CanOmitEndTag(void) const;
PRBool CanContainSelf(void) const;
PRBool CanAutoCloseTag(nsDTDContext& aContext,eHTMLTags aTag) const;
PRBool HasSpecialProperty(PRInt32 aProperty) const;
PRBool IsSpecialParent(eHTMLTags aTag) const;
PRBool IsExcludableParent(eHTMLTags aParent) const;
PRBool SectionContains(eHTMLTags aTag,PRBool allowDepthSearch);
PRBool ShouldVerifyHierarchy();
PRBool CanBeContained(eHTMLTags aParentTag,nsDTDContext &aContext); //default version
static PRBool CanContain(eHTMLTags aParent,eHTMLTags aChild,nsDTDMode aMode);
static PRBool IsContainer(eHTMLTags aTag) ;
static PRBool IsResidualStyleTag(eHTMLTags aTag) ;
static PRBool IsTextTag(eHTMLTags aTag);
static PRBool IsWhitespaceTag(eHTMLTags aTag);
static PRBool IsBlockParent(eHTMLTags aTag);
static PRBool IsInlineParent(eHTMLTags aTag);
static PRBool IsFlowParent(eHTMLTags aTag);
static PRBool IsSectionTag(eHTMLTags aTag);
static PRBool IsChildOfHead(eHTMLTags aTag,PRBool& aExclusively) ;
eHTMLTags mTagID;
eHTMLTags mRequiredAncestor;
eHTMLTags mExcludingAncestor; //If set, the presence of the excl-ancestor prevents this from opening.
const TagList* mRootNodes; //These are the tags above which you many not autoclose a START tag
const TagList* mEndRootNodes; //These are the tags above which you many not autoclose an END tag
const TagList* mAutocloseStart; //these are the start tags that you can automatically close with this START tag
const TagList* mAutocloseEnd; //these are the start tags that you can automatically close with this END tag
const TagList* mSynonymousTags; //These are morally equivalent; an end tag for one can close a start tag for another (like <Hn>)
const TagList* mExcludableParents; //These are the TAGS that cannot contain you
int mParentBits; //defines groups that can contain this element
int mInclusionBits; //defines parental and containment rules
int mExclusionBits; //defines things you CANNOT contain
int mSpecialProperties; //used for various special purposes...
PRUint32 mPropagateRange; //tells us how far a parent is willing to prop. badly formed children
const TagList* mSpecialParents; //These are the special tags that contain this tag (directly)
const TagList* mSpecialKids; //These are the extra things you can contain
eHTMLTags mSkipTarget; //If set, then we skip all content until this tag is seen
ContainFunc mCanBeContained;
};
extern nsHTMLElement* gHTMLElements;
//special property bits...
static const int kDiscardTag = 0x0001; //tells us to toss this tag
static const int kOmitEndTag = 0x0002; //safely ignore end tag
static const int kLegalOpen = 0x0004; //Lets BODY, TITLE, SCRIPT to reopen
static const int kOmitWS = 0x0008; //If set, the tag can omit all ws and newlines
static const int kNoPropagate = 0x0010; //If set, this tag won't propagate as a child
static const int kBadContentWatch = 0x0020;
static const int kNoStyleLeaksIn = 0x0040;
static const int kNoStyleLeaksOut = 0x0080;
static const int kMustCloseSelf = 0x0100;
static const int kSaveMisplaced = 0x0200; //If set, then children this tag can't contain are pushed onto the misplaced stack
static const int kNonContainer = 0x0400; //If set, then this tag is not a container.
static const int kHandleStrayTag = 0x0800; //If set, we automatically open a start tag
static const int kRequiresBody = 0x1000; //If set, then in case of no BODY one will be opened up immediately.
static const int kVerifyHierarchy = 0x2000; //If set, check to see if the tag is a child or a sibling..
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,108 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* 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/
*
* 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.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef NS_EXPAT_DRIVER__
#define NS_EXPAT_DRIVER__
#include "xmlparse.h"
#include "nsString.h"
#include "nsIDTD.h"
#include "nsITokenizer.h"
#include "nsIInputStream.h"
class nsIExpatSink;
struct nsCatalogData;
class nsExpatDriver : public nsIDTD,
public nsITokenizer
{
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIDTD
NS_DECL_NSITOKENIZER
nsExpatDriver();
virtual ~nsExpatDriver();
int HandleExternalEntityRef(const PRUnichar *openEntityNames,
const PRUnichar *base,
const PRUnichar *systemId,
const PRUnichar *publicId);
nsresult HandleStartElement(const PRUnichar *aName, const PRUnichar **aAtts);
nsresult HandleEndElement(const PRUnichar *aName);
nsresult HandleCharacterData(const PRUnichar *aCData, const PRUint32 aLength);
nsresult HandleComment(const PRUnichar *aName);
nsresult HandleProcessingInstruction(const PRUnichar *aTarget, const PRUnichar *aData);
nsresult HandleXMLDeclaration(const PRUnichar *aData, const PRUint32 aLength);
nsresult HandleDefault(const PRUnichar *aData, const PRUint32 aLength);
nsresult HandleStartCdataSection();
nsresult HandleEndCdataSection();
nsresult HandleStartDoctypeDecl();
nsresult HandleEndDoctypeDecl();
protected:
// Load up an external stream to get external entity information
nsresult OpenInputStreamFromExternalDTD(const PRUnichar* aFPIStr,
const PRUnichar* aURLStr,
const PRUnichar* aBaseURL,
nsIInputStream** in,
nsAString& aAbsURL);
nsresult ParseBuffer(const char* aBuffer, PRUint32 aLength, PRBool aIsFinal);
nsresult HandleError(const char *aBuffer, PRUint32 aLength, PRBool aIsFinal);
void GetLine(const char* aSourceBuffer, PRUint32 aLength, PRUint32 aOffset, nsString& aLine);
XML_Parser mExpatParser;
nsString mLastLine;
nsString mCDataText;
nsString mDoctypeText;
PRPackedBool mInCData;
PRPackedBool mInDoctype;
PRPackedBool mInExternalDTD;
PRPackedBool mHandledXMLDeclaration;
PRInt32 mBytePosition;
nsresult mInternalState;
PRUint32 mBytesParsed;
nsIExpatSink* mSink;
const nsCatalogData* mCatalogData; // weak
};
nsresult NS_NewExpatDriver(nsIDTD** aDriver);
#endif

View File

@@ -0,0 +1,281 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* 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/
*
* 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.
*
* The Original Code is Mozilla Communicator client code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsHTMLEntities.h"
#include "nsString.h"
#include "nsCRT.h"
#include "prtypes.h"
#include "pldhash.h"
struct EntityNode {
const char* mStr; // never owns buffer
PRInt32 mUnicode;
};
struct EntityNodeEntry : public PLDHashEntryHdr
{
const EntityNode* node;
};
PR_STATIC_CALLBACK(const void*)
getStringKey(PLDHashTable*, PLDHashEntryHdr* aHdr)
{
const EntityNodeEntry* entry = NS_STATIC_CAST(const EntityNodeEntry*, aHdr);
return entry->node->mStr;
}
PR_STATIC_CALLBACK(const void*)
getUnicodeKey(PLDHashTable*, PLDHashEntryHdr* aHdr)
{
const EntityNodeEntry* entry = NS_STATIC_CAST(const EntityNodeEntry*, aHdr);
return NS_INT32_TO_PTR(entry->node->mUnicode);
}
PR_STATIC_CALLBACK(PRBool)
matchNodeString(PLDHashTable*, const PLDHashEntryHdr* aHdr,
const void* key)
{
const EntityNodeEntry* entry = NS_STATIC_CAST(const EntityNodeEntry*, aHdr);
const char* str = NS_STATIC_CAST(const char*, key);
return (nsCRT::strcmp(entry->node->mStr, str) == 0);
}
PR_STATIC_CALLBACK(PRBool)
matchNodeUnicode(PLDHashTable*, const PLDHashEntryHdr* aHdr,
const void* key)
{
const EntityNodeEntry* entry = NS_STATIC_CAST(const EntityNodeEntry*, aHdr);
const PRInt32 ucode = NS_PTR_TO_INT32(key);
return (entry->node->mUnicode == ucode);
}
PR_STATIC_CALLBACK(PLDHashNumber)
hashUnicodeValue(PLDHashTable*, const void* key)
{
// key is actually the unicode value
return PLDHashNumber(NS_PTR_TO_INT32(key));
}
static const PLDHashTableOps EntityToUnicodeOps = {
PL_DHashAllocTable,
PL_DHashFreeTable,
getStringKey,
PL_DHashStringKey,
matchNodeString,
PL_DHashMoveEntryStub,
PL_DHashClearEntryStub,
PL_DHashFinalizeStub,
nsnull,
};
static const PLDHashTableOps UnicodeToEntityOps = {
PL_DHashAllocTable,
PL_DHashFreeTable,
getUnicodeKey,
hashUnicodeValue,
matchNodeUnicode,
PL_DHashMoveEntryStub,
PL_DHashClearEntryStub,
PL_DHashFinalizeStub,
nsnull,
};
static PLDHashTable gEntityToUnicode = { 0 };
static PLDHashTable gUnicodeToEntity = { 0 };
static nsrefcnt gTableRefCnt = 0;
#define HTML_ENTITY(_name, _value) { #_name, _value },
static const EntityNode gEntityArray[] = {
#include "nsHTMLEntityList.h"
};
#undef HTML_ENTITY
#define NS_HTML_ENTITY_COUNT ((PRInt32)NS_ARRAY_LENGTH(gEntityArray))
nsresult
nsHTMLEntities::AddRefTable(void)
{
if (!gTableRefCnt) {
if (!PL_DHashTableInit(&gEntityToUnicode, &EntityToUnicodeOps,
nsnull, sizeof(EntityNodeEntry),
PRUint32(NS_HTML_ENTITY_COUNT / 0.75))) {
gEntityToUnicode.ops = nsnull;
return NS_ERROR_OUT_OF_MEMORY;
}
if (!PL_DHashTableInit(&gUnicodeToEntity, &UnicodeToEntityOps,
nsnull, sizeof(EntityNodeEntry),
PRUint32(NS_HTML_ENTITY_COUNT / 0.75))) {
PL_DHashTableFinish(&gEntityToUnicode);
gEntityToUnicode.ops = gUnicodeToEntity.ops = nsnull;
return NS_ERROR_OUT_OF_MEMORY;
}
for (const EntityNode *node = gEntityArray,
*node_end = gEntityArray + NS_ARRAY_LENGTH(gEntityArray);
node < node_end; ++node) {
// add to Entity->Unicode table
EntityNodeEntry* entry =
NS_STATIC_CAST(EntityNodeEntry*,
PL_DHashTableOperate(&gEntityToUnicode,
node->mStr,
PL_DHASH_ADD));
NS_ASSERTION(entry, "Error adding an entry");
// Prefer earlier entries when we have duplication.
if (!entry->node)
entry->node = node;
// add to Unicode->Entity table
entry = NS_STATIC_CAST(EntityNodeEntry*,
PL_DHashTableOperate(&gUnicodeToEntity,
NS_INT32_TO_PTR(node->mUnicode),
PL_DHASH_ADD));
NS_ASSERTION(entry, "Error adding an entry");
// Prefer earlier entries when we have duplication.
if (!entry->node)
entry->node = node;
}
}
++gTableRefCnt;
return NS_OK;
}
void
nsHTMLEntities::ReleaseTable(void)
{
if (--gTableRefCnt != 0)
return;
if (gEntityToUnicode.ops) {
PL_DHashTableFinish(&gEntityToUnicode);
gEntityToUnicode.ops = nsnull;
}
if (gUnicodeToEntity.ops) {
PL_DHashTableFinish(&gUnicodeToEntity);
gUnicodeToEntity.ops = nsnull;
}
}
PRInt32
nsHTMLEntities::EntityToUnicode(const nsCString& aEntity)
{
NS_ASSERTION(gEntityToUnicode.ops, "no lookup table, needs addref");
if (!gEntityToUnicode.ops)
return -1;
//this little piece of code exists because entities may or may not have the terminating ';'.
//if we see it, strip if off for this test...
if(';'==aEntity.Last()) {
nsCAutoString temp(aEntity);
temp.Truncate(aEntity.Length()-1);
return EntityToUnicode(temp);
}
EntityNodeEntry* entry =
NS_STATIC_CAST(EntityNodeEntry*,
PL_DHashTableOperate(&gEntityToUnicode, aEntity.get(), PL_DHASH_LOOKUP));
if (!entry || PL_DHASH_ENTRY_IS_FREE(entry))
return -1;
return entry->node->mUnicode;
}
PRInt32
nsHTMLEntities::EntityToUnicode(const nsAString& aEntity) {
nsCAutoString theEntity; theEntity.AssignWithConversion(aEntity);
if(';'==theEntity.Last()) {
theEntity.Truncate(theEntity.Length()-1);
}
return EntityToUnicode(theEntity);
}
const char*
nsHTMLEntities::UnicodeToEntity(PRInt32 aUnicode)
{
NS_ASSERTION(gUnicodeToEntity.ops, "no lookup table, needs addref");
EntityNodeEntry* entry =
NS_STATIC_CAST(EntityNodeEntry*,
PL_DHashTableOperate(&gUnicodeToEntity, NS_INT32_TO_PTR(aUnicode), PL_DHASH_LOOKUP));
if (!entry || PL_DHASH_ENTRY_IS_FREE(entry))
return nsnull;
return entry->node->mStr;
}
#ifdef NS_DEBUG
#include <stdio.h>
class nsTestEntityTable {
public:
nsTestEntityTable() {
PRInt32 value;
nsHTMLEntities::AddRefTable();
// Make sure we can find everything we are supposed to
for (int i = 0; i < NS_HTML_ENTITY_COUNT; ++i) {
nsAutoString entity; entity.AssignWithConversion(gEntityArray[i].mStr);
value = nsHTMLEntities::EntityToUnicode(entity);
NS_ASSERTION(value != -1, "can't find entity");
NS_ASSERTION(value == gEntityArray[i].mUnicode, "bad unicode value");
entity.AssignWithConversion(nsHTMLEntities::UnicodeToEntity(value));
NS_ASSERTION(entity.EqualsWithConversion(gEntityArray[i].mStr), "bad entity name");
}
// Make sure we don't find things that aren't there
value = nsHTMLEntities::EntityToUnicode(nsCAutoString("@"));
NS_ASSERTION(value == -1, "found @");
value = nsHTMLEntities::EntityToUnicode(nsCAutoString("zzzzz"));
NS_ASSERTION(value == -1, "found zzzzz");
nsHTMLEntities::ReleaseTable();
}
};
//nsTestEntityTable validateEntityTable;
#endif

View File

@@ -0,0 +1,68 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* 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/
*
* 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.
*
* The Original Code is Mozilla Communicator client code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsHTMLEntities_h___
#define nsHTMLEntities_h___
#include "nsString.h"
class nsHTMLEntities {
public:
static nsresult AddRefTable(void);
static void ReleaseTable(void);
/**
* Translate an entity string into it's unicode value. This call
* returns -1 if the entity cannot be mapped. Note that the string
* passed in must NOT have the leading "&" nor the trailing ";"
* in it.
*/
static PRInt32 EntityToUnicode(const nsAString& aEntity);
static PRInt32 EntityToUnicode(const nsCString& aEntity);
/**
* Translate a unicode value into an entity string. This call
* returns null if the entity cannot be mapped.
* Note that the string returned DOES NOT have the leading "&" nor
* the trailing ";" in it.
*/
static const char* UnicodeToEntity(PRInt32 aUnicode);
};
#endif /* nsHTMLEntities_h___ */

View File

@@ -0,0 +1,334 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* 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/
*
* 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.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1999
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/******
This file contains the list of all HTML entities
See nsHTMLEntities.h for access to the enum values for entities
It is designed to be used as inline input to nsHTMLEntities.cpp *only*
through the magic of C preprocessing.
All entires must be enclosed in the macro HTML_ENTITY which will have cruel
and unusual things done to it
It is recommended (but not strictly necessary) to keep all entries
in alphabetical order
The first argument to HTML_ENTITY is the string value of the entity
The second argument it HTML_ENTITY is the unicode value of the entity
******/
// ISO 8859-1 entities.
// See the HTML4.0 spec for this list in it's DTD form
HTML_ENTITY(nbsp, 160)
HTML_ENTITY(iexcl, 161)
HTML_ENTITY(cent, 162)
HTML_ENTITY(pound, 163)
HTML_ENTITY(curren, 164)
HTML_ENTITY(yen, 165)
HTML_ENTITY(brvbar, 166)
HTML_ENTITY(sect, 167)
HTML_ENTITY(uml, 168)
HTML_ENTITY(copy, 169)
HTML_ENTITY(ordf, 170)
HTML_ENTITY(laquo, 171)
HTML_ENTITY(not, 172)
HTML_ENTITY(shy, 173)
HTML_ENTITY(reg, 174)
HTML_ENTITY(macr, 175)
HTML_ENTITY(deg, 176)
HTML_ENTITY(plusmn, 177)
HTML_ENTITY(sup2, 178)
HTML_ENTITY(sup3, 179)
HTML_ENTITY(acute, 180)
HTML_ENTITY(micro, 181)
HTML_ENTITY(para, 182)
HTML_ENTITY(middot, 183)
HTML_ENTITY(cedil, 184)
HTML_ENTITY(sup1, 185)
HTML_ENTITY(ordm, 186)
HTML_ENTITY(raquo, 187)
HTML_ENTITY(frac14, 188)
HTML_ENTITY(frac12, 189)
HTML_ENTITY(frac34, 190)
HTML_ENTITY(iquest, 191)
HTML_ENTITY(Agrave, 192)
HTML_ENTITY(Aacute, 193)
HTML_ENTITY(Acirc, 194)
HTML_ENTITY(Atilde, 195)
HTML_ENTITY(Auml, 196)
HTML_ENTITY(Aring, 197)
HTML_ENTITY(AElig, 198)
HTML_ENTITY(Ccedil, 199)
HTML_ENTITY(Egrave, 200)
HTML_ENTITY(Eacute, 201)
HTML_ENTITY(Ecirc, 202)
HTML_ENTITY(Euml, 203)
HTML_ENTITY(Igrave, 204)
HTML_ENTITY(Iacute, 205)
HTML_ENTITY(Icirc, 206)
HTML_ENTITY(Iuml, 207)
HTML_ENTITY(ETH, 208)
HTML_ENTITY(Ntilde, 209)
HTML_ENTITY(Ograve, 210)
HTML_ENTITY(Oacute, 211)
HTML_ENTITY(Ocirc, 212)
HTML_ENTITY(Otilde, 213)
HTML_ENTITY(Ouml, 214)
HTML_ENTITY(times, 215)
HTML_ENTITY(Oslash, 216)
HTML_ENTITY(Ugrave, 217)
HTML_ENTITY(Uacute, 218)
HTML_ENTITY(Ucirc, 219)
HTML_ENTITY(Uuml, 220)
HTML_ENTITY(Yacute, 221)
HTML_ENTITY(THORN, 222)
HTML_ENTITY(szlig, 223)
HTML_ENTITY(agrave, 224)
HTML_ENTITY(aacute, 225)
HTML_ENTITY(acirc, 226)
HTML_ENTITY(atilde, 227)
HTML_ENTITY(auml, 228)
HTML_ENTITY(aring, 229)
HTML_ENTITY(aelig, 230)
HTML_ENTITY(ccedil, 231)
HTML_ENTITY(egrave, 232)
HTML_ENTITY(eacute, 233)
HTML_ENTITY(ecirc, 234)
HTML_ENTITY(euml, 235)
HTML_ENTITY(igrave, 236)
HTML_ENTITY(iacute, 237)
HTML_ENTITY(icirc, 238)
HTML_ENTITY(iuml, 239)
HTML_ENTITY(eth, 240)
HTML_ENTITY(ntilde, 241)
HTML_ENTITY(ograve, 242)
HTML_ENTITY(oacute, 243)
HTML_ENTITY(ocirc, 244)
HTML_ENTITY(otilde, 245)
HTML_ENTITY(ouml, 246)
HTML_ENTITY(divide, 247)
HTML_ENTITY(oslash, 248)
HTML_ENTITY(ugrave, 249)
HTML_ENTITY(uacute, 250)
HTML_ENTITY(ucirc, 251)
HTML_ENTITY(uuml, 252)
HTML_ENTITY(yacute, 253)
HTML_ENTITY(thorn, 254)
HTML_ENTITY(yuml, 255)
// Symbols, mathematical symbols and Greek letters
// See the HTML4.0 spec for this list in it's DTD form
HTML_ENTITY(fnof, 402)
HTML_ENTITY(Alpha, 913)
HTML_ENTITY(Beta, 914)
HTML_ENTITY(Gamma, 915)
HTML_ENTITY(Delta, 916)
HTML_ENTITY(Epsilon, 917)
HTML_ENTITY(Zeta, 918)
HTML_ENTITY(Eta, 919)
HTML_ENTITY(Theta, 920)
HTML_ENTITY(Iota, 921)
HTML_ENTITY(Kappa, 922)
HTML_ENTITY(Lambda, 923)
HTML_ENTITY(Mu, 924)
HTML_ENTITY(Nu, 925)
HTML_ENTITY(Xi, 926)
HTML_ENTITY(Omicron, 927)
HTML_ENTITY(Pi, 928)
HTML_ENTITY(Rho, 929)
HTML_ENTITY(Sigma, 931)
HTML_ENTITY(Tau, 932)
HTML_ENTITY(Upsilon, 933)
HTML_ENTITY(Phi, 934)
HTML_ENTITY(Chi, 935)
HTML_ENTITY(Psi, 936)
HTML_ENTITY(Omega, 937)
HTML_ENTITY(alpha, 945)
HTML_ENTITY(beta, 946)
HTML_ENTITY(gamma, 947)
HTML_ENTITY(delta, 948)
HTML_ENTITY(epsilon, 949)
HTML_ENTITY(zeta, 950)
HTML_ENTITY(eta, 951)
HTML_ENTITY(theta, 952)
HTML_ENTITY(iota, 953)
HTML_ENTITY(kappa, 954)
HTML_ENTITY(lambda, 955)
HTML_ENTITY(mu, 956)
HTML_ENTITY(nu, 957)
HTML_ENTITY(xi, 958)
HTML_ENTITY(omicron, 959)
HTML_ENTITY(pi, 960)
HTML_ENTITY(rho, 961)
HTML_ENTITY(sigmaf, 962)
HTML_ENTITY(sigma, 963)
HTML_ENTITY(tau, 964)
HTML_ENTITY(upsilon, 965)
HTML_ENTITY(phi, 966)
HTML_ENTITY(chi, 967)
HTML_ENTITY(psi, 968)
HTML_ENTITY(omega, 969)
HTML_ENTITY(thetasym, 977)
HTML_ENTITY(upsih, 978)
HTML_ENTITY(piv, 982)
HTML_ENTITY(bull, 8226)
HTML_ENTITY(hellip, 8230)
HTML_ENTITY(prime, 8242)
HTML_ENTITY(Prime, 8243)
HTML_ENTITY(oline, 8254)
HTML_ENTITY(frasl, 8260)
HTML_ENTITY(weierp, 8472)
HTML_ENTITY(image, 8465)
HTML_ENTITY(real, 8476)
HTML_ENTITY(trade, 8482)
HTML_ENTITY(alefsym, 8501)
HTML_ENTITY(larr, 8592)
HTML_ENTITY(uarr, 8593)
HTML_ENTITY(rarr, 8594)
HTML_ENTITY(darr, 8595)
HTML_ENTITY(harr, 8596)
HTML_ENTITY(crarr, 8629)
HTML_ENTITY(lArr, 8656)
HTML_ENTITY(uArr, 8657)
HTML_ENTITY(rArr, 8658)
HTML_ENTITY(dArr, 8659)
HTML_ENTITY(hArr, 8660)
HTML_ENTITY(forall, 8704)
HTML_ENTITY(part, 8706)
HTML_ENTITY(exist, 8707)
HTML_ENTITY(empty, 8709)
HTML_ENTITY(nabla, 8711)
HTML_ENTITY(isin, 8712)
HTML_ENTITY(notin, 8713)
HTML_ENTITY(ni, 8715)
HTML_ENTITY(prod, 8719)
HTML_ENTITY(sum, 8721)
HTML_ENTITY(minus, 8722)
HTML_ENTITY(lowast, 8727)
HTML_ENTITY(radic, 8730)
HTML_ENTITY(prop, 8733)
HTML_ENTITY(infin, 8734)
HTML_ENTITY(ang, 8736)
HTML_ENTITY(and, 8743)
HTML_ENTITY(or, 8744)
HTML_ENTITY(cap, 8745)
HTML_ENTITY(cup, 8746)
HTML_ENTITY(int, 8747)
HTML_ENTITY(there4, 8756)
HTML_ENTITY(sim, 8764)
HTML_ENTITY(cong, 8773)
HTML_ENTITY(asymp, 8776)
HTML_ENTITY(ne, 8800)
HTML_ENTITY(equiv, 8801)
HTML_ENTITY(le, 8804)
HTML_ENTITY(ge, 8805)
HTML_ENTITY(sub, 8834)
HTML_ENTITY(sup, 8835)
HTML_ENTITY(nsub, 8836)
HTML_ENTITY(sube, 8838)
HTML_ENTITY(supe, 8839)
HTML_ENTITY(oplus, 8853)
HTML_ENTITY(otimes, 8855)
HTML_ENTITY(perp, 8869)
HTML_ENTITY(sdot, 8901)
HTML_ENTITY(lceil, 8968)
HTML_ENTITY(rceil, 8969)
HTML_ENTITY(lfloor, 8970)
HTML_ENTITY(rfloor, 8971)
HTML_ENTITY(lang, 9001)
HTML_ENTITY(rang, 9002)
HTML_ENTITY(loz, 9674)
HTML_ENTITY(spades, 9824)
HTML_ENTITY(clubs, 9827)
HTML_ENTITY(hearts, 9829)
HTML_ENTITY(diams, 9830)
// Markup-significant and internationalization characters
// See the HTML4.0 spec for this list in it's DTD form
HTML_ENTITY(quot, 34)
HTML_ENTITY(amp, 38)
HTML_ENTITY(lt, 60)
HTML_ENTITY(gt, 62)
HTML_ENTITY(OElig, 338)
HTML_ENTITY(oelig, 339)
HTML_ENTITY(Scaron, 352)
HTML_ENTITY(scaron, 353)
HTML_ENTITY(Yuml, 376)
HTML_ENTITY(circ, 710)
HTML_ENTITY(tilde, 732)
HTML_ENTITY(ensp, 8194)
HTML_ENTITY(emsp, 8195)
HTML_ENTITY(thinsp, 8201)
HTML_ENTITY(zwnj, 8204)
HTML_ENTITY(zwj, 8205)
HTML_ENTITY(lrm, 8206)
HTML_ENTITY(rlm, 8207)
HTML_ENTITY(ndash, 8211)
HTML_ENTITY(mdash, 8212)
HTML_ENTITY(lsquo, 8216)
HTML_ENTITY(rsquo, 8217)
HTML_ENTITY(sbquo, 8218)
HTML_ENTITY(ldquo, 8220)
HTML_ENTITY(rdquo, 8221)
HTML_ENTITY(bdquo, 8222)
HTML_ENTITY(dagger, 8224)
HTML_ENTITY(Dagger, 8225)
HTML_ENTITY(permil, 8240)
HTML_ENTITY(lsaquo, 8249)
HTML_ENTITY(rsaquo, 8250)
HTML_ENTITY(euro, 8364)
// Navigator entity extensions
// This block of entities needs to be at the bottom of the list since it
// contains duplicate Unicode codepoints. The codepoint to entity name
// mapping (used by Composer) must ignores them, which occurs only
// because they are listed later.
// apos is from XML
HTML_ENTITY(apos, 39)
// The capitalized versions are required to handle non-standard input.
HTML_ENTITY(AMP, 38)
HTML_ENTITY(COPY, 169)
HTML_ENTITY(GT, 62)
HTML_ENTITY(LT, 60)
HTML_ENTITY(QUOT, 34)
HTML_ENTITY(REG, 174)

View File

@@ -0,0 +1,529 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* 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/
*
* 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.
*
* The Original Code is Mozilla Communicator client code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsHTMLTags.h"
#include "nsCRT.h"
#include "nsReadableUtils.h"
#include "plhash.h"
#include "nsString.h"
#include "nsStaticAtom.h"
// C++ sucks! There's no way to do this with a macro, at least not
// that I know, if you know how to do this with a macro then please do
// so...
static const PRUnichar sHTMLTagUnicodeName_a[] =
{'a', '\0'};
static const PRUnichar sHTMLTagUnicodeName_abbr[] =
{'a', 'b', 'b', 'r', '\0'};
static const PRUnichar sHTMLTagUnicodeName_acronym[] =
{'a', 'c', 'r', 'o', 'n', 'y', 'm', '\0'};
static const PRUnichar sHTMLTagUnicodeName_address[] =
{'a', 'd', 'd', 'r', 'e', 's', 's', '\0'};
static const PRUnichar sHTMLTagUnicodeName_applet[] =
{'a', 'p', 'p', 'l', 'e', 't', '\0'};
static const PRUnichar sHTMLTagUnicodeName_area[] =
{'a', 'r', 'e', 'a', '\0'};
static const PRUnichar sHTMLTagUnicodeName_b[] =
{'b', '\0'};
static const PRUnichar sHTMLTagUnicodeName_base[] =
{'b', 'a', 's', 'e', '\0'};
static const PRUnichar sHTMLTagUnicodeName_basefont[] =
{'b', 'a', 's', 'e', 'f', 'o', 'n', 't', '\0'};
static const PRUnichar sHTMLTagUnicodeName_bdo[] =
{'b', 'd', 'o', '\0'};
static const PRUnichar sHTMLTagUnicodeName_bgsound[] =
{'b', 'g', 's', 'o', 'u', 'n', 'd', '\0'};
static const PRUnichar sHTMLTagUnicodeName_big[] =
{'b', 'i', 'g', '\0'};
static const PRUnichar sHTMLTagUnicodeName_blink[] =
{'b', 'l', 'i', 'n', 'k', '\0'};
static const PRUnichar sHTMLTagUnicodeName_blockquote[] =
{'b', 'l', 'o', 'c', 'k', 'q', 'u', 'o', 't', 'e', '\0'};
static const PRUnichar sHTMLTagUnicodeName_body[] =
{'b', 'o', 'd', 'y', '\0'};
static const PRUnichar sHTMLTagUnicodeName_br[] =
{'b', 'r', '\0'};
static const PRUnichar sHTMLTagUnicodeName_button[] =
{'b', 'u', 't', 't', 'o', 'n', '\0'};
static const PRUnichar sHTMLTagUnicodeName_caption[] =
{'c', 'a', 'p', 't', 'i', 'o', 'n', '\0'};
static const PRUnichar sHTMLTagUnicodeName_center[] =
{'c', 'e', 'n', 't', 'e', 'r', '\0'};
static const PRUnichar sHTMLTagUnicodeName_cite[] =
{'c', 'i', 't', 'e', '\0'};
static const PRUnichar sHTMLTagUnicodeName_code[] =
{'c', 'o', 'd', 'e', '\0'};
static const PRUnichar sHTMLTagUnicodeName_col[] =
{'c', 'o', 'l', '\0'};
static const PRUnichar sHTMLTagUnicodeName_colgroup[] =
{'c', 'o', 'l', 'g', 'r', 'o', 'u', 'p', '\0'};
static const PRUnichar sHTMLTagUnicodeName_counter[] =
{'c', 'o', 'u', 'n', 't', 'e', 'r', '\0'};
static const PRUnichar sHTMLTagUnicodeName_dd[] =
{'d', 'd', '\0'};
static const PRUnichar sHTMLTagUnicodeName_del[] =
{'d', 'e', 'l', '\0'};
static const PRUnichar sHTMLTagUnicodeName_dfn[] =
{'d', 'f', 'n', '\0'};
static const PRUnichar sHTMLTagUnicodeName_dir[] =
{'d', 'i', 'r', '\0'};
static const PRUnichar sHTMLTagUnicodeName_div[] =
{'d', 'i', 'v', '\0'};
static const PRUnichar sHTMLTagUnicodeName_dl[] =
{'d', 'l', '\0'};
static const PRUnichar sHTMLTagUnicodeName_dt[] =
{'d', 't', '\0'};
static const PRUnichar sHTMLTagUnicodeName_em[] =
{'e', 'm', '\0'};
static const PRUnichar sHTMLTagUnicodeName_embed[] =
{'e', 'm', 'b', 'e', 'd', '\0'};
static const PRUnichar sHTMLTagUnicodeName_endnote[] =
{'e', 'n', 'd', 'n', 'o', 't', 'e', '\0'};
static const PRUnichar sHTMLTagUnicodeName_fieldset[] =
{'f', 'i', 'e', 'l', 'd', 's', 'e', 't', '\0'};
static const PRUnichar sHTMLTagUnicodeName_font[] =
{'f', 'o', 'n', 't', '\0'};
static const PRUnichar sHTMLTagUnicodeName_form[] =
{'f', 'o', 'r', 'm', '\0'};
static const PRUnichar sHTMLTagUnicodeName_frame[] =
{'f', 'r', 'a', 'm', 'e', '\0'};
static const PRUnichar sHTMLTagUnicodeName_frameset[] =
{'f', 'r', 'a', 'm', 'e', 's', 'e', 't', '\0'};
static const PRUnichar sHTMLTagUnicodeName_h1[] =
{'h', '1', '\0'};
static const PRUnichar sHTMLTagUnicodeName_h2[] =
{'h', '2', '\0'};
static const PRUnichar sHTMLTagUnicodeName_h3[] =
{'h', '3', '\0'};
static const PRUnichar sHTMLTagUnicodeName_h4[] =
{'h', '4', '\0'};
static const PRUnichar sHTMLTagUnicodeName_h5[] =
{'h', '5', '\0'};
static const PRUnichar sHTMLTagUnicodeName_h6[] =
{'h', '6', '\0'};
static const PRUnichar sHTMLTagUnicodeName_head[] =
{'h', 'e', 'a', 'd', '\0'};
static const PRUnichar sHTMLTagUnicodeName_hr[] =
{'h', 'r', '\0'};
static const PRUnichar sHTMLTagUnicodeName_html[] =
{'h', 't', 'm', 'l', '\0'};
static const PRUnichar sHTMLTagUnicodeName_i[] =
{'i', '\0'};
static const PRUnichar sHTMLTagUnicodeName_iframe[] =
{'i', 'f', 'r', 'a', 'm', 'e', '\0'};
static const PRUnichar sHTMLTagUnicodeName_image[] =
{'i', 'm', 'a', 'g', 'e', '\0'};
static const PRUnichar sHTMLTagUnicodeName_img[] =
{'i', 'm', 'g', '\0'};
static const PRUnichar sHTMLTagUnicodeName_input[] =
{'i', 'n', 'p', 'u', 't', '\0'};
static const PRUnichar sHTMLTagUnicodeName_ins[] =
{'i', 'n', 's', '\0'};
static const PRUnichar sHTMLTagUnicodeName_isindex[] =
{'i', 's', 'i', 'n', 'd', 'e', 'x', '\0'};
static const PRUnichar sHTMLTagUnicodeName_kbd[] =
{'k', 'b', 'd', '\0'};
static const PRUnichar sHTMLTagUnicodeName_keygen[] =
{'k', 'e', 'y', 'g', 'e', 'n', '\0'};
static const PRUnichar sHTMLTagUnicodeName_label[] =
{'l', 'a', 'b', 'e', 'l', '\0'};
static const PRUnichar sHTMLTagUnicodeName_legend[] =
{'l', 'e', 'g', 'e', 'n', 'd', '\0'};
static const PRUnichar sHTMLTagUnicodeName_li[] =
{'l', 'i', '\0'};
static const PRUnichar sHTMLTagUnicodeName_link[] =
{'l', 'i', 'n', 'k', '\0'};
static const PRUnichar sHTMLTagUnicodeName_listing[] =
{'l', 'i', 's', 't', 'i', 'n', 'g', '\0'};
static const PRUnichar sHTMLTagUnicodeName_map[] =
{'m', 'a', 'p', '\0'};
static const PRUnichar sHTMLTagUnicodeName_marquee[] =
{'m', 'a', 'r', 'q', 'u', 'e', 'e', '\0'};
static const PRUnichar sHTMLTagUnicodeName_menu[] =
{'m', 'e', 'n', 'u', '\0'};
static const PRUnichar sHTMLTagUnicodeName_meta[] =
{'m', 'e', 't', 'a', '\0'};
static const PRUnichar sHTMLTagUnicodeName_multicol[] =
{'m', 'u', 'l', 't', 'i', 'c', 'o', 'l', '\0'};
static const PRUnichar sHTMLTagUnicodeName_nobr[] =
{'n', 'o', 'b', 'r', '\0'};
static const PRUnichar sHTMLTagUnicodeName_noembed[] =
{'n', 'o', 'e', 'm', 'b', 'e', 'd', '\0'};
static const PRUnichar sHTMLTagUnicodeName_noframes[] =
{'n', 'o', 'f', 'r', 'a', 'm', 'e', 's', '\0'};
static const PRUnichar sHTMLTagUnicodeName_noscript[] =
{'n', 'o', 's', 'c', 'r', 'i', 'p', 't', '\0'};
static const PRUnichar sHTMLTagUnicodeName_object[] =
{'o', 'b', 'j', 'e', 'c', 't', '\0'};
static const PRUnichar sHTMLTagUnicodeName_ol[] =
{'o', 'l', '\0'};
static const PRUnichar sHTMLTagUnicodeName_optgroup[] =
{'o', 'p', 't', 'g', 'r', 'o', 'u', 'p', '\0'};
static const PRUnichar sHTMLTagUnicodeName_option[] =
{'o', 'p', 't', 'i', 'o', 'n', '\0'};
static const PRUnichar sHTMLTagUnicodeName_p[] =
{'p', '\0'};
static const PRUnichar sHTMLTagUnicodeName_param[] =
{'p', 'a', 'r', 'a', 'm', '\0'};
static const PRUnichar sHTMLTagUnicodeName_parsererror[] =
{'p', 'a', 'r', 's', 'e', 'r', 'e', 'r', 'r', 'o', 'r', '\0'};
static const PRUnichar sHTMLTagUnicodeName_plaintext[] =
{'p', 'l', 'a', 'i', 'n', 't', 'e', 'x', 't', '\0'};
static const PRUnichar sHTMLTagUnicodeName_pre[] =
{'p', 'r', 'e', '\0'};
static const PRUnichar sHTMLTagUnicodeName_q[] =
{'q', '\0'};
static const PRUnichar sHTMLTagUnicodeName_s[] =
{'s', '\0'};
static const PRUnichar sHTMLTagUnicodeName_samp[] =
{'s', 'a', 'm', 'p', '\0'};
static const PRUnichar sHTMLTagUnicodeName_script[] =
{'s', 'c', 'r', 'i', 'p', 't', '\0'};
static const PRUnichar sHTMLTagUnicodeName_select[] =
{'s', 'e', 'l', 'e', 'c', 't', '\0'};
static const PRUnichar sHTMLTagUnicodeName_server[] =
{'s', 'e', 'r', 'v', 'e', 'r', '\0'};
static const PRUnichar sHTMLTagUnicodeName_small[] =
{'s', 'm', 'a', 'l', 'l', '\0'};
static const PRUnichar sHTMLTagUnicodeName_sound[] =
{'s', 'o', 'u', 'n', 'd', '\0'};
static const PRUnichar sHTMLTagUnicodeName_sourcetext[] =
{'s', 'o', 'u', 'r', 'c', 'e', 't', 'e', 'x', 't', '\0'};
static const PRUnichar sHTMLTagUnicodeName_spacer[] =
{'s', 'p', 'a', 'c', 'e', 'r', '\0'};
static const PRUnichar sHTMLTagUnicodeName_span[] =
{'s', 'p', 'a', 'n', '\0'};
static const PRUnichar sHTMLTagUnicodeName_strike[] =
{'s', 't', 'r', 'i', 'k', 'e', '\0'};
static const PRUnichar sHTMLTagUnicodeName_strong[] =
{'s', 't', 'r', 'o', 'n', 'g', '\0'};
static const PRUnichar sHTMLTagUnicodeName_style[] =
{'s', 't', 'y', 'l', 'e', '\0'};
static const PRUnichar sHTMLTagUnicodeName_sub[] =
{'s', 'u', 'b', '\0'};
static const PRUnichar sHTMLTagUnicodeName_sup[] =
{'s', 'u', 'p', '\0'};
static const PRUnichar sHTMLTagUnicodeName_table[] =
{'t', 'a', 'b', 'l', 'e', '\0'};
static const PRUnichar sHTMLTagUnicodeName_tbody[] =
{'t', 'b', 'o', 'd', 'y', '\0'};
static const PRUnichar sHTMLTagUnicodeName_td[] =
{'t', 'd', '\0'};
static const PRUnichar sHTMLTagUnicodeName_textarea[] =
{'t', 'e', 'x', 't', 'a', 'r', 'e', 'a', '\0'};
static const PRUnichar sHTMLTagUnicodeName_tfoot[] =
{'t', 'f', 'o', 'o', 't', '\0'};
static const PRUnichar sHTMLTagUnicodeName_th[] =
{'t', 'h', '\0'};
static const PRUnichar sHTMLTagUnicodeName_thead[] =
{'t', 'h', 'e', 'a', 'd', '\0'};
static const PRUnichar sHTMLTagUnicodeName_title[] =
{'t', 'i', 't', 'l', 'e', '\0'};
static const PRUnichar sHTMLTagUnicodeName_tr[] =
{'t', 'r', '\0'};
static const PRUnichar sHTMLTagUnicodeName_tt[] =
{'t', 't', '\0'};
static const PRUnichar sHTMLTagUnicodeName_u[] =
{'u', '\0'};
static const PRUnichar sHTMLTagUnicodeName_ul[] =
{'u', 'l', '\0'};
static const PRUnichar sHTMLTagUnicodeName_var[] =
{'v', 'a', 'r', '\0'};
static const PRUnichar sHTMLTagUnicodeName_wbr[] =
{'w', 'b', 'r', '\0'};
static const PRUnichar sHTMLTagUnicodeName_xmp[] =
{'x', 'm', 'p', '\0'};
// static array of unicode tag names
#define HTML_TAG(_tag, _classname) sHTMLTagUnicodeName_##_tag,
#define HTML_OTHER(_tag, _classname)
static const PRUnichar* const kTagUnicodeTable[] = {
#include "nsHTMLTagList.h"
};
#undef HTML_TAG
// static array of tag atoms
static nsIAtom* kTagAtomTable[eHTMLTag_userdefined - 1];
// static array of tag StaticAtom structs
#define HTML_TAG(_tag, _classname) { #_tag, &kTagAtomTable[eHTMLTag_##_tag - 1] },
static const nsStaticAtom kTagAtoms_info[] = {
#include "nsHTMLTagList.h"
};
#undef HTML_TAG
#undef HTML_OTHER
static PRInt32 gTableRefCount;
static PLHashTable* gTagTable;
PR_STATIC_CALLBACK(PLHashNumber)
HTMLTagsHashCodeUCPtr(const void *key)
{
const PRUnichar *str = (const PRUnichar *)key;
return nsCRT::HashCode(str);
}
PR_STATIC_CALLBACK(PRIntn)
HTMLTagsKeyCompareUCPtr(const void *key1, const void *key2)
{
const PRUnichar *str1 = (const PRUnichar *)key1;
const PRUnichar *str2 = (const PRUnichar *)key2;
return nsCRT::strcmp(str1, str2) == 0;
}
static PRUint32 sMaxTagNameLength;
#define NS_HTMLTAG_NAME_MAX_LENGTH 11
// static
nsresult
nsHTMLTags::AddRefTable(void)
{
if (gTableRefCount++ == 0) {
NS_ASSERTION(!gTagTable, "pre existing hash!");
gTagTable = PL_NewHashTable(64, HTMLTagsHashCodeUCPtr,
HTMLTagsKeyCompareUCPtr, PL_CompareValues,
nsnull, nsnull);
NS_ENSURE_TRUE(gTagTable, NS_ERROR_OUT_OF_MEMORY);
// Fill in gTagTable with the above static PRUnichar strings as
// keys and the value of the corresponding enum as the value in
// the table.
PRInt32 i;
for (i = 0; i < NS_HTML_TAG_MAX; ++i) {
PRUint32 len = nsCRT::strlen(kTagUnicodeTable[i]);
PL_HashTableAdd(gTagTable, kTagUnicodeTable[i],
NS_INT32_TO_PTR(i + 1));
if (len > sMaxTagNameLength) {
sMaxTagNameLength = len;
}
}
NS_ASSERTION(sMaxTagNameLength == NS_HTMLTAG_NAME_MAX_LENGTH,
"NS_HTMLTAG_NAME_MAX_LENGTH not set correctly!");
// Fill in our static atom pointers
NS_RegisterStaticAtoms(kTagAtoms_info, NS_ARRAY_LENGTH(kTagAtoms_info));
#ifdef DEBUG
{
// let's verify that all names in the the table are lowercase...
for (i = 0; i < NS_HTML_TAG_MAX; ++i) {
nsCAutoString temp1(kTagAtoms_info[i].mString);
nsCAutoString temp2(kTagAtoms_info[i].mString);
ToLowerCase(temp1);
NS_ASSERTION(temp1.Equals(temp2), "upper case char in table");
}
// let's verify that all names in the unicode strings above are
// correct.
for (i = 0; i < NS_HTML_TAG_MAX; ++i) {
nsAutoString temp1(kTagUnicodeTable[i]);
nsAutoString temp2; temp2.AssignWithConversion(kTagAtoms_info[i].mString);
NS_ASSERTION(temp1.Equals(temp2), "Bad unicode tag name!");
}
}
#endif
}
return NS_OK;
}
// static
void
nsHTMLTags::ReleaseTable(void)
{
if (0 == --gTableRefCount) {
if (gTagTable) {
// Nothing to delete/free in this table, just destroy the table.
PL_HashTableDestroy(gTagTable);
gTagTable = nsnull;
}
}
}
// static
nsHTMLTag
nsHTMLTags::CaseSensitiveLookupTag(const PRUnichar* aTagName)
{
NS_ASSERTION(gTagTable, "no lookup table, needs addref");
NS_ASSERTION(aTagName, "null tagname!");
PRUint32 tag = NS_PTR_TO_INT32(PL_HashTableLookupConst(gTagTable, aTagName));
return (nsHTMLTag)tag;
}
// static
nsHTMLTag
nsHTMLTags::LookupTag(const nsAString& aTagName)
{
PRUint32 length = aTagName.Length();
if (length > sMaxTagNameLength) {
return eHTMLTag_userdefined;
}
static PRUnichar buf[NS_HTMLTAG_NAME_MAX_LENGTH + 1];
nsAString::const_iterator iter;
PRUint32 i = 0;
PRUnichar c;
aTagName.BeginReading(iter);
// Fast lowercasing-while-copying of ASCII characters into a
// PRUnichar buffer
while (i < length) {
c = *iter;
if (c <= 'Z' && c >= 'A') {
c |= 0x20; // Lowercase the ASCII character.
}
buf[i] = c; // Copy ASCII character.
++i;
++iter;
}
buf[i] = 0;
nsHTMLTag tag = CaseSensitiveLookupTag(buf);
// hack: this can come out when rickg provides a way for the editor to ask
// CanContain() questions without having to first fetch the parsers
// internal enum values for a tag name.
// Hmm, this hack would be faster if we'd put these strings in the
// hash table. But maybe it's not worth it...
if (tag == eHTMLTag_unknown) {
// "__moz_text"
static const PRUnichar moz_text[] =
{'_', '_', 'm', 'o', 'z', '_', 't', 'e', 'x', 't', PRUnichar(0) };
// "#text"
static const PRUnichar text[] =
{'#', 't', 'e', 'x', 't', PRUnichar(0) };
if (nsCRT::strcmp(buf, moz_text) == 0) {
tag = eHTMLTag_text;
} else if (nsCRT::strcmp(buf, text) == 0) {
tag = eHTMLTag_text;
} else {
tag = eHTMLTag_userdefined;
}
}
return tag;
}
// static
const PRUnichar *
nsHTMLTags::GetStringValue(nsHTMLTag aEnum)
{
if (aEnum <= eHTMLTag_unknown || aEnum > NS_HTML_TAG_MAX) {
return nsnull;
}
return kTagUnicodeTable[aEnum - 1];
}
// static
nsIAtom *
nsHTMLTags::GetAtom(nsHTMLTag aEnum)
{
if (aEnum <= eHTMLTag_unknown || aEnum > NS_HTML_TAG_MAX) {
return nsnull;
}
return kTagAtomTable[aEnum - 1];
}
#ifdef NS_DEBUG
// tag table verification class.
class nsTestTagTable {
public:
nsTestTagTable() {
const PRUnichar *tag;
nsHTMLTag id;
nsHTMLTags::AddRefTable();
// Make sure we can find everything we are supposed to
for (int i = 0; i < NS_HTML_TAG_MAX; ++i) {
tag = kTagUnicodeTable[i];
id = nsHTMLTags::LookupTag(nsDependentString(tag));
NS_ASSERTION(id != eHTMLTag_userdefined, "can't find tag id");
const PRUnichar* check = nsHTMLTags::GetStringValue(id);
NS_ASSERTION(0 == nsCRT::strcmp(check, tag), "can't map id back to tag");
}
// Make sure we don't find things that aren't there
id = nsHTMLTags::LookupTag(NS_LITERAL_STRING("@"));
NS_ASSERTION(id == eHTMLTag_userdefined, "found @");
id = nsHTMLTags::LookupTag(NS_LITERAL_STRING("zzzzz"));
NS_ASSERTION(id == eHTMLTag_userdefined, "found zzzzz");
tag = nsHTMLTags::GetStringValue((nsHTMLTag) 0);
NS_ASSERTION(!tag, "found enum 0");
tag = nsHTMLTags::GetStringValue((nsHTMLTag) -1);
NS_ASSERTION(!tag, "found enum -1");
tag = nsHTMLTags::GetStringValue((nsHTMLTag) (NS_HTML_TAG_MAX + 1));
NS_ASSERTION(!tag, "found past max enum");
nsHTMLTags::ReleaseTable();
}
};
static const nsTestTagTable validateTagTable;
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,115 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* 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/
*
* 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.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/**
* MODULE NOTES:
* @update gess 4/1/98
*
*/
#ifndef __NSHTMLTOKENIZER
#define __NSHTMLTOKENIZER
#include "nsISupports.h"
#include "nsITokenizer.h"
#include "nsIDTD.h"
#include "prtypes.h"
#include "nsDeque.h"
#include "nsScanner.h"
#include "nsHTMLTokens.h"
#include "nsDTDUtils.h"
#define NS_HTMLTOKENIZER_IID \
{0xe4238ddd, 0x9eb6, 0x11d2, \
{0xba, 0xa5, 0x0, 0x10, 0x4b, 0x98, 0x3f, 0xd4 }}
/***************************************************************
Notes:
***************************************************************/
#ifdef _MSC_VER
#pragma warning( disable : 4275 )
#endif
class nsHTMLTokenizer : public nsITokenizer {
public:
NS_DECL_ISUPPORTS
NS_DECL_NSITOKENIZER
nsHTMLTokenizer(PRInt32 aParseMode = eDTDMode_quirks,
eParserDocType aDocType = eHTML3_Quirks,
eParserCommands aCommand = eViewNormal);
virtual ~nsHTMLTokenizer();
protected:
virtual nsresult ConsumeTag(PRUnichar aChar,CToken*& aToken,nsScanner& aScanner,PRBool& aFlushTokens);
virtual nsresult ConsumeStartTag(PRUnichar aChar,CToken*& aToken,nsScanner& aScanner,PRBool& aFlushTokens);
virtual nsresult ConsumeEndTag(PRUnichar aChar,CToken*& aToken,nsScanner& aScanner);
virtual nsresult ConsumeAttributes(PRUnichar aChar, CToken* aToken, nsScanner& aScanner);
virtual nsresult ConsumeEntity(PRUnichar aChar,CToken*& aToken,nsScanner& aScanner);
virtual nsresult ConsumeWhitespace(PRUnichar aChar,CToken*& aToken,nsScanner& aScanner);
virtual nsresult ConsumeComment(PRUnichar aChar,CToken*& aToken,nsScanner& aScanner);
virtual nsresult ConsumeNewline(PRUnichar aChar,CToken*& aToken,nsScanner& aScanner);
virtual nsresult ConsumeText(CToken*& aToken,nsScanner& aScanner);
virtual nsresult ConsumeSpecialMarkup(PRUnichar aChar,CToken*& aToken,nsScanner& aScanner);
virtual nsresult ConsumeProcessingInstruction(PRUnichar aChar,CToken*& aToken,nsScanner& aScanner);
nsresult ScanDocStructure(PRBool aIsFinalChunk);
virtual void PreserveToken(CStartToken* aStartToken, nsScanner& aScanner, nsScannerIterator aOrigin);
static void AddToken(CToken*& aToken,nsresult aResult,nsDeque* aDeque,nsTokenAllocator* aTokenAllocator);
nsDeque mTokenDeque;
PRPackedBool mIsFinalChunk;
nsTokenAllocator* mTokenAllocator;
PRInt32 mTokenScanPos;
PRUint32 mFlags;
eHTMLTags mPreserveTarget; // Tag whose content is preserved
};
extern nsresult NS_NewHTMLTokenizer(nsITokenizer** aInstancePtrResult,
PRInt32 aMode,eParserDocType aDocType,
eParserCommands aCommand);
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,812 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* 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/
*
* 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.
*
* The Original Code is Mozilla Communicator client code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsIAtom.h"
#include "nsLoggingSink.h"
#include "nsHTMLTags.h"
#include "nsString.h"
#include "nsReadableUtils.h"
#include "prprf.h"
static NS_DEFINE_IID(kIContentSinkIID, NS_ICONTENT_SINK_IID);
static NS_DEFINE_IID(kIHTMLContentSinkIID, NS_IHTML_CONTENT_SINK_IID);
static NS_DEFINE_IID(kILoggingSinkIID, NS_ILOGGING_SINK_IID);
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
// list of tags that have skipped content
static const char gSkippedContentTags[] = {
eHTMLTag_style,
eHTMLTag_script,
eHTMLTag_server,
eHTMLTag_textarea,
eHTMLTag_title,
0
};
nsresult
NS_NewHTMLLoggingSink(nsIContentSink** aInstancePtrResult)
{
NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr");
if (nsnull == aInstancePtrResult) {
return NS_ERROR_NULL_POINTER;
}
nsLoggingSink* it = new nsLoggingSink();
if (nsnull == it) {
return NS_ERROR_OUT_OF_MEMORY;
}
return it->QueryInterface(kIContentSinkIID, (void**) aInstancePtrResult);
}
nsLoggingSink::nsLoggingSink() {
mOutput = 0;
mLevel=-1;
mSink=0;
mParser=0;
}
nsLoggingSink::~nsLoggingSink() {
mSink=0;
if(mOutput && mAutoDeleteOutput) {
delete mOutput;
}
mOutput=0;
}
NS_IMPL_ADDREF(nsLoggingSink)
NS_IMPL_RELEASE(nsLoggingSink)
nsresult
nsLoggingSink::QueryInterface(const nsIID& aIID, void** aInstancePtr)
{
NS_PRECONDITION(nsnull != aInstancePtr, "null ptr");
if (nsnull == aInstancePtr) {
return NS_ERROR_NULL_POINTER;
}
if (aIID.Equals(kISupportsIID)) {
nsISupports* tmp = this;
*aInstancePtr = (void*) tmp;
}
else if (aIID.Equals(kIContentSinkIID)) {
nsIContentSink* tmp = this;
*aInstancePtr = (void*) tmp;
}
else if (aIID.Equals(kIHTMLContentSinkIID)) {
nsIHTMLContentSink* tmp = this;
*aInstancePtr = (void*) tmp;
}
else if (aIID.Equals(kILoggingSinkIID)) {
nsILoggingSink* tmp = this;
*aInstancePtr = (void*) tmp;
}
else {
*aInstancePtr = nsnull;
return NS_NOINTERFACE;
}
NS_ADDREF(this);
return NS_OK;
}
NS_IMETHODIMP
nsLoggingSink::SetOutputStream(PRFileDesc *aStream,PRBool autoDeleteOutput) {
mOutput = aStream;
mAutoDeleteOutput=autoDeleteOutput;
return NS_OK;
}
static
void WriteTabs(PRFileDesc * out,int aTabCount) {
int tabs;
for(tabs=0;tabs<aTabCount;++tabs)
PR_fprintf(out, " ");
}
NS_IMETHODIMP
nsLoggingSink::WillBuildModel() {
WriteTabs(mOutput,++mLevel);
PR_fprintf(mOutput, "<begin>\n");
//proxy the call to the real sink if you have one.
if(mSink) {
mSink->WillBuildModel();
}
return NS_OK;
}
NS_IMETHODIMP
nsLoggingSink::DidBuildModel() {
WriteTabs(mOutput,--mLevel);
PR_fprintf(mOutput, "</begin>\n");
//proxy the call to the real sink if you have one.
nsresult theResult=NS_OK;
if(mSink) {
theResult=mSink->DidBuildModel();
}
return theResult;
}
NS_IMETHODIMP
nsLoggingSink::WillInterrupt() {
nsresult theResult=NS_OK;
//proxy the call to the real sink if you have one.
if(mSink) {
theResult=mSink->WillInterrupt();
}
return theResult;
}
NS_IMETHODIMP
nsLoggingSink::WillResume() {
nsresult theResult=NS_OK;
//proxy the call to the real sink if you have one.
if(mSink) {
theResult=mSink->WillResume();
}
return theResult;
}
NS_IMETHODIMP
nsLoggingSink::SetParser(nsIParser* aParser) {
nsresult theResult=NS_OK;
//proxy the call to the real sink if you have one.
if(mSink) {
theResult=mSink->SetParser(aParser);
}
NS_IF_RELEASE(mParser);
mParser = aParser;
NS_IF_ADDREF(mParser);
return theResult;
}
NS_IMETHODIMP
nsLoggingSink::OpenContainer(const nsIParserNode& aNode) {
OpenNode("container", aNode); //do the real logging work...
nsresult theResult=NS_OK;
//then proxy the call to the real sink if you have one.
if(mSink) {
theResult=mSink->OpenContainer(aNode);
}
return theResult;
}
NS_IMETHODIMP
nsLoggingSink::CloseContainer(const nsHTMLTag aTag) {
nsresult theResult=NS_OK;
nsHTMLTag nodeType = nsHTMLTag(aTag);
if ((nodeType >= eHTMLTag_unknown) &&
(nodeType <= nsHTMLTag(NS_HTML_TAG_MAX))) {
const PRUnichar* tag = nsHTMLTags::GetStringValue(nodeType);
theResult = CloseNode(NS_ConvertUCS2toUTF8(tag).get());
}
else theResult= CloseNode("???");
//then proxy the call to the real sink if you have one.
if(mSink) {
theResult=mSink->CloseContainer(aTag);
}
return theResult;
}
NS_IMETHODIMP
nsLoggingSink::AddHeadContent(const nsIParserNode& aNode) {
LeafNode(aNode);
nsresult theResult=NS_OK;
//then proxy the call to the real sink if you have one.
if(mSink) {
theResult=mSink->AddHeadContent(aNode);
}
return theResult;
}
NS_IMETHODIMP
nsLoggingSink::AddLeaf(const nsIParserNode& aNode) {
LeafNode(aNode);
nsresult theResult=NS_OK;
//then proxy the call to the real sink if you have one.
if(mSink) {
theResult=mSink->AddLeaf(aNode);
}
return theResult;
}
/**
* This gets called by the parser when you want to add
* a PI node to the current container in the content
* model.
*
* @updated gess 3/25/98
* @param
* @return
*/
NS_IMETHODIMP
nsLoggingSink::AddProcessingInstruction(const nsIParserNode& aNode){
#ifdef VERBOSE_DEBUG
DebugDump("<",aNode.GetText(),(mNodeStackPos)*2);
#endif
nsresult theResult=NS_OK;
//then proxy the call to the real sink if you have one.
if(mSink) {
theResult=mSink->AddProcessingInstruction(aNode);
}
return theResult;
}
/**
* This gets called by the parser when it encounters
* a DOCTYPE declaration in the HTML document.
*/
NS_IMETHODIMP
nsLoggingSink::AddDocTypeDecl(const nsIParserNode& aNode) {
#ifdef VERBOSE_DEBUG
DebugDump("<",aNode.GetText(),(mNodeStackPos)*2);
#endif
nsresult theResult=NS_OK;
//then proxy the call to the real sink if you have one.
if(mSink) {
theResult=mSink->AddDocTypeDecl(aNode);
}
return theResult;
}
/**
* This gets called by the parser when you want to add
* a comment node to the current container in the content
* model.
*
* @updated gess 3/25/98
* @param
* @return
*/
NS_IMETHODIMP
nsLoggingSink::AddComment(const nsIParserNode& aNode){
#ifdef VERBOSE_DEBUG
DebugDump("<",aNode.GetText(),(mNodeStackPos)*2);
#endif
nsresult theResult=NS_OK;
//then proxy the call to the real sink if you have one.
if(mSink) {
theResult=mSink->AddComment(aNode);
}
return theResult;
}
NS_IMETHODIMP
nsLoggingSink::SetTitle(const nsString& aValue) {
char* tmp = nsnull;
GetNewCString(aValue, &tmp);
WriteTabs(mOutput,++mLevel);
if(tmp) {
PR_fprintf(mOutput, "<title value=\"%s\"/>\n", tmp);
nsMemory::Free(tmp);
}
--mLevel;
nsresult theResult=NS_OK;
//then proxy the call to the real sink if you have one.
if(mSink) {
theResult=mSink->SetTitle(aValue);
}
return theResult;
}
NS_IMETHODIMP
nsLoggingSink::OpenHTML(const nsIParserNode& aNode) {
OpenNode("html", aNode);
nsresult theResult=NS_OK;
//then proxy the call to the real sink if you have one.
if(mSink) {
theResult=mSink->OpenHTML(aNode);
}
return theResult;
}
NS_IMETHODIMP
nsLoggingSink::CloseHTML() {
CloseNode("html");
nsresult theResult=NS_OK;
//then proxy the call to the real sink if you have one.
if(mSink) {
theResult=mSink->CloseHTML();
}
return theResult;
}
NS_IMETHODIMP
nsLoggingSink::OpenHead(const nsIParserNode& aNode) {
OpenNode("head", aNode);
nsresult theResult=NS_OK;
//then proxy the call to the real sink if you have one.
if(mSink) {
theResult=mSink->OpenHead(aNode);
}
return theResult;
}
NS_IMETHODIMP
nsLoggingSink::CloseHead() {
CloseNode("head");
nsresult theResult=NS_OK;
//then proxy the call to the real sink if you have one.
if(mSink) {
theResult=mSink->CloseHead();
}
return theResult;
}
NS_IMETHODIMP
nsLoggingSink::OpenBody(const nsIParserNode& aNode) {
OpenNode("body", aNode);
nsresult theResult=NS_OK;
//then proxy the call to the real sink if you have one.
if(mSink) {
theResult=mSink->OpenBody(aNode);
}
return theResult;
}
NS_IMETHODIMP
nsLoggingSink::CloseBody() {
CloseNode("body");
nsresult theResult=NS_OK;
//then proxy the call to the real sink if you have one.
if(mSink) {
theResult=mSink->CloseBody();
}
return theResult;
}
NS_IMETHODIMP
nsLoggingSink::OpenForm(const nsIParserNode& aNode) {
OpenNode("form", aNode);
nsresult theResult=NS_OK;
//then proxy the call to the real sink if you have one.
if(mSink) {
theResult=mSink->OpenForm(aNode);
}
return theResult;
}
NS_IMETHODIMP
nsLoggingSink::CloseForm() {
CloseNode("form");
nsresult theResult=NS_OK;
//then proxy the call to the real sink if you have one.
if(mSink) {
theResult=mSink->CloseForm();
}
return theResult;
}
NS_IMETHODIMP
nsLoggingSink::OpenMap(const nsIParserNode& aNode) {
OpenNode("map", aNode);
nsresult theResult=NS_OK;
//then proxy the call to the real sink if you have one.
if(mSink) {
theResult=mSink->OpenMap(aNode);
}
return theResult;
}
NS_IMETHODIMP
nsLoggingSink::CloseMap() {
CloseNode("map");
nsresult theResult=NS_OK;
//then proxy the call to the real sink if you have one.
if(mSink) {
theResult=mSink->CloseMap();
}
return theResult;
}
NS_IMETHODIMP
nsLoggingSink::OpenFrameset(const nsIParserNode& aNode) {
OpenNode("frameset", aNode);
nsresult theResult=NS_OK;
//then proxy the call to the real sink if you have one.
if(mSink) {
theResult=mSink->OpenFrameset(aNode);
}
return theResult;
}
NS_IMETHODIMP
nsLoggingSink::CloseFrameset() {
CloseNode("frameset");
nsresult theResult=NS_OK;
//then proxy the call to the real sink if you have one.
if(mSink) {
theResult=mSink->CloseFrameset();
}
return theResult;
}
nsresult
nsLoggingSink::OpenNode(const char* aKind, const nsIParserNode& aNode) {
WriteTabs(mOutput,++mLevel);
PR_fprintf(mOutput,"<open container=");
nsHTMLTag nodeType = nsHTMLTag(aNode.GetNodeType());
if ((nodeType >= eHTMLTag_unknown) &&
(nodeType <= nsHTMLTag(NS_HTML_TAG_MAX))) {
const PRUnichar* tag = nsHTMLTags::GetStringValue(nodeType);
PR_fprintf(mOutput, "\"%s\"", NS_ConvertUCS2toUTF8(tag).get());
}
else {
char* text;
GetNewCString(aNode.GetText(), &text);
if(text) {
PR_fprintf(mOutput, "\"%s\"", text);
nsMemory::Free(text);
}
}
if (WillWriteAttributes(aNode)) {
PR_fprintf(mOutput, ">\n");
WriteAttributes(aNode);
PR_fprintf(mOutput, "</open>\n");
}
else {
PR_fprintf(mOutput, ">\n");
}
return NS_OK;
}
nsresult
nsLoggingSink::CloseNode(const char* aKind) {
WriteTabs(mOutput,mLevel--);
PR_fprintf(mOutput, "<close container=\"%s\">\n", aKind);
return NS_OK;
}
nsresult
nsLoggingSink::WriteAttributes(const nsIParserNode& aNode) {
WriteTabs(mOutput,1+mLevel);
nsAutoString tmp;
PRInt32 ac = aNode.GetAttributeCount();
for (PRInt32 i = 0; i < ac; ++i) {
char* key=nsnull;
char* value=nsnull;
const nsAString& k = aNode.GetKeyAt(i);
const nsAString& v = aNode.GetValueAt(i);
GetNewCString(k, &key);
if(key) {
PR_fprintf(mOutput, " <attr key=\"%s\" value=\"", key);
nsMemory::Free(key);
}
tmp.Truncate();
tmp.Append(v);
if(!tmp.IsEmpty()) {
PRUnichar first = tmp.First();
if ((first == '"') || (first == '\'')) {
if (tmp.Last() == first) {
tmp.Cut(0, 1);
PRInt32 pos = tmp.Length() - 1;
if (pos >= 0) {
tmp.Cut(pos, 1);
}
} else {
// Mismatched quotes - leave them in
}
}
GetNewCString(tmp, &value);
if(value) {
PR_fprintf(mOutput, "%s\"/>\n", value);
WriteTabs(mOutput,1+mLevel);
nsMemory::Free(value);
}
}
}
if (0 != strchr(gSkippedContentTags, aNode.GetNodeType())) {
nsCOMPtr<nsIDTD> dtd;
mParser->GetDTD(getter_AddRefs(dtd));
NS_ENSURE_TRUE(dtd, NS_ERROR_FAILURE);
nsString theString;
PRInt32 lineNo = 0;
dtd->CollectSkippedContent(aNode.GetNodeType(), theString, lineNo);
char* content = nsnull;
GetNewCString(theString, &content);
if(content) {
PR_fprintf(mOutput, " <content value=\"");
PR_fprintf(mOutput, "%s\"/>\n", content) ;
nsMemory::Free(content);
}
}
WriteTabs(mOutput,1+mLevel);
return NS_OK;
}
PRBool
nsLoggingSink::WillWriteAttributes(const nsIParserNode& aNode)
{
PRInt32 ac = aNode.GetAttributeCount();
if (0 != ac) {
return PR_TRUE;
}
if (0 != strchr(gSkippedContentTags, aNode.GetNodeType())) {
nsCOMPtr<nsIDTD> dtd;
mParser->GetDTD(getter_AddRefs(dtd));
NS_ENSURE_TRUE(dtd, NS_ERROR_FAILURE);
nsString content;
PRInt32 lineNo = 0;
dtd->CollectSkippedContent(aNode.GetNodeType(), content, lineNo);
if (!content.IsEmpty()) {
return PR_TRUE;
}
}
return PR_FALSE;
}
nsresult
nsLoggingSink::LeafNode(const nsIParserNode& aNode)
{
WriteTabs(mOutput,1+mLevel);
nsHTMLTag nodeType = nsHTMLTag(aNode.GetNodeType());
if ((nodeType >= eHTMLTag_unknown) &&
(nodeType <= nsHTMLTag(NS_HTML_TAG_MAX))) {
const PRUnichar* tag = nsHTMLTags::GetStringValue(nodeType);
if(tag)
PR_fprintf(mOutput, "<leaf tag=\"%s\"", NS_ConvertUCS2toUTF8(tag).get());
else PR_fprintf(mOutput, "<leaf tag=\"???\"");
if (WillWriteAttributes(aNode)) {
PR_fprintf(mOutput, ">\n");
WriteAttributes(aNode);
PR_fprintf(mOutput, "</leaf>\n");
}
else {
PR_fprintf(mOutput, "/>\n");
}
}
else {
PRInt32 pos;
nsAutoString tmp;
char* str;
switch (nodeType) {
case eHTMLTag_whitespace:
case eHTMLTag_text:
GetNewCString(aNode.GetText(), &str);
if(str) {
PR_fprintf(mOutput, "<text value=\"%s\"/>\n", str);
nsMemory::Free(str);
}
break;
case eHTMLTag_newline:
PR_fprintf(mOutput, "<newline/>\n");
break;
case eHTMLTag_entity:
tmp.Append(aNode.GetText());
tmp.Cut(0, 1);
pos = tmp.Length() - 1;
if (pos >= 0) {
tmp.Cut(pos, 1);
}
PR_fprintf(mOutput, "<entity value=\"%s\"/>\n", NS_LossyConvertUCS2toASCII(tmp).get());
break;
default:
NS_NOTREACHED("unsupported leaf node type");
}//switch
}
return NS_OK;
}
nsresult
nsLoggingSink::QuoteText(const nsAString& aValue, nsString& aResult) {
aResult.Truncate();
/*
if you're stepping through the string anyway, why not use iterators instead of forcing the string to copy?
*/
const nsPromiseFlatString& flat = PromiseFlatString(aValue);
const PRUnichar* cp = flat.get();
const PRUnichar* end = cp + aValue.Length();
while (cp < end) {
PRUnichar ch = *cp++;
if (ch == '"') {
aResult.Append(NS_LITERAL_STRING("&quot;"));
}
else if (ch == '&') {
aResult.Append(NS_LITERAL_STRING("&amp;"));
}
else if ((ch < 32) || (ch >= 127)) {
aResult.Append(NS_LITERAL_STRING("&#"));
aResult.AppendInt(PRInt32(ch), 10);
aResult.Append(PRUnichar(';'));
}
else {
aResult.Append(ch);
}
}
return NS_OK;
}
/**
* Use this method to convert nsString to char*.
* REMEMBER: Match this call with nsMemory::Free(aResult);
*
* @update 04/04/99 harishd
* @param aValue - The string value
* @param aResult - String coverted to char*.
*/
nsresult
nsLoggingSink::GetNewCString(const nsAString& aValue, char** aResult)
{
nsresult result=NS_OK;
nsAutoString temp;
result=QuoteText(aValue,temp);
if(NS_SUCCEEDED(result)) {
if(!temp.IsEmpty()) {
*aResult = ToNewCString(temp);
}
}
return result;
}
/**
* This gets called when handling illegal contents, especially
* in dealing with tables. This method creates a new context.
*
* @update 04/04/99 harishd
* @param aPosition - The position from where the new context begins.
*/
NS_IMETHODIMP
nsLoggingSink::BeginContext(PRInt32 aPosition)
{
return NS_OK;
}
/**
* This method terminates any new context that got created by
* BeginContext and switches back to the main context.
*
* @update 04/04/99 harishd
* @param aPosition - Validates the end of a context.
*/
NS_IMETHODIMP
nsLoggingSink::EndContext(PRInt32 aPosition)
{
return NS_OK;
}

View File

@@ -0,0 +1,124 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* 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/
*
* 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.
*
* The Original Code is Mozilla Communicator client code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef NS_LOGGING_SINK_H__
#define NS_LOGGING_SINK_H__
#include "nsILoggingSink.h"
#include "nsIParser.h"
class nsLoggingSink : public nsILoggingSink {
public:
nsLoggingSink();
virtual ~nsLoggingSink();
void SetProxySink(nsIHTMLContentSink *aSink) {
mSink=aSink;
}
void ReleaseProxySink() {
NS_IF_RELEASE(mSink);
mSink=0;
}
// nsISupports
NS_DECL_ISUPPORTS
// nsIContentSink
NS_IMETHOD WillBuildModel();
NS_IMETHOD DidBuildModel();
NS_IMETHOD WillInterrupt();
NS_IMETHOD WillResume();
NS_IMETHOD SetParser(nsIParser* aParser);
NS_IMETHOD OpenContainer(const nsIParserNode& aNode);
NS_IMETHOD CloseContainer(const nsHTMLTag aTag);
NS_IMETHOD AddHeadContent(const nsIParserNode& aNode);
NS_IMETHOD AddLeaf(const nsIParserNode& aNode);
NS_IMETHOD AddComment(const nsIParserNode& aNode);
NS_IMETHOD AddProcessingInstruction(const nsIParserNode& aNode);
NS_IMETHOD AddDocTypeDecl(const nsIParserNode& aNode);
NS_IMETHOD FlushPendingNotifications() { return NS_OK; }
NS_IMETHOD SetDocumentCharset(nsACString& aCharset) { return NS_OK; }
NS_IMETHOD NotifyTagObservers(nsIParserNode* aNode) { return NS_OK; }
// nsIHTMLContentSink
NS_IMETHOD SetTitle(const nsString& aValue);
NS_IMETHOD OpenHTML(const nsIParserNode& aNode);
NS_IMETHOD CloseHTML();
NS_IMETHOD OpenHead(const nsIParserNode& aNode);
NS_IMETHOD CloseHead();
NS_IMETHOD OpenBody(const nsIParserNode& aNode);
NS_IMETHOD CloseBody();
NS_IMETHOD OpenForm(const nsIParserNode& aNode);
NS_IMETHOD CloseForm();
NS_IMETHOD OpenMap(const nsIParserNode& aNode);
NS_IMETHOD CloseMap();
NS_IMETHOD OpenFrameset(const nsIParserNode& aNode);
NS_IMETHOD CloseFrameset();
NS_IMETHOD IsEnabled(PRInt32 aTag, PRBool* aReturn) { return NS_OK; }
NS_IMETHOD_(PRBool) IsFormOnStack() { return PR_FALSE; }
NS_IMETHOD BeginContext(PRInt32 aPosition);
NS_IMETHOD EndContext(PRInt32 aPosition);
NS_IMETHOD WillProcessTokens(void) { return NS_OK; }
NS_IMETHOD DidProcessTokens(void) { return NS_OK; }
NS_IMETHOD WillProcessAToken(void) { return NS_OK; }
NS_IMETHOD DidProcessAToken(void) { return NS_OK; }
// nsILoggingSink
NS_IMETHOD SetOutputStream(PRFileDesc *aStream,PRBool autoDelete=PR_FALSE);
nsresult OpenNode(const char* aKind, const nsIParserNode& aNode);
nsresult CloseNode(const char* aKind);
nsresult LeafNode(const nsIParserNode& aNode);
nsresult WriteAttributes(const nsIParserNode& aNode);
nsresult QuoteText(const nsAString& aValue, nsString& aResult);
nsresult GetNewCString(const nsAString& aValue, char** aResult);
PRBool WillWriteAttributes(const nsIParserNode& aNode);
protected:
PRFileDesc *mOutput;
int mLevel;
nsIHTMLContentSink *mSink;
PRBool mAutoDeleteOutput;
nsIParser* mParser;
};
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,469 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* 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/
*
* 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.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/**
* MODULE NOTES:
* @update gess 4/1/98
*
* This class does two primary jobs:
* 1) It iterates the tokens provided during the
* tokenization process, identifing where elements
* begin and end (doing validation and normalization).
* 2) It controls and coordinates with an instance of
* the IContentSink interface, to coordinate the
* the production of the content model.
*
* The basic operation of this class assumes that an HTML
* document is non-normalized. Therefore, we don't process
* the document in a normalized way. Don't bother to look
* for methods like: doHead() or doBody().
*
* Instead, in order to be backward compatible, we must
* scan the set of tokens and perform this basic set of
* operations:
* 1) Determine the token type (easy, since the tokens know)
* 2) Determine the appropriate section of the HTML document
* each token belongs in (HTML,HEAD,BODY,FRAMESET).
* 3) Insert content into our document (via the sink) into
* the correct section.
* 4) In the case of tags that belong in the BODY, we must
* ensure that our underlying document state reflects
* the appropriate context for our tag.
*
* For example,if we see a <TR>, we must ensure our
* document contains a table into which the row can
* be placed. This may result in "implicit containers"
* created to ensure a well-formed document.
*
*/
#ifndef NS_PARSER__
#define NS_PARSER__
#include "nsIParser.h"
#include "nsDeque.h"
#include "nsParserNode.h"
#include "nsIURL.h"
#include "CParserContext.h"
#include "nsParserCIID.h"
#include "nsITokenizer.h"
#include "nsHTMLTags.h"
#include "nsDTDUtils.h"
#include "nsTimer.h"
#include "nsIEventQueue.h"
#include "nsIContentSink.h"
#include "nsIParserFilter.h"
class nsIDTD;
class nsScanner;
class nsIProgressEventSink;
#ifdef _MSC_VER
#pragma warning( disable : 4275 )
#endif
class nsParser : public nsIParser,
public nsIStreamListener{
public:
friend class CTokenHandler;
static void FreeSharedObjects(void);
NS_DECL_ISUPPORTS
/**
* default constructor
* @update gess5/11/98
*/
nsParser();
/**
* Destructor
* @update gess5/11/98
*/
virtual ~nsParser();
/**
* Select given content sink into parser for parser output
* @update gess5/11/98
* @param aSink is the new sink to be used by parser
* @return old sink, or NULL
*/
NS_IMETHOD_(void) SetContentSink(nsIContentSink* aSink);
/**
* retrive the sink set into the parser
* @update gess5/11/98
* @param aSink is the new sink to be used by parser
* @return old sink, or NULL
*/
NS_IMETHOD_(nsIContentSink*) GetContentSink(void);
/**
* Call this method once you've created a parser, and want to instruct it
* about the command which caused the parser to be constructed. For example,
* this allows us to select a DTD which can do, say, view-source.
*
* @update gess 3/25/98
* @param aCommand -- ptrs to string that contains command
* @return nada
*/
NS_IMETHOD_(void) GetCommand(nsString& aCommand);
NS_IMETHOD_(void) SetCommand(const char* aCommand);
NS_IMETHOD_(void) SetCommand(eParserCommands aParserCommand);
/**
* Call this method once you've created a parser, and want to instruct it
* about what charset to load
*
* @update ftang 4/23/99
* @param aCharset- the charset of a document
* @param aCharsetSource- the source of the charset
* @return nada
*/
NS_IMETHOD_(void) SetDocumentCharset(const nsACString& aCharset, PRInt32 aSource);
NS_IMETHOD_(void) GetDocumentCharset(nsACString& aCharset, PRInt32& aSource)
{
aCharset = mCharset;
aSource = mCharsetSource;
}
NS_IMETHOD_(void) SetParserFilter(nsIParserFilter* aFilter);
NS_IMETHOD RegisterDTD(nsIDTD* aDTD);
/**
* Retrieve the scanner from the topmost parser context
*
* @update gess 6/9/98
* @return ptr to scanner
*/
NS_IMETHOD_(nsDTDMode) GetParseMode(void);
/**
* Cause parser to parse input from given URL
* @update gess5/11/98
* @param aURL is a descriptor for source document
* @param aListener is a listener to forward notifications to
* @return TRUE if all went well -- FALSE otherwise
*/
NS_IMETHOD Parse(nsIURI* aURL,
nsIRequestObserver* aListener = nsnull,
PRBool aEnableVerify = PR_FALSE,
void* aKey = 0,
nsDTDMode aMode = eDTDMode_autodetect);
/**
* Cause parser to parse input from given stream
* @update gess5/11/98
* @param aStream is the i/o source
* @return TRUE if all went well -- FALSE otherwise
*/
NS_IMETHOD Parse(nsIInputStream* aStream,
const nsACString& aMimeType,
PRBool aEnableVerify = PR_FALSE,
void* aKey = 0,
nsDTDMode aMode = eDTDMode_autodetect);
/**
* @update gess5/11/98
* @param anHTMLString contains a string-full of real HTML
* @param appendTokens tells us whether we should insert tokens inline, or append them.
* @return TRUE if all went well -- FALSE otherwise
*/
NS_IMETHOD Parse(const nsAString& aSourceBuffer,
void* aKey,
const nsACString& aContentType,
PRBool aEnableVerify,
PRBool aLastCall,
nsDTDMode aMode = eDTDMode_autodetect);
NS_IMETHOD ParseFragment(const nsAString& aSourceBuffer,
void* aKey,
nsVoidArray& aTagStack,
PRUint32 anInsertPos,
const nsACString& aContentType,
nsDTDMode aMode = eDTDMode_autodetect);
/**
* This method gets called when the tokens have been consumed, and it's time
* to build the model via the content sink.
* @update gess5/11/98
* @return YES if model building went well -- NO otherwise.
*/
NS_IMETHOD BuildModel(void);
/**
* Call this when you want control whether or not the parser will parse
* and tokenize input (TRUE), or whether it just caches input to be
* parsed later (FALSE).
*
* @update gess 9/1/98
* @param aState determines whether we parse/tokenize or just cache.
* @return current state
*/
NS_IMETHOD ContinueParsing();
NS_IMETHOD_(void) BlockParser();
NS_IMETHOD_(void) UnblockParser();
NS_IMETHOD Terminate(void);
/**
* Call this to query whether the parser is enabled or not.
*
* @update vidur 4/12/99
* @return current state
*/
NS_IMETHOD_(PRBool) IsParserEnabled();
/**
* Call this to query whether the parser thinks it's done with parsing.
*
* @update rickg 5/12/01
* @return complete state
*/
NS_IMETHOD_(PRBool) IsComplete();
/**
* This rather arcane method (hack) is used as a signal between the
* DTD and the parser. It allows the DTD to tell the parser that content
* that comes through (parser::parser(string)) but not consumed should
* propagate into the next string based parse call.
*
* @update gess 9/1/98
* @param aState determines whether we propagate unused string content.
* @return current state
*/
void SetUnusedInput(nsString& aBuffer);
/**
* This method gets called (automatically) during incremental parsing
* @update gess5/11/98
* @return TRUE if all went well, otherwise FALSE
*/
virtual nsresult ResumeParse(PRBool allowIteration = PR_TRUE,
PRBool aIsFinalChunk = PR_FALSE,
PRBool aCanInterrupt = PR_TRUE);
//*********************************************
// These methods are callback methods used by
// net lib to let us know about our inputstream.
//*********************************************
// nsIRequestObserver methods:
NS_DECL_NSIREQUESTOBSERVER
// nsIStreamListener methods:
NS_DECL_NSISTREAMLISTENER
void PushContext(CParserContext& aContext);
CParserContext* PopContext();
CParserContext* PeekContext() {return mParserContext;}
/**
*
* @update gess 1/22/99
* @param
* @return
*/
nsresult GetTokenizer(nsITokenizer*& aTokenizer);
/**
* Get the channel associated with this parser
* @update harishd,gagan 07/17/01
* @param aChannel out param that will contain the result
* @return NS_OK if successful
*/
NS_IMETHOD GetChannel(nsIChannel** aChannel);
/**
* Get the DTD associated with this parser
* @update vidur 9/29/99
* @param aDTD out param that will contain the result
* @return NS_OK if successful, NS_ERROR_FAILURE for runtime error
*/
NS_IMETHOD GetDTD(nsIDTD** aDTD);
/**
* Detects the existence of a META tag with charset information in
* the given buffer.
*/
PRBool DetectMetaTag(const char* aBytes,
PRInt32 aLen,
nsCString& oCharset,
PRInt32& oCharsetSource);
void SetSinkCharset(nsACString& aCharset);
/**
* Removes continue parsing events
* @update kmcclusk 5/18/98
*/
NS_IMETHODIMP CancelParsingEvents();
/**
* Indicates whether the parser is in a state where it
* can be interrupted.
* @return PR_TRUE if parser can be interrupted, PR_FALSE if it can not be interrupted.
* @update kmcclusk 5/18/98
*/
PRBool CanInterrupt(void);
/**
* Set to parser state to indicate whether parsing tokens can be interrupted
* @param aCanInterrupt PR_TRUE if parser can be interrupted, PR_FALSE if it can not be interrupted.
* @update kmcclusk 5/18/98
*/
void SetCanInterrupt(PRBool aCanInterrupt);
/**
* This is called when the final chunk has been
* passed to the parser and the content sink has
* interrupted token processing. It schedules
* a ParserContinue PL_Event which will ask the parser
* to HandleParserContinueEvent when it is handled.
* @update kmcclusk6/1/2001
*/
nsresult PostContinueEvent();
/**
* Fired when the continue parse event is triggered.
* @update kmcclusk 5/18/98
*/
void HandleParserContinueEvent(void);
protected:
/**
*
* @update gess5/18/98
* @param
* @return
*/
nsresult WillBuildModel(nsString& aFilename);
/**
*
* @update gess5/18/98
* @param
* @return
*/
nsresult DidBuildModel(nsresult anErrorCode);
private:
/*******************************************
These are the tokenization methods...
*******************************************/
/**
* Part of the code sandwich, this gets called right before
* the tokenization process begins. The main reason for
* this call is to allow the delegate to do initialization.
*
* @update gess 3/25/98
* @param
* @return TRUE if it's ok to proceed
*/
PRBool WillTokenize(PRBool aIsFinalChunk = PR_FALSE);
/**
* This is the primary control routine. It iteratively
* consumes tokens until an error occurs or you run out
* of data.
*
* @update gess 3/25/98
* @return error code
*/
nsresult Tokenize(PRBool aIsFinalChunk = PR_FALSE);
/**
* This is the tail-end of the code sandwich for the
* tokenization process. It gets called once tokenziation
* has completed.
*
* @update gess 3/25/98
* @param
* @return TRUE if all went well
*/
PRBool DidTokenize(PRBool aIsFinalChunk = PR_FALSE);
protected:
//*********************************************
// And now, some data members...
//*********************************************
nsCOMPtr<nsIEventQueue> mEventQueue;
CParserContext* mParserContext;
nsCOMPtr<nsIRequestObserver> mObserver;
nsCOMPtr<nsIContentSink> mSink;
nsCOMPtr<nsIParserFilter> mParserFilter;
nsTokenAllocator mTokenAllocator;
eParserCommands mCommand;
nsresult mInternalState;
PRInt32 mStreamStatus;
PRInt32 mCharsetSource;
PRUint16 mFlags;
nsString mUnusedInput;
nsCString mCharset;
nsString mCommandStr;
public:
MOZ_TIMER_DECLARE(mParseTime)
MOZ_TIMER_DECLARE(mDTDTime)
MOZ_TIMER_DECLARE(mTokenizeTime)
};
#endif

View File

@@ -0,0 +1,137 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* 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/
*
* 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.
*
* The Original Code is Mozilla Communicator client code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Pierre Phaneuf <pp@ludusdesign.com>
*
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsIAtom.h"
#include "nsString.h"
#include "nspr.h"
#include "nsCOMPtr.h"
#include "nsIGenericFactory.h"
#include "nsIModule.h"
#include "nsParserCIID.h"
#include "nsParser.h"
#include "CNavDTD.h"
#include "COtherDTD.h"
#include "nsHTMLEntities.h"
#include "nsHTMLTokenizer.h"
//#include "nsTextTokenizer.h"
#include "nsElementTable.h"
#include "nsParserService.h"
#ifdef MOZ_VIEW_SOURCE
#include "nsViewSourceHTML.h"
#endif
#ifdef NS_DEBUG
#include "nsLoggingSink.h"
#include "nsExpatDriver.h"
#endif
//----------------------------------------------------------------------
#ifdef NS_DEBUG
NS_GENERIC_FACTORY_CONSTRUCTOR(nsLoggingSink)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsExpatDriver)
#endif
NS_GENERIC_FACTORY_CONSTRUCTOR(nsParser)
NS_GENERIC_FACTORY_CONSTRUCTOR(CNavDTD)
NS_GENERIC_FACTORY_CONSTRUCTOR(CTransitionalDTD)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsParserService)
#ifdef MOZ_VIEW_SOURCE
NS_GENERIC_FACTORY_CONSTRUCTOR(CViewSourceHTML)
#endif
static const nsModuleComponentInfo gComponents[] = {
#ifdef NS_DEBUG
{ "Logging sink", NS_LOGGING_SINK_CID, NULL, nsLoggingSinkConstructor },
{ "Expat Driver", NS_EXPAT_DRIVER_CID, NULL, nsExpatDriverConstructor },
#endif
{ "Parser", NS_PARSER_CID, NULL, nsParserConstructor },
{ "Navigator HTML DTD", NS_CNAVDTD_CID, NULL, CNavDTDConstructor },
{ "Transitional DTD", NS_CTRANSITIONAL_DTD_CID, NULL,
CTransitionalDTDConstructor },
#ifdef MOZ_VIEW_SOURCE
{ "ViewSource DTD", NS_VIEWSOURCE_DTD_CID, NULL, CViewSourceHTMLConstructor },
#endif
{ "ParserService",
NS_PARSERSERVICE_CID,
NS_PARSER_CONTRACTID_PREFIX "/parser-service;1",
nsParserServiceConstructor
}
};
static PRBool gInitialized = PR_FALSE;
PR_STATIC_CALLBACK(nsresult)
Initialize(nsIModule* aSelf)
{
if (!gInitialized) {
nsresult rv = nsHTMLTags::AddRefTable();
NS_ENSURE_SUCCESS(rv, rv);
rv = nsHTMLEntities::AddRefTable();
if (NS_FAILED(rv)) {
nsHTMLTags::ReleaseTable();
return rv;
}
InitializeElementTable();
CNewlineToken::AllocNewline();
gInitialized = PR_TRUE;
}
return NS_OK;
}
PR_STATIC_CALLBACK(void)
Shutdown(nsIModule* aSelf)
{
if (gInitialized) {
nsHTMLTags::ReleaseTable();
nsHTMLEntities::ReleaseTable();
nsDTDContext::ReleaseGlobalObjects();
nsParser::FreeSharedObjects();
DeleteElementTable();
CNewlineToken::FreeNewline();
gInitialized = PR_FALSE;
}
}
NS_IMPL_NSGETMODULE_WITH_CTOR_DTOR(nsParserModule, gComponents, Initialize, Shutdown)

View File

@@ -0,0 +1,101 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* 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/
*
* 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.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsIServiceManager.h"
#include "nsIStringBundle.h"
#include "nsXPIDLString.h"
#include "nsParserMsgUtils.h"
#include "nsNetCID.h"
static NS_DEFINE_CID(kStringBundleServiceCID, NS_STRINGBUNDLESERVICE_CID);
// This code is derived from nsFormControlHelper::GetLocalizedString()
static nsresult GetBundle(const char * aPropFileName, nsIStringBundle **aBundle)
{
NS_ENSURE_ARG_POINTER(aPropFileName);
NS_ENSURE_ARG_POINTER(aBundle);
// Create a bundle for the localization
nsresult rv;
nsCOMPtr<nsIStringBundleService> stringService =
do_GetService(kStringBundleServiceCID, &rv);
if (NS_SUCCEEDED(rv))
rv = stringService->CreateBundle(aPropFileName, aBundle);
return rv;
}
nsresult
nsParserMsgUtils::GetLocalizedStringByName(const char * aPropFileName, const char* aKey, nsString& oVal)
{
oVal.Truncate();
NS_ENSURE_ARG_POINTER(aKey);
nsCOMPtr<nsIStringBundle> bundle;
nsresult rv = GetBundle(aPropFileName,getter_AddRefs(bundle));
if (NS_SUCCEEDED(rv) && bundle) {
nsXPIDLString valUni;
nsAutoString key; key.AssignWithConversion(aKey);
rv = bundle->GetStringFromName(key.get(), getter_Copies(valUni));
if (NS_SUCCEEDED(rv) && valUni) {
oVal.Assign(valUni);
}
}
return rv;
}
nsresult
nsParserMsgUtils::GetLocalizedStringByID(const char * aPropFileName, PRUint32 aID, nsString& oVal)
{
oVal.Truncate();
nsCOMPtr<nsIStringBundle> bundle;
nsresult rv = GetBundle(aPropFileName,getter_AddRefs(bundle));
if (NS_SUCCEEDED(rv) && bundle) {
nsXPIDLString valUni;
rv = bundle->GetStringFromID(aID, getter_Copies(valUni));
if (NS_SUCCEEDED(rv) && valUni) {
oVal.Assign(valUni);
}
}
return rv;
}

View File

@@ -0,0 +1,54 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* 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/
*
* 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.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsParserMsgUtils_h
#define nsParserMsgUtils_h
#include "nsString.h"
#define XMLPARSER_PROPERTIES "chrome://communicator/locale/layout/xmlparser.properties"
class nsParserMsgUtils {
nsParserMsgUtils(); // Currently this is not meant to be created, use the static methods
~nsParserMsgUtils(); // If perf required, change this to cache values etc.
public:
static nsresult GetLocalizedStringByName(const char * aPropFileName, const char* aKey, nsString& aVal);
static nsresult GetLocalizedStringByID(const char * aPropFileName, PRUint32 aID, nsString& aVal);
};
#endif

View File

@@ -0,0 +1,392 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* 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/
*
* 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.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsIAtom.h"
#include "nsParserNode.h"
#include <string.h>
#include "nsHTMLTokens.h"
#include "nsITokenizer.h"
#include "nsDTDUtils.h"
/**
* Default Constructor
*/
nsCParserNode::nsCParserNode()
: mToken(nsnull),
mUseCount(0),
mGenericState(PR_FALSE),
mTokenAllocator(nsnull)
{
MOZ_COUNT_CTOR(nsCParserNode);
#ifdef HEAP_ALLOCATED_NODES
mNodeAllocator = nsnull;
#endif
}
/**
* Constructor
*
* @update gess 3/25/98
* @param aToken -- token to init internal token
* @return
*/
nsCParserNode::nsCParserNode(CToken* aToken,
nsTokenAllocator* aTokenAllocator,
nsNodeAllocator* aNodeAllocator): nsIParserNode()
{
mRefCnt = 0;
MOZ_COUNT_CTOR(nsCParserNode);
static int theNodeCount = 0;
++theNodeCount;
mToken = aToken;
IF_HOLD(mToken);
mTokenAllocator = aTokenAllocator;
mUseCount = 0;
mGenericState = PR_FALSE;
#ifdef HEAP_ALLOCATED_NODES
mNodeAllocator = aNodeAllocator;
#endif
}
/**
* default destructor
* NOTE: We intentionally DONT recycle mToken here.
* It may get cached for use elsewhere
* @update gess 3/25/98
* @param
* @return
*/
nsCParserNode::~nsCParserNode() {
MOZ_COUNT_DTOR(nsCParserNode);
ReleaseAll();
#ifdef HEAP_ALLOCATED_NODES
if(mNodeAllocator) {
mNodeAllocator->Recycle(this);
}
mNodeAllocator = nsnull;
#endif
mTokenAllocator = 0;
}
/**
* Init
*
* @update gess 3/25/98
* @param
* @return
*/
nsresult
nsCParserNode::Init(CToken* aToken,
nsTokenAllocator* aTokenAllocator,
nsNodeAllocator* aNodeAllocator)
{
mTokenAllocator = aTokenAllocator;
mToken = aToken;
IF_HOLD(mToken);
mGenericState = PR_FALSE;
mUseCount=0;
#ifdef HEAP_ALLOCATED_NODES
mNodeAllocator = aNodeAllocator;
#endif
return NS_OK;
}
void
nsCParserNode::AddAttribute(CToken* aToken)
{
}
/**
* Gets the name of this node. Currently unused.
*
* @update gess 3/25/98
* @param
* @return string ref containing node name
*/
const nsAString&
nsCParserNode::GetTagName() const {
return EmptyString();
}
/**
* Get text value of this node, which translates into
* getting the text value of the underlying token
*
* @update gess 3/25/98
* @param
* @return string ref of text from internal token
*/
const nsAString&
nsCParserNode::GetText() const
{
if (mToken) {
return mToken->GetStringValue();
}
return EmptyString();
}
/**
* Get node type, meaning, get the tag type of the
* underlying token
*
* @update gess 3/25/98
* @param
* @return int value that represents tag type
*/
PRInt32
nsCParserNode::GetNodeType(void) const
{
return (mToken) ? mToken->GetTypeID() : 0;
}
/**
* Gets the token type, which corresponds to a value from
* eHTMLTokens_xxx.
*
* @update gess 3/25/98
* @param
* @return
*/
PRInt32
nsCParserNode::GetTokenType(void) const
{
return (mToken) ? mToken->GetTokenType() : 0;
}
/**
* Retrieve the number of attributes on this node
*
* @update gess 3/25/98
* @param
* @return int -- representing attribute count
*/
PRInt32
nsCParserNode::GetAttributeCount(PRBool askToken) const
{
return 0;
}
/**
* Retrieve the string rep of the attribute key at the
* given index.
*
* @update gess 3/25/98
* @param anIndex-- offset of attribute to retrieve
* @return string rep of given attribute text key
*/
const nsAString&
nsCParserNode::GetKeyAt(PRUint32 anIndex) const
{
return EmptyString();
}
/**
* Retrieve the string rep of the attribute at given offset
*
* @update gess 3/25/98
* @param anIndex-- offset of attribute to retrieve
* @return string rep of given attribute text value
*/
const nsAString&
nsCParserNode::GetValueAt(PRUint32 anIndex) const
{
return EmptyString();
}
PRInt32
nsCParserNode::TranslateToUnicodeStr(nsString& aString) const
{
if (eToken_entity == mToken->GetTokenType()) {
return ((CEntityToken*)mToken)->TranslateToUnicodeStr(aString);
}
return -1;
}
/**
* This getter retrieves the line number from the input source where
* the token occured. Lines are interpreted as occuring between \n characters.
* @update gess7/24/98
* @return int containing the line number the token was found on
*/
PRInt32
nsCParserNode::GetSourceLineNumber(void) const {
return mToken ? mToken->GetLineNumber() : 0;
}
/**
* This method pop the attribute token
* @update harishd 03/25/99
* @return token at anIndex
*/
CToken*
nsCParserNode::PopAttributeToken() {
return 0;
}
/** Retrieve a string containing the tag and its attributes in "source" form
* @update rickg 06June2000
* @return void
*/
void
nsCParserNode::GetSource(nsString& aString)
{
eHTMLTags theTag = mToken ? (eHTMLTags)mToken->GetTypeID() : eHTMLTag_unknown;
aString.Assign(PRUnichar('<'));
const PRUnichar* theTagName = nsHTMLTags::GetStringValue(theTag);
if(theTagName) {
aString.Append(theTagName);
}
aString.Append(PRUnichar('>'));
}
/** Release all the objects you're holding to.
* @update harishd 08/02/00
* @return void
*/
nsresult
nsCParserNode::ReleaseAll()
{
if(mTokenAllocator) {
IF_FREE(mToken,mTokenAllocator);
}
return NS_OK;
}
nsresult
nsCParserStartNode::Init(CToken* aToken,
nsTokenAllocator* aTokenAllocator,
nsNodeAllocator* aNodeAllocator)
{
NS_ASSERTION(mAttributes.GetSize() == 0, "attributes not recycled!");
return nsCParserNode::Init(aToken, aTokenAllocator, aNodeAllocator);
}
void nsCParserStartNode::AddAttribute(CToken* aToken)
{
NS_ASSERTION(0 != aToken, "Error: Token shouldn't be null!");
mAttributes.Push(aToken);
}
PRInt32
nsCParserStartNode::GetAttributeCount(PRBool askToken) const
{
PRInt32 result = 0;
if (askToken) {
result = mToken ? mToken->GetAttributeCount() : 0;
}
else {
result = mAttributes.GetSize();
}
return result;
}
const nsAString&
nsCParserStartNode::GetKeyAt(PRUint32 anIndex) const
{
if ((PRInt32)anIndex < mAttributes.GetSize()) {
CAttributeToken* attr =
NS_STATIC_CAST(CAttributeToken*, mAttributes.ObjectAt(anIndex));
if (attr) {
return attr->GetKey();
}
}
return EmptyString();
}
const nsAString&
nsCParserStartNode::GetValueAt(PRUint32 anIndex) const
{
if (PRInt32(anIndex) < mAttributes.GetSize()) {
CAttributeToken* attr =
NS_STATIC_CAST(CAttributeToken*, mAttributes.ObjectAt(anIndex));
if (attr) {
return attr->GetValue();
}
}
return EmptyString();
}
CToken*
nsCParserStartNode::PopAttributeToken()
{
return NS_STATIC_CAST(CToken*, mAttributes.Pop());
}
void nsCParserStartNode::GetSource(nsString& aString)
{
aString.Assign(PRUnichar('<'));
const PRUnichar* theTagName =
nsHTMLTags::GetStringValue(nsHTMLTag(mToken->GetTypeID()));
if (theTagName) {
aString.Append(theTagName);
}
PRInt32 index;
PRInt32 size = mAttributes.GetSize();
for (index = 0 ; index < size; ++index) {
CAttributeToken *theToken =
NS_STATIC_CAST(CAttributeToken*, mAttributes.ObjectAt(index));
if (theToken) {
theToken->AppendSourceTo(aString);
aString.Append(PRUnichar(' ')); //this will get removed...
}
}
aString.Append(PRUnichar('>'));
}
nsresult nsCParserStartNode::ReleaseAll()
{
NS_ASSERTION(0!=mTokenAllocator, "Error: no token allocator");
CToken* theAttrToken;
while ((theAttrToken = NS_STATIC_CAST(CToken*, mAttributes.Pop()))) {
IF_FREE(theAttrToken, mTokenAllocator);
}
nsCParserNode::ReleaseAll();
return NS_OK;
}

View File

@@ -0,0 +1,322 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* 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/
*
* 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.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/**
* MODULE NOTES:
* @update gess 4/1/98
*
* This class is defines the basic interface between the
* parser and the content sink. The parser will iterate
* over the collection of tokens that it sees from the
* tokenizer, coverting each related "group" into one of
* these. This object gets passed to the sink, and is
* then immediately reused.
*
* If you want to hang onto one of these, you should
* make your own copy.
*
*/
#ifndef NS_PARSERNODE__
#define NS_PARSERNODE__
#include "nsIParserNode.h"
#include "nsToken.h"
#include "nsString.h"
#include "nsParserCIID.h"
#include "nsDeque.h"
#include "nsDTDUtils.h"
class nsTokenAllocator;
class nsCParserNode : public nsIParserNode {
protected:
PRInt32 mRefCnt;
public:
void AddRef()
{
++mRefCnt;
}
void Release(nsFixedSizeAllocator& aPool)
{
if (--mRefCnt == 0)
Destroy(this, aPool);
}
#ifndef HEAP_ALLOCATED_NODES
protected:
/**
* Hide operator new; clients should use Create() instead.
*/
static void* operator new(size_t) CPP_THROW_NEW { return 0; }
/**
* Hide operator delete; clients should use Destroy() instead.
*/
static void operator delete(void*,size_t) {}
#endif
public:
static nsCParserNode* Create(CToken* aToken,
nsTokenAllocator* aTokenAllocator,
nsNodeAllocator* aNodeAllocator)
{
#ifdef HEAP_ALLOCATED_NODES
return new
#else
nsFixedSizeAllocator& pool = aNodeAllocator->GetArenaPool();
void* place = pool.Alloc(sizeof(nsCParserNode));
return ::new (place)
#endif
nsCParserNode(aToken, aTokenAllocator, aNodeAllocator);
}
static void Destroy(nsCParserNode* aNode, nsFixedSizeAllocator& aPool)
{
#ifdef HEAP_ALLOCATED_NODES
delete aNode;
#else
aNode->~nsCParserNode();
aPool.Free(aNode, sizeof(*aNode));
#endif
}
/**
* Default constructor
*/
nsCParserNode();
/**
* Constructor
* @update gess5/11/98
* @param aToken is the token this node "refers" to
*/
nsCParserNode(CToken* aToken,
nsTokenAllocator* aTokenAllocator,
nsNodeAllocator* aNodeAllocator=0);
/**
* Destructor
* @update gess5/11/98
*/
virtual ~nsCParserNode();
/**
* Init
* @update gess5/11/98
*/
virtual nsresult Init(CToken* aToken,
nsTokenAllocator* aTokenAllocator,
nsNodeAllocator* aNodeAllocator=0);
/**
* Retrieve the name of the node
* @update gess5/11/98
* @return string containing node name
*/
virtual const nsAString& GetTagName() const;
/**
* Retrieve the text from the given node
* @update gess5/11/98
* @return string containing node text
*/
virtual const nsAString& GetText() const;
/**
* Retrieve the type of the parser node.
* @update gess5/11/98
* @return node type.
*/
virtual PRInt32 GetNodeType() const;
/**
* Retrieve token type of parser node
* @update gess5/11/98
* @return token type
*/
virtual PRInt32 GetTokenType() const;
//***************************************
//methods for accessing key/value pairs
//***************************************
/**
* Retrieve the number of attributes in this node.
* @update gess5/11/98
* @return count of attributes (may be 0)
*/
virtual PRInt32 GetAttributeCount(PRBool askToken=PR_FALSE) const;
/**
* Retrieve the key (of key/value pair) at given index
* @update gess5/11/98
* @param anIndex is the index of the key you want
* @return string containing key.
*/
virtual const nsAString& GetKeyAt(PRUint32 anIndex) const;
/**
* Retrieve the value (of key/value pair) at given index
* @update gess5/11/98
* @param anIndex is the index of the value you want
* @return string containing value.
*/
virtual const nsAString& GetValueAt(PRUint32 anIndex) const;
/**
* NOTE: When the node is an entity, this will translate the entity
* to it's unicode value, and store it in aString.
* @update gess5/11/98
* @param aString will contain the resulting unicode string value
* @return int (unicode char or unicode index from table)
*/
virtual PRInt32 TranslateToUnicodeStr(nsString& aString) const;
/**
*
* @update gess5/11/98
* @param
* @return
*/
virtual void AddAttribute(CToken* aToken);
/**
* This getter retrieves the line number from the input source where
* the token occured. Lines are interpreted as occuring between \n characters.
* @update gess7/24/98
* @return int containing the line number the token was found on
*/
virtual PRInt32 GetSourceLineNumber(void) const;
/** This method pop the attribute token from the given index
* @update harishd 03/25/99
* @return token at anIndex
*/
virtual CToken* PopAttributeToken();
/** Retrieve a string containing the tag and its attributes in "source" form
* @update rickg 06June2000
* @return void
*/
virtual void GetSource(nsString& aString);
/**
* This pair of methods allows us to set a generic bit (for arbitrary use)
* on each node stored in the context.
* @update gess 11May2000
*/
virtual PRBool GetGenericState(void) const {return mGenericState;}
virtual void SetGenericState(PRBool aState) {mGenericState=aState;}
/** Release all the objects you're holding
* @update harishd 08/02/00
* @return void
*/
virtual nsresult ReleaseAll();
CToken* mToken;
PRInt32 mUseCount;
PRPackedBool mGenericState;
nsTokenAllocator* mTokenAllocator;
#ifdef HEAP_ALLOCATED_NODES
nsNodeAllocator* mNodeAllocator; // weak
#endif
};
class nsCParserStartNode : public nsCParserNode
{
public:
static nsCParserNode* Create(CToken* aToken,
nsTokenAllocator* aTokenAllocator,
nsNodeAllocator* aNodeAllocator)
{
#ifdef HEAP_ALLOCATED_NODES
return new
#else
nsFixedSizeAllocator& pool = aNodeAllocator->GetArenaPool();
void* place = pool.Alloc(sizeof(nsCParserStartNode));
return ::new (place)
#endif
nsCParserStartNode(aToken, aTokenAllocator, aNodeAllocator);
}
nsCParserStartNode()
: nsCParserNode(), mAttributes(0) { }
nsCParserStartNode(CToken* aToken,
nsTokenAllocator* aTokenAllocator,
nsNodeAllocator* aNodeAllocator = 0)
: nsCParserNode(aToken, aTokenAllocator, aNodeAllocator), mAttributes(0) { }
virtual ~nsCParserStartNode()
{
NS_ASSERTION(0 != mTokenAllocator, "Error: no token allocator");
CToken* theAttrToken = 0;
while ((theAttrToken = NS_STATIC_CAST(CToken*, mAttributes.Pop()))) {
IF_FREE(theAttrToken, mTokenAllocator);
}
}
virtual nsresult Init(CToken* aToken,
nsTokenAllocator* aTokenAllocator,
nsNodeAllocator* aNodeAllocator = 0);
virtual void AddAttribute(CToken* aToken);
virtual PRInt32 GetAttributeCount(PRBool askToken = PR_FALSE) const;
virtual const nsAString& GetKeyAt(PRUint32 anIndex) const;
virtual const nsAString& GetValueAt(PRUint32 anIndex) const;
virtual CToken* PopAttributeToken();
virtual void GetSource(nsString& aString);
virtual nsresult ReleaseAll();
protected:
nsDeque mAttributes;
};
#endif

View File

@@ -0,0 +1,257 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* 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/
*
* 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.
*
* The Original Code is Mozilla Communicator client code.
*
* The Initial Developer of the Original Code is Netscape Communications
* Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
*/
#include "nsDOMError.h"
#include "nsIAtom.h"
#include "nsParserService.h"
#include "nsHTMLEntities.h"
#include "nsElementTable.h"
#include "nsICategoryManager.h"
#include "nsCategoryManagerUtils.h"
extern "C" int MOZ_XMLCheckQName(const char* ptr, const char* end,
int ns_aware, const char** colon);
nsParserService::nsParserService() : mEntries(0)
{
mHaveNotifiedCategoryObservers = PR_FALSE;
}
nsParserService::~nsParserService()
{
nsObserverEntry *entry = nsnull;
while( (entry = NS_STATIC_CAST(nsObserverEntry*,mEntries.Pop())) ) {
NS_RELEASE(entry);
}
}
NS_IMPL_ISUPPORTS1(nsParserService, nsIParserService)
NS_IMETHODIMP
nsParserService::HTMLAtomTagToId(nsIAtom* aAtom, PRInt32* aId) const
{
nsAutoString tagName;
aAtom->ToString(tagName);
*aId = nsHTMLTags::LookupTag(tagName);
return NS_OK;
}
NS_IMETHODIMP
nsParserService::HTMLCaseSensitiveAtomTagToId(nsIAtom* aAtom,
PRInt32* aId) const
{
nsAutoString tagName;
aAtom->ToString(tagName);
*aId = nsHTMLTags::CaseSensitiveLookupTag(tagName.get());
return NS_OK;
}
NS_IMETHODIMP
nsParserService::HTMLStringTagToId(const nsAString &aTagName,
PRInt32* aId) const
{
*aId = nsHTMLTags::LookupTag(aTagName);
return NS_OK;
}
NS_IMETHODIMP
nsParserService::HTMLIdToStringTag(PRInt32 aId,
const PRUnichar **aTagName) const
{
*aTagName = nsHTMLTags::GetStringValue((nsHTMLTag)aId);
return NS_OK;
}
NS_IMETHODIMP
nsParserService::HTMLConvertEntityToUnicode(const nsAString& aEntity,
PRInt32* aUnicode) const
{
*aUnicode = nsHTMLEntities::EntityToUnicode(aEntity);
return NS_OK;
}
NS_IMETHODIMP
nsParserService::HTMLConvertUnicodeToEntity(PRInt32 aUnicode,
nsCString& aEntity) const
{
const char* str = nsHTMLEntities::UnicodeToEntity(aUnicode);
if (str) {
aEntity.Assign(str);
}
return NS_OK;
}
NS_IMETHODIMP
nsParserService::IsContainer(PRInt32 aId, PRBool& aIsContainer) const
{
aIsContainer = nsHTMLElement::IsContainer((eHTMLTags)aId);
return NS_OK;
}
NS_IMETHODIMP
nsParserService::IsBlock(PRInt32 aId, PRBool& aIsBlock) const
{
if((aId>eHTMLTag_unknown) && (aId<eHTMLTag_userdefined)) {
aIsBlock=((gHTMLElements[aId].IsMemberOf(kBlock)) ||
(gHTMLElements[aId].IsMemberOf(kBlockEntity)) ||
(gHTMLElements[aId].IsMemberOf(kHeading)) ||
(gHTMLElements[aId].IsMemberOf(kPreformatted))||
(gHTMLElements[aId].IsMemberOf(kList)));
}
else {
aIsBlock = PR_FALSE;
}
return NS_OK;
}
NS_IMETHODIMP
nsParserService::RegisterObserver(nsIElementObserver* aObserver,
const nsAString& aTopic,
const eHTMLTags* aTags)
{
nsresult result = NS_OK;
nsObserverEntry* entry = GetEntry(aTopic);
if(!entry) {
result = CreateEntry(aTopic,&entry);
NS_ENSURE_SUCCESS(result,result);
}
while (*aTags) {
if(*aTags != eHTMLTag_userdefined && *aTags <= NS_HTML_TAG_MAX) {
entry->AddObserver(aObserver,*aTags);
}
++aTags;
}
return result;
}
NS_IMETHODIMP
nsParserService::UnregisterObserver(nsIElementObserver* aObserver,
const nsAString& aTopic)
{
PRInt32 count = mEntries.GetSize();
for (PRInt32 i=0; i < count; ++i) {
nsObserverEntry* entry = NS_STATIC_CAST(nsObserverEntry*,mEntries.ObjectAt(i));
if (entry && entry->Matches(aTopic)) {
entry->RemoveObserver(aObserver);
}
}
return NS_OK;
}
NS_IMETHODIMP
nsParserService::GetTopicObservers(const nsAString& aTopic,
nsIObserverEntry** aEntry) {
nsresult result = NS_OK;
nsObserverEntry* entry = GetEntry(aTopic);
if (!entry) {
return NS_ERROR_NULL_POINTER;
}
NS_ADDREF(*aEntry = entry);
return result;
}
nsresult
nsParserService::CheckQName(const nsASingleFragmentString& aQName,
PRBool aNamespaceAware,
const PRUnichar** aColon)
{
const char* colon;
const PRUnichar *begin, *end;
aQName.BeginReading(begin);
aQName.EndReading(end);
int result = MOZ_XMLCheckQName(NS_REINTERPRET_CAST(const char*, begin),
NS_REINTERPRET_CAST(const char*, end),
aNamespaceAware, &colon);
*aColon = NS_REINTERPRET_CAST(const PRUnichar*, colon);
if (result == 0) {
return NS_OK;
}
// MOZ_EXPAT_EMPTY_QNAME || MOZ_EXPAT_INVALID_CHARACTER
if (result & (1 << 0) || result & (1 << 1)) {
return NS_ERROR_DOM_INVALID_CHARACTER_ERR;
}
return NS_ERROR_DOM_NAMESPACE_ERR;
}
class nsMatchesTopic : public nsDequeFunctor{
const nsAString& mString;
public:
PRBool matched;
nsObserverEntry* entry;
nsMatchesTopic(const nsAString& aString):mString(aString),matched(PR_FALSE){};
virtual void* operator()(void* anObject){
entry=NS_STATIC_CAST(nsObserverEntry*, anObject);
matched=mString.Equals(entry->mTopic);
return matched ? nsnull : anObject;
};
};
// XXX This may be more efficient as a HashTable instead of linear search
nsObserverEntry*
nsParserService::GetEntry(const nsAString& aTopic)
{
if (!mHaveNotifiedCategoryObservers) {
mHaveNotifiedCategoryObservers = PR_TRUE;
NS_CreateServicesFromCategory("parser-service-category",
NS_STATIC_CAST(nsISupports*,NS_STATIC_CAST(void*,this)),
"parser-service-start");
}
nsMatchesTopic matchesTopic(aTopic);
mEntries.FirstThat(*&matchesTopic);
return matchesTopic.matched?matchesTopic.entry:nsnull;
}
nsresult
nsParserService::CreateEntry(const nsAString& aTopic, nsObserverEntry** aEntry)
{
*aEntry = new nsObserverEntry(aTopic);
if (!aEntry) {
return NS_ERROR_OUT_OF_MEMORY;
}
NS_ADDREF(*aEntry);
mEntries.Push(*aEntry);
return NS_OK;
}

View File

@@ -0,0 +1,85 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* 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/
*
* 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.
*
* The Original Code is Mozilla Communicator client code.
*
* The Initial Developer of the Original Code is Netscape Communications
* Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
*/
#ifndef NS_PARSERSERVICE_H__
#define NS_PARSERSERVICE_H__
#include "nsIParserService.h"
#include "nsDTDUtils.h"
#include "nsVoidArray.h"
extern "C" int MOZ_XMLIsLetter(const char* ptr);
extern "C" int MOZ_XMLIsNCNameChar(const char* ptr);
class nsParserService : public nsIParserService {
public:
nsParserService();
virtual ~nsParserService();
NS_DECL_ISUPPORTS
NS_IMETHOD HTMLAtomTagToId(nsIAtom* aAtom, PRInt32* aId) const;
NS_IMETHOD HTMLCaseSensitiveAtomTagToId(nsIAtom* aAtom, PRInt32* aId) const;
NS_IMETHOD HTMLStringTagToId(const nsAString &aTagName,
PRInt32* aId) const;
NS_IMETHOD HTMLIdToStringTag(PRInt32 aId, const PRUnichar **aTagName) const;
NS_IMETHOD HTMLConvertEntityToUnicode(const nsAString& aEntity,
PRInt32* aUnicode) const;
NS_IMETHOD HTMLConvertUnicodeToEntity(PRInt32 aUnicode,
nsCString& aEntity) const;
NS_IMETHOD IsContainer(PRInt32 aId, PRBool& aIsContainer) const;
NS_IMETHOD IsBlock(PRInt32 aId, PRBool& aIsBlock) const;
// Observer mechanism
NS_IMETHOD RegisterObserver(nsIElementObserver* aObserver,
const nsAString& aTopic,
const eHTMLTags* aTags = nsnull);
NS_IMETHOD UnregisterObserver(nsIElementObserver* aObserver,
const nsAString& aTopic);
NS_IMETHOD GetTopicObservers(const nsAString& aTopic,
nsIObserverEntry** aEntry);
nsresult CheckQName(const nsASingleFragmentString& aQName,
PRBool aNamespaceAware, const PRUnichar** aColon);
PRBool IsXMLLetter(PRUnichar aChar)
{
return MOZ_XMLIsLetter(NS_REINTERPRET_CAST(const char*, &aChar));
}
PRBool IsXMLNCNameChar(PRUnichar aChar)
{
return MOZ_XMLIsNCNameChar(NS_REINTERPRET_CAST(const char*, &aChar));
}
protected:
nsObserverEntry* GetEntry(const nsAString& aTopic);
nsresult CreateEntry(const nsAString& aTopic,
nsObserverEntry** aEntry);
nsDeque mEntries; //each topic holds a list of observers per tag.
PRBool mHaveNotifiedCategoryObservers;
};
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,389 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* 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/
*
* 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.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/**
* MODULE NOTES:
* @update gess 4/1/98
*
* The scanner is a low-level service class that knows
* how to consume characters out of an (internal) stream.
* This class also offers a series of utility methods
* that most tokenizers want, such as readUntil(),
* readWhile() and SkipWhitespace().
*/
#ifndef SCANNER
#define SCANNER
#include "nsCOMPtr.h"
#include "nsString.h"
#include "nsIParser.h"
#include "prtypes.h"
#include "nsIUnicodeDecoder.h"
#include "nsScannerString.h"
#include "nsIInputStream.h"
class nsReadEndCondition {
public:
const PRUnichar *mChars;
PRUnichar mFilter;
explicit nsReadEndCondition(const PRUnichar* aTerminateChars);
private:
nsReadEndCondition(const nsReadEndCondition& aOther); // No copying
void operator=(const nsReadEndCondition& aOther); // No assigning
};
class nsScanner {
public:
/**
* Use this constructor if you want i/o to be based on
* a single string you hand in during construction.
* This short cut was added for Javascript.
*
* @update ftang 3/02/99
* @param aCharset charset
* @param aCharsetSource - where the charset info came from
* @param aMode represents the parser mode (nav, other)
* @return
*/
nsScanner(const nsAString& anHTMLString, const nsACString& aCharset, PRInt32 aSource);
/**
* Use this constructor if you want i/o to be based on
* a file (therefore a stream) or just data you provide via Append().
*
* @update ftang 3/02/99
* @param aCharset charset
* @param aCharsetSource - where the charset info came from
* @param aMode represents the parser mode (nav, other)
* @return
*/
nsScanner(nsString& aFilename,PRBool aCreateStream, const nsACString& aCharset, PRInt32 aSource);
/**
* Use this constructor if you want i/o to be stream based.
*
* @update ftang 3/02/99
* @param aCharset charset
* @param aCharsetSource - where the charset info came from
* @param aMode represents the parser mode (nav, other)
* @return
*/
nsScanner(const nsAString& aFilename, nsIInputStream* aStream, const nsACString& aCharset, PRInt32 aSource);
~nsScanner();
/**
* retrieve next char from internal input stream
*
* @update gess 3/25/98
* @param ch is the char to accept new value
* @return error code reflecting read status
*/
nsresult GetChar(PRUnichar& ch);
/**
* peek ahead to consume next char from scanner's internal
* input buffer
*
* @update gess 3/25/98
* @param ch is the char to accept new value
* @return error code reflecting read status
*/
nsresult Peek(PRUnichar& ch, PRUint32 aOffset=0);
nsresult Peek(nsAString& aStr, PRInt32 aNumChars);
/**
* Skip over chars as long as they're in aSkipSet
*
* @update gess 3/25/98
* @param set of chars to be skipped
* @return error code
*/
nsresult SkipOver(nsString& SkipChars);
/**
* Skip over chars as long as they equal given char
*
* @update gess 3/25/98
* @param char to be skipped
* @return error code
*/
nsresult SkipOver(PRUnichar aSkipChar);
/**
* Skip over chars until they're in aValidSet
*
* @update gess 3/25/98
* @param aValid set contains chars you're looking for
* @return error code
*/
nsresult SkipTo(nsString& aValidSet);
/**
* Skip over chars as long as they're in aSequence
*
* @update gess 3/25/98
* @param contains sequence to be skipped
* @return error code
*/
nsresult SkipPast(nsString& aSequence);
/**
* Skip whitespace on scanner input stream
*
* @update gess 3/25/98
* @return error status
*/
nsresult SkipWhitespace(PRInt32& aNewlinesSkipped);
/**
* Determine if the scanner has reached EOF.
* This method can also cause the buffer to be filled
* if it happens to be empty
*
* @update gess 3/25/98
* @return PR_TRUE upon eof condition
*/
nsresult Eof(void);
/**
* Consume characters until you find the terminal char
*
* @update gess 3/25/98
* @param aString receives new data from stream
* @param addTerminal tells us whether to append terminal to aString
* @return error code
*/
nsresult GetIdentifier(nsString& aString,PRBool allowPunct=PR_FALSE);
nsresult ReadIdentifier(nsString& aString,PRBool allowPunct=PR_FALSE);
nsresult ReadIdentifier(nsScannerIterator& aStart,
nsScannerIterator& aEnd,
PRBool allowPunct=PR_FALSE);
nsresult ReadNumber(nsString& aString,PRInt32 aBase);
nsresult ReadWhitespace(nsString& aString,
PRInt32& aNewlinesSkipped);
nsresult ReadWhitespace(nsScannerIterator& aStart,
nsScannerIterator& aEnd,
PRInt32& aNewlinesSkipped);
/**
* Consume characters until you find the terminal char
*
* @update gess 3/25/98
* @param aString receives new data from stream
* @param aTerminal contains terminating char
* @param addTerminal tells us whether to append terminal to aString
* @return error code
*/
nsresult ReadUntil(nsAString& aString,
PRUnichar aTerminal,
PRBool addTerminal);
/**
* Consume characters until you find one contained in given
* terminal set.
*
* @update gess 3/25/98
* @param aString receives new data from stream
* @param aTermSet contains set of terminating chars
* @param addTerminal tells us whether to append terminal to aString
* @return error code
*/
nsresult ReadUntil(nsAString& aString,
const nsReadEndCondition& aEndCondition,
PRBool addTerminal);
nsresult ReadUntil(nsScannerIterator& aStart,
nsScannerIterator& aEnd,
const nsReadEndCondition& aEndCondition,
PRBool addTerminal);
/**
* Consume characters while they're members of anInputSet
*
* @update gess 3/25/98
* @param aString receives new data from stream
* @param anInputSet contains valid chars
* @param addTerminal tells us whether to append terminal to aString
* @return error code
*/
nsresult ReadWhile(nsString& aString,nsString& anInputSet,PRBool addTerminal);
/**
* Records current offset position in input stream. This allows us
* to back up to this point if the need should arise, such as when
* tokenization gets interrupted.
*
* @update gess 5/12/98
* @param
* @return
*/
void Mark(void);
/**
* Resets current offset position of input stream to marked position.
* This allows us to back up to this point if the need should arise,
* such as when tokenization gets interrupted.
* NOTE: IT IS REALLY BAD FORM TO CALL RELEASE WITHOUT CALLING MARK FIRST!
*
* @update gess 5/12/98
* @param
* @return
*/
void RewindToMark(void);
/**
*
*
* @update harishd 01/12/99
* @param
* @return
*/
PRBool UngetReadable(const nsAString& aBuffer);
/**
*
*
* @update gess 5/13/98
* @param
* @return
*/
nsresult Append(const nsAString& aBuffer);
/**
*
*
* @update gess 5/21/98
* @param
* @return
*/
nsresult Append(const char* aBuffer, PRUint32 aLen);
/**
* Call this to copy bytes out of the scanner that have not yet been consumed
* by the tokenization process.
*
* @update gess 5/12/98
* @param aCopyBuffer is where the scanner buffer will be copied to
* @return nada
*/
void CopyUnusedData(nsString& aCopyBuffer);
/**
* Retrieve the name of the file that the scanner is reading from.
* In some cases, it's just a given name, because the scanner isn't
* really reading from a file.
*
* @update gess 5/12/98
* @return
*/
nsString& GetFilename(void);
static void SelfTest();
/**
* Use this setter to change the scanner's unicode decoder
*
* @update ftang 3/02/99
* @param aCharset a normalized (alias resolved) charset name
* @param aCharsetSource- where the charset info came from
* @return
*/
nsresult SetDocumentCharset(const nsACString& aCharset, PRInt32 aSource);
void BindSubstring(nsScannerSubstring& aSubstring, const nsScannerIterator& aStart, const nsScannerIterator& aEnd);
void CurrentPosition(nsScannerIterator& aPosition);
void EndReading(nsScannerIterator& aPosition);
void SetPosition(nsScannerIterator& aPosition,
PRBool aTruncate = PR_FALSE,
PRBool aReverse = PR_FALSE);
void ReplaceCharacter(nsScannerIterator& aPosition,
PRUnichar aChar);
/**
* Internal method used to cause the internal buffer to
* be filled with data.
*
* @update gess4/3/98
*/
PRBool IsIncremental(void) {return mIncremental;}
void SetIncremental(PRBool anIncrValue) {mIncremental=anIncrValue;}
protected:
enum {eBufferSizeThreshold=0x1000}; //4K
/**
* Internal method used to cause the internal buffer to
* be filled with data.
*
* @update gess4/3/98
*/
nsresult FillBuffer(void);
void AppendToBuffer(nsScannerString::Buffer*);
void AppendToBuffer(const nsAString& aStr) { AppendToBuffer(nsScannerString::AllocBufferFromString(aStr)); }
void AppendASCIItoBuffer(const char* aData, PRUint32 aLen);
nsCOMPtr<nsIInputStream> mInputStream;
nsScannerString* mSlidingBuffer;
nsScannerIterator mCurrentPosition; // The position we will next read from in the scanner buffer
nsScannerIterator mMarkPosition; // The position last marked (we may rewind to here)
nsScannerIterator mEndPosition; // The current end of the scanner buffer
nsString mFilename;
PRUint32 mCountRemaining; // The number of bytes still to be read
// from the scanner buffer
PRUint32 mTotalRead;
PRPackedBool mIncremental;
PRInt32 mCharsetSource;
nsCString mCharset;
nsIUnicodeDecoder *mUnicodeDecoder;
};
#endif

View File

@@ -0,0 +1,578 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:set ts=2 sw=2 sts=2 et cindent: */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla 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/MPL/
*
* 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.
*
* The Original Code is Mozilla.
*
* The Initial Developer of the Original Code is IBM Corporation.
* Portions created by IBM Corporation are Copyright (C) 2003
* IBM Corporation. All Rights Reserved.
*
* Contributor(s):
* Darin Fisher <darin@meer.net>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include <stdlib.h>
#include "nsScannerString.h"
/**
* nsScannerBufferList
*/
nsScannerBufferList::Buffer*
nsScannerBufferList::AllocBufferFromString( const nsAString& aString )
{
PRUint32 len = aString.Length();
Buffer* buf = (Buffer*) malloc(sizeof(Buffer) + (len + 1) * sizeof(PRUnichar));
if (buf)
{
// leave PRCList members of Buffer uninitialized
buf->mUsageCount = 0;
buf->mDataEnd = buf->DataStart() + len;
nsAString::const_iterator source;
aString.BeginReading(source);
nsCharTraits<PRUnichar>::copy(buf->DataStart(), source.get(), len);
// XXX null terminate. this shouldn't be required, but we do it because
// nsScanner erroneously thinks it can dereference DataEnd :-(
*buf->mDataEnd = PRUnichar(0);
}
return buf;
}
nsScannerBufferList::Buffer*
nsScannerBufferList::AllocBuffer( PRUint32 capacity )
{
Buffer* buf = (Buffer*) malloc(sizeof(Buffer) + (capacity + 1) * sizeof(PRUnichar));
if (buf)
{
// leave PRCList members of Buffer uninitialized
buf->mUsageCount = 0;
buf->mDataEnd = buf->DataStart() + capacity;
// XXX null terminate. this shouldn't be required, but we do it because
// nsScanner erroneously thinks it can dereference DataEnd :-(
*buf->mDataEnd = PRUnichar(0);
}
return buf;
}
void
nsScannerBufferList::ReleaseAll()
{
while (!PR_CLIST_IS_EMPTY(&mBuffers))
{
PRCList* node = PR_LIST_HEAD(&mBuffers);
PR_REMOVE_LINK(node);
//printf(">>> freeing buffer @%p\n", node);
free(NS_STATIC_CAST(Buffer*, node));
}
}
void
nsScannerBufferList::SplitBuffer( const Position& pos )
{
// splitting to the right keeps the work string and any extant token
// pointing to and holding a reference count on the same buffer.
Buffer* bufferToSplit = pos.mBuffer;
NS_ASSERTION(bufferToSplit, "null pointer");
PRUint32 splitOffset = pos.mPosition - bufferToSplit->DataStart();
NS_ASSERTION(pos.mPosition >= bufferToSplit->DataStart() &&
splitOffset <= bufferToSplit->DataLength(),
"split offset is outside buffer");
PRUint32 len = bufferToSplit->DataLength() - splitOffset;
Buffer* new_buffer = AllocBuffer(len);
if (new_buffer)
{
nsCharTraits<PRUnichar>::copy(new_buffer->DataStart(),
bufferToSplit->DataStart() + splitOffset,
len);
InsertAfter(new_buffer, bufferToSplit);
bufferToSplit->SetDataLength(splitOffset);
}
}
void
nsScannerBufferList::DiscardUnreferencedPrefix( Buffer* aBuf )
{
if (aBuf == Head())
{
while (!PR_CLIST_IS_EMPTY(&mBuffers) && !Head()->IsInUse())
{
Buffer* buffer = Head();
PR_REMOVE_LINK(buffer);
free(buffer);
}
}
}
size_t
nsScannerBufferList::Position::Distance( const Position& aStart, const Position& aEnd )
{
size_t result = 0;
if (aStart.mBuffer == aEnd.mBuffer)
{
result = aEnd.mPosition - aStart.mPosition;
}
else
{
result = aStart.mBuffer->DataEnd() - aStart.mPosition;
for (Buffer* b = aStart.mBuffer->Next(); b != aEnd.mBuffer; b = b->Next())
result += b->DataLength();
result += aEnd.mPosition - aEnd.mBuffer->DataStart();
}
return result;
}
/**
* nsScannerSubstring
*/
nsScannerSubstring::nsScannerSubstring()
: mStart(nsnull, nsnull)
, mEnd(nsnull, nsnull)
, mBufferList(nsnull)
, mLength(0)
, mIsDirty(PR_TRUE)
{
}
nsScannerSubstring::nsScannerSubstring( const nsAString& s )
: mBufferList(nsnull)
, mIsDirty(PR_TRUE)
{
Rebind(s);
}
nsScannerSubstring::~nsScannerSubstring()
{
release_ownership_of_buffer_list();
}
PRInt32
nsScannerSubstring::CountChar( PRUnichar c ) const
{
/*
re-write this to use a counting sink
*/
size_type result = 0;
size_type lengthToExamine = Length();
nsScannerIterator iter;
for ( BeginReading(iter); ; )
{
PRInt32 lengthToExamineInThisFragment = iter.size_forward();
const PRUnichar* fromBegin = iter.get();
result += size_type(NS_COUNT(fromBegin, fromBegin+lengthToExamineInThisFragment, c));
if ( !(lengthToExamine -= lengthToExamineInThisFragment) )
return result;
iter.advance(lengthToExamineInThisFragment);
}
// never reached; quiets warnings
return 0;
}
void
nsScannerSubstring::Rebind( const nsScannerSubstring& aString,
const nsScannerIterator& aStart,
const nsScannerIterator& aEnd )
{
// allow for the case where &aString == this
aString.acquire_ownership_of_buffer_list();
release_ownership_of_buffer_list();
mStart = aStart;
mEnd = aEnd;
mBufferList = aString.mBufferList;
mLength = Distance(aStart, aEnd);
mIsDirty = PR_TRUE;
}
void
nsScannerSubstring::Rebind( const nsAString& aString )
{
release_ownership_of_buffer_list();
mBufferList = new nsScannerBufferList(AllocBufferFromString(aString));
mIsDirty = PR_TRUE;
init_range_from_buffer_list();
acquire_ownership_of_buffer_list();
}
const nsString&
nsScannerSubstring::AsString() const
{
if (mIsDirty)
{
nsScannerSubstring* mutable_this = NS_CONST_CAST(nsScannerSubstring*, this);
nsScannerIterator start, end;
CopyUnicodeTo(BeginReading(start), EndReading(end), mutable_this->mFlattenedRep);
mutable_this->mIsDirty = PR_FALSE;
}
return mFlattenedRep;
}
nsScannerIterator&
nsScannerSubstring::BeginReading( nsScannerIterator& iter ) const
{
iter.mOwner = this;
iter.mFragment.mBuffer = mStart.mBuffer;
iter.mFragment.mFragmentStart = mStart.mPosition;
if (mStart.mBuffer == mEnd.mBuffer)
iter.mFragment.mFragmentEnd = mEnd.mPosition;
else
iter.mFragment.mFragmentEnd = mStart.mBuffer->DataEnd();
iter.mPosition = mStart.mPosition;
iter.normalize_forward();
return iter;
}
nsScannerIterator&
nsScannerSubstring::EndReading( nsScannerIterator& iter ) const
{
iter.mOwner = this;
iter.mFragment.mBuffer = mEnd.mBuffer;
iter.mFragment.mFragmentEnd = mEnd.mPosition;
if (mStart.mBuffer == mEnd.mBuffer)
iter.mFragment.mFragmentStart = mStart.mPosition;
else
iter.mFragment.mFragmentStart = mEnd.mBuffer->DataStart();
iter.mPosition = mEnd.mPosition;
// must not |normalize_backward| as that would likely invalidate tests like |while ( first != last )|
return iter;
}
PRBool
nsScannerSubstring::GetNextFragment( nsScannerFragment& frag ) const
{
// check to see if we are at the end of the buffer list
if (frag.mBuffer == mEnd.mBuffer)
return PR_FALSE;
frag.mBuffer = NS_STATIC_CAST(const Buffer*, PR_NEXT_LINK(frag.mBuffer));
if (frag.mBuffer == mStart.mBuffer)
frag.mFragmentStart = mStart.mPosition;
else
frag.mFragmentStart = frag.mBuffer->DataStart();
if (frag.mBuffer == mEnd.mBuffer)
frag.mFragmentEnd = mEnd.mPosition;
else
frag.mFragmentEnd = frag.mBuffer->DataEnd();
return PR_TRUE;
}
PRBool
nsScannerSubstring::GetPrevFragment( nsScannerFragment& frag ) const
{
// check to see if we are at the beginning of the buffer list
if (frag.mBuffer == mStart.mBuffer)
return PR_FALSE;
frag.mBuffer = NS_STATIC_CAST(const Buffer*, PR_PREV_LINK(frag.mBuffer));
if (frag.mBuffer == mStart.mBuffer)
frag.mFragmentStart = mStart.mPosition;
else
frag.mFragmentStart = frag.mBuffer->DataStart();
if (frag.mBuffer == mEnd.mBuffer)
frag.mFragmentEnd = mEnd.mPosition;
else
frag.mFragmentEnd = frag.mBuffer->DataEnd();
return PR_TRUE;
}
/**
* nsScannerString
*/
nsScannerString::nsScannerString( Buffer* aBuf )
{
mBufferList = new nsScannerBufferList(aBuf);
init_range_from_buffer_list();
acquire_ownership_of_buffer_list();
}
void
nsScannerString::AppendBuffer( Buffer* aBuf )
{
mBufferList->Append(aBuf);
mLength += aBuf->DataLength();
mEnd.mBuffer = aBuf;
mEnd.mPosition = aBuf->DataEnd();
mIsDirty = PR_TRUE;
}
void
nsScannerString::DiscardPrefix( const nsScannerIterator& aIter )
{
Position old_start(mStart);
mStart = aIter;
mLength -= Position::Distance(old_start, mStart);
mStart.mBuffer->IncrementUsageCount();
old_start.mBuffer->DecrementUsageCount();
mBufferList->DiscardUnreferencedPrefix(old_start.mBuffer);
mIsDirty = PR_TRUE;
}
void
nsScannerString::UngetReadable( const nsAString& aReadable, const nsScannerIterator& aInsertPoint )
/*
* Warning: this routine manipulates the shared buffer list in an unexpected way.
* The original design did not really allow for insertions, but this call promises
* that if called for a point after the end of all extant token strings, that no token string
* or the work string will be invalidated.
*
* This routine is protected because it is the responsibility of the derived class to keep those promises.
*/
{
Position insertPos(aInsertPoint);
mBufferList->SplitBuffer(insertPos);
// splitting to the right keeps the work string and any extant token pointing to and
// holding a reference count on the same buffer
Buffer* new_buffer = AllocBufferFromString(aReadable);
// make a new buffer with all the data to insert...
// BULLSHIT ALERT: we may have empty space to re-use in the split buffer, measure the cost
// of this and decide if we should do the work to fill it
Buffer* buffer_to_split = insertPos.mBuffer;
mBufferList->InsertAfter(new_buffer, buffer_to_split);
mLength += aReadable.Length();
mEnd.mBuffer = mBufferList->Tail();
mEnd.mPosition = mEnd.mBuffer->DataEnd();
mIsDirty = PR_TRUE;
}
void
nsScannerString::ReplaceCharacter(nsScannerIterator& aPosition, PRUnichar aChar)
{
// XXX Casting a const to non-const. Unless the base class
// provides support for writing iterators, this is the best
// that can be done.
PRUnichar* pos = NS_CONST_CAST(PRUnichar*, aPosition.get());
*pos = aChar;
mIsDirty = PR_TRUE;
}
/**
* utils -- based on code from nsReadableUtils.cpp
*/
void
CopyUnicodeTo( const nsScannerIterator& aSrcStart,
const nsScannerIterator& aSrcEnd,
nsAString& aDest )
{
nsAString::iterator writer;
aDest.SetLength(Distance(aSrcStart, aSrcEnd));
aDest.BeginWriting(writer);
nsScannerIterator fromBegin(aSrcStart);
copy_string(fromBegin, aSrcEnd, writer);
}
void
AppendUnicodeTo( const nsScannerIterator& aSrcStart,
const nsScannerIterator& aSrcEnd,
nsAString& aDest )
{
nsAString::iterator writer;
PRUint32 oldLength = aDest.Length();
aDest.SetLength(oldLength + Distance(aSrcStart, aSrcEnd));
aDest.BeginWriting(writer).advance(oldLength);
nsScannerIterator fromBegin(aSrcStart);
copy_string(fromBegin, aSrcEnd, writer);
}
PRBool
FindCharInReadable( PRUnichar aChar,
nsScannerIterator& aSearchStart,
const nsScannerIterator& aSearchEnd )
{
while ( aSearchStart != aSearchEnd )
{
PRInt32 fragmentLength;
if ( SameFragment(aSearchStart, aSearchEnd) )
fragmentLength = aSearchEnd.get() - aSearchStart.get();
else
fragmentLength = aSearchStart.size_forward();
const PRUnichar* charFoundAt = nsCharTraits<PRUnichar>::find(aSearchStart.get(), fragmentLength, aChar);
if ( charFoundAt ) {
aSearchStart.advance( charFoundAt - aSearchStart.get() );
return PR_TRUE;
}
aSearchStart.advance(fragmentLength);
}
return PR_FALSE;
}
PRBool
FindInReadable( const nsAString& aPattern,
nsScannerIterator& aSearchStart,
nsScannerIterator& aSearchEnd,
const nsStringComparator& compare )
{
PRBool found_it = PR_FALSE;
// only bother searching at all if we're given a non-empty range to search
if ( aSearchStart != aSearchEnd )
{
nsAString::const_iterator aPatternStart, aPatternEnd;
aPattern.BeginReading(aPatternStart);
aPattern.EndReading(aPatternEnd);
// outer loop keeps searching till we find it or run out of string to search
while ( !found_it )
{
// fast inner loop (that's what it's called, not what it is) looks for a potential match
while ( aSearchStart != aSearchEnd &&
compare(*aPatternStart, *aSearchStart) )
++aSearchStart;
// if we broke out of the `fast' loop because we're out of string ... we're done: no match
if ( aSearchStart == aSearchEnd )
break;
// otherwise, we're at a potential match, let's see if we really hit one
nsAString::const_iterator testPattern(aPatternStart);
nsScannerIterator testSearch(aSearchStart);
// slow inner loop verifies the potential match (found by the `fast' loop) at the current position
for(;;)
{
// we already compared the first character in the outer loop,
// so we'll advance before the next comparison
++testPattern;
++testSearch;
// if we verified all the way to the end of the pattern, then we found it!
if ( testPattern == aPatternEnd )
{
found_it = PR_TRUE;
aSearchEnd = testSearch; // return the exact found range through the parameters
break;
}
// if we got to end of the string we're searching before we hit the end of the
// pattern, we'll never find what we're looking for
if ( testSearch == aSearchEnd )
{
aSearchStart = aSearchEnd;
break;
}
// else if we mismatched ... it's time to advance to the next search position
// and get back into the `fast' loop
if ( compare(*testPattern, *testSearch) )
{
++aSearchStart;
break;
}
}
}
}
return found_it;
}
/**
* This implementation is simple, but does too much work.
* It searches the entire string from left to right, and returns the last match found, if any.
* This implementation will be replaced when I get |reverse_iterator|s working.
*/
PRBool
RFindInReadable( const nsAString& aPattern,
nsScannerIterator& aSearchStart,
nsScannerIterator& aSearchEnd,
const nsStringComparator& aComparator )
{
PRBool found_it = PR_FALSE;
nsScannerIterator savedSearchEnd(aSearchEnd);
nsScannerIterator searchStart(aSearchStart), searchEnd(aSearchEnd);
while ( searchStart != searchEnd )
{
if ( FindInReadable(aPattern, searchStart, searchEnd, aComparator) )
{
found_it = PR_TRUE;
// this is the best match so far, so remember it
aSearchStart = searchStart;
aSearchEnd = searchEnd;
// ...and get ready to search some more
// (it's tempting to set |searchStart=searchEnd| ... but that misses overlapping patterns)
++searchStart;
searchEnd = savedSearchEnd;
}
}
// if we never found it, return an empty range
if ( !found_it )
aSearchStart = aSearchEnd;
return found_it;
}

View File

@@ -0,0 +1,196 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* 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/
*
* 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.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsToken.h"
#include "nsScanner.h"
#ifdef MATCH_CTOR_DTOR
MOZ_DECL_CTOR_COUNTER(CToken)
#endif
static int TokenCount=0;
static int DelTokenCount=0;
int CToken::GetTokenCount(){return TokenCount-DelTokenCount;}
/**************************************************************
And now for the CToken...
**************************************************************/
/**
* Default constructor
*
* @update gess 7/21/98
*/
CToken::CToken(PRInt32 aTag) {
// Tokens are allocated through the arena ( not heap allocated..yay ).
// We, therefore, don't need this macro anymore..
#ifdef MATCH_CTOR_DTOR
MOZ_COUNT_CTOR(CToken);
#endif
mAttrCount=0;
mNewlineCount=0;
mLineNumber = 0;
mTypeID=aTag;
// Note that the use count starts with 1 instead of 0. This
// is because of the assumption that any token created is in
// use and therefore does not require an explicit addref, or
// rather IF_HOLD. This, also, will make sure that tokens created
// on the stack do not accidently hit the arena recycler.
mUseCount=1;
#ifdef NS_DEBUG
++TokenCount;
#endif
}
/**
* Decstructor
*
* @update gess 3/25/98
*/
CToken::~CToken() {
// Tokens are allocated through the arena ( not heap allocated..yay ).
// We, therefore, don't need this macro anymore..
#ifdef MATCH_CTOR_DTOR
MOZ_COUNT_DTOR(CToken);
#endif
++DelTokenCount;
mUseCount=0;
}
/**
* Virtual method used to tell this toke to consume his
* valid chars.
*
* @update gess 3/25/98
* @param aChar -- first char in sequence
* @param aScanner -- object to retrieve data from
* @return int error code
*/
nsresult CToken::Consume(PRUnichar aChar,nsScanner& aScanner,PRInt32 aMode) {
nsresult result=NS_OK;
return result;
}
/**
* Get string of full contents, suitable for debug dump.
* It should look exactly like the input source.
* @update gess5/11/98
* @return reference to string containing string value
*/
void CToken::GetSource(nsString& anOutputString){
anOutputString.Assign(GetStringValue());
}
/**
* @update harishd 3/23/00
* @return reference to string containing string value
*/
void CToken::AppendSourceTo(nsAString& anOutputString){
anOutputString.Append(GetStringValue());
}
/**
* Sets the internal ordinal value for this token.
* This method is deprecated, and will soon be going away.
*
* @update gess 3/25/98
* @param value -- new ordinal value for this token
*/
void CToken::SetTypeID(PRInt32 aTypeID) {
mTypeID=aTypeID;
}
/**
* Retrieves copy of internal ordinal value.
* This method is deprecated, and will soon be going away.
*
* @update gess 3/25/98
* @return int containing ordinal value
*/
PRInt32 CToken::GetTypeID(void) {
return mTypeID;
}
/**
* Retrieves copy of attr count for this token
*
* @update gess 3/25/98
* @return int containing attribute count
*/
PRInt16 CToken::GetAttributeCount(void) {
return mAttrCount;
}
/**
* Retrieve type of token. This class returns -1, but
* subclasses return something more meaningful.
*
* @update gess 3/25/98
* @return int value containing token type.
*/
PRInt32 CToken::GetTokenType(void) {
return -1;
}
/**
* retrieve this tokens classname.
*
* @update gess 3/25/98
* @return char* containing name of class
*/
const char* CToken::GetClassName(void) {
return "token";
}
/**
*
* @update gess 3/25/98
*/
void CToken::SelfTest(void) {
#ifdef _DEBUG
#endif
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,128 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* 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/
*
* 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.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
/**
* MODULE NOTES:
* @update gess 4/8/98
*
*
*/
#ifndef __NS_VIEWSOURCE_HTML_
#define __NS_VIEWSOURCE_HTML_
#include "nsIDTD.h"
#include "nsISupports.h"
#include "nsHTMLTokens.h"
#include "nsIHTMLContentSink.h"
#include "nsDTDUtils.h"
#include "nsParserNode.h"
#define NS_VIEWSOURCE_HTML_IID \
{0xb6003010, 0x7932, 0x11d2, \
{0x80, 0x1b, 0x0, 0x60, 0x8, 0xbf, 0xc4, 0x89 }}
class nsIParserNode;
class nsParser;
class nsITokenizer;
class nsCParserNode;
class CViewSourceHTML: public nsIDTD
{
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIDTD
CViewSourceHTML();
virtual ~CViewSourceHTML();
/**
* Set this to TRUE if you want the DTD to verify its
* context stack.
* @update gess 7/23/98
* @param
* @return
*/
virtual void SetVerification(PRBool aEnable);
private:
nsresult WriteTag(PRInt32 tagType,
const nsAString &aText,
PRInt32 attrCount,
PRBool aNewlineRequired);
nsresult WriteAttributes(PRInt32 attrCount);
nsresult GenerateSummary();
void StartNewPreBlock(void);
// Utility method for adding attributes to the nodes we generate
void AddAttrToNode(nsCParserStartNode& aNode,
nsTokenAllocator* aAllocator,
const nsAString& aAttrName,
const nsAString& aAttrValue);
protected:
nsParser* mParser;
nsIHTMLContentSink* mSink;
PRInt32 mLineNumber;
nsITokenizer* mTokenizer; // weak
PRInt32 mStartTag;
PRInt32 mEndTag;
PRInt32 mCommentTag;
PRInt32 mCDATATag;
PRInt32 mMarkupDeclaration;
PRInt32 mDocTypeTag;
PRInt32 mPITag;
PRInt32 mEntityTag;
PRInt32 mText;
PRInt32 mKey;
PRInt32 mValue;
PRInt32 mPopupTag;
PRInt32 mSummaryTag;
PRPackedBool mSyntaxHighlight;
PRPackedBool mWrapLongLines;
PRPackedBool mHasOpenRoot;
PRPackedBool mHasOpenBody;
nsDTDMode mDTDMode;
eParserCommands mParserCommand; //tells us to viewcontent/viewsource/viewerrors...
eParserDocType mDocType;
nsCString mMimeType;
PRInt32 mErrorCount;
PRInt32 mTagCount;
nsString mFilename;
nsString mTags;
nsString mErrors;
PRUint32 mTokenCount;
};
extern nsresult NS_NewViewSourceHTML(nsIDTD** aInstancePtrResult);
#endif

View File

@@ -0,0 +1,42 @@
[gecko]
#if SHARED_LIBRARY
dist/bin/components/@SHARED_LIBRARY@
#else
!staticcomp @LIBRARY@ @MODULE_NAME@
#endif
!xpt dist/bin/components/htmlparser.xpt
#if ENABLE_TESTS
[gecko-tests]
dist/bin/htmlrobot@BINS@
dist/bin/TestOutput@BINS@
dist/bin/TestOutSinks.pl
dist/bin/grabpage@BINS@
dist/bin/TestParser@BINS@
#if OS_ARCH==WINNT
dist/bin/@DLLP@dbgrobot@DLLS@
#else
dist/bin/@DLLP@DebugRobot@DLLS@
#endif
dist/bin/OutTestData/plain.html
dist/bin/OutTestData/plainwrap.out
dist/bin/OutTestData/plainnowrap.out
dist/bin/OutTestData/simple.html
dist/bin/OutTestData/simplecopy.out
dist/bin/OutTestData/simplefmt.out
dist/bin/OutTestData/entityxif.xif
dist/bin/OutTestData/entityxif.out
dist/bin/OutTestData/mailquote.html
dist/bin/OutTestData/mailquote.out
dist/bin/OutTestData/htmltable.html
dist/bin/OutTestData/htmltable.out
dist/bin/OutTestData/xifstuff.xif
dist/bin/OutTestData/xifstuff.out
dist/bin/OutTestData/doctype.xif
dist/bin/OutTestData/xifdtplain.out
dist/bin/OutTestData/xifdthtml.out
dist/bin/OutTestData/simplemail.html
dist/bin/OutTestData/simplemail.out
#endif

View File

@@ -0,0 +1,536 @@
?normalize_forward@?$nsReadingIterator@G@@QAEXXZ ; 2536676
?Peek@nsScanner@@QAEIAAGI@Z ; 1386151
?HasSpecialProperty@nsHTMLElement@@QBEHH@Z ; 828366
?IsContainer@nsHTMLElement@@SAHW4nsHTMLTag@@@Z ; 729893
?SetPosition@nsScanner@@QAEXAAV?$nsReadingIterator@G@@HH@Z ; 626582
?GetTypeID@CStartToken@@UAEHXZ ; 447481
?TagAt@nsDTDContext@@QBE?AW4nsHTMLTag@@H@Z ; 442499
?TagAt@nsEntryStack@@QBE?AW4nsHTMLTag@@H@Z ; 442499
?GetChar@nsScanner@@QAEIAAG@Z ; 436221
?GetTypeID@CToken@@UAEHXZ ; 414744
?Release@CToken@@QAEXXZ ; 410639
?IsTextTag@nsHTMLElement@@SAHW4nsHTMLTag@@@Z ; 409935
?GetNodeType@nsCParserNode@@UBEHXZ ; 376722
?SkipWhitespace@nsScanner@@QAEIXZ ; 349902
?IsMemberOf@nsHTMLElement@@QBEHH@Z ; 333035
?EntryAt@nsEntryStack@@QBEPAUnsTagEntry@@H@Z ; 287272
?AddRef@CValidDTD@@UAGKXZ ; 278594
?IsEmpty@CStartToken@@QAEHXZ ; 264976
??0CHTMLToken@@QAE@W4nsHTMLTag@@@Z ; 258646
??0CToken@@QAE@H@Z ; 258646
??1CHTMLToken@@UAE@XZ ; 258638
??1CToken@@UAE@XZ ; 258638
?PopToken@nsHTMLTokenizer@@UAEPAVCToken@@XZ ; 258424
?AddToken@nsHTMLTokenizer@@KAXAAPAVCToken@@IPAVnsDeque@@PAVnsTokenAllocator@@@Z ; 256836
?GetStylesAt@nsDTDContext@@QBEPAVnsEntryStack@@H@Z ; 245673
?Last@nsEntryStack@@QBE?AW4nsHTMLTag@@XZ ; 235733
?Last@nsDTDContext@@QBE?AW4nsHTMLTag@@XZ ; 235602
?CreateTokenOfType@nsTokenAllocator@@UAEPAVCToken@@W4eHTMLTokenTypes@@W4nsHTMLTag@@@Z ; 229890
?CanContain@nsHTMLElement@@QBEHW4nsHTMLTag@@@Z ; 220969
?CanContain@CNavDTD@@UBEHHH@Z ; 219977
?IsBlockCloser@nsHTMLElement@@SAHW4nsHTMLTag@@@Z ; 209858
?IsExcludableParent@nsHTMLElement@@QBEHW4nsHTMLTag@@@Z ; 207431
?IsInlineEntity@nsHTMLElement@@SAHW4nsHTMLTag@@@Z ; 202682
?IsFlowEntity@nsHTMLElement@@SAHW4nsHTMLTag@@@Z ; 202504
?GetAttributeCount@nsCParserNode@@UBEHH@Z ; 179873
?Release@nsCParserNode@@UAGKXZ ; 165379
?HandleToken@CNavDTD@@UAGIPAVCToken@@PAVnsIParser@@@Z ; 160934
?Mark@nsScanner@@QAEXXZ ; 159135
?ConsumeToken@nsHTMLTokenizer@@UAEIAAVnsScanner@@AAH@Z ; 158411
?CanContainType@nsHTMLElement@@QBEHH@Z ; 154767
??1nsCParserNode@@UAE@XZ ; 152036
?ReleaseAll@nsCParserNode@@UAEIXZ ; 152036
??0nsCParserNode@@QAE@PAVCToken@@HPAVnsTokenAllocator@@PAVnsNodeAllocator@@@Z ; 152036
?GetKey@CAttributeToken@@UAEABVnsAString@@XZ ; 143387
?GetTypeID@CEndToken@@UAEHXZ ; 137592
?advance@?$nsReadingIterator@G@@QAEAAV1@H@Z ; 134751
?IsResidualStyleTag@nsHTMLElement@@SAHW4nsHTMLTag@@@Z ; 134511
?GetValue@CAttributeToken@@UAEABVnsString@@XZ ; 132768
?GetTokenType@CAttributeToken@@UAEHXZ ; 130147
?CanOmit@CNavDTD@@UAEHW4nsHTMLTag@@0AAH@Z ; 126847
?normalize_backward@?$nsReadingIterator@G@@QAEXXZ ; 125570
?CreateNode@nsNodeAllocator@@UAEPAVnsIParserNode@@PAVCToken@@HPAVnsTokenAllocator@@@Z ; 123953
??_EnsCParserNode@@UAEPAXI@Z ; 123953
?GetAttributeCount@CToken@@UAEFXZ ; 123723
?IsBlockParent@nsHTMLElement@@SAHW4nsHTMLTag@@@Z ; 120135
?IsChildOfHead@nsHTMLElement@@SAHW4nsHTMLTag@@AAH@Z ; 118017
?GetTopic@CObserverService@@QAEPAVnsObserverTopic@@ABVnsString@@@Z ; 117352
?Matches@nsObserverTopic@@QAEHABVnsString@@@Z ; 117133
?HandleStartToken@CNavDTD@@QAEIPAVCToken@@@Z ; 117131
?WillHandleStartTag@CNavDTD@@IAEIPAVCToken@@W4nsHTMLTag@@AAVnsIParserNode@@@Z ; 117131
?GetObserverService@nsParser@@QAEPAVCObserverService@@XZ ; 117131
?Notify@CObserverService@@QAEIW4nsHTMLTag@@AAVnsIParserNode@@PAXABVnsString@@PAVnsIParser@@@Z ; 117131
?IsSectionTag@nsHTMLElement@@SAHW4nsHTMLTag@@@Z ; 117130
?GetObserversForTag@nsObserverTopic@@QAEPAVnsDeque@@W4nsHTMLTag@@@Z ; 117127
?Notify@nsObserverTopic@@QAEIW4nsHTMLTag@@AAVnsIParserNode@@PAXPAVnsIParser@@@Z ; 117127
?DidHandleStartTag@CNavDTD@@IAEIAAVnsIParserNode@@W4nsHTMLTag@@@Z ; 117082
?IsInlineParent@nsHTMLElement@@SAHW4nsHTMLTag@@@Z ; 115787
?HandleDefaultStartToken@CNavDTD@@QAEIPAVCToken@@W4nsHTMLTag@@PAVnsIParserNode@@@Z ; 115628
?OpenTransientStyles@CNavDTD@@QAEIW4nsHTMLTag@@@Z ; 114059
?SectionContains@nsHTMLElement@@QAEHW4nsHTMLTag@@H@Z ; 112309
?CurrentPosition@nsScanner@@QAEXAAV?$nsReadingIterator@G@@@Z ; 112070
?Release@nsExpatDTD@@UAGKXZ ; 110889
?GetDTD@nsParser@@UAGIPAPAVnsIDTD@@@Z ; 109930
?GetTokenType@CStartToken@@UAEHXZ ; 108973
?CanExclude@nsHTMLElement@@QBEHW4nsHTMLTag@@@Z ; 105291
?GetTokenType@CNewlineToken@@UAEHXZ ; 101882
?GetTokenType@nsCParserNode@@UBEHXZ ; 96577
?IsBlock@nsHTMLElement@@QAEHXZ ; 94270
?GetText@nsCParserNode@@UBEABVnsAString@@XZ ; 91365
?IsBlockEntity@nsHTMLElement@@QAEHXZ ; 88355
?ReadUntil@nsScanner@@QAEIAAV?$nsReadingIterator@G@@0AAVnsString@@H@Z ; 87559
?LookupTag@nsHTMLTags@@SA?AW4nsHTMLTag@@ABVnsString@@@Z ; 85990
?ConsumeTag@nsHTMLTokenizer@@MAEIGAAPAVCToken@@AAVnsScanner@@AAH@Z ; 84796
?BindSubstring@nsScanner@@QAEXAAVnsSlidingSubstring@@ABV?$nsReadingIterator@G@@1@Z ; 83943
?GetKeyAt@nsCParserNode@@UBEABVnsAString@@I@Z ; 82821
?AddLeaf@CNavDTD@@QAEIPBVnsIParserNode@@@Z ; 80112
?GetIndexOfChildOrSynonym@nsHTMLElement@@SAHAAVnsDTDContext@@W4nsHTMLTag@@@Z ; 78350
?ReadUntil@nsScanner@@QAEIAAVnsString@@GH@Z ; 73445
?GetTokenType@CEndToken@@UAEHXZ ; 72911
?GetValueAt@nsCParserNode@@UBEABVnsString@@I@Z ; 72202
??1CAttributeToken@@UAE@XZ ; 70372
??_ECAttributeToken@@UAEPAXI@Z ; 70372
?AddAttribute@nsCParserNode@@UAEXPAVCToken@@@Z ; 70151
??_GCWhitespaceToken@@UAEPAXI@Z ; 69351
?GetTokenType@CTextToken@@UAEHXZ ; 68258
?GetTokenType@CWhitespaceToken@@UAEHXZ ; 61015
??0CAttributeToken@@QAE@XZ ; 60742
?Consume@CAttributeToken@@UAEIGAAVnsScanner@@H@Z ; 60590
?SanitizeKey@CAttributeToken@@UAEXXZ ; 60369
??REntityNameComparitor@@UAEHPAX0@Z ; 58628
??_ECStartToken@@UAEPAXI@Z ; 55220
??1CStartToken@@UAE@XZ ; 55220
?GetStringValue@nsHTMLTags@@SAABVnsCString@@W4nsHTMLTag@@@Z ; 51863
?HTMLIdToStringTag@nsParserService@@UBGIHAAVnsString@@@Z ; 51296
??0CStartToken@@QAE@W4nsHTMLTag@@@Z ; 49953
?ConsumeStartTag@nsHTMLTokenizer@@MAEIGAAPAVCToken@@AAVnsScanner@@AAH@Z ; 48526
?Consume@CStartToken@@UAEIGAAVnsScanner@@H@Z ; 48526
?GetIdentifier@nsScanner@@QAEIAAVnsString@@H@Z ; 48526
?OpenContainer@CNavDTD@@QAEIPBVnsIParserNode@@W4nsHTMLTag@@HPAVnsEntryStack@@@Z ; 41712
?EnsureCapacityFor@nsEntryStack@@QAEXHH@Z ; 41465
?Push@nsEntryStack@@QAEXPBVnsIParserNode@@PAV1@@Z ; 41413
?CloseContainer@CNavDTD@@QAEIPBVnsIParserNode@@W4nsHTMLTag@@H@Z ; 41312
?Pop@nsEntryStack@@QAEPAVnsIParserNode@@XZ ; 41295
?Push@nsDTDContext@@QAEXPBVnsIParserNode@@PAVnsEntryStack@@@Z ; 41163
?Pop@nsDTDContext@@QAEPAVnsIParserNode@@AAPAVnsEntryStack@@@Z ; 41163
?ShouldVerifyHierarchy@nsHTMLElement@@QAEHXZ ; 40028
?CloseContainersTo@CNavDTD@@QAEIHW4nsHTMLTag@@H@Z ; 38619
?ConsumeQuotedString@@YAIGAAVnsString@@AAVnsScanner@@H@Z ; 38547
?SkipOver@nsScanner@@QAEIG@Z ; 38538
??0CNewlineToken@@QAE@XZ ; 38117
??_GCNewlineToken@@UAEPAXI@Z ; 38117
?HasOpenContainer@nsDTDContext@@QBEHW4nsHTMLTag@@@Z ; 36857
?HasOpenContainer@CNavDTD@@UBEHW4nsHTMLTag@@@Z ; 36857
?GetStringValue@CNewlineToken@@UAEABVnsAString@@XZ ; 36604
?SetAttributeCount@CToken@@UAEXF@Z ; 35754
??0CEndToken@@QAE@W4nsHTMLTag@@@Z ; 34876
?ConsumeEndTag@nsHTMLTokenizer@@MAEIGAAPAVCToken@@AAVnsScanner@@@Z ; 34863
?Consume@CEndToken@@UAEIGAAVnsScanner@@H@Z ; 34863
?HandleEndToken@CNavDTD@@QAEIPAVCToken@@@Z ; 34771
?CanOmitEndTag@nsHTMLElement@@QBEHXZ ; 34352
?CloseContainersTo@CNavDTD@@QAEIW4nsHTMLTag@@H@Z ; 34144
?GetSourceLineNumber@nsCParserNode@@UBEHXZ ; 30958
?ConsumeAttributes@nsHTMLTokenizer@@MAEIGPAVCStartToken@@AAVnsScanner@@@Z ; 30601
?CollectAttributes@CNavDTD@@IAEIAAVnsIParserNode@@W4nsHTMLTag@@H@Z ; 30505
?ConsumeNewline@nsHTMLTokenizer@@MAEIGAAPAVCToken@@AAVnsScanner@@@Z ; 29388
?Consume@CNewlineToken@@UAEIGAAVnsScanner@@H@Z ; 29388
?CreateTokenOfType@nsTokenAllocator@@UAEPAVCToken@@W4eHTMLTokenTypes@@W4nsHTMLTag@@ABVnsAString@@@Z ; 28696
?GetStringValue@CWhitespaceToken@@UAEABVnsAString@@XZ ; 28683
?GetContentSink@nsParser@@UAEPAVnsIContentSink@@XZ ; 28646
?HandleToken@CWellFormedDTD@@UAGIPAVCToken@@PAVnsIParser@@@Z ; 27835
??1CTextToken@@UAE@XZ ; 23801
?GetStringValue@CTextToken@@UAEABVnsAString@@XZ ; 23795
??_GCMarkupDeclToken@@UAEPAXI@Z ; 23744
??0CTextToken@@QAE@XZ ; 23726
?Consume@CTextToken@@UAEIGAAVnsScanner@@H@Z ; 22716
?ConsumeText@nsHTMLTokenizer@@MAEIAAPAVCToken@@AAVnsScanner@@@Z ; 22716
Tokenizer_HandleDefault ; 22603
?GetTokenType@CEntityToken@@UAEHXZ ; 21763
?ReadUntil@nsScanner@@QAEIAAVnsString@@0H@Z ; 21266
Tokenizer_HandleCharacterData ; 20918
?SetContainerInfo@CStartToken@@UAEXW4eContainerInfo@@@Z ; 19446
?IsWhitespaceTag@nsHTMLElement@@SAHW4nsHTMLTag@@@Z ; 18870
?HandleLeafToken@CWellFormedDTD@@IAEIPAVCToken@@@Z ; 17030
?GetContainerInfo@CStartToken@@UBE?AW4eContainerInfo@@XZ ; 16245
?ConsumeWhitespace@nsHTMLTokenizer@@MAEIGAAPAVCToken@@AAVnsScanner@@@Z ; 15630
??0CWhitespaceToken@@QAE@XZ ; 15630
?Consume@CWhitespaceToken@@UAEIGAAVnsScanner@@H@Z ; 15630
?ReadWhitespace@nsScanner@@QAEIAAVnsString@@@Z ; 15630
?CanContainSelf@nsHTMLElement@@QBEHXZ ; 12433
?EntityToUnicode@nsHTMLEntities@@SAHABVnsCString@@@Z ; 11472
??0EntityNode@@QAE@ABVnsCString@@@Z ; 11472
?EntityToUnicode@nsHTMLEntities@@SAHABVnsAString@@@Z ; 11472
?PeekToken@nsHTMLTokenizer@@UAEPAVCToken@@XZ ; 10192
?SetKey@CAttributeToken@@UAEXABVnsAString@@@Z ; 9782
??0CAttributeToken@@QAE@ABVnsAString@@@Z ; 9630
Tokenizer_HandleUnknownEncoding ; 9555
??0CWhitespaceToken@@QAE@ABVnsAString@@@Z ; 7559
?GetStringValue@CStartToken@@UAEABVnsAString@@XZ ; 6598
?IsBlockElement@CNavDTD@@UBEHHH@Z ; 5952
?CanPropagate@CNavDTD@@UAEHW4nsHTMLTag@@0H@Z ; 5788
??0CEndToken@@QAE@ABVnsAString@@W4nsHTMLTag@@@Z ; 5568
?ConsumeEntity@nsHTMLTokenizer@@MAEIGAAPAVCToken@@AAVnsScanner@@@Z ; 5568
??0CEntityToken@@QAE@XZ ; 5451
?ConsumeEntity@CEntityToken@@SAHGAAVnsString@@AAVnsScanner@@@Z ; 5451
?Consume@CEntityToken@@UAEIGAAVnsScanner@@H@Z ; 5451
?HandleEntityToken@CNavDTD@@QAEIPAVCToken@@@Z ; 5449
?TranslateToUnicodeStr@CEntityToken@@QAEHAAVnsString@@@Z ; 5431
?TranslateToUnicodeStr@nsCParserNode@@UBEHAAVnsString@@@Z ; 5430
??0CStartToken@@QAE@ABVnsAString@@W4nsHTMLTag@@@Z ; 5271
XML_GetIdAttributeIndex ; 5153
?HandleStartToken@CWellFormedDTD@@IAEIPAVCToken@@@Z ; 5153
?GetIDAttributeAtom@CStartToken@@UAEIPAPAVnsIAtom@@@Z ; 5153
Tokenizer_HandleEndElement ; 5153
Tokenizer_HandleStartElement ; 5153
?HandleEndToken@CWellFormedDTD@@IAEIPAVCToken@@@Z ; 5149
?GetTokenizer@CNavDTD@@UAGIAAPAVnsITokenizer@@@Z ; 4456
?ReadIdentifier@nsScanner@@QAEIAAVnsString@@H@Z ; 4298
?GetStringValue@CCommentToken@@UAEABVnsAString@@XZ ; 3531
?ForwardPropagate@CNavDTD@@UAEHAAVnsString@@W4nsHTMLTag@@1@Z ; 3352
?BackwardPropagate@CNavDTD@@UBEHAAVnsString@@W4nsHTMLTag@@1@Z ; 3352
?GetTokenType@CCommentToken@@UAEHXZ ; 3013
?HTMLConvertEntityToUnicode@nsParserService@@UBGIABVnsString@@PAH@Z ; 2895
?HTMLStringTagToId@nsParserService@@UBGIABVnsString@@PAH@Z ; 2350
?EndReading@nsScanner@@QAEXAAV?$nsReadingIterator@G@@@Z ; 2128
?Release@nsParserService@@UAGKXZ ; 1891
?QueryInterface@nsParserService@@UAGIABUnsID@@PAPAX@Z ; 1889
??REntityCodeComparitor@@UAEHPAX0@Z ; 1827
??_GCCommentToken@@UAEPAXI@Z ; 1774
?IsInlineElement@CNavDTD@@UBEHHH@Z ; 1640
?CloseHead@CNavDTD@@QAEIPBVnsIParserNode@@@Z ; 1613
?AddRef@nsParser@@UAGKXZ ; 1606
?Release@nsParser@@UAGKXZ ; 1602
?Tokenize@nsParser@@AAEIH@Z ; 1429
?BuildModel@nsParser@@MAEIXZ ; 1429
?DidTokenize@nsParser@@AAEHH@Z ; 1429
?WillTokenize@nsParser@@AAEHH@Z ; 1429
?WillTokenize@nsHTMLTokenizer@@UAEIHPAVnsTokenAllocator@@@Z ; 1429
?CreateContextStackFor@CNavDTD@@QAEIW4nsHTMLTag@@@Z ; 1413
??0CCommentToken@@QAE@XZ ; 1384
?Consume@CCommentToken@@UAEIGAAVnsScanner@@H@Z ; 1384
?HandleCommentToken@CNavDTD@@QAEIPAVCToken@@@Z ; 1377
?ConsumeComment@nsHTMLTokenizer@@MAEIGAAPAVCToken@@AAVnsScanner@@@Z ; 1364
?AppendToBuffer@nsScanner@@IAEXPAG00@Z ; 1308
?HandleOmittedTag@CNavDTD@@IAEIPAVCToken@@W4nsHTMLTag@@1PAVnsIParserNode@@@Z ; 1303
?GetIDAttributeAtom@nsCParserNode@@UBEIPAPAVnsIAtom@@@Z ; 1289
?GetTokenizer@CWellFormedDTD@@UAGIAAPAVnsITokenizer@@@Z ; 1260
?GetFilename@nsScanner@@QAEAAVnsString@@XZ ; 1239
?OpenHead@CNavDTD@@QAEIPBVnsIParserNode@@@Z ; 1218
?ReadNumber@nsScanner@@QAEIAAVnsString@@@Z ; 1153
?AddHeadLeaf@CNavDTD@@QAEIPAVnsIParserNode@@@Z ; 1140
?Eof@nsScanner@@QAEIXZ ; 1140
?FillBuffer@nsScanner@@IAEIXZ ; 1140
?BuildModel@CNavDTD@@UAGIPAVnsIParser@@PAVnsITokenizer@@PAVnsITokenObserver@@PAVnsIContentSink@@@Z ; 1126
?DidTokenize@nsHTMLTokenizer@@UAEIH@Z ; 1114
?ScanDocStructure@nsHTMLTokenizer@@IAEIH@Z ; 1114
?ResumeParse@nsParser@@UAEIHH@Z ; 1086
?WillBuildModel@nsParser@@IAEIAAVnsString@@@Z ; 1052
?RewindToMark@nsScanner@@QAEXXZ ; 1020
?LastOf@@YAHAAVnsDTDContext@@AAUTagList@@@Z ; 966
?Append@nsScanner@@QAEIPBDI@Z ; 848
?AddRef@nsExpatTokenizer@@UAGKXZ ; 796
?Release@nsXMLTokenizer@@UAGKXZ ; 794
XML_Parse ; 760
?WillResumeParse@COtherDTD@@UAGIXZ ; 737
?ParseXMLBuffer@nsExpatTokenizer@@IAEIPBDIH@Z ; 713
?WillInterruptParse@COtherDTD@@UAGIXZ ; 644
?SetEmpty@CStartToken@@QAEXH@Z ; 632
?AppendSource@CToken@@UAEXAAVnsString@@@Z ; 616
Tokenizer_HandleComment ; 613
?NodeAt@nsEntryStack@@QBEPAVnsIParserNode@@H@Z ; 610
?OnDataAvailable@nsParser@@UAGIPAVnsIRequest@@PAVnsISupports@@PAVnsIInputStream@@II@Z ; 609
??1nsEntryStack@@QAE@XZ ; 588
??0nsEntryStack@@QAE@XZ ; 588
?QueryInterface@nsParser@@UAGIABUnsID@@PAPAX@Z ; 538
?PushTokenFront@nsHTMLTokenizer@@UAEPAVCToken@@PAV2@@Z ; 522
?CollectSkippedContent@CNavDTD@@IAEIAAVnsIParserNode@@AAH@Z ; 491
??_GnsString@@UAEPAXI@Z ; 491
?SetSkippedContent@nsCParserNode@@UAEXAAVnsString@@@Z ; 491
?GetSkippedContent@nsCParserNode@@UBEABVnsString@@XZ ; 490
?IsWellFormed@CStartToken@@UBEHXZ ; 478
?IsContainer@CElement@@UAEHXZ ; 469
?IsContainer@COtherDTD@@UBEHH@Z ; 469
??0CParserContext@@QAE@PAVnsScanner@@PAXW4eParserCommands@@PAVnsIStreamObserver@@PAVnsIDTD@@W4eAutoDetectResult@@H@Z ; 440
?do_GetService@@YA?BVnsGetServiceByCID@@ABUnsID@@PAI@Z ; 440
?SetDocumentCharset@nsScanner@@QAEIABVnsString@@W4nsCharsetSource@@@Z ; 440
?PushContext@nsParser@@QAEXAAVCParserContext@@@Z ; 440
?RegisterObservers@CObserverService@@IAEXABVnsString@@@Z ; 438
??1nsScanner@@QAE@XZ ; 437
??1CParserContext@@QAE@XZ ; 437
?ConsumeUntil@CTextToken@@QAEIGHAAVnsScanner@@AAVnsString@@HAAH@Z ; 415
?SetMimeType@CParserContext@@QAEXABVnsString@@@Z ; 408
??0nsScannerString@@QAE@PAG00@Z ; 408
??0nsHTMLTokenizer@@QAE@HW4eParserDocType@@W4eParserCommands@@@Z ; 408
??1nsHTMLTokenizer@@UAE@XZ ; 406
??1nsScannerString@@UAE@XZ ; 406
??_GnsScannerString@@UAEPAXI@Z ; 406
?GetLine@nsExpatTokenizer@@IAEXPBDIIAAVnsString@@@Z ; 398
?HandleCommentToken@CWellFormedDTD@@IAEIPAVCToken@@@Z ; 390
??0CCommentToken@@QAE@ABVnsAString@@@Z ; 390
?IsParserEnabled@nsParser@@UAEHXZ ; 374
?Bind@CTextToken@@UAEXABVnsAString@@@Z ; 367
??0nsDTDContext@@QAE@XZ ; 339
??1nsDTDContext@@QAE@XZ ; 339
?GetNextWord@CWordTokenizer@@QAEHXZ ; 336
??1nsNodeAllocator@@UAE@XZ ; 328
??0nsNodeAllocator@@QAE@XZ ; 328
?QueryInterface@CNavDTD@@UAGIABUnsID@@PAPAX@Z ; 326
??_ECNavDTD@@UAEPAXI@Z ; 326
??1CNavDTD@@UAE@XZ ; 326
??0CNavDTD@@QAE@XZ ; 326
?NS_NewNavHTMLDTD@@YAIPAPAVnsIDTD@@@Z ; 326
?Release@nsHTMLTokenizer@@UAGKXZ ; 325
?CreateNewInstance@CNavDTD@@UAEIPAPAVnsIDTD@@@Z ; 325
??_EnsHTMLTokenizer@@UAEPAXI@Z ; 325
?QueryInterface@nsHTMLTokenizer@@UAGIABUnsID@@PAPAX@Z ; 325
?NS_NewHTMLTokenizer@@YAIPAPAVnsITokenizer@@HW4eParserDocType@@W4eParserCommands@@@Z ; 325
?GetCloseTargetForEndTag@nsHTMLElement@@QBE?AW4nsHTMLTag@@AAVnsDTDContext@@H@Z ; 323
?WillTokenize@nsExpatTokenizer@@UAEIHPAVnsTokenAllocator@@@Z ; 315
?ConsumeToken@nsExpatTokenizer@@UAEIAAVnsScanner@@AAH@Z ; 315
?DidTokenize@nsExpatTokenizer@@UAEIH@Z ; 315
?WillResumeParse@CViewSourceHTML@@UAGIXZ ; 315
?BuildModel@CWellFormedDTD@@UAGIPAVnsIParser@@PAVnsITokenizer@@PAVnsITokenObserver@@PAVnsIContentSink@@@Z ; 315
?advance@?$nsWritingIterator@G@@QAEAAV1@H@Z ; 307
?GetTokenType@CCDATASectionToken@@UAEHXZ ; 294
?ContainsSet@nsHTMLElement@@QBEHH@Z ; 281
?HandleScriptToken@CNavDTD@@QAEIPBVnsIParserNode@@@Z ; 280
XmlInitEncoding ; 260
?PushStyle@nsDTDContext@@QAEXPBVnsIParserNode@@@Z ; 250
?PopStyle@CNavDTD@@QAEIW4nsHTMLTag@@@Z ; 242
?Append@nsScanner@@QAEIABVnsAString@@@Z ; 236
XML_ParseBuffer ; 234
XML_GetBuffer ; 234
?Bind@CTextToken@@UAEXPAVnsScanner@@AAV?$nsReadingIterator@G@@1@Z ; 228
?HasOpenContainer@CNavDTD@@UBEHQBW4nsHTMLTag@@H@Z ; 227
??0nsScanner@@QAE@AAVnsString@@ABV1@W4nsCharsetSource@@@Z ; 223
?Parse@nsParser@@UAEIABVnsAString@@PAXABVnsString@@HHW4nsDTDMode@@@Z ; 223
?CopyUnusedData@nsScanner@@QAEXAAVnsString@@@Z ; 221
?Peek@nsScanner@@QAEIAAVnsAString@@H@Z ; 221
?PopContext@nsParser@@QAEPAVCParserContext@@XZ ; 221
?RegisterObserverForTag@nsObserverTopic@@QAEXPAVnsIElementObserver@@W4nsHTMLTag@@@Z ; 221
?LookupTag@nsHTMLTags@@SA?AW4nsHTMLTag@@ABVnsCString@@@Z ; 221
??RnsObserverReleaser@@UAEPAXPAX@Z ; 220
?SetContentSink@nsParser@@UAEPAVnsIContentSink@@PAV2@@Z ; 219
??0nsObserverTopic@@QAE@ABVnsString@@@Z ; 219
?CreateTopic@CObserverService@@QAEPAVnsObserverTopic@@ABVnsString@@@Z ; 219
??0nsParser@@QAE@PAVnsITokenObserver@@@Z ; 219
??0nsTokenAllocator@@QAE@XZ ; 219
??0CObserverService@@QAE@XZ ; 219
??0nsScanner@@QAE@AAVnsString@@HABV1@W4nsCharsetSource@@@Z ; 217
?SetDocumentCharset@nsParser@@UAEXAAVnsString@@W4nsCharsetSource@@@Z ; 217
?Parse@nsParser@@UAEIPAVnsIURI@@PAVnsIStreamObserver@@HPAXW4nsDTDMode@@@Z ; 217
?WillInterruptParse@CViewSourceHTML@@UAGIXZ ; 216
??1nsTokenAllocator@@UAE@XZ ; 216
??1CObserverService@@QAE@XZ ; 216
??1nsObserverTopic@@QAE@XZ ; 216
??1nsParser@@UAE@XZ ; 216
??_EnsParser@@UAEPAXI@Z ; 216
?SetDataIntoBundle@nsParser@@UAGIABVnsString@@PAVnsISupports@@@Z ; 204
?OpenHTML@CNavDTD@@QAEIPBVnsIParserNode@@@Z ; 204
?SetDataIntoBundle@nsParserBundle@@UAGIABVnsString@@PAVnsISupports@@@Z ; 204
?DidBuildModel@nsParser@@IAEII@Z ; 203
?RecycleNodes@CNavDTD@@IAEXPAVnsEntryStack@@@Z ; 193
?CanParse@CNavDTD@@UAE?AW4eAutoDetectResult@@AAVCParserContext@@AAVnsString@@H@Z ; 187
?GetSharedObjects@@YAAAVCSharedParserObjects@@XZ ; 187
?PushStyles@nsDTDContext@@QAEXPAVnsEntryStack@@@Z ; 186
?OnStartRequest@nsParser@@UAGIPAVnsIRequest@@PAVnsISupports@@@Z ; 185
?OnStopRequest@nsParser@@UAGIPAVnsIRequest@@PAVnsISupports@@IPBG@Z ; 180
??0CElement@@QAE@W4nsHTMLTag@@@Z ; 166
?PopStyle@nsDTDContext@@QAEPAVnsIParserNode@@W4nsHTMLTag@@@Z ; 166
?CloseForm@CNavDTD@@QAEIPBVnsIParserNode@@@Z ; 165
?OpenForm@CNavDTD@@QAEIPBVnsIParserNode@@@Z ; 165
?readable_distance@?$nsCharSourceTraits@V?$nsReadingIterator@G@@@@SAIABV?$nsReadingIterator@G@@0@Z ; 154
?write@?$nsWritingIterator@G@@QAEIPBGI@Z ; 154
?normalize_forward@?$nsWritingIterator@G@@QAEXXZ ; 154
?move@?$nsCharTraits@G@@SAPAGPAGPBGI@Z ; 154
?RecordTrailingContent@nsHTMLTokenizer@@MAEXPAVCStartToken@@AAVnsScanner@@V?$nsReadingIterator@G@@@Z ; 153
?copy_string@@YAAAV?$nsWritingIterator@G@@AAV?$nsReadingIterator@G@@ABV2@AAV1@@Z ; 153
Tokenizer_HandleEndCdataSection ; 147
Tokenizer_HandleStartCdataSection ; 147
??0CCDATASectionToken@@QAE@ABVnsAString@@@Z ; 147
?IsTableElement@nsHTMLElement@@QAEHXZ ; 146
XmlPrologStateInit ; 130
XmlGetUtf16InternalEncoding ; 130
XML_ParserCreate ; 130
XML_SetBase ; 130
XML_ParserFree ; 128
?GetDocumentCharset@nsParser@@UAEXAAVnsString@@AAW4nsCharsetSource@@@Z ; 126
?SetCommand@nsParser@@UAEXPBD@Z ; 123
?Initialize@@YAXW4nsHTMLTag@@00PAUTagList@@11111HHHHI110@Z ; 123
?GetTextLength@CTextToken@@UAEHXZ ; 119
?IsSpecialParent@nsHTMLElement@@QBEHW4nsHTMLTag@@@Z ; 108
?OpenBody@CNavDTD@@QAEIPBVnsIParserNode@@@Z ; 108
?GetLoggingSink@@YAPAVnsLoggingSink@@XZ ; 104
?DidBuildModel@CNavDTD@@UAGIIHPAVnsIParser@@PAVnsIContentSink@@@Z ; 104
?WillBuildModel@CNavDTD@@UAGIABVCParserContext@@PAVnsIContentSink@@@Z ; 104
?ResetCounters@nsDTDContext@@QAEXXZ ; 104
??_EnsParserBundle@@UAEPAXI@Z ; 102
?PrependTokens@nsHTMLTokenizer@@UAEXAAVnsDeque@@@Z ; 102
??1nsParserBundle@@UAE@XZ ; 102
??_GnsHashtable@@UAEPAXI@Z ; 102
?Release@nsParserBundle@@UAGKXZ ; 102
??0nsParserBundle@@QAE@XZ ; 102
?CloseHTML@CNavDTD@@QAEIPBVnsIParserNode@@@Z ; 99
?DidBuildModel@CWellFormedDTD@@UAGIIHPAVnsIParser@@PAVnsIContentSink@@@Z ; 99
?CloseBody@CNavDTD@@QAEIPBVnsIParserNode@@@Z ; 97
?do_GetIOService@@YA?BVnsGetServiceByCID@@PAI@Z ; 96
?NS_NewURI@@YAIPAPAVnsIURI@@PBDPAV1@PAVnsIIOService@@@Z ; 96
?AppendSource@CStartToken@@UAEXAAVnsString@@@Z ; 91
??0CWellFormedDTD@@QAE@XZ ; 84
?NS_NewWellFormed_DTD@@YAIPAPAVnsIDTD@@@Z ; 84
?QueryInterface@CWellFormedDTD@@UAGIABUnsID@@PAPAX@Z ; 84
??0nsExpatTokenizer@@QAE@PAVnsString@@@Z ; 83
XML_SetUnknownEncodingHandler ; 83
XML_SetExternalEntityRefHandler ; 83
XML_SetDefaultHandlerExpand ; 83
XML_SetUnparsedEntityDeclHandler ; 83
??0_XMLParserState@@QAE@XZ ; 83
XML_SetCharacterDataHandler ; 83
XML_SetParamEntityParsing ; 83
?BufferContainsHTML@@YAHAAVnsString@@AAH@Z ; 83
?WillBuildModel@CWellFormedDTD@@UAGIABVCParserContext@@PAVnsIContentSink@@@Z ; 83
?SetupExpatParser@nsExpatTokenizer@@IAEXXZ ; 83
XML_SetCommentHandler ; 83
?CanParse@CWellFormedDTD@@UAE?AW4eAutoDetectResult@@AAVCParserContext@@AAVnsString@@H@Z ; 83
XML_SetUserData ; 83
XML_SetElementHandler ; 83
XML_SetNotationDeclHandler ; 83
XML_SetProcessingInstructionHandler ; 83
XML_SetDoctypeDeclHandler ; 83
XML_SetCdataSectionHandler ; 83
?CreateNewInstance@CWellFormedDTD@@UAEIPAPAVnsIDTD@@@Z ; 83
??_GCWellFormedDTD@@UAEPAXI@Z ; 82
??1CWellFormedDTD@@UAE@XZ ; 82
??_G_XMLParserState@@QAEPAXI@Z ; 81
??_EnsExpatTokenizer@@UAEPAXI@Z ; 81
??1nsExpatTokenizer@@UAE@XZ ; 81
XmlParseXmlDecl ; 80
??0CTextToken@@QAE@ABVnsAString@@@Z ; 75
?HandleProcessingInstructionToken@CWellFormedDTD@@IAEIPAVCToken@@@Z ; 74
??0CInstructionToken@@QAE@ABVnsAString@@@Z ; 74
?GetTokenType@CInstructionToken@@UAEHXZ ; 74
Tokenizer_HandleProcessingInstruction ; 74
?ContinueParsing@nsParser@@UAEIXZ ; 61
?GetTokenType@CDoctypeDeclToken@@UAEHXZ ; 58
?OpenNoscript@CNavDTD@@QAEIPBVnsIParserNode@@PAVnsEntryStack@@@Z ; 57
?CloseNoscript@CNavDTD@@QAEIPBVnsIParserNode@@@Z ; 57
?CloseMap@CNavDTD@@QAEIPBVnsIParserNode@@@Z ; 56
?OpenMap@CNavDTD@@QAEIPBVnsIParserNode@@@Z ; 56
?Append@nsEntryStack@@QAEXPAV1@@Z ; 52
?BlockParser@nsParser@@UAEXXZ ; 48
?NS_OpenURI@@YAIPAPAVnsIInputStream@@PAVnsIURI@@PAVnsIIOService@@PAVnsILoadGroup@@PAVnsIInterfaceRequestor@@I@Z ; 48
?NS_OpenURI@@YAIPAPAVnsIChannel@@PAVnsIURI@@PAVnsIIOService@@PAVnsILoadGroup@@PAVnsIInterfaceRequestor@@I@Z ; 48
?OpenInputStream@nsExpatTokenizer@@KAIABVnsString@@0PAPAVnsIInputStream@@PAV2@@Z ; 48
Tokenizer_HandleExternalEntityRef ; 48
XML_ExternalEntityParserCreate ; 47
?LoadStream@nsExpatTokenizer@@KAIPAVnsIInputStream@@AAPAGAAI@Z ; 47
?SetCommand@nsParser@@UAEXW4eParserCommands@@@Z ; 47
XmlPrologStateInitExternalEntity ; 47
?PopAttributeToken@nsCParserNode@@UAEPAVCToken@@XZ ; 45
?Initialize@CElement@@SAXAAV1@W4nsHTMLTag@@AATCGroupMembers@@2@Z ; 40
Tokenizer_HandleEndDoctypeDecl ; 39
?HandleDocTypeDeclToken@CWellFormedDTD@@IAEIPAVCToken@@@Z ; 39
Tokenizer_HandleStartDoctypeDecl ; 39
??0CDoctypeDeclToken@@QAE@ABVnsAString@@W4nsHTMLTag@@@Z ; 39
?ConsumeSpecialMarkup@nsHTMLTokenizer@@MAEIGAAPAVCToken@@AAVnsScanner@@@Z ; 34
?GetContainedGroups@CInlineElement@@SAAATCGroupMembers@@XZ ; 32
?IsSpecialEntity@nsHTMLElement@@QAEHXZ ; 26
?UnblockParser@nsParser@@UAEXXZ ; 25
?GetTagName@@YAPBDH@Z ; 24
?AppendSource@CEndToken@@UAEXAAVnsString@@@Z ; 23
?Initialize@CElement@@SAXAAV1@W4nsHTMLTag@@@Z ; 22
?HandleSavedTokens@CNavDTD@@IAEIH@Z ; 21
?IsFontStyleEntity@nsHTMLElement@@QAEHXZ ; 20
?GetCommand@nsParser@@UAEXAAVnsString@@@Z ; 20
?GetContainedGroups@CBlockElement@@SAAATCGroupMembers@@XZ ; 19
?GetEntity@nsDTDContext@@QBEPAVCNamedEntity@@ABVnsString@@@Z ; 18
?SetStringValue@CDoctypeDeclToken@@UAEXABVnsAString@@@Z ; 14
?HandleDocTypeDeclToken@CNavDTD@@QAEIPAVCToken@@@Z ; 14
??0CDoctypeDeclToken@@QAE@W4nsHTMLTag@@@Z ; 14
?Consume@CDoctypeDeclToken@@UAEIGAAVnsScanner@@H@Z ; 14
?PushFront@nsEntryStack@@QAEXPBVnsIParserNode@@PAV1@@Z ; 13
?GetContainedGroups@CSpecialElement@@SAAATCGroupMembers@@XZ ; 11
?UngetReadable@nsScanner@@QAEHABVnsAString@@@Z ; 10
?IsBlock@nsParserService@@UBGIHAAH@Z ; 10
?UngetReadable@nsScannerString@@UAEXABVnsAString@@ABV?$nsReadingIterator@G@@@Z ; 10
?GetContainedGroups@CPhraseElement@@SAAATCGroupMembers@@XZ ; 9
?GetContainedGroups@CFontStyleElement@@SAAATCGroupMembers@@XZ ; 8
?Release@CDTDDebug@@UAGKXZ ; 6
?IsContainer@nsParserService@@UBGIHAAH@Z ; 6
?Initialize@CLeafElement@@SAXAAVCElement@@W4nsHTMLTag@@@Z ; 5
?Terminate@CNavDTD@@UAEIPAVnsIParser@@@Z ; 5
?Terminate@nsParser@@UAEIXZ ; 5
??0CTextContainer@@QAE@W4nsHTMLTag@@@Z ; 4
?HasOptionalEndTag@@YAHW4nsHTMLTag@@@Z ; 4
?Initialize@CTextContainer@@SAXAAVCElement@@W4nsHTMLTag@@@Z ; 4
?GetClassObject@nsParserModule@@UAGIPAVnsIComponentManager@@ABUnsID@@1PAPAX@Z ; 4
?Initialize@CBlockElement@@SAXAAVCElement@@W4nsHTMLTag@@@Z ; 3
?CanContain@CElement@@UAEHPAV1@PAVnsDTDContext@@@Z ; 3
?CanContain@COtherDTD@@UBEHHH@Z ; 3
?ReadNumber@nsScanner@@QAEIAAV?$nsReadingIterator@G@@0@Z ; 3
??_ECTransitionalDTD@@UAEPAXI@Z ; 2
??1CTransitionalDTD@@UAE@XZ ; 2
??0CTransitionalDTD@@QAE@XZ ; 2
??0CSpecialElement@@QAE@W4nsHTMLTag@@@Z ; 2
??1COtherDTD@@UAE@XZ ; 2
?Initialize@CInlineElement@@SAXAAVCElement@@W4nsHTMLTag@@@Z ; 2
?Initialize@CHeadElement@@SAXAAVCElement@@W4nsHTMLTag@@@Z ; 2
??_GnsNodeAllocator@@UAEPAXI@Z ; 2
??0COtherDTD@@QAE@XZ ; 2
?Initialize@CFontStyleElement@@SAXAAVCElement@@W4nsHTMLTag@@@Z ; 2
?QueryInterface@COtherDTD@@UAGIABUnsID@@PAPAX@Z ; 2
?Initialize@CFrameElement@@SAXAAVCElement@@W4nsHTMLTag@@@Z ; 2
?Initialize@CSpecialElement@@SAXAAVCElement@@W4nsHTMLTag@@@Z ; 2
?Initialize@CAppletElement@@SAXAAVCElement@@W4nsHTMLTag@@@Z ; 2
?OpenFrameset@CNavDTD@@QAEIPBVnsIParserNode@@@Z ; 2
?CloseFrameset@CNavDTD@@QAEIPBVnsIParserNode@@@Z ; 2
?Remove@nsEntryStack@@QAEPAVnsIParserNode@@HW4nsHTMLTag@@@Z ; 2
??_EnsParserModule@@UAEPAXI@Z ; 1
?AddRefTable@nsHTMLTags@@SAXXZ ; 1
?QueryInterface@nsParserModule@@UAGIABUnsID@@PAPAX@Z ; 1
?Initialize@CTopLevelElement@@SAXAAVCElement@@W4nsHTMLTag@@@Z ; 1
?Initialize@CFormElement@@SAXAAVCElement@@W4nsHTMLTag@@@Z ; 1
??0CTextAreaElement@@QAE@XZ ; 1
??0nsParserModule@@QAE@XZ ; 1
?CanUnload@nsParserModule@@UAGIPAVnsIComponentManager@@PAH@Z ; 1
??0nsParserService@@QAE@XZ ; 1
?Shutdown@nsParserModule@@IAEXXZ ; 1
??_EEntityNameComparitor@@UAEPAXI@Z ; 1
?GetContainedGroups@CFormControlElement@@SAAATCGroupMembers@@XZ ; 1
?ReplaceCharacter@nsScannerString@@UAEXAAV?$nsReadingIterator@G@@G@Z ; 1
??0CPreformattedElement@@QAE@W4nsHTMLTag@@@Z ; 1
?Initialize@CFlowElement@@SAXAAVCElement@@W4nsHTMLTag@@@Z ; 1
DTD_HandleNotationDecl ; 1
?GetContainedGroups@CTopLevelElement@@SAAATCGroupMembers@@XZ ; 1
??0CSharedParserObjects@@QAE@XZ ; 1
??0CFormElement@@QAE@XZ ; 1
??0CScriptElement@@QAE@XZ ; 1
?CanContain@CBodyElement@@UAEHPAVCElement@@PAVnsDTDContext@@@Z ; 1
?DeleteElementTable@@YAXXZ ; 1
?FreeSharedObjects@nsParser@@SAXXZ ; 1
??_EEntityCodeComparitor@@UAEPAXI@Z ; 1
??0CHeadElement@@QAE@W4nsHTMLTag@@@Z ; 1
?InitializeElementTable@@YAXXZ ; 1
?ReplaceCharacter@nsScanner@@QAEXAAV?$nsReadingIterator@G@@G@Z ; 1
??0CElementTable@@QAE@XZ ; 1
?Initialize@CPhraseElement@@SAXAAVCElement@@W4nsHTMLTag@@@Z ; 1
?Initialize@nsParserModule@@QAEIXZ ; 1
??_GCSharedParserObjects@@QAEPAXI@Z ; 1
??0CTableElement@@QAE@W4nsHTMLTag@@@Z ; 1
??0CLIElement@@QAE@W4nsHTMLTag@@@Z ; 1
??0CCounterElement@@QAE@W4nsHTMLTag@@@Z ; 1
?AddRefTable@nsHTMLEntities@@SAXXZ ; 1
?InitializeElements@CElementTable@@QAEXXZ ; 1
??1nsParserService@@UAE@XZ ; 1
NSGetModule ; 1
??_EnsSlidingSubstring@@UAEPAXI@Z ; 1
??0CHTMLElement@@QAE@W4nsHTMLTag@@@Z ; 1
?AllocNewline@CNewlineToken@@SAXXZ ; 1
?ReleaseTable@nsHTMLEntities@@SAXXZ ; 1
??1nsParserModule@@UAE@XZ ; 1
?ReleaseTable@nsHTMLTags@@SAXXZ ; 1
?FreeNewline@CNewlineToken@@SAXXZ ; 1
??0CFieldsetElement@@QAE@XZ ; 1
??_EEntityNode@@QAEPAXI@Z ; 1
??_GnsParserService@@UAEPAXI@Z ; 1
??0CBodyElement@@QAE@W4nsHTMLTag@@@Z ; 1

View File

@@ -0,0 +1,53 @@
# 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/
#
# 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.
#
# The Original Code is mozilla.org code.
#
# The Initial Developer of the Original Code is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 2001 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s):
#
# Map Expat error codes to error strings
1 = out of memory
2 = syntax error
3 = no element found
4 = not well-formed
5 = unclosed token
6 = unclosed token
7 = mismatched tag
8 = duplicate attribute
9 = junk after document element
10 = illegal parameter entity reference
11 = undefined entity
12 = recursive entity reference
13 = asynchronous entity
14 = reference to invalid character number
15 = reference to binary entity
16 = reference to external entity in attribute
17 = xml processing instruction not at start of external entity
18 = unknown encoding
19 = encoding specified in XML declaration is incorrect
20 = unclosed CDATA section
21 = error in processing external entity reference
22 = document is not standalone
# %1$S is replaced by the Expat error string, may be followed by Expected (see below)
# %2$S is replaced by URL
# %3$d is replaced by line number
# %4$d is replaced by column number
XMLParsingError = XML Parsing Error: %1$S\nLocation: %2$S\nLine Number %3$d, Column %4$d:
# %S is replaced by a tag name.
# This gets appended to the error string if the error is mismatched tag.
Expected = . Expected: </%S>.