major improvements to parser API's; fixed a few bugs
git-svn-id: svn://10.0.0.236/trunk@4894 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -219,13 +219,15 @@ nsDequeIterator nsDeque::End(void) const{
|
||||
* @param aFunctor object to call for each member
|
||||
* @return *this
|
||||
*/
|
||||
const nsDeque& nsDeque::ForEach(nsDequeFunctor& aFunctor) const{
|
||||
const void* nsDeque::ForEach(nsDequeFunctor& aFunctor) const{
|
||||
int i=0;
|
||||
for(i=0;i<mSize;i++){
|
||||
void* obj=ObjectAt(i);
|
||||
aFunctor(obj);
|
||||
obj=aFunctor(obj);
|
||||
if(obj)
|
||||
return obj;
|
||||
}
|
||||
return *this;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/******************************************************
|
||||
@@ -379,9 +381,8 @@ void* nsDequeIterator::GetCurrent(void) {
|
||||
* @param aFunctor object to call for each member
|
||||
* @return *this
|
||||
*/
|
||||
const nsDequeIterator& nsDequeIterator::ForEach(nsDequeFunctor& aFunctor) const{
|
||||
mDeque.ForEach(aFunctor);
|
||||
return *this;
|
||||
const void* nsDequeIterator::ForEach(nsDequeFunctor& aFunctor) const{
|
||||
return mDeque.ForEach(aFunctor);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@
|
||||
*/
|
||||
class NS_BASE nsDequeFunctor{
|
||||
public:
|
||||
virtual void operator()(void* anObject)=0;
|
||||
virtual void* operator()(void* anObject)=0;
|
||||
};
|
||||
|
||||
|
||||
@@ -157,7 +157,7 @@ friend class nsDequeIterator;
|
||||
* @param aFunctor object to call for each member
|
||||
* @return *this
|
||||
*/
|
||||
const nsDeque& ForEach(nsDequeFunctor& aFunctor) const;
|
||||
const void* ForEach(nsDequeFunctor& aFunctor) const;
|
||||
|
||||
/**
|
||||
* Perform automated selftest on the deque
|
||||
@@ -346,7 +346,7 @@ public:
|
||||
* @param aFunctor object to call for each member
|
||||
* @return *this
|
||||
*/
|
||||
const nsDequeIterator& ForEach(nsDequeFunctor& aFunctor) const;
|
||||
const void* ForEach(nsDequeFunctor& aFunctor) const;
|
||||
|
||||
protected:
|
||||
PRInt32 mIndex;
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
#include "nsIStreamListener.h"
|
||||
#include "nsIURL.h"
|
||||
#include "nsIWebWidget.h"
|
||||
#include "CNavDTD.h"
|
||||
|
||||
static NS_DEFINE_IID(kIDocumentIID, NS_IDOCUMENT_IID);
|
||||
static NS_DEFINE_IID(kIDOMElementIID, NS_IDOMELEMENT_IID);
|
||||
@@ -119,6 +120,17 @@ nsHTMLDocument::StartDocumentLoad(nsIURL *aURL,
|
||||
rv = parser->QueryInterface(kIStreamListenerIID, (void**)aDocListener);
|
||||
|
||||
if (NS_OK == rv) {
|
||||
|
||||
//The following lines were added by Rick.
|
||||
//These perform "dynamic" DTD registration, allowing
|
||||
//the caller total control over process, and decoupling
|
||||
//parser from any given grammar.
|
||||
|
||||
nsIDTD* theDTD=0;
|
||||
NS_NewNavHTMLDTD(&theDTD);
|
||||
parser->RegisterDTD(theDTD);
|
||||
parser->RegisterDTD(theDTD);
|
||||
|
||||
parser->SetContentSink(sink);
|
||||
parser->BeginParse(aURL);
|
||||
}
|
||||
|
||||
@@ -40,6 +40,7 @@
|
||||
#include "nsScanner.h"
|
||||
#include "nsParserTypes.h"
|
||||
#include "nsVoidArray.h"
|
||||
#include "nsTokenHandler.h"
|
||||
|
||||
#include "prenv.h" //this is here for debug reasons...
|
||||
#include "prtypes.h" //this is here for debug reasons...
|
||||
@@ -61,6 +62,7 @@ static const char* kNullFilename= "Error: Null filename given";
|
||||
static const char* kNullTokenizer = "Error: Unable to construct tokenizer";
|
||||
static const char* kNullToken = "Error: Null token given";
|
||||
static const char* kInvalidTagStackPos = "Error: invalid tag stack position";
|
||||
static const char* kHTMLTextContentType = "text/html";
|
||||
|
||||
static nsAutoString gEmpty;
|
||||
|
||||
@@ -78,7 +80,8 @@ static char gStyleTags[]={
|
||||
eHTMLTag_a, eHTMLTag_bold, eHTMLTag_big,
|
||||
eHTMLTag_blink, eHTMLTag_cite, eHTMLTag_em,
|
||||
eHTMLTag_font, eHTMLTag_italic, eHTMLTag_kbd,
|
||||
eHTMLTag_small, eHTMLTag_spell, eHTMLTag_strike,
|
||||
eHTMLTag_s, eHTMLTag_small,
|
||||
eHTMLTag_spell, eHTMLTag_strike,
|
||||
eHTMLTag_strong, eHTMLTag_sub, eHTMLTag_sup,
|
||||
eHTMLTag_tt, eHTMLTag_u, eHTMLTag_var,
|
||||
0};
|
||||
@@ -215,9 +218,10 @@ void CNavDTD::InitializeDefaultTokenHandlers() {
|
||||
|
||||
class CNavTokenDeallocator: public nsDequeFunctor{
|
||||
public:
|
||||
virtual void operator()(void* anObject) {
|
||||
virtual void* operator()(void* anObject) {
|
||||
CToken* aToken = (CToken*)anObject;
|
||||
delete aToken;
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -277,6 +281,20 @@ void CNavDTD::SetDTDDebug(nsIDTDDebug * aDTDDebug)
|
||||
NS_ADDREF(mDTDDebug);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method gets called by the parser to determine if this DTD can handle
|
||||
* the requested process for the requested content type.
|
||||
*
|
||||
* @update gess6/24/98
|
||||
* @param
|
||||
* @return TRUE if the DTD can handle the process for this type; FALSE otherwise.
|
||||
*/
|
||||
PRBool CNavDTD::IsCapableOf(eProcessType aProcessType, nsString& aContentType,PRInt32 aVersion){
|
||||
PRBool result=aContentType.Equals(kHTMLTextContentType);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @update gess5/18/98
|
||||
@@ -337,10 +355,10 @@ PRInt32 CNavDTD::HandleToken(CToken* aToken){
|
||||
if(aToken) {
|
||||
CHTMLToken* theToken= (CHTMLToken*)(aToken);
|
||||
eHTMLTokenTypes theType=eHTMLTokenTypes(theToken->GetTokenType());
|
||||
CTokenHandler* aHandler=GetTokenHandler(theType);
|
||||
CITokenHandler* theHandler=GetTokenHandler(theType);
|
||||
|
||||
if(aHandler) {
|
||||
result=(*aHandler)(theToken,this);
|
||||
if(theHandler) {
|
||||
result=(*theHandler)(theToken,this);
|
||||
if (mDTDDebug)
|
||||
mDTDDebug->Verify(this, mParser, mContextStackPos, mContextStack, mFilename);
|
||||
}
|
||||
@@ -365,10 +383,10 @@ PRInt32 CNavDTD::HandleToken(CToken* aToken){
|
||||
* @param aNode -- CParserNode representing this start token
|
||||
* @return PR_TRUE if all went well; PR_FALSE if error occured
|
||||
*/
|
||||
PRInt32 CNavDTD::HandleDefaultStartToken(CToken* aToken,eHTMLTags aChildTag,nsCParserNode& aNode) {
|
||||
PRInt32 CNavDTD::HandleDefaultStartToken(CToken* aToken,eHTMLTags aChildTag,nsIParserNode& aNode) {
|
||||
NS_PRECONDITION(0!=aToken,kNullToken);
|
||||
|
||||
eHTMLTags parentTag=(eHTMLTags)GetTopNode();
|
||||
eHTMLTags parentTag=GetTopNode();
|
||||
PRInt32 result=kNoError;
|
||||
PRBool contains=CanContain(parentTag,aChildTag);
|
||||
|
||||
@@ -487,30 +505,7 @@ PRInt32 CNavDTD::HandleStartToken(CToken* aToken) {
|
||||
break;
|
||||
|
||||
case eHTMLTag_script:
|
||||
{
|
||||
PRInt32 pos=GetTopmostIndexOf(eHTMLTag_body);
|
||||
nsCParserNode theNode((CHTMLToken*)aToken);
|
||||
if (kNotFound == pos) {
|
||||
// We're in the HEAD
|
||||
result=OpenHead(theNode);
|
||||
if(kNoError==result) {
|
||||
mParser->CollectSkippedContent(attrNode,theCount);
|
||||
if(kNoError==result) {
|
||||
result=AddLeaf(attrNode);
|
||||
if(kNoError==result)
|
||||
result=CloseHead(theNode);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
// We're in the BODY
|
||||
mParser->CollectSkippedContent(attrNode,theCount);
|
||||
if(kNoError==result) {
|
||||
result=AddLeaf(attrNode);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
result=HandleScriptToken(st); break;
|
||||
|
||||
case eHTMLTag_head:
|
||||
break; //ignore head tags...
|
||||
@@ -570,7 +565,7 @@ PRInt32 CNavDTD::HandleEndToken(CToken* aToken) {
|
||||
|
||||
/*
|
||||
if(0!=strchr(gStyleTags,tokenTagType)){
|
||||
eHTMLTags topTag=(eHTMLTags)GetTopNode();
|
||||
eHTMLTags topTag=GetTopNode();
|
||||
if(0!=strchr(gStyleTags,topTag)){
|
||||
tokenTagType=topTag;
|
||||
}
|
||||
@@ -704,10 +699,32 @@ PRInt32 CNavDTD::HandleAttributeToken(CToken* aToken) {
|
||||
*/
|
||||
PRInt32 CNavDTD::HandleScriptToken(CToken* aToken) {
|
||||
NS_PRECONDITION(0!=aToken,kNullToken);
|
||||
PRInt32 result=kNoError;
|
||||
|
||||
PRInt32 pos=GetTopmostIndexOf(eHTMLTag_body);
|
||||
nsCParserNode theNode((CHTMLToken*)aToken);
|
||||
PRInt32 theCount=0;
|
||||
PRInt32 result=mParser->CollectSkippedContent(theNode,theCount);
|
||||
nsCParserNode attrNode((CHTMLToken*)aToken);
|
||||
PRInt32 attrCount=aToken->GetAttributeCount();
|
||||
|
||||
if (kNotFound == pos) {
|
||||
// We're in the HEAD
|
||||
result=OpenHead(theNode);
|
||||
if(kNoError==result) {
|
||||
mParser->CollectSkippedContent(attrNode,attrCount);
|
||||
if(kNoError==result) {
|
||||
result=AddLeaf(attrNode);
|
||||
if(kNoError==result)
|
||||
result=CloseHead(theNode);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
// We're in the BODY
|
||||
mParser->CollectSkippedContent(attrNode,attrCount);
|
||||
if(kNoError==result) {
|
||||
result=AddLeaf(attrNode);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -753,8 +770,8 @@ void CNavDTD::DeleteTokenHandlers(void) {
|
||||
* @param aTagType type of tag to be handled
|
||||
* @return valid tag handler (if found) or null
|
||||
*/
|
||||
CTokenHandler* CNavDTD::GetTokenHandler(eHTMLTokenTypes aType) const {
|
||||
CTokenHandler* result=0;
|
||||
CITokenHandler* CNavDTD::GetTokenHandler(eHTMLTokenTypes aType) const {
|
||||
CITokenHandler* result=0;
|
||||
if((aType>0) && (aType<eToken_last)) {
|
||||
result=mTokenHandlers[aType];
|
||||
}
|
||||
@@ -771,13 +788,13 @@ CTokenHandler* CNavDTD::GetTokenHandler(eHTMLTokenTypes aType) const {
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
CTokenHandler* CNavDTD::AddTokenHandler(CTokenHandler* aHandler) {
|
||||
CITokenHandler* CNavDTD::AddTokenHandler(CITokenHandler* aHandler) {
|
||||
NS_ASSERTION(0!=aHandler,"Error: Null handler");
|
||||
|
||||
if(aHandler) {
|
||||
eHTMLTokenTypes type=(eHTMLTokenTypes)aHandler->GetTokenType();
|
||||
if(type<eToken_last) {
|
||||
CTokenHandler* old=mTokenHandlers[type];
|
||||
CITokenHandler* old=mTokenHandlers[type];
|
||||
mTokenHandlers[type]=aHandler;
|
||||
}
|
||||
else {
|
||||
@@ -836,8 +853,8 @@ PRBool CNavDTD::CanContainStyles(eHTMLTags aParent) const {
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is called to determine whether or not a tag
|
||||
* of one type can contain a tag of another type.
|
||||
* This method is called to determine whether or not a
|
||||
* form-type tag can contain a tag of another form-type tag.
|
||||
*
|
||||
* @update gess 4/8/98
|
||||
* @param aParent -- tag enum of parent container
|
||||
@@ -845,7 +862,18 @@ PRBool CNavDTD::CanContainStyles(eHTMLTags aParent) const {
|
||||
* @return PR_TRUE if parent can contain child
|
||||
*/
|
||||
PRBool CNavDTD::CanContainFormElement(eHTMLTags aParent,eHTMLTags aChild) const {
|
||||
PRBool result=(mParser) ? HasOpenContainer(eHTMLTag_form) : PR_FALSE;
|
||||
PRBool result=PR_FALSE;
|
||||
|
||||
if(mParser && HasOpenContainer(eHTMLTag_form)) {
|
||||
eHTMLTags topTag=GetTopNode();
|
||||
switch(aChild) {
|
||||
case eHTMLTag_option:
|
||||
result=PRBool(eHTMLTag_select==topTag); break;
|
||||
default:
|
||||
result=PR_TRUE;
|
||||
break;
|
||||
} //switch
|
||||
}//if
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -880,7 +908,8 @@ PRBool CNavDTD::CanContain(PRInt32 aParent,PRInt32 aChild) {
|
||||
eHTMLTag_map, eHTMLTag_menu, eHTMLTag_newline, eHTMLTag_nobr,
|
||||
eHTMLTag_noframes, eHTMLTag_noscript,
|
||||
eHTMLTag_object, eHTMLTag_ol, eHTMLTag_paragraph, eHTMLTag_pre,
|
||||
eHTMLTag_quotation, eHTMLTag_strike, eHTMLTag_samp, eHTMLTag_script,
|
||||
eHTMLTag_quotation, eHTMLTag_s, eHTMLTag_strike,
|
||||
eHTMLTag_samp, eHTMLTag_script,
|
||||
eHTMLTag_select, eHTMLTag_small, eHTMLTag_span, eHTMLTag_strong,
|
||||
eHTMLTag_sub, eHTMLTag_sup, eHTMLTag_table, eHTMLTag_text,
|
||||
|
||||
@@ -901,7 +930,8 @@ PRBool CNavDTD::CanContain(PRInt32 aParent,PRInt32 aChild) {
|
||||
|
||||
eHTMLTag_label, eHTMLTag_map, eHTMLTag_newline, eHTMLTag_nobr,
|
||||
eHTMLTag_object, eHTMLTag_paragraph,
|
||||
eHTMLTag_quotation, eHTMLTag_strike, eHTMLTag_samp, eHTMLTag_script,
|
||||
eHTMLTag_quotation, eHTMLTag_s, eHTMLTag_strike,
|
||||
eHTMLTag_samp, eHTMLTag_script,
|
||||
eHTMLTag_select, eHTMLTag_small, eHTMLTag_span, eHTMLTag_strong,
|
||||
eHTMLTag_sub, eHTMLTag_sup, eHTMLTag_text, eHTMLTag_textarea,
|
||||
eHTMLTag_tt, eHTMLTag_u, eHTMLTag_userdefined, eHTMLTag_var,
|
||||
@@ -925,7 +955,8 @@ PRBool CNavDTD::CanContain(PRInt32 aParent,PRInt32 aChild) {
|
||||
|
||||
eHTMLTag_noframes,
|
||||
eHTMLTag_noscript, eHTMLTag_object, eHTMLTag_paragraph, eHTMLTag_pre,
|
||||
eHTMLTag_quotation, eHTMLTag_strike, eHTMLTag_samp, eHTMLTag_small,
|
||||
eHTMLTag_quotation, eHTMLTag_s, eHTMLTag_strike,
|
||||
eHTMLTag_samp, eHTMLTag_small,
|
||||
eHTMLTag_span, eHTMLTag_strong, eHTMLTag_sub, eHTMLTag_sup,
|
||||
eHTMLTag_td, eHTMLTag_text,
|
||||
|
||||
@@ -944,9 +975,9 @@ PRBool CNavDTD::CanContain(PRInt32 aParent,PRInt32 aChild) {
|
||||
}
|
||||
|
||||
switch((eHTMLTags)aParent) {
|
||||
|
||||
case eHTMLTag_address:
|
||||
result=PRBool(0!=strchr(gTagSet2,aChild));
|
||||
break;
|
||||
result=PRBool(0!=strchr(gTagSet2,aChild)); break;
|
||||
|
||||
case eHTMLTag_applet:
|
||||
{
|
||||
@@ -957,7 +988,8 @@ PRBool CNavDTD::CanContain(PRInt32 aParent,PRInt32 aChild) {
|
||||
eHTMLTag_em, eHTMLTag_font, eHTMLTag_italic, eHTMLTag_iframe,
|
||||
eHTMLTag_img, eHTMLTag_input, eHTMLTag_kbd, eHTMLTag_label,
|
||||
eHTMLTag_map, eHTMLTag_object, eHTMLTag_param, eHTMLTag_quotation,
|
||||
eHTMLTag_samp, eHTMLTag_script, eHTMLTag_select, eHTMLTag_small,
|
||||
eHTMLTag_s, eHTMLTag_samp, eHTMLTag_script,
|
||||
eHTMLTag_select, eHTMLTag_small,
|
||||
eHTMLTag_span, eHTMLTag_strike, eHTMLTag_strong, eHTMLTag_sub,
|
||||
eHTMLTag_sup, eHTMLTag_textarea, eHTMLTag_tt, eHTMLTag_u,
|
||||
eHTMLTag_var,0};
|
||||
@@ -1288,6 +1320,7 @@ PRBool CNavDTD::CanOmit(eHTMLTags aParent,eHTMLTags aChild) const {
|
||||
case eHTMLTag_input: case eHTMLTag_isindex:
|
||||
case eHTMLTag_label: case eHTMLTag_legend:
|
||||
case eHTMLTag_select: case eHTMLTag_textarea:
|
||||
case eHTMLTag_option:
|
||||
if(PR_FALSE==HasOpenContainer(eHTMLTag_form))
|
||||
result=PR_TRUE;
|
||||
break;
|
||||
@@ -1379,7 +1412,7 @@ PRBool CNavDTD::CanOmitEndTag(eHTMLTags aParent,eHTMLTags aChild) const {
|
||||
break;
|
||||
|
||||
default:
|
||||
if(IsCompatibleStyleTag(aChild,(eHTMLTags)GetTopNode()))
|
||||
if(IsCompatibleStyleTag(aChild,GetTopNode()))
|
||||
result=PR_FALSE;
|
||||
else result=(!HasOpenContainer(aChild));
|
||||
break;
|
||||
@@ -1587,33 +1620,6 @@ PRBool CNavDTD::BackwardPropagate(nsString& aVector,eHTMLTags aParentTag,eHTMLTa
|
||||
*/
|
||||
PRInt32 CNavDTD::DidOpenContainer(eHTMLTags aTag,PRBool /*anExplicitOpen*/){
|
||||
PRInt32 result=0;
|
||||
|
||||
switch (aTag) {
|
||||
|
||||
case eHTMLTag_a:
|
||||
case eHTMLTag_bold:
|
||||
case eHTMLTag_big:
|
||||
case eHTMLTag_blink:
|
||||
case eHTMLTag_cite:
|
||||
case eHTMLTag_em:
|
||||
case eHTMLTag_font:
|
||||
case eHTMLTag_italic:
|
||||
case eHTMLTag_kbd:
|
||||
case eHTMLTag_small:
|
||||
case eHTMLTag_spell:
|
||||
case eHTMLTag_strike:
|
||||
case eHTMLTag_strong:
|
||||
case eHTMLTag_sub:
|
||||
case eHTMLTag_sup:
|
||||
case eHTMLTag_tt:
|
||||
case eHTMLTag_u:
|
||||
case eHTMLTag_var:
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -1704,7 +1710,7 @@ PRInt32 CNavDTD::OpenTransientStyles(eHTMLTags aTag){
|
||||
if(0==strchr(gWhitespaceTags,aTag)){
|
||||
PRInt32 pos=0;
|
||||
|
||||
eHTMLTags parentTag=(eHTMLTags)GetTopNode();
|
||||
eHTMLTags parentTag=GetTopNode();
|
||||
if(CanContainStyles(parentTag)) {
|
||||
for(pos=0;pos<mStyleStackPos;pos++) {
|
||||
eHTMLTags theTag=(eHTMLTags)(int)mStyleStack[pos];
|
||||
@@ -1832,7 +1838,7 @@ PRInt32 CNavDTD::OpenBody(const nsIParserNode& aNode){
|
||||
NS_PRECONDITION(mContextStackPos >= 0, kInvalidTagStackPos);
|
||||
|
||||
PRInt32 result=kNoError;
|
||||
eHTMLTags topTag=(eHTMLTags)CNavDTD::GetTopNode();
|
||||
eHTMLTags topTag=GetTopNode();
|
||||
|
||||
if(eHTMLTag_html!=topTag) {
|
||||
|
||||
@@ -2126,7 +2132,7 @@ PRInt32 CNavDTD::CloseContainersTo(eHTMLTags aTag,PRBool aUpdateStyles){
|
||||
return CloseContainersTo(pos,aTag,aUpdateStyles);
|
||||
}
|
||||
|
||||
eHTMLTags theTopTag=(eHTMLTags)GetTopNode();
|
||||
eHTMLTags theTopTag=GetTopNode();
|
||||
if(IsCompatibleStyleTag(aTag,theTopTag)) {
|
||||
//if you're here, it's because we're trying to close one style tag,
|
||||
//but a different one is actually open. Because this is NAV4x
|
||||
@@ -2263,13 +2269,13 @@ PRInt32 CNavDTD::CreateContextStackFor(eHTMLTags aChildTag){
|
||||
*/
|
||||
PRInt32 CNavDTD::ReduceContextStackFor(eHTMLTags aChildTag){
|
||||
PRInt32 result=kNoError;
|
||||
eHTMLTags topTag=(eHTMLTags)GetTopNode();
|
||||
eHTMLTags topTag=GetTopNode();
|
||||
|
||||
while( (topTag!=kNotFound) &&
|
||||
(PR_FALSE==CanContain(topTag,aChildTag)) &&
|
||||
(PR_FALSE==CanContainIndirect(topTag,aChildTag))) {
|
||||
CloseTopmostContainer();
|
||||
topTag=(eHTMLTags)GetTopNode();
|
||||
topTag=GetTopNode();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -2297,6 +2303,7 @@ PRInt32 CNavDTD::UpdateStyleStackForOpenTag(eHTMLTags aTag,eHTMLTags anActualTag
|
||||
case eHTMLTag_font:
|
||||
case eHTMLTag_italic:
|
||||
case eHTMLTag_kbd:
|
||||
case eHTMLTag_s:
|
||||
case eHTMLTag_small:
|
||||
case eHTMLTag_spell:
|
||||
case eHTMLTag_strike:
|
||||
@@ -2346,6 +2353,7 @@ PRInt32 CNavDTD::UpdateStyleStackForCloseTag(eHTMLTags aTag,eHTMLTags anActualTa
|
||||
case eHTMLTag_kbd:
|
||||
case eHTMLTag_small:
|
||||
case eHTMLTag_spell:
|
||||
case eHTMLTag_s:
|
||||
case eHTMLTag_strike:
|
||||
case eHTMLTag_strong:
|
||||
case eHTMLTag_sub:
|
||||
|
||||
@@ -28,22 +28,22 @@
|
||||
#define NS_NAVHTMLDTD__
|
||||
|
||||
#include "nsIDTD.h"
|
||||
#include "nsISupports.h"
|
||||
#include "nsHTMLTokens.h"
|
||||
#include "nshtmlpars.h"
|
||||
#include "nsParserNode.h"
|
||||
#include "nsTokenHandler.h"
|
||||
#include "nsVoidArray.h"
|
||||
#include "nsDeque.h"
|
||||
|
||||
|
||||
#define NS_INAVHTML_DTD_IID \
|
||||
{0x5c5cce40, 0xcfd6, 0x11d1, \
|
||||
{0xaa, 0xda, 0x00, 0x80, 0x5f, 0x8a, 0x3e, 0x14}}
|
||||
|
||||
|
||||
class nsParser;
|
||||
class nsIHTMLContentSink;
|
||||
class nsIDTDDebug;
|
||||
class nsIParserNode;
|
||||
class CITokenHandler;
|
||||
class nsParser;
|
||||
|
||||
class CNavDTD : public nsIDTD {
|
||||
|
||||
@@ -70,13 +70,21 @@ class CNavDTD : public nsIDTD {
|
||||
*/
|
||||
virtual ~CNavDTD();
|
||||
|
||||
/**
|
||||
*
|
||||
* @update gess7/1/98
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
virtual PRBool IsCapableOf(eProcessType aProcessType, nsString& aString, PRInt32 aVersion);
|
||||
|
||||
/**
|
||||
*
|
||||
* @update jevering6/23/98
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
virtual void SetDTDDebug(nsIDTDDebug * aDTDDebug);
|
||||
virtual void SetDTDDebug(nsIDTDDebug * aDTDDebug);
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -292,7 +300,7 @@ class CNavDTD : public nsIDTD {
|
||||
* @param aNode is a node be updated with info from given token
|
||||
* @return TRUE if the token was handled.
|
||||
*/
|
||||
PRInt32 HandleDefaultStartToken(CToken* aToken,eHTMLTags aChildTag,nsCParserNode& aNode);
|
||||
PRInt32 HandleDefaultStartToken(CToken* aToken,eHTMLTags aChildTag,nsIParserNode& aNode);
|
||||
|
||||
/**
|
||||
* This method gets called when an end token has been consumed and needs
|
||||
@@ -359,7 +367,7 @@ class CNavDTD : public nsIDTD {
|
||||
|
||||
|
||||
|
||||
private:
|
||||
protected:
|
||||
|
||||
/**
|
||||
* Causes token handlers to be registered for this parser.
|
||||
@@ -373,13 +381,13 @@ private:
|
||||
* DEPRECATED
|
||||
* @update gess5/11/98
|
||||
*/
|
||||
CTokenHandler* GetTokenHandler(eHTMLTokenTypes aType) const;
|
||||
CITokenHandler* GetTokenHandler(eHTMLTokenTypes aType) const;
|
||||
|
||||
/**
|
||||
* DEPRECATED
|
||||
* @update gess5/11/98
|
||||
*/
|
||||
CTokenHandler* AddTokenHandler(CTokenHandler* aHandler);
|
||||
CITokenHandler* AddTokenHandler(CITokenHandler* aHandler);
|
||||
|
||||
/**
|
||||
* DEPRECATED
|
||||
@@ -679,7 +687,7 @@ protected:
|
||||
nsParser* mParser;
|
||||
nsIHTMLContentSink* mSink;
|
||||
|
||||
CTokenHandler* mTokenHandlers[eToken_last];
|
||||
CITokenHandler* mTokenHandlers[eToken_last];
|
||||
|
||||
nsVoidArray mLeafBits;
|
||||
nsVoidArray mContextStack;
|
||||
@@ -691,9 +699,10 @@ protected:
|
||||
PRBool mHasOpenMap;
|
||||
nsDeque mTokenDeque;
|
||||
char* mFilename;
|
||||
nsIDTDDebug* mDTDDebug;
|
||||
nsIDTDDebug* mDTDDebug;
|
||||
};
|
||||
|
||||
extern NS_HTMLPARS nsresult NS_NewNavHTMLDTD(nsIDTD** aInstancePtrResult);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -26,13 +26,7 @@
|
||||
#ifndef NS_OTHERHTMLDTD__
|
||||
#define NS_OTHERHTMLDTD__
|
||||
|
||||
#include "nsIDTD.h"
|
||||
#include "nsHTMLTokens.h"
|
||||
#include "nshtmlpars.h"
|
||||
#include "nsParserNode.h"
|
||||
#include "nsTokenHandler.h"
|
||||
#include "nsDeque.h"
|
||||
#include "nsVoidArray.h"
|
||||
#include "CNavDTD.h"
|
||||
|
||||
|
||||
#define NS_IOtherHTML_DTD_IID \
|
||||
@@ -40,11 +34,10 @@
|
||||
{0x80, 0x22, 0x00, 0x60, 0x8, 0x14, 0x98, 0x89}}
|
||||
|
||||
|
||||
class nsParser;
|
||||
class nsIHTMLContentSink;
|
||||
class nsIDTDDebug;
|
||||
//class nsParser;
|
||||
//class nsIHTMLContentSink;
|
||||
|
||||
class COtherDTD : public nsIDTD {
|
||||
class COtherDTD : public CNavDTD {
|
||||
|
||||
public:
|
||||
|
||||
@@ -69,14 +62,8 @@ class COtherDTD : public nsIDTD {
|
||||
*/
|
||||
virtual ~COtherDTD();
|
||||
|
||||
/**
|
||||
*
|
||||
* @update jevering6/23/98
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
virtual void SetDTDDebug(nsIDTDDebug * aDTDDebug);
|
||||
|
||||
virtual PRBool IsCapableOf(eProcessType aProcessType, nsString& aString,PRInt32 aVersion);
|
||||
|
||||
/**
|
||||
*
|
||||
* @update gess5/18/98
|
||||
@@ -101,15 +88,6 @@ class COtherDTD : public nsIDTD {
|
||||
*/
|
||||
virtual PRInt32 HandleToken(CToken* aToken);
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
virtual void SetParser(nsIParser* aParser);
|
||||
|
||||
/**
|
||||
* Cause the tokenizer to consume the next token, and
|
||||
* return an error result.
|
||||
@@ -137,14 +115,6 @@ class COtherDTD : public nsIDTD {
|
||||
*/
|
||||
virtual void WillInterruptParse(void);
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
virtual nsIContentSink* SetContentSink(nsIContentSink* aSink);
|
||||
|
||||
/**
|
||||
* This method is called to determine whether or not a tag
|
||||
* of one type can contain a tag of another type.
|
||||
@@ -239,30 +209,6 @@ class COtherDTD : public nsIDTD {
|
||||
*/
|
||||
virtual PRInt32 DidOpenContainer(eHTMLTags aTag,PRBool anExplicitOpen);
|
||||
|
||||
/**
|
||||
* 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;
|
||||
|
||||
|
||||
/**
|
||||
* Retrieve 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;
|
||||
|
||||
/**
|
||||
*
|
||||
* @update gess6/4/98
|
||||
@@ -291,7 +237,7 @@ class COtherDTD : public nsIDTD {
|
||||
* @param aNode is a node be updated with info from given token
|
||||
* @return TRUE if the token was handled.
|
||||
*/
|
||||
PRInt32 HandleDefaultStartToken(CToken* aToken,eHTMLTags aChildTag,nsCParserNode& aNode);
|
||||
PRInt32 HandleDefaultStartToken(CToken* aToken,eHTMLTags aChildTag,nsIParserNode& aNode);
|
||||
|
||||
/**
|
||||
* This method gets called when an end token has been consumed and needs
|
||||
@@ -358,33 +304,6 @@ class COtherDTD : public nsIDTD {
|
||||
|
||||
private:
|
||||
|
||||
/**
|
||||
* Causes token handlers to be registered for this parser.
|
||||
* DO NOT CALL THIS! IT'S DEPRECATED!
|
||||
* @update gess5/11/98
|
||||
*/
|
||||
void InitializeDefaultTokenHandlers();
|
||||
|
||||
|
||||
/**
|
||||
* DEPRECATED
|
||||
* @update gess5/11/98
|
||||
*/
|
||||
CTokenHandler* GetTokenHandler(eHTMLTokenTypes aType) const;
|
||||
|
||||
/**
|
||||
* DEPRECATED
|
||||
* @update gess5/11/98
|
||||
*/
|
||||
CTokenHandler* AddTokenHandler(CTokenHandler* aHandler);
|
||||
|
||||
/**
|
||||
* DEPRECATED
|
||||
* @update gess5/11/98
|
||||
*/
|
||||
void DeleteTokenHandlers(void);
|
||||
|
||||
|
||||
|
||||
//*************************************************
|
||||
//these cover methods mimic the sink, and are used
|
||||
@@ -673,23 +592,8 @@ protected:
|
||||
|
||||
PRBool CanContainFormElement(eHTMLTags aParent,eHTMLTags aChild) const;
|
||||
|
||||
nsParser* mParser;
|
||||
nsIHTMLContentSink* mSink;
|
||||
|
||||
CTokenHandler* mTokenHandlers[eToken_last];
|
||||
|
||||
nsVoidArray mLeafBits;
|
||||
nsVoidArray mContextStack;
|
||||
PRInt32 mContextStackPos;
|
||||
|
||||
nsVoidArray mStyleStack;
|
||||
PRInt32 mStyleStackPos;
|
||||
PRBool mHasOpenForm;
|
||||
PRBool mHasOpenMap;
|
||||
nsDeque mTokenDeque;
|
||||
char* mFilename;
|
||||
nsIDTDDebug* mDTDDebug;
|
||||
};
|
||||
|
||||
extern NS_HTMLPARS nsresult NS_NewOtherHTMLDTD(nsIDTD** aInstancePtrResult);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -42,8 +42,11 @@ EXPORTS = \
|
||||
nsHTMLTokens.h \
|
||||
nsIParserNode.h \
|
||||
nsIParser.h \
|
||||
nsIDTD.h \
|
||||
nsIParserFilter.h \
|
||||
nsToken.h \
|
||||
CNavDTD.h \
|
||||
COtherDTD.h \
|
||||
$(NULL)
|
||||
|
||||
MODULE = raptor
|
||||
|
||||
@@ -32,7 +32,8 @@ CPPSRCS=nsHTMLContentSink.cpp \
|
||||
|
||||
EXPORTS=nshtmlpars.h nsIContentSink.h nsIHTMLContentSink.h \
|
||||
nsHTMLTokens.h nsIParserNode.h nsIParser.h nsToken.h \
|
||||
nsIDTDDebug.h nsIParserFilter.h
|
||||
nsIDTDDebug.h nsIParserFilter.h \
|
||||
CNavDTD.h COtherDTD.h nsIDTD.h
|
||||
|
||||
CPP_OBJS=.\$(OBJDIR)\nsHTMLContentSink.obj \
|
||||
.\$(OBJDIR)\CNavDTD.obj \
|
||||
|
||||
@@ -45,8 +45,8 @@ static const char* kNullScanner = "Error: Scanner is null.";
|
||||
const PRInt32 kMAXNAMELEN=10;
|
||||
struct StrToUnicodeStruct
|
||||
{
|
||||
char fName[kMAXNAMELEN+1];
|
||||
PRInt32 fValue;
|
||||
char mName[kMAXNAMELEN+1];
|
||||
PRInt32 mValue;
|
||||
};
|
||||
|
||||
|
||||
@@ -96,8 +96,9 @@ static StrToUnicodeStruct gStrToUnicodeTable[] =
|
||||
|
||||
|
||||
struct HTMLTagEntry {
|
||||
char fName[12];
|
||||
eHTMLTags fTagID;
|
||||
char mName[12];
|
||||
eHTMLTags mTagID;
|
||||
PRInt16 mUnused;
|
||||
};
|
||||
|
||||
// KEEP THIS LIST SORTED!
|
||||
@@ -106,103 +107,103 @@ struct HTMLTagEntry {
|
||||
// the binary search code above will break!
|
||||
HTMLTagEntry gHTMLTagTable[] =
|
||||
{
|
||||
{"!!UNKNOWN", eHTMLTag_unknown},
|
||||
{"!DOCTYPE", eHTMLTag_doctype}, {"A", eHTMLTag_a},
|
||||
{"ACRONYM", eHTMLTag_acronym}, {"ADDRESS", eHTMLTag_address},
|
||||
{"APPLET", eHTMLTag_applet}, {"AREA", eHTMLTag_area},
|
||||
{"!!UNKNOWN", eHTMLTag_unknown,0},
|
||||
{"!DOCTYPE", eHTMLTag_doctype,0}, {"A", eHTMLTag_a,0},
|
||||
{"ACRONYM", eHTMLTag_acronym,0}, {"ADDRESS", eHTMLTag_address,0},
|
||||
{"APPLET", eHTMLTag_applet,0}, {"AREA", eHTMLTag_area,0},
|
||||
|
||||
{"B", eHTMLTag_bold}, {"BASE", eHTMLTag_base},
|
||||
{"BASEFONT", eHTMLTag_basefont}, {"BDO", eHTMLTag_bdo},
|
||||
{"BIG", eHTMLTag_big}, {"BLINK", eHTMLTag_blink},
|
||||
{"BLOCKQUOTE", eHTMLTag_blockquote}, {"BODY", eHTMLTag_body},
|
||||
{"BR", eHTMLTag_br}, {"BUTTON", eHTMLTag_button},
|
||||
{"B", eHTMLTag_bold,0}, {"BASE", eHTMLTag_base,0},
|
||||
{"BASEFONT", eHTMLTag_basefont,0}, {"BDO", eHTMLTag_bdo,0},
|
||||
{"BIG", eHTMLTag_big,0}, {"BLINK", eHTMLTag_blink,0},
|
||||
{"BLOCKQUOTE", eHTMLTag_blockquote,0}, {"BODY", eHTMLTag_body,0},
|
||||
{"BR", eHTMLTag_br,0}, {"BUTTON", eHTMLTag_button,0},
|
||||
|
||||
{"CAPTION", eHTMLTag_caption}, {"CENTER", eHTMLTag_center},
|
||||
{"CERTIFICATE", eHTMLTag_certificate},
|
||||
{"CITE", eHTMLTag_cite}, {"CODE", eHTMLTag_code},
|
||||
{"COL", eHTMLTag_col}, {"COLGROUP", eHTMLTag_colgroup},
|
||||
{"COMMENT", eHTMLTag_comment},
|
||||
{"CAPTION", eHTMLTag_caption,0}, {"CENTER", eHTMLTag_center,0},
|
||||
{"CERTIFICATE", eHTMLTag_certificate,0},
|
||||
{"CITE", eHTMLTag_cite,0}, {"CODE", eHTMLTag_code,0},
|
||||
{"COL", eHTMLTag_col,0}, {"COLGROUP", eHTMLTag_colgroup,0},
|
||||
{"COMMENT", eHTMLTag_comment,0},
|
||||
|
||||
{"DD", eHTMLTag_dd}, {"DEL", eHTMLTag_del},
|
||||
{"DFN", eHTMLTag_dfn}, {"DIR", eHTMLTag_dir},
|
||||
{"DIV", eHTMLTag_div}, {"DL", eHTMLTag_dl},
|
||||
{"DT", eHTMLTag_dt},
|
||||
{"DD", eHTMLTag_dd,0}, {"DEL", eHTMLTag_del,0},
|
||||
{"DFN", eHTMLTag_dfn,0}, {"DIR", eHTMLTag_dir,0},
|
||||
{"DIV", eHTMLTag_div,0}, {"DL", eHTMLTag_dl,0},
|
||||
{"DT", eHTMLTag_dt,0},
|
||||
|
||||
{"EM", eHTMLTag_em}, {"EMBED", eHTMLTag_embed},
|
||||
{"ENTITY", eHTMLTag_entity}, //a pseudo tag
|
||||
{"EM", eHTMLTag_em,0}, {"EMBED", eHTMLTag_embed,0},
|
||||
{"ENTITY", eHTMLTag_entity,0}, //a pseudo tag
|
||||
|
||||
{"FIELDSET", eHTMLTag_fieldset}, {"FONT", eHTMLTag_font},
|
||||
{"FOOTER", eHTMLTag_footer}, {"FORM", eHTMLTag_form},
|
||||
{"FRAME", eHTMLTag_frame}, {"FRAMESET", eHTMLTag_frameset},
|
||||
{"FIELDSET", eHTMLTag_fieldset,0}, {"FONT", eHTMLTag_font,0},
|
||||
{"FOOTER", eHTMLTag_footer,0}, {"FORM", eHTMLTag_form,0},
|
||||
{"FRAME", eHTMLTag_frame,0}, {"FRAMESET", eHTMLTag_frameset,0},
|
||||
|
||||
{"H1", eHTMLTag_h1}, {"H2", eHTMLTag_h2},
|
||||
{"H3", eHTMLTag_h3}, {"H4", eHTMLTag_h4},
|
||||
{"H5", eHTMLTag_h5}, {"H6", eHTMLTag_h6},
|
||||
{"HEAD", eHTMLTag_head}, {"HEADER", eHTMLTag_header},
|
||||
{"HR", eHTMLTag_hr}, {"HTML", eHTMLTag_html},
|
||||
{"H1", eHTMLTag_h1,0}, {"H2", eHTMLTag_h2,0},
|
||||
{"H3", eHTMLTag_h3,0}, {"H4", eHTMLTag_h4,0},
|
||||
{"H5", eHTMLTag_h5,0}, {"H6", eHTMLTag_h6,0},
|
||||
{"HEAD", eHTMLTag_head,0}, {"HEADER", eHTMLTag_header,0},
|
||||
{"HR", eHTMLTag_hr,0}, {"HTML", eHTMLTag_html,0},
|
||||
|
||||
{"I", eHTMLTag_italic}, {"IFRAME", eHTMLTag_iframe},
|
||||
{"ILAYER", eHTMLTag_ilayer}, {"IMG", eHTMLTag_img},
|
||||
{"INPUT", eHTMLTag_input}, {"INS", eHTMLTag_ins},
|
||||
{"ISINDEX", eHTMLTag_isindex},
|
||||
{"I", eHTMLTag_italic,0}, {"IFRAME", eHTMLTag_iframe,0},
|
||||
{"ILAYER", eHTMLTag_ilayer,0}, {"IMG", eHTMLTag_img,0},
|
||||
{"INPUT", eHTMLTag_input,0}, {"INS", eHTMLTag_ins,0},
|
||||
{"ISINDEX", eHTMLTag_isindex,0},
|
||||
|
||||
{"KBD", eHTMLTag_kbd}, {"KEYGEN", eHTMLTag_keygen},
|
||||
{"KBD", eHTMLTag_kbd,0}, {"KEYGEN", eHTMLTag_keygen,0},
|
||||
|
||||
{"LABEL", eHTMLTag_label}, {"LAYER", eHTMLTag_layer},
|
||||
{"LEGEND", eHTMLTag_legend}, {"LI", eHTMLTag_listitem},
|
||||
{"LINK", eHTMLTag_link}, {"LISTING", eHTMLTag_listing},
|
||||
{"LABEL", eHTMLTag_label,0}, {"LAYER", eHTMLTag_layer,0},
|
||||
{"LEGEND", eHTMLTag_legend,0}, {"LI", eHTMLTag_listitem,0},
|
||||
{"LINK", eHTMLTag_link,0}, {"LISTING", eHTMLTag_listing,0},
|
||||
|
||||
{"MAP", eHTMLTag_map}, {"MARQUEE", eHTMLTag_marquee},
|
||||
{"MATH", eHTMLTag_math},
|
||||
{"MENU", eHTMLTag_menu}, {"META", eHTMLTag_meta},
|
||||
{"MAP", eHTMLTag_map,0}, {"MARQUEE", eHTMLTag_marquee,0},
|
||||
{"MATH", eHTMLTag_math,0},
|
||||
{"MENU", eHTMLTag_menu,0}, {"META", eHTMLTag_meta,0},
|
||||
|
||||
{"NEWLINE", eHTMLTag_newline}, {"NOBR", eHTMLTag_nobr},
|
||||
{"NEWLINE", eHTMLTag_newline,0}, {"NOBR", eHTMLTag_nobr,0},
|
||||
|
||||
{"NOEMBED", eHTMLTag_noembed}, {"NOFRAMES", eHTMLTag_noframes},
|
||||
{"NOLAYER", eHTMLTag_nolayer}, {"NOSCRIPT", eHTMLTag_noscript},
|
||||
{"NOTE", eHTMLTag_note},
|
||||
{"NOEMBED", eHTMLTag_noembed,0}, {"NOFRAMES", eHTMLTag_noframes,0},
|
||||
{"NOLAYER", eHTMLTag_nolayer,0}, {"NOSCRIPT", eHTMLTag_noscript,0},
|
||||
{"NOTE", eHTMLTag_note,0},
|
||||
|
||||
{"OBJECT", eHTMLTag_object}, {"OL", eHTMLTag_ol},
|
||||
{"OPTION", eHTMLTag_option},
|
||||
{"OBJECT", eHTMLTag_object,0}, {"OL", eHTMLTag_ol,0},
|
||||
{"OPTION", eHTMLTag_option,0},
|
||||
|
||||
{"P", eHTMLTag_paragraph}, {"PARAM", eHTMLTag_param},
|
||||
{"PLAINTEXT", eHTMLTag_plaintext},
|
||||
{"P", eHTMLTag_paragraph,0}, {"PARAM", eHTMLTag_param,0},
|
||||
{"PLAINTEXT", eHTMLTag_plaintext,0},
|
||||
|
||||
{"PRE", eHTMLTag_pre},
|
||||
{"PRE", eHTMLTag_pre,0},
|
||||
|
||||
{"Q", eHTMLTag_quotation},
|
||||
{"Q", eHTMLTag_quotation,0},
|
||||
|
||||
{"S", eHTMLTag_strike}, {"SAMP", eHTMLTag_samp},
|
||||
{"SCRIPT", eHTMLTag_script}, {"SELECT", eHTMLTag_select},
|
||||
{"SERVER", eHTMLTag_server}, {"SMALL", eHTMLTag_small},
|
||||
{"SPACER", eHTMLTag_spacer},
|
||||
{"SPAN", eHTMLTag_span}, {"SPELL", eHTMLTag_spell},
|
||||
{"STRIKE", eHTMLTag_strike},
|
||||
{"STRONG", eHTMLTag_strong}, {"STYLE", eHTMLTag_style},
|
||||
{"SUB", eHTMLTag_sub}, {"SUP", eHTMLTag_sup},
|
||||
{"S", eHTMLTag_s,0}, {"SAMP", eHTMLTag_samp,0},
|
||||
{"SCRIPT", eHTMLTag_script,0}, {"SELECT", eHTMLTag_select,0},
|
||||
{"SERVER", eHTMLTag_server,0}, {"SMALL", eHTMLTag_small,0},
|
||||
{"SPACER", eHTMLTag_spacer,0},
|
||||
{"SPAN", eHTMLTag_span,0}, {"SPELL", eHTMLTag_spell,0},
|
||||
{"STRIKE", eHTMLTag_strike,0},
|
||||
{"STRONG", eHTMLTag_strong,0}, {"STYLE", eHTMLTag_style,0},
|
||||
{"SUB", eHTMLTag_sub,0}, {"SUP", eHTMLTag_sup,0},
|
||||
|
||||
{"TABLE", eHTMLTag_table}, {"TBODY", eHTMLTag_tbody},
|
||||
{"TD", eHTMLTag_td},
|
||||
{"TABLE", eHTMLTag_table,0}, {"TBODY", eHTMLTag_tbody,0},
|
||||
{"TD", eHTMLTag_td,0},
|
||||
|
||||
{"TEXT", eHTMLTag_text},
|
||||
{"TEXT", eHTMLTag_text,0},
|
||||
|
||||
{"TEXTAREA", eHTMLTag_textarea},
|
||||
{"TFOOT", eHTMLTag_tfoot}, {"TH", eHTMLTag_th},
|
||||
{"THEAD", eHTMLTag_thead}, {"TITLE", eHTMLTag_title},
|
||||
{"TR", eHTMLTag_tr}, {"TT", eHTMLTag_tt},
|
||||
{"TEXTAREA", eHTMLTag_textarea,0},
|
||||
{"TFOOT", eHTMLTag_tfoot,0}, {"TH", eHTMLTag_th,0},
|
||||
{"THEAD", eHTMLTag_thead,0}, {"TITLE", eHTMLTag_title,0},
|
||||
{"TR", eHTMLTag_tr,0}, {"TT", eHTMLTag_tt,0},
|
||||
|
||||
{"U", eHTMLTag_u}, {"UL", eHTMLTag_ul},
|
||||
{"USERDEF", eHTMLTag_userdefined},
|
||||
{"VAR", eHTMLTag_var}, {"WBR", eHTMLTag_wbr},
|
||||
{"WS", eHTMLTag_whitespace},
|
||||
{"U", eHTMLTag_u,0}, {"UL", eHTMLTag_ul,0},
|
||||
{"VAR", eHTMLTag_var,0}, {"WBR", eHTMLTag_wbr,0},
|
||||
{"WS", eHTMLTag_whitespace,0},
|
||||
|
||||
{"X-USERDEF", eHTMLTag_userdefined,0}, //make sure this is always last!
|
||||
|
||||
};
|
||||
|
||||
|
||||
struct HTMLAttrEntry
|
||||
{
|
||||
char fName[11];
|
||||
eHTMLAttributes fAttrID;
|
||||
char mName[11];
|
||||
eHTMLAttributes mAttrID;
|
||||
};
|
||||
|
||||
HTMLAttrEntry gHTMLAttributeTable[] =
|
||||
@@ -1073,21 +1074,20 @@ PRInt32 CEntityToken::TranslateToUnicodeStr(nsString& aString) {
|
||||
aString.Append(PRUnichar(index));
|
||||
}
|
||||
else {
|
||||
char* cp = mTextValue.ToNewCString();
|
||||
index=FindEntityIndex(cp);
|
||||
index=FindEntityIndex(mTextValue);
|
||||
if(kNotFound!=index) {
|
||||
PRUnichar ch=gStrToUnicodeTable[index].fValue;
|
||||
PRUnichar ch=gStrToUnicodeTable[index].mValue;
|
||||
aString=ch;
|
||||
}
|
||||
else {
|
||||
#ifdef GESS_MACHINE
|
||||
index=TranslateExtendedEntity(cp,aString);
|
||||
index=TranslateExtendedEntity(mTextValue,aString);
|
||||
#endif
|
||||
}
|
||||
delete cp;
|
||||
}
|
||||
return index;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
@@ -1102,7 +1102,7 @@ PRBool CEntityToken::VerifyEntityTable(){
|
||||
PRInt32 i,j;
|
||||
for(i=1;i<count-1;i++)
|
||||
{
|
||||
j=strcmp(gStrToUnicodeTable[i-1].fName,gStrToUnicodeTable[i].fName);
|
||||
j=strcmp(gStrToUnicodeTable[i-1].mName,gStrToUnicodeTable[i].mName);
|
||||
if(j>0)
|
||||
return PR_FALSE;
|
||||
}
|
||||
@@ -1119,23 +1119,19 @@ PRBool CEntityToken::VerifyEntityTable(){
|
||||
* @param aBuflen -- optional string length
|
||||
* @return integer offset of string in table, or kNotFound
|
||||
*/
|
||||
PRInt32 CEntityToken::FindEntityIndex(const char* aBuffer,PRInt32 aBufLen) {
|
||||
PRInt32 CEntityToken::FindEntityIndex(nsString& aString) {
|
||||
PRInt32 result=kNotFound;
|
||||
PRInt32 cnt=sizeof(gStrToUnicodeTable)/sizeof(StrToUnicodeStruct);
|
||||
PRInt32 low=0;
|
||||
PRInt32 high=cnt-1;
|
||||
PRInt32 middle=kNotFound;
|
||||
|
||||
if(kNotFound==aBufLen) {
|
||||
aBufLen=strlen(aBuffer);
|
||||
}
|
||||
|
||||
if (aBuffer && aBufLen && cnt) {
|
||||
|
||||
if(cnt) {
|
||||
while(low<=high)
|
||||
{
|
||||
middle=(PRInt32)(low+high)/2;
|
||||
// result=strncmp(aBuffer,gStrToUnicodeTable[middle].fName,aBufLen);
|
||||
result=strcmp(aBuffer,gStrToUnicodeTable[middle].fName);
|
||||
result=aString.Compare(gStrToUnicodeTable[middle].mName);
|
||||
// result=strcmp(aBuffer,gStrToUnicodeTable[middle].mName);
|
||||
if (result==0) {
|
||||
return middle;
|
||||
}
|
||||
@@ -1149,6 +1145,46 @@ PRInt32 CEntityToken::FindEntityIndex(const char* aBuffer,PRInt32 aBufLen) {
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* This method is used to convert from a given string (char*)
|
||||
* into a entity index (offset within entity table).
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param aBuffer -- string to be converted
|
||||
* @param aBuflen -- optional string length
|
||||
* @return integer offset of string in table, or kNotFound
|
||||
*/
|
||||
PRInt32 CEntityToken::FindEntityIndexMax(const char* aBuffer,PRInt32 aBufLen) {
|
||||
PRInt32 result=kNotFound;
|
||||
PRInt32 cnt=sizeof(gStrToUnicodeTable)/sizeof(StrToUnicodeStruct);
|
||||
PRInt32 low=0;
|
||||
PRInt32 high=cnt-1;
|
||||
PRInt32 middle=kNotFound;
|
||||
|
||||
if(aBuffer) {
|
||||
if(-1==aBufLen) {
|
||||
aBufLen=strlen(aBuffer);
|
||||
}
|
||||
|
||||
if(aBufLen && cnt) {
|
||||
while(low<=high)
|
||||
{
|
||||
middle=(PRInt32)(low+high)/2;
|
||||
result=strcmp(aBuffer,gStrToUnicodeTable[middle].mName);
|
||||
if (result==0) {
|
||||
return middle;
|
||||
}
|
||||
if (result<0) {
|
||||
high=middle-1;
|
||||
}
|
||||
else low=middle+1;
|
||||
}
|
||||
}
|
||||
}
|
||||
return kNotFound;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* This method reduces all text entities into their char
|
||||
* representation.
|
||||
@@ -1171,9 +1207,9 @@ PRInt32 CEntityToken::ReduceEntities(nsString& aString) {
|
||||
if(kNotFound==endpos)
|
||||
cnt=aString.Length()-1-amppos;
|
||||
else cnt=endpos-amppos;
|
||||
PRInt32 index=FindEntityIndex((const char*)&aString[amppos+1],cnt);
|
||||
PRInt32 index=FindEntityIndexMax((const char*)&aString[amppos+1],cnt);
|
||||
if(kNotFound!=index) {
|
||||
aString[amppos]=gStrToUnicodeTable[index].fValue;
|
||||
aString[amppos]=gStrToUnicodeTable[index].mValue;
|
||||
aString.Cut(amppos+1,cnt+(endpos!=kNotFound));
|
||||
}
|
||||
else offset=amppos+1;
|
||||
@@ -1316,19 +1352,19 @@ public:
|
||||
PRInt32 i,j;
|
||||
for(i=1;i<count-1;i++)
|
||||
{
|
||||
j=strcmp(gHTMLTagTable[i-1].fName,gHTMLTagTable[i].fName);
|
||||
j=strcmp(gHTMLTagTable[i-1].mName,gHTMLTagTable[i].mName);
|
||||
if(j>0) {
|
||||
#ifdef VERBOSE_DEBUG
|
||||
cout << "Tag Table is out of order at " << i << "!" << endl;
|
||||
#endif
|
||||
return;
|
||||
cout << "Tag Table names are out of order at " << i << "!" << endl;
|
||||
}
|
||||
if(gHTMLTagTable[i-1].mTagID>=gHTMLTagTable[i].mTagID) {
|
||||
cout << "Tag table ID's are out of order at " << i << "!" << endl;;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* This method accepts a string (and optionally, its length)
|
||||
* and determines the eHTMLTag (id) value.
|
||||
@@ -1347,9 +1383,9 @@ eHTMLTags DetermineHTMLTagType(const nsString& aString)
|
||||
|
||||
while(low<=high){
|
||||
middle=(PRInt32)(low+high)/2;
|
||||
result=aString.Compare(gHTMLTagTable[middle].fName, PR_TRUE);
|
||||
result=aString.Compare(gHTMLTagTable[middle].mName, PR_TRUE);
|
||||
if (result==0)
|
||||
return gHTMLTagTable[middle].fTagID;
|
||||
return gHTMLTagTable[middle].mTagID;
|
||||
if (result<0)
|
||||
high=middle-1;
|
||||
else low=middle+1;
|
||||
@@ -1373,9 +1409,9 @@ const char* GetTagName(PRInt32 aTag) {
|
||||
|
||||
while(low<=high) {
|
||||
middle=(PRInt32)(low+high)/2;
|
||||
if(aTag==gHTMLTagTable[middle].fTagID)
|
||||
return gHTMLTagTable[middle].fName;
|
||||
if(aTag<gHTMLTagTable[middle].fTagID)
|
||||
if(aTag==gHTMLTagTable[middle].mTagID)
|
||||
return gHTMLTagTable[middle].mName;
|
||||
if(aTag<gHTMLTagTable[middle].mTagID)
|
||||
high=middle-1;
|
||||
else low=middle+1;
|
||||
}
|
||||
@@ -1399,7 +1435,7 @@ public:
|
||||
PRInt32 i,j;
|
||||
for(i=1;i<count-1;i++)
|
||||
{
|
||||
j=strcmp(gHTMLAttributeTable[i-1].fName,gHTMLAttributeTable[i].fName);
|
||||
j=strcmp(gHTMLAttributeTable[i-1].mName,gHTMLAttributeTable[i].mName);
|
||||
if(j>0) {
|
||||
#ifdef VERBOSE_DEBUG
|
||||
cout << "Attribute table is out of order at " << j << "!" << endl;
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
|
||||
/* -*- 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
|
||||
@@ -75,22 +76,24 @@ enum eHTMLTags
|
||||
eHTMLTag_link, eHTMLTag_listing, eHTMLTag_map, eHTMLTag_marquee,
|
||||
eHTMLTag_math, eHTMLTag_menu, eHTMLTag_meta, eHTMLTag_newline,
|
||||
eHTMLTag_nobr,
|
||||
eHTMLTag_noembed, eHTMLTag_noframes, eHTMLTag_nolayer, eHTMLTag_noscript, //74
|
||||
eHTMLTag_noembed, eHTMLTag_noframes, eHTMLTag_nolayer, eHTMLTag_noscript, //
|
||||
eHTMLTag_note, eHTMLTag_object, eHTMLTag_ol,
|
||||
eHTMLTag_option, eHTMLTag_paragraph, eHTMLTag_param, eHTMLTag_plaintext,
|
||||
eHTMLTag_pre, eHTMLTag_quotation, eHTMLTag_samp, eHTMLTag_script,
|
||||
eHTMLTag_pre, eHTMLTag_quotation,
|
||||
|
||||
eHTMLTag_s, eHTMLTag_samp, eHTMLTag_script,
|
||||
eHTMLTag_select, eHTMLTag_server, eHTMLTag_small,
|
||||
eHTMLTag_spacer, eHTMLTag_span, eHTMLTag_spell,
|
||||
eHTMLTag_strong, eHTMLTag_style, eHTMLTag_strike, eHTMLTag_sub,
|
||||
eHTMLTag_sup,
|
||||
eHTMLTag_table, eHTMLTag_tbody, eHTMLTag_td, //98
|
||||
|
||||
eHTMLTag_text, //used for plain text; this is not really a tag.
|
||||
eHTMLTag_textarea, //100
|
||||
eHTMLTag_strike, eHTMLTag_strong, eHTMLTag_style,
|
||||
eHTMLTag_sub, eHTMLTag_sup,
|
||||
|
||||
eHTMLTag_table, eHTMLTag_tbody, eHTMLTag_td, //
|
||||
eHTMLTag_text, //used for plain text; this is not really a tag.
|
||||
eHTMLTag_textarea, //
|
||||
|
||||
eHTMLTag_tfoot,
|
||||
eHTMLTag_th, eHTMLTag_thead, eHTMLTag_title, eHTMLTag_tr,
|
||||
eHTMLTag_tt, eHTMLTag_monofont, eHTMLTag_u, eHTMLTag_ul,
|
||||
eHTMLTag_tt, eHTMLTag_u, eHTMLTag_ul,
|
||||
eHTMLTag_var, eHTMLTag_wbr, eHTMLTag_whitespace,
|
||||
eHTMLTag_xmp,
|
||||
|
||||
@@ -121,9 +124,9 @@ enum eHTMLAttributes {
|
||||
|
||||
PRInt32 ConsumeQuotedString(PRUnichar aChar,nsString& aString,CScanner& aScanner);
|
||||
PRInt32 ConsumeAttributeText(PRUnichar aChar,nsString& aString,CScanner& aScanner);
|
||||
PRInt32 FindEntityIndex(const char* aBuffer,PRInt32 aBufLen=-1);
|
||||
eHTMLTags DetermineHTMLTagType(const nsString& aString);
|
||||
const char* GetTagName(PRInt32 aTag);
|
||||
//PRInt32 FindEntityIndex(nsString& aString,PRInt32 aCount=-1);
|
||||
|
||||
|
||||
/**
|
||||
@@ -219,7 +222,8 @@ class CEntityToken : public CHTMLToken {
|
||||
virtual PRInt32 Consume(PRUnichar aChar,CScanner& aScanner);
|
||||
static PRInt32 ConsumeEntity(PRUnichar aChar,nsString& aString,CScanner& aScanner);
|
||||
static PRInt32 TranslateToUnicodeStr(PRInt32 aValue,nsString& aString);
|
||||
static PRInt32 FindEntityIndex(const char* aBuffer,PRInt32 aBufLen=-1);
|
||||
static PRInt32 FindEntityIndex(nsString& aString);
|
||||
static PRInt32 FindEntityIndexMax(const char* aBuffer,PRInt32 aCount=-1);
|
||||
static PRBool VerifyEntityTable(void);
|
||||
static PRInt32 ReduceEntities(nsString& aString);
|
||||
virtual void DebugDumpSource(ostream& out);
|
||||
|
||||
@@ -39,11 +39,23 @@ class CToken;
|
||||
class nsIContentSink;
|
||||
class nsIDTDDebug;
|
||||
class nsIURL;
|
||||
class nsString;
|
||||
|
||||
enum eProcessType {eParsing, eConverting};
|
||||
enum eAutoDetectResult {eUnknownDetect, eValidDetect, eInvalidDetect};
|
||||
|
||||
class nsIDTD : public nsISupports {
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
*
|
||||
* @update gess6/24/98
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
virtual ~nsIDTD() {};
|
||||
|
||||
/**
|
||||
* This method is called to determine whether or not a tag
|
||||
* of one type can contain a tag of another type.
|
||||
@@ -63,6 +75,14 @@ class nsIDTD : public nsISupports {
|
||||
*/
|
||||
virtual nsIContentSink* SetContentSink(nsIContentSink* aSink)=0;
|
||||
|
||||
/**
|
||||
*
|
||||
* @update gess6/24/98
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
virtual PRBool IsCapableOf(eProcessType aProcessType, nsString& aContentType, PRInt32 aVersion)=0;
|
||||
|
||||
/**
|
||||
*
|
||||
* @update gess5/18/98
|
||||
@@ -130,7 +150,7 @@ class nsIDTD : public nsISupports {
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
virtual void SetDTDDebug(nsIDTDDebug * aDTDDebug) = 0;
|
||||
virtual void SetDTDDebug(nsIDTDDebug * aDTDDebug) = 0;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -21,7 +21,8 @@
|
||||
|
||||
#include "nshtmlpars.h"
|
||||
#include "nsISupports.h"
|
||||
|
||||
#include "nsIStreamListener.h"
|
||||
#include "nsIDTD.h"
|
||||
|
||||
#define NS_IPARSER_IID \
|
||||
{0x355cbba0, 0xbf7d, 0x11d1, \
|
||||
@@ -33,7 +34,6 @@ class nsIStreamObserver;
|
||||
class nsString;
|
||||
class CToken;
|
||||
class nsIURL;
|
||||
class nsIDTD;
|
||||
class nsIDTDDebug;
|
||||
|
||||
/**
|
||||
@@ -45,11 +45,11 @@ class nsIDTDDebug;
|
||||
class nsIParser : public nsISupports {
|
||||
public:
|
||||
|
||||
virtual void RegisterDTD(nsIDTD* aDTD)=0;
|
||||
|
||||
virtual nsIContentSink* SetContentSink(nsIContentSink* aContentSink)=0;
|
||||
|
||||
virtual void SetDTD(nsIDTD* aDTD)=0;
|
||||
|
||||
virtual nsIDTD* GetDTD(void)=0;
|
||||
virtual eAutoDetectResult AutoDetectContentType(nsString& aBuffer)=0;
|
||||
|
||||
/**
|
||||
* Cause the tokenizer to consume the next token, and
|
||||
@@ -65,14 +65,23 @@ class nsIParser : public nsISupports {
|
||||
nsIStreamObserver* aListener = nsnull,
|
||||
nsIDTDDebug * aDTDDebug = 0) = 0;
|
||||
|
||||
virtual PRInt32 Parse(nsIURL* aURL,
|
||||
nsIStreamObserver* aListener = nsnull,
|
||||
nsIDTDDebug * aDTDDebug = 0) = 0;
|
||||
|
||||
/******************************************************************************************
|
||||
* Parse methods always begin with an input source, and perform conversions
|
||||
* until you wind up with HTML in your actual content model.
|
||||
******************************************************************************************/
|
||||
virtual PRInt32 Parse(nsIURL* aURL,nsIStreamObserver* aListener = nsnull,nsIDTDDebug * aDTDDebug = 0) = 0;
|
||||
virtual PRInt32 Parse(const char* aFilename)=0;
|
||||
|
||||
virtual PRInt32 Parse(nsString& anHTMLString,PRBool appendTokens)=0;
|
||||
|
||||
/******************************************************************************************
|
||||
* Convert methods start input source (of known or unknown form), and perform conversions
|
||||
* until you wind up with a <i>stream</i> in your target form.
|
||||
* The internal content model is never effected.
|
||||
******************************************************************************************/
|
||||
virtual PRInt32 Convert(nsIURL* aURL,char* aSourceForm,char* aTargetForm,nsIStreamListener* aListener) = 0;
|
||||
virtual PRInt32 Convert(const char* aFilename,char* aSourceForm,char* aTargetForm)=0;
|
||||
virtual PRInt32 Convert(nsString& anHTMLString,char* aSourceForm,char* aTargetForm,PRBool appendTokens)=0;
|
||||
|
||||
virtual PRInt32 ResumeParse(void)=0;
|
||||
|
||||
/**
|
||||
|
||||
@@ -35,6 +35,7 @@ class CITokenHandler {
|
||||
public:
|
||||
|
||||
virtual PRInt32 operator()(CToken* aToken,nsIDTD* aDTD)=0;
|
||||
virtual PRInt32 GetTokenType(void)=0;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -22,8 +22,6 @@
|
||||
#include "nsIContentSink.h"
|
||||
#include "nsString.h"
|
||||
#include "nsCRT.h"
|
||||
#include "COtherDTD.h"
|
||||
#include "CNavDTD.h"
|
||||
#include "nsScanner.h"
|
||||
#include "prenv.h" //this is here for debug reasons...
|
||||
#include "plstr.h"
|
||||
@@ -31,6 +29,7 @@
|
||||
#include "nsIInputStream.h"
|
||||
#include "nsIParserFilter.h"
|
||||
#include "nsIDTDDebug.h"
|
||||
#include "nshtmlpars.h"
|
||||
|
||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
static NS_DEFINE_IID(kClassIID, NS_PARSER_IID);
|
||||
@@ -40,6 +39,7 @@ static NS_DEFINE_IID(kIStreamListenerIID, NS_ISTREAMLISTENER_IID);
|
||||
static const char* kNullURL = "Error: Null URL given";
|
||||
static const char* kNullFilename= "Error: Null filename given";
|
||||
static const char* kNullTokenizer = "Error: Unable to construct tokenizer";
|
||||
static const char* kHTMLTextContentType = "text/html";
|
||||
|
||||
static const int gTransferBufferSize=4096; //size of the buffer used in moving data from iistream
|
||||
|
||||
@@ -70,13 +70,62 @@ NS_HTMLPARS nsresult NS_NewParser(nsIParser** aInstancePtrResult)
|
||||
|
||||
class CTokenDeallocator: public nsDequeFunctor{
|
||||
public:
|
||||
virtual void operator()(void* anObject) {
|
||||
virtual void* operator()(void* anObject) {
|
||||
CToken* aToken = (CToken*)anObject;
|
||||
delete aToken;
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
CTokenDeallocator gTokenKiller;
|
||||
CTokenDeallocator gTokenDeallocator;
|
||||
|
||||
class CDTDDeallocator: public nsDequeFunctor{
|
||||
public:
|
||||
virtual void* operator()(void* anObject) {
|
||||
nsIDTD* aDTD =(nsIDTD*)anObject;
|
||||
NS_RELEASE(aDTD);
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
class CDTDFinder: public nsDequeFunctor{
|
||||
public:
|
||||
CDTDFinder(nsIDTD* aDTD) {
|
||||
NS_IF_ADDREF(mTargetDTD=aDTD);
|
||||
}
|
||||
~CDTDFinder() {
|
||||
NS_IF_RELEASE(mTargetDTD);
|
||||
}
|
||||
virtual void* operator()(void* anObject) {
|
||||
return (anObject==(void*)mTargetDTD) ? anObject : 0;
|
||||
}
|
||||
nsIDTD* mTargetDTD;
|
||||
};
|
||||
|
||||
class CSharedParserObjects {
|
||||
public:
|
||||
|
||||
CSharedParserObjects() : mDeallocator(), mDTDDeque(mDeallocator) {
|
||||
}
|
||||
~CSharedParserObjects() {
|
||||
}
|
||||
|
||||
void RegisterDTD(nsIDTD* aDTD){
|
||||
CDTDFinder theFinder(aDTD);
|
||||
if(!mDTDDeque.ForEach(theFinder))
|
||||
mDTDDeque.Push(aDTD);
|
||||
}
|
||||
|
||||
nsIDTD* FindDTD(nsIDTD* aDTD){
|
||||
return 0;
|
||||
}
|
||||
|
||||
CDTDDeallocator mDeallocator;
|
||||
nsDeque mDTDDeque;
|
||||
};
|
||||
|
||||
CSharedParserObjects gSharedParserObjects;
|
||||
|
||||
|
||||
/**
|
||||
* default constructor
|
||||
@@ -85,7 +134,10 @@ CTokenDeallocator gTokenKiller;
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
nsParser::nsParser() : mTokenDeque(gTokenKiller) {
|
||||
nsParser::nsParser() :
|
||||
mTokenDeque(gTokenDeallocator),
|
||||
mContentType()
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
mDTDDebug = 0;
|
||||
mParserFilter = 0;
|
||||
@@ -97,6 +149,9 @@ nsParser::nsParser() : mTokenDeque(gTokenKiller) {
|
||||
mParseMode=eParseMode_unknown;
|
||||
mURL=0;
|
||||
mDTD=0;
|
||||
mScanner=0;
|
||||
mTransferBuffer=new char[gTransferBufferSize+1];
|
||||
mAutoDetectStatus=eUnknownDetect;
|
||||
}
|
||||
|
||||
|
||||
@@ -121,7 +176,6 @@ nsParser::~nsParser() {
|
||||
delete mScanner;
|
||||
mScanner=0;
|
||||
|
||||
NS_IF_RELEASE(mDTD);
|
||||
NS_IF_RELEASE(mURL);
|
||||
|
||||
}
|
||||
@@ -207,26 +261,16 @@ nsIContentSink* nsParser::SetContentSink(nsIContentSink* aSink) {
|
||||
return old;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* Call this static method when you want to
|
||||
* register your dynamic DTD's with the parser.
|
||||
*
|
||||
* @update gess 6/9/98
|
||||
* @param
|
||||
* @return
|
||||
* @param aDTD is the object to be registered.
|
||||
* @return nothing.
|
||||
*/
|
||||
void nsParser::SetDTD(nsIDTD* aDTD) {
|
||||
mDTD=aDTD;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the DTD from the parser.
|
||||
* @update gess6/18/98
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
nsIDTD * nsParser::GetDTD(void) {
|
||||
return mDTD;
|
||||
void nsParser::RegisterDTD(nsIDTD* aDTD){
|
||||
gSharedParserObjects.RegisterDTD(aDTD);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -240,39 +284,6 @@ CScanner* nsParser::GetScanner(void){
|
||||
return mScanner;
|
||||
}
|
||||
|
||||
/**
|
||||
* This is where we loop over the tokens created in the
|
||||
* tokenization phase, and try to make sense out of them.
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param
|
||||
* @return PR_TRUE if parse succeeded, PR_FALSE otherwise.
|
||||
*/
|
||||
PRInt32 nsParser::IterateTokens() {
|
||||
nsDequeIterator e=mTokenDeque.End();
|
||||
nsDequeIterator theMarkPos(e);
|
||||
mMajorIteration++;
|
||||
|
||||
if(!mCurrentPos)
|
||||
mCurrentPos=new nsDequeIterator(mTokenDeque.Begin());
|
||||
|
||||
PRInt32 result=kNoError;
|
||||
while((kNoError==result) && ((*mCurrentPos<e))){
|
||||
mMinorIteration++;
|
||||
CToken* theToken=(CToken*)mCurrentPos->GetCurrent();
|
||||
|
||||
theMarkPos=*mCurrentPos;
|
||||
result=mDTD->HandleToken(theToken);
|
||||
++(*mCurrentPos);
|
||||
}
|
||||
|
||||
if(kInterrupted==result)
|
||||
*mCurrentPos=theMarkPos;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
@@ -291,7 +302,6 @@ eParseMode DetermineParseMode() {
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
@@ -299,34 +309,59 @@ eParseMode DetermineParseMode() {
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
nsIDTD* CreateDTD(eParseMode aMode,const char* aContentType) {
|
||||
nsIDTD* aDTD=0;
|
||||
switch(aMode) {
|
||||
case eParseMode_navigator:
|
||||
aDTD=new CNavDTD(); break;
|
||||
case eParseMode_other:
|
||||
aDTD=new COtherDTD(); break;
|
||||
default:
|
||||
break;
|
||||
PRBool FindSuitableDTD(eProcessType aProcessType,eParseMode aMode,nsString& aContentType, nsIDTD*& aDefaultDTD) {
|
||||
PRBool result=PR_FALSE;
|
||||
|
||||
if(aDefaultDTD) {
|
||||
if(aDefaultDTD->IsCapableOf(aProcessType,aContentType,0)) {
|
||||
result=PR_TRUE;
|
||||
}
|
||||
}
|
||||
if (aDTD)
|
||||
aDTD->AddRef();
|
||||
return aDTD;
|
||||
}
|
||||
else {
|
||||
nsDequeIterator b=gSharedParserObjects.mDTDDeque.Begin();
|
||||
nsDequeIterator e=gSharedParserObjects.mDTDDeque.End();
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @update gess6/22/98
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
PRBool nsParser::DetermineContentType(const char* aContentType) {
|
||||
PRBool result=PR_TRUE;
|
||||
aContentType="application/x-unknown-content-type";
|
||||
while(b<e){
|
||||
nsIDTD* theDTD=(nsIDTD*)b.GetCurrent();
|
||||
if(theDTD && theDTD->IsCapableOf(aProcessType,aContentType,0)) {
|
||||
aDefaultDTD=theDTD;
|
||||
result=PR_TRUE;
|
||||
break;
|
||||
}
|
||||
++b;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Call this method if you want the known DTD's to try
|
||||
* to detect the document type based through analysis
|
||||
* of the underlying stream.
|
||||
*
|
||||
* @update gess6/22/98
|
||||
* @param aBuffer -- nsString containing sample data to be analyzed.
|
||||
* @return auto-detect result: eValid, eInvalid, eUnknown
|
||||
*/
|
||||
eAutoDetectResult nsParser::AutoDetectContentType(nsString& aBuffer) {
|
||||
|
||||
//The process:
|
||||
// You should go out and ask each DTD if they
|
||||
// recognize the content in the scanner.
|
||||
// Somebody should say yes, or we can't continue.
|
||||
|
||||
//This method may change mContentType and mDTD.
|
||||
//It absolutely changes mAutoDetectStatus
|
||||
|
||||
mAutoDetectStatus=eUnknownDetect;
|
||||
if(PR_TRUE==mContentType.Equals(kHTMLTextContentType)) {
|
||||
mAutoDetectStatus=eValidDetect;
|
||||
}
|
||||
|
||||
return mAutoDetectStatus;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This gets called just prior to the model actually
|
||||
* being constructed. It's important to make this the
|
||||
@@ -338,14 +373,13 @@ PRBool nsParser::DetermineContentType(const char* aContentType) {
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
PRInt32 nsParser::WillBuildModel(const char* aFilename, const char* aContentType){
|
||||
PRInt32 nsParser::WillBuildModel(eProcessType aProcessType, const char* aFilename){
|
||||
|
||||
mMajorIteration=-1;
|
||||
mMinorIteration=-1;
|
||||
|
||||
mParseMode=DetermineParseMode();
|
||||
mDTD=(0==mDTD) ? CreateDTD(mParseMode,aContentType) : mDTD;
|
||||
if(mDTD) {
|
||||
mDTD->SetDTDDebug(mDTDDebug);
|
||||
if(PR_TRUE==FindSuitableDTD(aProcessType,mParseMode,mContentType,mDTD)) {
|
||||
mDTD->SetParser(this);
|
||||
mDTD->SetContentSink(mSink);
|
||||
mDTD->WillBuildModel(aFilename);
|
||||
@@ -406,16 +440,66 @@ PRBool nsParser::Parse(const char* aFilename){
|
||||
|
||||
//ok, time to create our tokenizer and begin the process
|
||||
mScanner=new CScanner(aFilename,mParseMode);
|
||||
char theContentType[600];
|
||||
DetermineContentType(theContentType);
|
||||
WillBuildModel(aFilename,theContentType);
|
||||
status=ResumeParse();
|
||||
DidBuildModel(status);
|
||||
|
||||
if(mScanner) {
|
||||
mScanner->Eof();
|
||||
if(eValidDetect==AutoDetectContentType(mScanner->GetBuffer())) {
|
||||
WillBuildModel(eParsing,aFilename);
|
||||
status=ResumeParse();
|
||||
DidBuildModel(status);
|
||||
}
|
||||
} //if
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
/**
|
||||
* This is the main controlling routine in the parsing process.
|
||||
* Note that it may get called multiple times for the same scanner,
|
||||
* since this is a pushed based system, and all the tokens may
|
||||
* not have been consumed by the scanner during a given invocation
|
||||
* of this method.
|
||||
*
|
||||
* NOTE: We don't call willbuildmodel here, because it will happen
|
||||
* as a result of calling OnStartBinding later on.
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param aFilename -- const char* containing file to be parsed.
|
||||
* @return PR_TRUE if parse succeeded, PR_FALSE otherwise.
|
||||
*/
|
||||
PRInt32 nsParser::Parse(nsIURL* aURL,nsIStreamObserver* aListener, nsIDTDDebug * aDTDDebug) {
|
||||
PRInt32 status;
|
||||
|
||||
status = BeginParse(aURL, aListener, aDTDDebug);
|
||||
if (NS_OK == status) {
|
||||
status=mURL->Open(this);
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Call this method if all you want to do is parse 1 string full of HTML text.
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
PRInt32 nsParser::Parse(nsString& aSourceBuffer,PRBool appendTokens){
|
||||
PRInt32 result=kNoError;
|
||||
|
||||
mScanner=new CScanner();
|
||||
mScanner->Append(aSourceBuffer);
|
||||
|
||||
if(eValidDetect==AutoDetectContentType(aSourceBuffer)) {
|
||||
WillBuildModel(eParsing,"from-string");
|
||||
result=ResumeParse();
|
||||
DidBuildModel(result);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* This is the main controlling routine in the parsing process.
|
||||
* Note that it may get called multiple times for the same scanner,
|
||||
@@ -454,46 +538,35 @@ PRInt32 nsParser::BeginParse(nsIURL* aURL,nsIStreamObserver* aListener, nsIDTDDe
|
||||
}
|
||||
|
||||
/**
|
||||
* This is the main controlling routine in the parsing process.
|
||||
* Note that it may get called multiple times for the same scanner,
|
||||
* since this is a pushed based system, and all the tokens may
|
||||
* not have been consumed by the scanner during a given invocation
|
||||
* of this method.
|
||||
*
|
||||
* NOTE: We don't call willbuildmodel here, because it will happen
|
||||
* as a result of calling OnStartBinding later on.
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param aFilename -- const char* containing file to be parsed.
|
||||
* @return PR_TRUE if parse succeeded, PR_FALSE otherwise.
|
||||
*
|
||||
* @update gess6/23/98
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
PRInt32 nsParser::Parse(nsIURL* aURL,nsIStreamObserver* aListener, nsIDTDDebug * aDTDDebug) {
|
||||
PRInt32 status;
|
||||
|
||||
status = BeginParse(aURL, aListener, aDTDDebug);
|
||||
if (NS_OK == status) {
|
||||
status=mURL->Open(this);
|
||||
}
|
||||
return status;
|
||||
PRInt32 nsParser::Convert(nsIURL* aURL,char* aSourceForm,char* aTargetForm,nsIStreamListener* aListener) {
|
||||
PRInt32 result=0;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Call this method if all you want to do is parse 1 string full of HTML text.
|
||||
*
|
||||
* @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
|
||||
*
|
||||
* @update gess6/23/98
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
PRInt32 nsParser::Parse(nsString& aSourceBuffer,PRBool appendTokens){
|
||||
PRInt32 result=kNoError;
|
||||
|
||||
WillBuildModel("nsString","text/html");
|
||||
mScanner->Append(aSourceBuffer);
|
||||
result=ResumeParse();
|
||||
DidBuildModel(result);
|
||||
|
||||
PRInt32 nsParser::Convert(const char* aFilename,char* aSourceForm,char* aTargetForm) {
|
||||
PRInt32 result=0;
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @update gess6/23/98
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
PRInt32 nsParser::Convert(nsString& anHTMLString,char* aSourceForm,char* aTargetForm,PRBool appendTokens){
|
||||
PRInt32 result=0;
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -520,6 +593,37 @@ PRInt32 nsParser::ResumeParse() {
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* This is where we loop over the tokens created in the
|
||||
* tokenization phase, and try to make sense out of them.
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param
|
||||
* @return PR_TRUE if parse succeeded, PR_FALSE otherwise.
|
||||
*/
|
||||
PRInt32 nsParser::IterateTokens() {
|
||||
nsDequeIterator e=mTokenDeque.End();
|
||||
nsDequeIterator theMarkPos(e);
|
||||
mMajorIteration++;
|
||||
|
||||
if(!mCurrentPos)
|
||||
mCurrentPos=new nsDequeIterator(mTokenDeque.Begin());
|
||||
|
||||
PRInt32 result=kNoError;
|
||||
while((kNoError==result) && ((*mCurrentPos<e))){
|
||||
mMinorIteration++;
|
||||
CToken* theToken=(CToken*)mCurrentPos->GetCurrent();
|
||||
|
||||
theMarkPos=*mCurrentPos;
|
||||
result=mDTD->HandleToken(theToken);
|
||||
++(*mCurrentPos);
|
||||
}
|
||||
|
||||
if(kInterrupted==result)
|
||||
*mCurrentPos=theMarkPos;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the attributes for this node, and add then into
|
||||
@@ -577,6 +681,10 @@ PRInt32 nsParser::CollectSkippedContent(nsCParserNode& aNode,PRInt32& aCount) {
|
||||
return result;
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
These methods are used to talk to the netlib system...
|
||||
*******************************************************************/
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
@@ -618,11 +726,11 @@ nsresult nsParser::OnStartBinding(const char *aContentType){
|
||||
if (nsnull != mObserver) {
|
||||
mObserver->OnStartBinding(aContentType);
|
||||
}
|
||||
nsresult result=WillBuildModel(mURL->GetSpec(),aContentType);
|
||||
if(!mTransferBuffer) {
|
||||
mTransferBuffer=new char[gTransferBufferSize+1];
|
||||
}
|
||||
return result;
|
||||
mAutoDetectStatus=eUnknownDetect;
|
||||
mDTD=0;
|
||||
|
||||
mContentType=aContentType;
|
||||
return kNoError;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -634,9 +742,21 @@ nsresult nsParser::OnStartBinding(const char *aContentType){
|
||||
* @return error code (usually 0)
|
||||
*/
|
||||
nsresult nsParser::OnDataAvailable(nsIInputStream *pIStream, PRInt32 length){
|
||||
/* if (nsnull != mListener) {
|
||||
//Rick potts removed this.
|
||||
//Does it need to be here?
|
||||
mListener->OnDataAvailable(pIStream, length);
|
||||
}
|
||||
*/
|
||||
int len=0;
|
||||
int offset=0;
|
||||
|
||||
if(eInvalidDetect==mAutoDetectStatus) {
|
||||
if(mScanner) {
|
||||
mScanner->GetBuffer().Truncate();
|
||||
}
|
||||
}
|
||||
|
||||
do {
|
||||
PRInt32 err;
|
||||
len = pIStream->Read(&err, mTransferBuffer, 0, gTransferBufferSize);
|
||||
@@ -650,9 +770,13 @@ nsresult nsParser::OnDataAvailable(nsIInputStream *pIStream, PRInt32 length){
|
||||
|
||||
if (mParserFilter)
|
||||
mParserFilter->RawBuffer(mTransferBuffer, &len);
|
||||
mScanner->Append(mTransferBuffer,len);
|
||||
|
||||
mScanner->Append(&mTransferBuffer[offset],len);
|
||||
|
||||
if(eUnknownDetect==mAutoDetectStatus) {
|
||||
if(eValidDetect==AutoDetectContentType(mScanner->GetBuffer())) {
|
||||
nsresult result=WillBuildModel(eParsing,mURL->GetSpec());
|
||||
} //if
|
||||
}
|
||||
} //if
|
||||
} while (len > 0);
|
||||
|
||||
|
||||
@@ -60,7 +60,6 @@
|
||||
#include "nsParserNode.h"
|
||||
#include "nsParserTypes.h"
|
||||
#include "nsIURL.h"
|
||||
#include "nsIStreamListener.h"
|
||||
|
||||
|
||||
#define NS_PARSER_IID \
|
||||
@@ -107,11 +106,9 @@ friend class CTokenHandler;
|
||||
virtual nsIContentSink* SetContentSink(nsIContentSink* aSink);
|
||||
|
||||
virtual nsIParserFilter* SetParserFilter(nsIParserFilter* aFilter);
|
||||
|
||||
virtual void RegisterDTD(nsIDTD* aDTD);
|
||||
|
||||
virtual void SetDTD(nsIDTD* aDTD);
|
||||
|
||||
virtual nsIDTD* GetDTD(void);
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
@@ -152,6 +149,15 @@ friend class CTokenHandler;
|
||||
*/
|
||||
virtual PRInt32 Parse(nsString& anHTMLString,PRBool appendTokens);
|
||||
|
||||
/******************************************************************************************
|
||||
* Convert methods start input source (of known or unknown form), and perform conversions
|
||||
* until you wind up with a <i>stream</i> in your target form.
|
||||
* The internal content model is never effected.
|
||||
******************************************************************************************/
|
||||
virtual PRInt32 Convert(nsIURL* aURL,char* aSourceForm, char* aTargetForm,nsIStreamListener* aListener);
|
||||
virtual PRInt32 Convert(const char* aFilename,char* aSourceForm,char* aTargetForm);
|
||||
virtual PRInt32 Convert(nsString& anHTMLString,char* aSourceForm,char* aTargetForm,PRBool appendTokens);
|
||||
|
||||
/**
|
||||
* This method gets called (automatically) during incremental parsing
|
||||
* @update gess5/11/98
|
||||
@@ -208,7 +214,7 @@ protected:
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
PRInt32 WillBuildModel(const char* aFilename=0,const char* aContentType=0);
|
||||
PRInt32 WillBuildModel(eProcessType theProcessType=eParsing,const char* aFilename=0);
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -303,7 +309,7 @@ private:
|
||||
* @param
|
||||
* @return TRUE if we figured it out.
|
||||
*/
|
||||
PRBool DetermineContentType(const char* aContentType);
|
||||
eAutoDetectResult AutoDetectContentType(nsString& aBuffer);
|
||||
|
||||
|
||||
protected:
|
||||
@@ -328,7 +334,9 @@ protected:
|
||||
nsDeque mTokenDeque;
|
||||
CScanner* mScanner;
|
||||
nsIURL* mURL;
|
||||
nsIDTDDebug* mDTDDebug;
|
||||
nsIDTDDebug* mDTDDebug;
|
||||
nsString mContentType;
|
||||
eAutoDetectResult mAutoDetectStatus;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
#include "nsParserNode.h"
|
||||
#include "string.h"
|
||||
|
||||
#include "nsHTMLTokens.h"
|
||||
|
||||
/**
|
||||
* Default constructor
|
||||
@@ -32,7 +32,7 @@ nsCParserNode::nsCParserNode(CToken* aToken): nsIParserNode(),
|
||||
mName(), mEmptyString() {
|
||||
NS_PRECONDITION(0!=aToken, "Null Token");
|
||||
mAttributeCount=0;
|
||||
mToken=(CHTMLToken*)aToken;
|
||||
mToken=aToken;
|
||||
memset(mAttributes,0,sizeof(mAttributes));
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ void nsCParserNode::AddAttribute(CToken* aToken) {
|
||||
NS_PRECONDITION(mAttributeCount<sizeof(mAttributes), "Buffer overrun!");
|
||||
NS_PRECONDITION(0!=aToken, "Error: Token shouldn't be null!");
|
||||
if(aToken) {
|
||||
mAttributes[mAttributeCount++]=(CHTMLToken*)aToken;
|
||||
mAttributes[mAttributeCount++]=aToken;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ void nsCParserNode::SetSkippedContent(CToken* aToken){
|
||||
NS_PRECONDITION(mAttributeCount<sizeof(mAttributes)-1, "Buffer overrun!");
|
||||
NS_PRECONDITION(0!=aToken, "Error: Token shouldn't be null!");
|
||||
if(aToken) {
|
||||
mAttributes[mAttributeCount++]=(CHTMLToken*)aToken;
|
||||
mAttributes[mAttributeCount++]=aToken;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
#define NS_PARSERNODE__
|
||||
|
||||
#include "nsIParserNode.h"
|
||||
#include "nsHTMLTokens.h"
|
||||
#include "nsToken.h"
|
||||
#include "nsString.h"
|
||||
|
||||
//class nsParser;
|
||||
@@ -148,11 +148,11 @@ class nsCParserNode : public nsIParserNode {
|
||||
|
||||
|
||||
protected:
|
||||
PRInt32 mAttributeCount;
|
||||
CHTMLToken* mToken;
|
||||
CHTMLToken* mAttributes[20]; // XXX Ack! This needs to be dynamic!
|
||||
nsString mName;
|
||||
nsString mEmptyString;
|
||||
PRInt32 mAttributeCount;
|
||||
CToken* mToken;
|
||||
CToken* mAttributes[20]; // XXX Ack! This needs to be dynamic!
|
||||
nsString mName;
|
||||
nsString mEmptyString;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -503,6 +503,15 @@ PRInt32 CScanner::ReadUntil(nsString& aString,PRUnichar aTerminalChar,PRBool add
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
nsString& CScanner::GetBuffer(void) {
|
||||
return mBuffer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Conduct self test. Actually, selftesting for this class
|
||||
|
||||
@@ -233,6 +233,15 @@ class CScanner {
|
||||
*/
|
||||
PRInt32 IncrementalAppend(const char* aBuffer,PRInt32 aSize);
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @update gess 5/12/98
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
nsString& GetBuffer(void);
|
||||
|
||||
static void SelfTest();
|
||||
|
||||
protected:
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
#include "nsIStreamListener.h"
|
||||
#include "nsIURL.h"
|
||||
#include "nsIWebWidget.h"
|
||||
#include "CNavDTD.h"
|
||||
|
||||
static NS_DEFINE_IID(kIDocumentIID, NS_IDOCUMENT_IID);
|
||||
static NS_DEFINE_IID(kIDOMElementIID, NS_IDOMELEMENT_IID);
|
||||
@@ -119,6 +120,17 @@ nsHTMLDocument::StartDocumentLoad(nsIURL *aURL,
|
||||
rv = parser->QueryInterface(kIStreamListenerIID, (void**)aDocListener);
|
||||
|
||||
if (NS_OK == rv) {
|
||||
|
||||
//The following lines were added by Rick.
|
||||
//These perform "dynamic" DTD registration, allowing
|
||||
//the caller total control over process, and decoupling
|
||||
//parser from any given grammar.
|
||||
|
||||
nsIDTD* theDTD=0;
|
||||
NS_NewNavHTMLDTD(&theDTD);
|
||||
parser->RegisterDTD(theDTD);
|
||||
parser->RegisterDTD(theDTD);
|
||||
|
||||
parser->SetContentSink(sink);
|
||||
parser->BeginParse(aURL);
|
||||
}
|
||||
|
||||
@@ -40,6 +40,7 @@
|
||||
#include "nsScanner.h"
|
||||
#include "nsParserTypes.h"
|
||||
#include "nsVoidArray.h"
|
||||
#include "nsTokenHandler.h"
|
||||
|
||||
#include "prenv.h" //this is here for debug reasons...
|
||||
#include "prtypes.h" //this is here for debug reasons...
|
||||
@@ -61,6 +62,7 @@ static const char* kNullFilename= "Error: Null filename given";
|
||||
static const char* kNullTokenizer = "Error: Unable to construct tokenizer";
|
||||
static const char* kNullToken = "Error: Null token given";
|
||||
static const char* kInvalidTagStackPos = "Error: invalid tag stack position";
|
||||
static const char* kHTMLTextContentType = "text/html";
|
||||
|
||||
static nsAutoString gEmpty;
|
||||
|
||||
@@ -78,7 +80,8 @@ static char gStyleTags[]={
|
||||
eHTMLTag_a, eHTMLTag_bold, eHTMLTag_big,
|
||||
eHTMLTag_blink, eHTMLTag_cite, eHTMLTag_em,
|
||||
eHTMLTag_font, eHTMLTag_italic, eHTMLTag_kbd,
|
||||
eHTMLTag_small, eHTMLTag_spell, eHTMLTag_strike,
|
||||
eHTMLTag_s, eHTMLTag_small,
|
||||
eHTMLTag_spell, eHTMLTag_strike,
|
||||
eHTMLTag_strong, eHTMLTag_sub, eHTMLTag_sup,
|
||||
eHTMLTag_tt, eHTMLTag_u, eHTMLTag_var,
|
||||
0};
|
||||
@@ -215,9 +218,10 @@ void CNavDTD::InitializeDefaultTokenHandlers() {
|
||||
|
||||
class CNavTokenDeallocator: public nsDequeFunctor{
|
||||
public:
|
||||
virtual void operator()(void* anObject) {
|
||||
virtual void* operator()(void* anObject) {
|
||||
CToken* aToken = (CToken*)anObject;
|
||||
delete aToken;
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -277,6 +281,20 @@ void CNavDTD::SetDTDDebug(nsIDTDDebug * aDTDDebug)
|
||||
NS_ADDREF(mDTDDebug);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method gets called by the parser to determine if this DTD can handle
|
||||
* the requested process for the requested content type.
|
||||
*
|
||||
* @update gess6/24/98
|
||||
* @param
|
||||
* @return TRUE if the DTD can handle the process for this type; FALSE otherwise.
|
||||
*/
|
||||
PRBool CNavDTD::IsCapableOf(eProcessType aProcessType, nsString& aContentType,PRInt32 aVersion){
|
||||
PRBool result=aContentType.Equals(kHTMLTextContentType);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @update gess5/18/98
|
||||
@@ -337,10 +355,10 @@ PRInt32 CNavDTD::HandleToken(CToken* aToken){
|
||||
if(aToken) {
|
||||
CHTMLToken* theToken= (CHTMLToken*)(aToken);
|
||||
eHTMLTokenTypes theType=eHTMLTokenTypes(theToken->GetTokenType());
|
||||
CTokenHandler* aHandler=GetTokenHandler(theType);
|
||||
CITokenHandler* theHandler=GetTokenHandler(theType);
|
||||
|
||||
if(aHandler) {
|
||||
result=(*aHandler)(theToken,this);
|
||||
if(theHandler) {
|
||||
result=(*theHandler)(theToken,this);
|
||||
if (mDTDDebug)
|
||||
mDTDDebug->Verify(this, mParser, mContextStackPos, mContextStack, mFilename);
|
||||
}
|
||||
@@ -365,10 +383,10 @@ PRInt32 CNavDTD::HandleToken(CToken* aToken){
|
||||
* @param aNode -- CParserNode representing this start token
|
||||
* @return PR_TRUE if all went well; PR_FALSE if error occured
|
||||
*/
|
||||
PRInt32 CNavDTD::HandleDefaultStartToken(CToken* aToken,eHTMLTags aChildTag,nsCParserNode& aNode) {
|
||||
PRInt32 CNavDTD::HandleDefaultStartToken(CToken* aToken,eHTMLTags aChildTag,nsIParserNode& aNode) {
|
||||
NS_PRECONDITION(0!=aToken,kNullToken);
|
||||
|
||||
eHTMLTags parentTag=(eHTMLTags)GetTopNode();
|
||||
eHTMLTags parentTag=GetTopNode();
|
||||
PRInt32 result=kNoError;
|
||||
PRBool contains=CanContain(parentTag,aChildTag);
|
||||
|
||||
@@ -487,30 +505,7 @@ PRInt32 CNavDTD::HandleStartToken(CToken* aToken) {
|
||||
break;
|
||||
|
||||
case eHTMLTag_script:
|
||||
{
|
||||
PRInt32 pos=GetTopmostIndexOf(eHTMLTag_body);
|
||||
nsCParserNode theNode((CHTMLToken*)aToken);
|
||||
if (kNotFound == pos) {
|
||||
// We're in the HEAD
|
||||
result=OpenHead(theNode);
|
||||
if(kNoError==result) {
|
||||
mParser->CollectSkippedContent(attrNode,theCount);
|
||||
if(kNoError==result) {
|
||||
result=AddLeaf(attrNode);
|
||||
if(kNoError==result)
|
||||
result=CloseHead(theNode);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
// We're in the BODY
|
||||
mParser->CollectSkippedContent(attrNode,theCount);
|
||||
if(kNoError==result) {
|
||||
result=AddLeaf(attrNode);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
result=HandleScriptToken(st); break;
|
||||
|
||||
case eHTMLTag_head:
|
||||
break; //ignore head tags...
|
||||
@@ -570,7 +565,7 @@ PRInt32 CNavDTD::HandleEndToken(CToken* aToken) {
|
||||
|
||||
/*
|
||||
if(0!=strchr(gStyleTags,tokenTagType)){
|
||||
eHTMLTags topTag=(eHTMLTags)GetTopNode();
|
||||
eHTMLTags topTag=GetTopNode();
|
||||
if(0!=strchr(gStyleTags,topTag)){
|
||||
tokenTagType=topTag;
|
||||
}
|
||||
@@ -704,10 +699,32 @@ PRInt32 CNavDTD::HandleAttributeToken(CToken* aToken) {
|
||||
*/
|
||||
PRInt32 CNavDTD::HandleScriptToken(CToken* aToken) {
|
||||
NS_PRECONDITION(0!=aToken,kNullToken);
|
||||
PRInt32 result=kNoError;
|
||||
|
||||
PRInt32 pos=GetTopmostIndexOf(eHTMLTag_body);
|
||||
nsCParserNode theNode((CHTMLToken*)aToken);
|
||||
PRInt32 theCount=0;
|
||||
PRInt32 result=mParser->CollectSkippedContent(theNode,theCount);
|
||||
nsCParserNode attrNode((CHTMLToken*)aToken);
|
||||
PRInt32 attrCount=aToken->GetAttributeCount();
|
||||
|
||||
if (kNotFound == pos) {
|
||||
// We're in the HEAD
|
||||
result=OpenHead(theNode);
|
||||
if(kNoError==result) {
|
||||
mParser->CollectSkippedContent(attrNode,attrCount);
|
||||
if(kNoError==result) {
|
||||
result=AddLeaf(attrNode);
|
||||
if(kNoError==result)
|
||||
result=CloseHead(theNode);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
// We're in the BODY
|
||||
mParser->CollectSkippedContent(attrNode,attrCount);
|
||||
if(kNoError==result) {
|
||||
result=AddLeaf(attrNode);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -753,8 +770,8 @@ void CNavDTD::DeleteTokenHandlers(void) {
|
||||
* @param aTagType type of tag to be handled
|
||||
* @return valid tag handler (if found) or null
|
||||
*/
|
||||
CTokenHandler* CNavDTD::GetTokenHandler(eHTMLTokenTypes aType) const {
|
||||
CTokenHandler* result=0;
|
||||
CITokenHandler* CNavDTD::GetTokenHandler(eHTMLTokenTypes aType) const {
|
||||
CITokenHandler* result=0;
|
||||
if((aType>0) && (aType<eToken_last)) {
|
||||
result=mTokenHandlers[aType];
|
||||
}
|
||||
@@ -771,13 +788,13 @@ CTokenHandler* CNavDTD::GetTokenHandler(eHTMLTokenTypes aType) const {
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
CTokenHandler* CNavDTD::AddTokenHandler(CTokenHandler* aHandler) {
|
||||
CITokenHandler* CNavDTD::AddTokenHandler(CITokenHandler* aHandler) {
|
||||
NS_ASSERTION(0!=aHandler,"Error: Null handler");
|
||||
|
||||
if(aHandler) {
|
||||
eHTMLTokenTypes type=(eHTMLTokenTypes)aHandler->GetTokenType();
|
||||
if(type<eToken_last) {
|
||||
CTokenHandler* old=mTokenHandlers[type];
|
||||
CITokenHandler* old=mTokenHandlers[type];
|
||||
mTokenHandlers[type]=aHandler;
|
||||
}
|
||||
else {
|
||||
@@ -836,8 +853,8 @@ PRBool CNavDTD::CanContainStyles(eHTMLTags aParent) const {
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is called to determine whether or not a tag
|
||||
* of one type can contain a tag of another type.
|
||||
* This method is called to determine whether or not a
|
||||
* form-type tag can contain a tag of another form-type tag.
|
||||
*
|
||||
* @update gess 4/8/98
|
||||
* @param aParent -- tag enum of parent container
|
||||
@@ -845,7 +862,18 @@ PRBool CNavDTD::CanContainStyles(eHTMLTags aParent) const {
|
||||
* @return PR_TRUE if parent can contain child
|
||||
*/
|
||||
PRBool CNavDTD::CanContainFormElement(eHTMLTags aParent,eHTMLTags aChild) const {
|
||||
PRBool result=(mParser) ? HasOpenContainer(eHTMLTag_form) : PR_FALSE;
|
||||
PRBool result=PR_FALSE;
|
||||
|
||||
if(mParser && HasOpenContainer(eHTMLTag_form)) {
|
||||
eHTMLTags topTag=GetTopNode();
|
||||
switch(aChild) {
|
||||
case eHTMLTag_option:
|
||||
result=PRBool(eHTMLTag_select==topTag); break;
|
||||
default:
|
||||
result=PR_TRUE;
|
||||
break;
|
||||
} //switch
|
||||
}//if
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -880,7 +908,8 @@ PRBool CNavDTD::CanContain(PRInt32 aParent,PRInt32 aChild) {
|
||||
eHTMLTag_map, eHTMLTag_menu, eHTMLTag_newline, eHTMLTag_nobr,
|
||||
eHTMLTag_noframes, eHTMLTag_noscript,
|
||||
eHTMLTag_object, eHTMLTag_ol, eHTMLTag_paragraph, eHTMLTag_pre,
|
||||
eHTMLTag_quotation, eHTMLTag_strike, eHTMLTag_samp, eHTMLTag_script,
|
||||
eHTMLTag_quotation, eHTMLTag_s, eHTMLTag_strike,
|
||||
eHTMLTag_samp, eHTMLTag_script,
|
||||
eHTMLTag_select, eHTMLTag_small, eHTMLTag_span, eHTMLTag_strong,
|
||||
eHTMLTag_sub, eHTMLTag_sup, eHTMLTag_table, eHTMLTag_text,
|
||||
|
||||
@@ -901,7 +930,8 @@ PRBool CNavDTD::CanContain(PRInt32 aParent,PRInt32 aChild) {
|
||||
|
||||
eHTMLTag_label, eHTMLTag_map, eHTMLTag_newline, eHTMLTag_nobr,
|
||||
eHTMLTag_object, eHTMLTag_paragraph,
|
||||
eHTMLTag_quotation, eHTMLTag_strike, eHTMLTag_samp, eHTMLTag_script,
|
||||
eHTMLTag_quotation, eHTMLTag_s, eHTMLTag_strike,
|
||||
eHTMLTag_samp, eHTMLTag_script,
|
||||
eHTMLTag_select, eHTMLTag_small, eHTMLTag_span, eHTMLTag_strong,
|
||||
eHTMLTag_sub, eHTMLTag_sup, eHTMLTag_text, eHTMLTag_textarea,
|
||||
eHTMLTag_tt, eHTMLTag_u, eHTMLTag_userdefined, eHTMLTag_var,
|
||||
@@ -925,7 +955,8 @@ PRBool CNavDTD::CanContain(PRInt32 aParent,PRInt32 aChild) {
|
||||
|
||||
eHTMLTag_noframes,
|
||||
eHTMLTag_noscript, eHTMLTag_object, eHTMLTag_paragraph, eHTMLTag_pre,
|
||||
eHTMLTag_quotation, eHTMLTag_strike, eHTMLTag_samp, eHTMLTag_small,
|
||||
eHTMLTag_quotation, eHTMLTag_s, eHTMLTag_strike,
|
||||
eHTMLTag_samp, eHTMLTag_small,
|
||||
eHTMLTag_span, eHTMLTag_strong, eHTMLTag_sub, eHTMLTag_sup,
|
||||
eHTMLTag_td, eHTMLTag_text,
|
||||
|
||||
@@ -944,9 +975,9 @@ PRBool CNavDTD::CanContain(PRInt32 aParent,PRInt32 aChild) {
|
||||
}
|
||||
|
||||
switch((eHTMLTags)aParent) {
|
||||
|
||||
case eHTMLTag_address:
|
||||
result=PRBool(0!=strchr(gTagSet2,aChild));
|
||||
break;
|
||||
result=PRBool(0!=strchr(gTagSet2,aChild)); break;
|
||||
|
||||
case eHTMLTag_applet:
|
||||
{
|
||||
@@ -957,7 +988,8 @@ PRBool CNavDTD::CanContain(PRInt32 aParent,PRInt32 aChild) {
|
||||
eHTMLTag_em, eHTMLTag_font, eHTMLTag_italic, eHTMLTag_iframe,
|
||||
eHTMLTag_img, eHTMLTag_input, eHTMLTag_kbd, eHTMLTag_label,
|
||||
eHTMLTag_map, eHTMLTag_object, eHTMLTag_param, eHTMLTag_quotation,
|
||||
eHTMLTag_samp, eHTMLTag_script, eHTMLTag_select, eHTMLTag_small,
|
||||
eHTMLTag_s, eHTMLTag_samp, eHTMLTag_script,
|
||||
eHTMLTag_select, eHTMLTag_small,
|
||||
eHTMLTag_span, eHTMLTag_strike, eHTMLTag_strong, eHTMLTag_sub,
|
||||
eHTMLTag_sup, eHTMLTag_textarea, eHTMLTag_tt, eHTMLTag_u,
|
||||
eHTMLTag_var,0};
|
||||
@@ -1288,6 +1320,7 @@ PRBool CNavDTD::CanOmit(eHTMLTags aParent,eHTMLTags aChild) const {
|
||||
case eHTMLTag_input: case eHTMLTag_isindex:
|
||||
case eHTMLTag_label: case eHTMLTag_legend:
|
||||
case eHTMLTag_select: case eHTMLTag_textarea:
|
||||
case eHTMLTag_option:
|
||||
if(PR_FALSE==HasOpenContainer(eHTMLTag_form))
|
||||
result=PR_TRUE;
|
||||
break;
|
||||
@@ -1379,7 +1412,7 @@ PRBool CNavDTD::CanOmitEndTag(eHTMLTags aParent,eHTMLTags aChild) const {
|
||||
break;
|
||||
|
||||
default:
|
||||
if(IsCompatibleStyleTag(aChild,(eHTMLTags)GetTopNode()))
|
||||
if(IsCompatibleStyleTag(aChild,GetTopNode()))
|
||||
result=PR_FALSE;
|
||||
else result=(!HasOpenContainer(aChild));
|
||||
break;
|
||||
@@ -1587,33 +1620,6 @@ PRBool CNavDTD::BackwardPropagate(nsString& aVector,eHTMLTags aParentTag,eHTMLTa
|
||||
*/
|
||||
PRInt32 CNavDTD::DidOpenContainer(eHTMLTags aTag,PRBool /*anExplicitOpen*/){
|
||||
PRInt32 result=0;
|
||||
|
||||
switch (aTag) {
|
||||
|
||||
case eHTMLTag_a:
|
||||
case eHTMLTag_bold:
|
||||
case eHTMLTag_big:
|
||||
case eHTMLTag_blink:
|
||||
case eHTMLTag_cite:
|
||||
case eHTMLTag_em:
|
||||
case eHTMLTag_font:
|
||||
case eHTMLTag_italic:
|
||||
case eHTMLTag_kbd:
|
||||
case eHTMLTag_small:
|
||||
case eHTMLTag_spell:
|
||||
case eHTMLTag_strike:
|
||||
case eHTMLTag_strong:
|
||||
case eHTMLTag_sub:
|
||||
case eHTMLTag_sup:
|
||||
case eHTMLTag_tt:
|
||||
case eHTMLTag_u:
|
||||
case eHTMLTag_var:
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -1704,7 +1710,7 @@ PRInt32 CNavDTD::OpenTransientStyles(eHTMLTags aTag){
|
||||
if(0==strchr(gWhitespaceTags,aTag)){
|
||||
PRInt32 pos=0;
|
||||
|
||||
eHTMLTags parentTag=(eHTMLTags)GetTopNode();
|
||||
eHTMLTags parentTag=GetTopNode();
|
||||
if(CanContainStyles(parentTag)) {
|
||||
for(pos=0;pos<mStyleStackPos;pos++) {
|
||||
eHTMLTags theTag=(eHTMLTags)(int)mStyleStack[pos];
|
||||
@@ -1832,7 +1838,7 @@ PRInt32 CNavDTD::OpenBody(const nsIParserNode& aNode){
|
||||
NS_PRECONDITION(mContextStackPos >= 0, kInvalidTagStackPos);
|
||||
|
||||
PRInt32 result=kNoError;
|
||||
eHTMLTags topTag=(eHTMLTags)CNavDTD::GetTopNode();
|
||||
eHTMLTags topTag=GetTopNode();
|
||||
|
||||
if(eHTMLTag_html!=topTag) {
|
||||
|
||||
@@ -2126,7 +2132,7 @@ PRInt32 CNavDTD::CloseContainersTo(eHTMLTags aTag,PRBool aUpdateStyles){
|
||||
return CloseContainersTo(pos,aTag,aUpdateStyles);
|
||||
}
|
||||
|
||||
eHTMLTags theTopTag=(eHTMLTags)GetTopNode();
|
||||
eHTMLTags theTopTag=GetTopNode();
|
||||
if(IsCompatibleStyleTag(aTag,theTopTag)) {
|
||||
//if you're here, it's because we're trying to close one style tag,
|
||||
//but a different one is actually open. Because this is NAV4x
|
||||
@@ -2263,13 +2269,13 @@ PRInt32 CNavDTD::CreateContextStackFor(eHTMLTags aChildTag){
|
||||
*/
|
||||
PRInt32 CNavDTD::ReduceContextStackFor(eHTMLTags aChildTag){
|
||||
PRInt32 result=kNoError;
|
||||
eHTMLTags topTag=(eHTMLTags)GetTopNode();
|
||||
eHTMLTags topTag=GetTopNode();
|
||||
|
||||
while( (topTag!=kNotFound) &&
|
||||
(PR_FALSE==CanContain(topTag,aChildTag)) &&
|
||||
(PR_FALSE==CanContainIndirect(topTag,aChildTag))) {
|
||||
CloseTopmostContainer();
|
||||
topTag=(eHTMLTags)GetTopNode();
|
||||
topTag=GetTopNode();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -2297,6 +2303,7 @@ PRInt32 CNavDTD::UpdateStyleStackForOpenTag(eHTMLTags aTag,eHTMLTags anActualTag
|
||||
case eHTMLTag_font:
|
||||
case eHTMLTag_italic:
|
||||
case eHTMLTag_kbd:
|
||||
case eHTMLTag_s:
|
||||
case eHTMLTag_small:
|
||||
case eHTMLTag_spell:
|
||||
case eHTMLTag_strike:
|
||||
@@ -2346,6 +2353,7 @@ PRInt32 CNavDTD::UpdateStyleStackForCloseTag(eHTMLTags aTag,eHTMLTags anActualTa
|
||||
case eHTMLTag_kbd:
|
||||
case eHTMLTag_small:
|
||||
case eHTMLTag_spell:
|
||||
case eHTMLTag_s:
|
||||
case eHTMLTag_strike:
|
||||
case eHTMLTag_strong:
|
||||
case eHTMLTag_sub:
|
||||
|
||||
@@ -28,22 +28,22 @@
|
||||
#define NS_NAVHTMLDTD__
|
||||
|
||||
#include "nsIDTD.h"
|
||||
#include "nsISupports.h"
|
||||
#include "nsHTMLTokens.h"
|
||||
#include "nshtmlpars.h"
|
||||
#include "nsParserNode.h"
|
||||
#include "nsTokenHandler.h"
|
||||
#include "nsVoidArray.h"
|
||||
#include "nsDeque.h"
|
||||
|
||||
|
||||
#define NS_INAVHTML_DTD_IID \
|
||||
{0x5c5cce40, 0xcfd6, 0x11d1, \
|
||||
{0xaa, 0xda, 0x00, 0x80, 0x5f, 0x8a, 0x3e, 0x14}}
|
||||
|
||||
|
||||
class nsParser;
|
||||
class nsIHTMLContentSink;
|
||||
class nsIDTDDebug;
|
||||
class nsIParserNode;
|
||||
class CITokenHandler;
|
||||
class nsParser;
|
||||
|
||||
class CNavDTD : public nsIDTD {
|
||||
|
||||
@@ -70,13 +70,21 @@ class CNavDTD : public nsIDTD {
|
||||
*/
|
||||
virtual ~CNavDTD();
|
||||
|
||||
/**
|
||||
*
|
||||
* @update gess7/1/98
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
virtual PRBool IsCapableOf(eProcessType aProcessType, nsString& aString, PRInt32 aVersion);
|
||||
|
||||
/**
|
||||
*
|
||||
* @update jevering6/23/98
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
virtual void SetDTDDebug(nsIDTDDebug * aDTDDebug);
|
||||
virtual void SetDTDDebug(nsIDTDDebug * aDTDDebug);
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -292,7 +300,7 @@ class CNavDTD : public nsIDTD {
|
||||
* @param aNode is a node be updated with info from given token
|
||||
* @return TRUE if the token was handled.
|
||||
*/
|
||||
PRInt32 HandleDefaultStartToken(CToken* aToken,eHTMLTags aChildTag,nsCParserNode& aNode);
|
||||
PRInt32 HandleDefaultStartToken(CToken* aToken,eHTMLTags aChildTag,nsIParserNode& aNode);
|
||||
|
||||
/**
|
||||
* This method gets called when an end token has been consumed and needs
|
||||
@@ -359,7 +367,7 @@ class CNavDTD : public nsIDTD {
|
||||
|
||||
|
||||
|
||||
private:
|
||||
protected:
|
||||
|
||||
/**
|
||||
* Causes token handlers to be registered for this parser.
|
||||
@@ -373,13 +381,13 @@ private:
|
||||
* DEPRECATED
|
||||
* @update gess5/11/98
|
||||
*/
|
||||
CTokenHandler* GetTokenHandler(eHTMLTokenTypes aType) const;
|
||||
CITokenHandler* GetTokenHandler(eHTMLTokenTypes aType) const;
|
||||
|
||||
/**
|
||||
* DEPRECATED
|
||||
* @update gess5/11/98
|
||||
*/
|
||||
CTokenHandler* AddTokenHandler(CTokenHandler* aHandler);
|
||||
CITokenHandler* AddTokenHandler(CITokenHandler* aHandler);
|
||||
|
||||
/**
|
||||
* DEPRECATED
|
||||
@@ -679,7 +687,7 @@ protected:
|
||||
nsParser* mParser;
|
||||
nsIHTMLContentSink* mSink;
|
||||
|
||||
CTokenHandler* mTokenHandlers[eToken_last];
|
||||
CITokenHandler* mTokenHandlers[eToken_last];
|
||||
|
||||
nsVoidArray mLeafBits;
|
||||
nsVoidArray mContextStack;
|
||||
@@ -691,9 +699,10 @@ protected:
|
||||
PRBool mHasOpenMap;
|
||||
nsDeque mTokenDeque;
|
||||
char* mFilename;
|
||||
nsIDTDDebug* mDTDDebug;
|
||||
nsIDTDDebug* mDTDDebug;
|
||||
};
|
||||
|
||||
extern NS_HTMLPARS nsresult NS_NewNavHTMLDTD(nsIDTD** aInstancePtrResult);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -26,13 +26,7 @@
|
||||
#ifndef NS_OTHERHTMLDTD__
|
||||
#define NS_OTHERHTMLDTD__
|
||||
|
||||
#include "nsIDTD.h"
|
||||
#include "nsHTMLTokens.h"
|
||||
#include "nshtmlpars.h"
|
||||
#include "nsParserNode.h"
|
||||
#include "nsTokenHandler.h"
|
||||
#include "nsDeque.h"
|
||||
#include "nsVoidArray.h"
|
||||
#include "CNavDTD.h"
|
||||
|
||||
|
||||
#define NS_IOtherHTML_DTD_IID \
|
||||
@@ -40,11 +34,10 @@
|
||||
{0x80, 0x22, 0x00, 0x60, 0x8, 0x14, 0x98, 0x89}}
|
||||
|
||||
|
||||
class nsParser;
|
||||
class nsIHTMLContentSink;
|
||||
class nsIDTDDebug;
|
||||
//class nsParser;
|
||||
//class nsIHTMLContentSink;
|
||||
|
||||
class COtherDTD : public nsIDTD {
|
||||
class COtherDTD : public CNavDTD {
|
||||
|
||||
public:
|
||||
|
||||
@@ -69,14 +62,8 @@ class COtherDTD : public nsIDTD {
|
||||
*/
|
||||
virtual ~COtherDTD();
|
||||
|
||||
/**
|
||||
*
|
||||
* @update jevering6/23/98
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
virtual void SetDTDDebug(nsIDTDDebug * aDTDDebug);
|
||||
|
||||
virtual PRBool IsCapableOf(eProcessType aProcessType, nsString& aString,PRInt32 aVersion);
|
||||
|
||||
/**
|
||||
*
|
||||
* @update gess5/18/98
|
||||
@@ -101,15 +88,6 @@ class COtherDTD : public nsIDTD {
|
||||
*/
|
||||
virtual PRInt32 HandleToken(CToken* aToken);
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
virtual void SetParser(nsIParser* aParser);
|
||||
|
||||
/**
|
||||
* Cause the tokenizer to consume the next token, and
|
||||
* return an error result.
|
||||
@@ -137,14 +115,6 @@ class COtherDTD : public nsIDTD {
|
||||
*/
|
||||
virtual void WillInterruptParse(void);
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
virtual nsIContentSink* SetContentSink(nsIContentSink* aSink);
|
||||
|
||||
/**
|
||||
* This method is called to determine whether or not a tag
|
||||
* of one type can contain a tag of another type.
|
||||
@@ -239,30 +209,6 @@ class COtherDTD : public nsIDTD {
|
||||
*/
|
||||
virtual PRInt32 DidOpenContainer(eHTMLTags aTag,PRBool anExplicitOpen);
|
||||
|
||||
/**
|
||||
* 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;
|
||||
|
||||
|
||||
/**
|
||||
* Retrieve 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;
|
||||
|
||||
/**
|
||||
*
|
||||
* @update gess6/4/98
|
||||
@@ -291,7 +237,7 @@ class COtherDTD : public nsIDTD {
|
||||
* @param aNode is a node be updated with info from given token
|
||||
* @return TRUE if the token was handled.
|
||||
*/
|
||||
PRInt32 HandleDefaultStartToken(CToken* aToken,eHTMLTags aChildTag,nsCParserNode& aNode);
|
||||
PRInt32 HandleDefaultStartToken(CToken* aToken,eHTMLTags aChildTag,nsIParserNode& aNode);
|
||||
|
||||
/**
|
||||
* This method gets called when an end token has been consumed and needs
|
||||
@@ -358,33 +304,6 @@ class COtherDTD : public nsIDTD {
|
||||
|
||||
private:
|
||||
|
||||
/**
|
||||
* Causes token handlers to be registered for this parser.
|
||||
* DO NOT CALL THIS! IT'S DEPRECATED!
|
||||
* @update gess5/11/98
|
||||
*/
|
||||
void InitializeDefaultTokenHandlers();
|
||||
|
||||
|
||||
/**
|
||||
* DEPRECATED
|
||||
* @update gess5/11/98
|
||||
*/
|
||||
CTokenHandler* GetTokenHandler(eHTMLTokenTypes aType) const;
|
||||
|
||||
/**
|
||||
* DEPRECATED
|
||||
* @update gess5/11/98
|
||||
*/
|
||||
CTokenHandler* AddTokenHandler(CTokenHandler* aHandler);
|
||||
|
||||
/**
|
||||
* DEPRECATED
|
||||
* @update gess5/11/98
|
||||
*/
|
||||
void DeleteTokenHandlers(void);
|
||||
|
||||
|
||||
|
||||
//*************************************************
|
||||
//these cover methods mimic the sink, and are used
|
||||
@@ -673,23 +592,8 @@ protected:
|
||||
|
||||
PRBool CanContainFormElement(eHTMLTags aParent,eHTMLTags aChild) const;
|
||||
|
||||
nsParser* mParser;
|
||||
nsIHTMLContentSink* mSink;
|
||||
|
||||
CTokenHandler* mTokenHandlers[eToken_last];
|
||||
|
||||
nsVoidArray mLeafBits;
|
||||
nsVoidArray mContextStack;
|
||||
PRInt32 mContextStackPos;
|
||||
|
||||
nsVoidArray mStyleStack;
|
||||
PRInt32 mStyleStackPos;
|
||||
PRBool mHasOpenForm;
|
||||
PRBool mHasOpenMap;
|
||||
nsDeque mTokenDeque;
|
||||
char* mFilename;
|
||||
nsIDTDDebug* mDTDDebug;
|
||||
};
|
||||
|
||||
extern NS_HTMLPARS nsresult NS_NewOtherHTMLDTD(nsIDTD** aInstancePtrResult);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -42,8 +42,11 @@ EXPORTS = \
|
||||
nsHTMLTokens.h \
|
||||
nsIParserNode.h \
|
||||
nsIParser.h \
|
||||
nsIDTD.h \
|
||||
nsIParserFilter.h \
|
||||
nsToken.h \
|
||||
CNavDTD.h \
|
||||
COtherDTD.h \
|
||||
$(NULL)
|
||||
|
||||
MODULE = raptor
|
||||
|
||||
@@ -32,7 +32,8 @@ CPPSRCS=nsHTMLContentSink.cpp \
|
||||
|
||||
EXPORTS=nshtmlpars.h nsIContentSink.h nsIHTMLContentSink.h \
|
||||
nsHTMLTokens.h nsIParserNode.h nsIParser.h nsToken.h \
|
||||
nsIDTDDebug.h nsIParserFilter.h
|
||||
nsIDTDDebug.h nsIParserFilter.h \
|
||||
CNavDTD.h COtherDTD.h nsIDTD.h
|
||||
|
||||
CPP_OBJS=.\$(OBJDIR)\nsHTMLContentSink.obj \
|
||||
.\$(OBJDIR)\CNavDTD.obj \
|
||||
|
||||
@@ -45,8 +45,8 @@ static const char* kNullScanner = "Error: Scanner is null.";
|
||||
const PRInt32 kMAXNAMELEN=10;
|
||||
struct StrToUnicodeStruct
|
||||
{
|
||||
char fName[kMAXNAMELEN+1];
|
||||
PRInt32 fValue;
|
||||
char mName[kMAXNAMELEN+1];
|
||||
PRInt32 mValue;
|
||||
};
|
||||
|
||||
|
||||
@@ -96,8 +96,9 @@ static StrToUnicodeStruct gStrToUnicodeTable[] =
|
||||
|
||||
|
||||
struct HTMLTagEntry {
|
||||
char fName[12];
|
||||
eHTMLTags fTagID;
|
||||
char mName[12];
|
||||
eHTMLTags mTagID;
|
||||
PRInt16 mUnused;
|
||||
};
|
||||
|
||||
// KEEP THIS LIST SORTED!
|
||||
@@ -106,103 +107,103 @@ struct HTMLTagEntry {
|
||||
// the binary search code above will break!
|
||||
HTMLTagEntry gHTMLTagTable[] =
|
||||
{
|
||||
{"!!UNKNOWN", eHTMLTag_unknown},
|
||||
{"!DOCTYPE", eHTMLTag_doctype}, {"A", eHTMLTag_a},
|
||||
{"ACRONYM", eHTMLTag_acronym}, {"ADDRESS", eHTMLTag_address},
|
||||
{"APPLET", eHTMLTag_applet}, {"AREA", eHTMLTag_area},
|
||||
{"!!UNKNOWN", eHTMLTag_unknown,0},
|
||||
{"!DOCTYPE", eHTMLTag_doctype,0}, {"A", eHTMLTag_a,0},
|
||||
{"ACRONYM", eHTMLTag_acronym,0}, {"ADDRESS", eHTMLTag_address,0},
|
||||
{"APPLET", eHTMLTag_applet,0}, {"AREA", eHTMLTag_area,0},
|
||||
|
||||
{"B", eHTMLTag_bold}, {"BASE", eHTMLTag_base},
|
||||
{"BASEFONT", eHTMLTag_basefont}, {"BDO", eHTMLTag_bdo},
|
||||
{"BIG", eHTMLTag_big}, {"BLINK", eHTMLTag_blink},
|
||||
{"BLOCKQUOTE", eHTMLTag_blockquote}, {"BODY", eHTMLTag_body},
|
||||
{"BR", eHTMLTag_br}, {"BUTTON", eHTMLTag_button},
|
||||
{"B", eHTMLTag_bold,0}, {"BASE", eHTMLTag_base,0},
|
||||
{"BASEFONT", eHTMLTag_basefont,0}, {"BDO", eHTMLTag_bdo,0},
|
||||
{"BIG", eHTMLTag_big,0}, {"BLINK", eHTMLTag_blink,0},
|
||||
{"BLOCKQUOTE", eHTMLTag_blockquote,0}, {"BODY", eHTMLTag_body,0},
|
||||
{"BR", eHTMLTag_br,0}, {"BUTTON", eHTMLTag_button,0},
|
||||
|
||||
{"CAPTION", eHTMLTag_caption}, {"CENTER", eHTMLTag_center},
|
||||
{"CERTIFICATE", eHTMLTag_certificate},
|
||||
{"CITE", eHTMLTag_cite}, {"CODE", eHTMLTag_code},
|
||||
{"COL", eHTMLTag_col}, {"COLGROUP", eHTMLTag_colgroup},
|
||||
{"COMMENT", eHTMLTag_comment},
|
||||
{"CAPTION", eHTMLTag_caption,0}, {"CENTER", eHTMLTag_center,0},
|
||||
{"CERTIFICATE", eHTMLTag_certificate,0},
|
||||
{"CITE", eHTMLTag_cite,0}, {"CODE", eHTMLTag_code,0},
|
||||
{"COL", eHTMLTag_col,0}, {"COLGROUP", eHTMLTag_colgroup,0},
|
||||
{"COMMENT", eHTMLTag_comment,0},
|
||||
|
||||
{"DD", eHTMLTag_dd}, {"DEL", eHTMLTag_del},
|
||||
{"DFN", eHTMLTag_dfn}, {"DIR", eHTMLTag_dir},
|
||||
{"DIV", eHTMLTag_div}, {"DL", eHTMLTag_dl},
|
||||
{"DT", eHTMLTag_dt},
|
||||
{"DD", eHTMLTag_dd,0}, {"DEL", eHTMLTag_del,0},
|
||||
{"DFN", eHTMLTag_dfn,0}, {"DIR", eHTMLTag_dir,0},
|
||||
{"DIV", eHTMLTag_div,0}, {"DL", eHTMLTag_dl,0},
|
||||
{"DT", eHTMLTag_dt,0},
|
||||
|
||||
{"EM", eHTMLTag_em}, {"EMBED", eHTMLTag_embed},
|
||||
{"ENTITY", eHTMLTag_entity}, //a pseudo tag
|
||||
{"EM", eHTMLTag_em,0}, {"EMBED", eHTMLTag_embed,0},
|
||||
{"ENTITY", eHTMLTag_entity,0}, //a pseudo tag
|
||||
|
||||
{"FIELDSET", eHTMLTag_fieldset}, {"FONT", eHTMLTag_font},
|
||||
{"FOOTER", eHTMLTag_footer}, {"FORM", eHTMLTag_form},
|
||||
{"FRAME", eHTMLTag_frame}, {"FRAMESET", eHTMLTag_frameset},
|
||||
{"FIELDSET", eHTMLTag_fieldset,0}, {"FONT", eHTMLTag_font,0},
|
||||
{"FOOTER", eHTMLTag_footer,0}, {"FORM", eHTMLTag_form,0},
|
||||
{"FRAME", eHTMLTag_frame,0}, {"FRAMESET", eHTMLTag_frameset,0},
|
||||
|
||||
{"H1", eHTMLTag_h1}, {"H2", eHTMLTag_h2},
|
||||
{"H3", eHTMLTag_h3}, {"H4", eHTMLTag_h4},
|
||||
{"H5", eHTMLTag_h5}, {"H6", eHTMLTag_h6},
|
||||
{"HEAD", eHTMLTag_head}, {"HEADER", eHTMLTag_header},
|
||||
{"HR", eHTMLTag_hr}, {"HTML", eHTMLTag_html},
|
||||
{"H1", eHTMLTag_h1,0}, {"H2", eHTMLTag_h2,0},
|
||||
{"H3", eHTMLTag_h3,0}, {"H4", eHTMLTag_h4,0},
|
||||
{"H5", eHTMLTag_h5,0}, {"H6", eHTMLTag_h6,0},
|
||||
{"HEAD", eHTMLTag_head,0}, {"HEADER", eHTMLTag_header,0},
|
||||
{"HR", eHTMLTag_hr,0}, {"HTML", eHTMLTag_html,0},
|
||||
|
||||
{"I", eHTMLTag_italic}, {"IFRAME", eHTMLTag_iframe},
|
||||
{"ILAYER", eHTMLTag_ilayer}, {"IMG", eHTMLTag_img},
|
||||
{"INPUT", eHTMLTag_input}, {"INS", eHTMLTag_ins},
|
||||
{"ISINDEX", eHTMLTag_isindex},
|
||||
{"I", eHTMLTag_italic,0}, {"IFRAME", eHTMLTag_iframe,0},
|
||||
{"ILAYER", eHTMLTag_ilayer,0}, {"IMG", eHTMLTag_img,0},
|
||||
{"INPUT", eHTMLTag_input,0}, {"INS", eHTMLTag_ins,0},
|
||||
{"ISINDEX", eHTMLTag_isindex,0},
|
||||
|
||||
{"KBD", eHTMLTag_kbd}, {"KEYGEN", eHTMLTag_keygen},
|
||||
{"KBD", eHTMLTag_kbd,0}, {"KEYGEN", eHTMLTag_keygen,0},
|
||||
|
||||
{"LABEL", eHTMLTag_label}, {"LAYER", eHTMLTag_layer},
|
||||
{"LEGEND", eHTMLTag_legend}, {"LI", eHTMLTag_listitem},
|
||||
{"LINK", eHTMLTag_link}, {"LISTING", eHTMLTag_listing},
|
||||
{"LABEL", eHTMLTag_label,0}, {"LAYER", eHTMLTag_layer,0},
|
||||
{"LEGEND", eHTMLTag_legend,0}, {"LI", eHTMLTag_listitem,0},
|
||||
{"LINK", eHTMLTag_link,0}, {"LISTING", eHTMLTag_listing,0},
|
||||
|
||||
{"MAP", eHTMLTag_map}, {"MARQUEE", eHTMLTag_marquee},
|
||||
{"MATH", eHTMLTag_math},
|
||||
{"MENU", eHTMLTag_menu}, {"META", eHTMLTag_meta},
|
||||
{"MAP", eHTMLTag_map,0}, {"MARQUEE", eHTMLTag_marquee,0},
|
||||
{"MATH", eHTMLTag_math,0},
|
||||
{"MENU", eHTMLTag_menu,0}, {"META", eHTMLTag_meta,0},
|
||||
|
||||
{"NEWLINE", eHTMLTag_newline}, {"NOBR", eHTMLTag_nobr},
|
||||
{"NEWLINE", eHTMLTag_newline,0}, {"NOBR", eHTMLTag_nobr,0},
|
||||
|
||||
{"NOEMBED", eHTMLTag_noembed}, {"NOFRAMES", eHTMLTag_noframes},
|
||||
{"NOLAYER", eHTMLTag_nolayer}, {"NOSCRIPT", eHTMLTag_noscript},
|
||||
{"NOTE", eHTMLTag_note},
|
||||
{"NOEMBED", eHTMLTag_noembed,0}, {"NOFRAMES", eHTMLTag_noframes,0},
|
||||
{"NOLAYER", eHTMLTag_nolayer,0}, {"NOSCRIPT", eHTMLTag_noscript,0},
|
||||
{"NOTE", eHTMLTag_note,0},
|
||||
|
||||
{"OBJECT", eHTMLTag_object}, {"OL", eHTMLTag_ol},
|
||||
{"OPTION", eHTMLTag_option},
|
||||
{"OBJECT", eHTMLTag_object,0}, {"OL", eHTMLTag_ol,0},
|
||||
{"OPTION", eHTMLTag_option,0},
|
||||
|
||||
{"P", eHTMLTag_paragraph}, {"PARAM", eHTMLTag_param},
|
||||
{"PLAINTEXT", eHTMLTag_plaintext},
|
||||
{"P", eHTMLTag_paragraph,0}, {"PARAM", eHTMLTag_param,0},
|
||||
{"PLAINTEXT", eHTMLTag_plaintext,0},
|
||||
|
||||
{"PRE", eHTMLTag_pre},
|
||||
{"PRE", eHTMLTag_pre,0},
|
||||
|
||||
{"Q", eHTMLTag_quotation},
|
||||
{"Q", eHTMLTag_quotation,0},
|
||||
|
||||
{"S", eHTMLTag_strike}, {"SAMP", eHTMLTag_samp},
|
||||
{"SCRIPT", eHTMLTag_script}, {"SELECT", eHTMLTag_select},
|
||||
{"SERVER", eHTMLTag_server}, {"SMALL", eHTMLTag_small},
|
||||
{"SPACER", eHTMLTag_spacer},
|
||||
{"SPAN", eHTMLTag_span}, {"SPELL", eHTMLTag_spell},
|
||||
{"STRIKE", eHTMLTag_strike},
|
||||
{"STRONG", eHTMLTag_strong}, {"STYLE", eHTMLTag_style},
|
||||
{"SUB", eHTMLTag_sub}, {"SUP", eHTMLTag_sup},
|
||||
{"S", eHTMLTag_s,0}, {"SAMP", eHTMLTag_samp,0},
|
||||
{"SCRIPT", eHTMLTag_script,0}, {"SELECT", eHTMLTag_select,0},
|
||||
{"SERVER", eHTMLTag_server,0}, {"SMALL", eHTMLTag_small,0},
|
||||
{"SPACER", eHTMLTag_spacer,0},
|
||||
{"SPAN", eHTMLTag_span,0}, {"SPELL", eHTMLTag_spell,0},
|
||||
{"STRIKE", eHTMLTag_strike,0},
|
||||
{"STRONG", eHTMLTag_strong,0}, {"STYLE", eHTMLTag_style,0},
|
||||
{"SUB", eHTMLTag_sub,0}, {"SUP", eHTMLTag_sup,0},
|
||||
|
||||
{"TABLE", eHTMLTag_table}, {"TBODY", eHTMLTag_tbody},
|
||||
{"TD", eHTMLTag_td},
|
||||
{"TABLE", eHTMLTag_table,0}, {"TBODY", eHTMLTag_tbody,0},
|
||||
{"TD", eHTMLTag_td,0},
|
||||
|
||||
{"TEXT", eHTMLTag_text},
|
||||
{"TEXT", eHTMLTag_text,0},
|
||||
|
||||
{"TEXTAREA", eHTMLTag_textarea},
|
||||
{"TFOOT", eHTMLTag_tfoot}, {"TH", eHTMLTag_th},
|
||||
{"THEAD", eHTMLTag_thead}, {"TITLE", eHTMLTag_title},
|
||||
{"TR", eHTMLTag_tr}, {"TT", eHTMLTag_tt},
|
||||
{"TEXTAREA", eHTMLTag_textarea,0},
|
||||
{"TFOOT", eHTMLTag_tfoot,0}, {"TH", eHTMLTag_th,0},
|
||||
{"THEAD", eHTMLTag_thead,0}, {"TITLE", eHTMLTag_title,0},
|
||||
{"TR", eHTMLTag_tr,0}, {"TT", eHTMLTag_tt,0},
|
||||
|
||||
{"U", eHTMLTag_u}, {"UL", eHTMLTag_ul},
|
||||
{"USERDEF", eHTMLTag_userdefined},
|
||||
{"VAR", eHTMLTag_var}, {"WBR", eHTMLTag_wbr},
|
||||
{"WS", eHTMLTag_whitespace},
|
||||
{"U", eHTMLTag_u,0}, {"UL", eHTMLTag_ul,0},
|
||||
{"VAR", eHTMLTag_var,0}, {"WBR", eHTMLTag_wbr,0},
|
||||
{"WS", eHTMLTag_whitespace,0},
|
||||
|
||||
{"X-USERDEF", eHTMLTag_userdefined,0}, //make sure this is always last!
|
||||
|
||||
};
|
||||
|
||||
|
||||
struct HTMLAttrEntry
|
||||
{
|
||||
char fName[11];
|
||||
eHTMLAttributes fAttrID;
|
||||
char mName[11];
|
||||
eHTMLAttributes mAttrID;
|
||||
};
|
||||
|
||||
HTMLAttrEntry gHTMLAttributeTable[] =
|
||||
@@ -1073,21 +1074,20 @@ PRInt32 CEntityToken::TranslateToUnicodeStr(nsString& aString) {
|
||||
aString.Append(PRUnichar(index));
|
||||
}
|
||||
else {
|
||||
char* cp = mTextValue.ToNewCString();
|
||||
index=FindEntityIndex(cp);
|
||||
index=FindEntityIndex(mTextValue);
|
||||
if(kNotFound!=index) {
|
||||
PRUnichar ch=gStrToUnicodeTable[index].fValue;
|
||||
PRUnichar ch=gStrToUnicodeTable[index].mValue;
|
||||
aString=ch;
|
||||
}
|
||||
else {
|
||||
#ifdef GESS_MACHINE
|
||||
index=TranslateExtendedEntity(cp,aString);
|
||||
index=TranslateExtendedEntity(mTextValue,aString);
|
||||
#endif
|
||||
}
|
||||
delete cp;
|
||||
}
|
||||
return index;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
@@ -1102,7 +1102,7 @@ PRBool CEntityToken::VerifyEntityTable(){
|
||||
PRInt32 i,j;
|
||||
for(i=1;i<count-1;i++)
|
||||
{
|
||||
j=strcmp(gStrToUnicodeTable[i-1].fName,gStrToUnicodeTable[i].fName);
|
||||
j=strcmp(gStrToUnicodeTable[i-1].mName,gStrToUnicodeTable[i].mName);
|
||||
if(j>0)
|
||||
return PR_FALSE;
|
||||
}
|
||||
@@ -1119,23 +1119,19 @@ PRBool CEntityToken::VerifyEntityTable(){
|
||||
* @param aBuflen -- optional string length
|
||||
* @return integer offset of string in table, or kNotFound
|
||||
*/
|
||||
PRInt32 CEntityToken::FindEntityIndex(const char* aBuffer,PRInt32 aBufLen) {
|
||||
PRInt32 CEntityToken::FindEntityIndex(nsString& aString) {
|
||||
PRInt32 result=kNotFound;
|
||||
PRInt32 cnt=sizeof(gStrToUnicodeTable)/sizeof(StrToUnicodeStruct);
|
||||
PRInt32 low=0;
|
||||
PRInt32 high=cnt-1;
|
||||
PRInt32 middle=kNotFound;
|
||||
|
||||
if(kNotFound==aBufLen) {
|
||||
aBufLen=strlen(aBuffer);
|
||||
}
|
||||
|
||||
if (aBuffer && aBufLen && cnt) {
|
||||
|
||||
if(cnt) {
|
||||
while(low<=high)
|
||||
{
|
||||
middle=(PRInt32)(low+high)/2;
|
||||
// result=strncmp(aBuffer,gStrToUnicodeTable[middle].fName,aBufLen);
|
||||
result=strcmp(aBuffer,gStrToUnicodeTable[middle].fName);
|
||||
result=aString.Compare(gStrToUnicodeTable[middle].mName);
|
||||
// result=strcmp(aBuffer,gStrToUnicodeTable[middle].mName);
|
||||
if (result==0) {
|
||||
return middle;
|
||||
}
|
||||
@@ -1149,6 +1145,46 @@ PRInt32 CEntityToken::FindEntityIndex(const char* aBuffer,PRInt32 aBufLen) {
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* This method is used to convert from a given string (char*)
|
||||
* into a entity index (offset within entity table).
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param aBuffer -- string to be converted
|
||||
* @param aBuflen -- optional string length
|
||||
* @return integer offset of string in table, or kNotFound
|
||||
*/
|
||||
PRInt32 CEntityToken::FindEntityIndexMax(const char* aBuffer,PRInt32 aBufLen) {
|
||||
PRInt32 result=kNotFound;
|
||||
PRInt32 cnt=sizeof(gStrToUnicodeTable)/sizeof(StrToUnicodeStruct);
|
||||
PRInt32 low=0;
|
||||
PRInt32 high=cnt-1;
|
||||
PRInt32 middle=kNotFound;
|
||||
|
||||
if(aBuffer) {
|
||||
if(-1==aBufLen) {
|
||||
aBufLen=strlen(aBuffer);
|
||||
}
|
||||
|
||||
if(aBufLen && cnt) {
|
||||
while(low<=high)
|
||||
{
|
||||
middle=(PRInt32)(low+high)/2;
|
||||
result=strcmp(aBuffer,gStrToUnicodeTable[middle].mName);
|
||||
if (result==0) {
|
||||
return middle;
|
||||
}
|
||||
if (result<0) {
|
||||
high=middle-1;
|
||||
}
|
||||
else low=middle+1;
|
||||
}
|
||||
}
|
||||
}
|
||||
return kNotFound;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* This method reduces all text entities into their char
|
||||
* representation.
|
||||
@@ -1171,9 +1207,9 @@ PRInt32 CEntityToken::ReduceEntities(nsString& aString) {
|
||||
if(kNotFound==endpos)
|
||||
cnt=aString.Length()-1-amppos;
|
||||
else cnt=endpos-amppos;
|
||||
PRInt32 index=FindEntityIndex((const char*)&aString[amppos+1],cnt);
|
||||
PRInt32 index=FindEntityIndexMax((const char*)&aString[amppos+1],cnt);
|
||||
if(kNotFound!=index) {
|
||||
aString[amppos]=gStrToUnicodeTable[index].fValue;
|
||||
aString[amppos]=gStrToUnicodeTable[index].mValue;
|
||||
aString.Cut(amppos+1,cnt+(endpos!=kNotFound));
|
||||
}
|
||||
else offset=amppos+1;
|
||||
@@ -1316,19 +1352,19 @@ public:
|
||||
PRInt32 i,j;
|
||||
for(i=1;i<count-1;i++)
|
||||
{
|
||||
j=strcmp(gHTMLTagTable[i-1].fName,gHTMLTagTable[i].fName);
|
||||
j=strcmp(gHTMLTagTable[i-1].mName,gHTMLTagTable[i].mName);
|
||||
if(j>0) {
|
||||
#ifdef VERBOSE_DEBUG
|
||||
cout << "Tag Table is out of order at " << i << "!" << endl;
|
||||
#endif
|
||||
return;
|
||||
cout << "Tag Table names are out of order at " << i << "!" << endl;
|
||||
}
|
||||
if(gHTMLTagTable[i-1].mTagID>=gHTMLTagTable[i].mTagID) {
|
||||
cout << "Tag table ID's are out of order at " << i << "!" << endl;;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* This method accepts a string (and optionally, its length)
|
||||
* and determines the eHTMLTag (id) value.
|
||||
@@ -1347,9 +1383,9 @@ eHTMLTags DetermineHTMLTagType(const nsString& aString)
|
||||
|
||||
while(low<=high){
|
||||
middle=(PRInt32)(low+high)/2;
|
||||
result=aString.Compare(gHTMLTagTable[middle].fName, PR_TRUE);
|
||||
result=aString.Compare(gHTMLTagTable[middle].mName, PR_TRUE);
|
||||
if (result==0)
|
||||
return gHTMLTagTable[middle].fTagID;
|
||||
return gHTMLTagTable[middle].mTagID;
|
||||
if (result<0)
|
||||
high=middle-1;
|
||||
else low=middle+1;
|
||||
@@ -1373,9 +1409,9 @@ const char* GetTagName(PRInt32 aTag) {
|
||||
|
||||
while(low<=high) {
|
||||
middle=(PRInt32)(low+high)/2;
|
||||
if(aTag==gHTMLTagTable[middle].fTagID)
|
||||
return gHTMLTagTable[middle].fName;
|
||||
if(aTag<gHTMLTagTable[middle].fTagID)
|
||||
if(aTag==gHTMLTagTable[middle].mTagID)
|
||||
return gHTMLTagTable[middle].mName;
|
||||
if(aTag<gHTMLTagTable[middle].mTagID)
|
||||
high=middle-1;
|
||||
else low=middle+1;
|
||||
}
|
||||
@@ -1399,7 +1435,7 @@ public:
|
||||
PRInt32 i,j;
|
||||
for(i=1;i<count-1;i++)
|
||||
{
|
||||
j=strcmp(gHTMLAttributeTable[i-1].fName,gHTMLAttributeTable[i].fName);
|
||||
j=strcmp(gHTMLAttributeTable[i-1].mName,gHTMLAttributeTable[i].mName);
|
||||
if(j>0) {
|
||||
#ifdef VERBOSE_DEBUG
|
||||
cout << "Attribute table is out of order at " << j << "!" << endl;
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
|
||||
/* -*- 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
|
||||
@@ -75,22 +76,24 @@ enum eHTMLTags
|
||||
eHTMLTag_link, eHTMLTag_listing, eHTMLTag_map, eHTMLTag_marquee,
|
||||
eHTMLTag_math, eHTMLTag_menu, eHTMLTag_meta, eHTMLTag_newline,
|
||||
eHTMLTag_nobr,
|
||||
eHTMLTag_noembed, eHTMLTag_noframes, eHTMLTag_nolayer, eHTMLTag_noscript, //74
|
||||
eHTMLTag_noembed, eHTMLTag_noframes, eHTMLTag_nolayer, eHTMLTag_noscript, //
|
||||
eHTMLTag_note, eHTMLTag_object, eHTMLTag_ol,
|
||||
eHTMLTag_option, eHTMLTag_paragraph, eHTMLTag_param, eHTMLTag_plaintext,
|
||||
eHTMLTag_pre, eHTMLTag_quotation, eHTMLTag_samp, eHTMLTag_script,
|
||||
eHTMLTag_pre, eHTMLTag_quotation,
|
||||
|
||||
eHTMLTag_s, eHTMLTag_samp, eHTMLTag_script,
|
||||
eHTMLTag_select, eHTMLTag_server, eHTMLTag_small,
|
||||
eHTMLTag_spacer, eHTMLTag_span, eHTMLTag_spell,
|
||||
eHTMLTag_strong, eHTMLTag_style, eHTMLTag_strike, eHTMLTag_sub,
|
||||
eHTMLTag_sup,
|
||||
eHTMLTag_table, eHTMLTag_tbody, eHTMLTag_td, //98
|
||||
|
||||
eHTMLTag_text, //used for plain text; this is not really a tag.
|
||||
eHTMLTag_textarea, //100
|
||||
eHTMLTag_strike, eHTMLTag_strong, eHTMLTag_style,
|
||||
eHTMLTag_sub, eHTMLTag_sup,
|
||||
|
||||
eHTMLTag_table, eHTMLTag_tbody, eHTMLTag_td, //
|
||||
eHTMLTag_text, //used for plain text; this is not really a tag.
|
||||
eHTMLTag_textarea, //
|
||||
|
||||
eHTMLTag_tfoot,
|
||||
eHTMLTag_th, eHTMLTag_thead, eHTMLTag_title, eHTMLTag_tr,
|
||||
eHTMLTag_tt, eHTMLTag_monofont, eHTMLTag_u, eHTMLTag_ul,
|
||||
eHTMLTag_tt, eHTMLTag_u, eHTMLTag_ul,
|
||||
eHTMLTag_var, eHTMLTag_wbr, eHTMLTag_whitespace,
|
||||
eHTMLTag_xmp,
|
||||
|
||||
@@ -121,9 +124,9 @@ enum eHTMLAttributes {
|
||||
|
||||
PRInt32 ConsumeQuotedString(PRUnichar aChar,nsString& aString,CScanner& aScanner);
|
||||
PRInt32 ConsumeAttributeText(PRUnichar aChar,nsString& aString,CScanner& aScanner);
|
||||
PRInt32 FindEntityIndex(const char* aBuffer,PRInt32 aBufLen=-1);
|
||||
eHTMLTags DetermineHTMLTagType(const nsString& aString);
|
||||
const char* GetTagName(PRInt32 aTag);
|
||||
//PRInt32 FindEntityIndex(nsString& aString,PRInt32 aCount=-1);
|
||||
|
||||
|
||||
/**
|
||||
@@ -219,7 +222,8 @@ class CEntityToken : public CHTMLToken {
|
||||
virtual PRInt32 Consume(PRUnichar aChar,CScanner& aScanner);
|
||||
static PRInt32 ConsumeEntity(PRUnichar aChar,nsString& aString,CScanner& aScanner);
|
||||
static PRInt32 TranslateToUnicodeStr(PRInt32 aValue,nsString& aString);
|
||||
static PRInt32 FindEntityIndex(const char* aBuffer,PRInt32 aBufLen=-1);
|
||||
static PRInt32 FindEntityIndex(nsString& aString);
|
||||
static PRInt32 FindEntityIndexMax(const char* aBuffer,PRInt32 aCount=-1);
|
||||
static PRBool VerifyEntityTable(void);
|
||||
static PRInt32 ReduceEntities(nsString& aString);
|
||||
virtual void DebugDumpSource(ostream& out);
|
||||
|
||||
@@ -39,11 +39,23 @@ class CToken;
|
||||
class nsIContentSink;
|
||||
class nsIDTDDebug;
|
||||
class nsIURL;
|
||||
class nsString;
|
||||
|
||||
enum eProcessType {eParsing, eConverting};
|
||||
enum eAutoDetectResult {eUnknownDetect, eValidDetect, eInvalidDetect};
|
||||
|
||||
class nsIDTD : public nsISupports {
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
*
|
||||
* @update gess6/24/98
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
virtual ~nsIDTD() {};
|
||||
|
||||
/**
|
||||
* This method is called to determine whether or not a tag
|
||||
* of one type can contain a tag of another type.
|
||||
@@ -63,6 +75,14 @@ class nsIDTD : public nsISupports {
|
||||
*/
|
||||
virtual nsIContentSink* SetContentSink(nsIContentSink* aSink)=0;
|
||||
|
||||
/**
|
||||
*
|
||||
* @update gess6/24/98
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
virtual PRBool IsCapableOf(eProcessType aProcessType, nsString& aContentType, PRInt32 aVersion)=0;
|
||||
|
||||
/**
|
||||
*
|
||||
* @update gess5/18/98
|
||||
@@ -130,7 +150,7 @@ class nsIDTD : public nsISupports {
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
virtual void SetDTDDebug(nsIDTDDebug * aDTDDebug) = 0;
|
||||
virtual void SetDTDDebug(nsIDTDDebug * aDTDDebug) = 0;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -21,7 +21,8 @@
|
||||
|
||||
#include "nshtmlpars.h"
|
||||
#include "nsISupports.h"
|
||||
|
||||
#include "nsIStreamListener.h"
|
||||
#include "nsIDTD.h"
|
||||
|
||||
#define NS_IPARSER_IID \
|
||||
{0x355cbba0, 0xbf7d, 0x11d1, \
|
||||
@@ -33,7 +34,6 @@ class nsIStreamObserver;
|
||||
class nsString;
|
||||
class CToken;
|
||||
class nsIURL;
|
||||
class nsIDTD;
|
||||
class nsIDTDDebug;
|
||||
|
||||
/**
|
||||
@@ -45,11 +45,11 @@ class nsIDTDDebug;
|
||||
class nsIParser : public nsISupports {
|
||||
public:
|
||||
|
||||
virtual void RegisterDTD(nsIDTD* aDTD)=0;
|
||||
|
||||
virtual nsIContentSink* SetContentSink(nsIContentSink* aContentSink)=0;
|
||||
|
||||
virtual void SetDTD(nsIDTD* aDTD)=0;
|
||||
|
||||
virtual nsIDTD* GetDTD(void)=0;
|
||||
virtual eAutoDetectResult AutoDetectContentType(nsString& aBuffer)=0;
|
||||
|
||||
/**
|
||||
* Cause the tokenizer to consume the next token, and
|
||||
@@ -65,14 +65,23 @@ class nsIParser : public nsISupports {
|
||||
nsIStreamObserver* aListener = nsnull,
|
||||
nsIDTDDebug * aDTDDebug = 0) = 0;
|
||||
|
||||
virtual PRInt32 Parse(nsIURL* aURL,
|
||||
nsIStreamObserver* aListener = nsnull,
|
||||
nsIDTDDebug * aDTDDebug = 0) = 0;
|
||||
|
||||
/******************************************************************************************
|
||||
* Parse methods always begin with an input source, and perform conversions
|
||||
* until you wind up with HTML in your actual content model.
|
||||
******************************************************************************************/
|
||||
virtual PRInt32 Parse(nsIURL* aURL,nsIStreamObserver* aListener = nsnull,nsIDTDDebug * aDTDDebug = 0) = 0;
|
||||
virtual PRInt32 Parse(const char* aFilename)=0;
|
||||
|
||||
virtual PRInt32 Parse(nsString& anHTMLString,PRBool appendTokens)=0;
|
||||
|
||||
/******************************************************************************************
|
||||
* Convert methods start input source (of known or unknown form), and perform conversions
|
||||
* until you wind up with a <i>stream</i> in your target form.
|
||||
* The internal content model is never effected.
|
||||
******************************************************************************************/
|
||||
virtual PRInt32 Convert(nsIURL* aURL,char* aSourceForm,char* aTargetForm,nsIStreamListener* aListener) = 0;
|
||||
virtual PRInt32 Convert(const char* aFilename,char* aSourceForm,char* aTargetForm)=0;
|
||||
virtual PRInt32 Convert(nsString& anHTMLString,char* aSourceForm,char* aTargetForm,PRBool appendTokens)=0;
|
||||
|
||||
virtual PRInt32 ResumeParse(void)=0;
|
||||
|
||||
/**
|
||||
|
||||
@@ -35,6 +35,7 @@ class CITokenHandler {
|
||||
public:
|
||||
|
||||
virtual PRInt32 operator()(CToken* aToken,nsIDTD* aDTD)=0;
|
||||
virtual PRInt32 GetTokenType(void)=0;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -22,8 +22,6 @@
|
||||
#include "nsIContentSink.h"
|
||||
#include "nsString.h"
|
||||
#include "nsCRT.h"
|
||||
#include "COtherDTD.h"
|
||||
#include "CNavDTD.h"
|
||||
#include "nsScanner.h"
|
||||
#include "prenv.h" //this is here for debug reasons...
|
||||
#include "plstr.h"
|
||||
@@ -31,6 +29,7 @@
|
||||
#include "nsIInputStream.h"
|
||||
#include "nsIParserFilter.h"
|
||||
#include "nsIDTDDebug.h"
|
||||
#include "nshtmlpars.h"
|
||||
|
||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
static NS_DEFINE_IID(kClassIID, NS_PARSER_IID);
|
||||
@@ -40,6 +39,7 @@ static NS_DEFINE_IID(kIStreamListenerIID, NS_ISTREAMLISTENER_IID);
|
||||
static const char* kNullURL = "Error: Null URL given";
|
||||
static const char* kNullFilename= "Error: Null filename given";
|
||||
static const char* kNullTokenizer = "Error: Unable to construct tokenizer";
|
||||
static const char* kHTMLTextContentType = "text/html";
|
||||
|
||||
static const int gTransferBufferSize=4096; //size of the buffer used in moving data from iistream
|
||||
|
||||
@@ -70,13 +70,62 @@ NS_HTMLPARS nsresult NS_NewParser(nsIParser** aInstancePtrResult)
|
||||
|
||||
class CTokenDeallocator: public nsDequeFunctor{
|
||||
public:
|
||||
virtual void operator()(void* anObject) {
|
||||
virtual void* operator()(void* anObject) {
|
||||
CToken* aToken = (CToken*)anObject;
|
||||
delete aToken;
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
CTokenDeallocator gTokenKiller;
|
||||
CTokenDeallocator gTokenDeallocator;
|
||||
|
||||
class CDTDDeallocator: public nsDequeFunctor{
|
||||
public:
|
||||
virtual void* operator()(void* anObject) {
|
||||
nsIDTD* aDTD =(nsIDTD*)anObject;
|
||||
NS_RELEASE(aDTD);
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
class CDTDFinder: public nsDequeFunctor{
|
||||
public:
|
||||
CDTDFinder(nsIDTD* aDTD) {
|
||||
NS_IF_ADDREF(mTargetDTD=aDTD);
|
||||
}
|
||||
~CDTDFinder() {
|
||||
NS_IF_RELEASE(mTargetDTD);
|
||||
}
|
||||
virtual void* operator()(void* anObject) {
|
||||
return (anObject==(void*)mTargetDTD) ? anObject : 0;
|
||||
}
|
||||
nsIDTD* mTargetDTD;
|
||||
};
|
||||
|
||||
class CSharedParserObjects {
|
||||
public:
|
||||
|
||||
CSharedParserObjects() : mDeallocator(), mDTDDeque(mDeallocator) {
|
||||
}
|
||||
~CSharedParserObjects() {
|
||||
}
|
||||
|
||||
void RegisterDTD(nsIDTD* aDTD){
|
||||
CDTDFinder theFinder(aDTD);
|
||||
if(!mDTDDeque.ForEach(theFinder))
|
||||
mDTDDeque.Push(aDTD);
|
||||
}
|
||||
|
||||
nsIDTD* FindDTD(nsIDTD* aDTD){
|
||||
return 0;
|
||||
}
|
||||
|
||||
CDTDDeallocator mDeallocator;
|
||||
nsDeque mDTDDeque;
|
||||
};
|
||||
|
||||
CSharedParserObjects gSharedParserObjects;
|
||||
|
||||
|
||||
/**
|
||||
* default constructor
|
||||
@@ -85,7 +134,10 @@ CTokenDeallocator gTokenKiller;
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
nsParser::nsParser() : mTokenDeque(gTokenKiller) {
|
||||
nsParser::nsParser() :
|
||||
mTokenDeque(gTokenDeallocator),
|
||||
mContentType()
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
mDTDDebug = 0;
|
||||
mParserFilter = 0;
|
||||
@@ -97,6 +149,9 @@ nsParser::nsParser() : mTokenDeque(gTokenKiller) {
|
||||
mParseMode=eParseMode_unknown;
|
||||
mURL=0;
|
||||
mDTD=0;
|
||||
mScanner=0;
|
||||
mTransferBuffer=new char[gTransferBufferSize+1];
|
||||
mAutoDetectStatus=eUnknownDetect;
|
||||
}
|
||||
|
||||
|
||||
@@ -121,7 +176,6 @@ nsParser::~nsParser() {
|
||||
delete mScanner;
|
||||
mScanner=0;
|
||||
|
||||
NS_IF_RELEASE(mDTD);
|
||||
NS_IF_RELEASE(mURL);
|
||||
|
||||
}
|
||||
@@ -207,26 +261,16 @@ nsIContentSink* nsParser::SetContentSink(nsIContentSink* aSink) {
|
||||
return old;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* Call this static method when you want to
|
||||
* register your dynamic DTD's with the parser.
|
||||
*
|
||||
* @update gess 6/9/98
|
||||
* @param
|
||||
* @return
|
||||
* @param aDTD is the object to be registered.
|
||||
* @return nothing.
|
||||
*/
|
||||
void nsParser::SetDTD(nsIDTD* aDTD) {
|
||||
mDTD=aDTD;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the DTD from the parser.
|
||||
* @update gess6/18/98
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
nsIDTD * nsParser::GetDTD(void) {
|
||||
return mDTD;
|
||||
void nsParser::RegisterDTD(nsIDTD* aDTD){
|
||||
gSharedParserObjects.RegisterDTD(aDTD);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -240,39 +284,6 @@ CScanner* nsParser::GetScanner(void){
|
||||
return mScanner;
|
||||
}
|
||||
|
||||
/**
|
||||
* This is where we loop over the tokens created in the
|
||||
* tokenization phase, and try to make sense out of them.
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param
|
||||
* @return PR_TRUE if parse succeeded, PR_FALSE otherwise.
|
||||
*/
|
||||
PRInt32 nsParser::IterateTokens() {
|
||||
nsDequeIterator e=mTokenDeque.End();
|
||||
nsDequeIterator theMarkPos(e);
|
||||
mMajorIteration++;
|
||||
|
||||
if(!mCurrentPos)
|
||||
mCurrentPos=new nsDequeIterator(mTokenDeque.Begin());
|
||||
|
||||
PRInt32 result=kNoError;
|
||||
while((kNoError==result) && ((*mCurrentPos<e))){
|
||||
mMinorIteration++;
|
||||
CToken* theToken=(CToken*)mCurrentPos->GetCurrent();
|
||||
|
||||
theMarkPos=*mCurrentPos;
|
||||
result=mDTD->HandleToken(theToken);
|
||||
++(*mCurrentPos);
|
||||
}
|
||||
|
||||
if(kInterrupted==result)
|
||||
*mCurrentPos=theMarkPos;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
@@ -291,7 +302,6 @@ eParseMode DetermineParseMode() {
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
@@ -299,34 +309,59 @@ eParseMode DetermineParseMode() {
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
nsIDTD* CreateDTD(eParseMode aMode,const char* aContentType) {
|
||||
nsIDTD* aDTD=0;
|
||||
switch(aMode) {
|
||||
case eParseMode_navigator:
|
||||
aDTD=new CNavDTD(); break;
|
||||
case eParseMode_other:
|
||||
aDTD=new COtherDTD(); break;
|
||||
default:
|
||||
break;
|
||||
PRBool FindSuitableDTD(eProcessType aProcessType,eParseMode aMode,nsString& aContentType, nsIDTD*& aDefaultDTD) {
|
||||
PRBool result=PR_FALSE;
|
||||
|
||||
if(aDefaultDTD) {
|
||||
if(aDefaultDTD->IsCapableOf(aProcessType,aContentType,0)) {
|
||||
result=PR_TRUE;
|
||||
}
|
||||
}
|
||||
if (aDTD)
|
||||
aDTD->AddRef();
|
||||
return aDTD;
|
||||
}
|
||||
else {
|
||||
nsDequeIterator b=gSharedParserObjects.mDTDDeque.Begin();
|
||||
nsDequeIterator e=gSharedParserObjects.mDTDDeque.End();
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @update gess6/22/98
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
PRBool nsParser::DetermineContentType(const char* aContentType) {
|
||||
PRBool result=PR_TRUE;
|
||||
aContentType="application/x-unknown-content-type";
|
||||
while(b<e){
|
||||
nsIDTD* theDTD=(nsIDTD*)b.GetCurrent();
|
||||
if(theDTD && theDTD->IsCapableOf(aProcessType,aContentType,0)) {
|
||||
aDefaultDTD=theDTD;
|
||||
result=PR_TRUE;
|
||||
break;
|
||||
}
|
||||
++b;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Call this method if you want the known DTD's to try
|
||||
* to detect the document type based through analysis
|
||||
* of the underlying stream.
|
||||
*
|
||||
* @update gess6/22/98
|
||||
* @param aBuffer -- nsString containing sample data to be analyzed.
|
||||
* @return auto-detect result: eValid, eInvalid, eUnknown
|
||||
*/
|
||||
eAutoDetectResult nsParser::AutoDetectContentType(nsString& aBuffer) {
|
||||
|
||||
//The process:
|
||||
// You should go out and ask each DTD if they
|
||||
// recognize the content in the scanner.
|
||||
// Somebody should say yes, or we can't continue.
|
||||
|
||||
//This method may change mContentType and mDTD.
|
||||
//It absolutely changes mAutoDetectStatus
|
||||
|
||||
mAutoDetectStatus=eUnknownDetect;
|
||||
if(PR_TRUE==mContentType.Equals(kHTMLTextContentType)) {
|
||||
mAutoDetectStatus=eValidDetect;
|
||||
}
|
||||
|
||||
return mAutoDetectStatus;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This gets called just prior to the model actually
|
||||
* being constructed. It's important to make this the
|
||||
@@ -338,14 +373,13 @@ PRBool nsParser::DetermineContentType(const char* aContentType) {
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
PRInt32 nsParser::WillBuildModel(const char* aFilename, const char* aContentType){
|
||||
PRInt32 nsParser::WillBuildModel(eProcessType aProcessType, const char* aFilename){
|
||||
|
||||
mMajorIteration=-1;
|
||||
mMinorIteration=-1;
|
||||
|
||||
mParseMode=DetermineParseMode();
|
||||
mDTD=(0==mDTD) ? CreateDTD(mParseMode,aContentType) : mDTD;
|
||||
if(mDTD) {
|
||||
mDTD->SetDTDDebug(mDTDDebug);
|
||||
if(PR_TRUE==FindSuitableDTD(aProcessType,mParseMode,mContentType,mDTD)) {
|
||||
mDTD->SetParser(this);
|
||||
mDTD->SetContentSink(mSink);
|
||||
mDTD->WillBuildModel(aFilename);
|
||||
@@ -406,16 +440,66 @@ PRBool nsParser::Parse(const char* aFilename){
|
||||
|
||||
//ok, time to create our tokenizer and begin the process
|
||||
mScanner=new CScanner(aFilename,mParseMode);
|
||||
char theContentType[600];
|
||||
DetermineContentType(theContentType);
|
||||
WillBuildModel(aFilename,theContentType);
|
||||
status=ResumeParse();
|
||||
DidBuildModel(status);
|
||||
|
||||
if(mScanner) {
|
||||
mScanner->Eof();
|
||||
if(eValidDetect==AutoDetectContentType(mScanner->GetBuffer())) {
|
||||
WillBuildModel(eParsing,aFilename);
|
||||
status=ResumeParse();
|
||||
DidBuildModel(status);
|
||||
}
|
||||
} //if
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
/**
|
||||
* This is the main controlling routine in the parsing process.
|
||||
* Note that it may get called multiple times for the same scanner,
|
||||
* since this is a pushed based system, and all the tokens may
|
||||
* not have been consumed by the scanner during a given invocation
|
||||
* of this method.
|
||||
*
|
||||
* NOTE: We don't call willbuildmodel here, because it will happen
|
||||
* as a result of calling OnStartBinding later on.
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param aFilename -- const char* containing file to be parsed.
|
||||
* @return PR_TRUE if parse succeeded, PR_FALSE otherwise.
|
||||
*/
|
||||
PRInt32 nsParser::Parse(nsIURL* aURL,nsIStreamObserver* aListener, nsIDTDDebug * aDTDDebug) {
|
||||
PRInt32 status;
|
||||
|
||||
status = BeginParse(aURL, aListener, aDTDDebug);
|
||||
if (NS_OK == status) {
|
||||
status=mURL->Open(this);
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Call this method if all you want to do is parse 1 string full of HTML text.
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
PRInt32 nsParser::Parse(nsString& aSourceBuffer,PRBool appendTokens){
|
||||
PRInt32 result=kNoError;
|
||||
|
||||
mScanner=new CScanner();
|
||||
mScanner->Append(aSourceBuffer);
|
||||
|
||||
if(eValidDetect==AutoDetectContentType(aSourceBuffer)) {
|
||||
WillBuildModel(eParsing,"from-string");
|
||||
result=ResumeParse();
|
||||
DidBuildModel(result);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* This is the main controlling routine in the parsing process.
|
||||
* Note that it may get called multiple times for the same scanner,
|
||||
@@ -454,46 +538,35 @@ PRInt32 nsParser::BeginParse(nsIURL* aURL,nsIStreamObserver* aListener, nsIDTDDe
|
||||
}
|
||||
|
||||
/**
|
||||
* This is the main controlling routine in the parsing process.
|
||||
* Note that it may get called multiple times for the same scanner,
|
||||
* since this is a pushed based system, and all the tokens may
|
||||
* not have been consumed by the scanner during a given invocation
|
||||
* of this method.
|
||||
*
|
||||
* NOTE: We don't call willbuildmodel here, because it will happen
|
||||
* as a result of calling OnStartBinding later on.
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param aFilename -- const char* containing file to be parsed.
|
||||
* @return PR_TRUE if parse succeeded, PR_FALSE otherwise.
|
||||
*
|
||||
* @update gess6/23/98
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
PRInt32 nsParser::Parse(nsIURL* aURL,nsIStreamObserver* aListener, nsIDTDDebug * aDTDDebug) {
|
||||
PRInt32 status;
|
||||
|
||||
status = BeginParse(aURL, aListener, aDTDDebug);
|
||||
if (NS_OK == status) {
|
||||
status=mURL->Open(this);
|
||||
}
|
||||
return status;
|
||||
PRInt32 nsParser::Convert(nsIURL* aURL,char* aSourceForm,char* aTargetForm,nsIStreamListener* aListener) {
|
||||
PRInt32 result=0;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Call this method if all you want to do is parse 1 string full of HTML text.
|
||||
*
|
||||
* @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
|
||||
*
|
||||
* @update gess6/23/98
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
PRInt32 nsParser::Parse(nsString& aSourceBuffer,PRBool appendTokens){
|
||||
PRInt32 result=kNoError;
|
||||
|
||||
WillBuildModel("nsString","text/html");
|
||||
mScanner->Append(aSourceBuffer);
|
||||
result=ResumeParse();
|
||||
DidBuildModel(result);
|
||||
|
||||
PRInt32 nsParser::Convert(const char* aFilename,char* aSourceForm,char* aTargetForm) {
|
||||
PRInt32 result=0;
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @update gess6/23/98
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
PRInt32 nsParser::Convert(nsString& anHTMLString,char* aSourceForm,char* aTargetForm,PRBool appendTokens){
|
||||
PRInt32 result=0;
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -520,6 +593,37 @@ PRInt32 nsParser::ResumeParse() {
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* This is where we loop over the tokens created in the
|
||||
* tokenization phase, and try to make sense out of them.
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param
|
||||
* @return PR_TRUE if parse succeeded, PR_FALSE otherwise.
|
||||
*/
|
||||
PRInt32 nsParser::IterateTokens() {
|
||||
nsDequeIterator e=mTokenDeque.End();
|
||||
nsDequeIterator theMarkPos(e);
|
||||
mMajorIteration++;
|
||||
|
||||
if(!mCurrentPos)
|
||||
mCurrentPos=new nsDequeIterator(mTokenDeque.Begin());
|
||||
|
||||
PRInt32 result=kNoError;
|
||||
while((kNoError==result) && ((*mCurrentPos<e))){
|
||||
mMinorIteration++;
|
||||
CToken* theToken=(CToken*)mCurrentPos->GetCurrent();
|
||||
|
||||
theMarkPos=*mCurrentPos;
|
||||
result=mDTD->HandleToken(theToken);
|
||||
++(*mCurrentPos);
|
||||
}
|
||||
|
||||
if(kInterrupted==result)
|
||||
*mCurrentPos=theMarkPos;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the attributes for this node, and add then into
|
||||
@@ -577,6 +681,10 @@ PRInt32 nsParser::CollectSkippedContent(nsCParserNode& aNode,PRInt32& aCount) {
|
||||
return result;
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
These methods are used to talk to the netlib system...
|
||||
*******************************************************************/
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
@@ -618,11 +726,11 @@ nsresult nsParser::OnStartBinding(const char *aContentType){
|
||||
if (nsnull != mObserver) {
|
||||
mObserver->OnStartBinding(aContentType);
|
||||
}
|
||||
nsresult result=WillBuildModel(mURL->GetSpec(),aContentType);
|
||||
if(!mTransferBuffer) {
|
||||
mTransferBuffer=new char[gTransferBufferSize+1];
|
||||
}
|
||||
return result;
|
||||
mAutoDetectStatus=eUnknownDetect;
|
||||
mDTD=0;
|
||||
|
||||
mContentType=aContentType;
|
||||
return kNoError;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -634,9 +742,21 @@ nsresult nsParser::OnStartBinding(const char *aContentType){
|
||||
* @return error code (usually 0)
|
||||
*/
|
||||
nsresult nsParser::OnDataAvailable(nsIInputStream *pIStream, PRInt32 length){
|
||||
/* if (nsnull != mListener) {
|
||||
//Rick potts removed this.
|
||||
//Does it need to be here?
|
||||
mListener->OnDataAvailable(pIStream, length);
|
||||
}
|
||||
*/
|
||||
int len=0;
|
||||
int offset=0;
|
||||
|
||||
if(eInvalidDetect==mAutoDetectStatus) {
|
||||
if(mScanner) {
|
||||
mScanner->GetBuffer().Truncate();
|
||||
}
|
||||
}
|
||||
|
||||
do {
|
||||
PRInt32 err;
|
||||
len = pIStream->Read(&err, mTransferBuffer, 0, gTransferBufferSize);
|
||||
@@ -650,9 +770,13 @@ nsresult nsParser::OnDataAvailable(nsIInputStream *pIStream, PRInt32 length){
|
||||
|
||||
if (mParserFilter)
|
||||
mParserFilter->RawBuffer(mTransferBuffer, &len);
|
||||
mScanner->Append(mTransferBuffer,len);
|
||||
|
||||
mScanner->Append(&mTransferBuffer[offset],len);
|
||||
|
||||
if(eUnknownDetect==mAutoDetectStatus) {
|
||||
if(eValidDetect==AutoDetectContentType(mScanner->GetBuffer())) {
|
||||
nsresult result=WillBuildModel(eParsing,mURL->GetSpec());
|
||||
} //if
|
||||
}
|
||||
} //if
|
||||
} while (len > 0);
|
||||
|
||||
|
||||
@@ -60,7 +60,6 @@
|
||||
#include "nsParserNode.h"
|
||||
#include "nsParserTypes.h"
|
||||
#include "nsIURL.h"
|
||||
#include "nsIStreamListener.h"
|
||||
|
||||
|
||||
#define NS_PARSER_IID \
|
||||
@@ -107,11 +106,9 @@ friend class CTokenHandler;
|
||||
virtual nsIContentSink* SetContentSink(nsIContentSink* aSink);
|
||||
|
||||
virtual nsIParserFilter* SetParserFilter(nsIParserFilter* aFilter);
|
||||
|
||||
virtual void RegisterDTD(nsIDTD* aDTD);
|
||||
|
||||
virtual void SetDTD(nsIDTD* aDTD);
|
||||
|
||||
virtual nsIDTD* GetDTD(void);
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
@@ -152,6 +149,15 @@ friend class CTokenHandler;
|
||||
*/
|
||||
virtual PRInt32 Parse(nsString& anHTMLString,PRBool appendTokens);
|
||||
|
||||
/******************************************************************************************
|
||||
* Convert methods start input source (of known or unknown form), and perform conversions
|
||||
* until you wind up with a <i>stream</i> in your target form.
|
||||
* The internal content model is never effected.
|
||||
******************************************************************************************/
|
||||
virtual PRInt32 Convert(nsIURL* aURL,char* aSourceForm, char* aTargetForm,nsIStreamListener* aListener);
|
||||
virtual PRInt32 Convert(const char* aFilename,char* aSourceForm,char* aTargetForm);
|
||||
virtual PRInt32 Convert(nsString& anHTMLString,char* aSourceForm,char* aTargetForm,PRBool appendTokens);
|
||||
|
||||
/**
|
||||
* This method gets called (automatically) during incremental parsing
|
||||
* @update gess5/11/98
|
||||
@@ -208,7 +214,7 @@ protected:
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
PRInt32 WillBuildModel(const char* aFilename=0,const char* aContentType=0);
|
||||
PRInt32 WillBuildModel(eProcessType theProcessType=eParsing,const char* aFilename=0);
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -303,7 +309,7 @@ private:
|
||||
* @param
|
||||
* @return TRUE if we figured it out.
|
||||
*/
|
||||
PRBool DetermineContentType(const char* aContentType);
|
||||
eAutoDetectResult AutoDetectContentType(nsString& aBuffer);
|
||||
|
||||
|
||||
protected:
|
||||
@@ -328,7 +334,9 @@ protected:
|
||||
nsDeque mTokenDeque;
|
||||
CScanner* mScanner;
|
||||
nsIURL* mURL;
|
||||
nsIDTDDebug* mDTDDebug;
|
||||
nsIDTDDebug* mDTDDebug;
|
||||
nsString mContentType;
|
||||
eAutoDetectResult mAutoDetectStatus;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
#include "nsParserNode.h"
|
||||
#include "string.h"
|
||||
|
||||
#include "nsHTMLTokens.h"
|
||||
|
||||
/**
|
||||
* Default constructor
|
||||
@@ -32,7 +32,7 @@ nsCParserNode::nsCParserNode(CToken* aToken): nsIParserNode(),
|
||||
mName(), mEmptyString() {
|
||||
NS_PRECONDITION(0!=aToken, "Null Token");
|
||||
mAttributeCount=0;
|
||||
mToken=(CHTMLToken*)aToken;
|
||||
mToken=aToken;
|
||||
memset(mAttributes,0,sizeof(mAttributes));
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ void nsCParserNode::AddAttribute(CToken* aToken) {
|
||||
NS_PRECONDITION(mAttributeCount<sizeof(mAttributes), "Buffer overrun!");
|
||||
NS_PRECONDITION(0!=aToken, "Error: Token shouldn't be null!");
|
||||
if(aToken) {
|
||||
mAttributes[mAttributeCount++]=(CHTMLToken*)aToken;
|
||||
mAttributes[mAttributeCount++]=aToken;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ void nsCParserNode::SetSkippedContent(CToken* aToken){
|
||||
NS_PRECONDITION(mAttributeCount<sizeof(mAttributes)-1, "Buffer overrun!");
|
||||
NS_PRECONDITION(0!=aToken, "Error: Token shouldn't be null!");
|
||||
if(aToken) {
|
||||
mAttributes[mAttributeCount++]=(CHTMLToken*)aToken;
|
||||
mAttributes[mAttributeCount++]=aToken;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
#define NS_PARSERNODE__
|
||||
|
||||
#include "nsIParserNode.h"
|
||||
#include "nsHTMLTokens.h"
|
||||
#include "nsToken.h"
|
||||
#include "nsString.h"
|
||||
|
||||
//class nsParser;
|
||||
@@ -148,11 +148,11 @@ class nsCParserNode : public nsIParserNode {
|
||||
|
||||
|
||||
protected:
|
||||
PRInt32 mAttributeCount;
|
||||
CHTMLToken* mToken;
|
||||
CHTMLToken* mAttributes[20]; // XXX Ack! This needs to be dynamic!
|
||||
nsString mName;
|
||||
nsString mEmptyString;
|
||||
PRInt32 mAttributeCount;
|
||||
CToken* mToken;
|
||||
CToken* mAttributes[20]; // XXX Ack! This needs to be dynamic!
|
||||
nsString mName;
|
||||
nsString mEmptyString;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -503,6 +503,15 @@ PRInt32 CScanner::ReadUntil(nsString& aString,PRUnichar aTerminalChar,PRBool add
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
nsString& CScanner::GetBuffer(void) {
|
||||
return mBuffer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Conduct self test. Actually, selftesting for this class
|
||||
|
||||
@@ -233,6 +233,15 @@ class CScanner {
|
||||
*/
|
||||
PRInt32 IncrementalAppend(const char* aBuffer,PRInt32 aSize);
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @update gess 5/12/98
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
nsString& GetBuffer(void);
|
||||
|
||||
static void SelfTest();
|
||||
|
||||
protected:
|
||||
|
||||
@@ -219,13 +219,15 @@ nsDequeIterator nsDeque::End(void) const{
|
||||
* @param aFunctor object to call for each member
|
||||
* @return *this
|
||||
*/
|
||||
const nsDeque& nsDeque::ForEach(nsDequeFunctor& aFunctor) const{
|
||||
const void* nsDeque::ForEach(nsDequeFunctor& aFunctor) const{
|
||||
int i=0;
|
||||
for(i=0;i<mSize;i++){
|
||||
void* obj=ObjectAt(i);
|
||||
aFunctor(obj);
|
||||
obj=aFunctor(obj);
|
||||
if(obj)
|
||||
return obj;
|
||||
}
|
||||
return *this;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/******************************************************
|
||||
@@ -379,9 +381,8 @@ void* nsDequeIterator::GetCurrent(void) {
|
||||
* @param aFunctor object to call for each member
|
||||
* @return *this
|
||||
*/
|
||||
const nsDequeIterator& nsDequeIterator::ForEach(nsDequeFunctor& aFunctor) const{
|
||||
mDeque.ForEach(aFunctor);
|
||||
return *this;
|
||||
const void* nsDequeIterator::ForEach(nsDequeFunctor& aFunctor) const{
|
||||
return mDeque.ForEach(aFunctor);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@
|
||||
*/
|
||||
class NS_BASE nsDequeFunctor{
|
||||
public:
|
||||
virtual void operator()(void* anObject)=0;
|
||||
virtual void* operator()(void* anObject)=0;
|
||||
};
|
||||
|
||||
|
||||
@@ -157,7 +157,7 @@ friend class nsDequeIterator;
|
||||
* @param aFunctor object to call for each member
|
||||
* @return *this
|
||||
*/
|
||||
const nsDeque& ForEach(nsDequeFunctor& aFunctor) const;
|
||||
const void* ForEach(nsDequeFunctor& aFunctor) const;
|
||||
|
||||
/**
|
||||
* Perform automated selftest on the deque
|
||||
@@ -346,7 +346,7 @@ public:
|
||||
* @param aFunctor object to call for each member
|
||||
* @return *this
|
||||
*/
|
||||
const nsDequeIterator& ForEach(nsDequeFunctor& aFunctor) const;
|
||||
const void* ForEach(nsDequeFunctor& aFunctor) const;
|
||||
|
||||
protected:
|
||||
PRInt32 mIndex;
|
||||
|
||||
Reference in New Issue
Block a user