From f9c74bf2ef2811ae11d97f25ec319e5d241237e2 Mon Sep 17 00:00:00 2001 From: "heikki%netscape.com" Date: Wed, 17 Jan 2001 18:59:12 +0000 Subject: [PATCH] Bug 64448, comments in internal subset moved to before internal subset. I also fixed some static global variables and NS_GET_IID stuff. r=harishd, sr=vidur. --- htmlparser/src/nsExpatTokenizer.cpp | 25 ++++--- htmlparser/src/nsITokenizer.h | 79 ---------------------- parser/htmlparser/src/nsExpatTokenizer.cpp | 25 ++++--- parser/htmlparser/src/nsITokenizer.h | 79 ---------------------- 4 files changed, 30 insertions(+), 178 deletions(-) diff --git a/htmlparser/src/nsExpatTokenizer.cpp b/htmlparser/src/nsExpatTokenizer.cpp index 80d360944f4..8dad05d59c0 100644 --- a/htmlparser/src/nsExpatTokenizer.cpp +++ b/htmlparser/src/nsExpatTokenizer.cpp @@ -60,8 +60,6 @@ typedef struct _XMLParserState { And now for the main class -- nsExpatTokenizer... ************************************************************************/ -static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); -static NS_DEFINE_IID(kITokenizerIID, NS_ITOKENIZER_IID); static NS_DEFINE_IID(kHTMLTokenizerIID, NS_HTMLTOKENIZER_IID); static NS_DEFINE_IID(kClassIID, NS_EXPATTOKENIZER_IID); @@ -100,10 +98,10 @@ nsresult nsExpatTokenizer::QueryInterface(const nsIID& aIID, void** aInstancePtr return NS_ERROR_NULL_POINTER; } - if(aIID.Equals(kISupportsIID)) { //do IUnknown... + if(aIID.Equals(NS_GET_IID(nsISupports))) { //do IUnknown... *aInstancePtr = (nsExpatTokenizer*)(this); } - else if(aIID.Equals(kITokenizerIID)) { //do ITokenizer base class... + else if(aIID.Equals(NS_GET_IID(nsITokenizer))) { //do ITokenizer base class... *aInstancePtr = (nsITokenizer*)(this); } else if(aIID.Equals(kHTMLTokenizerIID)) { //do nsHTMLTokenizer base class... @@ -627,12 +625,19 @@ void nsExpatTokenizer::HandleCharacterData(void *userData, const XML_Char *s, in void nsExpatTokenizer::HandleComment(void *userData, const XML_Char *name) { XMLParserState* state = (XMLParserState*) userData; - CToken* theToken = state->tokenAllocator->CreateTokenOfType(eToken_comment, eHTMLTag_unknown, nsLiteralString((PRUnichar*)name)); - if(theToken) { - AddToken(theToken, NS_OK, state->tokenDeque, state->tokenAllocator); - } - else{ - //THROW A HUGE ERROR IF WE CANT CREATE A TOKEN! + if (state->indoctype) { + // We do not want comments popping out of the doctype... + state->doctypeText.Append(NS_LITERAL_STRING("")); + } else { + CToken* theToken = state->tokenAllocator->CreateTokenOfType(eToken_comment, eHTMLTag_unknown, nsLiteralString((PRUnichar*)name)); + if(theToken) { + AddToken(theToken, NS_OK, state->tokenDeque, state->tokenAllocator); + } + else{ + //THROW A HUGE ERROR IF WE CANT CREATE A TOKEN! + } } } diff --git a/htmlparser/src/nsITokenizer.h b/htmlparser/src/nsITokenizer.h index c6f6ad1a088..e69de29bb2d 100644 --- a/htmlparser/src/nsITokenizer.h +++ b/htmlparser/src/nsITokenizer.h @@ -1,79 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* - * The contents of this file are subject to the Netscape Public - * License Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is Netscape - * Communications Corporation. Portions created by Netscape are - * Copyright (C) 1998 Netscape Communications Corporation. All - * Rights Reserved. - * - * Contributor(s): - */ - - -/** - * MODULE NOTES: - * @update gess 4/1/98 - * - */ - -#ifndef __NSITOKENIZER__ -#define __NSITOKENIZER__ - -#include "nsISupports.h" -#include "prtypes.h" -#include "nshtmlpars.h" - -class CToken; -class nsScanner; -class nsDeque; -class nsTokenAllocator; - -#define NS_ITOKENIZER_IID \ - {0xe4238ddc, 0x9eb6, 0x11d2, {0xba, 0xa5, 0x0, 0x10, 0x4b, 0x98, 0x3f, 0xd4 }} - -/** - * This interface is used as a callback to objects interested - * in observing the token stream created from the parse process. - */ -class nsITokenObserver { -public: - virtual PRBool operator()(CToken* aToken)=0; -}; - -/*************************************************************** - Notes: - ***************************************************************/ - -class nsITokenizer : public nsISupports { -public: - - virtual nsresult WillTokenize(PRBool aIsFinalChunk,nsTokenAllocator* aTokenAllocator)=0; - virtual nsresult ConsumeToken(nsScanner& aScanner,PRBool& aFlushTokens)=0; - virtual nsresult DidTokenize(PRBool aIsFinalChunk)=0; - virtual nsTokenAllocator* GetTokenAllocator(void)=0; - - virtual CToken* PushTokenFront(CToken* aToken)=0; - virtual CToken* PushToken(CToken* aToken)=0; - virtual CToken* PopToken(void)=0; - virtual CToken* PeekToken(void)=0; - virtual PRInt32 GetCount(void)=0; - virtual CToken* GetTokenAt(PRInt32 anIndex)=0; - - virtual void PrependTokens(nsDeque& aDeque)=0; - -}; - - -#endif - diff --git a/parser/htmlparser/src/nsExpatTokenizer.cpp b/parser/htmlparser/src/nsExpatTokenizer.cpp index 80d360944f4..8dad05d59c0 100644 --- a/parser/htmlparser/src/nsExpatTokenizer.cpp +++ b/parser/htmlparser/src/nsExpatTokenizer.cpp @@ -60,8 +60,6 @@ typedef struct _XMLParserState { And now for the main class -- nsExpatTokenizer... ************************************************************************/ -static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); -static NS_DEFINE_IID(kITokenizerIID, NS_ITOKENIZER_IID); static NS_DEFINE_IID(kHTMLTokenizerIID, NS_HTMLTOKENIZER_IID); static NS_DEFINE_IID(kClassIID, NS_EXPATTOKENIZER_IID); @@ -100,10 +98,10 @@ nsresult nsExpatTokenizer::QueryInterface(const nsIID& aIID, void** aInstancePtr return NS_ERROR_NULL_POINTER; } - if(aIID.Equals(kISupportsIID)) { //do IUnknown... + if(aIID.Equals(NS_GET_IID(nsISupports))) { //do IUnknown... *aInstancePtr = (nsExpatTokenizer*)(this); } - else if(aIID.Equals(kITokenizerIID)) { //do ITokenizer base class... + else if(aIID.Equals(NS_GET_IID(nsITokenizer))) { //do ITokenizer base class... *aInstancePtr = (nsITokenizer*)(this); } else if(aIID.Equals(kHTMLTokenizerIID)) { //do nsHTMLTokenizer base class... @@ -627,12 +625,19 @@ void nsExpatTokenizer::HandleCharacterData(void *userData, const XML_Char *s, in void nsExpatTokenizer::HandleComment(void *userData, const XML_Char *name) { XMLParserState* state = (XMLParserState*) userData; - CToken* theToken = state->tokenAllocator->CreateTokenOfType(eToken_comment, eHTMLTag_unknown, nsLiteralString((PRUnichar*)name)); - if(theToken) { - AddToken(theToken, NS_OK, state->tokenDeque, state->tokenAllocator); - } - else{ - //THROW A HUGE ERROR IF WE CANT CREATE A TOKEN! + if (state->indoctype) { + // We do not want comments popping out of the doctype... + state->doctypeText.Append(NS_LITERAL_STRING("")); + } else { + CToken* theToken = state->tokenAllocator->CreateTokenOfType(eToken_comment, eHTMLTag_unknown, nsLiteralString((PRUnichar*)name)); + if(theToken) { + AddToken(theToken, NS_OK, state->tokenDeque, state->tokenAllocator); + } + else{ + //THROW A HUGE ERROR IF WE CANT CREATE A TOKEN! + } } } diff --git a/parser/htmlparser/src/nsITokenizer.h b/parser/htmlparser/src/nsITokenizer.h index c6f6ad1a088..e69de29bb2d 100644 --- a/parser/htmlparser/src/nsITokenizer.h +++ b/parser/htmlparser/src/nsITokenizer.h @@ -1,79 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* - * The contents of this file are subject to the Netscape Public - * License Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is Netscape - * Communications Corporation. Portions created by Netscape are - * Copyright (C) 1998 Netscape Communications Corporation. All - * Rights Reserved. - * - * Contributor(s): - */ - - -/** - * MODULE NOTES: - * @update gess 4/1/98 - * - */ - -#ifndef __NSITOKENIZER__ -#define __NSITOKENIZER__ - -#include "nsISupports.h" -#include "prtypes.h" -#include "nshtmlpars.h" - -class CToken; -class nsScanner; -class nsDeque; -class nsTokenAllocator; - -#define NS_ITOKENIZER_IID \ - {0xe4238ddc, 0x9eb6, 0x11d2, {0xba, 0xa5, 0x0, 0x10, 0x4b, 0x98, 0x3f, 0xd4 }} - -/** - * This interface is used as a callback to objects interested - * in observing the token stream created from the parse process. - */ -class nsITokenObserver { -public: - virtual PRBool operator()(CToken* aToken)=0; -}; - -/*************************************************************** - Notes: - ***************************************************************/ - -class nsITokenizer : public nsISupports { -public: - - virtual nsresult WillTokenize(PRBool aIsFinalChunk,nsTokenAllocator* aTokenAllocator)=0; - virtual nsresult ConsumeToken(nsScanner& aScanner,PRBool& aFlushTokens)=0; - virtual nsresult DidTokenize(PRBool aIsFinalChunk)=0; - virtual nsTokenAllocator* GetTokenAllocator(void)=0; - - virtual CToken* PushTokenFront(CToken* aToken)=0; - virtual CToken* PushToken(CToken* aToken)=0; - virtual CToken* PopToken(void)=0; - virtual CToken* PeekToken(void)=0; - virtual PRInt32 GetCount(void)=0; - virtual CToken* GetTokenAt(PRInt32 anIndex)=0; - - virtual void PrependTokens(nsDeque& aDeque)=0; - -}; - - -#endif -