зеркало из https://github.com/mozilla/gecko-dev.git
fixed 22340, 23749, 23931, 24419, 25522, 25630, 25845 and 25895; r=harishd
This commit is contained in:
Родитель
4d12935e0e
Коммит
4948a346f2
|
@ -4,7 +4,7 @@
|
|||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
|
@ -89,91 +89,6 @@ static char gShowCRC;
|
|||
|
||||
|
||||
|
||||
/***************************************************************
|
||||
This the ITagHandler deque deallocator, needed by the
|
||||
CTagHandlerRegister
|
||||
***************************************************************/
|
||||
class CTagHandlerDeallocator: public nsDequeFunctor{
|
||||
public:
|
||||
virtual void* operator()(void* aObject) {
|
||||
nsITagHandler* tagHandler = (nsITagHandler*)aObject;
|
||||
delete tagHandler;
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
/***************************************************************
|
||||
This funtor will be called for each item in the TagHandler que to
|
||||
check for a Tag name, and setting the current TagHandler when it is reached
|
||||
***************************************************************/
|
||||
class CTagFinder: public nsDequeFunctor{
|
||||
|
||||
public:
|
||||
CTagFinder(){}
|
||||
void Initialize(const nsString &aTagName) {mTagName = aTagName;}
|
||||
|
||||
virtual ~CTagFinder() {
|
||||
}
|
||||
|
||||
virtual void* operator()(void* aObject) {
|
||||
nsString* theString = ((nsITagHandler*)aObject)->GetString();
|
||||
if( theString->Equals(mTagName)){
|
||||
return aObject;
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
nsAutoString mTagName;
|
||||
};
|
||||
|
||||
/***************************************************************
|
||||
This a an object that will keep track of TagHandlers in
|
||||
the DTD. Uses a factory pattern
|
||||
***************************************************************/
|
||||
class CTagHandlerRegister {
|
||||
public:
|
||||
|
||||
CTagHandlerRegister();
|
||||
|
||||
~CTagHandlerRegister();
|
||||
|
||||
void RegisterTagHandler(nsITagHandler *aTagHandler){
|
||||
mTagHandlerDeque.Push(aTagHandler);
|
||||
}
|
||||
|
||||
nsITagHandler* FindTagHandler(const nsString &aTagName){
|
||||
nsITagHandler* foundHandler = nsnull;
|
||||
|
||||
mTagFinder.Initialize(aTagName);
|
||||
mTagHandlerDeque.Begin();
|
||||
foundHandler = (nsITagHandler*) mTagHandlerDeque.FirstThat(mTagFinder);
|
||||
return foundHandler;
|
||||
}
|
||||
|
||||
nsDeque mTagHandlerDeque;
|
||||
CTagFinder mTagFinder;
|
||||
};
|
||||
|
||||
MOZ_DECL_CTOR_COUNTER(CTagHandlerRegister);
|
||||
|
||||
CTagHandlerRegister::CTagHandlerRegister() : mTagHandlerDeque(new CTagHandlerDeallocator())
|
||||
{
|
||||
MOZ_COUNT_CTOR(CTagHandlerRegister);
|
||||
}
|
||||
|
||||
CTagHandlerRegister::~CTagHandlerRegister()
|
||||
{
|
||||
MOZ_COUNT_DTOR(CTagHandlerRegister);
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
The CTagHandlerRegister for a CNavDTD.
|
||||
This is where special taghanders for our tags can be managed and called from
|
||||
Note: This can also be attached to some object so it can be refcounted
|
||||
and destroyed if you want this to go away when not imbedded.
|
||||
************************************************************************/
|
||||
//CTagHandlerRegister gTagHandlerRegister;
|
||||
|
||||
|
||||
/************************************************************************
|
||||
And now for the main class -- CNavDTD...
|
||||
|
@ -242,6 +157,8 @@ CNavDTD::CNavDTD() : nsIDTD(), mMisplacedContent(0), mSkippedContent(0), mShared
|
|||
mExpectedCRC32=0;
|
||||
mDTDState=NS_OK;
|
||||
mStyleHandlingEnabled=PR_TRUE;
|
||||
mIsText=PR_FALSE;
|
||||
mRequestedHead=PR_FALSE;
|
||||
|
||||
if(!gHTMLElements) {
|
||||
InitializeElementTable();
|
||||
|
@ -452,11 +369,23 @@ PRBool CNavDTD::Verify(nsString& aURLRef,nsIParser* aParser){
|
|||
*/
|
||||
eAutoDetectResult CNavDTD::CanParse(nsString& aContentType, nsString& aCommand, nsString& aBuffer, PRInt32 aVersion) {
|
||||
eAutoDetectResult result=eUnknownDetect;
|
||||
|
||||
if(!aCommand.Equals(kViewSourceCommand)) {
|
||||
|
||||
|
||||
if(aCommand.Equals(kViewSourceCommand)) {
|
||||
if(PR_TRUE==aContentType.Equals(kPlainTextContentType)) {
|
||||
result=ePrimaryDetect;
|
||||
}
|
||||
else if(aContentType.Equals(kRTFTextContentType)){
|
||||
result=ePrimaryDetect;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(PR_TRUE==aContentType.Equals(kHTMLTextContentType)) {
|
||||
result=ePrimaryDetect;
|
||||
}
|
||||
if(PR_TRUE==aContentType.Equals(kPlainTextContentType)) {
|
||||
result=ePrimaryDetect;
|
||||
}
|
||||
else {
|
||||
//otherwise, look into the buffer to see if you recognize anything...
|
||||
PRBool theBufHasXML=PR_FALSE;
|
||||
|
@ -492,6 +421,7 @@ nsresult CNavDTD::WillBuildModel(nsString& aFilename,
|
|||
mHasOpenScript=PR_FALSE;
|
||||
mParseMode=aParseMode;
|
||||
mStyleHandlingEnabled=(eParseMode_quirks==mParseMode);
|
||||
mRequestedHead=PR_FALSE;
|
||||
|
||||
if((aNotifySink) && (aSink)) {
|
||||
|
||||
|
@ -501,6 +431,8 @@ nsresult CNavDTD::WillBuildModel(nsString& aFilename,
|
|||
mTokenRecycler=0;
|
||||
mStyleHandlingEnabled=PR_TRUE;
|
||||
|
||||
mIsText=aSourceType.Equals(kPlainTextContentType) || aSourceType.Equals(kRTFTextContentType);
|
||||
|
||||
if(aSink && (!mSink)) {
|
||||
result=aSink->QueryInterface(kIHTMLContentSinkIID, (void **)&mSink);
|
||||
}
|
||||
|
@ -516,6 +448,7 @@ nsresult CNavDTD::WillBuildModel(nsString& aFilename,
|
|||
mExpectedCRC32=0;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -542,12 +475,17 @@ nsresult CNavDTD::BuildModel(nsIParser* aParser,nsITokenizer* aTokenizer,nsIToke
|
|||
mTokenRecycler=(CTokenRecycler*)mTokenizer->GetTokenRecycler();
|
||||
if(mSink) {
|
||||
|
||||
|
||||
|
||||
if(!mBodyContext->GetCount()) {
|
||||
//if the content model is empty, then begin by opening <html>...
|
||||
CStartToken *theToken=(CStartToken*)mTokenRecycler->CreateTokenOfType(eToken_start,eHTMLTag_html,"html");
|
||||
HandleStartToken(theToken); //this token should get pushed on the context stack, don't recycle it.
|
||||
|
||||
if(mIsText) {
|
||||
//we do this little trick for text files, in both normal and viewsource mode...
|
||||
CStartToken *theToken=(CStartToken*)mTokenRecycler->CreateTokenOfType(eToken_start,eHTMLTag_pre);
|
||||
HandleStartToken(theToken);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
while(NS_SUCCEEDED(result)){
|
||||
|
@ -883,30 +821,6 @@ nsresult CNavDTD::HandleToken(CToken* aToken,nsIParser* aParser){
|
|||
}//if
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method causes all tokens to be dispatched to the given tag handler.
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param aHandler -- object to receive subsequent tokens...
|
||||
* @return error code (usually 0)
|
||||
*/
|
||||
nsresult CNavDTD::CaptureTokenPump(nsITagHandler* aHandler) {
|
||||
nsresult result=NS_OK;
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method releases the token-pump capture obtained in CaptureTokenPump()
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param aHandler -- object that received tokens...
|
||||
* @return error code (usually 0)
|
||||
*/
|
||||
nsresult CNavDTD::ReleaseTokenPump(nsITagHandler* aHandler){
|
||||
nsresult result=NS_OK;
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* This gets called after we've handled a given start tag.
|
||||
|
@ -940,9 +854,9 @@ nsresult CNavDTD::DidHandleStartTag(nsCParserNode& aNode,eHTMLTags aChildTag){
|
|||
{
|
||||
STOP_TIMER()
|
||||
MOZ_TIMER_DEBUGLOG(("Stop: Parse Time: CNavDTD::DidHandleStartTag(), this=%p\n", this));
|
||||
const nsString& theText=aNode.GetSkippedContent();
|
||||
if(0<theText.Length()) {
|
||||
CViewSourceHTML::WriteText(theText,*mSink,PR_TRUE,PR_FALSE);
|
||||
const nsString& theString=aNode.GetSkippedContent();
|
||||
if(0<theString.Length()) {
|
||||
CViewSourceHTML::WriteText(theString,*mSink,PR_TRUE,PR_FALSE);
|
||||
}
|
||||
MOZ_TIMER_DEBUGLOG(("Start: Parse Time: CNavDTD::DidHandleStartTag(), this=%p\n", this));
|
||||
START_TIMER()
|
||||
|
@ -1105,22 +1019,27 @@ nsresult CNavDTD::HandleDefaultStartToken(CToken* aToken,eHTMLTags aChildTag,nsI
|
|||
if(theChildAgrees && theChildIsContainer) {
|
||||
if ((theParentTag!=aChildTag) && (!nsHTMLElement::IsResidualStyleTag(aChildTag))) {
|
||||
|
||||
PRInt32 theChildIndex=GetIndexOfChildOrSynonym(*mBodyContext,aChildTag);
|
||||
if(gHTMLElements[theParentTag].IsBlockEntity()) {
|
||||
PRInt32 theChildIndex=GetIndexOfChildOrSynonym(*mBodyContext,aChildTag);
|
||||
|
||||
if((kNotFound<theChildIndex) && (theChildIndex<theIndex)) {
|
||||
if((kNotFound<theChildIndex) && (theChildIndex<theIndex)) {
|
||||
|
||||
/*-------------------------------------------------------------------------------------
|
||||
Here's a tricky case from bug 22596: <h5><li><h5>
|
||||
/*-------------------------------------------------------------------------------------
|
||||
1. Here's a tricky case from bug 22596: <h5><li><h5>
|
||||
|
||||
How do we know that the 2nd <h5> should close the <LI> rather than nest inside the <LI>?
|
||||
(Afterall, the <h5> is a legal child of the <LI>).
|
||||
How do we know that the 2nd <h5> should close the <LI> rather than nest inside the <LI>?
|
||||
(Afterall, the <h5> is a legal child of the <LI>).
|
||||
|
||||
The way you know is that there is no root between the two, so the <h5> binds more
|
||||
tightly to the 1st <h5> than to the <LI>.
|
||||
-------------------------------------------------------------------------------------*/
|
||||
The way you know is that there is no root between the two, so the <h5> binds more
|
||||
tightly to the 1st <h5> than to the <LI>.
|
||||
|
||||
theChildAgrees=CanBeContained(aChildTag,*mBodyContext);
|
||||
} //if
|
||||
2. Also, bug 6148 shows this case: <SPAN><DIV><SPAN>
|
||||
From this case we learned not to execute this logic if the parent is a block.
|
||||
-------------------------------------------------------------------------------------*/
|
||||
|
||||
theChildAgrees=CanBeContained(aChildTag,*mBodyContext);
|
||||
} //if
|
||||
}//if
|
||||
} //if
|
||||
} //if
|
||||
} //if parentcontains
|
||||
|
@ -1417,6 +1336,7 @@ nsresult CNavDTD::HandleStartToken(CToken* aToken) {
|
|||
if(mHadBody || mHadFrameset) {
|
||||
result=HandleOmittedTag(aToken,theChildTag,theParent,theNode);
|
||||
isTokenHandled=PR_TRUE;
|
||||
mRequestedHead=PR_TRUE;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
@ -1457,7 +1377,7 @@ nsresult CNavDTD::HandleStartToken(CToken* aToken) {
|
|||
break;
|
||||
|
||||
case eHTMLTag_script:
|
||||
theHeadIsParent=(!mHasOpenBody);
|
||||
theHeadIsParent=((!mHasOpenBody) || mRequestedHead);
|
||||
mHasOpenScript=PR_TRUE;
|
||||
|
||||
default:
|
||||
|
@ -1645,6 +1565,7 @@ nsresult CNavDTD::HandleEndToken(CToken* aToken) {
|
|||
|
||||
case eHTMLTag_head:
|
||||
StripWSFollowingTag(theChildTag,mTokenizer,mTokenRecycler,mLineNumber);
|
||||
mRequestedHead=PR_FALSE;
|
||||
//ok to fall through...
|
||||
|
||||
case eHTMLTag_form:
|
||||
|
@ -2068,7 +1989,10 @@ nsresult CNavDTD::CollectSkippedContent(nsCParserNode& aNode,PRInt32 &aCount) {
|
|||
// XXX rickg This linefeed conversion stuff should be moved out of
|
||||
// the parser and into the form element code
|
||||
PRBool aMustConvertLinebreaks = PR_FALSE;
|
||||
|
||||
|
||||
mScratch.Truncate();
|
||||
aNode.SetSkippedContent(mScratch);
|
||||
|
||||
for(aIndex=0;aIndex<aMax;aIndex++){
|
||||
CHTMLToken* theNextToken=(CHTMLToken*)mSkippedContent.PopFront();
|
||||
|
||||
|
@ -2079,16 +2003,18 @@ nsresult CNavDTD::CollectSkippedContent(nsCParserNode& aNode,PRInt32 &aCount) {
|
|||
// the start token as mTrailing content and will get appended in
|
||||
// start token's GetSource();
|
||||
if(eToken_attribute!=theTokenType) {
|
||||
if((eHTMLTag_textarea==theNodeTag) && (eToken_entity==theTokenType)) {
|
||||
((CEntityToken*)theNextToken)->TranslateToUnicodeStr(mScratch);
|
||||
// since this is an entity, we know that it's only one character.
|
||||
// check to see if it's a CR, in which case we'll need to do line
|
||||
// termination conversion at the end.
|
||||
aMustConvertLinebreaks |= (mScratch[0] == kCR);
|
||||
if (eToken_entity==theTokenType) {
|
||||
if((eHTMLTag_textarea==theNodeTag) || (eHTMLTag_title==theNodeTag)) {
|
||||
((CEntityToken*)theNextToken)->TranslateToUnicodeStr(mScratch);
|
||||
// since this is an entity, we know that it's only one character.
|
||||
// check to see if it's a CR, in which case we'll need to do line
|
||||
// termination conversion at the end.
|
||||
aMustConvertLinebreaks |= (mScratch[0] == kCR);
|
||||
}
|
||||
}
|
||||
else theNextToken->GetSource(mScratch);
|
||||
|
||||
aNode.mSkippedContent+=mScratch;
|
||||
aNode.mSkippedContent->Append(mScratch);
|
||||
}
|
||||
mTokenRecycler->RecycleToken(theNextToken);
|
||||
}
|
||||
|
@ -2106,13 +2032,13 @@ nsresult CNavDTD::CollectSkippedContent(nsCParserNode& aNode,PRInt32 &aCount) {
|
|||
aNode.mSkippedContent.ReplaceChar("\r", kNewLine);
|
||||
*/
|
||||
#if 1
|
||||
nsLinebreakConverter::ConvertStringLineBreaks(aNode.mSkippedContent,
|
||||
nsLinebreakConverter::ConvertStringLineBreaks(*aNode.mSkippedContent,
|
||||
nsLinebreakConverter::eLinebreakAny, nsLinebreakConverter::eLinebreakContent);
|
||||
#endif
|
||||
}
|
||||
|
||||
// Let's hope that this does not hamper the PERFORMANCE!!
|
||||
mLineNumber += aNode.mSkippedContent.CountChar(kNewLine);
|
||||
mLineNumber += aNode.mSkippedContent->CountChar(kNewLine);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -2879,8 +2805,19 @@ CNavDTD::OpenContainer(const nsIParserNode *aNode,eHTMLTags aTag,PRBool aClosedB
|
|||
PRBool isDefaultNode=PR_FALSE;
|
||||
|
||||
|
||||
if (nsHTMLElement::IsResidualStyleTag(aTag))
|
||||
if (nsHTMLElement::IsResidualStyleTag(aTag)) {
|
||||
/***********************************************************************
|
||||
* Here's an interesting problem:
|
||||
*
|
||||
* If there's an <a> on the RS-stack, and you're trying to open
|
||||
* another <a>, the one on the RS-stack should be discarded.
|
||||
*
|
||||
* I'm updating OpenTransientStyles to throw old <a>'s away.
|
||||
*
|
||||
***********************************************************************/
|
||||
|
||||
OpenTransientStyles(aTag);
|
||||
}
|
||||
|
||||
#ifdef ENABLE_CRC
|
||||
#define K_OPENOP 100
|
||||
|
@ -3362,16 +3299,16 @@ nsresult CNavDTD::AddHeadLeaf(nsIParserNode *aNode){
|
|||
if(NS_OK==result) {
|
||||
if(eHTMLTag_title==theTag) {
|
||||
|
||||
///XXX this evil hack is necessary only for beta.
|
||||
//Post beta, lets make the GetSkippedContent() call non-const.
|
||||
|
||||
const nsString& theString=aNode->GetSkippedContent();
|
||||
nsString* theStr=(nsString*)&theString;
|
||||
theStr->CompressWhitespace();
|
||||
PRInt32 theLen=theString.Length();
|
||||
CBufDescriptor theBD(theString.GetUnicode(), PR_TRUE, theLen+1, theLen);
|
||||
nsAutoString theString2(theBD);
|
||||
|
||||
theString2.CompressWhitespace();
|
||||
|
||||
STOP_TIMER()
|
||||
MOZ_TIMER_DEBUGLOG(("Stop: Parse Time: CNavDTD::AddHeadLeaf(), this=%p\n", this));
|
||||
mSink->SetTitle(theString);
|
||||
mSink->SetTitle(theString2);
|
||||
MOZ_TIMER_DEBUGLOG(("Start: Parse Time: CNavDTD::AddHeadLeaf(), this=%p\n", this));
|
||||
START_TIMER()
|
||||
|
||||
|
@ -3454,7 +3391,7 @@ nsresult CNavDTD::CreateContextStackFor(eHTMLTags aChildTag){
|
|||
nsresult CNavDTD::GetTokenizer(nsITokenizer*& aTokenizer) {
|
||||
nsresult result=NS_OK;
|
||||
if(!mTokenizer) {
|
||||
result=NS_NewHTMLTokenizer(&mTokenizer,mParseMode,PR_FALSE);
|
||||
result=NS_NewHTMLTokenizer(&mTokenizer,mParseMode,mIsText);
|
||||
}
|
||||
aTokenizer=mTokenizer;
|
||||
return result;
|
||||
|
|
|
@ -90,6 +90,7 @@
|
|||
#include "nsVoidArray.h"
|
||||
#include "nsDeque.h"
|
||||
#include "nsParserCIID.h"
|
||||
#include "nsTime.h"
|
||||
|
||||
#define NS_INAVHTML_DTD_IID \
|
||||
{0x5c5cce40, 0xcfd6, 0x11d1, \
|
||||
|
@ -220,24 +221,6 @@ CLASS_EXPORT_HTMLPARS CNavDTD : public nsIDTD {
|
|||
*/
|
||||
NS_IMETHOD HandleToken(CToken* aToken,nsIParser* aParser);
|
||||
|
||||
/**
|
||||
* This method causes all tokens to be dispatched to the given tag handler.
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param aHandler -- object to receive subsequent tokens...
|
||||
* @return error code (usually 0)
|
||||
*/
|
||||
NS_IMETHOD CaptureTokenPump(nsITagHandler* aHandler);
|
||||
|
||||
/**
|
||||
* This method releases the token-pump capture obtained in CaptureTokenPump()
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param aHandler -- object that received tokens...
|
||||
* @return error code (usually 0)
|
||||
*/
|
||||
NS_IMETHOD ReleaseTokenPump(nsITagHandler* aHandler);
|
||||
|
||||
/**
|
||||
*
|
||||
* @update gess12/28/98
|
||||
|
@ -541,6 +524,8 @@ protected:
|
|||
PRUint32 mExpectedCRC32;
|
||||
nsAutoString mScratch; //used for various purposes; non-persistent
|
||||
PRBool mStyleHandlingEnabled;
|
||||
PRBool mIsText;
|
||||
PRBool mRequestedHead;
|
||||
|
||||
#ifdef NS_DEBUG
|
||||
PRInt32 gNodeCount;
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -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
|
||||
|
@ -22,47 +23,119 @@
|
|||
|
||||
/**
|
||||
* MODULE NOTES:
|
||||
* @update gess 4/8/98
|
||||
* @update gess 7/15/98
|
||||
*
|
||||
* NavDTD is an implementation of the nsIDTD interface.
|
||||
* In particular, this class captures the behaviors of the original
|
||||
* Navigator parser productions.
|
||||
*
|
||||
* This DTD, like any other in NGLayout, provides a few basic services:
|
||||
* - First, the DTD collaborates with the Parser class to convert plain
|
||||
* text into a sequence of HTMLTokens.
|
||||
* - Second, the DTD describes containment rules for known elements.
|
||||
* - Third the DTD controls and coordinates the interaction between the
|
||||
* parsing system and content sink. (The content sink is the interface
|
||||
* that serves as a proxy for content model).
|
||||
* - Fourth the DTD maintains an internal style-stack to handle residual (leaky)
|
||||
* style tags.
|
||||
*
|
||||
* You're most likely working in this class file because
|
||||
* you want to add or change a behavior inherent in this DTD. The remainder
|
||||
* of this section will describe what you need to do to affect the kind of
|
||||
* change you want in this DTD.
|
||||
*
|
||||
* RESIDUAL-STYLE HANDLNG:
|
||||
* There are a number of ways to represent style in an HTML document.
|
||||
* 1) explicit style tags (<B>, <I> etc)
|
||||
* 2) implicit styles (like those implicit in <Hn>)
|
||||
* 3) CSS based styles
|
||||
*
|
||||
* Residual style handling results from explicit style tags that are
|
||||
* not closed. Consider this example: <p>text <b>bold </p>
|
||||
* When the <p> tag closes, the <b> tag is NOT automatically closed.
|
||||
* Unclosed style tags are handled by the process we call residual-style
|
||||
* tag handling.
|
||||
*
|
||||
* There are two aspects to residual style tag handling. The first is the
|
||||
* construction and managing of a stack of residual style tags. The
|
||||
* second is the automatic emission of residual style tags onto leaf content
|
||||
* in subsequent portions of the document.This step is necessary to propagate
|
||||
* the expected style behavior to subsequent portions of the document.
|
||||
*
|
||||
* Construction and managing the residual style stack is an inline process that
|
||||
* occurs during the model building phase of the parse process. During the model-
|
||||
* building phase of the parse process, a content stack is maintained which tracks
|
||||
* the open container hierarchy. If a style tag(s) fails to be closed when a normal
|
||||
* container is closed, that style tag is placed onto the residual style stack. If
|
||||
* that style tag is subsequently closed (in most contexts), it is popped off the
|
||||
* residual style stack -- and are of no further concern.
|
||||
*
|
||||
* Residual style tag emission occurs when the style stack is not empty, and leaf
|
||||
* content occurs. In our earlier example, the <b> tag "leaked" out of the <p>
|
||||
* container. Just before the next leaf is emitted (in this or another container) the
|
||||
* style tags that are on the stack are emitted in succession. These same residual
|
||||
* style tags get closed automatically when the leaf's container closes, or if a
|
||||
* child container is opened.
|
||||
*
|
||||
*
|
||||
*/
|
||||
#ifndef NS_NAVHTMLDTD__
|
||||
#define NS_NAVHTMLDTD__
|
||||
|
||||
#ifndef NS_OTHERHTMLDTD__
|
||||
#define NS_OTHERHTMLDTD__
|
||||
|
||||
#include "CNavDTD.h"
|
||||
#include "nsIDTD.h"
|
||||
#include "nsISupports.h"
|
||||
#include "nsIParser.h"
|
||||
#include "nsHTMLTokens.h"
|
||||
#include "nshtmlpars.h"
|
||||
#include "nsVoidArray.h"
|
||||
#include "nsDeque.h"
|
||||
#include "nsParserCIID.h"
|
||||
|
||||
|
||||
#define NS_IOtherHTML_DTD_IID \
|
||||
#define NS_IOTHERHTML_DTD_IID \
|
||||
{0x8a5e89c0, 0xd16d, 0x11d1, \
|
||||
{0x80, 0x22, 0x00, 0x60, 0x8, 0x14, 0x98, 0x89}}
|
||||
|
||||
class nsIHTMLContentSink;
|
||||
class nsIDTDDebug;
|
||||
class nsIParserNode;
|
||||
class nsParser;
|
||||
class nsDTDContext;
|
||||
class nsEntryStack;
|
||||
class nsITokenizer;
|
||||
class nsCParserNode;
|
||||
class CTokenRecycler;
|
||||
|
||||
//class nsParser;
|
||||
//class nsIHTMLContentSink;
|
||||
/***************************************************************
|
||||
Now the main event: COtherDTD.
|
||||
|
||||
This not so simple class performs all the duties of token
|
||||
construction and model building. It works in conjunction with
|
||||
an nsParser.
|
||||
***************************************************************/
|
||||
|
||||
#if defined(XP_PC)
|
||||
#pragma warning( disable : 4275 )
|
||||
#endif
|
||||
|
||||
CLASS_EXPORT_HTMLPARS COtherDTD : public nsIDTD {
|
||||
|
||||
#if defined(XP_PC)
|
||||
#pragma warning( default : 4275 )
|
||||
#endif
|
||||
|
||||
class COtherDTD : public CNavDTD {
|
||||
|
||||
public:
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @update gess 4/9/98
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
* Common constructor for navdtd. You probably want to call
|
||||
* NS_NewNavHTMLDTD().
|
||||
*
|
||||
* @update gess 7/9/98
|
||||
*/
|
||||
COtherDTD();
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @update gess 4/9/98
|
||||
* @param
|
||||
* @return
|
||||
* Virtual destructor -- you know what to do
|
||||
* @update gess 7/9/98
|
||||
*/
|
||||
virtual ~COtherDTD();
|
||||
|
||||
|
@ -76,31 +149,106 @@ class COtherDTD : public CNavDTD {
|
|||
*/
|
||||
virtual nsresult CreateNewInstance(nsIDTD** aInstancePtrResult);
|
||||
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
/**
|
||||
* This method is called to determine if the given DTD can parse
|
||||
* a document in a given source-type.
|
||||
* NOTE: Parsing always assumes that the end result will involve
|
||||
* storing the result in the main content model.
|
||||
* @update gess6/24/98
|
||||
* @param
|
||||
* @return TRUE if this DTD can satisfy the request; FALSE otherwise.
|
||||
* a document of a given source-type.
|
||||
* Note that parsing assumes that the end result will always be stored
|
||||
* in the main content model. Of course, it's up to you which content-
|
||||
* model you pass in to the parser, so you can always control the process.
|
||||
*
|
||||
* @update gess 7/15/98
|
||||
* @param aContentType contains the name of a filetype that you are
|
||||
* being asked to parse).
|
||||
* @return TRUE if this DTD parse the given type; FALSE otherwise.
|
||||
*/
|
||||
virtual eAutoDetectResult CanParse(nsString& aContentType, nsString& aCommand, nsString& aBuffer, PRInt32 aVersion);
|
||||
|
||||
|
||||
/**
|
||||
* Called by the parser to initiate dtd verification of the
|
||||
* internal context stack.
|
||||
* @update gess 7/23/98
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
virtual PRBool Verify(nsString& aURLRef,nsIParser* aParser);
|
||||
|
||||
|
||||
/**
|
||||
* The parser uses a code sandwich to wrap the parsing process. Before
|
||||
* the process begins, WillBuildModel() is called. Afterwards the parser
|
||||
* calls DidBuildModel().
|
||||
* @update gess5/18/98
|
||||
* @param aFilename is the name of the file being parsed.
|
||||
* @return error code (almost always 0)
|
||||
*/
|
||||
NS_IMETHOD WillBuildModel( nsString& aFilename,
|
||||
PRBool aNotifySink,
|
||||
nsString& aSourceType,
|
||||
eParseMode aParseMode,
|
||||
nsString& aCommand,
|
||||
nsIContentSink* aSink=0);
|
||||
|
||||
/**
|
||||
* The parser uses a code sandwich to wrap the parsing process. Before
|
||||
* the process begins, WillBuildModel() is called. Afterwards the parser
|
||||
* calls DidBuildModel().
|
||||
* @update gess5/18/98
|
||||
* @param aFilename is the name of the file being parsed.
|
||||
* @return error code (almost always 0)
|
||||
*/
|
||||
NS_IMETHOD BuildModel(nsIParser* aParser,nsITokenizer* aTokenizer,nsITokenObserver* anObserver=0,nsIContentSink* aSink=0);
|
||||
|
||||
/**
|
||||
* The parser uses a code sandwich to wrap the parsing process. Before
|
||||
* the process begins, WillBuildModel() is called. Afterwards the parser
|
||||
* calls DidBuildModel().
|
||||
* @update gess5/18/98
|
||||
* @param anErrorCode contans the last error that occured
|
||||
* @return error code
|
||||
*/
|
||||
NS_IMETHOD DidBuildModel(nsresult anErrorCode,PRBool aNotifySink,nsIParser* aParser,nsIContentSink* aSink=0);
|
||||
|
||||
/**
|
||||
* This method is called by the parser, once for each token
|
||||
* that has been constructed during the tokenization phase.
|
||||
* @update gess 3/25/98
|
||||
* @param aToken -- token object to be put into content model
|
||||
* @return 0 if all is well; non-zero is an error
|
||||
*/
|
||||
NS_IMETHOD HandleToken(CToken* aToken,nsIParser* aParser);
|
||||
|
||||
/**
|
||||
*
|
||||
* @update gess5/18/98
|
||||
* @update gess12/28/98
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
NS_IMETHOD GetTokenizer(nsITokenizer*& aTokenizer);
|
||||
|
||||
/**
|
||||
*
|
||||
* @update gess12/28/98
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
virtual nsITokenRecycler* GetTokenRecycler(void);
|
||||
|
||||
/**
|
||||
* If the parse process gets interrupted, this method gets called
|
||||
* prior to the process resuming.
|
||||
* @update gess5/18/98
|
||||
* @return error code -- usually NS_OK (0)
|
||||
*/
|
||||
NS_IMETHOD WillResumeParse(void);
|
||||
|
||||
/**
|
||||
*
|
||||
* If the parse process is about to be interrupted, this method
|
||||
* will be called just prior.
|
||||
* @update gess5/18/98
|
||||
* @param
|
||||
* @return
|
||||
* @return error code -- usually NS_OK (0)
|
||||
*/
|
||||
NS_IMETHOD WillInterruptParse(void);
|
||||
|
||||
|
@ -115,103 +263,151 @@ class COtherDTD : public CNavDTD {
|
|||
*/
|
||||
virtual PRBool CanContain(PRInt32 aParent,PRInt32 aChild) const;
|
||||
|
||||
/**
|
||||
* This method is called to determine whether or not a tag
|
||||
* of one type can contain a tag of another type.
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param aParent -- int tag of parent container
|
||||
* @param aChild -- int tag of child container
|
||||
* @return PR_TRUE if parent can contain child
|
||||
*/
|
||||
virtual PRBool CanPropagate(eHTMLTags aParent,eHTMLTags aChild,PRBool aParentContains) ;
|
||||
|
||||
/**
|
||||
* This method gets called to determine whether a given
|
||||
* tag can contain newlines. Most do not.
|
||||
* child tag can be omitted by the given parent.
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param aParent -- parent tag being asked about omitting given child
|
||||
* @param aChild -- child tag being tested for omittability by parent
|
||||
* @param aParentContains -- can be 0,1,-1 (false,true, unknown)
|
||||
* @return PR_TRUE if given tag can be omitted
|
||||
*/
|
||||
virtual PRBool CanOmit(eHTMLTags aParent,eHTMLTags aChild,PRBool& aParentContains) ;
|
||||
|
||||
/**
|
||||
* This method gets called to determine whether a given
|
||||
* tag is itself a container
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param aTag -- tag to test for containership
|
||||
* @return PR_TRUE if given tag can contain other tags
|
||||
*/
|
||||
virtual PRBool CanOmit(eHTMLTags aParent,eHTMLTags aChild,PRBool& aParentContains) ;
|
||||
virtual PRBool IsContainer(PRInt32 aTag) const;
|
||||
|
||||
/**
|
||||
* This method tries to design a context map (without actually
|
||||
* changing our parser state) from the parent down to the
|
||||
* child.
|
||||
*
|
||||
* @update gess4/6/98
|
||||
* @param aParent -- tag type of parent
|
||||
* @param aChild -- tag type of child
|
||||
* @return True if closure was achieved -- other false
|
||||
*/
|
||||
virtual PRBool ForwardPropagate(nsString& aSequence,eHTMLTags aParentTag,eHTMLTags aChildTag);
|
||||
|
||||
/**
|
||||
* This method tries to design a context map (without actually
|
||||
* changing our parser state) from the child up to the parent.
|
||||
*
|
||||
* @update gess4/6/98
|
||||
* @param aParent -- tag type of parent
|
||||
* @param aChild -- tag type of child
|
||||
* @return True if closure was achieved -- other false
|
||||
*/
|
||||
virtual PRBool BackwardPropagate(nsString& aSequence,eHTMLTags aParentTag,eHTMLTags aChildTag) const;
|
||||
|
||||
/**
|
||||
* Attempt forward and/or backward propagation for the given
|
||||
* child within the current context vector stack.
|
||||
* @update gess5/11/98
|
||||
* @param type of child to be propagated.
|
||||
* @return TRUE if succeeds, otherwise FALSE
|
||||
*/
|
||||
nsresult CreateContextStackFor(eHTMLTags aChildTag);
|
||||
|
||||
/**
|
||||
* Ask parser if a given container is open ANYWHERE on stack
|
||||
* @update gess5/11/98
|
||||
* @param id of container you want to test for
|
||||
* @return TRUE if the given container type is open -- otherwise FALSE
|
||||
*/
|
||||
virtual PRBool HasOpenContainer(eHTMLTags aContainer) const;
|
||||
|
||||
/**
|
||||
* Ask parser if a given container is open ANYWHERE on stack
|
||||
* @update gess5/11/98
|
||||
* @param id of container you want to test for
|
||||
* @return TRUE if the given container type is open -- otherwise FALSE
|
||||
*/
|
||||
virtual PRBool HasOpenContainer(const eHTMLTags aTagSet[],PRInt32 aCount) const;
|
||||
|
||||
/**
|
||||
* Accessor that retrieves the tag type of the topmost item on context
|
||||
* vector stack.
|
||||
*
|
||||
* @update gess5/11/98
|
||||
* @return tag type (may be unknown)
|
||||
*/
|
||||
virtual eHTMLTags GetTopNode() const;
|
||||
|
||||
/**
|
||||
* Finds the topmost occurance of given tag within context vector stack.
|
||||
* @update gess5/11/98
|
||||
* @param tag to be found
|
||||
* @return index of topmost tag occurance -- may be -1 (kNotFound).
|
||||
*/
|
||||
// virtual PRInt32 GetTopmostIndexOf(eHTMLTags aTag) const;
|
||||
|
||||
/**
|
||||
* Finds the topmost occurance of given tag within context vector stack.
|
||||
* @update gess5/11/98
|
||||
* @param tag to be found
|
||||
* @return index of topmost tag occurance -- may be -1 (kNotFound).
|
||||
*/
|
||||
virtual PRInt32 LastOf(eHTMLTags aTagSet[],PRInt32 aCount) const;
|
||||
|
||||
/**
|
||||
* Use this id you want to stop the building content model
|
||||
* --------------[ Sets DTD to STOP mode ]----------------
|
||||
* It's recommended to use this method in accordance with
|
||||
* the parser's terminate() method.
|
||||
*
|
||||
* @update harishd 07/22/99
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
virtual nsresult Terminate(void) { return mDTDState=NS_ERROR_HTMLPARSER_STOPPARSING; }
|
||||
|
||||
/**
|
||||
* Give rest of world access to our tag enums, so that CanContain(), etc,
|
||||
* become useful.
|
||||
*/
|
||||
NS_IMETHOD StringTagToIntTag(nsString &aTag, PRInt32* aIntTag)const;
|
||||
NS_IMETHOD StringTagToIntTag(nsString &aTag, PRInt32* aIntTag) const;
|
||||
|
||||
NS_IMETHOD IntTagToStringTag(PRInt32 aIntTag, nsString& aTag) const;
|
||||
|
||||
NS_IMETHOD ConvertEntityToUnicode(const nsString& aEntity, PRInt32* aUnicode) const;
|
||||
|
||||
/**
|
||||
* This method gets called when a start token has been consumed and needs
|
||||
* to be handled (possibly added to content model via sink).
|
||||
* The following set of methods are used to partially construct
|
||||
* the content model (via the sink) according to the type of token.
|
||||
* @update gess5/11/98
|
||||
* @param aToken is the start token to be handled
|
||||
* @return TRUE if the token was handled.
|
||||
* @param aToken is the token (of a given type) to be handled
|
||||
* @return error code representing construction state; usually 0.
|
||||
*/
|
||||
nsresult HandleStartToken(CToken* aToken);
|
||||
|
||||
/**
|
||||
* This method gets called when a start token has been consumed, and
|
||||
* we want to use default start token handling behavior.
|
||||
* This method gets called automatically by handleStartToken.
|
||||
*
|
||||
* @update gess5/11/98
|
||||
* @param aToken is the start token to be handled
|
||||
* @param aChildTag is the tag-type of given token
|
||||
* @param aNode is a node be updated with info from given token
|
||||
* @return TRUE if the token was handled.
|
||||
*/
|
||||
nsresult HandleDefaultStartToken(CToken* aToken,eHTMLTags aChildTag,nsIParserNode *aNode);
|
||||
|
||||
/**
|
||||
* This method gets called when an end token has been consumed and needs
|
||||
* to be handled (possibly added to content model via sink).
|
||||
* @update gess5/11/98
|
||||
* @param aToken is the end token to be handled
|
||||
* @return TRUE if the token was handled.
|
||||
*/
|
||||
nsresult HandleEndToken(CToken* aToken);
|
||||
|
||||
/**
|
||||
* This method gets called when an entity token has been consumed and needs
|
||||
* to be handled (possibly added to content model via sink).
|
||||
* @update gess5/11/98
|
||||
* @param aToken is the entity token to be handled
|
||||
* @return TRUE if the token was handled.
|
||||
*/
|
||||
nsresult HandleEntityToken(CToken* aToken);
|
||||
|
||||
/**
|
||||
* This method gets called when a comment token has been consumed and needs
|
||||
* to be handled (possibly added to content model via sink).
|
||||
* @update gess5/11/98
|
||||
* @param aToken is the comment token to be handled
|
||||
* @return TRUE if the token was handled.
|
||||
*/
|
||||
nsresult HandleCommentToken(CToken* aToken);
|
||||
|
||||
/**
|
||||
* This method gets called when an attribute token has been consumed and needs
|
||||
* to be handled (possibly added to content model via sink).
|
||||
* @update gess5/11/98
|
||||
* @param aToken is the attribute token to be handled
|
||||
* @return TRUE if the token was handled.
|
||||
*/
|
||||
nsresult HandleAttributeToken(CToken* aToken);
|
||||
|
||||
/**
|
||||
* This method gets called when a script token has been consumed and needs
|
||||
* to be handled (possibly added to content model via sink).
|
||||
* @update gess5/11/98
|
||||
* @param aToken is the script token to be handled
|
||||
* @return TRUE if the token was handled.
|
||||
*/
|
||||
nsresult HandleScriptToken(const nsIParserNode *aNode);
|
||||
|
||||
/**
|
||||
* This method gets called when a style token has been consumed and needs
|
||||
* to be handled (possibly added to content model via sink).
|
||||
* @update gess5/11/98
|
||||
* @param aToken is the style token to be handled
|
||||
* @return TRUE if the token was handled.
|
||||
*/
|
||||
nsresult HandleStyleToken(CToken* aToken);
|
||||
|
||||
private:
|
||||
nsresult HandleStartToken(CToken* aToken);
|
||||
nsresult HandleDefaultStartToken(CToken* aToken,eHTMLTags aChildTag,nsIParserNode *aNode);
|
||||
nsresult HandleEndToken(CToken* aToken);
|
||||
nsresult HandleEntityToken(CToken* aToken);
|
||||
nsresult HandleCommentToken(CToken* aToken);
|
||||
nsresult HandleAttributeToken(CToken* aToken);
|
||||
nsresult HandleScriptToken(const nsIParserNode *aNode);
|
||||
nsresult HandleStyleToken(CToken* aToken);
|
||||
nsresult HandleProcessingInstructionToken(CToken* aToken);
|
||||
nsresult HandleDocTypeDeclToken(CToken* aToken);
|
||||
|
||||
|
||||
//*************************************************
|
||||
|
@ -233,7 +429,7 @@ private:
|
|||
nsresult OpenForm(const nsIParserNode *aNode);
|
||||
nsresult OpenMap(const nsIParserNode *aNode);
|
||||
nsresult OpenFrameset(const nsIParserNode *aNode);
|
||||
nsresult OpenContainer(const nsIParserNode *aNode,eHTMLTags aTag,PRBool aUpdateStyleStack,nsEntryStack* aStyleStack=0);
|
||||
nsresult OpenContainer(const nsIParserNode *aNode,eHTMLTags aTag,PRBool aClosedByStartTag,nsEntryStack* aStyleStack=0);
|
||||
|
||||
/**
|
||||
* The next set of methods close the given HTML element.
|
||||
|
@ -248,40 +444,97 @@ private:
|
|||
nsresult CloseForm(const nsIParserNode *aNode);
|
||||
nsresult CloseMap(const nsIParserNode *aNode);
|
||||
nsresult CloseFrameset(const nsIParserNode *aNode);
|
||||
|
||||
nsresult CloseContainer(const nsIParserNode *aNode,eHTMLTags aTarget,PRBool aUpdateStyles);
|
||||
nsresult CloseContainersTo(eHTMLTags aTag,PRBool aUpdateStyles);
|
||||
nsresult CloseContainersTo(PRInt32 anIndex,eHTMLTags aTarget,PRBool aUpdateStyles);
|
||||
|
||||
/**
|
||||
* The special purpose methods automatically close
|
||||
* one or more open containers.
|
||||
* @update gess5/11/98
|
||||
* @return error code - 0 if all went well.
|
||||
*/
|
||||
nsresult CloseContainer(const nsIParserNode *aNode,eHTMLTags aTarget,PRBool aClosedByStartTag);
|
||||
nsresult CloseContainersTo(eHTMLTags aTag,PRBool aClosedByStartTag);
|
||||
nsresult CloseContainersTo(PRInt32 anIndex,eHTMLTags aTag,PRBool aClosedByStartTag);
|
||||
|
||||
/**
|
||||
* Causes leaf to be added to sink at current vector pos.
|
||||
* @update gess5/11/98
|
||||
* @param aNode is leaf node to be added.
|
||||
* @return TRUE if all went well -- FALSE otherwise.
|
||||
* @return error code - 0 if all went well.
|
||||
*/
|
||||
nsresult AddLeaf(const nsIParserNode *aNode);
|
||||
|
||||
nsresult AddHeadLeaf(nsIParserNode *aNode);
|
||||
|
||||
/**
|
||||
* Attempt forward and/or backward propagation for the given
|
||||
* child within the current context vector stack.
|
||||
* This set of methods is used to create and manage the set of
|
||||
* transient styles that occur as a result of poorly formed HTML
|
||||
* or bugs in the original navigator.
|
||||
*
|
||||
* @update gess5/11/98
|
||||
* @param type of child to be propagated.
|
||||
* @return TRUE if succeeds, otherwise FALSE
|
||||
* @param aTag -- represents the transient style tag to be handled.
|
||||
* @return error code -- usually 0
|
||||
*/
|
||||
nsresult CreateContextStackFor(eHTMLTags aChildTag);
|
||||
nsresult OpenTransientStyles(eHTMLTags aChildTag);
|
||||
nsresult CloseTransientStyles(eHTMLTags aChildTag);
|
||||
nsresult PopStyle(eHTMLTags aTag);
|
||||
|
||||
nsresult OpenTransientStyles(eHTMLTags aTag);
|
||||
nsresult CloseTransientStyles(eHTMLTags aTag);
|
||||
nsresult PopStyle(eHTMLTags aTag);
|
||||
|
||||
nsresult DoFragment(PRBool aFlag);
|
||||
nsresult DoFragment(PRBool aFlag);
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
nsresult CollectAttributes(nsCParserNode& aNode,eHTMLTags aTag,PRInt32 aCount);
|
||||
nsresult CollectSkippedContent(nsCParserNode& aNode,PRInt32& aCount);
|
||||
nsresult WillHandleStartTag(CToken* aToken,eHTMLTags aChildTag,nsCParserNode& aNode);
|
||||
nsresult DidHandleStartTag(nsCParserNode& aNode,eHTMLTags aChildTag);
|
||||
nsresult HandleOmittedTag(CToken* aToken,eHTMLTags aChildTag,eHTMLTags aParent,nsIParserNode *aNode);
|
||||
nsresult HandleSavedTokens(PRInt32 anIndex);
|
||||
nsCParserNode* CreateNode(void);
|
||||
void RecycleNode(nsCParserNode* aNode);
|
||||
void RecycleNodes(nsEntryStack *aNodeStack);
|
||||
|
||||
nsIHTMLContentSink* mSink;
|
||||
|
||||
nsDTDContext* mHeadContext;
|
||||
nsDTDContext* mBodyContext;
|
||||
nsDTDContext* mFormContext;
|
||||
nsDTDContext* mMapContext;
|
||||
nsDTDContext* mTempContext;
|
||||
PRBool mHasOpenForm;
|
||||
PRBool mHasOpenMap;
|
||||
PRInt32 mHasOpenHead;
|
||||
PRBool mHasOpenBody;
|
||||
PRBool mHadFrameset;
|
||||
PRBool mHadBody;
|
||||
nsString mFilename;
|
||||
nsIDTDDebug* mDTDDebug;
|
||||
PRInt32 mLineNumber;
|
||||
nsParser* mParser;
|
||||
nsITokenizer* mTokenizer;
|
||||
CTokenRecycler* mTokenRecycler;
|
||||
nsDeque mMisplacedContent;
|
||||
nsDeque mSkippedContent;
|
||||
PRBool mHasOpenScript;
|
||||
PRBool mSaveBadTokens;
|
||||
eHTMLTags mSkipTarget;
|
||||
nsDeque mSharedNodes;
|
||||
nsresult mDTDState;
|
||||
eParseMode mParseMode;
|
||||
|
||||
PRUint32 mComputedCRC32;
|
||||
PRUint32 mExpectedCRC32;
|
||||
nsAutoString mScratch; //used for various purposes; non-persistent
|
||||
PRBool mStyleHandlingEnabled;
|
||||
PRBool mIsText;
|
||||
|
||||
#ifdef NS_DEBUG
|
||||
PRInt32 gNodeCount;
|
||||
#endif
|
||||
|
||||
};
|
||||
|
||||
extern NS_HTMLPARS nsresult NS_NewOtherHTMLDTD(nsIDTD** aInstancePtrResult);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -37,6 +37,7 @@
|
|||
#include "nshtmlpars.h"
|
||||
#include "nsVoidArray.h"
|
||||
#include "nsDeque.h"
|
||||
#include "nsToken.h"
|
||||
|
||||
#define NS_RTF_DTD_IID \
|
||||
{0xa39c6bfc, 0x15f0, 0x11d2, \
|
||||
|
@ -45,6 +46,7 @@
|
|||
class nsIParserNode;
|
||||
class nsParser;
|
||||
class nsITokenizer;
|
||||
class nsIHTMLContentSink;
|
||||
|
||||
enum eRTFTokenTypes {
|
||||
eRTFToken_unknown=0,
|
||||
|
@ -63,6 +65,8 @@ enum eRTFTags {
|
|||
eRTFCtrl_linefeed,
|
||||
eRTFCtrl_return,
|
||||
eRTFCtrl_begincontrol,
|
||||
eRTFCtrl_text,
|
||||
eRTFCtrl_ansi,
|
||||
eRTFCtrl_bold,
|
||||
eRTFCtrl_bin,
|
||||
eRTFCtrl_blue,
|
||||
|
@ -89,58 +93,43 @@ enum eRTFTags {
|
|||
eRTFCtrl_tab,
|
||||
eRTFCtrl_title,
|
||||
eRTFCtrl_underline,
|
||||
eRTFCtrl_startgroup,
|
||||
eRTFCtrl_endgroup,
|
||||
eRTFCtrl_startgroup, // {
|
||||
eRTFCtrl_endgroup, // }
|
||||
eRTFCtrl_last //make sure this stays the last token...
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* Represents the token of RTF. Always has form \xxxx<optarg>delimiter
|
||||
*
|
||||
* @update gess7/8/98
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
class CRTFControlWord : public CToken {
|
||||
public:
|
||||
CRTFControlWord(char* aKey);
|
||||
virtual PRInt32 GetTokenType();
|
||||
virtual nsresult Consume(PRUnichar aChar,nsScanner& aScanner,PRInt32 aMode);
|
||||
protected:
|
||||
nsString mArgument;
|
||||
CRTFControlWord(eRTFTags aTagID);
|
||||
virtual PRInt32 GetTokenType();
|
||||
virtual nsresult Consume(PRUnichar aChar,nsScanner& aScanner,PRInt32 aMode);
|
||||
|
||||
eRTFTags mTag;
|
||||
nsAutoString mArgument;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @update gess7/8/98
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
class CRTFGroup: public CToken {
|
||||
public:
|
||||
CRTFGroup(char* aKey,PRBool aStartGroup);
|
||||
virtual PRInt32 GetTokenType();
|
||||
virtual void SetGroupStart(PRBool aFlag);
|
||||
virtual PRBool IsGroupStart();
|
||||
virtual nsresult Consume(PRUnichar aChar,nsScanner& aScanner,PRInt32 aMode);
|
||||
protected:
|
||||
PRBool mStart;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* This represents the document content.
|
||||
*
|
||||
* @update gess7/8/98
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
class CRTFContent: public CToken {
|
||||
public:
|
||||
CRTFContent(PRUnichar* aValue);
|
||||
virtual PRInt32 GetTokenType();
|
||||
virtual nsresult Consume(PRUnichar aChar,nsScanner& aScanner,PRInt32 aMode);
|
||||
CRTFContent(PRUnichar* aKey=0);
|
||||
virtual PRInt32 GetTokenType();
|
||||
virtual nsresult Consume(PRUnichar aChar,nsScanner& aScanner,PRInt32 aMode);
|
||||
};
|
||||
|
||||
|
||||
|
@ -225,14 +214,6 @@ class CRtfDTD : public nsIDTD {
|
|||
*/
|
||||
NS_IMETHOD DidBuildModel(nsresult anErrorCode,PRInt32 aLevel,nsIParser* aParser,nsIContentSink* aSink=0);
|
||||
|
||||
/**
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param aToken -- token object to be put into content model
|
||||
* @return 0 if all is well; non-zero is an error
|
||||
*/
|
||||
NS_IMETHOD HandleGroup(CToken* aToken);
|
||||
|
||||
/**
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
|
@ -256,25 +237,6 @@ class CRtfDTD : public nsIDTD {
|
|||
* @return 0 if all is well; non-zero is an error
|
||||
*/
|
||||
NS_IMETHOD HandleToken(CToken* aToken,nsIParser* aParser);
|
||||
|
||||
/**
|
||||
* This method causes all tokens to be dispatched to the given tag handler.
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param aHandler -- object to receive subsequent tokens...
|
||||
* @return error code (usually 0)
|
||||
*/
|
||||
NS_IMETHOD CaptureTokenPump(nsITagHandler* aHandler);
|
||||
|
||||
/**
|
||||
* This method releases the token-pump capture obtained in CaptureTokenPump()
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param aHandler -- object that received tokens...
|
||||
* @return error code (usually 0)
|
||||
*/
|
||||
NS_IMETHOD ReleaseTokenPump(nsITagHandler* aHandler);
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -375,6 +337,18 @@ protected:
|
|||
nsParser* mParser;
|
||||
char* mFilename;
|
||||
nsITokenizer* mTokenizer;
|
||||
PRBool mHasHeader;
|
||||
nsDeque mGroups;
|
||||
PRInt32 mGroupCount;
|
||||
nsIHTMLContentSink* mSink;
|
||||
|
||||
private:
|
||||
nsresult PushGroup();
|
||||
nsresult PopGroup();
|
||||
nsresult OpenContainer(eHTMLTags aTag,const char* aTagName);
|
||||
nsresult CloseContainer(eHTMLTags aTag);
|
||||
nsresult AddLeafContainer(eHTMLTags aTag,const char* aTagName);
|
||||
nsresult EmitStyleContainer(CToken* aToken,eRTFTags aTag,PRBool aState);
|
||||
};
|
||||
|
||||
extern NS_HTMLPARS nsresult NS_NewRTF_DTD(nsIDTD** aInstancePtrResult);
|
||||
|
|
|
@ -193,6 +193,42 @@ void nsEntryStack::Append(nsEntryStack *aStack) {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @update gess 01/25/00
|
||||
*/
|
||||
nsIParserNode* nsEntryStack::Remove(eHTMLTags aTag) {
|
||||
nsIParserNode* result=0;
|
||||
|
||||
if(0<mCount) {
|
||||
result=mEntries[--mCount].mNode;
|
||||
|
||||
((nsCParserNode*)result)->mUseCount--;
|
||||
((nsCParserNode*)result)->mToken->mUseCount--;
|
||||
mEntries[mCount].mNode=0;
|
||||
mEntries[mCount].mStyles=0;
|
||||
|
||||
nsEntryStack* theStyleStack=mEntries[mCount].mParent;
|
||||
|
||||
if(theStyleStack) {
|
||||
//now we have to tell the residual style stack where this tag
|
||||
//originated that it's no longer in use.
|
||||
PRUint32 scount=theStyleStack->mCount;
|
||||
PRUint32 sindex=0;
|
||||
|
||||
nsTagEntry *theStyleEntry=theStyleStack->mEntries;
|
||||
for(sindex=scount-1;sindex>0;sindex--){
|
||||
if(theStyleEntry->mTag==mEntries[mCount].mTag) {
|
||||
theStyleEntry->mParent=0; //this tells us that the style is not open at any level
|
||||
break;
|
||||
}
|
||||
theStyleEntry++;
|
||||
} //for
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -558,6 +594,33 @@ nsIParserNode* nsDTDContext::PopStyle(eHTMLTags aTag){
|
|||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* This is similar to popstyle, except that it removes the
|
||||
* style tag given from anywhere in the style stack, and
|
||||
* not just at the top.
|
||||
*
|
||||
* @update gess 01/26/00
|
||||
*/
|
||||
nsIParserNode* nsDTDContext::RemoveStyle(eHTMLTags aTag){
|
||||
|
||||
PRInt32 theLevel=0;
|
||||
|
||||
for(theLevel=mStack.mCount-1;theLevel>0;theLevel--) {
|
||||
nsEntryStack *theStack=mStack.mEntries[theLevel].mStyles;
|
||||
if(theStack) {
|
||||
if(aTag==theStack->Last()) {
|
||||
return theStack->Pop();
|
||||
mResidualStyleCount--;
|
||||
} else {
|
||||
// NS_ERROR("bad residual style entry");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**************************************************************
|
||||
Now define the tokenrecycler class...
|
||||
**************************************************************/
|
||||
|
@ -732,7 +795,7 @@ void DebugDumpContainmentRules(nsIDTD& theDTD,const char* aFilename,const char*
|
|||
int i,j=0;
|
||||
int written;
|
||||
for(i=1;i<eHTMLTag_text;i++){
|
||||
const char* tag=nsHTMLTags::GetStringValue((eHTMLTags)i);
|
||||
const char* tag=nsHTMLTags::GetCStringValue((eHTMLTags)i);
|
||||
out << endl << endl << "Tag: <" << tag << ">" << endl;
|
||||
out << prefix;
|
||||
written=0;
|
||||
|
@ -743,7 +806,7 @@ void DebugDumpContainmentRules(nsIDTD& theDTD,const char* aFilename,const char*
|
|||
written=0;
|
||||
}
|
||||
if(theDTD.CanContain(i,j)){
|
||||
tag=nsHTMLTags::GetStringValue((eHTMLTags)j);
|
||||
tag=nsHTMLTags::GetCStringValue((eHTMLTags)j);
|
||||
if(tag) {
|
||||
out<< tag << ", ";
|
||||
written++;
|
||||
|
|
|
@ -77,6 +77,7 @@ public:
|
|||
void PushFront(const nsIParserNode* aNode,nsEntryStack* aStyleStack=0);
|
||||
void Append(nsEntryStack *theStack);
|
||||
nsIParserNode* Pop(void);
|
||||
nsIParserNode* Remove(eHTMLTags aTag);
|
||||
nsIParserNode* NodeAt(PRInt32 anIndex) const;
|
||||
eHTMLTags First() const;
|
||||
eHTMLTags TagAt(PRInt32 anIndex) const;
|
||||
|
@ -154,6 +155,7 @@ public:
|
|||
void PushStyles(nsEntryStack *theStyles);
|
||||
nsIParserNode* PopStyle(void);
|
||||
nsIParserNode* PopStyle(eHTMLTags aTag);
|
||||
nsIParserNode* RemoveStyle(eHTMLTags aTag);
|
||||
|
||||
nsEntryStack mStack; //this will hold a list of tagentries...
|
||||
PRInt32 mResidualStyleCount;
|
||||
|
|
|
@ -447,9 +447,9 @@ void InitializeElementTable(void) {
|
|||
Initialize(
|
||||
/*tag*/ eHTMLTag_dir,
|
||||
/*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown,
|
||||
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
|
||||
/*autoclose starttags and endtags*/ 0,0,0,0,
|
||||
/*parent,incl,exclgroups*/ kList, (kSelf|kFlowEntity), kNone,
|
||||
/*rootnodes,endrootnodes*/ &gOLRootTags,&gOLRootTags,
|
||||
/*autoclose starttags and endtags*/ &gOLAutoClose, &gULCloseTags, 0,0,
|
||||
/*parent,incl,exclgroups*/ kList, (kFlowEntity|kSelf), kNone,
|
||||
/*special props, prop-range*/ 0,kDefaultPropRange,
|
||||
/*special parents,kids,skip*/ 0,&gULKids,eHTMLTag_unknown);
|
||||
|
||||
|
@ -937,7 +937,7 @@ void InitializeElementTable(void) {
|
|||
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
|
||||
/*autoclose starttags and endtags*/ 0,0,0,0,
|
||||
/*parent,incl,exclgroups*/ kPreformatted, kFlowEntity, kNone, //I'm allowing WAY too much in here. Spec says inline.
|
||||
/*special props, prop-range*/ kNoStyleLeaksIn, kDefaultPropRange,
|
||||
/*special props, prop-range*/ 0, kDefaultPropRange,
|
||||
/*special parents,kids,skip*/ 0,&gPreKids,eHTMLTag_unknown);
|
||||
|
||||
Initialize(
|
||||
|
@ -1387,9 +1387,12 @@ PRBool nsHTMLElement::IsBlockCloser(eHTMLTags aTag){
|
|||
(kHeading==gHTMLElements[aTag].mParentBits));
|
||||
if(!result) {
|
||||
// NOBR is a block closure - Ref. Bug# 24462
|
||||
// DIR is a block closure -- Ref. Bug# 25845
|
||||
|
||||
static eHTMLTags gClosers[]={ eHTMLTag_table,eHTMLTag_tbody,eHTMLTag_caption,eHTMLTag_dd,eHTMLTag_dt,
|
||||
/* eHTMLTag_td,eHTMLTag_tfoot,eHTMLTag_th,eHTMLTag_thead,eHTMLTag_tr, */
|
||||
eHTMLTag_nobr,eHTMLTag_optgroup,eHTMLTag_ol,eHTMLTag_ul};
|
||||
eHTMLTag_nobr,eHTMLTag_optgroup,eHTMLTag_ol,eHTMLTag_ul,eHTMLTag_dir};
|
||||
|
||||
result=FindTagInSet(aTag,gClosers,sizeof(gClosers)/sizeof(eHTMLTag_body));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -516,30 +516,6 @@ NS_IMETHODIMP nsExpatDTD::HandleToken(CToken* aToken,nsIParser* aParser) {
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* This method causes all tokens to be dispatched to the given tag handler.
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param aHandler -- object to receive subsequent tokens...
|
||||
* @return error code (usually 0)
|
||||
*/
|
||||
nsresult nsExpatDTD::CaptureTokenPump(nsITagHandler* aHandler) {
|
||||
nsresult result=NS_OK;
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method releases the token-pump capture obtained in CaptureTokenPump()
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param aHandler -- object that received tokens...
|
||||
* @return error code (usually 0)
|
||||
*/
|
||||
nsresult nsExpatDTD::ReleaseTokenPump(nsITagHandler* aHandler){
|
||||
nsresult result=NS_OK;
|
||||
return result;
|
||||
}
|
||||
|
||||
nsresult nsExpatDTD::ParseXMLBuffer(const char *buffer){
|
||||
nsresult result=NS_OK;
|
||||
if (mExpatParser) {
|
||||
|
|
|
@ -141,24 +141,6 @@ class nsExpatDTD : public nsIDTD {
|
|||
*/
|
||||
NS_IMETHOD HandleToken(CToken* aToken,nsIParser* aParser);
|
||||
|
||||
/**
|
||||
* This method causes all tokens to be dispatched to the given tag handler.
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param aHandler -- object to receive subsequent tokens...
|
||||
* @return error code (usually 0)
|
||||
*/
|
||||
NS_IMETHOD CaptureTokenPump(nsITagHandler* aHandler);
|
||||
|
||||
/**
|
||||
* This method releases the token-pump capture obtained in CaptureTokenPump()
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param aHandler -- object that received tokens...
|
||||
* @return error code (usually 0)
|
||||
*/
|
||||
NS_IMETHOD ReleaseTokenPump(nsITagHandler* aHandler);
|
||||
|
||||
/**
|
||||
*
|
||||
* @update gess12/28/98
|
||||
|
|
|
@ -150,6 +150,17 @@ nsHTMLTags::GetStringValue(nsHTMLTag aTag)
|
|||
}
|
||||
}
|
||||
|
||||
const char* nsHTMLTags::GetCStringValue(nsHTMLTag aTag) {
|
||||
NS_ASSERTION(gTagArray, "no lookup table, needs addref");
|
||||
if ((eHTMLTag_unknown < aTag) &&
|
||||
(aTag < NS_HTML_TAG_MAX) && gTagArray) {
|
||||
return gTagArray[aTag - 1].mStr.mStr;
|
||||
}
|
||||
else {
|
||||
static const char* kNullStr="";
|
||||
return kNullStr;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#ifdef NS_DEBUG
|
||||
|
|
|
@ -57,6 +57,7 @@ public:
|
|||
|
||||
static nsHTMLTag LookupTag(const nsStr& aTag);
|
||||
static const nsCString& GetStringValue(nsHTMLTag aEnum);
|
||||
static const char* GetCStringValue(nsHTMLTag aEnum);
|
||||
};
|
||||
|
||||
#endif /* nsHTMLTags_h___ */
|
||||
|
|
|
@ -53,7 +53,7 @@ static NS_DEFINE_CID(kCharsetConverterManagerCID, NS_ICHARSETCONVERTERMANAGER_CI
|
|||
|
||||
const PRInt32 gTabSize=4;
|
||||
const PRInt32 gOLNumberWidth = 3;
|
||||
const PRInt32 gIndentSizeList = MaxInt(gTabSize, gOLNumberWidth + 3);
|
||||
const PRInt32 gIndentSizeList = (gTabSize<gOLNumberWidth+3) ? gTabSize: gOLNumberWidth+3;
|
||||
// Indention of non-first lines of ul and ol
|
||||
|
||||
static PRBool IsInline(eHTMLTags aTag);
|
||||
|
@ -759,13 +759,7 @@ nsHTMLToTXTSinkStream::AddLeaf(const nsIParserNode& aNode)
|
|||
printf(" '%s' ", text.ToNewCString());
|
||||
#endif
|
||||
|
||||
if (mTagStackIndex > 1 && mTagStack[mTagStackIndex-2] == eHTMLTag_select)
|
||||
{
|
||||
// Don't output the contents of SELECT elements;
|
||||
// Might be nice, eventually, to output just the selected element.
|
||||
return NS_OK;
|
||||
}
|
||||
else if (type == eHTMLTag_text)
|
||||
if (type == eHTMLTag_text)
|
||||
{
|
||||
Write(text);
|
||||
}
|
||||
|
|
|
@ -490,7 +490,7 @@ nsresult nsHTMLTokenizer::ConsumeStartTag(PRUnichar aChar,CToken*& aToken,nsScan
|
|||
aToken=theRecycler->CreateTokenOfType(eToken_start,eHTMLTag_unknown);
|
||||
|
||||
if(aToken) {
|
||||
result= aToken->Consume(aChar,aScanner,mParseMode); //tell new token to finish consuming text...
|
||||
result= aToken->Consume(aChar,aScanner,mPlainText); //tell new token to finish consuming text...
|
||||
if(NS_SUCCEEDED(result)) {
|
||||
|
||||
AddToken(aToken,result,&mTokenDeque,theRecycler);
|
||||
|
|
|
@ -77,6 +77,22 @@ void CHTMLToken::SetStringValue(const char* name){
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This method retrieves the value of this internal string.
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @return nsString reference to internal string value
|
||||
*/
|
||||
nsString& CHTMLToken::GetStringValueXXX(void) {
|
||||
if((eHTMLTag_unknown<mTypeID) && (eHTMLTag_userdefined!=mTypeID)) {
|
||||
if(!mTextValue.Length()) {
|
||||
mTextValue = nsHTMLTags::GetStringValue((nsHTMLTag) mTypeID);
|
||||
}
|
||||
}
|
||||
return mTextValue;
|
||||
}
|
||||
|
||||
/*
|
||||
* constructor from tag id
|
||||
*
|
||||
|
@ -97,12 +113,15 @@ CStartToken::CStartToken(eHTMLTags aTag) : CHTMLToken(aTag) {
|
|||
* @param
|
||||
* @return
|
||||
*/
|
||||
CStartToken::CStartToken(nsString& aString,eHTMLTags aTag) : CHTMLToken(aString,aTag) {
|
||||
CStartToken::CStartToken(const nsString& aString) : CHTMLToken(aString) {
|
||||
mAttributed=PR_FALSE;
|
||||
mEmpty=PR_FALSE;
|
||||
mOrigin=-1;
|
||||
}
|
||||
|
||||
CStartToken::CStartToken(const nsString& aName,eHTMLTags aTag) : CHTMLToken(aName,aTag) {
|
||||
mTypeID=aTag;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -206,6 +225,7 @@ PRBool CStartToken::IsEmpty(void) {
|
|||
* @update gess 3/25/98
|
||||
* @param aChar -- last char consumed from stream
|
||||
* @param aScanner -- controller of underlying input source
|
||||
* @param aMode -- 0=HTML; 1=text;
|
||||
* @return error result
|
||||
*/
|
||||
nsresult CStartToken::Consume(PRUnichar aChar, nsScanner& aScanner,PRInt32 aMode) {
|
||||
|
@ -215,9 +235,20 @@ nsresult CStartToken::Consume(PRUnichar aChar, nsScanner& aScanner,PRInt32 aMode
|
|||
//Stop consuming as soon as you see a space or a '>'.
|
||||
//NOTE: We don't Consume the tag attributes here, nor do we eat the ">"
|
||||
|
||||
mTextValue=aChar;
|
||||
nsresult result=aScanner.ReadIdentifier(mTextValue);
|
||||
mTypeID = nsHTMLTags::LookupTag(mTextValue);
|
||||
nsresult result=NS_OK;
|
||||
if(0==aMode) {
|
||||
nsSubsumeStr theSubstr;
|
||||
result=aScanner.GetIdentifier(theSubstr);
|
||||
mTypeID = (PRInt32)nsHTMLTags::LookupTag(theSubstr);
|
||||
if(eHTMLTag_userdefined==mTypeID) {
|
||||
mTextValue=theSubstr;
|
||||
}
|
||||
}
|
||||
else {
|
||||
mTextValue=aChar;
|
||||
nsresult result=aScanner.ReadIdentifier(mTextValue);
|
||||
mTypeID = nsHTMLTags::LookupTag(mTextValue);
|
||||
}
|
||||
|
||||
//Good. Now, let's skip whitespace after the identifier,
|
||||
//and see if the next char is ">". If so, we have a complete
|
||||
|
|
|
@ -101,6 +101,7 @@ public:
|
|||
CHTMLToken(eHTMLTags aTag);
|
||||
CHTMLToken(const nsString& aString,eHTMLTags aTag=eHTMLTag_unknown);
|
||||
virtual void SetStringValue(const char* name);
|
||||
virtual nsString& GetStringValueXXX(void);
|
||||
|
||||
protected:
|
||||
};
|
||||
|
@ -113,8 +114,10 @@ protected:
|
|||
*/
|
||||
class CStartToken: public CHTMLToken {
|
||||
public:
|
||||
CStartToken(eHTMLTags aTag);
|
||||
CStartToken(nsString& aName,eHTMLTags aTag=eHTMLTag_unknown);
|
||||
CStartToken(eHTMLTags aTag=eHTMLTag_unknown);
|
||||
CStartToken(const nsString& aString);
|
||||
CStartToken(const nsString& aName,eHTMLTags aTag);
|
||||
|
||||
virtual nsresult Consume(PRUnichar aChar,nsScanner& aScanner,PRInt32 aMode);
|
||||
virtual PRInt32 GetTypeID(void);
|
||||
virtual const char* GetClassName(void);
|
||||
|
|
|
@ -64,7 +64,6 @@ class CToken;
|
|||
class nsIDTDDebug;
|
||||
class nsIURI;
|
||||
class nsString;
|
||||
class nsITagHandler;
|
||||
class nsIContentSink;
|
||||
|
||||
|
||||
|
@ -151,24 +150,6 @@ class nsIDTD : public nsISupports {
|
|||
|
||||
virtual nsITokenRecycler* GetTokenRecycler(void)=0;
|
||||
|
||||
/**
|
||||
* This method causes all tokens to be dispatched to the given tag handler.
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param aHandler -- object to receive subsequent tokens...
|
||||
* @return error code (usually 0)
|
||||
*/
|
||||
NS_IMETHOD CaptureTokenPump(nsITagHandler* aHandler)=0;
|
||||
|
||||
/**
|
||||
* This method releases the token-pump capture obtained in CaptureTokenPump()
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param aHandler -- object that received tokens...
|
||||
* @return error code (usually 0)
|
||||
*/
|
||||
NS_IMETHOD ReleaseTokenPump(nsITagHandler* aHandler)=0;
|
||||
|
||||
/**
|
||||
* If the parse process gets interrupted midway, this method is called by the
|
||||
* parser prior to resuming the process.
|
||||
|
|
|
@ -275,5 +275,5 @@ const PRUnichar kNullCh = '\0';
|
|||
#define kPlainTextContentType "text/plain"
|
||||
#define kViewSourceCommand "view-source"
|
||||
#define kTextCSSContentType "text/css"
|
||||
|
||||
#define kRTFTextContentType "text/rtf"
|
||||
#endif
|
||||
|
|
|
@ -41,6 +41,7 @@
|
|||
#include "nsIChannel.h"
|
||||
#include "nsIProgressEventSink.h"
|
||||
#include "nsIBufferInputStream.h"
|
||||
#include "CRTFDTD.h"
|
||||
|
||||
//#define rickgdebug
|
||||
|
||||
|
@ -98,7 +99,7 @@ public:
|
|||
mDTDDeque.Push(theDTD);
|
||||
|
||||
mHasViewSourceDTD=PR_FALSE;
|
||||
mHasXMLDTD=PR_FALSE;
|
||||
mHasRTFDTD=mHasXMLDTD=PR_FALSE;
|
||||
}
|
||||
|
||||
~CSharedParserObjects() {
|
||||
|
@ -122,6 +123,7 @@ public:
|
|||
nsDeque mDTDDeque;
|
||||
PRBool mHasViewSourceDTD; //this allows us to defer construction of this object.
|
||||
PRBool mHasXMLDTD; //also defer XML dtd construction
|
||||
PRBool mHasRTFDTD; //also defer RTF dtd construction
|
||||
};
|
||||
|
||||
static CSharedParserObjects* gSharedParserObjects=0;
|
||||
|
@ -415,6 +417,10 @@ PRBool FindSuitableDTD( CParserContext& aParserContext,nsString& aCommand,nsStri
|
|||
|
||||
CSharedParserObjects& gSharedObjects=GetSharedObjects();
|
||||
|
||||
#if 0
|
||||
aParserContext.mSourceType="text/rtf";
|
||||
#endif
|
||||
|
||||
aParserContext.mAutoDetectStatus=eUnknownDetect;
|
||||
PRInt32 theDTDIndex=0;
|
||||
nsIDTD* theBestDTD=0;
|
||||
|
@ -444,6 +450,11 @@ PRBool FindSuitableDTD( CParserContext& aParserContext,nsString& aCommand,nsStri
|
|||
gSharedObjects.mDTDDeque.Push(theDTD);
|
||||
gSharedObjects.mHasViewSourceDTD=PR_TRUE;
|
||||
}
|
||||
else if(!gSharedObjects.mHasRTFDTD) {
|
||||
NS_NewRTF_DTD(&theDTD); //do this so all non-html files can be viewed...
|
||||
gSharedObjects.mDTDDeque.Push(theDTD);
|
||||
gSharedObjects.mHasRTFDTD=PR_TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -471,54 +482,48 @@ eParseMode DetermineParseMode(nsParser& aParser) {
|
|||
eParseMode result=eParseMode_unknown;
|
||||
nsScanner* theScanner=aParser.GetScanner();
|
||||
if(theScanner){
|
||||
nsAutoString theBufCopy;
|
||||
nsString& theBuffer=theScanner->GetBuffer();
|
||||
theBuffer.Left(theBufCopy,125);
|
||||
PRInt32 theIndex=theBufCopy.Find("<!");
|
||||
theIndex=(theIndex!=kNotFound)? theIndex=theBufCopy.Find("DOCTYPE",PR_TRUE,2):kNotFound;
|
||||
|
||||
PRInt32 theIndex=theBuffer.Find("<!",PR_FALSE,-1);
|
||||
if(kNotFound<theIndex)
|
||||
theIndex=theBuffer.Find("DOCTYPE",PR_TRUE,theIndex+1,10);
|
||||
|
||||
if(kNotFound<theIndex) {
|
||||
//good, we found "DOCTYPE" -- now go find it's end delimiter '>'
|
||||
theBufCopy.StripWhitespace();
|
||||
PRInt32 theSubIndex=theBufCopy.FindChar(kGreaterThan,theIndex+1);
|
||||
theBufCopy.Truncate(theSubIndex);
|
||||
theSubIndex=theBufCopy.Find("-//W3C//DTD",PR_TRUE,theIndex+8);
|
||||
PRInt32 theEnd=theBuffer.FindChar(kGreaterThan,theIndex+1);
|
||||
PRInt32 theSubIndex=theBuffer.Find("-//W3C//DTD",PR_TRUE,theIndex+8,theEnd-(theIndex+8));
|
||||
if(kNotFound<theSubIndex) {
|
||||
if(kNotFound<(theSubIndex=theBufCopy.Find("HTML4.0",PR_TRUE,theSubIndex+11))) {
|
||||
PRUnichar num=theBufCopy.CharAt(theSubIndex+7);
|
||||
if(num > '0' && num < '9') {
|
||||
result=eParseMode_noquirks; // XXX - investigate this more.
|
||||
}
|
||||
else if((theBufCopy.Find("TRANSITIONAL",PR_TRUE,theSubIndex+7)>kNotFound)||
|
||||
(theBufCopy.Find("FRAMESET",PR_TRUE,theSubIndex+7)>kNotFound) ||
|
||||
(theBufCopy.Find("LATIN1", PR_TRUE,theSubIndex+7) >kNotFound) ||
|
||||
(theBufCopy.Find("SYMBOLS",PR_TRUE,theSubIndex+7) >kNotFound) ||
|
||||
(theBufCopy.Find("SPECIAL",PR_TRUE,theSubIndex+7) >kNotFound))
|
||||
if(kNotFound<(theSubIndex=theBuffer.Find("HTML 4",PR_TRUE,theSubIndex+11,theEnd-(theSubIndex+11)))) {
|
||||
if((theBuffer.Find("TRANSITIONAL",PR_TRUE,theSubIndex+7)>kNotFound)||
|
||||
(theBuffer.Find("FRAMESET",PR_TRUE,theSubIndex+7)>kNotFound) ||
|
||||
(theBuffer.Find("LATIN1", PR_TRUE,theSubIndex+7) >kNotFound) ||
|
||||
(theBuffer.Find("SYMBOLS",PR_TRUE,theSubIndex+7) >kNotFound) ||
|
||||
(theBuffer.Find("SPECIAL",PR_TRUE,theSubIndex+7) >kNotFound))
|
||||
result=eParseMode_quirks; // XXX -HACK- Set the appropriate mode.
|
||||
else
|
||||
result=eParseMode_noquirks;
|
||||
}
|
||||
else if(kNotFound<(theSubIndex=theBufCopy.Find("XHTML",PR_TRUE,theSubIndex+11))) {
|
||||
if((theBufCopy.Find("TRANSITIONAL",PR_TRUE,theSubIndex)>kNotFound)||
|
||||
(theBufCopy.Find("STRICT",PR_TRUE,theSubIndex) >kNotFound) ||
|
||||
(theBufCopy.Find("FRAMESET",PR_TRUE,theSubIndex) >kNotFound))
|
||||
else if(kNotFound<(theSubIndex=theBuffer.Find("XHTML",PR_TRUE,theSubIndex+11))) {
|
||||
if((theBuffer.Find("TRANSITIONAL",PR_TRUE,theSubIndex)>kNotFound)||
|
||||
(theBuffer.Find("STRICT",PR_TRUE,theSubIndex) >kNotFound) ||
|
||||
(theBuffer.Find("FRAMESET",PR_TRUE,theSubIndex) >kNotFound))
|
||||
result=eParseMode_noquirks;
|
||||
else
|
||||
result=eParseMode_quirks;
|
||||
}
|
||||
}
|
||||
else if(kNotFound<(theSubIndex=theBufCopy.Find("ISO/IEC15445:1999",PR_TRUE,theIndex+8))) {
|
||||
theSubIndex=theBufCopy.Find("HTML",PR_TRUE,theSubIndex+18);
|
||||
else if(kNotFound<(theSubIndex=theBuffer.Find("ISO/IEC15445:1999",PR_TRUE,theIndex+8))) {
|
||||
theSubIndex=theBuffer.Find("HTML",PR_TRUE,theSubIndex+18);
|
||||
if(kNotFound==theSubIndex)
|
||||
theSubIndex=theBufCopy.Find("HYPERTEXTMARKUPLANGUAGE",PR_TRUE,theSubIndex+18);
|
||||
theSubIndex=theBuffer.Find("HYPERTEXTMARKUPLANGUAGE",PR_TRUE,theSubIndex+18);
|
||||
result=eParseMode_noquirks;
|
||||
}
|
||||
}
|
||||
else if(kNotFound<(theIndex=theBufCopy.Find("?XML",PR_TRUE))) {
|
||||
else if(kNotFound<(theIndex=theBuffer.Find("?XML",PR_TRUE))) {
|
||||
result=eParseMode_noquirks;
|
||||
}
|
||||
else {
|
||||
theIndex=theBufCopy.Find("NOQUIRKS",PR_TRUE);
|
||||
theIndex=theBuffer.Find("NOQUIRKS",PR_TRUE);
|
||||
if(kNotFound<theIndex) {
|
||||
result=eParseMode_noquirks;
|
||||
}
|
||||
|
@ -935,7 +940,7 @@ nsresult nsParser::ParseFragment(const nsString& aSourceBuffer,void* aKey,nsITag
|
|||
theBuffer.Append("<title>title</title><a href=\"one\">link</a>");
|
||||
#else
|
||||
//this is the normal code path for paste...
|
||||
theBuffer.Append(aSourceBuffer);
|
||||
theBuffer.Append(aSourceBuffer);
|
||||
#endif
|
||||
|
||||
if(theBuffer.Length()){
|
||||
|
@ -1389,10 +1394,11 @@ nsresult nsParser::OnStopRequest(nsIChannel* channel, nsISupports* aContext,
|
|||
nsresult result=NS_OK;
|
||||
|
||||
if(eOnStart==mParserContext->mStreamListenerState) {
|
||||
|
||||
//If you're here, then OnDataAvailable() never got called.
|
||||
//Prior to necko, we never dealt with this case, but the problem may have existed.
|
||||
//What we'll do (for now at least) is construct the worlds smallest HTML document.
|
||||
nsAutoString temp("<BODY></BODY>");
|
||||
//What we'll do (for now at least) is construct a blank HTML document.
|
||||
nsAutoString temp("<html><body></body></html>");
|
||||
mParserContext->mScanner->Append(temp);
|
||||
result=ResumeParse(nsnull, PR_TRUE);
|
||||
}
|
||||
|
@ -1484,7 +1490,8 @@ nsresult nsParser::Tokenize(PRBool aIsFinalChunk){
|
|||
else if(NS_ERROR_HTMLPARSER_STOPPARSING==result)
|
||||
return Terminate();
|
||||
}
|
||||
else if(flushTokens) {
|
||||
else if(flushTokens && mObserversEnabled) {
|
||||
// I added the extra test of mObserversEnabled to fix Bug# 23931.
|
||||
// Flush tokens on seeing </SCRIPT> -- Ref: Bug# 22485 --
|
||||
// Also remember to update the marked position.
|
||||
mParserContext->mScanner->Mark();
|
||||
|
|
|
@ -47,7 +47,7 @@ nsString& GetEmptyString() {
|
|||
* @return
|
||||
*/
|
||||
nsCParserNode::nsCParserNode(CToken* aToken,PRInt32 aLineNumber,nsITokenRecycler* aRecycler):
|
||||
nsIParserNode(), mSkippedContent("") {
|
||||
nsIParserNode() {
|
||||
NS_INIT_REFCNT();
|
||||
|
||||
static int theNodeCount=0;
|
||||
|
@ -57,6 +57,7 @@ nsCParserNode::nsCParserNode(CToken* aToken,PRInt32 aLineNumber,nsITokenRecycler
|
|||
mToken=aToken;
|
||||
mRecycler=aRecycler;
|
||||
mUseCount=0;
|
||||
mSkippedContent=0;
|
||||
}
|
||||
|
||||
static void RecycleTokens(nsITokenRecycler* aRecycler,nsDeque& aDeque) {
|
||||
|
@ -89,6 +90,10 @@ nsCParserNode::~nsCParserNode() {
|
|||
delete mAttributes;
|
||||
mAttributes=0;
|
||||
}
|
||||
if(mSkippedContent) {
|
||||
delete mSkippedContent;
|
||||
}
|
||||
mSkippedContent=0;
|
||||
}
|
||||
|
||||
|
||||
|
@ -110,7 +115,9 @@ nsresult nsCParserNode::Init(CToken* aToken,PRInt32 aLineNumber,nsITokenRecycler
|
|||
RecycleTokens(mRecycler,*mAttributes);
|
||||
mToken=aToken;
|
||||
mUseCount=0;
|
||||
mSkippedContent.Truncate();
|
||||
if(mSkippedContent) {
|
||||
mSkippedContent->Truncate();
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -201,9 +208,12 @@ const nsString& nsCParserNode::GetText() const {
|
|||
* @return string ref of text from internal token
|
||||
*/
|
||||
const nsString& nsCParserNode::GetSkippedContent() const {
|
||||
return mSkippedContent;
|
||||
if(mSkippedContent)
|
||||
return *mSkippedContent;
|
||||
return GetEmptyString();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get text value of this node, which translates into
|
||||
* getting the text value of the underlying token
|
||||
|
@ -213,7 +223,10 @@ const nsString& nsCParserNode::GetSkippedContent() const {
|
|||
* @return string ref of text from internal token
|
||||
*/
|
||||
void nsCParserNode::SetSkippedContent(nsString& aString) {
|
||||
mSkippedContent=aString;
|
||||
if(!mSkippedContent) {
|
||||
mSkippedContent=new nsString(aString);
|
||||
}
|
||||
else *mSkippedContent=aString;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -174,11 +174,11 @@ class nsCParserNode : public nsIParserNode {
|
|||
*/
|
||||
virtual CToken* PopAttributeToken();
|
||||
|
||||
PRInt32 mLineNumber;
|
||||
CToken* mToken;
|
||||
nsDeque* mAttributes;
|
||||
nsAutoString mSkippedContent;
|
||||
PRInt32 mUseCount;
|
||||
PRInt32 mLineNumber;
|
||||
CToken* mToken;
|
||||
nsDeque* mAttributes;
|
||||
nsString* mSkippedContent;
|
||||
PRInt32 mUseCount;
|
||||
|
||||
nsITokenRecycler* mRecycler;
|
||||
};
|
||||
|
|
|
@ -646,6 +646,47 @@ nsresult nsScanner::SkipPast(nsString& aValidSet){
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Consume characters until you did not find the terminal char
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param aString - receives new data from stream
|
||||
* @param aIgnore - If set ignores ':','-','_'
|
||||
* @return error code
|
||||
*/
|
||||
nsresult nsScanner::GetIdentifier(nsSubsumeStr& aString) {
|
||||
|
||||
PRUnichar theChar=0;
|
||||
nsresult result=Peek(theChar);
|
||||
const PRUnichar* theBuf=mBuffer.GetUnicode();
|
||||
PRInt32 theOrigin=mOffset;
|
||||
PRBool found=PR_FALSE;
|
||||
|
||||
while(NS_OK==result) {
|
||||
|
||||
theChar=theBuf[mOffset++];
|
||||
if(theChar) {
|
||||
found=PR_FALSE;
|
||||
if(('a'<=theChar) && (theChar<='z'))
|
||||
found=PR_TRUE;
|
||||
else if(('A'<=theChar) && (theChar<='Z'))
|
||||
found=PR_TRUE;
|
||||
else if(('0'<=theChar) && (theChar<='9'))
|
||||
found=PR_TRUE;
|
||||
|
||||
if(!found) {
|
||||
mOffset-=1;
|
||||
PRUnichar* thePtr=(PRUnichar*)&theBuf[theOrigin-1];
|
||||
aString.Subsume(thePtr,PR_FALSE,mOffset-theOrigin+1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//DoErrTest(aString);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Consume characters until you did not find the terminal char
|
||||
|
|
|
@ -175,6 +175,7 @@ class nsScanner {
|
|||
* @param addTerminal tells us whether to append terminal to aString
|
||||
* @return error code
|
||||
*/
|
||||
nsresult GetIdentifier(nsSubsumeStr& aString);
|
||||
nsresult ReadIdentifier(nsString& aString,PRBool aIgnore=PR_FALSE);
|
||||
nsresult ReadNumber(nsString& aString);
|
||||
nsresult ReadWhitespace(nsString& aString);
|
||||
|
|
|
@ -88,4 +88,64 @@ public:
|
|||
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* This class defines an object that describes the baseline group that a given
|
||||
* element belongs to.
|
||||
*
|
||||
* @update rgess 1/15/00
|
||||
*/
|
||||
class nsElementGroup {
|
||||
public:
|
||||
nsElementGroup(PRInt32 aGroupBits) {
|
||||
mGroupBits=aGroupBits;
|
||||
}
|
||||
|
||||
nsElementGroup(const nsElementGroup& aGroup) {
|
||||
mGroupBits=aGroup.mGroupBits;
|
||||
}
|
||||
|
||||
nsElementGroup& operator=(const nsElementGroup& aGroup) {
|
||||
mGroupBits=aGroup.mGroupBits;
|
||||
return *this;
|
||||
}
|
||||
|
||||
~nsElementGroup() {
|
||||
mGroupBits=0;
|
||||
}
|
||||
|
||||
private:
|
||||
PRInt32 mGroupBits;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* This class defines an object that describes the each element (tag).
|
||||
*
|
||||
* @update rgess 1/15/00
|
||||
*/
|
||||
class nsElement {
|
||||
public:
|
||||
nsElement() {
|
||||
mGroup=0;
|
||||
}
|
||||
|
||||
nsElement(const nsElement& aGroup){
|
||||
mGroup=aGroup.mGroup;
|
||||
}
|
||||
|
||||
nsElement& operator=(const nsElement& aGroup) {
|
||||
mGroup=aGroup.mGroup;
|
||||
return *this;
|
||||
}
|
||||
|
||||
~nsElement() {
|
||||
mGroup=0;
|
||||
}
|
||||
|
||||
private:
|
||||
nsElementGroup* mGroup;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
|
|
@ -347,31 +347,6 @@ NS_IMETHODIMP CValidDTD::HandleToken(CToken* aToken,nsIParser* aParser) {
|
|||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method causes all tokens to be dispatched to the given tag handler.
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param aHandler -- object to receive subsequent tokens...
|
||||
* @return error code (usually 0)
|
||||
*/
|
||||
nsresult CValidDTD::CaptureTokenPump(nsITagHandler* aHandler) {
|
||||
nsresult result=NS_OK;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This method releases the token-pump capture obtained in CaptureTokenPump()
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param aHandler -- object that received tokens...
|
||||
* @return error code (usually 0)
|
||||
*/
|
||||
nsresult CValidDTD::ReleaseTokenPump(nsITagHandler* aHandler){
|
||||
nsresult result=NS_OK;
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @update gess8/4/98
|
||||
|
|
|
@ -149,25 +149,6 @@ class CValidDTD : public nsIDTD {
|
|||
*/
|
||||
NS_IMETHOD HandleToken(CToken* aToken,nsIParser* aParser);
|
||||
|
||||
|
||||
/**
|
||||
* This method causes all tokens to be dispatched to the given tag handler.
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param aHandler -- object to receive subsequent tokens...
|
||||
* @return error code (usually 0)
|
||||
*/
|
||||
NS_IMETHOD CaptureTokenPump(nsITagHandler* aHandler);
|
||||
|
||||
/**
|
||||
* This method releases the token-pump capture obtained in CaptureTokenPump()
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param aHandler -- object that received tokens...
|
||||
* @return error code (usually 0)
|
||||
*/
|
||||
NS_IMETHOD ReleaseTokenPump(nsITagHandler* aHandler);
|
||||
|
||||
/**
|
||||
*
|
||||
* @update gess12/28/98
|
||||
|
|
|
@ -940,26 +940,3 @@ NS_IMETHODIMP CViewSourceHTML::HandleToken(CToken* aToken,nsIParser* aParser) {
|
|||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method causes all tokens to be dispatched to the given tag handler.
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param aHandler -- object to receive subsequent tokens...
|
||||
* @return error code (usually 0)
|
||||
*/
|
||||
nsresult CViewSourceHTML::CaptureTokenPump(nsITagHandler* aHandler) {
|
||||
nsresult result=NS_OK;
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method releases the token-pump capture obtained in CaptureTokenPump()
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param aHandler -- object that received tokens...
|
||||
* @return error code (usually 0)
|
||||
*/
|
||||
nsresult CViewSourceHTML::ReleaseTokenPump(nsITagHandler* aHandler){
|
||||
nsresult result=NS_OK;
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -159,24 +159,6 @@ class CViewSourceHTML: public nsIDTD {
|
|||
*/
|
||||
virtual nsITokenRecycler* GetTokenRecycler(void);
|
||||
|
||||
/**
|
||||
* This method causes all tokens to be dispatched to the given tag handler.
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param aHandler -- object to receive subsequent tokens...
|
||||
* @return error code (usually 0)
|
||||
*/
|
||||
NS_IMETHOD CaptureTokenPump(nsITagHandler* aHandler);
|
||||
|
||||
/**
|
||||
* This method releases the token-pump capture obtained in CaptureTokenPump()
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param aHandler -- object that received tokens...
|
||||
* @return error code (usually 0)
|
||||
*/
|
||||
NS_IMETHOD ReleaseTokenPump(nsITagHandler* aHandler);
|
||||
|
||||
/**
|
||||
*
|
||||
* @update gess5/18/98
|
||||
|
|
|
@ -704,26 +704,3 @@ nsresult CWellFormedDTD::HandleDocTypeDeclToken(CToken* aToken) {
|
|||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method causes all tokens to be dispatched to the given tag handler.
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param aHandler -- object to receive subsequent tokens...
|
||||
* @return error code (usually 0)
|
||||
*/
|
||||
nsresult CWellFormedDTD::CaptureTokenPump(nsITagHandler* aHandler) {
|
||||
nsresult result=NS_OK;
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method releases the token-pump capture obtained in CaptureTokenPump()
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param aHandler -- object that received tokens...
|
||||
* @return error code (usually 0)
|
||||
*/
|
||||
nsresult CWellFormedDTD::ReleaseTokenPump(nsITagHandler* aHandler){
|
||||
nsresult result=NS_OK;
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -136,24 +136,6 @@ class CWellFormedDTD : public nsIDTD {
|
|||
*/
|
||||
NS_IMETHOD HandleToken(CToken* aToken,nsIParser* aParser);
|
||||
|
||||
/**
|
||||
* This method causes all tokens to be dispatched to the given tag handler.
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param aHandler -- object to receive subsequent tokens...
|
||||
* @return error code (usually 0)
|
||||
*/
|
||||
NS_IMETHOD CaptureTokenPump(nsITagHandler* aHandler);
|
||||
|
||||
/**
|
||||
* This method releases the token-pump capture obtained in CaptureTokenPump()
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param aHandler -- object that received tokens...
|
||||
* @return error code (usually 0)
|
||||
*/
|
||||
NS_IMETHOD ReleaseTokenPump(nsITagHandler* aHandler);
|
||||
|
||||
/**
|
||||
*
|
||||
* @update gess 12/20/99
|
||||
|
|
|
@ -313,25 +313,33 @@ eAutoDetectResult nsXIFDTD::CanParse(nsString& aContentType, nsString& aCommand,
|
|||
}
|
||||
}
|
||||
|
||||
nsString charset ="ISO-8859-1";
|
||||
nsString charset("ISO-8859-1");
|
||||
PRInt32 offset;
|
||||
offset = aBuffer.Find(kXIFDocInfo);
|
||||
if(kNotFound!=offset)
|
||||
{
|
||||
|
||||
if(kNotFound!=offset) {
|
||||
|
||||
offset = aBuffer.Find(kXIFCharset);
|
||||
if (kNotFound!=offset)
|
||||
{
|
||||
if (kNotFound!=offset) {
|
||||
|
||||
//begin by finding the start and end quotes in the string...
|
||||
PRInt32 start = aBuffer.FindChar('"',PR_FALSE,offset);
|
||||
PRInt32 end = aBuffer.FindChar('"',PR_FALSE,start+1);
|
||||
|
||||
if ((start != kNotFound) && (end != kNotFound))
|
||||
{
|
||||
charset = "";
|
||||
for (PRInt32 i = start+1; i < end; i++)
|
||||
{
|
||||
if ((start != kNotFound) && (end != kNotFound)) {
|
||||
#if 0
|
||||
//This is faster than using character iteration (used below)...
|
||||
//(Why call 1 function when 30 single-character appends will do? :)
|
||||
aBuffer.Mid(charset,start+1,(end-start)-1);
|
||||
|
||||
#else
|
||||
//I removed this old (SLOW) version in favor of calling the Mid() function
|
||||
charset.Truncate();
|
||||
for (PRInt32 i = start+1; i < end; i++) {
|
||||
PRUnichar ch = aBuffer[i];
|
||||
charset.Append(ch);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -472,30 +480,6 @@ nsresult nsXIFDTD::HandleToken(CToken* aToken,nsIParser* aParser) {
|
|||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method causes all tokens to be dispatched to the given tag handler.
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param aHandler -- object to receive subsequent tokens...
|
||||
* @return error code (usually 0)
|
||||
*/
|
||||
nsresult nsXIFDTD::CaptureTokenPump(nsITagHandler* aHandler) {
|
||||
nsresult result=NS_OK;
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method releases the token-pump capture obtained in CaptureTokenPump()
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param aHandler -- object that received tokens...
|
||||
* @return error code (usually 0)
|
||||
*/
|
||||
nsresult nsXIFDTD::ReleaseTokenPump(nsITagHandler* aHandler){
|
||||
nsresult result=NS_OK;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This method gets called when a start token has been
|
||||
|
@ -543,12 +527,9 @@ nsresult nsXIFDTD::HandleTextToken(CToken* aToken) {
|
|||
|
||||
nsresult result = NS_OK;
|
||||
|
||||
if (type == eXIFTag_text)
|
||||
{
|
||||
if (type == eXIFTag_text) {
|
||||
nsString& temp = aToken->GetStringValueXXX();
|
||||
|
||||
if (temp != "<xml version=\"1.0\"?>")
|
||||
{
|
||||
if (temp != "<xml version=\"1.0\"?>") {
|
||||
result= AddLeaf(node);
|
||||
}
|
||||
}
|
||||
|
@ -839,15 +820,13 @@ PRBool nsXIFDTD::IsHTMLContainer(eHTMLTags aTag) const {
|
|||
*
|
||||
*/
|
||||
|
||||
PRBool nsXIFDTD::GetAttribute(const nsIParserNode& aNode, const nsString& aKey, nsString& aValue)
|
||||
{
|
||||
PRBool nsXIFDTD::GetAttribute(const nsIParserNode& aNode, const nsString& aKey, nsString& aValue) {
|
||||
PRInt32 i;
|
||||
PRInt32 count = aNode.GetAttributeCount();
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
const nsString& key = aNode.GetKeyAt(i);
|
||||
if (key.Equals(aKey))
|
||||
{
|
||||
if (key.Equals(aKey)) {
|
||||
const nsString& value = aNode.GetValueAt(i);
|
||||
aValue = value;
|
||||
aValue.StripChars("\"");
|
||||
|
@ -898,53 +877,6 @@ PRBool nsXIFDTD::GetAttributePair(nsIParserNode& aNode, nsString& aKey, nsString
|
|||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @update gess12/28/98
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
eHTMLTags nsXIFDTD::GetHTMLTag(const nsString& aName)
|
||||
{
|
||||
eHTMLTags tag = nsHTMLTags::LookupTag(aName);
|
||||
return tag;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @update gess12/28/98
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
eHTMLTags nsXIFDTD::GetStartTag(const nsIParserNode& aNode, nsString& aName)
|
||||
{
|
||||
eXIFTags type = (eXIFTags)aNode.GetNodeType();
|
||||
eHTMLTags tag = eHTMLTag_unknown;
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case eXIFTag_container:
|
||||
case eXIFTag_leaf:
|
||||
if (GetAttribute(aNode,nsString("isa"),aName))
|
||||
tag = GetHTMLTag(aName);
|
||||
break;
|
||||
|
||||
case eXIFTag_css_stylesheet:
|
||||
aName = "style";
|
||||
tag = GetHTMLTag(aName);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return tag;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @update gess12/28/98
|
||||
|
@ -1083,27 +1015,29 @@ PRBool nsXIFDTD::StartTopOfStack()
|
|||
|
||||
/**
|
||||
*
|
||||
* @update gess12/28/98
|
||||
* @update gess 02/07/00
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
void nsXIFDTD::BeginStartTag(const nsIParserNode& aNode)
|
||||
{
|
||||
eXIFTags type = (eXIFTags)aNode.GetNodeType();
|
||||
eHTMLTags tag;
|
||||
nsString tagName;
|
||||
eHTMLTags tag = eHTMLTag_unknown;
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case eXIFTag_container:
|
||||
case eXIFTag_leaf:
|
||||
tag = GetStartTag(aNode,tagName);
|
||||
{
|
||||
nsAutoString tagName;
|
||||
if (GetAttribute(aNode,nsString("isa"),tagName))
|
||||
tag = nsHTMLTags::LookupTag(tagName);
|
||||
|
||||
if (type == eXIFTag_container)
|
||||
PushHTMLTag(tag,tagName);
|
||||
|
||||
// CToken* token = new CStartToken(tagName);
|
||||
// nsCParserNode* node = new nsCParserNode(token);
|
||||
PushNodeAndToken(tagName);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -1120,7 +1054,7 @@ void nsXIFDTD::AddEndTag(const nsIParserNode& aNode)
|
|||
PopHTMLTag(tag,name);
|
||||
|
||||
// Create a parse node for form this token
|
||||
CEndToken token(*name);
|
||||
CEndToken token(tag);
|
||||
nsCParserNode node(&token);
|
||||
|
||||
// close the container
|
||||
|
@ -1505,17 +1439,11 @@ void nsXIFDTD::BeginCSSStyleSheet(const nsIParserNode& aNode)
|
|||
mMaxCSSSelectorWidth = temp;
|
||||
}
|
||||
|
||||
//const char* name = nsHTMLTags::GetStringValue(eHTMLTag_html);
|
||||
}
|
||||
|
||||
void nsXIFDTD::EndCSSStyleSheet(const nsIParserNode& aNode)
|
||||
{
|
||||
nsString tagName(nsHTMLTags::GetStringValue(eHTMLTag_style));
|
||||
|
||||
if (mLowerCaseTags == PR_TRUE)
|
||||
tagName.ToLowerCase();
|
||||
else
|
||||
tagName.ToUpperCase();
|
||||
nsAutoString tagName("style");
|
||||
|
||||
CStartToken startToken(tagName);
|
||||
nsCParserNode startNode((CToken*)&startToken);
|
||||
|
|
|
@ -188,25 +188,6 @@ class nsXIFDTD : public nsIDTD {
|
|||
*/
|
||||
NS_IMETHOD HandleToken(CToken* aToken,nsIParser* aParser);
|
||||
|
||||
/**
|
||||
* This method causes all tokens to be dispatched to the given tag handler.
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param aHandler -- object to receive subsequent tokens...
|
||||
* @return error code (usually 0)
|
||||
*/
|
||||
NS_IMETHOD CaptureTokenPump(nsITagHandler* aHandler);
|
||||
|
||||
/**
|
||||
* This method releases the token-pump capture obtained in CaptureTokenPump()
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param aHandler -- object that received tokens...
|
||||
* @return error code (usually 0)
|
||||
*/
|
||||
NS_IMETHOD ReleaseTokenPump(nsITagHandler* aHandler);
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @update gpk 06/18/98
|
||||
|
@ -450,14 +431,12 @@ private:
|
|||
|
||||
|
||||
void AddAttribute(nsIParserNode& aNode);
|
||||
eHTMLTags GetHTMLTag(const nsString& aName);
|
||||
void PushHTMLTag(const eHTMLTags aTag, const nsString& aName);
|
||||
void PopHTMLTag(eHTMLTags& aTag, nsString*& aName);
|
||||
|
||||
PRBool GetAttributePair(nsIParserNode& aNode, nsString& aKey, nsString& aValue);
|
||||
PRBool GetAttribute(const nsIParserNode& aNode, const nsString& aKey, nsString& aValue);
|
||||
void BeginStartTag(const nsIParserNode& aNode);
|
||||
eHTMLTags GetStartTag(const nsIParserNode& aNode, nsString& aName);
|
||||
void AddEndTag(const nsIParserNode& aNode);
|
||||
void AddEndCommentTag(const nsIParserNode& aNode);
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
|
@ -89,91 +89,6 @@ static char gShowCRC;
|
|||
|
||||
|
||||
|
||||
/***************************************************************
|
||||
This the ITagHandler deque deallocator, needed by the
|
||||
CTagHandlerRegister
|
||||
***************************************************************/
|
||||
class CTagHandlerDeallocator: public nsDequeFunctor{
|
||||
public:
|
||||
virtual void* operator()(void* aObject) {
|
||||
nsITagHandler* tagHandler = (nsITagHandler*)aObject;
|
||||
delete tagHandler;
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
/***************************************************************
|
||||
This funtor will be called for each item in the TagHandler que to
|
||||
check for a Tag name, and setting the current TagHandler when it is reached
|
||||
***************************************************************/
|
||||
class CTagFinder: public nsDequeFunctor{
|
||||
|
||||
public:
|
||||
CTagFinder(){}
|
||||
void Initialize(const nsString &aTagName) {mTagName = aTagName;}
|
||||
|
||||
virtual ~CTagFinder() {
|
||||
}
|
||||
|
||||
virtual void* operator()(void* aObject) {
|
||||
nsString* theString = ((nsITagHandler*)aObject)->GetString();
|
||||
if( theString->Equals(mTagName)){
|
||||
return aObject;
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
nsAutoString mTagName;
|
||||
};
|
||||
|
||||
/***************************************************************
|
||||
This a an object that will keep track of TagHandlers in
|
||||
the DTD. Uses a factory pattern
|
||||
***************************************************************/
|
||||
class CTagHandlerRegister {
|
||||
public:
|
||||
|
||||
CTagHandlerRegister();
|
||||
|
||||
~CTagHandlerRegister();
|
||||
|
||||
void RegisterTagHandler(nsITagHandler *aTagHandler){
|
||||
mTagHandlerDeque.Push(aTagHandler);
|
||||
}
|
||||
|
||||
nsITagHandler* FindTagHandler(const nsString &aTagName){
|
||||
nsITagHandler* foundHandler = nsnull;
|
||||
|
||||
mTagFinder.Initialize(aTagName);
|
||||
mTagHandlerDeque.Begin();
|
||||
foundHandler = (nsITagHandler*) mTagHandlerDeque.FirstThat(mTagFinder);
|
||||
return foundHandler;
|
||||
}
|
||||
|
||||
nsDeque mTagHandlerDeque;
|
||||
CTagFinder mTagFinder;
|
||||
};
|
||||
|
||||
MOZ_DECL_CTOR_COUNTER(CTagHandlerRegister);
|
||||
|
||||
CTagHandlerRegister::CTagHandlerRegister() : mTagHandlerDeque(new CTagHandlerDeallocator())
|
||||
{
|
||||
MOZ_COUNT_CTOR(CTagHandlerRegister);
|
||||
}
|
||||
|
||||
CTagHandlerRegister::~CTagHandlerRegister()
|
||||
{
|
||||
MOZ_COUNT_DTOR(CTagHandlerRegister);
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
The CTagHandlerRegister for a CNavDTD.
|
||||
This is where special taghanders for our tags can be managed and called from
|
||||
Note: This can also be attached to some object so it can be refcounted
|
||||
and destroyed if you want this to go away when not imbedded.
|
||||
************************************************************************/
|
||||
//CTagHandlerRegister gTagHandlerRegister;
|
||||
|
||||
|
||||
/************************************************************************
|
||||
And now for the main class -- CNavDTD...
|
||||
|
@ -242,6 +157,8 @@ CNavDTD::CNavDTD() : nsIDTD(), mMisplacedContent(0), mSkippedContent(0), mShared
|
|||
mExpectedCRC32=0;
|
||||
mDTDState=NS_OK;
|
||||
mStyleHandlingEnabled=PR_TRUE;
|
||||
mIsText=PR_FALSE;
|
||||
mRequestedHead=PR_FALSE;
|
||||
|
||||
if(!gHTMLElements) {
|
||||
InitializeElementTable();
|
||||
|
@ -452,11 +369,23 @@ PRBool CNavDTD::Verify(nsString& aURLRef,nsIParser* aParser){
|
|||
*/
|
||||
eAutoDetectResult CNavDTD::CanParse(nsString& aContentType, nsString& aCommand, nsString& aBuffer, PRInt32 aVersion) {
|
||||
eAutoDetectResult result=eUnknownDetect;
|
||||
|
||||
if(!aCommand.Equals(kViewSourceCommand)) {
|
||||
|
||||
|
||||
if(aCommand.Equals(kViewSourceCommand)) {
|
||||
if(PR_TRUE==aContentType.Equals(kPlainTextContentType)) {
|
||||
result=ePrimaryDetect;
|
||||
}
|
||||
else if(aContentType.Equals(kRTFTextContentType)){
|
||||
result=ePrimaryDetect;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(PR_TRUE==aContentType.Equals(kHTMLTextContentType)) {
|
||||
result=ePrimaryDetect;
|
||||
}
|
||||
if(PR_TRUE==aContentType.Equals(kPlainTextContentType)) {
|
||||
result=ePrimaryDetect;
|
||||
}
|
||||
else {
|
||||
//otherwise, look into the buffer to see if you recognize anything...
|
||||
PRBool theBufHasXML=PR_FALSE;
|
||||
|
@ -492,6 +421,7 @@ nsresult CNavDTD::WillBuildModel(nsString& aFilename,
|
|||
mHasOpenScript=PR_FALSE;
|
||||
mParseMode=aParseMode;
|
||||
mStyleHandlingEnabled=(eParseMode_quirks==mParseMode);
|
||||
mRequestedHead=PR_FALSE;
|
||||
|
||||
if((aNotifySink) && (aSink)) {
|
||||
|
||||
|
@ -501,6 +431,8 @@ nsresult CNavDTD::WillBuildModel(nsString& aFilename,
|
|||
mTokenRecycler=0;
|
||||
mStyleHandlingEnabled=PR_TRUE;
|
||||
|
||||
mIsText=aSourceType.Equals(kPlainTextContentType) || aSourceType.Equals(kRTFTextContentType);
|
||||
|
||||
if(aSink && (!mSink)) {
|
||||
result=aSink->QueryInterface(kIHTMLContentSinkIID, (void **)&mSink);
|
||||
}
|
||||
|
@ -516,6 +448,7 @@ nsresult CNavDTD::WillBuildModel(nsString& aFilename,
|
|||
mExpectedCRC32=0;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -542,12 +475,17 @@ nsresult CNavDTD::BuildModel(nsIParser* aParser,nsITokenizer* aTokenizer,nsIToke
|
|||
mTokenRecycler=(CTokenRecycler*)mTokenizer->GetTokenRecycler();
|
||||
if(mSink) {
|
||||
|
||||
|
||||
|
||||
if(!mBodyContext->GetCount()) {
|
||||
//if the content model is empty, then begin by opening <html>...
|
||||
CStartToken *theToken=(CStartToken*)mTokenRecycler->CreateTokenOfType(eToken_start,eHTMLTag_html,"html");
|
||||
HandleStartToken(theToken); //this token should get pushed on the context stack, don't recycle it.
|
||||
|
||||
if(mIsText) {
|
||||
//we do this little trick for text files, in both normal and viewsource mode...
|
||||
CStartToken *theToken=(CStartToken*)mTokenRecycler->CreateTokenOfType(eToken_start,eHTMLTag_pre);
|
||||
HandleStartToken(theToken);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
while(NS_SUCCEEDED(result)){
|
||||
|
@ -883,30 +821,6 @@ nsresult CNavDTD::HandleToken(CToken* aToken,nsIParser* aParser){
|
|||
}//if
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method causes all tokens to be dispatched to the given tag handler.
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param aHandler -- object to receive subsequent tokens...
|
||||
* @return error code (usually 0)
|
||||
*/
|
||||
nsresult CNavDTD::CaptureTokenPump(nsITagHandler* aHandler) {
|
||||
nsresult result=NS_OK;
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method releases the token-pump capture obtained in CaptureTokenPump()
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param aHandler -- object that received tokens...
|
||||
* @return error code (usually 0)
|
||||
*/
|
||||
nsresult CNavDTD::ReleaseTokenPump(nsITagHandler* aHandler){
|
||||
nsresult result=NS_OK;
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* This gets called after we've handled a given start tag.
|
||||
|
@ -940,9 +854,9 @@ nsresult CNavDTD::DidHandleStartTag(nsCParserNode& aNode,eHTMLTags aChildTag){
|
|||
{
|
||||
STOP_TIMER()
|
||||
MOZ_TIMER_DEBUGLOG(("Stop: Parse Time: CNavDTD::DidHandleStartTag(), this=%p\n", this));
|
||||
const nsString& theText=aNode.GetSkippedContent();
|
||||
if(0<theText.Length()) {
|
||||
CViewSourceHTML::WriteText(theText,*mSink,PR_TRUE,PR_FALSE);
|
||||
const nsString& theString=aNode.GetSkippedContent();
|
||||
if(0<theString.Length()) {
|
||||
CViewSourceHTML::WriteText(theString,*mSink,PR_TRUE,PR_FALSE);
|
||||
}
|
||||
MOZ_TIMER_DEBUGLOG(("Start: Parse Time: CNavDTD::DidHandleStartTag(), this=%p\n", this));
|
||||
START_TIMER()
|
||||
|
@ -1105,22 +1019,27 @@ nsresult CNavDTD::HandleDefaultStartToken(CToken* aToken,eHTMLTags aChildTag,nsI
|
|||
if(theChildAgrees && theChildIsContainer) {
|
||||
if ((theParentTag!=aChildTag) && (!nsHTMLElement::IsResidualStyleTag(aChildTag))) {
|
||||
|
||||
PRInt32 theChildIndex=GetIndexOfChildOrSynonym(*mBodyContext,aChildTag);
|
||||
if(gHTMLElements[theParentTag].IsBlockEntity()) {
|
||||
PRInt32 theChildIndex=GetIndexOfChildOrSynonym(*mBodyContext,aChildTag);
|
||||
|
||||
if((kNotFound<theChildIndex) && (theChildIndex<theIndex)) {
|
||||
if((kNotFound<theChildIndex) && (theChildIndex<theIndex)) {
|
||||
|
||||
/*-------------------------------------------------------------------------------------
|
||||
Here's a tricky case from bug 22596: <h5><li><h5>
|
||||
/*-------------------------------------------------------------------------------------
|
||||
1. Here's a tricky case from bug 22596: <h5><li><h5>
|
||||
|
||||
How do we know that the 2nd <h5> should close the <LI> rather than nest inside the <LI>?
|
||||
(Afterall, the <h5> is a legal child of the <LI>).
|
||||
How do we know that the 2nd <h5> should close the <LI> rather than nest inside the <LI>?
|
||||
(Afterall, the <h5> is a legal child of the <LI>).
|
||||
|
||||
The way you know is that there is no root between the two, so the <h5> binds more
|
||||
tightly to the 1st <h5> than to the <LI>.
|
||||
-------------------------------------------------------------------------------------*/
|
||||
The way you know is that there is no root between the two, so the <h5> binds more
|
||||
tightly to the 1st <h5> than to the <LI>.
|
||||
|
||||
theChildAgrees=CanBeContained(aChildTag,*mBodyContext);
|
||||
} //if
|
||||
2. Also, bug 6148 shows this case: <SPAN><DIV><SPAN>
|
||||
From this case we learned not to execute this logic if the parent is a block.
|
||||
-------------------------------------------------------------------------------------*/
|
||||
|
||||
theChildAgrees=CanBeContained(aChildTag,*mBodyContext);
|
||||
} //if
|
||||
}//if
|
||||
} //if
|
||||
} //if
|
||||
} //if parentcontains
|
||||
|
@ -1417,6 +1336,7 @@ nsresult CNavDTD::HandleStartToken(CToken* aToken) {
|
|||
if(mHadBody || mHadFrameset) {
|
||||
result=HandleOmittedTag(aToken,theChildTag,theParent,theNode);
|
||||
isTokenHandled=PR_TRUE;
|
||||
mRequestedHead=PR_TRUE;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
@ -1457,7 +1377,7 @@ nsresult CNavDTD::HandleStartToken(CToken* aToken) {
|
|||
break;
|
||||
|
||||
case eHTMLTag_script:
|
||||
theHeadIsParent=(!mHasOpenBody);
|
||||
theHeadIsParent=((!mHasOpenBody) || mRequestedHead);
|
||||
mHasOpenScript=PR_TRUE;
|
||||
|
||||
default:
|
||||
|
@ -1645,6 +1565,7 @@ nsresult CNavDTD::HandleEndToken(CToken* aToken) {
|
|||
|
||||
case eHTMLTag_head:
|
||||
StripWSFollowingTag(theChildTag,mTokenizer,mTokenRecycler,mLineNumber);
|
||||
mRequestedHead=PR_FALSE;
|
||||
//ok to fall through...
|
||||
|
||||
case eHTMLTag_form:
|
||||
|
@ -2068,7 +1989,10 @@ nsresult CNavDTD::CollectSkippedContent(nsCParserNode& aNode,PRInt32 &aCount) {
|
|||
// XXX rickg This linefeed conversion stuff should be moved out of
|
||||
// the parser and into the form element code
|
||||
PRBool aMustConvertLinebreaks = PR_FALSE;
|
||||
|
||||
|
||||
mScratch.Truncate();
|
||||
aNode.SetSkippedContent(mScratch);
|
||||
|
||||
for(aIndex=0;aIndex<aMax;aIndex++){
|
||||
CHTMLToken* theNextToken=(CHTMLToken*)mSkippedContent.PopFront();
|
||||
|
||||
|
@ -2079,16 +2003,18 @@ nsresult CNavDTD::CollectSkippedContent(nsCParserNode& aNode,PRInt32 &aCount) {
|
|||
// the start token as mTrailing content and will get appended in
|
||||
// start token's GetSource();
|
||||
if(eToken_attribute!=theTokenType) {
|
||||
if((eHTMLTag_textarea==theNodeTag) && (eToken_entity==theTokenType)) {
|
||||
((CEntityToken*)theNextToken)->TranslateToUnicodeStr(mScratch);
|
||||
// since this is an entity, we know that it's only one character.
|
||||
// check to see if it's a CR, in which case we'll need to do line
|
||||
// termination conversion at the end.
|
||||
aMustConvertLinebreaks |= (mScratch[0] == kCR);
|
||||
if (eToken_entity==theTokenType) {
|
||||
if((eHTMLTag_textarea==theNodeTag) || (eHTMLTag_title==theNodeTag)) {
|
||||
((CEntityToken*)theNextToken)->TranslateToUnicodeStr(mScratch);
|
||||
// since this is an entity, we know that it's only one character.
|
||||
// check to see if it's a CR, in which case we'll need to do line
|
||||
// termination conversion at the end.
|
||||
aMustConvertLinebreaks |= (mScratch[0] == kCR);
|
||||
}
|
||||
}
|
||||
else theNextToken->GetSource(mScratch);
|
||||
|
||||
aNode.mSkippedContent+=mScratch;
|
||||
aNode.mSkippedContent->Append(mScratch);
|
||||
}
|
||||
mTokenRecycler->RecycleToken(theNextToken);
|
||||
}
|
||||
|
@ -2106,13 +2032,13 @@ nsresult CNavDTD::CollectSkippedContent(nsCParserNode& aNode,PRInt32 &aCount) {
|
|||
aNode.mSkippedContent.ReplaceChar("\r", kNewLine);
|
||||
*/
|
||||
#if 1
|
||||
nsLinebreakConverter::ConvertStringLineBreaks(aNode.mSkippedContent,
|
||||
nsLinebreakConverter::ConvertStringLineBreaks(*aNode.mSkippedContent,
|
||||
nsLinebreakConverter::eLinebreakAny, nsLinebreakConverter::eLinebreakContent);
|
||||
#endif
|
||||
}
|
||||
|
||||
// Let's hope that this does not hamper the PERFORMANCE!!
|
||||
mLineNumber += aNode.mSkippedContent.CountChar(kNewLine);
|
||||
mLineNumber += aNode.mSkippedContent->CountChar(kNewLine);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -2879,8 +2805,19 @@ CNavDTD::OpenContainer(const nsIParserNode *aNode,eHTMLTags aTag,PRBool aClosedB
|
|||
PRBool isDefaultNode=PR_FALSE;
|
||||
|
||||
|
||||
if (nsHTMLElement::IsResidualStyleTag(aTag))
|
||||
if (nsHTMLElement::IsResidualStyleTag(aTag)) {
|
||||
/***********************************************************************
|
||||
* Here's an interesting problem:
|
||||
*
|
||||
* If there's an <a> on the RS-stack, and you're trying to open
|
||||
* another <a>, the one on the RS-stack should be discarded.
|
||||
*
|
||||
* I'm updating OpenTransientStyles to throw old <a>'s away.
|
||||
*
|
||||
***********************************************************************/
|
||||
|
||||
OpenTransientStyles(aTag);
|
||||
}
|
||||
|
||||
#ifdef ENABLE_CRC
|
||||
#define K_OPENOP 100
|
||||
|
@ -3362,16 +3299,16 @@ nsresult CNavDTD::AddHeadLeaf(nsIParserNode *aNode){
|
|||
if(NS_OK==result) {
|
||||
if(eHTMLTag_title==theTag) {
|
||||
|
||||
///XXX this evil hack is necessary only for beta.
|
||||
//Post beta, lets make the GetSkippedContent() call non-const.
|
||||
|
||||
const nsString& theString=aNode->GetSkippedContent();
|
||||
nsString* theStr=(nsString*)&theString;
|
||||
theStr->CompressWhitespace();
|
||||
PRInt32 theLen=theString.Length();
|
||||
CBufDescriptor theBD(theString.GetUnicode(), PR_TRUE, theLen+1, theLen);
|
||||
nsAutoString theString2(theBD);
|
||||
|
||||
theString2.CompressWhitespace();
|
||||
|
||||
STOP_TIMER()
|
||||
MOZ_TIMER_DEBUGLOG(("Stop: Parse Time: CNavDTD::AddHeadLeaf(), this=%p\n", this));
|
||||
mSink->SetTitle(theString);
|
||||
mSink->SetTitle(theString2);
|
||||
MOZ_TIMER_DEBUGLOG(("Start: Parse Time: CNavDTD::AddHeadLeaf(), this=%p\n", this));
|
||||
START_TIMER()
|
||||
|
||||
|
@ -3454,7 +3391,7 @@ nsresult CNavDTD::CreateContextStackFor(eHTMLTags aChildTag){
|
|||
nsresult CNavDTD::GetTokenizer(nsITokenizer*& aTokenizer) {
|
||||
nsresult result=NS_OK;
|
||||
if(!mTokenizer) {
|
||||
result=NS_NewHTMLTokenizer(&mTokenizer,mParseMode,PR_FALSE);
|
||||
result=NS_NewHTMLTokenizer(&mTokenizer,mParseMode,mIsText);
|
||||
}
|
||||
aTokenizer=mTokenizer;
|
||||
return result;
|
||||
|
|
|
@ -90,6 +90,7 @@
|
|||
#include "nsVoidArray.h"
|
||||
#include "nsDeque.h"
|
||||
#include "nsParserCIID.h"
|
||||
#include "nsTime.h"
|
||||
|
||||
#define NS_INAVHTML_DTD_IID \
|
||||
{0x5c5cce40, 0xcfd6, 0x11d1, \
|
||||
|
@ -220,24 +221,6 @@ CLASS_EXPORT_HTMLPARS CNavDTD : public nsIDTD {
|
|||
*/
|
||||
NS_IMETHOD HandleToken(CToken* aToken,nsIParser* aParser);
|
||||
|
||||
/**
|
||||
* This method causes all tokens to be dispatched to the given tag handler.
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param aHandler -- object to receive subsequent tokens...
|
||||
* @return error code (usually 0)
|
||||
*/
|
||||
NS_IMETHOD CaptureTokenPump(nsITagHandler* aHandler);
|
||||
|
||||
/**
|
||||
* This method releases the token-pump capture obtained in CaptureTokenPump()
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param aHandler -- object that received tokens...
|
||||
* @return error code (usually 0)
|
||||
*/
|
||||
NS_IMETHOD ReleaseTokenPump(nsITagHandler* aHandler);
|
||||
|
||||
/**
|
||||
*
|
||||
* @update gess12/28/98
|
||||
|
@ -541,6 +524,8 @@ protected:
|
|||
PRUint32 mExpectedCRC32;
|
||||
nsAutoString mScratch; //used for various purposes; non-persistent
|
||||
PRBool mStyleHandlingEnabled;
|
||||
PRBool mIsText;
|
||||
PRBool mRequestedHead;
|
||||
|
||||
#ifdef NS_DEBUG
|
||||
PRInt32 gNodeCount;
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -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
|
||||
|
@ -22,47 +23,119 @@
|
|||
|
||||
/**
|
||||
* MODULE NOTES:
|
||||
* @update gess 4/8/98
|
||||
* @update gess 7/15/98
|
||||
*
|
||||
* NavDTD is an implementation of the nsIDTD interface.
|
||||
* In particular, this class captures the behaviors of the original
|
||||
* Navigator parser productions.
|
||||
*
|
||||
* This DTD, like any other in NGLayout, provides a few basic services:
|
||||
* - First, the DTD collaborates with the Parser class to convert plain
|
||||
* text into a sequence of HTMLTokens.
|
||||
* - Second, the DTD describes containment rules for known elements.
|
||||
* - Third the DTD controls and coordinates the interaction between the
|
||||
* parsing system and content sink. (The content sink is the interface
|
||||
* that serves as a proxy for content model).
|
||||
* - Fourth the DTD maintains an internal style-stack to handle residual (leaky)
|
||||
* style tags.
|
||||
*
|
||||
* You're most likely working in this class file because
|
||||
* you want to add or change a behavior inherent in this DTD. The remainder
|
||||
* of this section will describe what you need to do to affect the kind of
|
||||
* change you want in this DTD.
|
||||
*
|
||||
* RESIDUAL-STYLE HANDLNG:
|
||||
* There are a number of ways to represent style in an HTML document.
|
||||
* 1) explicit style tags (<B>, <I> etc)
|
||||
* 2) implicit styles (like those implicit in <Hn>)
|
||||
* 3) CSS based styles
|
||||
*
|
||||
* Residual style handling results from explicit style tags that are
|
||||
* not closed. Consider this example: <p>text <b>bold </p>
|
||||
* When the <p> tag closes, the <b> tag is NOT automatically closed.
|
||||
* Unclosed style tags are handled by the process we call residual-style
|
||||
* tag handling.
|
||||
*
|
||||
* There are two aspects to residual style tag handling. The first is the
|
||||
* construction and managing of a stack of residual style tags. The
|
||||
* second is the automatic emission of residual style tags onto leaf content
|
||||
* in subsequent portions of the document.This step is necessary to propagate
|
||||
* the expected style behavior to subsequent portions of the document.
|
||||
*
|
||||
* Construction and managing the residual style stack is an inline process that
|
||||
* occurs during the model building phase of the parse process. During the model-
|
||||
* building phase of the parse process, a content stack is maintained which tracks
|
||||
* the open container hierarchy. If a style tag(s) fails to be closed when a normal
|
||||
* container is closed, that style tag is placed onto the residual style stack. If
|
||||
* that style tag is subsequently closed (in most contexts), it is popped off the
|
||||
* residual style stack -- and are of no further concern.
|
||||
*
|
||||
* Residual style tag emission occurs when the style stack is not empty, and leaf
|
||||
* content occurs. In our earlier example, the <b> tag "leaked" out of the <p>
|
||||
* container. Just before the next leaf is emitted (in this or another container) the
|
||||
* style tags that are on the stack are emitted in succession. These same residual
|
||||
* style tags get closed automatically when the leaf's container closes, or if a
|
||||
* child container is opened.
|
||||
*
|
||||
*
|
||||
*/
|
||||
#ifndef NS_NAVHTMLDTD__
|
||||
#define NS_NAVHTMLDTD__
|
||||
|
||||
#ifndef NS_OTHERHTMLDTD__
|
||||
#define NS_OTHERHTMLDTD__
|
||||
|
||||
#include "CNavDTD.h"
|
||||
#include "nsIDTD.h"
|
||||
#include "nsISupports.h"
|
||||
#include "nsIParser.h"
|
||||
#include "nsHTMLTokens.h"
|
||||
#include "nshtmlpars.h"
|
||||
#include "nsVoidArray.h"
|
||||
#include "nsDeque.h"
|
||||
#include "nsParserCIID.h"
|
||||
|
||||
|
||||
#define NS_IOtherHTML_DTD_IID \
|
||||
#define NS_IOTHERHTML_DTD_IID \
|
||||
{0x8a5e89c0, 0xd16d, 0x11d1, \
|
||||
{0x80, 0x22, 0x00, 0x60, 0x8, 0x14, 0x98, 0x89}}
|
||||
|
||||
class nsIHTMLContentSink;
|
||||
class nsIDTDDebug;
|
||||
class nsIParserNode;
|
||||
class nsParser;
|
||||
class nsDTDContext;
|
||||
class nsEntryStack;
|
||||
class nsITokenizer;
|
||||
class nsCParserNode;
|
||||
class CTokenRecycler;
|
||||
|
||||
//class nsParser;
|
||||
//class nsIHTMLContentSink;
|
||||
/***************************************************************
|
||||
Now the main event: COtherDTD.
|
||||
|
||||
This not so simple class performs all the duties of token
|
||||
construction and model building. It works in conjunction with
|
||||
an nsParser.
|
||||
***************************************************************/
|
||||
|
||||
#if defined(XP_PC)
|
||||
#pragma warning( disable : 4275 )
|
||||
#endif
|
||||
|
||||
CLASS_EXPORT_HTMLPARS COtherDTD : public nsIDTD {
|
||||
|
||||
#if defined(XP_PC)
|
||||
#pragma warning( default : 4275 )
|
||||
#endif
|
||||
|
||||
class COtherDTD : public CNavDTD {
|
||||
|
||||
public:
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @update gess 4/9/98
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
* Common constructor for navdtd. You probably want to call
|
||||
* NS_NewNavHTMLDTD().
|
||||
*
|
||||
* @update gess 7/9/98
|
||||
*/
|
||||
COtherDTD();
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @update gess 4/9/98
|
||||
* @param
|
||||
* @return
|
||||
* Virtual destructor -- you know what to do
|
||||
* @update gess 7/9/98
|
||||
*/
|
||||
virtual ~COtherDTD();
|
||||
|
||||
|
@ -76,31 +149,106 @@ class COtherDTD : public CNavDTD {
|
|||
*/
|
||||
virtual nsresult CreateNewInstance(nsIDTD** aInstancePtrResult);
|
||||
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
/**
|
||||
* This method is called to determine if the given DTD can parse
|
||||
* a document in a given source-type.
|
||||
* NOTE: Parsing always assumes that the end result will involve
|
||||
* storing the result in the main content model.
|
||||
* @update gess6/24/98
|
||||
* @param
|
||||
* @return TRUE if this DTD can satisfy the request; FALSE otherwise.
|
||||
* a document of a given source-type.
|
||||
* Note that parsing assumes that the end result will always be stored
|
||||
* in the main content model. Of course, it's up to you which content-
|
||||
* model you pass in to the parser, so you can always control the process.
|
||||
*
|
||||
* @update gess 7/15/98
|
||||
* @param aContentType contains the name of a filetype that you are
|
||||
* being asked to parse).
|
||||
* @return TRUE if this DTD parse the given type; FALSE otherwise.
|
||||
*/
|
||||
virtual eAutoDetectResult CanParse(nsString& aContentType, nsString& aCommand, nsString& aBuffer, PRInt32 aVersion);
|
||||
|
||||
|
||||
/**
|
||||
* Called by the parser to initiate dtd verification of the
|
||||
* internal context stack.
|
||||
* @update gess 7/23/98
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
virtual PRBool Verify(nsString& aURLRef,nsIParser* aParser);
|
||||
|
||||
|
||||
/**
|
||||
* The parser uses a code sandwich to wrap the parsing process. Before
|
||||
* the process begins, WillBuildModel() is called. Afterwards the parser
|
||||
* calls DidBuildModel().
|
||||
* @update gess5/18/98
|
||||
* @param aFilename is the name of the file being parsed.
|
||||
* @return error code (almost always 0)
|
||||
*/
|
||||
NS_IMETHOD WillBuildModel( nsString& aFilename,
|
||||
PRBool aNotifySink,
|
||||
nsString& aSourceType,
|
||||
eParseMode aParseMode,
|
||||
nsString& aCommand,
|
||||
nsIContentSink* aSink=0);
|
||||
|
||||
/**
|
||||
* The parser uses a code sandwich to wrap the parsing process. Before
|
||||
* the process begins, WillBuildModel() is called. Afterwards the parser
|
||||
* calls DidBuildModel().
|
||||
* @update gess5/18/98
|
||||
* @param aFilename is the name of the file being parsed.
|
||||
* @return error code (almost always 0)
|
||||
*/
|
||||
NS_IMETHOD BuildModel(nsIParser* aParser,nsITokenizer* aTokenizer,nsITokenObserver* anObserver=0,nsIContentSink* aSink=0);
|
||||
|
||||
/**
|
||||
* The parser uses a code sandwich to wrap the parsing process. Before
|
||||
* the process begins, WillBuildModel() is called. Afterwards the parser
|
||||
* calls DidBuildModel().
|
||||
* @update gess5/18/98
|
||||
* @param anErrorCode contans the last error that occured
|
||||
* @return error code
|
||||
*/
|
||||
NS_IMETHOD DidBuildModel(nsresult anErrorCode,PRBool aNotifySink,nsIParser* aParser,nsIContentSink* aSink=0);
|
||||
|
||||
/**
|
||||
* This method is called by the parser, once for each token
|
||||
* that has been constructed during the tokenization phase.
|
||||
* @update gess 3/25/98
|
||||
* @param aToken -- token object to be put into content model
|
||||
* @return 0 if all is well; non-zero is an error
|
||||
*/
|
||||
NS_IMETHOD HandleToken(CToken* aToken,nsIParser* aParser);
|
||||
|
||||
/**
|
||||
*
|
||||
* @update gess5/18/98
|
||||
* @update gess12/28/98
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
NS_IMETHOD GetTokenizer(nsITokenizer*& aTokenizer);
|
||||
|
||||
/**
|
||||
*
|
||||
* @update gess12/28/98
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
virtual nsITokenRecycler* GetTokenRecycler(void);
|
||||
|
||||
/**
|
||||
* If the parse process gets interrupted, this method gets called
|
||||
* prior to the process resuming.
|
||||
* @update gess5/18/98
|
||||
* @return error code -- usually NS_OK (0)
|
||||
*/
|
||||
NS_IMETHOD WillResumeParse(void);
|
||||
|
||||
/**
|
||||
*
|
||||
* If the parse process is about to be interrupted, this method
|
||||
* will be called just prior.
|
||||
* @update gess5/18/98
|
||||
* @param
|
||||
* @return
|
||||
* @return error code -- usually NS_OK (0)
|
||||
*/
|
||||
NS_IMETHOD WillInterruptParse(void);
|
||||
|
||||
|
@ -115,103 +263,151 @@ class COtherDTD : public CNavDTD {
|
|||
*/
|
||||
virtual PRBool CanContain(PRInt32 aParent,PRInt32 aChild) const;
|
||||
|
||||
/**
|
||||
* This method is called to determine whether or not a tag
|
||||
* of one type can contain a tag of another type.
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param aParent -- int tag of parent container
|
||||
* @param aChild -- int tag of child container
|
||||
* @return PR_TRUE if parent can contain child
|
||||
*/
|
||||
virtual PRBool CanPropagate(eHTMLTags aParent,eHTMLTags aChild,PRBool aParentContains) ;
|
||||
|
||||
/**
|
||||
* This method gets called to determine whether a given
|
||||
* tag can contain newlines. Most do not.
|
||||
* child tag can be omitted by the given parent.
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param aParent -- parent tag being asked about omitting given child
|
||||
* @param aChild -- child tag being tested for omittability by parent
|
||||
* @param aParentContains -- can be 0,1,-1 (false,true, unknown)
|
||||
* @return PR_TRUE if given tag can be omitted
|
||||
*/
|
||||
virtual PRBool CanOmit(eHTMLTags aParent,eHTMLTags aChild,PRBool& aParentContains) ;
|
||||
|
||||
/**
|
||||
* This method gets called to determine whether a given
|
||||
* tag is itself a container
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param aTag -- tag to test for containership
|
||||
* @return PR_TRUE if given tag can contain other tags
|
||||
*/
|
||||
virtual PRBool CanOmit(eHTMLTags aParent,eHTMLTags aChild,PRBool& aParentContains) ;
|
||||
virtual PRBool IsContainer(PRInt32 aTag) const;
|
||||
|
||||
/**
|
||||
* This method tries to design a context map (without actually
|
||||
* changing our parser state) from the parent down to the
|
||||
* child.
|
||||
*
|
||||
* @update gess4/6/98
|
||||
* @param aParent -- tag type of parent
|
||||
* @param aChild -- tag type of child
|
||||
* @return True if closure was achieved -- other false
|
||||
*/
|
||||
virtual PRBool ForwardPropagate(nsString& aSequence,eHTMLTags aParentTag,eHTMLTags aChildTag);
|
||||
|
||||
/**
|
||||
* This method tries to design a context map (without actually
|
||||
* changing our parser state) from the child up to the parent.
|
||||
*
|
||||
* @update gess4/6/98
|
||||
* @param aParent -- tag type of parent
|
||||
* @param aChild -- tag type of child
|
||||
* @return True if closure was achieved -- other false
|
||||
*/
|
||||
virtual PRBool BackwardPropagate(nsString& aSequence,eHTMLTags aParentTag,eHTMLTags aChildTag) const;
|
||||
|
||||
/**
|
||||
* Attempt forward and/or backward propagation for the given
|
||||
* child within the current context vector stack.
|
||||
* @update gess5/11/98
|
||||
* @param type of child to be propagated.
|
||||
* @return TRUE if succeeds, otherwise FALSE
|
||||
*/
|
||||
nsresult CreateContextStackFor(eHTMLTags aChildTag);
|
||||
|
||||
/**
|
||||
* Ask parser if a given container is open ANYWHERE on stack
|
||||
* @update gess5/11/98
|
||||
* @param id of container you want to test for
|
||||
* @return TRUE if the given container type is open -- otherwise FALSE
|
||||
*/
|
||||
virtual PRBool HasOpenContainer(eHTMLTags aContainer) const;
|
||||
|
||||
/**
|
||||
* Ask parser if a given container is open ANYWHERE on stack
|
||||
* @update gess5/11/98
|
||||
* @param id of container you want to test for
|
||||
* @return TRUE if the given container type is open -- otherwise FALSE
|
||||
*/
|
||||
virtual PRBool HasOpenContainer(const eHTMLTags aTagSet[],PRInt32 aCount) const;
|
||||
|
||||
/**
|
||||
* Accessor that retrieves the tag type of the topmost item on context
|
||||
* vector stack.
|
||||
*
|
||||
* @update gess5/11/98
|
||||
* @return tag type (may be unknown)
|
||||
*/
|
||||
virtual eHTMLTags GetTopNode() const;
|
||||
|
||||
/**
|
||||
* Finds the topmost occurance of given tag within context vector stack.
|
||||
* @update gess5/11/98
|
||||
* @param tag to be found
|
||||
* @return index of topmost tag occurance -- may be -1 (kNotFound).
|
||||
*/
|
||||
// virtual PRInt32 GetTopmostIndexOf(eHTMLTags aTag) const;
|
||||
|
||||
/**
|
||||
* Finds the topmost occurance of given tag within context vector stack.
|
||||
* @update gess5/11/98
|
||||
* @param tag to be found
|
||||
* @return index of topmost tag occurance -- may be -1 (kNotFound).
|
||||
*/
|
||||
virtual PRInt32 LastOf(eHTMLTags aTagSet[],PRInt32 aCount) const;
|
||||
|
||||
/**
|
||||
* Use this id you want to stop the building content model
|
||||
* --------------[ Sets DTD to STOP mode ]----------------
|
||||
* It's recommended to use this method in accordance with
|
||||
* the parser's terminate() method.
|
||||
*
|
||||
* @update harishd 07/22/99
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
virtual nsresult Terminate(void) { return mDTDState=NS_ERROR_HTMLPARSER_STOPPARSING; }
|
||||
|
||||
/**
|
||||
* Give rest of world access to our tag enums, so that CanContain(), etc,
|
||||
* become useful.
|
||||
*/
|
||||
NS_IMETHOD StringTagToIntTag(nsString &aTag, PRInt32* aIntTag)const;
|
||||
NS_IMETHOD StringTagToIntTag(nsString &aTag, PRInt32* aIntTag) const;
|
||||
|
||||
NS_IMETHOD IntTagToStringTag(PRInt32 aIntTag, nsString& aTag) const;
|
||||
|
||||
NS_IMETHOD ConvertEntityToUnicode(const nsString& aEntity, PRInt32* aUnicode) const;
|
||||
|
||||
/**
|
||||
* This method gets called when a start token has been consumed and needs
|
||||
* to be handled (possibly added to content model via sink).
|
||||
* The following set of methods are used to partially construct
|
||||
* the content model (via the sink) according to the type of token.
|
||||
* @update gess5/11/98
|
||||
* @param aToken is the start token to be handled
|
||||
* @return TRUE if the token was handled.
|
||||
* @param aToken is the token (of a given type) to be handled
|
||||
* @return error code representing construction state; usually 0.
|
||||
*/
|
||||
nsresult HandleStartToken(CToken* aToken);
|
||||
|
||||
/**
|
||||
* This method gets called when a start token has been consumed, and
|
||||
* we want to use default start token handling behavior.
|
||||
* This method gets called automatically by handleStartToken.
|
||||
*
|
||||
* @update gess5/11/98
|
||||
* @param aToken is the start token to be handled
|
||||
* @param aChildTag is the tag-type of given token
|
||||
* @param aNode is a node be updated with info from given token
|
||||
* @return TRUE if the token was handled.
|
||||
*/
|
||||
nsresult HandleDefaultStartToken(CToken* aToken,eHTMLTags aChildTag,nsIParserNode *aNode);
|
||||
|
||||
/**
|
||||
* This method gets called when an end token has been consumed and needs
|
||||
* to be handled (possibly added to content model via sink).
|
||||
* @update gess5/11/98
|
||||
* @param aToken is the end token to be handled
|
||||
* @return TRUE if the token was handled.
|
||||
*/
|
||||
nsresult HandleEndToken(CToken* aToken);
|
||||
|
||||
/**
|
||||
* This method gets called when an entity token has been consumed and needs
|
||||
* to be handled (possibly added to content model via sink).
|
||||
* @update gess5/11/98
|
||||
* @param aToken is the entity token to be handled
|
||||
* @return TRUE if the token was handled.
|
||||
*/
|
||||
nsresult HandleEntityToken(CToken* aToken);
|
||||
|
||||
/**
|
||||
* This method gets called when a comment token has been consumed and needs
|
||||
* to be handled (possibly added to content model via sink).
|
||||
* @update gess5/11/98
|
||||
* @param aToken is the comment token to be handled
|
||||
* @return TRUE if the token was handled.
|
||||
*/
|
||||
nsresult HandleCommentToken(CToken* aToken);
|
||||
|
||||
/**
|
||||
* This method gets called when an attribute token has been consumed and needs
|
||||
* to be handled (possibly added to content model via sink).
|
||||
* @update gess5/11/98
|
||||
* @param aToken is the attribute token to be handled
|
||||
* @return TRUE if the token was handled.
|
||||
*/
|
||||
nsresult HandleAttributeToken(CToken* aToken);
|
||||
|
||||
/**
|
||||
* This method gets called when a script token has been consumed and needs
|
||||
* to be handled (possibly added to content model via sink).
|
||||
* @update gess5/11/98
|
||||
* @param aToken is the script token to be handled
|
||||
* @return TRUE if the token was handled.
|
||||
*/
|
||||
nsresult HandleScriptToken(const nsIParserNode *aNode);
|
||||
|
||||
/**
|
||||
* This method gets called when a style token has been consumed and needs
|
||||
* to be handled (possibly added to content model via sink).
|
||||
* @update gess5/11/98
|
||||
* @param aToken is the style token to be handled
|
||||
* @return TRUE if the token was handled.
|
||||
*/
|
||||
nsresult HandleStyleToken(CToken* aToken);
|
||||
|
||||
private:
|
||||
nsresult HandleStartToken(CToken* aToken);
|
||||
nsresult HandleDefaultStartToken(CToken* aToken,eHTMLTags aChildTag,nsIParserNode *aNode);
|
||||
nsresult HandleEndToken(CToken* aToken);
|
||||
nsresult HandleEntityToken(CToken* aToken);
|
||||
nsresult HandleCommentToken(CToken* aToken);
|
||||
nsresult HandleAttributeToken(CToken* aToken);
|
||||
nsresult HandleScriptToken(const nsIParserNode *aNode);
|
||||
nsresult HandleStyleToken(CToken* aToken);
|
||||
nsresult HandleProcessingInstructionToken(CToken* aToken);
|
||||
nsresult HandleDocTypeDeclToken(CToken* aToken);
|
||||
|
||||
|
||||
//*************************************************
|
||||
|
@ -233,7 +429,7 @@ private:
|
|||
nsresult OpenForm(const nsIParserNode *aNode);
|
||||
nsresult OpenMap(const nsIParserNode *aNode);
|
||||
nsresult OpenFrameset(const nsIParserNode *aNode);
|
||||
nsresult OpenContainer(const nsIParserNode *aNode,eHTMLTags aTag,PRBool aUpdateStyleStack,nsEntryStack* aStyleStack=0);
|
||||
nsresult OpenContainer(const nsIParserNode *aNode,eHTMLTags aTag,PRBool aClosedByStartTag,nsEntryStack* aStyleStack=0);
|
||||
|
||||
/**
|
||||
* The next set of methods close the given HTML element.
|
||||
|
@ -248,40 +444,97 @@ private:
|
|||
nsresult CloseForm(const nsIParserNode *aNode);
|
||||
nsresult CloseMap(const nsIParserNode *aNode);
|
||||
nsresult CloseFrameset(const nsIParserNode *aNode);
|
||||
|
||||
nsresult CloseContainer(const nsIParserNode *aNode,eHTMLTags aTarget,PRBool aUpdateStyles);
|
||||
nsresult CloseContainersTo(eHTMLTags aTag,PRBool aUpdateStyles);
|
||||
nsresult CloseContainersTo(PRInt32 anIndex,eHTMLTags aTarget,PRBool aUpdateStyles);
|
||||
|
||||
/**
|
||||
* The special purpose methods automatically close
|
||||
* one or more open containers.
|
||||
* @update gess5/11/98
|
||||
* @return error code - 0 if all went well.
|
||||
*/
|
||||
nsresult CloseContainer(const nsIParserNode *aNode,eHTMLTags aTarget,PRBool aClosedByStartTag);
|
||||
nsresult CloseContainersTo(eHTMLTags aTag,PRBool aClosedByStartTag);
|
||||
nsresult CloseContainersTo(PRInt32 anIndex,eHTMLTags aTag,PRBool aClosedByStartTag);
|
||||
|
||||
/**
|
||||
* Causes leaf to be added to sink at current vector pos.
|
||||
* @update gess5/11/98
|
||||
* @param aNode is leaf node to be added.
|
||||
* @return TRUE if all went well -- FALSE otherwise.
|
||||
* @return error code - 0 if all went well.
|
||||
*/
|
||||
nsresult AddLeaf(const nsIParserNode *aNode);
|
||||
|
||||
nsresult AddHeadLeaf(nsIParserNode *aNode);
|
||||
|
||||
/**
|
||||
* Attempt forward and/or backward propagation for the given
|
||||
* child within the current context vector stack.
|
||||
* This set of methods is used to create and manage the set of
|
||||
* transient styles that occur as a result of poorly formed HTML
|
||||
* or bugs in the original navigator.
|
||||
*
|
||||
* @update gess5/11/98
|
||||
* @param type of child to be propagated.
|
||||
* @return TRUE if succeeds, otherwise FALSE
|
||||
* @param aTag -- represents the transient style tag to be handled.
|
||||
* @return error code -- usually 0
|
||||
*/
|
||||
nsresult CreateContextStackFor(eHTMLTags aChildTag);
|
||||
nsresult OpenTransientStyles(eHTMLTags aChildTag);
|
||||
nsresult CloseTransientStyles(eHTMLTags aChildTag);
|
||||
nsresult PopStyle(eHTMLTags aTag);
|
||||
|
||||
nsresult OpenTransientStyles(eHTMLTags aTag);
|
||||
nsresult CloseTransientStyles(eHTMLTags aTag);
|
||||
nsresult PopStyle(eHTMLTags aTag);
|
||||
|
||||
nsresult DoFragment(PRBool aFlag);
|
||||
nsresult DoFragment(PRBool aFlag);
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
nsresult CollectAttributes(nsCParserNode& aNode,eHTMLTags aTag,PRInt32 aCount);
|
||||
nsresult CollectSkippedContent(nsCParserNode& aNode,PRInt32& aCount);
|
||||
nsresult WillHandleStartTag(CToken* aToken,eHTMLTags aChildTag,nsCParserNode& aNode);
|
||||
nsresult DidHandleStartTag(nsCParserNode& aNode,eHTMLTags aChildTag);
|
||||
nsresult HandleOmittedTag(CToken* aToken,eHTMLTags aChildTag,eHTMLTags aParent,nsIParserNode *aNode);
|
||||
nsresult HandleSavedTokens(PRInt32 anIndex);
|
||||
nsCParserNode* CreateNode(void);
|
||||
void RecycleNode(nsCParserNode* aNode);
|
||||
void RecycleNodes(nsEntryStack *aNodeStack);
|
||||
|
||||
nsIHTMLContentSink* mSink;
|
||||
|
||||
nsDTDContext* mHeadContext;
|
||||
nsDTDContext* mBodyContext;
|
||||
nsDTDContext* mFormContext;
|
||||
nsDTDContext* mMapContext;
|
||||
nsDTDContext* mTempContext;
|
||||
PRBool mHasOpenForm;
|
||||
PRBool mHasOpenMap;
|
||||
PRInt32 mHasOpenHead;
|
||||
PRBool mHasOpenBody;
|
||||
PRBool mHadFrameset;
|
||||
PRBool mHadBody;
|
||||
nsString mFilename;
|
||||
nsIDTDDebug* mDTDDebug;
|
||||
PRInt32 mLineNumber;
|
||||
nsParser* mParser;
|
||||
nsITokenizer* mTokenizer;
|
||||
CTokenRecycler* mTokenRecycler;
|
||||
nsDeque mMisplacedContent;
|
||||
nsDeque mSkippedContent;
|
||||
PRBool mHasOpenScript;
|
||||
PRBool mSaveBadTokens;
|
||||
eHTMLTags mSkipTarget;
|
||||
nsDeque mSharedNodes;
|
||||
nsresult mDTDState;
|
||||
eParseMode mParseMode;
|
||||
|
||||
PRUint32 mComputedCRC32;
|
||||
PRUint32 mExpectedCRC32;
|
||||
nsAutoString mScratch; //used for various purposes; non-persistent
|
||||
PRBool mStyleHandlingEnabled;
|
||||
PRBool mIsText;
|
||||
|
||||
#ifdef NS_DEBUG
|
||||
PRInt32 gNodeCount;
|
||||
#endif
|
||||
|
||||
};
|
||||
|
||||
extern NS_HTMLPARS nsresult NS_NewOtherHTMLDTD(nsIDTD** aInstancePtrResult);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -37,6 +37,7 @@
|
|||
#include "nshtmlpars.h"
|
||||
#include "nsVoidArray.h"
|
||||
#include "nsDeque.h"
|
||||
#include "nsToken.h"
|
||||
|
||||
#define NS_RTF_DTD_IID \
|
||||
{0xa39c6bfc, 0x15f0, 0x11d2, \
|
||||
|
@ -45,6 +46,7 @@
|
|||
class nsIParserNode;
|
||||
class nsParser;
|
||||
class nsITokenizer;
|
||||
class nsIHTMLContentSink;
|
||||
|
||||
enum eRTFTokenTypes {
|
||||
eRTFToken_unknown=0,
|
||||
|
@ -63,6 +65,8 @@ enum eRTFTags {
|
|||
eRTFCtrl_linefeed,
|
||||
eRTFCtrl_return,
|
||||
eRTFCtrl_begincontrol,
|
||||
eRTFCtrl_text,
|
||||
eRTFCtrl_ansi,
|
||||
eRTFCtrl_bold,
|
||||
eRTFCtrl_bin,
|
||||
eRTFCtrl_blue,
|
||||
|
@ -89,58 +93,43 @@ enum eRTFTags {
|
|||
eRTFCtrl_tab,
|
||||
eRTFCtrl_title,
|
||||
eRTFCtrl_underline,
|
||||
eRTFCtrl_startgroup,
|
||||
eRTFCtrl_endgroup,
|
||||
eRTFCtrl_startgroup, // {
|
||||
eRTFCtrl_endgroup, // }
|
||||
eRTFCtrl_last //make sure this stays the last token...
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* Represents the token of RTF. Always has form \xxxx<optarg>delimiter
|
||||
*
|
||||
* @update gess7/8/98
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
class CRTFControlWord : public CToken {
|
||||
public:
|
||||
CRTFControlWord(char* aKey);
|
||||
virtual PRInt32 GetTokenType();
|
||||
virtual nsresult Consume(PRUnichar aChar,nsScanner& aScanner,PRInt32 aMode);
|
||||
protected:
|
||||
nsString mArgument;
|
||||
CRTFControlWord(eRTFTags aTagID);
|
||||
virtual PRInt32 GetTokenType();
|
||||
virtual nsresult Consume(PRUnichar aChar,nsScanner& aScanner,PRInt32 aMode);
|
||||
|
||||
eRTFTags mTag;
|
||||
nsAutoString mArgument;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @update gess7/8/98
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
class CRTFGroup: public CToken {
|
||||
public:
|
||||
CRTFGroup(char* aKey,PRBool aStartGroup);
|
||||
virtual PRInt32 GetTokenType();
|
||||
virtual void SetGroupStart(PRBool aFlag);
|
||||
virtual PRBool IsGroupStart();
|
||||
virtual nsresult Consume(PRUnichar aChar,nsScanner& aScanner,PRInt32 aMode);
|
||||
protected:
|
||||
PRBool mStart;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* This represents the document content.
|
||||
*
|
||||
* @update gess7/8/98
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
class CRTFContent: public CToken {
|
||||
public:
|
||||
CRTFContent(PRUnichar* aValue);
|
||||
virtual PRInt32 GetTokenType();
|
||||
virtual nsresult Consume(PRUnichar aChar,nsScanner& aScanner,PRInt32 aMode);
|
||||
CRTFContent(PRUnichar* aKey=0);
|
||||
virtual PRInt32 GetTokenType();
|
||||
virtual nsresult Consume(PRUnichar aChar,nsScanner& aScanner,PRInt32 aMode);
|
||||
};
|
||||
|
||||
|
||||
|
@ -225,14 +214,6 @@ class CRtfDTD : public nsIDTD {
|
|||
*/
|
||||
NS_IMETHOD DidBuildModel(nsresult anErrorCode,PRInt32 aLevel,nsIParser* aParser,nsIContentSink* aSink=0);
|
||||
|
||||
/**
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param aToken -- token object to be put into content model
|
||||
* @return 0 if all is well; non-zero is an error
|
||||
*/
|
||||
NS_IMETHOD HandleGroup(CToken* aToken);
|
||||
|
||||
/**
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
|
@ -256,25 +237,6 @@ class CRtfDTD : public nsIDTD {
|
|||
* @return 0 if all is well; non-zero is an error
|
||||
*/
|
||||
NS_IMETHOD HandleToken(CToken* aToken,nsIParser* aParser);
|
||||
|
||||
/**
|
||||
* This method causes all tokens to be dispatched to the given tag handler.
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param aHandler -- object to receive subsequent tokens...
|
||||
* @return error code (usually 0)
|
||||
*/
|
||||
NS_IMETHOD CaptureTokenPump(nsITagHandler* aHandler);
|
||||
|
||||
/**
|
||||
* This method releases the token-pump capture obtained in CaptureTokenPump()
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param aHandler -- object that received tokens...
|
||||
* @return error code (usually 0)
|
||||
*/
|
||||
NS_IMETHOD ReleaseTokenPump(nsITagHandler* aHandler);
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -375,6 +337,18 @@ protected:
|
|||
nsParser* mParser;
|
||||
char* mFilename;
|
||||
nsITokenizer* mTokenizer;
|
||||
PRBool mHasHeader;
|
||||
nsDeque mGroups;
|
||||
PRInt32 mGroupCount;
|
||||
nsIHTMLContentSink* mSink;
|
||||
|
||||
private:
|
||||
nsresult PushGroup();
|
||||
nsresult PopGroup();
|
||||
nsresult OpenContainer(eHTMLTags aTag,const char* aTagName);
|
||||
nsresult CloseContainer(eHTMLTags aTag);
|
||||
nsresult AddLeafContainer(eHTMLTags aTag,const char* aTagName);
|
||||
nsresult EmitStyleContainer(CToken* aToken,eRTFTags aTag,PRBool aState);
|
||||
};
|
||||
|
||||
extern NS_HTMLPARS nsresult NS_NewRTF_DTD(nsIDTD** aInstancePtrResult);
|
||||
|
|
|
@ -193,6 +193,42 @@ void nsEntryStack::Append(nsEntryStack *aStack) {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @update gess 01/25/00
|
||||
*/
|
||||
nsIParserNode* nsEntryStack::Remove(eHTMLTags aTag) {
|
||||
nsIParserNode* result=0;
|
||||
|
||||
if(0<mCount) {
|
||||
result=mEntries[--mCount].mNode;
|
||||
|
||||
((nsCParserNode*)result)->mUseCount--;
|
||||
((nsCParserNode*)result)->mToken->mUseCount--;
|
||||
mEntries[mCount].mNode=0;
|
||||
mEntries[mCount].mStyles=0;
|
||||
|
||||
nsEntryStack* theStyleStack=mEntries[mCount].mParent;
|
||||
|
||||
if(theStyleStack) {
|
||||
//now we have to tell the residual style stack where this tag
|
||||
//originated that it's no longer in use.
|
||||
PRUint32 scount=theStyleStack->mCount;
|
||||
PRUint32 sindex=0;
|
||||
|
||||
nsTagEntry *theStyleEntry=theStyleStack->mEntries;
|
||||
for(sindex=scount-1;sindex>0;sindex--){
|
||||
if(theStyleEntry->mTag==mEntries[mCount].mTag) {
|
||||
theStyleEntry->mParent=0; //this tells us that the style is not open at any level
|
||||
break;
|
||||
}
|
||||
theStyleEntry++;
|
||||
} //for
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -558,6 +594,33 @@ nsIParserNode* nsDTDContext::PopStyle(eHTMLTags aTag){
|
|||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* This is similar to popstyle, except that it removes the
|
||||
* style tag given from anywhere in the style stack, and
|
||||
* not just at the top.
|
||||
*
|
||||
* @update gess 01/26/00
|
||||
*/
|
||||
nsIParserNode* nsDTDContext::RemoveStyle(eHTMLTags aTag){
|
||||
|
||||
PRInt32 theLevel=0;
|
||||
|
||||
for(theLevel=mStack.mCount-1;theLevel>0;theLevel--) {
|
||||
nsEntryStack *theStack=mStack.mEntries[theLevel].mStyles;
|
||||
if(theStack) {
|
||||
if(aTag==theStack->Last()) {
|
||||
return theStack->Pop();
|
||||
mResidualStyleCount--;
|
||||
} else {
|
||||
// NS_ERROR("bad residual style entry");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**************************************************************
|
||||
Now define the tokenrecycler class...
|
||||
**************************************************************/
|
||||
|
@ -732,7 +795,7 @@ void DebugDumpContainmentRules(nsIDTD& theDTD,const char* aFilename,const char*
|
|||
int i,j=0;
|
||||
int written;
|
||||
for(i=1;i<eHTMLTag_text;i++){
|
||||
const char* tag=nsHTMLTags::GetStringValue((eHTMLTags)i);
|
||||
const char* tag=nsHTMLTags::GetCStringValue((eHTMLTags)i);
|
||||
out << endl << endl << "Tag: <" << tag << ">" << endl;
|
||||
out << prefix;
|
||||
written=0;
|
||||
|
@ -743,7 +806,7 @@ void DebugDumpContainmentRules(nsIDTD& theDTD,const char* aFilename,const char*
|
|||
written=0;
|
||||
}
|
||||
if(theDTD.CanContain(i,j)){
|
||||
tag=nsHTMLTags::GetStringValue((eHTMLTags)j);
|
||||
tag=nsHTMLTags::GetCStringValue((eHTMLTags)j);
|
||||
if(tag) {
|
||||
out<< tag << ", ";
|
||||
written++;
|
||||
|
|
|
@ -77,6 +77,7 @@ public:
|
|||
void PushFront(const nsIParserNode* aNode,nsEntryStack* aStyleStack=0);
|
||||
void Append(nsEntryStack *theStack);
|
||||
nsIParserNode* Pop(void);
|
||||
nsIParserNode* Remove(eHTMLTags aTag);
|
||||
nsIParserNode* NodeAt(PRInt32 anIndex) const;
|
||||
eHTMLTags First() const;
|
||||
eHTMLTags TagAt(PRInt32 anIndex) const;
|
||||
|
@ -154,6 +155,7 @@ public:
|
|||
void PushStyles(nsEntryStack *theStyles);
|
||||
nsIParserNode* PopStyle(void);
|
||||
nsIParserNode* PopStyle(eHTMLTags aTag);
|
||||
nsIParserNode* RemoveStyle(eHTMLTags aTag);
|
||||
|
||||
nsEntryStack mStack; //this will hold a list of tagentries...
|
||||
PRInt32 mResidualStyleCount;
|
||||
|
|
|
@ -447,9 +447,9 @@ void InitializeElementTable(void) {
|
|||
Initialize(
|
||||
/*tag*/ eHTMLTag_dir,
|
||||
/*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown,
|
||||
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
|
||||
/*autoclose starttags and endtags*/ 0,0,0,0,
|
||||
/*parent,incl,exclgroups*/ kList, (kSelf|kFlowEntity), kNone,
|
||||
/*rootnodes,endrootnodes*/ &gOLRootTags,&gOLRootTags,
|
||||
/*autoclose starttags and endtags*/ &gOLAutoClose, &gULCloseTags, 0,0,
|
||||
/*parent,incl,exclgroups*/ kList, (kFlowEntity|kSelf), kNone,
|
||||
/*special props, prop-range*/ 0,kDefaultPropRange,
|
||||
/*special parents,kids,skip*/ 0,&gULKids,eHTMLTag_unknown);
|
||||
|
||||
|
@ -937,7 +937,7 @@ void InitializeElementTable(void) {
|
|||
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
|
||||
/*autoclose starttags and endtags*/ 0,0,0,0,
|
||||
/*parent,incl,exclgroups*/ kPreformatted, kFlowEntity, kNone, //I'm allowing WAY too much in here. Spec says inline.
|
||||
/*special props, prop-range*/ kNoStyleLeaksIn, kDefaultPropRange,
|
||||
/*special props, prop-range*/ 0, kDefaultPropRange,
|
||||
/*special parents,kids,skip*/ 0,&gPreKids,eHTMLTag_unknown);
|
||||
|
||||
Initialize(
|
||||
|
@ -1387,9 +1387,12 @@ PRBool nsHTMLElement::IsBlockCloser(eHTMLTags aTag){
|
|||
(kHeading==gHTMLElements[aTag].mParentBits));
|
||||
if(!result) {
|
||||
// NOBR is a block closure - Ref. Bug# 24462
|
||||
// DIR is a block closure -- Ref. Bug# 25845
|
||||
|
||||
static eHTMLTags gClosers[]={ eHTMLTag_table,eHTMLTag_tbody,eHTMLTag_caption,eHTMLTag_dd,eHTMLTag_dt,
|
||||
/* eHTMLTag_td,eHTMLTag_tfoot,eHTMLTag_th,eHTMLTag_thead,eHTMLTag_tr, */
|
||||
eHTMLTag_nobr,eHTMLTag_optgroup,eHTMLTag_ol,eHTMLTag_ul};
|
||||
eHTMLTag_nobr,eHTMLTag_optgroup,eHTMLTag_ol,eHTMLTag_ul,eHTMLTag_dir};
|
||||
|
||||
result=FindTagInSet(aTag,gClosers,sizeof(gClosers)/sizeof(eHTMLTag_body));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -516,30 +516,6 @@ NS_IMETHODIMP nsExpatDTD::HandleToken(CToken* aToken,nsIParser* aParser) {
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* This method causes all tokens to be dispatched to the given tag handler.
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param aHandler -- object to receive subsequent tokens...
|
||||
* @return error code (usually 0)
|
||||
*/
|
||||
nsresult nsExpatDTD::CaptureTokenPump(nsITagHandler* aHandler) {
|
||||
nsresult result=NS_OK;
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method releases the token-pump capture obtained in CaptureTokenPump()
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param aHandler -- object that received tokens...
|
||||
* @return error code (usually 0)
|
||||
*/
|
||||
nsresult nsExpatDTD::ReleaseTokenPump(nsITagHandler* aHandler){
|
||||
nsresult result=NS_OK;
|
||||
return result;
|
||||
}
|
||||
|
||||
nsresult nsExpatDTD::ParseXMLBuffer(const char *buffer){
|
||||
nsresult result=NS_OK;
|
||||
if (mExpatParser) {
|
||||
|
|
|
@ -141,24 +141,6 @@ class nsExpatDTD : public nsIDTD {
|
|||
*/
|
||||
NS_IMETHOD HandleToken(CToken* aToken,nsIParser* aParser);
|
||||
|
||||
/**
|
||||
* This method causes all tokens to be dispatched to the given tag handler.
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param aHandler -- object to receive subsequent tokens...
|
||||
* @return error code (usually 0)
|
||||
*/
|
||||
NS_IMETHOD CaptureTokenPump(nsITagHandler* aHandler);
|
||||
|
||||
/**
|
||||
* This method releases the token-pump capture obtained in CaptureTokenPump()
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param aHandler -- object that received tokens...
|
||||
* @return error code (usually 0)
|
||||
*/
|
||||
NS_IMETHOD ReleaseTokenPump(nsITagHandler* aHandler);
|
||||
|
||||
/**
|
||||
*
|
||||
* @update gess12/28/98
|
||||
|
|
|
@ -150,6 +150,17 @@ nsHTMLTags::GetStringValue(nsHTMLTag aTag)
|
|||
}
|
||||
}
|
||||
|
||||
const char* nsHTMLTags::GetCStringValue(nsHTMLTag aTag) {
|
||||
NS_ASSERTION(gTagArray, "no lookup table, needs addref");
|
||||
if ((eHTMLTag_unknown < aTag) &&
|
||||
(aTag < NS_HTML_TAG_MAX) && gTagArray) {
|
||||
return gTagArray[aTag - 1].mStr.mStr;
|
||||
}
|
||||
else {
|
||||
static const char* kNullStr="";
|
||||
return kNullStr;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#ifdef NS_DEBUG
|
||||
|
|
|
@ -57,6 +57,7 @@ public:
|
|||
|
||||
static nsHTMLTag LookupTag(const nsStr& aTag);
|
||||
static const nsCString& GetStringValue(nsHTMLTag aEnum);
|
||||
static const char* GetCStringValue(nsHTMLTag aEnum);
|
||||
};
|
||||
|
||||
#endif /* nsHTMLTags_h___ */
|
||||
|
|
|
@ -53,7 +53,7 @@ static NS_DEFINE_CID(kCharsetConverterManagerCID, NS_ICHARSETCONVERTERMANAGER_CI
|
|||
|
||||
const PRInt32 gTabSize=4;
|
||||
const PRInt32 gOLNumberWidth = 3;
|
||||
const PRInt32 gIndentSizeList = MaxInt(gTabSize, gOLNumberWidth + 3);
|
||||
const PRInt32 gIndentSizeList = (gTabSize<gOLNumberWidth+3) ? gTabSize: gOLNumberWidth+3;
|
||||
// Indention of non-first lines of ul and ol
|
||||
|
||||
static PRBool IsInline(eHTMLTags aTag);
|
||||
|
@ -759,13 +759,7 @@ nsHTMLToTXTSinkStream::AddLeaf(const nsIParserNode& aNode)
|
|||
printf(" '%s' ", text.ToNewCString());
|
||||
#endif
|
||||
|
||||
if (mTagStackIndex > 1 && mTagStack[mTagStackIndex-2] == eHTMLTag_select)
|
||||
{
|
||||
// Don't output the contents of SELECT elements;
|
||||
// Might be nice, eventually, to output just the selected element.
|
||||
return NS_OK;
|
||||
}
|
||||
else if (type == eHTMLTag_text)
|
||||
if (type == eHTMLTag_text)
|
||||
{
|
||||
Write(text);
|
||||
}
|
||||
|
|
|
@ -490,7 +490,7 @@ nsresult nsHTMLTokenizer::ConsumeStartTag(PRUnichar aChar,CToken*& aToken,nsScan
|
|||
aToken=theRecycler->CreateTokenOfType(eToken_start,eHTMLTag_unknown);
|
||||
|
||||
if(aToken) {
|
||||
result= aToken->Consume(aChar,aScanner,mParseMode); //tell new token to finish consuming text...
|
||||
result= aToken->Consume(aChar,aScanner,mPlainText); //tell new token to finish consuming text...
|
||||
if(NS_SUCCEEDED(result)) {
|
||||
|
||||
AddToken(aToken,result,&mTokenDeque,theRecycler);
|
||||
|
|
|
@ -77,6 +77,22 @@ void CHTMLToken::SetStringValue(const char* name){
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This method retrieves the value of this internal string.
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @return nsString reference to internal string value
|
||||
*/
|
||||
nsString& CHTMLToken::GetStringValueXXX(void) {
|
||||
if((eHTMLTag_unknown<mTypeID) && (eHTMLTag_userdefined!=mTypeID)) {
|
||||
if(!mTextValue.Length()) {
|
||||
mTextValue = nsHTMLTags::GetStringValue((nsHTMLTag) mTypeID);
|
||||
}
|
||||
}
|
||||
return mTextValue;
|
||||
}
|
||||
|
||||
/*
|
||||
* constructor from tag id
|
||||
*
|
||||
|
@ -97,12 +113,15 @@ CStartToken::CStartToken(eHTMLTags aTag) : CHTMLToken(aTag) {
|
|||
* @param
|
||||
* @return
|
||||
*/
|
||||
CStartToken::CStartToken(nsString& aString,eHTMLTags aTag) : CHTMLToken(aString,aTag) {
|
||||
CStartToken::CStartToken(const nsString& aString) : CHTMLToken(aString) {
|
||||
mAttributed=PR_FALSE;
|
||||
mEmpty=PR_FALSE;
|
||||
mOrigin=-1;
|
||||
}
|
||||
|
||||
CStartToken::CStartToken(const nsString& aName,eHTMLTags aTag) : CHTMLToken(aName,aTag) {
|
||||
mTypeID=aTag;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -206,6 +225,7 @@ PRBool CStartToken::IsEmpty(void) {
|
|||
* @update gess 3/25/98
|
||||
* @param aChar -- last char consumed from stream
|
||||
* @param aScanner -- controller of underlying input source
|
||||
* @param aMode -- 0=HTML; 1=text;
|
||||
* @return error result
|
||||
*/
|
||||
nsresult CStartToken::Consume(PRUnichar aChar, nsScanner& aScanner,PRInt32 aMode) {
|
||||
|
@ -215,9 +235,20 @@ nsresult CStartToken::Consume(PRUnichar aChar, nsScanner& aScanner,PRInt32 aMode
|
|||
//Stop consuming as soon as you see a space or a '>'.
|
||||
//NOTE: We don't Consume the tag attributes here, nor do we eat the ">"
|
||||
|
||||
mTextValue=aChar;
|
||||
nsresult result=aScanner.ReadIdentifier(mTextValue);
|
||||
mTypeID = nsHTMLTags::LookupTag(mTextValue);
|
||||
nsresult result=NS_OK;
|
||||
if(0==aMode) {
|
||||
nsSubsumeStr theSubstr;
|
||||
result=aScanner.GetIdentifier(theSubstr);
|
||||
mTypeID = (PRInt32)nsHTMLTags::LookupTag(theSubstr);
|
||||
if(eHTMLTag_userdefined==mTypeID) {
|
||||
mTextValue=theSubstr;
|
||||
}
|
||||
}
|
||||
else {
|
||||
mTextValue=aChar;
|
||||
nsresult result=aScanner.ReadIdentifier(mTextValue);
|
||||
mTypeID = nsHTMLTags::LookupTag(mTextValue);
|
||||
}
|
||||
|
||||
//Good. Now, let's skip whitespace after the identifier,
|
||||
//and see if the next char is ">". If so, we have a complete
|
||||
|
|
|
@ -101,6 +101,7 @@ public:
|
|||
CHTMLToken(eHTMLTags aTag);
|
||||
CHTMLToken(const nsString& aString,eHTMLTags aTag=eHTMLTag_unknown);
|
||||
virtual void SetStringValue(const char* name);
|
||||
virtual nsString& GetStringValueXXX(void);
|
||||
|
||||
protected:
|
||||
};
|
||||
|
@ -113,8 +114,10 @@ protected:
|
|||
*/
|
||||
class CStartToken: public CHTMLToken {
|
||||
public:
|
||||
CStartToken(eHTMLTags aTag);
|
||||
CStartToken(nsString& aName,eHTMLTags aTag=eHTMLTag_unknown);
|
||||
CStartToken(eHTMLTags aTag=eHTMLTag_unknown);
|
||||
CStartToken(const nsString& aString);
|
||||
CStartToken(const nsString& aName,eHTMLTags aTag);
|
||||
|
||||
virtual nsresult Consume(PRUnichar aChar,nsScanner& aScanner,PRInt32 aMode);
|
||||
virtual PRInt32 GetTypeID(void);
|
||||
virtual const char* GetClassName(void);
|
||||
|
|
|
@ -64,7 +64,6 @@ class CToken;
|
|||
class nsIDTDDebug;
|
||||
class nsIURI;
|
||||
class nsString;
|
||||
class nsITagHandler;
|
||||
class nsIContentSink;
|
||||
|
||||
|
||||
|
@ -151,24 +150,6 @@ class nsIDTD : public nsISupports {
|
|||
|
||||
virtual nsITokenRecycler* GetTokenRecycler(void)=0;
|
||||
|
||||
/**
|
||||
* This method causes all tokens to be dispatched to the given tag handler.
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param aHandler -- object to receive subsequent tokens...
|
||||
* @return error code (usually 0)
|
||||
*/
|
||||
NS_IMETHOD CaptureTokenPump(nsITagHandler* aHandler)=0;
|
||||
|
||||
/**
|
||||
* This method releases the token-pump capture obtained in CaptureTokenPump()
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param aHandler -- object that received tokens...
|
||||
* @return error code (usually 0)
|
||||
*/
|
||||
NS_IMETHOD ReleaseTokenPump(nsITagHandler* aHandler)=0;
|
||||
|
||||
/**
|
||||
* If the parse process gets interrupted midway, this method is called by the
|
||||
* parser prior to resuming the process.
|
||||
|
|
|
@ -275,5 +275,5 @@ const PRUnichar kNullCh = '\0';
|
|||
#define kPlainTextContentType "text/plain"
|
||||
#define kViewSourceCommand "view-source"
|
||||
#define kTextCSSContentType "text/css"
|
||||
|
||||
#define kRTFTextContentType "text/rtf"
|
||||
#endif
|
||||
|
|
|
@ -41,6 +41,7 @@
|
|||
#include "nsIChannel.h"
|
||||
#include "nsIProgressEventSink.h"
|
||||
#include "nsIBufferInputStream.h"
|
||||
#include "CRTFDTD.h"
|
||||
|
||||
//#define rickgdebug
|
||||
|
||||
|
@ -98,7 +99,7 @@ public:
|
|||
mDTDDeque.Push(theDTD);
|
||||
|
||||
mHasViewSourceDTD=PR_FALSE;
|
||||
mHasXMLDTD=PR_FALSE;
|
||||
mHasRTFDTD=mHasXMLDTD=PR_FALSE;
|
||||
}
|
||||
|
||||
~CSharedParserObjects() {
|
||||
|
@ -122,6 +123,7 @@ public:
|
|||
nsDeque mDTDDeque;
|
||||
PRBool mHasViewSourceDTD; //this allows us to defer construction of this object.
|
||||
PRBool mHasXMLDTD; //also defer XML dtd construction
|
||||
PRBool mHasRTFDTD; //also defer RTF dtd construction
|
||||
};
|
||||
|
||||
static CSharedParserObjects* gSharedParserObjects=0;
|
||||
|
@ -415,6 +417,10 @@ PRBool FindSuitableDTD( CParserContext& aParserContext,nsString& aCommand,nsStri
|
|||
|
||||
CSharedParserObjects& gSharedObjects=GetSharedObjects();
|
||||
|
||||
#if 0
|
||||
aParserContext.mSourceType="text/rtf";
|
||||
#endif
|
||||
|
||||
aParserContext.mAutoDetectStatus=eUnknownDetect;
|
||||
PRInt32 theDTDIndex=0;
|
||||
nsIDTD* theBestDTD=0;
|
||||
|
@ -444,6 +450,11 @@ PRBool FindSuitableDTD( CParserContext& aParserContext,nsString& aCommand,nsStri
|
|||
gSharedObjects.mDTDDeque.Push(theDTD);
|
||||
gSharedObjects.mHasViewSourceDTD=PR_TRUE;
|
||||
}
|
||||
else if(!gSharedObjects.mHasRTFDTD) {
|
||||
NS_NewRTF_DTD(&theDTD); //do this so all non-html files can be viewed...
|
||||
gSharedObjects.mDTDDeque.Push(theDTD);
|
||||
gSharedObjects.mHasRTFDTD=PR_TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -471,54 +482,48 @@ eParseMode DetermineParseMode(nsParser& aParser) {
|
|||
eParseMode result=eParseMode_unknown;
|
||||
nsScanner* theScanner=aParser.GetScanner();
|
||||
if(theScanner){
|
||||
nsAutoString theBufCopy;
|
||||
nsString& theBuffer=theScanner->GetBuffer();
|
||||
theBuffer.Left(theBufCopy,125);
|
||||
PRInt32 theIndex=theBufCopy.Find("<!");
|
||||
theIndex=(theIndex!=kNotFound)? theIndex=theBufCopy.Find("DOCTYPE",PR_TRUE,2):kNotFound;
|
||||
|
||||
PRInt32 theIndex=theBuffer.Find("<!",PR_FALSE,-1);
|
||||
if(kNotFound<theIndex)
|
||||
theIndex=theBuffer.Find("DOCTYPE",PR_TRUE,theIndex+1,10);
|
||||
|
||||
if(kNotFound<theIndex) {
|
||||
//good, we found "DOCTYPE" -- now go find it's end delimiter '>'
|
||||
theBufCopy.StripWhitespace();
|
||||
PRInt32 theSubIndex=theBufCopy.FindChar(kGreaterThan,theIndex+1);
|
||||
theBufCopy.Truncate(theSubIndex);
|
||||
theSubIndex=theBufCopy.Find("-//W3C//DTD",PR_TRUE,theIndex+8);
|
||||
PRInt32 theEnd=theBuffer.FindChar(kGreaterThan,theIndex+1);
|
||||
PRInt32 theSubIndex=theBuffer.Find("-//W3C//DTD",PR_TRUE,theIndex+8,theEnd-(theIndex+8));
|
||||
if(kNotFound<theSubIndex) {
|
||||
if(kNotFound<(theSubIndex=theBufCopy.Find("HTML4.0",PR_TRUE,theSubIndex+11))) {
|
||||
PRUnichar num=theBufCopy.CharAt(theSubIndex+7);
|
||||
if(num > '0' && num < '9') {
|
||||
result=eParseMode_noquirks; // XXX - investigate this more.
|
||||
}
|
||||
else if((theBufCopy.Find("TRANSITIONAL",PR_TRUE,theSubIndex+7)>kNotFound)||
|
||||
(theBufCopy.Find("FRAMESET",PR_TRUE,theSubIndex+7)>kNotFound) ||
|
||||
(theBufCopy.Find("LATIN1", PR_TRUE,theSubIndex+7) >kNotFound) ||
|
||||
(theBufCopy.Find("SYMBOLS",PR_TRUE,theSubIndex+7) >kNotFound) ||
|
||||
(theBufCopy.Find("SPECIAL",PR_TRUE,theSubIndex+7) >kNotFound))
|
||||
if(kNotFound<(theSubIndex=theBuffer.Find("HTML 4",PR_TRUE,theSubIndex+11,theEnd-(theSubIndex+11)))) {
|
||||
if((theBuffer.Find("TRANSITIONAL",PR_TRUE,theSubIndex+7)>kNotFound)||
|
||||
(theBuffer.Find("FRAMESET",PR_TRUE,theSubIndex+7)>kNotFound) ||
|
||||
(theBuffer.Find("LATIN1", PR_TRUE,theSubIndex+7) >kNotFound) ||
|
||||
(theBuffer.Find("SYMBOLS",PR_TRUE,theSubIndex+7) >kNotFound) ||
|
||||
(theBuffer.Find("SPECIAL",PR_TRUE,theSubIndex+7) >kNotFound))
|
||||
result=eParseMode_quirks; // XXX -HACK- Set the appropriate mode.
|
||||
else
|
||||
result=eParseMode_noquirks;
|
||||
}
|
||||
else if(kNotFound<(theSubIndex=theBufCopy.Find("XHTML",PR_TRUE,theSubIndex+11))) {
|
||||
if((theBufCopy.Find("TRANSITIONAL",PR_TRUE,theSubIndex)>kNotFound)||
|
||||
(theBufCopy.Find("STRICT",PR_TRUE,theSubIndex) >kNotFound) ||
|
||||
(theBufCopy.Find("FRAMESET",PR_TRUE,theSubIndex) >kNotFound))
|
||||
else if(kNotFound<(theSubIndex=theBuffer.Find("XHTML",PR_TRUE,theSubIndex+11))) {
|
||||
if((theBuffer.Find("TRANSITIONAL",PR_TRUE,theSubIndex)>kNotFound)||
|
||||
(theBuffer.Find("STRICT",PR_TRUE,theSubIndex) >kNotFound) ||
|
||||
(theBuffer.Find("FRAMESET",PR_TRUE,theSubIndex) >kNotFound))
|
||||
result=eParseMode_noquirks;
|
||||
else
|
||||
result=eParseMode_quirks;
|
||||
}
|
||||
}
|
||||
else if(kNotFound<(theSubIndex=theBufCopy.Find("ISO/IEC15445:1999",PR_TRUE,theIndex+8))) {
|
||||
theSubIndex=theBufCopy.Find("HTML",PR_TRUE,theSubIndex+18);
|
||||
else if(kNotFound<(theSubIndex=theBuffer.Find("ISO/IEC15445:1999",PR_TRUE,theIndex+8))) {
|
||||
theSubIndex=theBuffer.Find("HTML",PR_TRUE,theSubIndex+18);
|
||||
if(kNotFound==theSubIndex)
|
||||
theSubIndex=theBufCopy.Find("HYPERTEXTMARKUPLANGUAGE",PR_TRUE,theSubIndex+18);
|
||||
theSubIndex=theBuffer.Find("HYPERTEXTMARKUPLANGUAGE",PR_TRUE,theSubIndex+18);
|
||||
result=eParseMode_noquirks;
|
||||
}
|
||||
}
|
||||
else if(kNotFound<(theIndex=theBufCopy.Find("?XML",PR_TRUE))) {
|
||||
else if(kNotFound<(theIndex=theBuffer.Find("?XML",PR_TRUE))) {
|
||||
result=eParseMode_noquirks;
|
||||
}
|
||||
else {
|
||||
theIndex=theBufCopy.Find("NOQUIRKS",PR_TRUE);
|
||||
theIndex=theBuffer.Find("NOQUIRKS",PR_TRUE);
|
||||
if(kNotFound<theIndex) {
|
||||
result=eParseMode_noquirks;
|
||||
}
|
||||
|
@ -935,7 +940,7 @@ nsresult nsParser::ParseFragment(const nsString& aSourceBuffer,void* aKey,nsITag
|
|||
theBuffer.Append("<title>title</title><a href=\"one\">link</a>");
|
||||
#else
|
||||
//this is the normal code path for paste...
|
||||
theBuffer.Append(aSourceBuffer);
|
||||
theBuffer.Append(aSourceBuffer);
|
||||
#endif
|
||||
|
||||
if(theBuffer.Length()){
|
||||
|
@ -1389,10 +1394,11 @@ nsresult nsParser::OnStopRequest(nsIChannel* channel, nsISupports* aContext,
|
|||
nsresult result=NS_OK;
|
||||
|
||||
if(eOnStart==mParserContext->mStreamListenerState) {
|
||||
|
||||
//If you're here, then OnDataAvailable() never got called.
|
||||
//Prior to necko, we never dealt with this case, but the problem may have existed.
|
||||
//What we'll do (for now at least) is construct the worlds smallest HTML document.
|
||||
nsAutoString temp("<BODY></BODY>");
|
||||
//What we'll do (for now at least) is construct a blank HTML document.
|
||||
nsAutoString temp("<html><body></body></html>");
|
||||
mParserContext->mScanner->Append(temp);
|
||||
result=ResumeParse(nsnull, PR_TRUE);
|
||||
}
|
||||
|
@ -1484,7 +1490,8 @@ nsresult nsParser::Tokenize(PRBool aIsFinalChunk){
|
|||
else if(NS_ERROR_HTMLPARSER_STOPPARSING==result)
|
||||
return Terminate();
|
||||
}
|
||||
else if(flushTokens) {
|
||||
else if(flushTokens && mObserversEnabled) {
|
||||
// I added the extra test of mObserversEnabled to fix Bug# 23931.
|
||||
// Flush tokens on seeing </SCRIPT> -- Ref: Bug# 22485 --
|
||||
// Also remember to update the marked position.
|
||||
mParserContext->mScanner->Mark();
|
||||
|
|
|
@ -47,7 +47,7 @@ nsString& GetEmptyString() {
|
|||
* @return
|
||||
*/
|
||||
nsCParserNode::nsCParserNode(CToken* aToken,PRInt32 aLineNumber,nsITokenRecycler* aRecycler):
|
||||
nsIParserNode(), mSkippedContent("") {
|
||||
nsIParserNode() {
|
||||
NS_INIT_REFCNT();
|
||||
|
||||
static int theNodeCount=0;
|
||||
|
@ -57,6 +57,7 @@ nsCParserNode::nsCParserNode(CToken* aToken,PRInt32 aLineNumber,nsITokenRecycler
|
|||
mToken=aToken;
|
||||
mRecycler=aRecycler;
|
||||
mUseCount=0;
|
||||
mSkippedContent=0;
|
||||
}
|
||||
|
||||
static void RecycleTokens(nsITokenRecycler* aRecycler,nsDeque& aDeque) {
|
||||
|
@ -89,6 +90,10 @@ nsCParserNode::~nsCParserNode() {
|
|||
delete mAttributes;
|
||||
mAttributes=0;
|
||||
}
|
||||
if(mSkippedContent) {
|
||||
delete mSkippedContent;
|
||||
}
|
||||
mSkippedContent=0;
|
||||
}
|
||||
|
||||
|
||||
|
@ -110,7 +115,9 @@ nsresult nsCParserNode::Init(CToken* aToken,PRInt32 aLineNumber,nsITokenRecycler
|
|||
RecycleTokens(mRecycler,*mAttributes);
|
||||
mToken=aToken;
|
||||
mUseCount=0;
|
||||
mSkippedContent.Truncate();
|
||||
if(mSkippedContent) {
|
||||
mSkippedContent->Truncate();
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -201,9 +208,12 @@ const nsString& nsCParserNode::GetText() const {
|
|||
* @return string ref of text from internal token
|
||||
*/
|
||||
const nsString& nsCParserNode::GetSkippedContent() const {
|
||||
return mSkippedContent;
|
||||
if(mSkippedContent)
|
||||
return *mSkippedContent;
|
||||
return GetEmptyString();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get text value of this node, which translates into
|
||||
* getting the text value of the underlying token
|
||||
|
@ -213,7 +223,10 @@ const nsString& nsCParserNode::GetSkippedContent() const {
|
|||
* @return string ref of text from internal token
|
||||
*/
|
||||
void nsCParserNode::SetSkippedContent(nsString& aString) {
|
||||
mSkippedContent=aString;
|
||||
if(!mSkippedContent) {
|
||||
mSkippedContent=new nsString(aString);
|
||||
}
|
||||
else *mSkippedContent=aString;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -174,11 +174,11 @@ class nsCParserNode : public nsIParserNode {
|
|||
*/
|
||||
virtual CToken* PopAttributeToken();
|
||||
|
||||
PRInt32 mLineNumber;
|
||||
CToken* mToken;
|
||||
nsDeque* mAttributes;
|
||||
nsAutoString mSkippedContent;
|
||||
PRInt32 mUseCount;
|
||||
PRInt32 mLineNumber;
|
||||
CToken* mToken;
|
||||
nsDeque* mAttributes;
|
||||
nsString* mSkippedContent;
|
||||
PRInt32 mUseCount;
|
||||
|
||||
nsITokenRecycler* mRecycler;
|
||||
};
|
||||
|
|
|
@ -646,6 +646,47 @@ nsresult nsScanner::SkipPast(nsString& aValidSet){
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Consume characters until you did not find the terminal char
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param aString - receives new data from stream
|
||||
* @param aIgnore - If set ignores ':','-','_'
|
||||
* @return error code
|
||||
*/
|
||||
nsresult nsScanner::GetIdentifier(nsSubsumeStr& aString) {
|
||||
|
||||
PRUnichar theChar=0;
|
||||
nsresult result=Peek(theChar);
|
||||
const PRUnichar* theBuf=mBuffer.GetUnicode();
|
||||
PRInt32 theOrigin=mOffset;
|
||||
PRBool found=PR_FALSE;
|
||||
|
||||
while(NS_OK==result) {
|
||||
|
||||
theChar=theBuf[mOffset++];
|
||||
if(theChar) {
|
||||
found=PR_FALSE;
|
||||
if(('a'<=theChar) && (theChar<='z'))
|
||||
found=PR_TRUE;
|
||||
else if(('A'<=theChar) && (theChar<='Z'))
|
||||
found=PR_TRUE;
|
||||
else if(('0'<=theChar) && (theChar<='9'))
|
||||
found=PR_TRUE;
|
||||
|
||||
if(!found) {
|
||||
mOffset-=1;
|
||||
PRUnichar* thePtr=(PRUnichar*)&theBuf[theOrigin-1];
|
||||
aString.Subsume(thePtr,PR_FALSE,mOffset-theOrigin+1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//DoErrTest(aString);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Consume characters until you did not find the terminal char
|
||||
|
|
|
@ -175,6 +175,7 @@ class nsScanner {
|
|||
* @param addTerminal tells us whether to append terminal to aString
|
||||
* @return error code
|
||||
*/
|
||||
nsresult GetIdentifier(nsSubsumeStr& aString);
|
||||
nsresult ReadIdentifier(nsString& aString,PRBool aIgnore=PR_FALSE);
|
||||
nsresult ReadNumber(nsString& aString);
|
||||
nsresult ReadWhitespace(nsString& aString);
|
||||
|
|
|
@ -88,4 +88,64 @@ public:
|
|||
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* This class defines an object that describes the baseline group that a given
|
||||
* element belongs to.
|
||||
*
|
||||
* @update rgess 1/15/00
|
||||
*/
|
||||
class nsElementGroup {
|
||||
public:
|
||||
nsElementGroup(PRInt32 aGroupBits) {
|
||||
mGroupBits=aGroupBits;
|
||||
}
|
||||
|
||||
nsElementGroup(const nsElementGroup& aGroup) {
|
||||
mGroupBits=aGroup.mGroupBits;
|
||||
}
|
||||
|
||||
nsElementGroup& operator=(const nsElementGroup& aGroup) {
|
||||
mGroupBits=aGroup.mGroupBits;
|
||||
return *this;
|
||||
}
|
||||
|
||||
~nsElementGroup() {
|
||||
mGroupBits=0;
|
||||
}
|
||||
|
||||
private:
|
||||
PRInt32 mGroupBits;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* This class defines an object that describes the each element (tag).
|
||||
*
|
||||
* @update rgess 1/15/00
|
||||
*/
|
||||
class nsElement {
|
||||
public:
|
||||
nsElement() {
|
||||
mGroup=0;
|
||||
}
|
||||
|
||||
nsElement(const nsElement& aGroup){
|
||||
mGroup=aGroup.mGroup;
|
||||
}
|
||||
|
||||
nsElement& operator=(const nsElement& aGroup) {
|
||||
mGroup=aGroup.mGroup;
|
||||
return *this;
|
||||
}
|
||||
|
||||
~nsElement() {
|
||||
mGroup=0;
|
||||
}
|
||||
|
||||
private:
|
||||
nsElementGroup* mGroup;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
|
|
@ -347,31 +347,6 @@ NS_IMETHODIMP CValidDTD::HandleToken(CToken* aToken,nsIParser* aParser) {
|
|||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method causes all tokens to be dispatched to the given tag handler.
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param aHandler -- object to receive subsequent tokens...
|
||||
* @return error code (usually 0)
|
||||
*/
|
||||
nsresult CValidDTD::CaptureTokenPump(nsITagHandler* aHandler) {
|
||||
nsresult result=NS_OK;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This method releases the token-pump capture obtained in CaptureTokenPump()
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param aHandler -- object that received tokens...
|
||||
* @return error code (usually 0)
|
||||
*/
|
||||
nsresult CValidDTD::ReleaseTokenPump(nsITagHandler* aHandler){
|
||||
nsresult result=NS_OK;
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @update gess8/4/98
|
||||
|
|
|
@ -149,25 +149,6 @@ class CValidDTD : public nsIDTD {
|
|||
*/
|
||||
NS_IMETHOD HandleToken(CToken* aToken,nsIParser* aParser);
|
||||
|
||||
|
||||
/**
|
||||
* This method causes all tokens to be dispatched to the given tag handler.
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param aHandler -- object to receive subsequent tokens...
|
||||
* @return error code (usually 0)
|
||||
*/
|
||||
NS_IMETHOD CaptureTokenPump(nsITagHandler* aHandler);
|
||||
|
||||
/**
|
||||
* This method releases the token-pump capture obtained in CaptureTokenPump()
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param aHandler -- object that received tokens...
|
||||
* @return error code (usually 0)
|
||||
*/
|
||||
NS_IMETHOD ReleaseTokenPump(nsITagHandler* aHandler);
|
||||
|
||||
/**
|
||||
*
|
||||
* @update gess12/28/98
|
||||
|
|
|
@ -940,26 +940,3 @@ NS_IMETHODIMP CViewSourceHTML::HandleToken(CToken* aToken,nsIParser* aParser) {
|
|||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method causes all tokens to be dispatched to the given tag handler.
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param aHandler -- object to receive subsequent tokens...
|
||||
* @return error code (usually 0)
|
||||
*/
|
||||
nsresult CViewSourceHTML::CaptureTokenPump(nsITagHandler* aHandler) {
|
||||
nsresult result=NS_OK;
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method releases the token-pump capture obtained in CaptureTokenPump()
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param aHandler -- object that received tokens...
|
||||
* @return error code (usually 0)
|
||||
*/
|
||||
nsresult CViewSourceHTML::ReleaseTokenPump(nsITagHandler* aHandler){
|
||||
nsresult result=NS_OK;
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -159,24 +159,6 @@ class CViewSourceHTML: public nsIDTD {
|
|||
*/
|
||||
virtual nsITokenRecycler* GetTokenRecycler(void);
|
||||
|
||||
/**
|
||||
* This method causes all tokens to be dispatched to the given tag handler.
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param aHandler -- object to receive subsequent tokens...
|
||||
* @return error code (usually 0)
|
||||
*/
|
||||
NS_IMETHOD CaptureTokenPump(nsITagHandler* aHandler);
|
||||
|
||||
/**
|
||||
* This method releases the token-pump capture obtained in CaptureTokenPump()
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param aHandler -- object that received tokens...
|
||||
* @return error code (usually 0)
|
||||
*/
|
||||
NS_IMETHOD ReleaseTokenPump(nsITagHandler* aHandler);
|
||||
|
||||
/**
|
||||
*
|
||||
* @update gess5/18/98
|
||||
|
|
|
@ -704,26 +704,3 @@ nsresult CWellFormedDTD::HandleDocTypeDeclToken(CToken* aToken) {
|
|||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method causes all tokens to be dispatched to the given tag handler.
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param aHandler -- object to receive subsequent tokens...
|
||||
* @return error code (usually 0)
|
||||
*/
|
||||
nsresult CWellFormedDTD::CaptureTokenPump(nsITagHandler* aHandler) {
|
||||
nsresult result=NS_OK;
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method releases the token-pump capture obtained in CaptureTokenPump()
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param aHandler -- object that received tokens...
|
||||
* @return error code (usually 0)
|
||||
*/
|
||||
nsresult CWellFormedDTD::ReleaseTokenPump(nsITagHandler* aHandler){
|
||||
nsresult result=NS_OK;
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -136,24 +136,6 @@ class CWellFormedDTD : public nsIDTD {
|
|||
*/
|
||||
NS_IMETHOD HandleToken(CToken* aToken,nsIParser* aParser);
|
||||
|
||||
/**
|
||||
* This method causes all tokens to be dispatched to the given tag handler.
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param aHandler -- object to receive subsequent tokens...
|
||||
* @return error code (usually 0)
|
||||
*/
|
||||
NS_IMETHOD CaptureTokenPump(nsITagHandler* aHandler);
|
||||
|
||||
/**
|
||||
* This method releases the token-pump capture obtained in CaptureTokenPump()
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param aHandler -- object that received tokens...
|
||||
* @return error code (usually 0)
|
||||
*/
|
||||
NS_IMETHOD ReleaseTokenPump(nsITagHandler* aHandler);
|
||||
|
||||
/**
|
||||
*
|
||||
* @update gess 12/20/99
|
||||
|
|
|
@ -313,25 +313,33 @@ eAutoDetectResult nsXIFDTD::CanParse(nsString& aContentType, nsString& aCommand,
|
|||
}
|
||||
}
|
||||
|
||||
nsString charset ="ISO-8859-1";
|
||||
nsString charset("ISO-8859-1");
|
||||
PRInt32 offset;
|
||||
offset = aBuffer.Find(kXIFDocInfo);
|
||||
if(kNotFound!=offset)
|
||||
{
|
||||
|
||||
if(kNotFound!=offset) {
|
||||
|
||||
offset = aBuffer.Find(kXIFCharset);
|
||||
if (kNotFound!=offset)
|
||||
{
|
||||
if (kNotFound!=offset) {
|
||||
|
||||
//begin by finding the start and end quotes in the string...
|
||||
PRInt32 start = aBuffer.FindChar('"',PR_FALSE,offset);
|
||||
PRInt32 end = aBuffer.FindChar('"',PR_FALSE,start+1);
|
||||
|
||||
if ((start != kNotFound) && (end != kNotFound))
|
||||
{
|
||||
charset = "";
|
||||
for (PRInt32 i = start+1; i < end; i++)
|
||||
{
|
||||
if ((start != kNotFound) && (end != kNotFound)) {
|
||||
#if 0
|
||||
//This is faster than using character iteration (used below)...
|
||||
//(Why call 1 function when 30 single-character appends will do? :)
|
||||
aBuffer.Mid(charset,start+1,(end-start)-1);
|
||||
|
||||
#else
|
||||
//I removed this old (SLOW) version in favor of calling the Mid() function
|
||||
charset.Truncate();
|
||||
for (PRInt32 i = start+1; i < end; i++) {
|
||||
PRUnichar ch = aBuffer[i];
|
||||
charset.Append(ch);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -472,30 +480,6 @@ nsresult nsXIFDTD::HandleToken(CToken* aToken,nsIParser* aParser) {
|
|||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method causes all tokens to be dispatched to the given tag handler.
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param aHandler -- object to receive subsequent tokens...
|
||||
* @return error code (usually 0)
|
||||
*/
|
||||
nsresult nsXIFDTD::CaptureTokenPump(nsITagHandler* aHandler) {
|
||||
nsresult result=NS_OK;
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method releases the token-pump capture obtained in CaptureTokenPump()
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param aHandler -- object that received tokens...
|
||||
* @return error code (usually 0)
|
||||
*/
|
||||
nsresult nsXIFDTD::ReleaseTokenPump(nsITagHandler* aHandler){
|
||||
nsresult result=NS_OK;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This method gets called when a start token has been
|
||||
|
@ -543,12 +527,9 @@ nsresult nsXIFDTD::HandleTextToken(CToken* aToken) {
|
|||
|
||||
nsresult result = NS_OK;
|
||||
|
||||
if (type == eXIFTag_text)
|
||||
{
|
||||
if (type == eXIFTag_text) {
|
||||
nsString& temp = aToken->GetStringValueXXX();
|
||||
|
||||
if (temp != "<xml version=\"1.0\"?>")
|
||||
{
|
||||
if (temp != "<xml version=\"1.0\"?>") {
|
||||
result= AddLeaf(node);
|
||||
}
|
||||
}
|
||||
|
@ -839,15 +820,13 @@ PRBool nsXIFDTD::IsHTMLContainer(eHTMLTags aTag) const {
|
|||
*
|
||||
*/
|
||||
|
||||
PRBool nsXIFDTD::GetAttribute(const nsIParserNode& aNode, const nsString& aKey, nsString& aValue)
|
||||
{
|
||||
PRBool nsXIFDTD::GetAttribute(const nsIParserNode& aNode, const nsString& aKey, nsString& aValue) {
|
||||
PRInt32 i;
|
||||
PRInt32 count = aNode.GetAttributeCount();
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
const nsString& key = aNode.GetKeyAt(i);
|
||||
if (key.Equals(aKey))
|
||||
{
|
||||
if (key.Equals(aKey)) {
|
||||
const nsString& value = aNode.GetValueAt(i);
|
||||
aValue = value;
|
||||
aValue.StripChars("\"");
|
||||
|
@ -898,53 +877,6 @@ PRBool nsXIFDTD::GetAttributePair(nsIParserNode& aNode, nsString& aKey, nsString
|
|||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @update gess12/28/98
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
eHTMLTags nsXIFDTD::GetHTMLTag(const nsString& aName)
|
||||
{
|
||||
eHTMLTags tag = nsHTMLTags::LookupTag(aName);
|
||||
return tag;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @update gess12/28/98
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
eHTMLTags nsXIFDTD::GetStartTag(const nsIParserNode& aNode, nsString& aName)
|
||||
{
|
||||
eXIFTags type = (eXIFTags)aNode.GetNodeType();
|
||||
eHTMLTags tag = eHTMLTag_unknown;
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case eXIFTag_container:
|
||||
case eXIFTag_leaf:
|
||||
if (GetAttribute(aNode,nsString("isa"),aName))
|
||||
tag = GetHTMLTag(aName);
|
||||
break;
|
||||
|
||||
case eXIFTag_css_stylesheet:
|
||||
aName = "style";
|
||||
tag = GetHTMLTag(aName);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return tag;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @update gess12/28/98
|
||||
|
@ -1083,27 +1015,29 @@ PRBool nsXIFDTD::StartTopOfStack()
|
|||
|
||||
/**
|
||||
*
|
||||
* @update gess12/28/98
|
||||
* @update gess 02/07/00
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
void nsXIFDTD::BeginStartTag(const nsIParserNode& aNode)
|
||||
{
|
||||
eXIFTags type = (eXIFTags)aNode.GetNodeType();
|
||||
eHTMLTags tag;
|
||||
nsString tagName;
|
||||
eHTMLTags tag = eHTMLTag_unknown;
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case eXIFTag_container:
|
||||
case eXIFTag_leaf:
|
||||
tag = GetStartTag(aNode,tagName);
|
||||
{
|
||||
nsAutoString tagName;
|
||||
if (GetAttribute(aNode,nsString("isa"),tagName))
|
||||
tag = nsHTMLTags::LookupTag(tagName);
|
||||
|
||||
if (type == eXIFTag_container)
|
||||
PushHTMLTag(tag,tagName);
|
||||
|
||||
// CToken* token = new CStartToken(tagName);
|
||||
// nsCParserNode* node = new nsCParserNode(token);
|
||||
PushNodeAndToken(tagName);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -1120,7 +1054,7 @@ void nsXIFDTD::AddEndTag(const nsIParserNode& aNode)
|
|||
PopHTMLTag(tag,name);
|
||||
|
||||
// Create a parse node for form this token
|
||||
CEndToken token(*name);
|
||||
CEndToken token(tag);
|
||||
nsCParserNode node(&token);
|
||||
|
||||
// close the container
|
||||
|
@ -1505,17 +1439,11 @@ void nsXIFDTD::BeginCSSStyleSheet(const nsIParserNode& aNode)
|
|||
mMaxCSSSelectorWidth = temp;
|
||||
}
|
||||
|
||||
//const char* name = nsHTMLTags::GetStringValue(eHTMLTag_html);
|
||||
}
|
||||
|
||||
void nsXIFDTD::EndCSSStyleSheet(const nsIParserNode& aNode)
|
||||
{
|
||||
nsString tagName(nsHTMLTags::GetStringValue(eHTMLTag_style));
|
||||
|
||||
if (mLowerCaseTags == PR_TRUE)
|
||||
tagName.ToLowerCase();
|
||||
else
|
||||
tagName.ToUpperCase();
|
||||
nsAutoString tagName("style");
|
||||
|
||||
CStartToken startToken(tagName);
|
||||
nsCParserNode startNode((CToken*)&startToken);
|
||||
|
|
|
@ -188,25 +188,6 @@ class nsXIFDTD : public nsIDTD {
|
|||
*/
|
||||
NS_IMETHOD HandleToken(CToken* aToken,nsIParser* aParser);
|
||||
|
||||
/**
|
||||
* This method causes all tokens to be dispatched to the given tag handler.
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param aHandler -- object to receive subsequent tokens...
|
||||
* @return error code (usually 0)
|
||||
*/
|
||||
NS_IMETHOD CaptureTokenPump(nsITagHandler* aHandler);
|
||||
|
||||
/**
|
||||
* This method releases the token-pump capture obtained in CaptureTokenPump()
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param aHandler -- object that received tokens...
|
||||
* @return error code (usually 0)
|
||||
*/
|
||||
NS_IMETHOD ReleaseTokenPump(nsITagHandler* aHandler);
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @update gpk 06/18/98
|
||||
|
@ -450,14 +431,12 @@ private:
|
|||
|
||||
|
||||
void AddAttribute(nsIParserNode& aNode);
|
||||
eHTMLTags GetHTMLTag(const nsString& aName);
|
||||
void PushHTMLTag(const eHTMLTags aTag, const nsString& aName);
|
||||
void PopHTMLTag(eHTMLTags& aTag, nsString*& aName);
|
||||
|
||||
PRBool GetAttributePair(nsIParserNode& aNode, nsString& aKey, nsString& aValue);
|
||||
PRBool GetAttribute(const nsIParserNode& aNode, const nsString& aKey, nsString& aValue);
|
||||
void BeginStartTag(const nsIParserNode& aNode);
|
||||
eHTMLTags GetStartTag(const nsIParserNode& aNode, nsString& aName);
|
||||
void AddEndTag(const nsIParserNode& aNode);
|
||||
void AddEndCommentTag(const nsIParserNode& aNode);
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче