small mods to parser API's for DOM/paste

This commit is contained in:
rickg%netscape.com 1999-05-04 23:20:28 +00:00
Родитель 051d4df938
Коммит 2291cf9492
18 изменённых файлов: 192 добавлений и 90 удалений

Просмотреть файл

@ -734,7 +734,7 @@ nsresult CNavDTD::DidHandleStartTag(nsCParserNode& aNode,eHTMLTags aChildTag){
* @return topmost index of tag on stack
*/
static
PRInt32 GetTopmostIndexOf(eHTMLTags aTag,nsTagStack& aTagStack) {
PRInt32 GetTopmostIndexOf(eHTMLTags aTag,nsEntryStack& aTagStack) {
int i=0;
int count = aTagStack.GetSize();
for(i=(count-1);i>=0;i--){
@ -755,7 +755,7 @@ PRInt32 GetTopmostIndexOf(eHTMLTags aTag,nsTagStack& aTagStack) {
* @return PR_TRUE if autoclosure should occur
*/
static
eHTMLTags FindAutoCloseTargetForStartTag(eHTMLTags aCurrentTag,nsTagStack& aTagStack) {
eHTMLTags FindAutoCloseTargetForStartTag(eHTMLTags aCurrentTag,nsEntryStack& aTagStack) {
int theTopIndex = aTagStack.GetSize();
eHTMLTags thePrevTag=aTagStack.Last();
@ -820,7 +820,7 @@ eHTMLTags FindAutoCloseTargetForStartTag(eHTMLTags aCurrentTag,nsTagStack& aTagS
* @return index of kNotFound
*/
static
PRInt32 GetIndexOfChildOrSynonym(nsTagStack& aTagStack,eHTMLTags aChildTag) {
PRInt32 GetIndexOfChildOrSynonym(nsEntryStack& aTagStack,eHTMLTags aChildTag) {
PRInt32 theChildIndex=aTagStack.GetTopmostIndexOf(aChildTag);
if(kNotFound==theChildIndex) {
CTagList* theSynTags=gHTMLElements[aChildTag].GetSynonymousTags(); //get the list of tags that THIS tag can close
@ -842,7 +842,7 @@ PRInt32 GetIndexOfChildOrSynonym(nsTagStack& aTagStack,eHTMLTags aChildTag) {
* @return PR_TRUE if child agrees to be opened here.
*/
static
PRBool CanBeContained(eHTMLTags aParentTag,eHTMLTags aChildTag,nsTagStack& aTagStack) {
PRBool CanBeContained(eHTMLTags aParentTag,eHTMLTags aChildTag,nsEntryStack& aTagStack) {
PRBool result=PR_TRUE;
/* # Interesting test cases: Result:
@ -1264,7 +1264,7 @@ nsresult CNavDTD::HandleStartToken(CToken* aToken) {
* @return PR_TRUE if given tag can contain other tags
*/
static
PRBool HasCloseablePeerAboveRoot(CTagList& aRootTagList,nsTagStack& aTagStack,eHTMLTags aTag,PRBool anEndTag) {
PRBool HasCloseablePeerAboveRoot(CTagList& aRootTagList,nsEntryStack& aTagStack,eHTMLTags aTag,PRBool anEndTag) {
PRInt32 theRootIndex=aRootTagList.GetTopmostIndexOf(aTagStack);
CTagList* theCloseTags=(anEndTag) ? gHTMLElements[aTag].GetAutoCloseEndTags() : gHTMLElements[aTag].GetAutoCloseStartTags();
PRInt32 theChildIndex=-1;
@ -1289,7 +1289,7 @@ PRBool HasCloseablePeerAboveRoot(CTagList& aRootTagList,nsTagStack& aTagStack,eH
* @return PR_TRUE if autoclosure should occur
*/
static
eHTMLTags FindAutoCloseTargetForEndTag(eHTMLTags aCurrentTag,nsTagStack& aTagStack) {
eHTMLTags FindAutoCloseTargetForEndTag(eHTMLTags aCurrentTag,nsEntryStack& aTagStack) {
int theTopIndex=aTagStack.GetSize();
eHTMLTags thePrevTag=aTagStack.Last();
@ -1946,7 +1946,7 @@ PRBool CNavDTD::IsContainer(PRInt32 aTag) const {
* @param aChild -- tag type of child
* @return TRUE if propagation closes; false otherwise
*/
PRBool CNavDTD::ForwardPropagate(nsTagStack& aStack,eHTMLTags aParentTag,eHTMLTags aChildTag) {
PRBool CNavDTD::ForwardPropagate(nsEntryStack& aStack,eHTMLTags aParentTag,eHTMLTags aChildTag) {
PRBool result=PR_FALSE;
switch(aParentTag) {
@ -1991,7 +1991,7 @@ PRBool CNavDTD::ForwardPropagate(nsTagStack& aStack,eHTMLTags aParentTag,eHTMLTa
* @param aChild -- tag type of child
* @return TRUE if propagation closes; false otherwise
*/
PRBool CNavDTD::BackwardPropagate(nsTagStack& aStack,eHTMLTags aParentTag,eHTMLTags aChildTag) const {
PRBool CNavDTD::BackwardPropagate(nsEntryStack& aStack,eHTMLTags aParentTag,eHTMLTags aChildTag) const {
eHTMLTags theParentTag=aChildTag;
@ -2139,7 +2139,7 @@ nsresult CNavDTD::OpenTransientStyles(eHTMLTags aTag){
int theStackPos=0;
for(theStackPos=0;theStackPos<mBodyContext->GetCount();theStackPos++){
nsTagStack* theStyleStack=mBodyContext->mStyles[theStackPos];
nsEntryStack* theStyleStack=mBodyContext->mStyles[theStackPos];
if(theStyleStack) {
int theTagPos=0;
int count = theStyleStack->mTags->GetSize();
@ -2749,7 +2749,7 @@ nsresult CNavDTD::AddHeadLeaf(const nsIParserNode& aNode){
*/
nsresult CNavDTD::CreateContextStackFor(eHTMLTags aChildTag){
static nsTagStack kPropagationStack;
static nsEntryStack kPropagationStack;
kPropagationStack.Empty();
nsresult result=(nsresult)kContextMismatch;
@ -2848,7 +2848,7 @@ nsresult CNavDTD::UpdateStyleStackForOpenTag(eHTMLTags aTag,eHTMLTags anActualTa
nsresult result=0;
if(nsHTMLElement::IsStyleTag(aTag)) {
nsTagStack* theStyleStack=mBodyContext->GetStyles();
nsEntryStack* theStyleStack=mBodyContext->GetStyles();
if(theStyleStack){
theStyleStack->Push(aTag);
}
@ -2869,7 +2869,7 @@ nsresult
CNavDTD::UpdateStyleStackForCloseTag(eHTMLTags aTag,eHTMLTags anActualTag){
nsresult result=0;
nsTagStack* theStyles=mBodyContext->GetStyles();
nsEntryStack* theStyles=mBodyContext->GetStyles();
if(theStyles){
if(nsHTMLElement::IsStyleTag(aTag)) {
if(aTag==anActualTag) {

Просмотреть файл

@ -98,7 +98,7 @@ class nsCParserNode;
class CITokenHandler;
class nsParser;
class nsDTDContext;
class nsTagStack;
class nsEntryStack;
class nsITokenizer;
/***************************************************************
@ -327,7 +327,7 @@ CLASS_EXPORT_HTMLPARS CNavDTD : public nsIDTD {
* @param aChild -- tag type of child
* @return True if closure was achieved -- other false
*/
virtual PRBool ForwardPropagate(nsTagStack& aTagStack,eHTMLTags aParentTag,eHTMLTags aChildTag);
virtual PRBool ForwardPropagate(nsEntryStack& aTagStack,eHTMLTags aParentTag,eHTMLTags aChildTag);
/**
* This method tries to design a context map (without actually
@ -338,7 +338,7 @@ CLASS_EXPORT_HTMLPARS CNavDTD : public nsIDTD {
* @param aChild -- tag type of child
* @return True if closure was achieved -- other false
*/
virtual PRBool BackwardPropagate(nsTagStack& aTagStack,eHTMLTags aParentTag,eHTMLTags aChildTag) const;
virtual PRBool BackwardPropagate(nsEntryStack& aTagStack,eHTMLTags aParentTag,eHTMLTags aChildTag) const;
/**
* Ask parser if a given container is open ANYWHERE on stack

Просмотреть файл

@ -31,7 +31,7 @@
* @update harishd 04/04/99
* @update gess 04/22/99
*/
nsTagStack::nsTagStack() {
nsEntryStack::nsEntryStack() {
mCapacity=0;
mCount=0;
mEntries=0;
@ -42,7 +42,7 @@ nsTagStack::nsTagStack() {
* @update harishd 04/04/99
* @update gess 04/22/99
*/
nsTagStack::~nsTagStack() {
nsEntryStack::~nsEntryStack() {
if(mEntries)
delete [] mEntries;
}
@ -51,7 +51,7 @@ nsTagStack::~nsTagStack() {
* Resets state of stack to be empty.
* @update harishd 04/04/99
*/
void nsTagStack::Empty(void) {
void nsEntryStack::Empty(void) {
mCount=0;
}
@ -59,7 +59,7 @@ void nsTagStack::Empty(void) {
*
* @update gess 04/22/99
*/
void nsTagStack::Push(eHTMLTags aTag) {
void nsEntryStack::Push(eHTMLTags aTag) {
if(mCount==mCapacity){
nsTagEntry* temp=new nsTagEntry[mCapacity+=50];
PRUint32 index=0;
@ -80,7 +80,7 @@ void nsTagStack::Push(eHTMLTags aTag) {
* @update harishd 04/04/99
* @update gess 04/21/99
*/
eHTMLTags nsTagStack::Pop() {
eHTMLTags nsEntryStack::Pop() {
eHTMLTags result=eHTMLTag_unknown;
if(0<mCount) {
result=mEntries[--mCount].mTag;
@ -93,7 +93,7 @@ eHTMLTags nsTagStack::Pop() {
* @update harishd 04/04/99
* @update gess 04/21/99
*/
eHTMLTags nsTagStack::First() const {
eHTMLTags nsEntryStack::First() const {
eHTMLTags result=eHTMLTag_unknown;
if(0<mCount){
result=mEntries[0].mTag;
@ -106,7 +106,7 @@ eHTMLTags nsTagStack::First() const {
* @update harishd 04/04/99
* @update gess 04/21/99
*/
eHTMLTags nsTagStack::TagAt(PRUint32 anIndex) const {
eHTMLTags nsEntryStack::TagAt(PRUint32 anIndex) const {
eHTMLTags result=eHTMLTag_unknown;
if(anIndex<mCount) {
result=mEntries[anIndex].mTag;
@ -118,7 +118,7 @@ eHTMLTags nsTagStack::TagAt(PRUint32 anIndex) const {
*
* @update gess 04/21/99
*/
nsTagEntry& nsTagStack::EntryAt(PRUint32 anIndex) const {
nsTagEntry& nsEntryStack::EntryAt(PRUint32 anIndex) const {
static nsTagEntry gSentinel;
if(anIndex<mCount) {
return mEntries[anIndex];
@ -132,7 +132,7 @@ nsTagEntry& nsTagStack::EntryAt(PRUint32 anIndex) const {
* @update harishd 04/04/99
* @update gess 04/21/99
*/
eHTMLTags nsTagStack::operator[](PRUint32 anIndex) const {
eHTMLTags nsEntryStack::operator[](PRUint32 anIndex) const {
eHTMLTags result=eHTMLTag_unknown;
if(anIndex<mCount) {
result=mEntries[anIndex].mTag;
@ -146,7 +146,7 @@ eHTMLTags nsTagStack::operator[](PRUint32 anIndex) const {
* @update harishd 04/04/99
* @update gess 04/21/99
*/
eHTMLTags nsTagStack::Last() const {
eHTMLTags nsEntryStack::Last() const {
return TagAt(mCount-1);
}
@ -155,7 +155,7 @@ eHTMLTags nsTagStack::Last() const {
* @update harishd 04/04/99
* @update gess 04/21/99
*/
PRInt32 nsTagStack::GetTopmostIndexOf(eHTMLTags aTag) const {
PRInt32 nsEntryStack::GetTopmostIndexOf(eHTMLTags aTag) const {
int theIndex=0;
for(theIndex=mCount-1;theIndex>=0;theIndex--){
if(aTag==TagAt(theIndex))
@ -272,12 +272,12 @@ eHTMLTags nsDTDContext::Last() const {
* @update gess7/9/98
* @update gess 4/26/99
*/
nsTagStack* nsDTDContext::GetStyles(void) const {
nsTagStack* result=0;
nsEntryStack* nsDTDContext::GetStyles(void) const {
nsEntryStack* result=0;
if(0<mStack.mCount){
PRInt32 theIndex=mStack.mEntries[mStack.mCount-1].mStyleIndex;
if(-1<theIndex){
result=(nsTagStack*)mStyles.ObjectAt(theIndex);
result=(nsEntryStack*)mStyles.ObjectAt(theIndex);
}
}
return result;

Просмотреть файл

@ -66,10 +66,10 @@ struct nsTagEntry {
PRInt8 mStyleIndex;
};
class nsTagStack {
class nsEntryStack {
public:
nsTagStack();
~nsTagStack();
nsEntryStack();
~nsEntryStack();
void Push(eHTMLTags aTag);
eHTMLTags Pop();
eHTMLTags First() const;
@ -106,13 +106,13 @@ public:
eHTMLTags Last() const;
void Empty(void);
PRInt32 GetCount(void);
nsTagStack* GetStyles(void) const;
nsEntryStack* GetStyles(void) const;
void SaveToken(CToken* aToken, PRInt32 aID);
CToken* RestoreTokenFrom(PRInt32 aID);
PRInt32 TokenCountAt(PRInt32 aID);
nsTagStack mStack;
nsEntryStack mStack;
nsDeque mSkipped; //each entry will hold a deque full of skipped tokens...
nsDeque mStyles; //each entry will hold a tagstack full of style tags...
#ifdef NS_DEBUG

Просмотреть файл

@ -47,7 +47,7 @@ PRBool CTagList::Contains(eHTMLTags aTag){
* @param
* @return
*/
PRInt32 CTagList::GetTopmostIndexOf(nsTagStack& aTagStack){
PRInt32 CTagList::GetTopmostIndexOf(nsEntryStack& aTagStack){
int max = aTagStack.GetSize();
int index;
for(index=max-1;index>=0;index--){
@ -64,7 +64,7 @@ PRInt32 CTagList::GetTopmostIndexOf(nsTagStack& aTagStack){
* @param
* @return
*/
PRInt32 CTagList::GetBottommostIndexOf(nsTagStack& aTagStack,PRInt32 aStartOffset){
PRInt32 CTagList::GetBottommostIndexOf(nsEntryStack& aTagStack,PRInt32 aStartOffset){
int max = aTagStack.GetSize();
int index;
for(index=aStartOffset;index<max;index++){

Просмотреть файл

@ -46,8 +46,8 @@ public:
mTagList=aTagList;
}
PRInt32 GetTopmostIndexOf(nsTagStack& aTagStack);
PRInt32 GetBottommostIndexOf(nsTagStack& aTagStack,PRInt32 aStartOffset);
PRInt32 GetTopmostIndexOf(nsEntryStack& aTagStack);
PRInt32 GetBottommostIndexOf(nsEntryStack& aTagStack,PRInt32 aStartOffset);
PRBool Contains(eHTMLTags aTag);
eHTMLTags mTags[5];

Просмотреть файл

@ -47,7 +47,7 @@ class nsIContentSink;
class nsIStreamObserver;
class nsString;
class nsIURL;
class nsTagStack;
enum eParseMode {
@ -79,6 +79,16 @@ typedef enum {
enum eStreamState {eNone,eOnStart,eOnDataAvail,eOnStop};
class nsITagStack {
public:
virtual void Push(PRUnichar* aTag)=0;
virtual PRUnichar* Pop(PRUnichar* aTag)=0;
virtual PRUnichar* TagAt(PRUint32 anIndex)=0;
virtual PRUint32 GetSize(void)=0;
};
/**
* This class defines the iparser interface. This XPCOM
* inteface is all that parser clients ever need to see.
@ -150,8 +160,8 @@ class nsIParser : public nsISupports {
virtual nsresult Parse(nsIInputStream& aStream, PRBool aEnableVerify=PR_FALSE) = 0;
virtual nsresult Parse(nsString& aSourceBuffer,void* aKey,const nsString& aContentType,PRBool aEnableVerify,PRBool aLastCall) = 0;
virtual PRBool IsValidFragment(nsString& aSourceBuffer,nsTagStack& aStack,PRUint32 anInsertPos,const nsString& aContentType)=0;
virtual nsresult InsertFragment(nsString& aSourceBuffer,void* aKey,nsTagStack& aStack,PRUint32 anInsertPos,const nsString& aContentType)=0;
virtual PRBool IsValidFragment(nsString& aSourceBuffer,nsITagStack& aStack,PRUint32 anInsertPos,const nsString& aContentType)=0;
virtual nsresult ParseFragment(nsString& aSourceBuffer,void* aKey,nsITagStack& aStack,PRUint32 anInsertPos,const nsString& aContentType)=0;
/**
* This method gets called when the tokens have been consumed, and it's time

Просмотреть файл

@ -756,7 +756,7 @@ nsresult nsParser::Parse(nsString& aSourceBuffer,void* aKey,const nsString& aCon
* @param
* @return
*/
PRBool nsParser::IsValidFragment(nsString& aSourceBuffer,nsTagStack& aStack,PRUint32 anInsertPos,const nsString& aContentType){
PRBool nsParser::IsValidFragment(nsString& aSourceBuffer,nsITagStack& aStack,PRUint32 anInsertPos,const nsString& aContentType){
PRBool result=PR_FALSE;
return result;
}
@ -767,7 +767,7 @@ PRBool nsParser::IsValidFragment(nsString& aSourceBuffer,nsTagStack& aStack,PRUi
* @param
* @return
*/
nsresult nsParser::InsertFragment(nsString& aSourceBuffer,void* aKey,nsTagStack& aStack,PRUint32 anInsertPos,const nsString& aContentType){
nsresult nsParser::ParseFragment(nsString& aSourceBuffer,void* aKey,nsITagStack& aStack,PRUint32 anInsertPos,const nsString& aContentType){
PRBool result=PR_FALSE;
return result;
}
@ -1136,3 +1136,31 @@ void nsParser::DebugDumpSource(ostream& aStream) {
}
/**********************************************************************************
This class is used as an interface between an external agent (like the DOM) and
the parser. It will contain a stack full of tagnames, which is used in our
parser/paste API's.
**********************************************************************************/
nsTagStack::nsTagStack() : nsITagStack(), mTags(0) {
}
void nsTagStack::Push(PRUnichar* aTag) {
mTags.Push(aTag);
}
PRUnichar* nsTagStack::Pop(void) {
PRUnichar* result=(PRUnichar*)mTags.Pop();
return result;
}
PRUnichar* nsTagStack::TagAt(PRUint32 anIndex) {
PRUnichar* result=0;
if(anIndex<(PRUint32)mTags.GetSize())
result=(PRUnichar*)mTags.ObjectAt(anIndex);
return result;
}
PRUint32 nsTagStack::GetSize(void) {
return mTags.GetSize();
}

Просмотреть файл

@ -184,8 +184,8 @@ friend class CTokenHandler;
virtual nsresult Parse(nsString& aSourceBuffer,void* aKey,const nsString& aContentType,PRBool aEnableVerify=PR_FALSE,PRBool aLastCall=PR_FALSE);
virtual PRBool IsValidFragment(nsString& aSourceBuffer,nsTagStack& aStack,PRUint32 anInsertPos,const nsString& aContentType);
virtual nsresult InsertFragment(nsString& aSourceBuffer,void* aKey,nsTagStack& aStack,PRUint32 anInsertPos,const nsString& aContentType);
virtual PRBool IsValidFragment(nsString& aSourceBuffer,nsITagStack& aStack,PRUint32 anInsertPos,const nsString& aContentType);
virtual nsresult ParseFragment(nsString& aSourceBuffer,void* aKey,nsITagStack& aStack,PRUint32 anInsertPos,const nsString& aContentType);
/**
@ -346,5 +346,18 @@ protected:
};
class nsTagStack : public nsITagStack {
public:
nsTagStack();
virtual void Push(PRUnichar* aTag);
virtual PRUnichar* Pop(void);
virtual PRUnichar* TagAt(PRUint32 anIndex);
virtual PRUint32 GetSize(void);
nsDeque mTags; //will hold a deque of prunichars...
};
#endif

Просмотреть файл

@ -734,7 +734,7 @@ nsresult CNavDTD::DidHandleStartTag(nsCParserNode& aNode,eHTMLTags aChildTag){
* @return topmost index of tag on stack
*/
static
PRInt32 GetTopmostIndexOf(eHTMLTags aTag,nsTagStack& aTagStack) {
PRInt32 GetTopmostIndexOf(eHTMLTags aTag,nsEntryStack& aTagStack) {
int i=0;
int count = aTagStack.GetSize();
for(i=(count-1);i>=0;i--){
@ -755,7 +755,7 @@ PRInt32 GetTopmostIndexOf(eHTMLTags aTag,nsTagStack& aTagStack) {
* @return PR_TRUE if autoclosure should occur
*/
static
eHTMLTags FindAutoCloseTargetForStartTag(eHTMLTags aCurrentTag,nsTagStack& aTagStack) {
eHTMLTags FindAutoCloseTargetForStartTag(eHTMLTags aCurrentTag,nsEntryStack& aTagStack) {
int theTopIndex = aTagStack.GetSize();
eHTMLTags thePrevTag=aTagStack.Last();
@ -820,7 +820,7 @@ eHTMLTags FindAutoCloseTargetForStartTag(eHTMLTags aCurrentTag,nsTagStack& aTagS
* @return index of kNotFound
*/
static
PRInt32 GetIndexOfChildOrSynonym(nsTagStack& aTagStack,eHTMLTags aChildTag) {
PRInt32 GetIndexOfChildOrSynonym(nsEntryStack& aTagStack,eHTMLTags aChildTag) {
PRInt32 theChildIndex=aTagStack.GetTopmostIndexOf(aChildTag);
if(kNotFound==theChildIndex) {
CTagList* theSynTags=gHTMLElements[aChildTag].GetSynonymousTags(); //get the list of tags that THIS tag can close
@ -842,7 +842,7 @@ PRInt32 GetIndexOfChildOrSynonym(nsTagStack& aTagStack,eHTMLTags aChildTag) {
* @return PR_TRUE if child agrees to be opened here.
*/
static
PRBool CanBeContained(eHTMLTags aParentTag,eHTMLTags aChildTag,nsTagStack& aTagStack) {
PRBool CanBeContained(eHTMLTags aParentTag,eHTMLTags aChildTag,nsEntryStack& aTagStack) {
PRBool result=PR_TRUE;
/* # Interesting test cases: Result:
@ -1264,7 +1264,7 @@ nsresult CNavDTD::HandleStartToken(CToken* aToken) {
* @return PR_TRUE if given tag can contain other tags
*/
static
PRBool HasCloseablePeerAboveRoot(CTagList& aRootTagList,nsTagStack& aTagStack,eHTMLTags aTag,PRBool anEndTag) {
PRBool HasCloseablePeerAboveRoot(CTagList& aRootTagList,nsEntryStack& aTagStack,eHTMLTags aTag,PRBool anEndTag) {
PRInt32 theRootIndex=aRootTagList.GetTopmostIndexOf(aTagStack);
CTagList* theCloseTags=(anEndTag) ? gHTMLElements[aTag].GetAutoCloseEndTags() : gHTMLElements[aTag].GetAutoCloseStartTags();
PRInt32 theChildIndex=-1;
@ -1289,7 +1289,7 @@ PRBool HasCloseablePeerAboveRoot(CTagList& aRootTagList,nsTagStack& aTagStack,eH
* @return PR_TRUE if autoclosure should occur
*/
static
eHTMLTags FindAutoCloseTargetForEndTag(eHTMLTags aCurrentTag,nsTagStack& aTagStack) {
eHTMLTags FindAutoCloseTargetForEndTag(eHTMLTags aCurrentTag,nsEntryStack& aTagStack) {
int theTopIndex=aTagStack.GetSize();
eHTMLTags thePrevTag=aTagStack.Last();
@ -1946,7 +1946,7 @@ PRBool CNavDTD::IsContainer(PRInt32 aTag) const {
* @param aChild -- tag type of child
* @return TRUE if propagation closes; false otherwise
*/
PRBool CNavDTD::ForwardPropagate(nsTagStack& aStack,eHTMLTags aParentTag,eHTMLTags aChildTag) {
PRBool CNavDTD::ForwardPropagate(nsEntryStack& aStack,eHTMLTags aParentTag,eHTMLTags aChildTag) {
PRBool result=PR_FALSE;
switch(aParentTag) {
@ -1991,7 +1991,7 @@ PRBool CNavDTD::ForwardPropagate(nsTagStack& aStack,eHTMLTags aParentTag,eHTMLTa
* @param aChild -- tag type of child
* @return TRUE if propagation closes; false otherwise
*/
PRBool CNavDTD::BackwardPropagate(nsTagStack& aStack,eHTMLTags aParentTag,eHTMLTags aChildTag) const {
PRBool CNavDTD::BackwardPropagate(nsEntryStack& aStack,eHTMLTags aParentTag,eHTMLTags aChildTag) const {
eHTMLTags theParentTag=aChildTag;
@ -2139,7 +2139,7 @@ nsresult CNavDTD::OpenTransientStyles(eHTMLTags aTag){
int theStackPos=0;
for(theStackPos=0;theStackPos<mBodyContext->GetCount();theStackPos++){
nsTagStack* theStyleStack=mBodyContext->mStyles[theStackPos];
nsEntryStack* theStyleStack=mBodyContext->mStyles[theStackPos];
if(theStyleStack) {
int theTagPos=0;
int count = theStyleStack->mTags->GetSize();
@ -2749,7 +2749,7 @@ nsresult CNavDTD::AddHeadLeaf(const nsIParserNode& aNode){
*/
nsresult CNavDTD::CreateContextStackFor(eHTMLTags aChildTag){
static nsTagStack kPropagationStack;
static nsEntryStack kPropagationStack;
kPropagationStack.Empty();
nsresult result=(nsresult)kContextMismatch;
@ -2848,7 +2848,7 @@ nsresult CNavDTD::UpdateStyleStackForOpenTag(eHTMLTags aTag,eHTMLTags anActualTa
nsresult result=0;
if(nsHTMLElement::IsStyleTag(aTag)) {
nsTagStack* theStyleStack=mBodyContext->GetStyles();
nsEntryStack* theStyleStack=mBodyContext->GetStyles();
if(theStyleStack){
theStyleStack->Push(aTag);
}
@ -2869,7 +2869,7 @@ nsresult
CNavDTD::UpdateStyleStackForCloseTag(eHTMLTags aTag,eHTMLTags anActualTag){
nsresult result=0;
nsTagStack* theStyles=mBodyContext->GetStyles();
nsEntryStack* theStyles=mBodyContext->GetStyles();
if(theStyles){
if(nsHTMLElement::IsStyleTag(aTag)) {
if(aTag==anActualTag) {

Просмотреть файл

@ -98,7 +98,7 @@ class nsCParserNode;
class CITokenHandler;
class nsParser;
class nsDTDContext;
class nsTagStack;
class nsEntryStack;
class nsITokenizer;
/***************************************************************
@ -327,7 +327,7 @@ CLASS_EXPORT_HTMLPARS CNavDTD : public nsIDTD {
* @param aChild -- tag type of child
* @return True if closure was achieved -- other false
*/
virtual PRBool ForwardPropagate(nsTagStack& aTagStack,eHTMLTags aParentTag,eHTMLTags aChildTag);
virtual PRBool ForwardPropagate(nsEntryStack& aTagStack,eHTMLTags aParentTag,eHTMLTags aChildTag);
/**
* This method tries to design a context map (without actually
@ -338,7 +338,7 @@ CLASS_EXPORT_HTMLPARS CNavDTD : public nsIDTD {
* @param aChild -- tag type of child
* @return True if closure was achieved -- other false
*/
virtual PRBool BackwardPropagate(nsTagStack& aTagStack,eHTMLTags aParentTag,eHTMLTags aChildTag) const;
virtual PRBool BackwardPropagate(nsEntryStack& aTagStack,eHTMLTags aParentTag,eHTMLTags aChildTag) const;
/**
* Ask parser if a given container is open ANYWHERE on stack

Просмотреть файл

@ -31,7 +31,7 @@
* @update harishd 04/04/99
* @update gess 04/22/99
*/
nsTagStack::nsTagStack() {
nsEntryStack::nsEntryStack() {
mCapacity=0;
mCount=0;
mEntries=0;
@ -42,7 +42,7 @@ nsTagStack::nsTagStack() {
* @update harishd 04/04/99
* @update gess 04/22/99
*/
nsTagStack::~nsTagStack() {
nsEntryStack::~nsEntryStack() {
if(mEntries)
delete [] mEntries;
}
@ -51,7 +51,7 @@ nsTagStack::~nsTagStack() {
* Resets state of stack to be empty.
* @update harishd 04/04/99
*/
void nsTagStack::Empty(void) {
void nsEntryStack::Empty(void) {
mCount=0;
}
@ -59,7 +59,7 @@ void nsTagStack::Empty(void) {
*
* @update gess 04/22/99
*/
void nsTagStack::Push(eHTMLTags aTag) {
void nsEntryStack::Push(eHTMLTags aTag) {
if(mCount==mCapacity){
nsTagEntry* temp=new nsTagEntry[mCapacity+=50];
PRUint32 index=0;
@ -80,7 +80,7 @@ void nsTagStack::Push(eHTMLTags aTag) {
* @update harishd 04/04/99
* @update gess 04/21/99
*/
eHTMLTags nsTagStack::Pop() {
eHTMLTags nsEntryStack::Pop() {
eHTMLTags result=eHTMLTag_unknown;
if(0<mCount) {
result=mEntries[--mCount].mTag;
@ -93,7 +93,7 @@ eHTMLTags nsTagStack::Pop() {
* @update harishd 04/04/99
* @update gess 04/21/99
*/
eHTMLTags nsTagStack::First() const {
eHTMLTags nsEntryStack::First() const {
eHTMLTags result=eHTMLTag_unknown;
if(0<mCount){
result=mEntries[0].mTag;
@ -106,7 +106,7 @@ eHTMLTags nsTagStack::First() const {
* @update harishd 04/04/99
* @update gess 04/21/99
*/
eHTMLTags nsTagStack::TagAt(PRUint32 anIndex) const {
eHTMLTags nsEntryStack::TagAt(PRUint32 anIndex) const {
eHTMLTags result=eHTMLTag_unknown;
if(anIndex<mCount) {
result=mEntries[anIndex].mTag;
@ -118,7 +118,7 @@ eHTMLTags nsTagStack::TagAt(PRUint32 anIndex) const {
*
* @update gess 04/21/99
*/
nsTagEntry& nsTagStack::EntryAt(PRUint32 anIndex) const {
nsTagEntry& nsEntryStack::EntryAt(PRUint32 anIndex) const {
static nsTagEntry gSentinel;
if(anIndex<mCount) {
return mEntries[anIndex];
@ -132,7 +132,7 @@ nsTagEntry& nsTagStack::EntryAt(PRUint32 anIndex) const {
* @update harishd 04/04/99
* @update gess 04/21/99
*/
eHTMLTags nsTagStack::operator[](PRUint32 anIndex) const {
eHTMLTags nsEntryStack::operator[](PRUint32 anIndex) const {
eHTMLTags result=eHTMLTag_unknown;
if(anIndex<mCount) {
result=mEntries[anIndex].mTag;
@ -146,7 +146,7 @@ eHTMLTags nsTagStack::operator[](PRUint32 anIndex) const {
* @update harishd 04/04/99
* @update gess 04/21/99
*/
eHTMLTags nsTagStack::Last() const {
eHTMLTags nsEntryStack::Last() const {
return TagAt(mCount-1);
}
@ -155,7 +155,7 @@ eHTMLTags nsTagStack::Last() const {
* @update harishd 04/04/99
* @update gess 04/21/99
*/
PRInt32 nsTagStack::GetTopmostIndexOf(eHTMLTags aTag) const {
PRInt32 nsEntryStack::GetTopmostIndexOf(eHTMLTags aTag) const {
int theIndex=0;
for(theIndex=mCount-1;theIndex>=0;theIndex--){
if(aTag==TagAt(theIndex))
@ -272,12 +272,12 @@ eHTMLTags nsDTDContext::Last() const {
* @update gess7/9/98
* @update gess 4/26/99
*/
nsTagStack* nsDTDContext::GetStyles(void) const {
nsTagStack* result=0;
nsEntryStack* nsDTDContext::GetStyles(void) const {
nsEntryStack* result=0;
if(0<mStack.mCount){
PRInt32 theIndex=mStack.mEntries[mStack.mCount-1].mStyleIndex;
if(-1<theIndex){
result=(nsTagStack*)mStyles.ObjectAt(theIndex);
result=(nsEntryStack*)mStyles.ObjectAt(theIndex);
}
}
return result;

Просмотреть файл

@ -66,10 +66,10 @@ struct nsTagEntry {
PRInt8 mStyleIndex;
};
class nsTagStack {
class nsEntryStack {
public:
nsTagStack();
~nsTagStack();
nsEntryStack();
~nsEntryStack();
void Push(eHTMLTags aTag);
eHTMLTags Pop();
eHTMLTags First() const;
@ -106,13 +106,13 @@ public:
eHTMLTags Last() const;
void Empty(void);
PRInt32 GetCount(void);
nsTagStack* GetStyles(void) const;
nsEntryStack* GetStyles(void) const;
void SaveToken(CToken* aToken, PRInt32 aID);
CToken* RestoreTokenFrom(PRInt32 aID);
PRInt32 TokenCountAt(PRInt32 aID);
nsTagStack mStack;
nsEntryStack mStack;
nsDeque mSkipped; //each entry will hold a deque full of skipped tokens...
nsDeque mStyles; //each entry will hold a tagstack full of style tags...
#ifdef NS_DEBUG

Просмотреть файл

@ -47,7 +47,7 @@ PRBool CTagList::Contains(eHTMLTags aTag){
* @param
* @return
*/
PRInt32 CTagList::GetTopmostIndexOf(nsTagStack& aTagStack){
PRInt32 CTagList::GetTopmostIndexOf(nsEntryStack& aTagStack){
int max = aTagStack.GetSize();
int index;
for(index=max-1;index>=0;index--){
@ -64,7 +64,7 @@ PRInt32 CTagList::GetTopmostIndexOf(nsTagStack& aTagStack){
* @param
* @return
*/
PRInt32 CTagList::GetBottommostIndexOf(nsTagStack& aTagStack,PRInt32 aStartOffset){
PRInt32 CTagList::GetBottommostIndexOf(nsEntryStack& aTagStack,PRInt32 aStartOffset){
int max = aTagStack.GetSize();
int index;
for(index=aStartOffset;index<max;index++){

Просмотреть файл

@ -46,8 +46,8 @@ public:
mTagList=aTagList;
}
PRInt32 GetTopmostIndexOf(nsTagStack& aTagStack);
PRInt32 GetBottommostIndexOf(nsTagStack& aTagStack,PRInt32 aStartOffset);
PRInt32 GetTopmostIndexOf(nsEntryStack& aTagStack);
PRInt32 GetBottommostIndexOf(nsEntryStack& aTagStack,PRInt32 aStartOffset);
PRBool Contains(eHTMLTags aTag);
eHTMLTags mTags[5];

Просмотреть файл

@ -47,7 +47,7 @@ class nsIContentSink;
class nsIStreamObserver;
class nsString;
class nsIURL;
class nsTagStack;
enum eParseMode {
@ -79,6 +79,16 @@ typedef enum {
enum eStreamState {eNone,eOnStart,eOnDataAvail,eOnStop};
class nsITagStack {
public:
virtual void Push(PRUnichar* aTag)=0;
virtual PRUnichar* Pop(PRUnichar* aTag)=0;
virtual PRUnichar* TagAt(PRUint32 anIndex)=0;
virtual PRUint32 GetSize(void)=0;
};
/**
* This class defines the iparser interface. This XPCOM
* inteface is all that parser clients ever need to see.
@ -150,8 +160,8 @@ class nsIParser : public nsISupports {
virtual nsresult Parse(nsIInputStream& aStream, PRBool aEnableVerify=PR_FALSE) = 0;
virtual nsresult Parse(nsString& aSourceBuffer,void* aKey,const nsString& aContentType,PRBool aEnableVerify,PRBool aLastCall) = 0;
virtual PRBool IsValidFragment(nsString& aSourceBuffer,nsTagStack& aStack,PRUint32 anInsertPos,const nsString& aContentType)=0;
virtual nsresult InsertFragment(nsString& aSourceBuffer,void* aKey,nsTagStack& aStack,PRUint32 anInsertPos,const nsString& aContentType)=0;
virtual PRBool IsValidFragment(nsString& aSourceBuffer,nsITagStack& aStack,PRUint32 anInsertPos,const nsString& aContentType)=0;
virtual nsresult ParseFragment(nsString& aSourceBuffer,void* aKey,nsITagStack& aStack,PRUint32 anInsertPos,const nsString& aContentType)=0;
/**
* This method gets called when the tokens have been consumed, and it's time

Просмотреть файл

@ -756,7 +756,7 @@ nsresult nsParser::Parse(nsString& aSourceBuffer,void* aKey,const nsString& aCon
* @param
* @return
*/
PRBool nsParser::IsValidFragment(nsString& aSourceBuffer,nsTagStack& aStack,PRUint32 anInsertPos,const nsString& aContentType){
PRBool nsParser::IsValidFragment(nsString& aSourceBuffer,nsITagStack& aStack,PRUint32 anInsertPos,const nsString& aContentType){
PRBool result=PR_FALSE;
return result;
}
@ -767,7 +767,7 @@ PRBool nsParser::IsValidFragment(nsString& aSourceBuffer,nsTagStack& aStack,PRUi
* @param
* @return
*/
nsresult nsParser::InsertFragment(nsString& aSourceBuffer,void* aKey,nsTagStack& aStack,PRUint32 anInsertPos,const nsString& aContentType){
nsresult nsParser::ParseFragment(nsString& aSourceBuffer,void* aKey,nsITagStack& aStack,PRUint32 anInsertPos,const nsString& aContentType){
PRBool result=PR_FALSE;
return result;
}
@ -1136,3 +1136,31 @@ void nsParser::DebugDumpSource(ostream& aStream) {
}
/**********************************************************************************
This class is used as an interface between an external agent (like the DOM) and
the parser. It will contain a stack full of tagnames, which is used in our
parser/paste API's.
**********************************************************************************/
nsTagStack::nsTagStack() : nsITagStack(), mTags(0) {
}
void nsTagStack::Push(PRUnichar* aTag) {
mTags.Push(aTag);
}
PRUnichar* nsTagStack::Pop(void) {
PRUnichar* result=(PRUnichar*)mTags.Pop();
return result;
}
PRUnichar* nsTagStack::TagAt(PRUint32 anIndex) {
PRUnichar* result=0;
if(anIndex<(PRUint32)mTags.GetSize())
result=(PRUnichar*)mTags.ObjectAt(anIndex);
return result;
}
PRUint32 nsTagStack::GetSize(void) {
return mTags.GetSize();
}

Просмотреть файл

@ -184,8 +184,8 @@ friend class CTokenHandler;
virtual nsresult Parse(nsString& aSourceBuffer,void* aKey,const nsString& aContentType,PRBool aEnableVerify=PR_FALSE,PRBool aLastCall=PR_FALSE);
virtual PRBool IsValidFragment(nsString& aSourceBuffer,nsTagStack& aStack,PRUint32 anInsertPos,const nsString& aContentType);
virtual nsresult InsertFragment(nsString& aSourceBuffer,void* aKey,nsTagStack& aStack,PRUint32 anInsertPos,const nsString& aContentType);
virtual PRBool IsValidFragment(nsString& aSourceBuffer,nsITagStack& aStack,PRUint32 anInsertPos,const nsString& aContentType);
virtual nsresult ParseFragment(nsString& aSourceBuffer,void* aKey,nsITagStack& aStack,PRUint32 anInsertPos,const nsString& aContentType);
/**
@ -346,5 +346,18 @@ protected:
};
class nsTagStack : public nsITagStack {
public:
nsTagStack();
virtual void Push(PRUnichar* aTag);
virtual PRUnichar* Pop(void);
virtual PRUnichar* TagAt(PRUint32 anIndex);
virtual PRUint32 GetSize(void);
nsDeque mTags; //will hold a deque of prunichars...
};
#endif