зеркало из https://github.com/mozilla/pjs.git
improved newline handling in tables
This commit is contained in:
Родитель
305efded8c
Коммит
a9058dc3c1
|
@ -234,7 +234,6 @@ CToken* CHTMLTokenizerDelegate::ConsumeEntity(PRUnichar aChar,CScanner& aScanner
|
|||
return result;
|
||||
}
|
||||
|
||||
#ifdef TOKENIZE_WHITESPACE
|
||||
/**-------------------------------------------------------
|
||||
* This method is called just after whitespace has been
|
||||
* consumed and we know we're at the start a whitespace run.
|
||||
|
@ -250,7 +249,6 @@ CToken* CHTMLTokenizerDelegate::ConsumeWhitespace(PRUnichar aChar,CScanner& aSca
|
|||
anErrorCode=result->Consume(aChar,aScanner);
|
||||
return result;
|
||||
}
|
||||
#endif
|
||||
|
||||
/**-------------------------------------------------------
|
||||
* This method is called just after a "<!" has been consumed
|
||||
|
@ -287,7 +285,6 @@ CToken* CHTMLTokenizerDelegate::ConsumeText(const nsString& aString,CScanner& aS
|
|||
return result;
|
||||
}
|
||||
|
||||
#ifdef TOKENIZE_CRLF
|
||||
/**-------------------------------------------------------
|
||||
* This method is called just after a newline has been consumed.
|
||||
*
|
||||
|
@ -304,7 +301,6 @@ CToken* CHTMLTokenizerDelegate::ConsumeNewline(PRUnichar aChar,CScanner& aScanne
|
|||
}
|
||||
return result;
|
||||
}
|
||||
#endif
|
||||
|
||||
/**-------------------------------------------------------
|
||||
* This method repeatedly called by the tokenizer.
|
||||
|
@ -333,18 +329,14 @@ CToken* CHTMLTokenizerDelegate::GetToken(CScanner& aScanner,PRInt32& anErrorCode
|
|||
return ConsumeEntity(aChar,aScanner,anErrorCode);
|
||||
case kLessThan:
|
||||
return ConsumeTag(aChar,aScanner,anErrorCode);
|
||||
#ifdef TOKENIZE_CRLF
|
||||
case kCR: case kLF:
|
||||
return ConsumeNewline(aChar,aScanner,anErrorCode);
|
||||
case kNotFound:
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
#ifdef TOKENIZE_WHITESPACE
|
||||
if(nsString::IsSpace(aChar))
|
||||
return ConsumeWhitespace(aChar,aScanner,anErrorCode);
|
||||
else
|
||||
#endif
|
||||
{
|
||||
nsAutoString temp(aChar);
|
||||
return ConsumeText(temp,aScanner,anErrorCode);
|
||||
|
|
|
@ -1,86 +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.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
/**
|
||||
* MODULE NOTES:
|
||||
* @update gess 4/1/98
|
||||
*
|
||||
* This class is used as the HTML tokenizer delegate.
|
||||
*
|
||||
* The tokenzier class has the smarts to open an source,
|
||||
* and iterate over its characters to produce a list of
|
||||
* tokens. The tokenizer doesn't know HTML, which is
|
||||
* where this delegate comes into play.
|
||||
*
|
||||
* The tokenizer calls methods on this class to help
|
||||
* with the creation of HTML-specific tokens from a source
|
||||
* stream.
|
||||
*
|
||||
* The interface here is very simple, mainly the call
|
||||
* to GetToken(), which Consumes bytes from the underlying
|
||||
* scanner.stream, and produces an HTML specific CToken.
|
||||
*/
|
||||
|
||||
#ifndef TOKENIZER_DELEGATE
|
||||
#define TOKENIZER_DELEGATE
|
||||
|
||||
#include "nsHTMLTokens.h"
|
||||
#include "nsITokenizerDelegate.h"
|
||||
#include "nsDeque.h"
|
||||
|
||||
|
||||
class CHTMLTokenizerDelegate : public ITokenizerDelegate {
|
||||
public:
|
||||
CHTMLTokenizerDelegate();
|
||||
CHTMLTokenizerDelegate(CHTMLTokenizerDelegate& aDelegate);
|
||||
|
||||
virtual CToken* GetToken(CScanner& aScanner,PRInt32& anErrorCode);
|
||||
virtual PRBool WillAddToken(CToken& aToken);
|
||||
|
||||
virtual PRBool WillTokenize();
|
||||
virtual PRBool DidTokenize();
|
||||
|
||||
virtual eParseMode GetParseMode() const;
|
||||
static void SelfTest();
|
||||
|
||||
protected:
|
||||
|
||||
virtual CToken* CreateTokenOfType(eHTMLTokenTypes aType);
|
||||
|
||||
CToken* ConsumeTag(PRUnichar aChar,CScanner& aScanner,PRInt32& anErrorCode);
|
||||
CToken* ConsumeStartTag(PRUnichar aChar,CScanner& aScanner,PRInt32& anErrorCode);
|
||||
void ConsumeAttributes(PRUnichar aChar,CScanner& aScanner,PRInt32& anErrorCode);
|
||||
CToken* ConsumeText(const nsString& aString,CScanner& aScanner,PRInt32& anErrorCode);
|
||||
CToken* ConsumeEntity(PRUnichar aChar,CScanner& aScanner,PRInt32& anErrorCode);
|
||||
#ifdef TOKENIZE_WHITESPACE
|
||||
CToken* ConsumeWhitespace(PRUnichar aChar,CScanner& aScanner,PRInt32& anErrorCode);
|
||||
#endif
|
||||
CToken* ConsumeComment(PRUnichar aChar,CScanner& aScanner,PRInt32& anErrorCode);
|
||||
#ifdef TOKENIZE_CRLF
|
||||
CToken* ConsumeNewline(PRUnichar aChar,CScanner& aScanner,PRInt32& anErrorCode);
|
||||
#endif
|
||||
|
||||
//the only special case method...
|
||||
virtual CToken* ConsumeContentToEndTag(const nsString& aString,PRUnichar aChar,CScanner& aScanner,PRInt32& anErrorCode);
|
||||
|
||||
nsDeque mTokenDeque;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
@ -523,16 +523,8 @@ PRInt32 CTextToken::GetTokenType(void) {
|
|||
* @return error result
|
||||
*------------------------------------------------------*/
|
||||
PRInt32 CTextToken::Consume(PRUnichar aChar, CScanner& aScanner) {
|
||||
|
||||
#ifdef TOKENIZE_CRLF
|
||||
static nsAutoString terminals("&<\r\n");
|
||||
#else
|
||||
static nsAutoString terminals("&<");
|
||||
#endif
|
||||
PRInt32 result=aScanner.ReadUntil(mTextValue,terminals,PR_FALSE);
|
||||
#ifndef TOKENIZE_CRLF
|
||||
mTextValue.StripChars("\r");
|
||||
#endif
|
||||
static nsAutoString terminals("&<\r\n");
|
||||
PRInt32 result=aScanner.ReadUntil(mTextValue,terminals,PR_FALSE);
|
||||
return result;
|
||||
};
|
||||
|
||||
|
@ -607,7 +599,6 @@ PRInt32 CCommentToken::GetTokenType(void) {
|
|||
return eToken_comment;
|
||||
}
|
||||
|
||||
#ifdef TOKENIZE_CRLF
|
||||
/**-------------------------------------------------------
|
||||
* default constructor
|
||||
*
|
||||
|
@ -656,7 +647,6 @@ PRInt32 CNewlineToken::Consume(PRUnichar aChar, CScanner& aScanner) {
|
|||
mTextValue.StripChars("\r");
|
||||
return result;
|
||||
};
|
||||
#endif /* TOKENIZE_CRLF */
|
||||
|
||||
/**-------------------------------------------------------
|
||||
* default constructor
|
||||
|
@ -834,7 +824,6 @@ void CAttributeToken::DebugDumpSource(ostream& out) {
|
|||
out<<">";
|
||||
}
|
||||
|
||||
#ifdef TOKENIZE_WHITESPACE
|
||||
/**-------------------------------------------------------
|
||||
* default constructor
|
||||
*
|
||||
|
@ -884,7 +873,6 @@ PRInt32 CWhitespaceToken::Consume(PRUnichar aChar, CScanner& aScanner) {
|
|||
mTextValue.StripChars("\r");
|
||||
return result;
|
||||
};
|
||||
#endif /* TOKENIZE_WHITESPACE */
|
||||
|
||||
/**-------------------------------------------------------
|
||||
* default constructor
|
||||
|
|
|
@ -35,10 +35,6 @@
|
|||
#include "nsToken.h"
|
||||
#include <iostream.h>
|
||||
|
||||
// If you define these to true then crlf sequences and whitespace come
|
||||
// through the scanner as seperate tokens.
|
||||
#undef TOKENIZE_CRLF
|
||||
#undef TOKENIZE_WHITESPACE
|
||||
|
||||
class CScanner;
|
||||
|
||||
|
@ -222,7 +218,6 @@ class CEntityToken : public CHTMLToken {
|
|||
*
|
||||
* @update gess 3/25/98
|
||||
*/ //---------------------------------------------------
|
||||
#ifdef TOKENIZE_WHITESPACE
|
||||
class CWhitespaceToken: public CHTMLToken {
|
||||
public:
|
||||
CWhitespaceToken(const nsString& aString);
|
||||
|
@ -230,7 +225,6 @@ class CWhitespaceToken: public CHTMLToken {
|
|||
virtual const char* GetClassName(void);
|
||||
virtual PRInt32 GetTokenType(void);
|
||||
};
|
||||
#endif
|
||||
|
||||
/** -----------------------------------------------------
|
||||
* Text tokens contain the normalized form of html text.
|
||||
|
@ -278,7 +272,6 @@ class CAttributeToken: public CHTMLToken {
|
|||
*
|
||||
* @update gess 3/25/98
|
||||
*/ //---------------------------------------------------
|
||||
#ifdef TOKENIZE_CRLF
|
||||
class CNewlineToken: public CHTMLToken {
|
||||
public:
|
||||
CNewlineToken(const nsString& aString);
|
||||
|
@ -286,7 +279,6 @@ class CNewlineToken: public CHTMLToken {
|
|||
virtual const char* GetClassName(void);
|
||||
virtual PRInt32 GetTokenType(void);
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
/** -----------------------------------------------------
|
||||
|
|
|
@ -234,7 +234,6 @@ CToken* CHTMLTokenizerDelegate::ConsumeEntity(PRUnichar aChar,CScanner& aScanner
|
|||
return result;
|
||||
}
|
||||
|
||||
#ifdef TOKENIZE_WHITESPACE
|
||||
/**-------------------------------------------------------
|
||||
* This method is called just after whitespace has been
|
||||
* consumed and we know we're at the start a whitespace run.
|
||||
|
@ -250,7 +249,6 @@ CToken* CHTMLTokenizerDelegate::ConsumeWhitespace(PRUnichar aChar,CScanner& aSca
|
|||
anErrorCode=result->Consume(aChar,aScanner);
|
||||
return result;
|
||||
}
|
||||
#endif
|
||||
|
||||
/**-------------------------------------------------------
|
||||
* This method is called just after a "<!" has been consumed
|
||||
|
@ -287,7 +285,6 @@ CToken* CHTMLTokenizerDelegate::ConsumeText(const nsString& aString,CScanner& aS
|
|||
return result;
|
||||
}
|
||||
|
||||
#ifdef TOKENIZE_CRLF
|
||||
/**-------------------------------------------------------
|
||||
* This method is called just after a newline has been consumed.
|
||||
*
|
||||
|
@ -304,7 +301,6 @@ CToken* CHTMLTokenizerDelegate::ConsumeNewline(PRUnichar aChar,CScanner& aScanne
|
|||
}
|
||||
return result;
|
||||
}
|
||||
#endif
|
||||
|
||||
/**-------------------------------------------------------
|
||||
* This method repeatedly called by the tokenizer.
|
||||
|
@ -333,18 +329,14 @@ CToken* CHTMLTokenizerDelegate::GetToken(CScanner& aScanner,PRInt32& anErrorCode
|
|||
return ConsumeEntity(aChar,aScanner,anErrorCode);
|
||||
case kLessThan:
|
||||
return ConsumeTag(aChar,aScanner,anErrorCode);
|
||||
#ifdef TOKENIZE_CRLF
|
||||
case kCR: case kLF:
|
||||
return ConsumeNewline(aChar,aScanner,anErrorCode);
|
||||
case kNotFound:
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
#ifdef TOKENIZE_WHITESPACE
|
||||
if(nsString::IsSpace(aChar))
|
||||
return ConsumeWhitespace(aChar,aScanner,anErrorCode);
|
||||
else
|
||||
#endif
|
||||
{
|
||||
nsAutoString temp(aChar);
|
||||
return ConsumeText(temp,aScanner,anErrorCode);
|
||||
|
|
|
@ -1,86 +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.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
/**
|
||||
* MODULE NOTES:
|
||||
* @update gess 4/1/98
|
||||
*
|
||||
* This class is used as the HTML tokenizer delegate.
|
||||
*
|
||||
* The tokenzier class has the smarts to open an source,
|
||||
* and iterate over its characters to produce a list of
|
||||
* tokens. The tokenizer doesn't know HTML, which is
|
||||
* where this delegate comes into play.
|
||||
*
|
||||
* The tokenizer calls methods on this class to help
|
||||
* with the creation of HTML-specific tokens from a source
|
||||
* stream.
|
||||
*
|
||||
* The interface here is very simple, mainly the call
|
||||
* to GetToken(), which Consumes bytes from the underlying
|
||||
* scanner.stream, and produces an HTML specific CToken.
|
||||
*/
|
||||
|
||||
#ifndef TOKENIZER_DELEGATE
|
||||
#define TOKENIZER_DELEGATE
|
||||
|
||||
#include "nsHTMLTokens.h"
|
||||
#include "nsITokenizerDelegate.h"
|
||||
#include "nsDeque.h"
|
||||
|
||||
|
||||
class CHTMLTokenizerDelegate : public ITokenizerDelegate {
|
||||
public:
|
||||
CHTMLTokenizerDelegate();
|
||||
CHTMLTokenizerDelegate(CHTMLTokenizerDelegate& aDelegate);
|
||||
|
||||
virtual CToken* GetToken(CScanner& aScanner,PRInt32& anErrorCode);
|
||||
virtual PRBool WillAddToken(CToken& aToken);
|
||||
|
||||
virtual PRBool WillTokenize();
|
||||
virtual PRBool DidTokenize();
|
||||
|
||||
virtual eParseMode GetParseMode() const;
|
||||
static void SelfTest();
|
||||
|
||||
protected:
|
||||
|
||||
virtual CToken* CreateTokenOfType(eHTMLTokenTypes aType);
|
||||
|
||||
CToken* ConsumeTag(PRUnichar aChar,CScanner& aScanner,PRInt32& anErrorCode);
|
||||
CToken* ConsumeStartTag(PRUnichar aChar,CScanner& aScanner,PRInt32& anErrorCode);
|
||||
void ConsumeAttributes(PRUnichar aChar,CScanner& aScanner,PRInt32& anErrorCode);
|
||||
CToken* ConsumeText(const nsString& aString,CScanner& aScanner,PRInt32& anErrorCode);
|
||||
CToken* ConsumeEntity(PRUnichar aChar,CScanner& aScanner,PRInt32& anErrorCode);
|
||||
#ifdef TOKENIZE_WHITESPACE
|
||||
CToken* ConsumeWhitespace(PRUnichar aChar,CScanner& aScanner,PRInt32& anErrorCode);
|
||||
#endif
|
||||
CToken* ConsumeComment(PRUnichar aChar,CScanner& aScanner,PRInt32& anErrorCode);
|
||||
#ifdef TOKENIZE_CRLF
|
||||
CToken* ConsumeNewline(PRUnichar aChar,CScanner& aScanner,PRInt32& anErrorCode);
|
||||
#endif
|
||||
|
||||
//the only special case method...
|
||||
virtual CToken* ConsumeContentToEndTag(const nsString& aString,PRUnichar aChar,CScanner& aScanner,PRInt32& anErrorCode);
|
||||
|
||||
nsDeque mTokenDeque;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
@ -523,16 +523,8 @@ PRInt32 CTextToken::GetTokenType(void) {
|
|||
* @return error result
|
||||
*------------------------------------------------------*/
|
||||
PRInt32 CTextToken::Consume(PRUnichar aChar, CScanner& aScanner) {
|
||||
|
||||
#ifdef TOKENIZE_CRLF
|
||||
static nsAutoString terminals("&<\r\n");
|
||||
#else
|
||||
static nsAutoString terminals("&<");
|
||||
#endif
|
||||
PRInt32 result=aScanner.ReadUntil(mTextValue,terminals,PR_FALSE);
|
||||
#ifndef TOKENIZE_CRLF
|
||||
mTextValue.StripChars("\r");
|
||||
#endif
|
||||
static nsAutoString terminals("&<\r\n");
|
||||
PRInt32 result=aScanner.ReadUntil(mTextValue,terminals,PR_FALSE);
|
||||
return result;
|
||||
};
|
||||
|
||||
|
@ -607,7 +599,6 @@ PRInt32 CCommentToken::GetTokenType(void) {
|
|||
return eToken_comment;
|
||||
}
|
||||
|
||||
#ifdef TOKENIZE_CRLF
|
||||
/**-------------------------------------------------------
|
||||
* default constructor
|
||||
*
|
||||
|
@ -656,7 +647,6 @@ PRInt32 CNewlineToken::Consume(PRUnichar aChar, CScanner& aScanner) {
|
|||
mTextValue.StripChars("\r");
|
||||
return result;
|
||||
};
|
||||
#endif /* TOKENIZE_CRLF */
|
||||
|
||||
/**-------------------------------------------------------
|
||||
* default constructor
|
||||
|
@ -834,7 +824,6 @@ void CAttributeToken::DebugDumpSource(ostream& out) {
|
|||
out<<">";
|
||||
}
|
||||
|
||||
#ifdef TOKENIZE_WHITESPACE
|
||||
/**-------------------------------------------------------
|
||||
* default constructor
|
||||
*
|
||||
|
@ -884,7 +873,6 @@ PRInt32 CWhitespaceToken::Consume(PRUnichar aChar, CScanner& aScanner) {
|
|||
mTextValue.StripChars("\r");
|
||||
return result;
|
||||
};
|
||||
#endif /* TOKENIZE_WHITESPACE */
|
||||
|
||||
/**-------------------------------------------------------
|
||||
* default constructor
|
||||
|
|
|
@ -35,10 +35,6 @@
|
|||
#include "nsToken.h"
|
||||
#include <iostream.h>
|
||||
|
||||
// If you define these to true then crlf sequences and whitespace come
|
||||
// through the scanner as seperate tokens.
|
||||
#undef TOKENIZE_CRLF
|
||||
#undef TOKENIZE_WHITESPACE
|
||||
|
||||
class CScanner;
|
||||
|
||||
|
@ -222,7 +218,6 @@ class CEntityToken : public CHTMLToken {
|
|||
*
|
||||
* @update gess 3/25/98
|
||||
*/ //---------------------------------------------------
|
||||
#ifdef TOKENIZE_WHITESPACE
|
||||
class CWhitespaceToken: public CHTMLToken {
|
||||
public:
|
||||
CWhitespaceToken(const nsString& aString);
|
||||
|
@ -230,7 +225,6 @@ class CWhitespaceToken: public CHTMLToken {
|
|||
virtual const char* GetClassName(void);
|
||||
virtual PRInt32 GetTokenType(void);
|
||||
};
|
||||
#endif
|
||||
|
||||
/** -----------------------------------------------------
|
||||
* Text tokens contain the normalized form of html text.
|
||||
|
@ -278,7 +272,6 @@ class CAttributeToken: public CHTMLToken {
|
|||
*
|
||||
* @update gess 3/25/98
|
||||
*/ //---------------------------------------------------
|
||||
#ifdef TOKENIZE_CRLF
|
||||
class CNewlineToken: public CHTMLToken {
|
||||
public:
|
||||
CNewlineToken(const nsString& aString);
|
||||
|
@ -286,7 +279,6 @@ class CNewlineToken: public CHTMLToken {
|
|||
virtual const char* GetClassName(void);
|
||||
virtual PRInt32 GetTokenType(void);
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
/** -----------------------------------------------------
|
||||
|
|
Загрузка…
Ссылка в новой задаче