91320 - Removed unused files from htmlparser module and created a public directory.

r= heikki
sr=vidur
This commit is contained in:
harishd%netscape.com 2001-08-03 21:15:15 +00:00
Родитель 37e7aeac02
Коммит 872f79900d
140 изменённых файлов: 6298 добавлений и 932 удалений

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

@ -44,7 +44,6 @@
#include "nsIMarkupDocumentViewer.h"
#include "nsINodeInfo.h"
#include "nsHTMLTokens.h"
#include "nsHTMLEntities.h"
#include "nsCRT.h"
#include "nsSupportsArray.h"
#include "jsapi.h" // for JSVERSION_* and JS_VersionToString

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

@ -29,7 +29,6 @@
#include "nsIHTMLContentContainer.h"
#include "nsHTMLAtoms.h"
#include "nsHTMLTokens.h"
#include "nsHTMLEntities.h"
#include "nsHTMLParts.h"
#include "nsIDOMText.h"
#include "nsIDOMComment.h"

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

@ -48,7 +48,6 @@
#include "nsIDOMCDATASection.h"
#include "nsDOMDocumentType.h"
#include "nsIHTMLContent.h"
#include "nsHTMLEntities.h"
#include "nsHTMLParts.h"
#include "nsVoidArray.h"
#include "nsCRT.h"

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

@ -23,7 +23,6 @@
#include "nsXMLDocument.h"
#include "nsWellFormedDTD.h"
#include "nsParserCIID.h"
#include "nsIParser.h"
#include "nsIXMLContent.h"

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

@ -26,7 +26,7 @@ VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
DIRS = src
DIRS = public src
ifdef ENABLE_TESTS
DIRS += robot tests

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

@ -1,33 +0,0 @@
#!nmake
#
# 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):
DEPTH=..
DIRS = src \
!if !defined(DISABLE_TESTS)
robot \
robot\test \
tests \
!endif
$(NULL)
include <$(DEPTH)\config\rules.mak>

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

@ -0,0 +1,22 @@
#
# This is a list of local files which get copied to the mozilla:htmlparser directory
#
nsIContentSink.h
nsIHTMLContentSink.h
nsIHTMLFragmentContentSink.h
nsITokenizer.h
nsIParserNode.h
nsIParserFilter.h
nsIParser.h
nsIDTD.h
nsIExpatTokenizer.h
nsIElementObserver.h
nsIParserService.h
nsHTMLTags.h
nsHTMLTagList.h
nsHTMLTokens.h
nshtmlpars.h
nsParserCIID.h
nsParserError.h
nsToken.h

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

@ -0,0 +1,60 @@
#
# 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):
#
DEPTH = ../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
MODULE = htmlparser
EXPORTS = \
nsIContentSink.h \
nsITokenizer.h \
nsIExpatTokenizer.h \
nsIHTMLContentSink.h \
nsIHTMLFragmentContentSink.h\
nsIParserNode.h \
nsIParser.h \
nsIDTD.h \
nsIParserFilter.h \
nsIElementObserver.h \
nsIParserService.h \
nshtmlpars.h \
nsHTMLTagList.h \
nsHTMLTags.h \
nsHTMLTokens.h \
nsParserError.h \
nsParserCIID.h \
nsToken.h \
$(NULL)
ifndef MOZ_DISABLE_DTD_DEBUG
EXPORTS += \
nsILoggingSink.h \
$(NULL)
endif
EXPORTS := $(addprefix $(srcdir)/, $(EXPORTS))
include $(topsrcdir)/config/rules.mk

52
htmlparser/public/makefile.win Executable file
Просмотреть файл

@ -0,0 +1,52 @@
#!nmake
#
# 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):
DEPTH=..\..
include <$(DEPTH)\config\config.mak>
MODULE = htmlparser
EXPORTS = \
nsITokenizer.h \
nsIExpatTokenizer.h \
nsIContentSink.h \
nsIHTMLContentSink.h \
nsIHTMLFragmentContentSink.h\
nsIParserNode.h \
nsIParser.h \
nsIParserFilter.h \
nsIDTD.h \
nsIElementObserver.h \
nsIParserService.h \
nshtmlpars.h \
nsHTMLTagList.h \
nsHTMLTags.h \
nsHTMLTokens.h \
nsParserError.h \
nsParserCIID.h \
nsToken.h \
!if !defined(MOZ_DISABLE_DTD_DEBUG)
nsILoggingSink.h \
!endif
$(NULL)
include <$(DEPTH)\config\rules.mak>

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

@ -0,0 +1,158 @@
/* -*- 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) 1999 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
/******
This file contains the list of all HTML tags
See nsHTMLTags.h for access to the enum values for tags
It is designed to be used as inline input to nsHTMLTags.cpp *only*
through the magic of C preprocessing.
All entires must be enclosed in the macro HTML_TAG which will have cruel
and unusual things done to it
It is recommended (but not strictly necessary) to keep all entries
in alphabetical order
The first argument to HTML_TAG is both the enum identifier of the property
and the string value
Entries *must* use only lowercase characters.
** Break these invarient and bad things will happen. **
******/
HTML_TAG(a)
HTML_TAG(abbr)
HTML_TAG(acronym)
HTML_TAG(address)
HTML_TAG(applet)
HTML_TAG(area)
HTML_TAG(b)
HTML_TAG(base)
HTML_TAG(basefont)
HTML_TAG(bdo)
HTML_TAG(bgsound)
HTML_TAG(big)
HTML_TAG(blink)
HTML_TAG(blockquote)
HTML_TAG(body)
HTML_TAG(br)
HTML_TAG(button)
HTML_TAG(caption)
HTML_TAG(center)
HTML_TAG(cite)
HTML_TAG(code)
HTML_TAG(col)
HTML_TAG(colgroup)
HTML_TAG(counter)
HTML_TAG(dd)
HTML_TAG(del)
HTML_TAG(dfn)
HTML_TAG(dir)
HTML_TAG(div)
HTML_TAG(dl)
HTML_TAG(dt)
HTML_TAG(em)
HTML_TAG(embed)
HTML_TAG(endnote)
HTML_TAG(fieldset)
HTML_TAG(font)
HTML_TAG(form)
HTML_TAG(frame)
HTML_TAG(frameset)
HTML_TAG(h1)
HTML_TAG(h2)
HTML_TAG(h3)
HTML_TAG(h4)
HTML_TAG(h5)
HTML_TAG(h6)
HTML_TAG(head)
HTML_TAG(hr)
HTML_TAG(html)
HTML_TAG(i)
HTML_TAG(iframe)
HTML_TAG(ilayer)
HTML_TAG(image)
HTML_TAG(img)
HTML_TAG(input)
HTML_TAG(ins)
HTML_TAG(isindex)
HTML_TAG(kbd)
HTML_TAG(keygen)
HTML_TAG(label)
HTML_TAG(layer)
HTML_TAG(legend)
HTML_TAG(li)
HTML_TAG(link)
HTML_TAG(listing)
HTML_TAG(map)
HTML_TAG(menu)
HTML_TAG(meta)
HTML_TAG(multicol)
HTML_TAG(nobr)
HTML_TAG(noembed)
HTML_TAG(noframes)
HTML_TAG(nolayer)
HTML_TAG(noscript)
HTML_TAG(object)
HTML_TAG(ol)
HTML_TAG(optgroup)
HTML_TAG(option)
HTML_TAG(p)
HTML_TAG(param)
HTML_TAG(parsererror)
HTML_TAG(plaintext)
HTML_TAG(pre)
HTML_TAG(q)
HTML_TAG(s)
HTML_TAG(samp)
HTML_TAG(script)
HTML_TAG(select)
HTML_TAG(server)
HTML_TAG(small)
HTML_TAG(sound)
HTML_TAG(sourcetext)
HTML_TAG(spacer)
HTML_TAG(span)
HTML_TAG(strike)
HTML_TAG(strong)
HTML_TAG(style)
HTML_TAG(sub)
HTML_TAG(sup)
HTML_TAG(table)
HTML_TAG(tbody)
HTML_TAG(td)
HTML_TAG(textarea)
HTML_TAG(tfoot)
HTML_TAG(th)
HTML_TAG(thead)
HTML_TAG(title)
HTML_TAG(tr)
HTML_TAG(tt)
HTML_TAG(u)
HTML_TAG(ul)
HTML_TAG(var)
HTML_TAG(wbr)
HTML_TAG(xmp)

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

@ -0,0 +1,68 @@
/* -*- 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 Communicator client 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):
*/
#ifndef nsHTMLTags_h___
#define nsHTMLTags_h___
#include "nshtmlpars.h"
class nsString;
class nsCString;
/*
Declare the enum list using the magic of preprocessing
enum values are "eHTMLTag_foo" (where foo is the tag)
To change the list of tags, see nsHTMLTagList.h
*/
#define HTML_TAG(_tag) eHTMLTag_##_tag,
enum nsHTMLTag {
/* this enum must be first and must be zero */
eHTMLTag_unknown = 0,
#include "nsHTMLTagList.h"
/* The remaining enums are not for tags */
eHTMLTag_text, eHTMLTag_whitespace, eHTMLTag_newline,
eHTMLTag_comment, eHTMLTag_entity, eHTMLTag_doctypeDecl,
eHTMLTag_markupDecl, eHTMLTag_instruction,
eHTMLTag_userdefined
};
#undef HTML_TAG
// Currently there are 112 HTML tags. eHTMLTag_text = 114.
#define NS_HTML_TAG_MAX PRInt32(eHTMLTag_text - 1)
class NS_HTMLPARS nsHTMLTags {
public:
static void AddRefTable(void);
static void ReleaseTable(void);
static nsHTMLTag LookupTag(const nsString& aTag);
static nsHTMLTag LookupTag(const nsCString& aTag);
static const nsCString& GetStringValue(nsHTMLTag aEnum);
static const char* GetCStringValue(nsHTMLTag aEnum);
};
#define eHTMLTags nsHTMLTag
#endif /* nsHTMLTags_h___ */

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

@ -0,0 +1,515 @@
/* -*- 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
*
* This file contains the declarations for all the HTML specific token types that
* our DTD's understand. In fact, the same set of token types are used for XML.
* Currently we have tokens for text, comments, start and end tags, entities,
* attributes, style, script and skipped content. Whitespace and newlines also
* have their own token types, but don't count on them to stay forever.
*
* If you're looking for the html tags, they're in a file called nsHTMLTag.h/cpp.
*
* Most of the token types have a similar API. They have methods to get the type
* of token (GetTokenType); those that represent HTML tags also have a method to
* get type tag type (GetTypeID). In addition, most have a method that causes the
* token to help in the parsing process called (Consume). We've also thrown in a
* few standard debugging methods as well.
*/
#ifndef HTMLTOKENS_H
#define HTMLTOKENS_H
#include "nsToken.h"
#include "nsHTMLTags.h"
#include "nsParserError.h"
#include "nsString.h"
#include "nsSlidingString.h"
class nsScanner;
/*******************************************************************
* This enum defines the set of token types that we currently support.
*******************************************************************/
enum eHTMLTokenTypes {
eToken_unknown=0,
eToken_start=1, eToken_end, eToken_comment, eToken_entity,
eToken_whitespace, eToken_newline, eToken_text, eToken_attribute,
eToken_script, eToken_style, eToken_skippedcontent, eToken_instruction,
eToken_cdatasection, eToken_error, eToken_doctypeDecl, eToken_markupDecl,
eToken_last //make sure this stays the last token...
};
enum eHTMLCategory {
eHTMLCategory_unknown=0,
eHTMLCategory_inline,
eHTMLCategory_block,
eHTMLCategory_blockAndInline,
eHTMLCategory_list,
eHTMLCategory_table,
eHTMLCategory_tablepart,
eHTMLCategory_tablerow,
eHTMLCategory_tabledata,
eHTMLCategory_head,
eHTMLCategory_html,
eHTMLCategory_body,
eHTMLCategory_form,
eHTMLCategory_options,
eHTMLCategory_frameset,
eHTMLCategory_text
};
nsresult ConsumeQuotedString(PRUnichar aChar,nsString& aString,nsScanner& aScanner);
nsresult ConsumeAttributeText(PRUnichar aChar,nsString& aString,nsScanner& aScanner);
const char* GetTagName(PRInt32 aTag);
//PRInt32 FindEntityIndex(nsString& aString,PRInt32 aCount=-1);
/**
* This declares the basic token type used in the HTML DTD's.
* @update gess 3/25/98
*/
class CHTMLToken : public CToken {
public:
virtual ~CHTMLToken();
CHTMLToken(eHTMLTags aTag);
virtual eContainerInfo GetContainerInfo(void) const {return eFormUnknown;}
virtual void SetContainerInfo(eContainerInfo aInfo) { }
protected:
};
/**
* This declares start tokens, which always take the form <xxxx>.
* This class also knows how to consume related attributes.
*
* @update gess 3/25/98
*/
class CStartToken: public CHTMLToken {
CTOKEN_IMPL_SIZEOF
public:
CStartToken(eHTMLTags aTag=eHTMLTag_unknown);
CStartToken(const nsAReadableString& aString);
CStartToken(const nsAReadableString& aName,eHTMLTags aTag);
virtual nsresult Consume(PRUnichar aChar,nsScanner& aScanner,PRInt32 aMode);
virtual PRInt32 GetTypeID(void);
virtual const char* GetClassName(void);
virtual PRInt32 GetTokenType(void);
PRBool IsAttributed(void);
void SetAttributed(PRBool aValue);
PRBool IsEmpty(void);
void SetEmpty(PRBool aValue);
virtual void DebugDumpSource(nsOutputStream& out);
virtual const nsAReadableString& GetStringValue();
virtual void GetSource(nsString& anOutputString);
virtual void AppendSource(nsString& anOutputString);
//the following info is used to set well-formedness state on start tags...
virtual eContainerInfo GetContainerInfo(void) const {return mContainerInfo;}
virtual void SetContainerInfo(eContainerInfo aContainerInfo) {mContainerInfo=aContainerInfo;}
virtual PRBool IsWellFormed(void) const {return PRBool(eWellFormed==mContainerInfo);}
/*
* Get and set the ID attribute atom for this element.
* See http://www.w3.org/TR/1998/REC-xml-19980210#sec-attribute-types
* for the definition of an ID attribute.
*
*/
virtual nsresult GetIDAttributeAtom(nsIAtom** aResult);
virtual nsresult SetIDAttributeAtom(nsIAtom* aID);
nsString mTextValue;
nsString mTrailingContent;
PRInt32 mOrigin;
protected:
PRBool mAttributed;
PRBool mEmpty;
eContainerInfo mContainerInfo;
nsCOMPtr<nsIAtom> mIDAttributeAtom;
};
/**
* This declares end tokens, which always take the
* form </xxxx>. This class also knows how to consume
* related attributes.
*
* @update gess 3/25/98
*/
class CEndToken: public CHTMLToken {
CTOKEN_IMPL_SIZEOF
public:
CEndToken(eHTMLTags aTag);
CEndToken(const nsAReadableString& aString);
CEndToken(const nsAReadableString& aName,eHTMLTags aTag);
virtual nsresult Consume(PRUnichar aChar,nsScanner& aScanner,PRInt32 aMode);
virtual PRInt32 GetTypeID(void);
virtual const char* GetClassName(void);
virtual PRInt32 GetTokenType(void);
virtual void DebugDumpSource(nsOutputStream& out);
virtual const nsAReadableString& GetStringValue();
virtual void GetSource(nsString& anOutputString);
virtual void AppendSource(nsString& anOutputString);
protected:
nsString mTextValue;
};
/**
* This declares comment tokens. Comments are usually
* thought of as tokens, but we treat them that way
* here so that the parser can have a consistent view
* of all tokens.
*
* @update gess 3/25/98
*/
class CCommentToken: public CHTMLToken {
CTOKEN_IMPL_SIZEOF
public:
CCommentToken();
CCommentToken(const nsAReadableString& aString);
virtual nsresult Consume(PRUnichar aChar,nsScanner& aScanner,PRInt32 aMode);
virtual const char* GetClassName(void);
virtual PRInt32 GetTokenType(void);
virtual const nsAReadableString& GetStringValue(void);
char mLeadingChar;
protected:
nsString mTextValue;
};
/**
* This class declares entity tokens, which always take
* the form &xxxx;. This class also offers a few utility
* methods that allow you to easily reduce entities.
*
* @update gess 3/25/98
*/
class CEntityToken : public CHTMLToken {
CTOKEN_IMPL_SIZEOF
public:
CEntityToken();
CEntityToken(const nsAReadableString& aString);
virtual const char* GetClassName(void);
virtual PRInt32 GetTokenType(void);
PRInt32 TranslateToUnicodeStr(nsString& aString);
virtual nsresult Consume(PRUnichar aChar,nsScanner& aScanner,PRInt32 aMode);
static nsresult ConsumeEntity(PRUnichar aChar,nsString& aString,nsScanner& aScanner);
static PRInt32 TranslateToUnicodeStr(PRInt32 aValue,nsString& aString);
virtual void DebugDumpSource(nsOutputStream& out);
virtual const nsAReadableString& GetStringValue(void);
virtual void GetSource(nsString& anOutputString);
virtual void AppendSource(nsString& anOutputString);
protected:
nsString mTextValue;
};
/**
* Whitespace tokens are used where whitespace can be
* detected as distinct from text. This allows us to
* easily skip leading/trailing whitespace when desired.
*
* @update gess 3/25/98
*/
class CWhitespaceToken: public CHTMLToken {
CTOKEN_IMPL_SIZEOF
public:
CWhitespaceToken();
CWhitespaceToken(const nsAReadableString& aString);
virtual nsresult Consume(PRUnichar aChar,nsScanner& aScanner,PRInt32 aMode);
virtual const char* GetClassName(void);
virtual PRInt32 GetTokenType(void);
virtual const nsAReadableString& GetStringValue(void);
protected:
nsString mTextValue;
};
/**
* Text tokens contain the normalized form of html text.
* These tokens are guaranteed not to contain entities,
* start or end tags, or newlines.
*
* @update gess 3/25/98
*/
class CTextToken: public CHTMLToken {
CTOKEN_IMPL_SIZEOF
public:
CTextToken();
CTextToken(const nsAReadableString& aString);
virtual nsresult Consume(PRUnichar aChar,nsScanner& aScanner,PRInt32 aMode);
nsresult ConsumeUntil(PRUnichar aChar,PRBool aIgnoreComments,nsScanner& aScanner,
nsString& aEndTagName,PRInt32 aMode,PRBool& aFlushTokens);
virtual const char* GetClassName(void);
virtual PRInt32 GetTokenType(void);
virtual PRInt32 GetTextLength(void);
virtual void CopyTo(nsAWritableString& aStr);
virtual const nsAReadableString& GetStringValue(void);
virtual void Bind(nsScanner* aScanner, nsReadingIterator<PRUnichar>& aStart, nsReadingIterator<PRUnichar>& aEnd);
virtual void Bind(const nsAReadableString& aStr);
protected:
nsSlidingSubstring mTextValue;
};
/**
* CDATASection tokens contain raw unescaped text content delimited by
* a ![CDATA[ and ]].
* XXX Not really a HTML construct - maybe we need a separation
*
* @update vidur 11/12/98
*/
class CCDATASectionToken : public CHTMLToken {
CTOKEN_IMPL_SIZEOF
public:
CCDATASectionToken();
CCDATASectionToken(const nsAReadableString& aString);
virtual nsresult Consume(PRUnichar aChar,nsScanner& aScanner,PRInt32 aMode);
virtual const char* GetClassName(void);
virtual PRInt32 GetTokenType(void);
virtual const nsAReadableString& GetStringValue(void);
protected:
nsString mTextValue;
};
/**
* Declaration tokens contain raw unescaped text content (not really, but
* right now we use this only for view source).
* XXX Not really a HTML construct - maybe we need a separation
*
*/
class CMarkupDeclToken : public CHTMLToken {
CTOKEN_IMPL_SIZEOF
public:
CMarkupDeclToken();
CMarkupDeclToken(const nsAReadableString& aString);
virtual nsresult Consume(PRUnichar aChar,nsScanner& aScanner,PRInt32 aMode);
virtual const char* GetClassName(void);
virtual PRInt32 GetTokenType(void);
virtual const nsAReadableString& GetStringValue(void);
protected:
nsSlidingSubstring mTextValue;
};
/**
* Attribute tokens are used to contain attribute key/value
* pairs whereever they may occur. Typically, they should
* occur only in start tokens. However, we may expand that
* ability when XML tokens become commonplace.
*
* @update gess 3/25/98
*/
class CAttributeToken: public CHTMLToken {
CTOKEN_IMPL_SIZEOF
public:
CAttributeToken();
CAttributeToken(const nsAReadableString& aString);
CAttributeToken(const nsAReadableString& aKey, const nsAReadableString& aString);
~CAttributeToken() {}
virtual nsresult Consume(PRUnichar aChar,nsScanner& aScanner,PRInt32 aMode);
virtual const char* GetClassName(void);
virtual PRInt32 GetTokenType(void);
virtual const nsAReadableString& GetKey(void) {return mTextKey;}
virtual void SetKey(const nsAReadableString& aKey);
virtual void BindKey(nsScanner* aScanner, nsReadingIterator<PRUnichar>& aStart, nsReadingIterator<PRUnichar>& aEnd);
virtual const nsString& GetValue(void) {return mTextValue;}
virtual void SanitizeKey();
virtual void DebugDumpToken(nsOutputStream& out);
virtual const nsAReadableString& GetStringValue(void);
virtual void GetSource(nsString& anOutputString);
virtual void AppendSource(nsString& anOutputString);
virtual void DebugDumpSource(nsOutputStream& out);
PRBool mLastAttribute;
PRBool mHasEqualWithoutValue;
protected:
nsAutoString mTextValue;
nsSlidingSubstring mTextKey;
};
/**
* Newline tokens contain, you guessed it, newlines.
* They consume newline (CR/LF) either alone or in pairs.
*
* @update gess 3/25/98
*/
class CNewlineToken: public CHTMLToken {
CTOKEN_IMPL_SIZEOF
public:
CNewlineToken();
virtual nsresult Consume(PRUnichar aChar,nsScanner& aScanner,PRInt32 aMode);
virtual const char* GetClassName(void);
virtual PRInt32 GetTokenType(void);
virtual const nsAReadableString& GetStringValue(void);
static void AllocNewline();
static void FreeNewline();
};
/**
* Script tokens contain sequences of javascript (or, gulp,
* any other script you care to send). We don't tokenize
* it here, nor validate it. We just wrap it up, and pass
* it along to the html parser, who sends it (later on)
* to the scripting engine.
*
* @update gess 3/25/98
*/
class CScriptToken: public CHTMLToken {
CTOKEN_IMPL_SIZEOF
public:
CScriptToken();
CScriptToken(const nsAReadableString& aString);
virtual const char* GetClassName(void);
virtual PRInt32 GetTokenType(void);
virtual const nsAReadableString& GetStringValue(void);
protected:
nsString mTextValue;
};
/**
* Style tokens contain sequences of css style. We don't
* tokenize it here, nor validate it. We just wrap it up,
* and pass it along to the html parser, who sends it
* (later on) to the style engine.
*
* @update gess 3/25/98
*/
class CStyleToken: public CHTMLToken {
CTOKEN_IMPL_SIZEOF
public:
CStyleToken();
CStyleToken(const nsAReadableString& aString);
virtual const char* GetClassName(void);
virtual PRInt32 GetTokenType(void);
virtual const nsAReadableString& GetStringValue(void);
protected:
nsString mTextValue;
};
/**
* Whitespace tokens are used where whitespace can be
* detected as distinct from text. This allows us to
* easily skip leading/trailing whitespace when desired.
*
* @update gess 3/25/98
*/
class CInstructionToken: public CHTMLToken {
CTOKEN_IMPL_SIZEOF
public:
CInstructionToken();
CInstructionToken(const nsAReadableString& aString);
virtual nsresult Consume(PRUnichar aChar,nsScanner& aScanner,PRInt32 aMode);
virtual const char* GetClassName(void);
virtual PRInt32 GetTokenType(void);
virtual const nsAReadableString& GetStringValue(void);
protected:
nsString mTextValue;
};
class CErrorToken : public CHTMLToken {
CTOKEN_IMPL_SIZEOF
public:
CErrorToken(nsParserError* aError=0);
~CErrorToken();
virtual const char* GetClassName(void);
virtual PRInt32 GetTokenType(void);
void SetError(nsParserError* aError); // CErrorToken takes ownership of aError
// The nsParserError object returned by GetError is still owned by CErrorToken.
// DO NOT use the delete operator on it. Should we change this so that a copy
// of nsParserError is returned which needs to be destroyed by the consumer?
const nsParserError* GetError(void);
virtual const nsAReadableString& GetStringValue(void);
protected:
nsString mTextValue;
nsParserError* mError;
};
/**
* This token is generated by the HTML and Expat tokenizers
* when they see the doctype declaration ("<!DOCTYPE ... >")
*
*/
class CDoctypeDeclToken: public CHTMLToken {
CTOKEN_IMPL_SIZEOF
public:
CDoctypeDeclToken(eHTMLTags aTag=eHTMLTag_unknown);
CDoctypeDeclToken(const nsAReadableString& aString,eHTMLTags aTag=eHTMLTag_unknown);
virtual nsresult Consume(PRUnichar aChar,nsScanner& aScanner,PRInt32 aMode);
virtual const char* GetClassName(void);
virtual PRInt32 GetTokenType(void);
virtual const nsAReadableString& GetStringValue(void);
virtual void SetStringValue(const nsAReadableString& aStr);
protected:
nsString mTextValue;
};
#endif

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

@ -0,0 +1,178 @@
/* -*- 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 Communicator client 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):
*/
#ifndef nsIContentSink_h___
#define nsIContentSink_h___
/**
* MODULE NOTES:
* @update gess 4/1/98
*
* This pure virtual interface is used as the "glue" that connects the parsing
* process to the content model construction process.
*
* The icontentsink interface is a very lightweight wrapper that represents the
* content-sink model building process. There is another one that you may care
* about more, which is the IHTMLContentSink interface. (See that file for details).
*/
#include "nsIParserNode.h"
#include "nsISupports.h"
#include "nsParserError.h"
class nsIParser;
#define NS_ICONTENT_SINK_IID \
{ 0xa6cf9052, 0x15b3, 0x11d2,{0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32}}
// The base value for the content ID counter.
// Values greater than or equal to this base value are used
// by each of the content sinks to assign unique values
// to the content objects created by them.
#define NS_CONTENT_ID_COUNTER_BASE 10000
class nsIContentSink : public nsISupports {
public:
NS_DEFINE_STATIC_IID_ACCESSOR(NS_ICONTENT_SINK_IID)
/**
* This method gets called when the parser begins the process
* of building the content model via the content sink.
*
* @update 5/7/98 gess
*/
NS_IMETHOD WillBuildModel(void)=0;
/**
* This method gets called when the parser concludes the process
* of building the content model via the content sink.
*
* @param aQualityLevel describes how well formed the doc was.
* 0=GOOD; 1=FAIR; 2=POOR;
* @update 5/7/98 gess
*/
NS_IMETHOD DidBuildModel(PRInt32 aQualityLevel)=0;
/**
* This method gets called when the parser gets i/o blocked,
* and wants to notify the sink that it may be a while before
* more data is available.
*
* @update 5/7/98 gess
*/
NS_IMETHOD WillInterrupt(void)=0;
/**
* This method gets called when the parser i/o gets unblocked,
* and we're about to start dumping content again to the sink.
*
* @update 5/7/98 gess
*/
NS_IMETHOD WillResume(void)=0;
/**
* This method gets called by the parser so that the content
* sink can retain a reference to the parser. The expectation
* is that the content sink will drop the reference when it
* gets the DidBuildModel notification i.e. when parsing is done.
*/
NS_IMETHOD SetParser(nsIParser* aParser)=0;
/**
* This method is used to open a generic container in the sink.
*
* @update 4/1/98 gess
* @param nsIParserNode reference to parser node interface
*/
NS_IMETHOD OpenContainer(const nsIParserNode& aNode) = 0;
/**
* This method gets called by the parser when a close
* container tag has been consumed and needs to be closed.
*
* @update 4/1/98 gess
* @param nsIParserNode reference to parser node interface
*/
NS_IMETHOD CloseContainer(const nsIParserNode& aNode) = 0;
/**
* This gets called by the parser when you want to add
* a leaf node to the current container in the content
* model.
*
* @update 4/1/98 gess
* @param nsIParserNode reference to parser node interface
*/
NS_IMETHOD AddLeaf(const nsIParserNode& aNode) = 0;
/**
* This gets called by the parser when you want to add
* a leaf node to the current container in the content
* model.
*
* @update 4/1/98 gess
* @param nsIParserNode reference to parser node interface
*/
NS_IMETHOD AddComment(const nsIParserNode& aNode) = 0;
/**
* This gets called by the parser when you want to add
* a leaf node to the current container in the content
* model.
*
* @update 4/1/98 gess
* @param nsIParserNode reference to parser node interface
*/
NS_IMETHOD AddProcessingInstruction(const nsIParserNode& aNode) = 0;
/**
* This method is called by the parser when it encounters
* a document type declaration.
*
* XXX Should the parser also part the internal subset?
*
* @param nsIParserNode reference to parser node interface
*/
NS_IMETHOD AddDocTypeDecl(const nsIParserNode& aNode, PRInt32 aMode)=0;
/**
* This gets called by the parser if it hits an unrecoverable
* error (in XML, if the document is not well-formed or valid).
*
* @param aErrorResult the error code
*/
NS_IMETHOD NotifyError(const nsParserError* aError)=0;
/**
* Flush all pending notifications so that the content model
* is in sync with the state of the sink.
*/
NS_IMETHOD FlushPendingNotifications()=0;
/**
* Set the document character set. This should be passed on to the
* document itself.
*/
NS_IMETHOD SetDocumentCharset(nsAWritableString& aCharset)=0;
};
#endif /* nsIContentSink_h___ */

209
htmlparser/public/nsIDTD.h Normal file
Просмотреть файл

@ -0,0 +1,209 @@
/* -*- 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):
*/
#ifndef nsIDTD_h___
#define nsIDTD_h___
/**
* MODULE NOTES:
* @update gess 7/20/98
*
* This interface defines standard interface for DTD's. Note that this isn't HTML specific.
* DTD's have several primary functions within the parser system:
* 1) To coordinate the consumption of an input stream via the parser
* 2) To serve as proxy to represent the containment rules of the underlying document
* 3) To offer autodetection services to the parser (mainly for doc conversion)
*
*/
#include "nsISupports.h"
#include "prtypes.h"
#include "nsITokenizer.h"
#define NS_IDTD_IID \
{ 0xa6cf9053, 0x15b3, 0x11d2,{0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32}}
enum eAutoDetectResult {
eUnknownDetect,
eValidDetect,
ePrimaryDetect,
eInvalidDetect
};
enum nsDTDMode {
eDTDMode_unknown=0,
eDTDMode_quirks, //pre 4.0 versions
eDTDMode_transitional,
eDTDMode_strict,
eDTDMode_autodetect
};
class nsIParser;
class CToken;
class nsIURI;
class nsString;
class nsIContentSink;
class CParserContext;
class nsIDTD : public nsISupports {
public:
static const nsIID& GetIID() { static nsIID iid = NS_IDTD_IID; return iid; }
virtual const nsIID& GetMostDerivedIID(void) const =0;
/**
* Call this method if you want the DTD to construct a clone of itself.
* @update gess7/23/98
* @param
* @return
*/
virtual nsresult CreateNewInstance(nsIDTD** aInstancePtrResult)=0;
/**
* 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 aContentType -- string representing type of doc to be converted (ie text/html)
* @return TRUE if this DTD can satisfy the request; FALSE otherwise.
*/
virtual eAutoDetectResult CanParse(CParserContext& aParserContext,nsString& aBuffer, PRInt32 aVersion)=0;
/**
* Called by the parser just before the parsing process begins
* @update gess5/18/98
* @param aFilename--string that contains name of file being parsed (if applicable)
* @return
*/
NS_IMETHOD WillBuildModel( const CParserContext& aParserContext,nsIContentSink* aSink=0)=0;
/**
* Called by the parser after the parsing process has concluded
* @update gess5/18/98
* @param anErrorCode - contains error code resulting from parse process
* @return
*/
NS_IMETHOD DidBuildModel(nsresult anErrorCode,PRBool aNotifySink,nsIParser* aParser,nsIContentSink* aSink=0)=0;
/**
* Called by the parser after the parsing process has concluded
* @update gess5/18/98
* @param anErrorCode - contains error code resulting from parse process
* @return
*/
NS_IMETHOD BuildModel(nsIParser* aParser,nsITokenizer* aTokenizer,nsITokenObserver* anObserver=0,nsIContentSink* aSink=0)=0;
/**
* Called during model building phase of parse process. Each token created during
* the parse phase is stored in a deque (in the parser) and are passed to this method
* so that the DTD can process the token. Ultimately, the DTD will transform given
* token into calls onto a contentsink.
* @update gess 3/25/98
* @param aToken -- token object to be put into content model
* @return error code (usually 0)
*/
NS_IMETHOD HandleToken(CToken* aToken,nsIParser* aParser)=0;
/**
*
* @update gess 12/20/99
* @param ptr-ref to (out) tokenizer
* @return nsresult
*/
NS_IMETHOD GetTokenizer(nsITokenizer*& aTokenizer)=0;
virtual nsTokenAllocator* GetTokenAllocator(void)=0;
/**
* If the parse process gets interrupted midway, this method is called by the
* parser prior to resuming the process.
* @update gess5/18/98
* @return ignored
*/
NS_IMETHOD WillResumeParse(void)=0;
/**
* If the parse process gets interrupted, this method is called by the parser
* to notify the DTD that interruption will occur.
* @update gess5/18/98
* @return ignored
*/
NS_IMETHOD WillInterruptParse(void)=0;
/**
* 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 CanContain(PRInt32 aParent,PRInt32 aChild) const =0;
/**
* 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 IsContainer(PRInt32 aTag) const=0;
/**
* 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(nsIParser* aParser=nsnull) = 0;
/* XXX Temporary measure, pending further work by RickG */
/**
* Give rest of world access to our tag enums, so that CanContain(), etc,
* become useful.
*/
NS_IMETHOD StringTagToIntTag(nsString &aTag, PRInt32* aIntTag) const =0;
NS_IMETHOD IntTagToStringTag(PRInt32 aIntTag, nsString& aTag) const =0;
NS_IMETHOD ConvertEntityToUnicode(const nsString& aEntity, PRInt32* aUnicode) const =0;
virtual PRBool IsBlockElement(PRInt32 aTagID,PRInt32 aParentID) const=0;
virtual PRBool IsInlineElement(PRInt32 aTagID,PRInt32 aParentID) const=0;
};
#endif /* nsIDTD_h___ */

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

@ -0,0 +1,75 @@
/* -*- 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) 1999 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s): Rick Gessner
*/
/**
* MODULE NOTES:
* @update rickg 03.23.2000 //removed unused NS_PARSER_SUBJECT and predecl of nsString
*
*/
#ifndef nsIElementObserver_h__
#define nsIElementObserver_h__
#include "nsISupports.h"
#include "prtypes.h"
#include "nsHTMLTags.h"
#include "nsVoidArray.h"
// {4672AA04-F6AE-11d2-B3B7-00805F8A6670}
#define NS_IELEMENTOBSERVER_IID \
{ 0x4672aa04, 0xf6ae, 0x11d2, { 0xb3, 0xb7, 0x0, 0x80, 0x5f, 0x8a, 0x66, 0x70 } }
class nsIElementObserver : public nsISupports {
public:
static const nsIID& GetIID() { static nsIID iid = NS_IELEMENTOBSERVER_IID; return iid; }
/*
* This method return the tag which the observer care about
*/
NS_IMETHOD_(const char*)GetTagNameAt(PRUint32 aTagIndex) = 0;
/*
* Subject call observer when the parser hit the tag
* @param aDocumentID- ID of the document
* @param aTag- the tag
* @param numOfAttributes - number of attributes
* @param nameArray - array of name.
* @param valueArray - array of value
*/
NS_IMETHOD Notify(PRUint32 aDocumentID, eHTMLTags aTag,
PRUint32 numOfAttributes, const PRUnichar* nameArray[],
const PRUnichar* valueArray[]) = 0;
NS_IMETHOD Notify(PRUint32 aDocumentID, const PRUnichar* aTag,
PRUint32 numOfAttributes, const PRUnichar* nameArray[],
const PRUnichar* valueArray[]) = 0;
NS_IMETHOD Notify(nsISupports* aDocumentID, const PRUnichar* aTag,
const nsStringArray* aKeys, const nsStringArray* aValues) = 0;
};
#endif /* nsIElementObserver_h__ */

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

@ -0,0 +1,61 @@
/* -*- 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 nra 2/24/99
*
*/
#ifndef __NSIEXPATTOKENIZER__
#define __NSIEXPATTOKENIZER__
#include "nsISupports.h"
#include "prtypes.h"
#include "xmlparse.h"
class CToken;
class nsScanner;
#define NS_IEXPATTOKENIZER_IID \
{0xf86a4380, 0xce17, 0x11d2, {0x80, 0x3f, 0x00, 0x60, 0x08, 0x98, 0x28, 0x77}}
class nsIExpatTokenizer : public nsITokenizer {
public:
/* Methods for setting callbacks on the expat parser */
virtual void SetElementHandler(XML_StartElementHandler start, XML_EndElementHandler end)=0;
virtual void SetCharacterDataHandler(XML_CharacterDataHandler handler)=0;
virtual void SetProcessingInstructionHandler(XML_ProcessingInstructionHandler handler)=0;
virtual void SetDefaultHandler(XML_DefaultHandler handler)=0;
virtual void SetUnparsedEntityDeclHandler(XML_UnparsedEntityDeclHandler handler)=0;
virtual void SetNotationDeclHandler(XML_NotationDeclHandler handler)=0;
virtual void SetExternalEntityRefHandler(XML_ExternalEntityRefHandler handler)=0;
virtual void SetUnknownEncodingHandler(XML_UnknownEncodingHandler handler, void *encodingHandlerData)=0;
virtual void FrontloadMisplacedContent(nsDeque& aDeque)=0;
};
#endif

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

@ -0,0 +1,267 @@
/* -*- 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 Communicator client 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):
*/
#ifndef nsIHTMLContentSink_h___
#define nsIHTMLContentSink_h___
/**
* MODULE NOTES:
* @update gess 4/1/98
*
* This file declares the concrete HTMLContentSink class.
* This class is used during the parsing process as the
* primary interface between the parser and the content
* model.
*
* After the tokenizer completes, the parser iterates over
* the known token list. As the parser identifies valid
* elements, it calls the contentsink interface to notify
* the content model that a new node or child node is being
* created and added to the content model.
*
* The HTMLContentSink interface assumes 4 underlying
* containers: HTML, HEAD, BODY and FRAMESET. Before
* accessing any these, the parser will call the appropriate
* OpennsIHTMLContentSink method: OpenHTML,OpenHead,OpenBody,OpenFrameSet;
* likewise, the ClosensIHTMLContentSink version will be called when the
* parser is done with a given section.
*
* IMPORTANT: The parser may Open each container more than
* once! This is due to the irregular nature of HTML files.
* For example, it is possible to encounter plain text at
* the start of an HTML document (that preceeds the HTML tag).
* Such text is treated as if it were part of the body.
* In such cases, the parser will Open the body, pass the text-
* node in and then Close the body. The body will likely be
* re-Opened later when the actual <BODY> tag has been seen.
*
* Containers within the body are Opened and Closed
* using the OpenContainer(...) and CloseContainer(...) calls.
* It is assumed that the document or contentSink is
* maintaining its state to manage where new content should
* be added to the underlying document.
*
* NOTE: OpenHTML() and OpenBody() may get called multiple times
* in the same document. That's fine, and it doesn't mean
* that we have multiple bodies or HTML's.
*
* NOTE: I haven't figured out how sub-documents (non-frames)
* are going to be handled. Stay tuned.
*/
#include "nsIParserNode.h"
#include "nsIContentSink.h"
#define NS_IHTML_CONTENT_SINK_IID \
{ 0xa6cf9051, 0x15b3, 0x11d2,{0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32}}
#ifdef XP_MAC
#define MAX_REFLOW_DEPTH 75 //setting to 75 to prevent layout from crashing on mac. Bug 55095.
#else
#define MAX_REFLOW_DEPTH 200 //windows and linux (etc) can do much deeper structures.
#endif
class nsIHTMLContentSink : public nsIContentSink {
public:
static const nsIID& GetIID() { static nsIID iid = NS_IHTML_CONTENT_SINK_IID; return iid; }
/**
* This method gets called by the parser when it encounters
* a title tag and wants to set the document title in the sink.
*
* @update 4/1/98 gess
* @param nsString reference to new title value
*/
NS_IMETHOD SetTitle(const nsString& aValue)=0;
/**
* This method is used to open the outer HTML container.
*
* @update 4/1/98 gess
* @param nsIParserNode reference to parser node interface
*/
NS_IMETHOD OpenHTML(const nsIParserNode& aNode)=0;
/**
* This method is used to close the outer HTML container.
*
* @update 4/1/98 gess
* @param nsIParserNode reference to parser node interface
*/
NS_IMETHOD CloseHTML(const nsIParserNode& aNode)=0;
/**
* This method is used to open the only HEAD container.
*
* @update 4/1/98 gess
* @param nsIParserNode reference to parser node interface
*/
NS_IMETHOD OpenHead(const nsIParserNode& aNode)=0;
/**
* This method is used to close the only HEAD container.
*
* @update 4/1/98 gess
* @param nsIParserNode reference to parser node interface
*/
NS_IMETHOD CloseHead(const nsIParserNode& aNode)=0;
/**
* This method is used to open the main BODY container.
*
* @update 4/1/98 gess
* @param nsIParserNode reference to parser node interface
*/
NS_IMETHOD OpenBody(const nsIParserNode& aNode)=0;
/**
* This method is used to close the main BODY container.
*
* @update 4/1/98 gess
* @param nsIParserNode reference to parser node interface
*/
NS_IMETHOD CloseBody(const nsIParserNode& aNode)=0;
/**
* This method is used to open a new FORM container.
*
* @update 4/1/98 gess
* @param nsIParserNode reference to parser node interface
*/
NS_IMETHOD OpenForm(const nsIParserNode& aNode)=0;
/**
* This method is used to close the outer FORM container.
*
* @update 4/1/98 gess
* @param nsIParserNode reference to parser node interface
*/
NS_IMETHOD CloseForm(const nsIParserNode& aNode)=0;
/**
* This method is used to open a new MAP container.
*
* @update 4/1/98 gess
* @param nsIParserNode reference to parser node interface
*/
NS_IMETHOD OpenMap(const nsIParserNode& aNode)=0;
/**
* This method is used to close the MAP container.
*
* @update 4/1/98 gess
* @param nsIParserNode reference to parser node interface
*/
NS_IMETHOD CloseMap(const nsIParserNode& aNode)=0;
/**
* This method is used to open the FRAMESET container.
*
* @update 4/1/98 gess
* @param nsIParserNode reference to parser node interface
*/
NS_IMETHOD OpenFrameset(const nsIParserNode& aNode)=0;
/**
* This method is used to close the FRAMESET container.
*
* @update 4/1/98 gess
* @param nsIParserNode reference to parser node interface
*/
NS_IMETHOD CloseFrameset(const nsIParserNode& aNode)=0;
/**
* This method tells the sink whether or not it is
* encoding an HTML fragment or the whole document.
* By default, the entire document is encoded.
*
* @update 03/14/99 gpk
* @param aFlag set to true if only encoding a fragment
*/
NS_IMETHOD DoFragment(PRBool aFlag)=0;
/**
* This gets called when handling illegal contents, especially
* in dealing with tables. This method creates a new context.
*
* @update 04/04/99 harishd
* @param aPosition - The position from where the new context begins.
*/
NS_IMETHOD BeginContext(PRInt32 aPosition)=0;
/**
* This method terminates any new context that got created by
* BeginContext and switches back to the main context.
*
* @update 04/04/99 harishd
* @param aPosition - Validates the end of a context.
*/
NS_IMETHOD EndContext(PRInt32 aPosition)=0;
/**
* Use this method to retrieve pref. for the tag.
*
* @update 04/11/01 harishd
* @param aTag - Check pref. for this tag.
*/
NS_IMETHOD GetPref(PRInt32 aTag,PRBool& aPref)=0;
/**
* This method is called when parser is about to begin
* synchronously processing a chunk of tokens.
*/
NS_IMETHOD WillProcessTokens(void)=0;
/**
* This method is called when parser has
* completed processing a chunk of tokens. The processing of the
* tokens may be interrupted by returning NS_ERROR_HTMLPARSER_INTERRUPTED from
* DidProcessAToken.
*/
NS_IMETHOD DidProcessTokens()=0;
/**
* This method is called when parser is about to
* process a single token
*/
NS_IMETHOD WillProcessAToken(void)=0;
/**
* This method is called when parser has completed
* the processing for a single token.
* @return NS_OK if processing should not be interrupted
* NS_ERROR_HTMLPARSER_INTERRUPTED if the parsing should be interrupted
*/
NS_IMETHOD DidProcessAToken(void)=0;
};
#if !defined(MOZ_DISABLE_DTD_DEBUG)
#include "nshtmlpars.h"
extern NS_HTMLPARS nsresult NS_NewHTMLNullSink(nsIContentSink** aInstancePtrResult);
#endif
#endif /* nsIHTMLContentSink_h___ */

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

@ -0,0 +1,44 @@
/* -*- 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 Communicator client 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):
*/
#ifndef nsIHTMLFragmentContentSink_h___
#define nsIHTMLFragmentContentSink_h___
#include "nsIHTMLContentSink.h"
class nsIDOMDocumentFragment;
#define NS_IHTML_FRAGMENT_CONTENT_SINK_IID \
{0xa6cf9102, 0x15b3, 0x11d2, \
{0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32}}
class nsIHTMLFragmentContentSink : public nsIHTMLContentSink {
public:
/**
* This method is used to obtain the fragment created by
* a fragment content sink. The value returned will be null
* if the content sink hasn't yet received parser notifications.
*
*/
NS_IMETHOD GetFragment(nsIDOMDocumentFragment** aFragment) = 0;
};
#endif

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

@ -0,0 +1,40 @@
/* -*- 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 Communicator client 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):
*/
#ifndef nsILoggingSink_h___
#define nsILoggingSink_h___
#include "nsIHTMLContentSink.h"
#include "nsString.h"
#include "prprf.h"
// IID for nsILoggingSink
#define NS_ILOGGING_SINK_IID \
{0xa6cf9061, 0x15b3, 0x11d2,{0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32}}
class nsILoggingSink : public nsIHTMLContentSink {
public:
NS_IMETHOD SetOutputStream(PRFileDesc *aStream,PRBool autoDelete=PR_FALSE) =0;
};
extern "C" nsresult NS_NewHTMLLoggingSink(nsIContentSink** aInstancePtrResult);
#endif /* nsILoggingSink_h___ */

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

@ -0,0 +1,392 @@
/* -*- 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):
*/
#ifndef NS_IPARSER___
#define NS_IPARSER___
/**
* MODULE NOTES:
* @update gess 4/1/98
*
* This class defines the iparser interface. This XPCOM
* inteface is all that parser clients ever need to see.
*
**/
#include "nsISupports.h"
#include "nsIStreamListener.h"
#include "nsIDTD.h"
#include "nsIInputStream.h"
#include "nsHashtable.h"
#define NS_IPARSER_IID \
{0x355cbba0, 0xbf7d, 0x11d1, \
{0xaa, 0xd9, 0x00, 0x80, 0x5f, 0x8a, 0x3e, 0x14}}
// {8B6A98A0-260E-11d4-8153-0010A4E0C706}
#define NS_IPARSER_BUNDLE_IID \
{ 0x8b6a98a0, 0x260e, 0x11d4, { 0x81, 0x53, 0x0, 0x10, 0xa4, 0xe0, 0xc7, 0x6 } };
// {41421C60-310A-11d4-816F-000064657374}
#define NS_IDEBUG_DUMP_CONTENT_IID \
{ 0x41421c60, 0x310a, 0x11d4, { 0x81, 0x6f, 0x0, 0x0, 0x64, 0x65, 0x73, 0x74 } };
class nsIContentSink;
class nsIRequestObserver;
class nsIParserFilter;
class nsString;
class nsIURI;
enum eParserCommands {
eViewNormal,
eViewSource,
eViewErrors
};
enum eCRCQuality {
eCRCGood = 0,
eCRCFair,
eCRCPoor
};
enum eParserDocType {
ePlainText = 0,
eXMLText,
eXHTMLText,
eHTML3Text,
eHTML4Text
};
typedef enum {
kCharsetUninitialized = 0,
kCharsetFromWeakDocTypeDefault,
kCharsetFromUserDefault ,
kCharsetFromDocTypeDefault,
kCharsetFromParentFrame,
kCharsetFromBookmarks,
kCharsetFromAutoDetection,
kCharsetFromMetaTag,
kCharsetFromByteOrderMark,
kCharsetFromCache,
kCharsetFromHTTPHeader,
kCharsetFromUserForced,
kCharsetFromOtherComponent,
kCharsetFromPreviousLoading
} nsCharsetSource;
enum eStreamState {eNone,eOnStart,eOnDataAvail,eOnStop};
class nsITagStack {
public:
virtual void Push(PRUnichar* aTag)=0;
virtual PRUnichar* Pop(void)=0;
virtual PRUnichar* TagAt(PRUint32 anIndex)=0;
virtual PRUint32 GetSize(void)=0;
};
/**
* FOR DEBUG PURPOSE ONLY
*
* Use this interface to query objects that contain content information.
* Ex. Parser can trigger dump content by querying the sink that has
* access to the content.
*
* @update harishd 05/25/00
*/
class nsIDebugDumpContent : public nsISupports {
public:
static const nsIID& GetIID() { static nsIID iid = NS_IDEBUG_DUMP_CONTENT_IID; return iid; }
NS_IMETHOD DumpContentModel()=0;
};
class nsISupportsParserBundle : public nsISupports {
public:
static const nsIID& GetIID() { static nsIID iid = NS_IPARSER_BUNDLE_IID; return iid; }
NS_IMETHOD GetDataFromBundle(const nsString& aKey,nsISupports** anObject)=0;
NS_IMETHOD SetDataIntoBundle(const nsString& aKey,nsISupports* anObject)=0;
};
/**
* This class defines the iparser interface. This XPCOM
* inteface is all that parser clients ever need to see.
*
* @update gess 3/25/98
*/
class nsIParser : public nsISupports {
public:
static const nsIID& GetIID() { static nsIID iid = NS_IPARSER_IID; return iid; }
/**
* Call this method if you have a DTD that you want to share with the parser.
* Registered DTD's get remembered until the system shuts down.
*
* @update gess 3/25/98
* @param aDTD -- ptr DTD that you're publishing the services of
*/
virtual void RegisterDTD(nsIDTD* aDTD)=0;
/**
* Select given content sink into parser for parser output
* @update gess5/11/98
* @param aSink is the new sink to be used by parser
* @return old sink, or NULL
*/
virtual nsIContentSink* SetContentSink(nsIContentSink* aSink)=0;
/**
* retrive the sink set into the parser
* @update gess5/11/98
* @param aSink is the new sink to be used by parser
* @return old sink, or NULL
*/
virtual nsIContentSink* GetContentSink(void)=0;
/**
* Call this method once you've created a parser, and want to instruct it
* about the command which caused the parser to be constructed. For example,
* this allows us to select a DTD which can do, say, view-source.
*
* @update gess 3/25/98
* @param aCommand -- ptrs to string that contains command
* @return nada
*/
virtual void GetCommand(nsString& aCommand)=0;
virtual void SetCommand(const char* aCommand)=0;
virtual void SetCommand(eParserCommands aParserCommand)=0;
/**
* Call this method once you've created a parser, and want to instruct it
* about what charset to load
*
* @update ftang 4/23/99
* @param aCharset- the charest of a document
* @param aCharsetSource- the soure of the chares
* @return nada
*/
virtual void SetDocumentCharset(nsString& aCharset, nsCharsetSource aSource)=0;
virtual void GetDocumentCharset(nsString& oCharset, nsCharsetSource& oSource)=0;
virtual nsIParserFilter* SetParserFilter(nsIParserFilter* aFilter) = 0;
/**
* Call this to get a newly constructed tagstack
* @update gess 5/05/99
* @param aTagStack is an out parm that will contain your result
* @return NS_OK if successful, or NS_HTMLPARSER_MEMORY_ERROR on error
*/
virtual nsresult CreateTagStack(nsITagStack** aTagStack)=0;
/**
* Get the DTD associated with this parser
* @update vidur 9/29/99
* @param aDTD out param that will contain the result
* @return NS_OK if successful, NS_ERROR_FAILURE for runtime error
*/
NS_IMETHOD GetDTD(nsIDTD** aDTD) = 0;
/******************************************************************************************
* Parse methods always begin with an input source, and perform conversions
* until you wind up being emitted to the given contentsink (which may or may not
* be a proxy for the NGLayout content model).
******************************************************************************************/
// Call this method to resume the parser from the blocked state..
virtual nsresult ContinueParsing() =0;
// Stops parsing temporarily.
virtual void BlockParser() =0;
// Open up the parser for tokenization, building up content
// model..etc. However, this method does not resume parsing
// automatically. It's the callers' responsibility to restart
// the parsing engine.
virtual void UnblockParser() =0;
virtual PRBool IsParserEnabled() =0;
virtual PRBool IsComplete() =0;
virtual nsresult Parse(nsIURI* aURL,nsIRequestObserver* aListener = nsnull,PRBool aEnableVerify=PR_FALSE, void* aKey=0,nsDTDMode aMode=eDTDMode_autodetect) = 0;
virtual nsresult Parse(nsIInputStream& aStream, const nsString& aMimeType,PRBool aEnableVerify=PR_FALSE, void* aKey=0,nsDTDMode aMode=eDTDMode_autodetect) = 0;
virtual nsresult Parse(const nsAReadableString& aSourceBuffer,void* aKey,const nsString& aContentType,PRBool aEnableVerify,PRBool aLastCall,nsDTDMode aMode=eDTDMode_autodetect) = 0;
virtual nsresult Terminate(void) = 0;
virtual nsresult ParseFragment(const nsAReadableString& aSourceBuffer,void* aKey,nsITagStack& aStack,PRUint32 anInsertPos,const nsString& aContentType,nsDTDMode aMode=eDTDMode_autodetect)=0;
/**
* This method gets called when the tokens have been consumed, and it's time
* to build the model via the content sink.
* @update gess5/11/98
* @return error code -- 0 if model building went well .
*/
virtual nsresult BuildModel(void)=0;
/**
* Retrieve the parse mode from the parser...
*
* @update gess 6/9/98
* @return ptr to scanner
*/
virtual nsDTDMode GetParseMode(void)=0;
/**
* Call this method to determine a DTD for a DOCTYPE
*
* @update harishd 05/01/00
* @param aDTD -- Carries the deduced ( from DOCTYPE ) DTD.
* @param aDocTypeStr -- A doctype for which a DTD is to be selected.
* @param aMimeType -- A mimetype for which a DTD is to be selected.
Note: aParseMode might be required.
* @param aCommand -- A command for which a DTD is to be selected.
* @param aParseMode -- Used with aMimeType to choose the correct DTD.
* @return NS_OK if succeeded else ERROR.
*/
NS_IMETHOD CreateCompatibleDTD(nsIDTD** aDTD,
nsString* aDocTypeStr,
eParserCommands aCommand,
const nsString* aMimeType=nsnull,
nsDTDMode aDTDMode=eDTDMode_unknown)=0;
/**
* Call this method to cancel any pending parsing events.
* Parsing events may be pending if all of the document's content
* has been passed to the parser but the parser has been interrupted
* because processing the tokens took too long.
*
* @update kmcclusk 05/18/01
* @return NS_OK if succeeded else ERROR.
*/
NS_IMETHOD CancelParsingEvents()=0;
};
/* ===========================================================*
Some useful constants...
* ===========================================================*/
#include "prtypes.h"
#include "nsError.h"
#define NS_ERROR_HTMLPARSER_EOF NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_HTMLPARSER,1000)
#define NS_ERROR_HTMLPARSER_UNKNOWN NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_HTMLPARSER,1001)
#define NS_ERROR_HTMLPARSER_CANTPROPAGATE NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_HTMLPARSER,1002)
#define NS_ERROR_HTMLPARSER_CONTEXTMISMATCH NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_HTMLPARSER,1003)
#define NS_ERROR_HTMLPARSER_BADFILENAME NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_HTMLPARSER,1004)
#define NS_ERROR_HTMLPARSER_BADURL NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_HTMLPARSER,1005)
#define NS_ERROR_HTMLPARSER_INVALIDPARSERCONTEXT NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_HTMLPARSER,1006)
#define NS_ERROR_HTMLPARSER_INTERRUPTED NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_HTMLPARSER,1007)
#define NS_ERROR_HTMLPARSER_BLOCK NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_HTMLPARSER,1008)
#define NS_ERROR_HTMLPARSER_BADTOKENIZER NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_HTMLPARSER,1009)
#define NS_ERROR_HTMLPARSER_BADATTRIBUTE NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_HTMLPARSER,1010)
#define NS_ERROR_HTMLPARSER_UNRESOLVEDDTD NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_HTMLPARSER,1011)
#define NS_ERROR_HTMLPARSER_MISPLACEDTABLECONTENT NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_HTMLPARSER,1012)
#define NS_ERROR_HTMLPARSER_BADDTD NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_HTMLPARSER,1013)
#define NS_ERROR_HTMLPARSER_BADCONTEXT NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_HTMLPARSER,1014)
#define NS_ERROR_HTMLPARSER_STOPPARSING NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_HTMLPARSER,1015)
#define NS_ERROR_HTMLPARSER_UNTERMINATEDSTRINGLITERAL NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_HTMLPARSER,1016)
#define NS_ERROR_HTMLPARSER_HIERARCHYTOODEEP NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_HTMLPARSER,1017)
#define NS_ERROR_HTMLPARSER_CONTINUE NS_OK
const PRUint32 kEOF = NS_ERROR_HTMLPARSER_EOF;
const PRUint32 kUnknownError = NS_ERROR_HTMLPARSER_UNKNOWN;
const PRUint32 kCantPropagate = NS_ERROR_HTMLPARSER_CANTPROPAGATE;
const PRUint32 kContextMismatch = NS_ERROR_HTMLPARSER_CONTEXTMISMATCH;
const PRUint32 kBadFilename = NS_ERROR_HTMLPARSER_BADFILENAME;
const PRUint32 kBadURL = NS_ERROR_HTMLPARSER_BADURL;
const PRUint32 kInvalidParserContext = NS_ERROR_HTMLPARSER_INVALIDPARSERCONTEXT;
const PRUint32 kBlocked = NS_ERROR_HTMLPARSER_BLOCK;
const PRUint32 kBadStringLiteral = NS_ERROR_HTMLPARSER_UNTERMINATEDSTRINGLITERAL;
const PRUint32 kHierarchyTooDeep = NS_ERROR_HTMLPARSER_HIERARCHYTOODEEP;
const PRUnichar kNewLine = '\n';
const PRUnichar kCR = '\r';
const PRUnichar kLF = '\n';
const PRUnichar kTab = '\t';
const PRUnichar kSpace = ' ';
const PRUnichar kQuote = '"';
const PRUnichar kApostrophe = '\'';
const PRUnichar kLessThan = '<';
const PRUnichar kGreaterThan = '>';
const PRUnichar kAmpersand = '&';
const PRUnichar kForwardSlash = '/';
const PRUnichar kBackSlash = '\\';
const PRUnichar kEqual = '=';
const PRUnichar kMinus = '-';
const PRUnichar kPlus = '+';
const PRUnichar kExclamation = '!';
const PRUnichar kSemicolon = ';';
const PRUnichar kHashsign = '#';
const PRUnichar kAsterisk = '*';
const PRUnichar kUnderbar = '_';
const PRUnichar kComma = ',';
const PRUnichar kLeftParen = '(';
const PRUnichar kRightParen = ')';
const PRUnichar kLeftBrace = '{';
const PRUnichar kRightBrace = '}';
const PRUnichar kQuestionMark = '?';
const PRUnichar kLeftSquareBracket = '[';
const PRUnichar kRightSquareBracket = ']';
const PRUnichar kNullCh = '\0';
#define kHTMLTextContentType "text/html"
#define kXMLTextContentType "text/xml"
#define kXMLApplicationContentType "application/xml"
#define kXHTMLApplicationContentType "application/xhtml+xml"
#define kXULTextContentType "application/vnd.mozilla.xul+xml"
#define kRDFTextContentType "text/rdf"
#define kXIFTextContentType "text/xif"
#define kPlainTextContentType "text/plain"
#define kViewSourceCommand "view-source"
#define kTextCSSContentType "text/css"
#define kApplicationJSContentType "application/x-javascript"
#define kTextJSContentType "text/javascript"
#define kSGMLTextContentType "text/sgml"
#define NS_IPARSER_FLAG_UNKNOWN_MODE 0x00000000
#define NS_IPARSER_FLAG_QUIRKS_MODE 0x00000002
#define NS_IPARSER_FLAG_STRICT_MODE 0x00000004
#define NS_IPARSER_FLAG_TRANSITIONAL_MODE 0x00000008
#define NS_IPARSER_FLAG_AUTO_DETECT_MODE 0x00000010
#define NS_IPARSER_FLAG_VIEW_NORMAL 0x00000020
#define NS_IPARSER_FLAG_VIEW_SOURCE 0x00000040
#define NS_IPARSER_FLAG_VIEW_ERRORS 0x00000080
#define NS_IPARSER_FLAG_PLAIN_TEXT 0x00000100
#define NS_IPARSER_FLAG_XML_TEXT 0x00000200
#define NS_IPARSER_FLAG_XHTML_TEXT 0x00000400
#define NS_IPARSER_FLAG_HTML3_TEXT 0x00000800
#define NS_IPARSER_FLAG_HTML4_TEXT 0x00001000
#endif

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

@ -0,0 +1,63 @@
/* -*- 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 jevering 6/17/98
*
* This interface is not yet used; it was intended to allow an observer object
* to "look at" the i/o stream coming into the parser before, during and after
* the parser saw it. The intention of this was to allow an observer to modify
* the stream at various stages.
*/
#ifndef IPARSERFILTER
#define IPARSERFILTER
#include "nsISupports.h"
class CToken;
#define NS_IPARSERFILTER_IID \
{0x14d6ff0, 0x0610, 0x11d2, \
{0x8c, 0x3f, 0x00, 0x80, 0x5f, 0x8a, 0x1d, 0xb7}}
class nsIParserFilter : public nsISupports {
public:
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IPARSERFILTER_IID)
NS_IMETHOD RawBuffer(const char * buffer, PRUint32 * buffer_length) = 0;
NS_IMETHOD WillAddToken(CToken & token) = 0;
NS_IMETHOD ProcessTokens( /* dont know what goes here yet */ void ) = 0;
NS_IMETHOD Finish() = 0;
};
#endif

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

@ -0,0 +1,180 @@
/* -*- 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
*
* This class is defines the basic interface between the
* parser and the content sink. The parser will iterate
* over the collection of tokens that it sees from the
* tokenizer, coverting each related "group" into one of
* these. This object gets passed to the sink, and is
* then immediately reused.
*
* If you want to hang onto one of these, you should
* make your own copy.
*
*/
#ifndef NS_IPARSERNODE__
#define NS_IPARSERNODE__
#include "nsISupports.h"
#include "prtypes.h"
#include "nsString.h"
#include "nsDebug.h"
//#define HEAP_ALLOCATED_NODES
//#define DEBUG_TRACK_NODES
class CToken;
// 6e59f160-2717-11d2-9246-00805f8a7ab6
#define NS_IPARSER_NODE_IID \
{0x6e59f160, 0x2717, 0x11d1, \
{0x92, 0x46, 0x00, 0x80, 0x5f, 0x8a, 0x7a, 0xb6}}
/**
* Parser nodes are the unit of exchange between the
* parser and the content sink. Nodes offer access to
* the current token, its attributes, and its skipped-
* content if applicable.
*
* @update gess 3/25/98
*/
class nsIParserNode { // XXX Should be nsAParserNode
public:
/**
* Retrieve the name of the node
* @update gess5/11/98
* @return string containing node name
*/
virtual const nsString& GetName() const =0; //to get name of tag
/**
* Retrieve the text from the given node
* @update gess5/11/98
* @return string containing node text
*/
virtual const nsAReadableString& GetText() const =0; //get plain text if available
/**
* Retrieve skipped context from node
* @update gess5/11/98
* @return string containing skipped content
*/
virtual const nsString& GetSkippedContent() const =0;
/**
* Retrieve the type of the parser node.
* @update gess5/11/98
* @return node type.
*/
virtual PRInt32 GetNodeType() const =0;
/**
* Retrieve token type of parser node
* @update gess5/11/98
* @return token type
*/
virtual PRInt32 GetTokenType() const =0;
/**
* Retrieve the number of attributes in this node.
* @update gess5/11/98
* @return count of attributes (may be 0)
*/
virtual PRInt32 GetAttributeCount(PRBool askToken=PR_FALSE) const =0;
/**
* Retrieve the key (of key/value pair) at given index
* @update gess5/11/98
* @param anIndex is the index of the key you want
* @return string containing key.
*/
virtual const nsAReadableString& GetKeyAt(PRUint32 anIndex) const =0;
/**
* Retrieve the value (of key/value pair) at given index
* @update gess5/11/98
* @param anIndex is the index of the value you want
* @return string containing value.
*/
virtual const nsString& GetValueAt(PRUint32 anIndex) const =0;
/**
* NOTE: When the node is an entity, this will translate the entity
* to it's unicode value, and store it in aString.
* @update gess5/11/98
* @param aString will contain the resulting unicode string value
* @return int (unicode char or unicode index from table)
*/
virtual PRInt32 TranslateToUnicodeStr(nsString& aString) const = 0;
virtual void AddAttribute(CToken* aToken)=0;
/**
* This getter retrieves the line number from the input source where
* the token occured. Lines are interpreted as occuring between \n characters.
* @update gess7/24/98
* @return int containing the line number the token was found on
*/
virtual PRInt32 GetSourceLineNumber(void) const =0;
/**
* This pair of methods allows us to set a generic bit (for arbitrary use)
* on each node stored in the context.
* @update gess 11May2000
*/
virtual PRBool GetGenericState(void) const =0;
virtual void SetGenericState(PRBool aState) =0;
/** Retrieve a string containing the tag and its attributes in "source" form
* @update rickg 06June2000
* @return void
*/
virtual void GetSource(nsString& aString)=0;
/** Release all the objects you're holding
* @update harishd 08/02/00
* @return void
*/
virtual nsresult ReleaseAll()=0;
/*
* Get and set the ID attribute atom for this node.
* See http://www.w3.org/TR/1998/REC-xml-19980210#sec-attribute-types
* for the definition of an ID attribute.
*
*/
virtual nsresult GetIDAttributeAtom(nsIAtom** aResult) const = 0;
virtual nsresult SetIDAttributeAtom(nsIAtom* aID) = 0;
};
#endif

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

@ -0,0 +1,54 @@
/* -*- 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 Communicator client 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):
*/
#ifndef nsIParserService_h__
#define nsIParserService_h__
#include "nsISupports.h"
#include "nsString.h"
#define NS_IPARSERSERVICE_IID \
{ 0xa6cf9111, 0x15b3, 0x11d2, \
{ 0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32 } }
class nsIParserService : public nsISupports {
public:
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IPARSERSERVICE_IID)
NS_IMETHOD HTMLAtomTagToId(nsIAtom* aAtom, PRInt32* aId) const=0;
NS_IMETHOD HTMLStringTagToId(const nsString &aTag, PRInt32* aId) const =0;
NS_IMETHOD HTMLIdToStringTag(PRInt32 aId, nsString& aTag) const =0;
NS_IMETHOD HTMLConvertEntityToUnicode(const nsString& aEntity,
PRInt32* aUnicode) const =0;
NS_IMETHOD HTMLConvertUnicodeToEntity(PRInt32 aUnicode,
nsCString& aEntity) const =0;
NS_IMETHOD IsContainer(PRInt32 aId, PRBool& aIsContainer) const =0;
NS_IMETHOD IsBlock(PRInt32 aId, PRBool& aIsBlock) const =0;
};
#endif // nsIParserService_h__

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

@ -0,0 +1,79 @@
/* -*- 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"
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:
NS_DEFINE_STATIC_IID_ACCESSOR(NS_ITOKENIZER_IID)
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

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

@ -0,0 +1,78 @@
/* -*- 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):
*/
#ifndef nsParserCIID_h__
#define nsParserCIID_h__
#include "nsISupports.h"
#include "nsIFactory.h"
#include "nsIComponentManager.h"
// {2ce606b0-bee6-11d1-aad9-00805f8a3e14}
#define NS_PARSER_CID \
{ 0x2ce606b0, 0xbee6, 0x11d1, { 0xaa, 0xd9, 0x0, 0x80, 0x5f, 0x8a, 0x3e, 0x14 } }
// XXX: This object should not be exposed outside of the parser.
// Remove when CNavDTD subclasses do not need access
#define NS_PARSER_NODE_IID \
{0x9039c670, 0x2717, 0x11d2, \
{0x92, 0x46, 0x00, 0x80, 0x5f, 0x8a, 0x7a, 0xb6}}
// {E6FD9941-899D-11d2-8EAE-00805F29F370}
#define NS_WELLFORMEDDTD_CID \
{ 0xe6fd9941, 0x899d, 0x11d2, { 0x8e, 0xae, 0x0, 0x80, 0x5f, 0x29, 0xf3, 0x70 } }
// {a6cf9107-15b3-11d2-932e-00805f8add32}
#define NS_CNAVDTD_CID \
{ 0xa6cf9107, 0x15b3, 0x11d2, { 0x93, 0x2e, 0x0, 0x80, 0x5f, 0x8a, 0xdd, 0x32 } }
// Class IID for the logging sink
#define NS_LOGGING_SINK_CID \
{0xa6cf9060, 0x15b3, 0x11d2,{0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32}}
// {a6cf910e-15b3-11d2-932e-00805f8add32}
#define NS_XIF_DTD_CID \
{ 0xa6cf910e, 0x15b3, 0x11d2, { 0x93, 0x2e, 0x0, 0x80, 0x5f, 0x8a, 0xdd, 0x32 } }
// {CCF5BED0-1AF8-11d4-812B-0010A4E0C706}
#define NS_COTHER_DTD_CID \
{ 0xccf5bed0, 0x1af8, 0x11d4, { 0x81, 0x2b, 0x0, 0x10, 0xa4, 0xe0, 0xc7, 0x6 } }
// {4611d482-960a-11d4-8eb0-b617661b6f7c}
#define NS_CTRANSITIONAL_DTD_CID \
{ 0x4611d482, 0x960a, 0x11d4, { 0x8e, 0xb0, 0xb6, 0x17, 0x66, 0x1b, 0x6f, 0x7c } }
// {8323FAD0-2102-11d4-8142-000064657374}
#define NS_VIEWSOURCE_DTD_CID \
{ 0x8323fad0, 0x2102, 0x11d4, { 0x81, 0x42, 0x0, 0x0, 0x64, 0x65, 0x73, 0x74 } }
// {a6cf910f-15b3-11d2-932e-00805f8add32}
#define NS_HTMLCONTENTSINKSTREAM_CID \
{ 0xa6cf910f, 0x15b3, 0x11d2, { 0x93, 0x2e, 0x0, 0x80, 0x5f, 0x8a, 0xdd, 0x32 } }
// {a6cf9112-15b3-11d2-932e-00805f8add32}
#define NS_PARSERSERVICE_CID \
{ 0xa6cf9112, 0x15b3, 0x11d2, { 0x93, 0x2e, 0x0, 0x80, 0x5f, 0x8a, 0xdd, 0x32 } }
#endif

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

@ -0,0 +1,49 @@
/* -*- 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 nra 3/3/99
*
* nsParserError structifies the notion of a parser error.
*/
#ifndef PARSERERROR__
#define PARSERERROR__
#include "prtypes.h"
#include "nsString.h"
typedef struct _nsParserError {
PRInt32 code;
PRInt32 lineNumber;
PRInt32 colNumber;
nsString description;
nsString sourceLine;
nsString sourceURL;
} nsParserError;
#endif

281
htmlparser/public/nsToken.h Normal file
Просмотреть файл

@ -0,0 +1,281 @@
/* -*- 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
*
* This class is defines the basic notion of a token
* within our system. All other tokens are derived from
* this one. It offers a few basic interfaces, but the
* most important is consume(). The consume() method gets
* called during the tokenization process when an instance
* of that particular token type gets detected in the
* input stream.
*
* CToken objects that are allocated from the heap _must_ be allocated
* using the nsTokenAllocator: the nsTokenAllocator object uses an
* arena to manage the tokens.
*
* The nsTokenAllocator object's arena implementation requires
* object size at destruction time to properly recycle the object;
* therefore, CToken::operator delete() is not public. Instead,
* heap-allocated tokens should be destroyed using the static
* Destroy() method, which accepts a token and the arena from which
* the token was allocated.
*
* Leaf classes (that are actually instantiated from the heap) must
* implement the SizeOf() method, which Destroy() uses to determine
* the size of the token in order to properly recycle it.
*/
#ifndef CTOKEN__
#define CTOKEN__
#include "prtypes.h"
#include "nsString.h"
#include "nsError.h"
#include "nsFileSpec.h"
#include "nsFixedSizeAllocator.h"
#define NS_HTMLTOKENS_NOT_AN_ENTITY \
NS_ERROR_GENERATE_SUCCESS(NS_ERROR_MODULE_HTMLPARSER,2000)
class nsScanner;
class nsTokenAllocator;
enum eContainerInfo {
eWellFormed,
eMalformed,
eFormUnknown
};
/**
* Implement the SizeOf() method; leaf classes derived from CToken
* must declare this.
*/
#define CTOKEN_IMPL_SIZEOF \
protected: \
virtual size_t SizeOf() const { return sizeof(*this); } \
public:
/**
* Token objects represent sequences of characters as they
* are consumed from the input stream (URL). While they're
* pretty general in nature, we use subclasses (found in
* nsHTMLTokens.h) to define <start>, </end>, <text>,
* <comment>, <&entity>, <newline>, and <whitespace> tokens.
*
* @update gess 3/25/98
*/
class CToken {
public:
enum eTokenOrigin {eSource,eResidualStyle};
protected:
// nsTokenAllocator should be the only class that tries to
// allocate tokens from the heap.
friend class nsTokenAllocator;
/**
*
* @update harishd 08/01/00
* @param aSize -
* @param aArena - Allocate memory from this pool.
*/
static void * operator new (size_t aSize,nsFixedSizeAllocator& anArena)
{
return anArena.Alloc(aSize);
}
/**
* Hide operator delete; clients should use Destroy() instead.
*/
static void operator delete (void*,size_t) {}
public:
/**
* destructor
* @update gess5/11/98
*/
virtual ~CToken();
/**
* Destroy a token.
*/
static void Destroy(CToken* aToken,nsFixedSizeAllocator& aArenaPool)
{
size_t sz = aToken->SizeOf();
aToken->~CToken();
aArenaPool.Free(aToken, sz);
}
/**
* Make a note on number of times you have been referenced
* @update harishd 08/02/00
*/
void AddRef() { mUseCount++; }
/**
* Free yourself if no one is holding you.
* @update harishd 08/02/00
*/
void Release(nsFixedSizeAllocator& aArenaPool) {
if(--mUseCount==0)
Destroy(this, aArenaPool);
}
/**
* Default constructor
* @update gess7/21/98
*/
CToken(PRInt32 aTag=0);
/**
* Retrieve string value of the token
* @update gess5/11/98
* @return reference to string containing string value
*/
virtual const nsAReadableString& GetStringValue(void) = 0;
/**
* Get string of full contents, suitable for debug dump.
* It should look exactly like the input source.
* @update gess5/11/98
* @return reference to string containing string value
*/
virtual void GetSource(nsString& anOutputString);
/** @update harishd 03/23/00
* @return reference to string containing string value
*/
virtual void AppendSource(nsString& anOutputString);
/**
* Sets the ordinal value of this token (not currently used)
* @update gess5/11/98
* @param value is the new ord value for this token
*/
virtual void SetTypeID(PRInt32 aValue);
/**
* Getter which retrieves the current ordinal value for this token
* @update gess5/11/98
* @return current ordinal value
*/
virtual PRInt32 GetTypeID(void);
/**
* Sets the # of attributes found for this token.
* @update gess5/11/98
* @param value is the attr count
*/
virtual void SetAttributeCount(PRInt16 aValue);
/**
* Getter which retrieves the current attribute count for this token
* @update gess5/11/98
* @return current attribute count
*/
virtual PRInt16 GetAttributeCount(void);
/**
* Causes token to consume data from given scanner.
* Note that behavior varies wildly between CToken subclasses.
* @update gess5/11/98
* @param aChar -- most recent char consumed
* @param aScanner -- input source where token should get data
* @return error code (0 means ok)
*/
virtual nsresult Consume(PRUnichar aChar,nsScanner& aScanner,PRInt32 aMode);
/**
* Causes token to dump itself in debug form to given output stream
* @update gess5/11/98
* @param out is the output stream where token should write itself
*/
virtual void DebugDumpToken(nsOutputStream& out);
/**
* Causes token to dump itself in source form to given output stream
* @update gess5/11/98
* @param out is the output stream where token should write itself
*/
virtual void DebugDumpSource(nsOutputStream& out);
/**
* Getter which retrieves type of token
* @update gess5/11/98
* @return int containing token type
*/
virtual PRInt32 GetTokenType(void);
/**
* Getter which retrieves the class name for this token
* This method is only used for debug purposes.
* @update gess5/11/98
* @return const char* containing class name
*/
virtual const char* GetClassName(void);
/**
* For tokens who care, this can tell us whether the token is
* well formed or not.
*
* @update gess 8/30/00
* @return PR_FALSE; subclasses MUST override if they care.
*/
virtual PRBool IsWellFormed(void) const {return PR_FALSE;}
/**
* perform self test.
* @update gess5/11/98
*/
virtual void SelfTest(void);
static int GetTokenCount();
eTokenOrigin mOrigin;
PRInt32 mNewlineCount;
protected:
/**
* Returns the size of the token object.
*/
virtual size_t SizeOf() const = 0;
PRInt32 mTypeID;
PRInt16 mAttrCount;
PRInt32 mUseCount;
};
#endif

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

@ -0,0 +1,48 @@
/* -*- 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 nshtmlpars_h___
#define nshtmlpars_h___
#include "nscore.h"
#include "nsError.h"
#ifdef _IMPL_NS_HTMLPARS
#define NS_HTMLPARS NS_EXPORT
#else
#define NS_HTMLPARS NS_IMPORT
#endif
#if defined(XP_MAC)
#define CLASS_EXPORT_HTMLPARS NS_HTMLPARS class
#else
#define CLASS_EXPORT_HTMLPARS class NS_HTMLPARS
#endif
#endif /* nshtmlpars_h___ */

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

@ -28,7 +28,6 @@
#include "nsDebug.h"
#include "nsIDTDDebug.h"
#include "CNavDTD.h"
#include "nsHTMLTokens.h"
#include "nsCRT.h"
@ -36,7 +35,6 @@
#include "nsIParser.h"
#include "nsIHTMLContentSink.h"
#include "nsScanner.h"
#include "nsIDTDDebug.h"
#include "prenv.h" //this is here for debug reasons...
#include "prtypes.h" //this is here for debug reasons...
#include "prio.h"
@ -54,7 +52,10 @@
#include "nsVoidArray.h"
#include "nsReadableUtils.h"
#include "prmem.h"
#if !defined(MOZ_DISABLE_DTD_DEBUG)
#include "nsLoggingSink.h"
#endif
static NS_DEFINE_IID(kIHTMLContentSinkIID, NS_IHTML_CONTENT_SINK_IID);
@ -171,9 +172,6 @@ CNavDTD::CNavDTD() : nsIDTD(),
mExpectedCRC32(0),
#endif
#ifdef NS_DEBUG
mDTDDebug(0),
#endif
mLineNumber(1)
{
NS_INIT_REFCNT();
@ -200,6 +198,8 @@ const nsIID& CNavDTD::GetMostDerivedIID(void)const {
}
#if !defined(MOZ_DISABLE_DTD_DEBUG)
nsLoggingSink* GetLoggingSink() {
//these are used when you want to generate a log file for contentsink construction...
@ -216,7 +216,6 @@ nsLoggingSink* GetLoggingSink() {
checkForPath=PR_FALSE;
}
#ifdef NS_DEBUG
if(gLogPath && (!theSink)) {
static nsLoggingSink gLoggingSink;
@ -234,11 +233,12 @@ nsLoggingSink* GetLoggingSink() {
gLoggingSink.SetOutputStream(theLogFile,PR_TRUE);
theSink=&gLoggingSink;
}
#endif
return theSink;
}
#endif
/**
* Default destructor
*
@ -259,18 +259,17 @@ CNavDTD::~CNavDTD(){
mTempContext=0;
}
#if !defined(MOZ_DISABLE_DTD_DEBUG)
if(mSink) {
nsLoggingSink *theLogSink=GetLoggingSink();
if(mSink==theLogSink) {
theLogSink->ReleaseProxySink();
}
NS_IF_RELEASE(mSink);
}
#ifdef NS_DEBUG
NS_IF_RELEASE(mDTDDebug);
#endif
NS_IF_RELEASE(mSink);
}
@ -297,39 +296,6 @@ nsresult CNavDTD::CreateNewInstance(nsIDTD** aInstancePtrResult){
return result;
}
/**
* Called by the parser to initiate dtd verification of the
* internal context stack.
* @update gess 7/23/98
* @param
* @return
*/
PRBool CNavDTD::Verify(nsString& aURLRef,nsIParser* aParser){
PRBool result=PR_TRUE;
/*
* Disable some DTD debugging code in the parser that
* breaks on some compilers because of some broken
* streams code in prstrm.cpp.
*/
#ifdef NS_DEBUG
if(!mDTDDebug){
nsresult rval = NS_NewDTDDebug(&mDTDDebug);
if (NS_OK != rval) {
fputs("Cannot create parser debugger.\n", stdout);
result=-PR_FALSE;
}
else mDTDDebug->SetVerificationDirectory(kVerificationDir);
}
if(mDTDDebug) {
// mDTDDebug->Verify(this,aParser,mBodyContext->GetCount(),mBodyContext->mStack,aURLRef);
}
#endif
return result;
}
/**
* This method is called to determine if the given DTD can parse
* a document in a given source-type.
@ -428,7 +394,7 @@ nsresult CNavDTD::WillBuildModel( const CParserContext& aParserContext,nsIConte
//a logging sink. If so, then we'll create one, and make it the
//proxy for the real sink we're given from the parser.
#ifdef NS_DEBUG
#if !defined(MOZ_DISABLE_DTD_DEBUG)
nsLoggingSink *theLogSink=GetLoggingSink();
if(theLogSink) {
theLogSink->SetProxySink(mSink);
@ -682,12 +648,6 @@ nsresult CNavDTD::DidBuildModel(nsresult anErrorCode,PRBool aNotifySink,nsIParse
while((theToken=(CToken*)mMisplacedContent.Pop())) {
IF_FREE(theToken, mTokenAllocator);
}
#ifdef NS_DEBUG
if(mDTDDebug) {
mDTDDebug->DumpVectorRecord();
}
#endif
}
} //if aparser
@ -943,12 +903,6 @@ nsresult CNavDTD::HandleToken(CToken* aToken,nsIParser* aParser){
else {
return NS_OK;
}
#ifdef NS_DEBUG
if (mDTDDebug) {
//mDTDDebug->Verify(this, mParser, mBodyContext->GetCount(), mBodyContext->mStack, mFilename);
}
#endif
}
}

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

@ -86,7 +86,6 @@
#include "nsISupports.h"
#include "nsIParser.h"
#include "nsHTMLTags.h"
#include "nshtmlpars.h"
#include "nsVoidArray.h"
#include "nsDeque.h"
#include "nsParserCIID.h"
@ -99,7 +98,6 @@
class nsIHTMLContentSink;
class nsIDTDDebug;
class nsIParserNode;
class nsParser;
class nsDTDContext;
@ -168,16 +166,6 @@ CLASS_EXPORT_HTMLPARS CNavDTD : public nsIDTD {
*/
virtual eAutoDetectResult CanParse(CParserContext& aParserContext,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
@ -511,10 +499,6 @@ protected:
nsAutoString mMimeType; //ok as an autostring; these are short.
nsNodeAllocator mNodeAllocator;
nsString mFilename;
#ifdef NS_DEBUG
nsIDTDDebug* mDTDDebug;
#endif
#ifdef ENABLE_CRC
PRUint32 mComputedCRC32;

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

@ -24,8 +24,7 @@
//#define RICKG_DEBUG
#include "nsDebug.h"
#include "nsIDTDDebug.h"
#include "nsDebug.h"
#include "COtherDTD.h"
#include "nsHTMLTokens.h"
#include "nsCRT.h"
@ -33,7 +32,6 @@
#include "nsIParser.h"
#include "nsIHTMLContentSink.h"
#include "nsScanner.h"
#include "nsIDTDDebug.h"
#include "prenv.h" //this is here for debug reasons...
#include "prtypes.h" //this is here for debug reasons...
#include "prio.h"
@ -132,8 +130,7 @@ NS_IMPL_RELEASE(COtherDTD)
COtherDTD::COtherDTD() : nsIDTD() {
NS_INIT_REFCNT();
mSink = 0;
mParser=0;
mDTDDebug=0;
mParser=0;
mLineNumber=1;
mHasOpenBody=PR_FALSE;
mHasOpenHead=0;
@ -199,7 +196,6 @@ COtherDTD::~COtherDTD(){
NS_IF_RELEASE(mTokenizer);
NS_IF_RELEASE(mSink);
NS_IF_RELEASE(mDTDDebug);
}
/**
@ -243,38 +239,6 @@ nsresult COtherDTD::CreateNewInstance(nsIDTD** aInstancePtrResult){
return result;
}
/**
* Called by the parser to initiate dtd verification of the
* internal context stack.
* @update gess 7/23/98
* @param
* @return
*/
PRBool COtherDTD::Verify(nsString& aURLRef,nsIParser* aParser){
PRBool result=PR_TRUE;
/*
* Disable some DTD debugging code in the parser that
* breaks on some compilers because of some broken
* streams code in prstrm.cpp.
*/
#if !defined(MOZ_DISABLE_DTD_DEBUG)
if(!mDTDDebug){
nsresult rval = NS_NewDTDDebug(&mDTDDebug);
if (NS_OK != rval) {
fputs("Cannot create parser debugger.\n", stdout);
result=-PR_FALSE;
}
else mDTDDebug->SetVerificationDirectory(kVerificationDir);
}
#endif
if(mDTDDebug) {
// mDTDDebug->Verify(this,aParser,mBodyContext->GetCount(),mBodyContext->mStack,aURLRef);
}
return result;
}
/**
* This method is called to determine if the given DTD can parse
* a document in a given source-type.

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

@ -86,7 +86,6 @@
#include "nsISupports.h"
#include "nsIParser.h"
#include "nsHTMLTokens.h"
#include "nshtmlpars.h"
#include "nsVoidArray.h"
#include "nsDeque.h"
#include "nsParserCIID.h"
@ -96,7 +95,6 @@
{0x80, 0x22, 0x00, 0x60, 0x8, 0x14, 0x98, 0x89}}
class nsIHTMLContentSink;
class nsIDTDDebug;
class nsIParserNode;
class nsParser;
class nsDTDContext;
@ -165,17 +163,7 @@ CLASS_EXPORT_HTMLPARS COtherDTD : public nsIDTD {
* @return TRUE if this DTD parse the given type; FALSE otherwise.
*/
virtual eAutoDetectResult CanParse(CParserContext& aParserContext,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
@ -328,7 +316,6 @@ protected:
PRBool mHadFrameset;
PRBool mHadBody;
nsString mFilename;
nsIDTDDebug* mDTDDebug;
PRInt32 mLineNumber;
nsParser* mParser;
nsITokenizer* mTokenizer;

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

@ -35,7 +35,6 @@
#include "nsScanner.h"
#include "nsIStreamListener.h"
#include "nsString.h"
#include "nshtmlpars.h"
/**
* Note that the parser is given FULL access to all

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

@ -1,27 +0,0 @@
#
# This is a list of local files which get copied to the mozilla:htmlparser directory
#
nshtmlpars.h
nsIContentSink.h
nsIHTMLContentSink.h
nsIHTMLFragmentContentSink.h
nsITokenizer.h
nsHTMLTokens.h
nsIParserNode.h
nsIParserFilter.h
nsIParser.h
nsToken.h
nsIDTDDebug.h
nsIDTD.h
CNavDTD.h
nsHTMLTags.h
nsHTMLTagList.h
nsParserCIID.h
nsHTMLEntities.h
nsHTMLEntityList.h
nsWellFormedDTD.h
nsIExpatTokenizer.h
nsParserError.h
nsIElementObserver.h
nsIParserService.h

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

@ -19,20 +19,20 @@
# Contributor(s):
#
DEPTH = ../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
DEPTH = ../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
MODULE = htmlparser
LIBRARY_NAME = htmlpars
MODULE = htmlparser
LIBRARY_NAME = htmlpars
EXPORT_LIBRARY = 1
IS_COMPONENT = 1
MODULE_NAME = nsParserModule
SHORT_LIBNAME = gkparser
REQUIRES = xpcom string necko util uconv expat layout dom pref nkcache
IS_COMPONENT = 1
MODULE_NAME = nsParserModule
SHORT_LIBNAME = gkparser
REQUIRES = xpcom string necko util uconv expat layout dom pref nkcache
SHARED_LIBRARY_LIBS = \
$(DIST)/lib/libexpat_s.$(LIB_SUFFIX) \
@ -43,71 +43,35 @@ ifdef MOZ_PERF_METRICS
SHARED_LIBRARY_LIBS += $(DIST)/lib/libmozutil_s.$(LIB_SUFFIX)
endif
CPPSRCS = \
nsDTDUtils.cpp \
CPPSRCS = \
nsDTDUtils.cpp \
nsHTMLTokenizer.cpp \
nsXMLTokenizer.cpp \
nsExpatTokenizer.cpp \
nsElementTable.cpp \
CNavDTD.cpp \
COtherDTD.cpp \
nsHTMLEntities.cpp \
nsHTMLNullSink.cpp \
nsHTMLTags.cpp \
nsHTMLTokens.cpp \
nsLoggingSink.cpp \
nsParser.cpp \
CParserContext.cpp \
nsParserModule.cpp \
nsParserNode.cpp \
nsScanner.cpp \
nsToken.cpp \
nsTokenHandler.cpp \
nsValidDTD.cpp \
nsExpatTokenizer.cpp\
nsElementTable.cpp \
CNavDTD.cpp \
COtherDTD.cpp \
nsHTMLEntities.cpp \
nsHTMLTags.cpp \
nsHTMLTokens.cpp \
nsParser.cpp \
CParserContext.cpp \
nsParserModule.cpp \
nsParserNode.cpp \
nsScanner.cpp \
nsToken.cpp \
nsTokenHandler.cpp \
nsWellFormedDTD.cpp \
nsViewSourceHTML.cpp \
nsViewSourceHTML.cpp\
$(NULL)
#
# Disable some DTD debugging code in the parser that
# breaks on some compilers because of some broken
# streams code in prstrm.cpp.
#
ifndef MOZ_DISABLE_DTD_DEBUG
CPPSRCS += nsDTDDebug.cpp
CPPSRCS += \
nsLoggingSink.cpp \
nsHTMLNullSink.cpp \
$(NULL)
endif
EXPORTS = \
nshtmlpars.h \
nsIContentSink.h \
nsITokenizer.h \
nsIExpatTokenizer.h \
nsIHTMLContentSink.h \
nsIHTMLFragmentContentSink.h \
nsHTMLEntities.h \
nsHTMLEntityList.h \
nsHTMLTags.h \
nsHTMLTagList.h \
nsHTMLTokens.h \
nsILoggingSink.h \
nsIParserNode.h \
nsIParser.h \
nsParser.h \
nsIDTD.h \
nsIDTDDebug.h \
nsIParserFilter.h \
nsToken.h \
CNavDTD.h \
COtherDTD.h \
nsWellFormedDTD.h \
nsValidDTD.h \
nsParserCIID.h \
nsParserError.h \
nsIElementObserver.h \
nsIParserService.h \
$(NULL)
EXPORTS := $(addprefix $(srcdir)/, $(EXPORTS))
EXPORTS := $(addprefix $(srcdir)/, $(EXPORTS))
ifeq ($(MOZ_WIDGET_TOOLKIT),os2)
@ -120,4 +84,3 @@ include $(topsrcdir)/config/rules.mk
DEFINES += -D_IMPL_NS_HTMLPARS -DXML_DTD

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

@ -28,91 +28,56 @@ DEFINES=-D_IMPL_NS_HTMLPARS -DWIN32_LEAN_AND_MEAN -DXML_DTD
MODULE = htmlparser
LIBRARY_NAME = gkparser
MODULE_NAME = nsParserModule
MODULE_NAME = nsParserModule
CPPSRCS= \
nsDTDUtils.cpp \
CPPSRCS = \
nsDTDUtils.cpp \
nsHTMLTokenizer.cpp \
nsXMLTokenizer.cpp \
nsExpatTokenizer.cpp \
nsElementTable.cpp \
CNavDTD.cpp \
COtherDTD.cpp \
nsDTDDebug.cpp \
nsHTMLEntities.cpp \
nsHTMLNullSink.cpp \
nsHTMLTags.cpp \
nsHTMLTokens.cpp \
nsLoggingSink.cpp \
nsParser.cpp \
CParserContext.cpp \
nsParserNode.cpp \
nsScanner.cpp \
nsToken.cpp \
nsTokenHandler.cpp \
nsValidDTD.cpp \
nsWellFormedDTD.cpp \
nsViewSourceHTML.cpp \
nsParserModule.cpp \
nsExpatTokenizer.cpp\
nsElementTable.cpp \
CNavDTD.cpp \
COtherDTD.cpp \
nsHTMLEntities.cpp \
nsHTMLTags.cpp \
nsHTMLTokens.cpp \
nsParser.cpp \
CParserContext.cpp \
nsParserNode.cpp \
nsScanner.cpp \
nsToken.cpp \
nsWellFormedDTD.cpp \
nsViewSourceHTML.cpp\
nsParserModule.cpp \
!if !defined(MOZ_DISABLE_DTD_DEBUG)
nsLoggingSink.cpp \
nsHTMLNullSink.cpp \
!endif
$(NULL)
CPP_OBJS= \
.\$(OBJDIR)\nsDTDUtils.obj \
CPP_OBJS = \
.\$(OBJDIR)\nsDTDUtils.obj \
.\$(OBJDIR)\nsHTMLTokenizer.obj \
.\$(OBJDIR)\nsXMLTokenizer.obj \
.\$(OBJDIR)\nsExpatTokenizer.obj \
.\$(OBJDIR)\nsElementTable.obj \
.\$(OBJDIR)\CNavDTD.obj \
.\$(OBJDIR)\COtherDTD.obj \
.\$(OBJDIR)\nsDTDDebug.obj \
.\$(OBJDIR)\nsHTMLEntities.obj \
.\$(OBJDIR)\nsHTMLNullSink.obj \
.\$(OBJDIR)\nsHTMLTags.obj \
.\$(OBJDIR)\nsHTMLTokens.obj \
.\$(OBJDIR)\nsLoggingSink.obj \
.\$(OBJDIR)\nsParser.obj \
.\$(OBJDIR)\CParserContext.obj \
.\$(OBJDIR)\nsParserNode.obj \
.\$(OBJDIR)\nsScanner.obj \
.\$(OBJDIR)\nsToken.obj \
.\$(OBJDIR)\nsTokenHandler.obj \
.\$(OBJDIR)\nsValidDTD.obj \
.\$(OBJDIR)\nsWellFormedDTD.obj \
.\$(OBJDIR)\nsViewSourceHTML.obj \
.\$(OBJDIR)\nsParserModule.obj \
.\$(OBJDIR)\nsExpatTokenizer.obj\
.\$(OBJDIR)\nsElementTable.obj \
.\$(OBJDIR)\CNavDTD.obj \
.\$(OBJDIR)\COtherDTD.obj \
.\$(OBJDIR)\nsHTMLEntities.obj \
.\$(OBJDIR)\nsHTMLTags.obj \
.\$(OBJDIR)\nsHTMLTokens.obj \
.\$(OBJDIR)\nsParser.obj \
.\$(OBJDIR)\CParserContext.obj \
.\$(OBJDIR)\nsParserNode.obj \
.\$(OBJDIR)\nsScanner.obj \
.\$(OBJDIR)\nsToken.obj \
.\$(OBJDIR)\nsWellFormedDTD.obj \
.\$(OBJDIR)\nsViewSourceHTML.obj\
.\$(OBJDIR)\nsParserModule.obj \
!if !defined(MOZ_DISABLE_DTD_DEBUG)
.\$(OBJDIR)\nsLoggingSink.obj \
.\$(OBJDIR)\nsHTMLNullSink.obj \
!endif
$(NULL)
EXPORTS= \
nshtmlpars.h \
nsITokenizer.h \
nsIExpatTokenizer.h \
nsIContentSink.h \
nsIHTMLContentSink.h \
nsILoggingSink.h \
nsIHTMLFragmentContentSink.h \
nsHTMLEntities.h \
nsHTMLEntityList.h \
nsHTMLTags.h \
nsHTMLTagList.h \
nsHTMLTokens.h \
nsIParserNode.h \
nsIParser.h \
nsParser.h \
nsToken.h \
nsIDTDDebug.h \
nsIParserFilter.h \
CNavDTD.h \
nsWellFormedDTD.h \
nsValidDTD.h \
COtherDTD.h \
nsIDTD.h \
nsParserCIID.h \
nsParserError.h \
nsIElementObserver.h \
nsIParserService.h \
$(NULL)
LINCS= -I$(PUBLIC)\xpcom \
-I$(PUBLIC)\raptor \
-I$(PUBLIC)\uconv \

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

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

@ -40,7 +40,6 @@
#include "nsIEntityConverter.h"
#include "nsCRT.h"
#include "nsIDocumentEncoder.h" // for output flags
#include "nshtmlpars.h"
#include "nsHTMLTokens.h"
#include "nsIOutputStream.h"

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

@ -33,7 +33,6 @@
#include "nsScanner.h"
#include "plstr.h"
#include "nsIParserFilter.h"
#include "nshtmlpars.h"
#include "nsWellFormedDTD.h"
#include "nsViewSourceHTML.h"
#include "nsIStringStream.h"
@ -363,7 +362,7 @@ nsParser::nsParser(nsITokenObserver* anObserver) {
rv = eventService->GetThreadEventQueue(NS_CURRENT_THREAD, getter_AddRefs(mEventQueue));
}
NS_ASSERTION(mEventQueue, "event queue is null");
// NS_ASSERTION(mEventQueue, "event queue is null");
}
}
@ -650,82 +649,84 @@ public:
return kNotFound; // Ref. bug 89732
}
const CharT *cp=mBuffer+mOffset+mLength; //skip last word
if (mOffset >= 0) {
const CharT *cp=mBuffer+mOffset+mLength; //skip last word
mLength=0; //reset this
mOffset=-1; //reset this
mLength=0; //reset this
mOffset=-1; //reset this
//now skip whitespace...
//now skip whitespace...
CharT target=0;
PRBool done=PR_FALSE;
CharT target=0;
PRBool done=PR_FALSE;
while((!done) && (cp++<mEndBuffer)) {
switch(*cp) {
case kSpace: case kNewLine:
case kCR: case kTab:
case kEqual:
continue;
while((!done) && (cp++<mEndBuffer)) {
switch(*cp) {
case kSpace: case kNewLine:
case kCR: case kTab:
case kEqual:
continue;
case kQuote:
target=*cp;
if (aSkipQuotes) {
cp++;
}
done=PR_TRUE;
break;
case kMinus:
target=*cp;
done=PR_TRUE;
break;
default:
done=PR_TRUE;
break;
}
}
if(cp<mEndBuffer) {
const CharT *firstcp=cp; //hang onto this...
PRInt32 theDashCount=2;
cp++; //just skip first letter to simplify processing...
//ok, now find end of this word
while(cp++<mEndBuffer) {
if(kQuote==target) {
if(kQuote==*cp) {
cp++;
break; //we found our end...
}
}
else if(kMinus==target) {
//then let's look for SGML comments
if(kMinus==*cp) {
if(4==++theDashCount) {
case kQuote:
target=*cp;
if (aSkipQuotes) {
cp++;
}
done=PR_TRUE;
break;
case kMinus:
target=*cp;
done=PR_TRUE;
break;
default:
done=PR_TRUE;
break;
}
}
if(cp<mEndBuffer) {
const CharT *firstcp=cp; //hang onto this...
PRInt32 theDashCount=2;
cp++; //just skip first letter to simplify processing...
//ok, now find end of this word
while(cp++<mEndBuffer) {
if(kQuote==target) {
if(kQuote==*cp) {
cp++;
break; //we found our end...
}
}
else if(kMinus==target) {
//then let's look for SGML comments
if(kMinus==*cp) {
if(4==++theDashCount) {
cp++;
break;
}
}
}
else {
if((kSpace==*cp) ||
(kNewLine==*cp) ||
(kGreaterThan==*cp) ||
(kQuote==*cp) ||
(kCR==*cp) ||
(kTab==*cp) ||
(kEqual == *cp)) {
break;
}
}
}
else {
if((kSpace==*cp) ||
(kNewLine==*cp) ||
(kGreaterThan==*cp) ||
(kQuote==*cp) ||
(kCR==*cp) ||
(kTab==*cp) ||
(kEqual == *cp)) {
break;
}
}
mLength=cp-firstcp;
mOffset = (0<mLength) ? firstcp-mBuffer : -1;
}
mLength=cp-firstcp;
mOffset = (0<mLength) ? firstcp-mBuffer : -1;
}
return mOffset;

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

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

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

@ -28,7 +28,6 @@
#include "nsIModule.h"
#include "nsParserCIID.h"
#include "nsParser.h"
#include "nsLoggingSink.h"
#include "nsWellFormedDTD.h"
#include "CNavDTD.h"
#include "COtherDTD.h"
@ -36,12 +35,15 @@
#include "nsViewSourceHTML.h"
#include "nsHTMLEntities.h"
#include "nsHTMLTokenizer.h"
#include "nsXMLTokenizer.h"
//#include "nsTextTokenizer.h"
#include "nsExpatTokenizer.h"
#include "nsIParserService.h"
#include "nsElementTable.h"
#if !defined(MOZ_DISABLE_DTD_DEBUG)
#include "nsLoggingSink.h"
#endif
static NS_DEFINE_IID(kIParserServiceIID, NS_IPARSERSERVICE_IID);
class nsParserService : public nsIParserService {
@ -148,8 +150,11 @@ nsParserService::IsBlock(PRInt32 aId, PRBool& aIsBlock) const
//----------------------------------------------------------------------
static NS_DEFINE_CID(kParserCID, NS_PARSER_CID);
#if !defined(MOZ_DISABLE_DTD_DEBUG)
static NS_DEFINE_CID(kLoggingSinkCID, NS_LOGGING_SINK_CID);
#endif
static NS_DEFINE_CID(kParserCID, NS_PARSER_CID);
static NS_DEFINE_CID(kWellFormedDTDCID, NS_WELLFORMEDDTD_CID);
static NS_DEFINE_CID(kNavDTDCID, NS_CNAVDTD_CID);
static NS_DEFINE_CID(kCOtherDTDCID, NS_COTHER_DTD_CID);
@ -157,8 +162,11 @@ static NS_DEFINE_CID(kCTransitionalDTDCID, NS_CTRANSITIONAL_DTD_CID);
static NS_DEFINE_CID(kViewSourceDTDCID, NS_VIEWSOURCE_DTD_CID);
static NS_DEFINE_CID(kParserServiceCID, NS_PARSERSERVICE_CID);
NS_GENERIC_FACTORY_CONSTRUCTOR(nsParser)
#if !defined(MOZ_DISABLE_DTD_DEBUG)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsLoggingSink)
#endif
NS_GENERIC_FACTORY_CONSTRUCTOR(nsParser)
NS_GENERIC_FACTORY_CONSTRUCTOR(CWellFormedDTD)
NS_GENERIC_FACTORY_CONSTRUCTOR(CNavDTD)
NS_GENERIC_FACTORY_CONSTRUCTOR(COtherDTD)
@ -167,8 +175,12 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(CViewSourceHTML)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsParserService)
static nsModuleComponentInfo gComponents[] = {
{ "Parser", NS_PARSER_CID, NULL, nsParserConstructor },
#if !defined(MOZ_DISABLE_DTD_DEBUG)
{ "Logging sink", NS_LOGGING_SINK_CID, NULL, nsLoggingSinkConstructor },
#endif
{ "Parser", NS_PARSER_CID, NULL, nsParserConstructor },
{ "Well formed DTD", NS_WELLFORMEDDTD_CID, NULL, CWellFormedDTDConstructor },
{ "Navigator HTML DTD", NS_CNAVDTD_CID, NULL, CNavDTDConstructor },
{ "OTHER DTD", NS_COTHER_DTD_CID, NULL, COtherDTDConstructor },

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

@ -24,7 +24,6 @@
#include "nsParserNode.h"
#include "string.h"
#include "nsHTMLTokens.h"
#include "nshtmlpars.h"
#include "nsITokenizer.h"
#include "nsDTDUtils.h"

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

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

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

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

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

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

@ -48,13 +48,11 @@
# define START_TIMER()
#endif
#include "nsIDTDDebug.h"
#include "nsViewSourceHTML.h"
#include "nsCRT.h"
#include "nsParser.h"
#include "nsScanner.h"
#include "nsIParser.h"
#include "nsTokenHandler.h"
#include "nsDTDUtils.h"
#include "nsIContentSink.h"
#include "nsIHTMLContentSink.h"
@ -593,7 +591,6 @@ NS_IMETHODIMP CViewSourceHTML::BuildModel(nsIParser* aParser,nsITokenizer* aToke
else if(NS_ERROR_HTMLPARSER_BLOCK!=result){
mTokenizer->PushTokenFront(theToken);
}
// theRootDTD->Verify(kEmptyString,aParser);
}
else break;
}//while
@ -761,19 +758,6 @@ NS_IMETHODIMP CViewSourceHTML::WillInterruptParse(void){
return result;
}
/**
* Called by the parser to initiate dtd verification of the
* internal context stack.
* @update gess 7/23/98
* @param
* @return
*/
PRBool CViewSourceHTML::Verify(nsString& aURLRef,nsIParser* aParser) {
PRBool result=PR_TRUE;
mParser=(nsParser*)aParser;
return result;
}
/**
* Called by the parser to enable/disable dtd verification of the
* internal context stack.

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

@ -34,7 +34,6 @@
#include "nsIDTD.h"
#include "nsISupports.h"
#include "nsHTMLTokens.h"
#include "nshtmlpars.h"
#include "nsIHTMLContentSink.h"
#include "nsIXMLContentSink.h"
#include "nsDTDUtils.h"
@ -171,16 +170,6 @@ class CViewSourceHTML: public nsIDTD {
*/
NS_IMETHOD WillInterruptParse(void);
/**
* 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);
/**
* Set this to TRUE if you want the DTD to verify its
* context stack.

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

@ -27,14 +27,11 @@
*
*/
#include "nsIDTDDebug.h"
#include "nsWellFormedDTD.h"
#include "nsCRT.h"
#include "nsParser.h"
#include "nsScanner.h"
#include "nsIParser.h"
#include "nsTokenHandler.h"
#include "nsDTDUtils.h"
#include "nsIContentSink.h"
#include "nsIHTMLContentSink.h"
@ -266,7 +263,6 @@ NS_IMETHODIMP CWellFormedDTD::BuildModel(nsIParser* aParser,nsITokenizer* aToken
// if(NS_ERROR_HTMLPARSER_BLOCK!=result){
mTokenizer->PushTokenFront(theToken);
}
// theRootDTD->Verify(kEmptyString,aParser);
}
else break;
}
@ -419,19 +415,6 @@ NS_IMETHODIMP CWellFormedDTD::WillInterruptParse(void){
return result;
}
/**
* Called by the parser to initiate dtd verification of the
* internal context stack.
* @update gess 7/23/98
* @param
* @return
*/
PRBool CWellFormedDTD::Verify(nsString& aURLRef,nsIParser* aParser) {
PRBool result=PR_TRUE;
mParser=(nsParser*)aParser;
return result;
}
/**
* Called by the parser to enable/disable dtd verification of the
* internal context stack.

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

@ -34,7 +34,6 @@
#include "nsIDTD.h"
#include "nsISupports.h"
#include "nsHTMLTokens.h"
#include "nshtmlpars.h"
#include "nsIContentSink.h"
#define NS_WELLFORMED_DTD_IID \
@ -157,15 +156,6 @@ class CWellFormedDTD : public nsIDTD {
*/
NS_IMETHOD WillInterruptParse(void);
/**
* 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);
/**
* Set this to TRUE if you want the DTD to verify its
* context stack.

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

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

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

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

@ -21,7 +21,6 @@
*/
#include "nsIFrameUtil.h"
#include "nsFrame.h"
#include "nsHTMLEntities.h"
#include "nsString.h"
#include "nsRect.h"
#include <stdlib.h>

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

@ -21,7 +21,6 @@
*/
#include "nsIFrameUtil.h"
#include "nsFrame.h"
#include "nsHTMLEntities.h"
#include "nsString.h"
#include "nsRect.h"
#include <stdlib.h>

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

@ -26,7 +26,7 @@ VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
DIRS = src
DIRS = public src
ifdef ENABLE_TESTS
DIRS += robot tests

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

@ -1,33 +0,0 @@
#!nmake
#
# 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):
DEPTH=..
DIRS = src \
!if !defined(DISABLE_TESTS)
robot \
robot\test \
tests \
!endif
$(NULL)
include <$(DEPTH)\config\rules.mak>

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

@ -0,0 +1,22 @@
#
# This is a list of local files which get copied to the mozilla:htmlparser directory
#
nsIContentSink.h
nsIHTMLContentSink.h
nsIHTMLFragmentContentSink.h
nsITokenizer.h
nsIParserNode.h
nsIParserFilter.h
nsIParser.h
nsIDTD.h
nsIExpatTokenizer.h
nsIElementObserver.h
nsIParserService.h
nsHTMLTags.h
nsHTMLTagList.h
nsHTMLTokens.h
nshtmlpars.h
nsParserCIID.h
nsParserError.h
nsToken.h

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

@ -0,0 +1,60 @@
#
# 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):
#
DEPTH = ../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
MODULE = htmlparser
EXPORTS = \
nsIContentSink.h \
nsITokenizer.h \
nsIExpatTokenizer.h \
nsIHTMLContentSink.h \
nsIHTMLFragmentContentSink.h\
nsIParserNode.h \
nsIParser.h \
nsIDTD.h \
nsIParserFilter.h \
nsIElementObserver.h \
nsIParserService.h \
nshtmlpars.h \
nsHTMLTagList.h \
nsHTMLTags.h \
nsHTMLTokens.h \
nsParserError.h \
nsParserCIID.h \
nsToken.h \
$(NULL)
ifndef MOZ_DISABLE_DTD_DEBUG
EXPORTS += \
nsILoggingSink.h \
$(NULL)
endif
EXPORTS := $(addprefix $(srcdir)/, $(EXPORTS))
include $(topsrcdir)/config/rules.mk

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

@ -0,0 +1,52 @@
#!nmake
#
# 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):
DEPTH=..\..
include <$(DEPTH)\config\config.mak>
MODULE = htmlparser
EXPORTS = \
nsITokenizer.h \
nsIExpatTokenizer.h \
nsIContentSink.h \
nsIHTMLContentSink.h \
nsIHTMLFragmentContentSink.h\
nsIParserNode.h \
nsIParser.h \
nsIParserFilter.h \
nsIDTD.h \
nsIElementObserver.h \
nsIParserService.h \
nshtmlpars.h \
nsHTMLTagList.h \
nsHTMLTags.h \
nsHTMLTokens.h \
nsParserError.h \
nsParserCIID.h \
nsToken.h \
!if !defined(MOZ_DISABLE_DTD_DEBUG)
nsILoggingSink.h \
!endif
$(NULL)
include <$(DEPTH)\config\rules.mak>

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

@ -0,0 +1,158 @@
/* -*- 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) 1999 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
/******
This file contains the list of all HTML tags
See nsHTMLTags.h for access to the enum values for tags
It is designed to be used as inline input to nsHTMLTags.cpp *only*
through the magic of C preprocessing.
All entires must be enclosed in the macro HTML_TAG which will have cruel
and unusual things done to it
It is recommended (but not strictly necessary) to keep all entries
in alphabetical order
The first argument to HTML_TAG is both the enum identifier of the property
and the string value
Entries *must* use only lowercase characters.
** Break these invarient and bad things will happen. **
******/
HTML_TAG(a)
HTML_TAG(abbr)
HTML_TAG(acronym)
HTML_TAG(address)
HTML_TAG(applet)
HTML_TAG(area)
HTML_TAG(b)
HTML_TAG(base)
HTML_TAG(basefont)
HTML_TAG(bdo)
HTML_TAG(bgsound)
HTML_TAG(big)
HTML_TAG(blink)
HTML_TAG(blockquote)
HTML_TAG(body)
HTML_TAG(br)
HTML_TAG(button)
HTML_TAG(caption)
HTML_TAG(center)
HTML_TAG(cite)
HTML_TAG(code)
HTML_TAG(col)
HTML_TAG(colgroup)
HTML_TAG(counter)
HTML_TAG(dd)
HTML_TAG(del)
HTML_TAG(dfn)
HTML_TAG(dir)
HTML_TAG(div)
HTML_TAG(dl)
HTML_TAG(dt)
HTML_TAG(em)
HTML_TAG(embed)
HTML_TAG(endnote)
HTML_TAG(fieldset)
HTML_TAG(font)
HTML_TAG(form)
HTML_TAG(frame)
HTML_TAG(frameset)
HTML_TAG(h1)
HTML_TAG(h2)
HTML_TAG(h3)
HTML_TAG(h4)
HTML_TAG(h5)
HTML_TAG(h6)
HTML_TAG(head)
HTML_TAG(hr)
HTML_TAG(html)
HTML_TAG(i)
HTML_TAG(iframe)
HTML_TAG(ilayer)
HTML_TAG(image)
HTML_TAG(img)
HTML_TAG(input)
HTML_TAG(ins)
HTML_TAG(isindex)
HTML_TAG(kbd)
HTML_TAG(keygen)
HTML_TAG(label)
HTML_TAG(layer)
HTML_TAG(legend)
HTML_TAG(li)
HTML_TAG(link)
HTML_TAG(listing)
HTML_TAG(map)
HTML_TAG(menu)
HTML_TAG(meta)
HTML_TAG(multicol)
HTML_TAG(nobr)
HTML_TAG(noembed)
HTML_TAG(noframes)
HTML_TAG(nolayer)
HTML_TAG(noscript)
HTML_TAG(object)
HTML_TAG(ol)
HTML_TAG(optgroup)
HTML_TAG(option)
HTML_TAG(p)
HTML_TAG(param)
HTML_TAG(parsererror)
HTML_TAG(plaintext)
HTML_TAG(pre)
HTML_TAG(q)
HTML_TAG(s)
HTML_TAG(samp)
HTML_TAG(script)
HTML_TAG(select)
HTML_TAG(server)
HTML_TAG(small)
HTML_TAG(sound)
HTML_TAG(sourcetext)
HTML_TAG(spacer)
HTML_TAG(span)
HTML_TAG(strike)
HTML_TAG(strong)
HTML_TAG(style)
HTML_TAG(sub)
HTML_TAG(sup)
HTML_TAG(table)
HTML_TAG(tbody)
HTML_TAG(td)
HTML_TAG(textarea)
HTML_TAG(tfoot)
HTML_TAG(th)
HTML_TAG(thead)
HTML_TAG(title)
HTML_TAG(tr)
HTML_TAG(tt)
HTML_TAG(u)
HTML_TAG(ul)
HTML_TAG(var)
HTML_TAG(wbr)
HTML_TAG(xmp)

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

@ -0,0 +1,68 @@
/* -*- 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 Communicator client 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):
*/
#ifndef nsHTMLTags_h___
#define nsHTMLTags_h___
#include "nshtmlpars.h"
class nsString;
class nsCString;
/*
Declare the enum list using the magic of preprocessing
enum values are "eHTMLTag_foo" (where foo is the tag)
To change the list of tags, see nsHTMLTagList.h
*/
#define HTML_TAG(_tag) eHTMLTag_##_tag,
enum nsHTMLTag {
/* this enum must be first and must be zero */
eHTMLTag_unknown = 0,
#include "nsHTMLTagList.h"
/* The remaining enums are not for tags */
eHTMLTag_text, eHTMLTag_whitespace, eHTMLTag_newline,
eHTMLTag_comment, eHTMLTag_entity, eHTMLTag_doctypeDecl,
eHTMLTag_markupDecl, eHTMLTag_instruction,
eHTMLTag_userdefined
};
#undef HTML_TAG
// Currently there are 112 HTML tags. eHTMLTag_text = 114.
#define NS_HTML_TAG_MAX PRInt32(eHTMLTag_text - 1)
class NS_HTMLPARS nsHTMLTags {
public:
static void AddRefTable(void);
static void ReleaseTable(void);
static nsHTMLTag LookupTag(const nsString& aTag);
static nsHTMLTag LookupTag(const nsCString& aTag);
static const nsCString& GetStringValue(nsHTMLTag aEnum);
static const char* GetCStringValue(nsHTMLTag aEnum);
};
#define eHTMLTags nsHTMLTag
#endif /* nsHTMLTags_h___ */

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

@ -0,0 +1,515 @@
/* -*- 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
*
* This file contains the declarations for all the HTML specific token types that
* our DTD's understand. In fact, the same set of token types are used for XML.
* Currently we have tokens for text, comments, start and end tags, entities,
* attributes, style, script and skipped content. Whitespace and newlines also
* have their own token types, but don't count on them to stay forever.
*
* If you're looking for the html tags, they're in a file called nsHTMLTag.h/cpp.
*
* Most of the token types have a similar API. They have methods to get the type
* of token (GetTokenType); those that represent HTML tags also have a method to
* get type tag type (GetTypeID). In addition, most have a method that causes the
* token to help in the parsing process called (Consume). We've also thrown in a
* few standard debugging methods as well.
*/
#ifndef HTMLTOKENS_H
#define HTMLTOKENS_H
#include "nsToken.h"
#include "nsHTMLTags.h"
#include "nsParserError.h"
#include "nsString.h"
#include "nsSlidingString.h"
class nsScanner;
/*******************************************************************
* This enum defines the set of token types that we currently support.
*******************************************************************/
enum eHTMLTokenTypes {
eToken_unknown=0,
eToken_start=1, eToken_end, eToken_comment, eToken_entity,
eToken_whitespace, eToken_newline, eToken_text, eToken_attribute,
eToken_script, eToken_style, eToken_skippedcontent, eToken_instruction,
eToken_cdatasection, eToken_error, eToken_doctypeDecl, eToken_markupDecl,
eToken_last //make sure this stays the last token...
};
enum eHTMLCategory {
eHTMLCategory_unknown=0,
eHTMLCategory_inline,
eHTMLCategory_block,
eHTMLCategory_blockAndInline,
eHTMLCategory_list,
eHTMLCategory_table,
eHTMLCategory_tablepart,
eHTMLCategory_tablerow,
eHTMLCategory_tabledata,
eHTMLCategory_head,
eHTMLCategory_html,
eHTMLCategory_body,
eHTMLCategory_form,
eHTMLCategory_options,
eHTMLCategory_frameset,
eHTMLCategory_text
};
nsresult ConsumeQuotedString(PRUnichar aChar,nsString& aString,nsScanner& aScanner);
nsresult ConsumeAttributeText(PRUnichar aChar,nsString& aString,nsScanner& aScanner);
const char* GetTagName(PRInt32 aTag);
//PRInt32 FindEntityIndex(nsString& aString,PRInt32 aCount=-1);
/**
* This declares the basic token type used in the HTML DTD's.
* @update gess 3/25/98
*/
class CHTMLToken : public CToken {
public:
virtual ~CHTMLToken();
CHTMLToken(eHTMLTags aTag);
virtual eContainerInfo GetContainerInfo(void) const {return eFormUnknown;}
virtual void SetContainerInfo(eContainerInfo aInfo) { }
protected:
};
/**
* This declares start tokens, which always take the form <xxxx>.
* This class also knows how to consume related attributes.
*
* @update gess 3/25/98
*/
class CStartToken: public CHTMLToken {
CTOKEN_IMPL_SIZEOF
public:
CStartToken(eHTMLTags aTag=eHTMLTag_unknown);
CStartToken(const nsAReadableString& aString);
CStartToken(const nsAReadableString& aName,eHTMLTags aTag);
virtual nsresult Consume(PRUnichar aChar,nsScanner& aScanner,PRInt32 aMode);
virtual PRInt32 GetTypeID(void);
virtual const char* GetClassName(void);
virtual PRInt32 GetTokenType(void);
PRBool IsAttributed(void);
void SetAttributed(PRBool aValue);
PRBool IsEmpty(void);
void SetEmpty(PRBool aValue);
virtual void DebugDumpSource(nsOutputStream& out);
virtual const nsAReadableString& GetStringValue();
virtual void GetSource(nsString& anOutputString);
virtual void AppendSource(nsString& anOutputString);
//the following info is used to set well-formedness state on start tags...
virtual eContainerInfo GetContainerInfo(void) const {return mContainerInfo;}
virtual void SetContainerInfo(eContainerInfo aContainerInfo) {mContainerInfo=aContainerInfo;}
virtual PRBool IsWellFormed(void) const {return PRBool(eWellFormed==mContainerInfo);}
/*
* Get and set the ID attribute atom for this element.
* See http://www.w3.org/TR/1998/REC-xml-19980210#sec-attribute-types
* for the definition of an ID attribute.
*
*/
virtual nsresult GetIDAttributeAtom(nsIAtom** aResult);
virtual nsresult SetIDAttributeAtom(nsIAtom* aID);
nsString mTextValue;
nsString mTrailingContent;
PRInt32 mOrigin;
protected:
PRBool mAttributed;
PRBool mEmpty;
eContainerInfo mContainerInfo;
nsCOMPtr<nsIAtom> mIDAttributeAtom;
};
/**
* This declares end tokens, which always take the
* form </xxxx>. This class also knows how to consume
* related attributes.
*
* @update gess 3/25/98
*/
class CEndToken: public CHTMLToken {
CTOKEN_IMPL_SIZEOF
public:
CEndToken(eHTMLTags aTag);
CEndToken(const nsAReadableString& aString);
CEndToken(const nsAReadableString& aName,eHTMLTags aTag);
virtual nsresult Consume(PRUnichar aChar,nsScanner& aScanner,PRInt32 aMode);
virtual PRInt32 GetTypeID(void);
virtual const char* GetClassName(void);
virtual PRInt32 GetTokenType(void);
virtual void DebugDumpSource(nsOutputStream& out);
virtual const nsAReadableString& GetStringValue();
virtual void GetSource(nsString& anOutputString);
virtual void AppendSource(nsString& anOutputString);
protected:
nsString mTextValue;
};
/**
* This declares comment tokens. Comments are usually
* thought of as tokens, but we treat them that way
* here so that the parser can have a consistent view
* of all tokens.
*
* @update gess 3/25/98
*/
class CCommentToken: public CHTMLToken {
CTOKEN_IMPL_SIZEOF
public:
CCommentToken();
CCommentToken(const nsAReadableString& aString);
virtual nsresult Consume(PRUnichar aChar,nsScanner& aScanner,PRInt32 aMode);
virtual const char* GetClassName(void);
virtual PRInt32 GetTokenType(void);
virtual const nsAReadableString& GetStringValue(void);
char mLeadingChar;
protected:
nsString mTextValue;
};
/**
* This class declares entity tokens, which always take
* the form &xxxx;. This class also offers a few utility
* methods that allow you to easily reduce entities.
*
* @update gess 3/25/98
*/
class CEntityToken : public CHTMLToken {
CTOKEN_IMPL_SIZEOF
public:
CEntityToken();
CEntityToken(const nsAReadableString& aString);
virtual const char* GetClassName(void);
virtual PRInt32 GetTokenType(void);
PRInt32 TranslateToUnicodeStr(nsString& aString);
virtual nsresult Consume(PRUnichar aChar,nsScanner& aScanner,PRInt32 aMode);
static nsresult ConsumeEntity(PRUnichar aChar,nsString& aString,nsScanner& aScanner);
static PRInt32 TranslateToUnicodeStr(PRInt32 aValue,nsString& aString);
virtual void DebugDumpSource(nsOutputStream& out);
virtual const nsAReadableString& GetStringValue(void);
virtual void GetSource(nsString& anOutputString);
virtual void AppendSource(nsString& anOutputString);
protected:
nsString mTextValue;
};
/**
* Whitespace tokens are used where whitespace can be
* detected as distinct from text. This allows us to
* easily skip leading/trailing whitespace when desired.
*
* @update gess 3/25/98
*/
class CWhitespaceToken: public CHTMLToken {
CTOKEN_IMPL_SIZEOF
public:
CWhitespaceToken();
CWhitespaceToken(const nsAReadableString& aString);
virtual nsresult Consume(PRUnichar aChar,nsScanner& aScanner,PRInt32 aMode);
virtual const char* GetClassName(void);
virtual PRInt32 GetTokenType(void);
virtual const nsAReadableString& GetStringValue(void);
protected:
nsString mTextValue;
};
/**
* Text tokens contain the normalized form of html text.
* These tokens are guaranteed not to contain entities,
* start or end tags, or newlines.
*
* @update gess 3/25/98
*/
class CTextToken: public CHTMLToken {
CTOKEN_IMPL_SIZEOF
public:
CTextToken();
CTextToken(const nsAReadableString& aString);
virtual nsresult Consume(PRUnichar aChar,nsScanner& aScanner,PRInt32 aMode);
nsresult ConsumeUntil(PRUnichar aChar,PRBool aIgnoreComments,nsScanner& aScanner,
nsString& aEndTagName,PRInt32 aMode,PRBool& aFlushTokens);
virtual const char* GetClassName(void);
virtual PRInt32 GetTokenType(void);
virtual PRInt32 GetTextLength(void);
virtual void CopyTo(nsAWritableString& aStr);
virtual const nsAReadableString& GetStringValue(void);
virtual void Bind(nsScanner* aScanner, nsReadingIterator<PRUnichar>& aStart, nsReadingIterator<PRUnichar>& aEnd);
virtual void Bind(const nsAReadableString& aStr);
protected:
nsSlidingSubstring mTextValue;
};
/**
* CDATASection tokens contain raw unescaped text content delimited by
* a ![CDATA[ and ]].
* XXX Not really a HTML construct - maybe we need a separation
*
* @update vidur 11/12/98
*/
class CCDATASectionToken : public CHTMLToken {
CTOKEN_IMPL_SIZEOF
public:
CCDATASectionToken();
CCDATASectionToken(const nsAReadableString& aString);
virtual nsresult Consume(PRUnichar aChar,nsScanner& aScanner,PRInt32 aMode);
virtual const char* GetClassName(void);
virtual PRInt32 GetTokenType(void);
virtual const nsAReadableString& GetStringValue(void);
protected:
nsString mTextValue;
};
/**
* Declaration tokens contain raw unescaped text content (not really, but
* right now we use this only for view source).
* XXX Not really a HTML construct - maybe we need a separation
*
*/
class CMarkupDeclToken : public CHTMLToken {
CTOKEN_IMPL_SIZEOF
public:
CMarkupDeclToken();
CMarkupDeclToken(const nsAReadableString& aString);
virtual nsresult Consume(PRUnichar aChar,nsScanner& aScanner,PRInt32 aMode);
virtual const char* GetClassName(void);
virtual PRInt32 GetTokenType(void);
virtual const nsAReadableString& GetStringValue(void);
protected:
nsSlidingSubstring mTextValue;
};
/**
* Attribute tokens are used to contain attribute key/value
* pairs whereever they may occur. Typically, they should
* occur only in start tokens. However, we may expand that
* ability when XML tokens become commonplace.
*
* @update gess 3/25/98
*/
class CAttributeToken: public CHTMLToken {
CTOKEN_IMPL_SIZEOF
public:
CAttributeToken();
CAttributeToken(const nsAReadableString& aString);
CAttributeToken(const nsAReadableString& aKey, const nsAReadableString& aString);
~CAttributeToken() {}
virtual nsresult Consume(PRUnichar aChar,nsScanner& aScanner,PRInt32 aMode);
virtual const char* GetClassName(void);
virtual PRInt32 GetTokenType(void);
virtual const nsAReadableString& GetKey(void) {return mTextKey;}
virtual void SetKey(const nsAReadableString& aKey);
virtual void BindKey(nsScanner* aScanner, nsReadingIterator<PRUnichar>& aStart, nsReadingIterator<PRUnichar>& aEnd);
virtual const nsString& GetValue(void) {return mTextValue;}
virtual void SanitizeKey();
virtual void DebugDumpToken(nsOutputStream& out);
virtual const nsAReadableString& GetStringValue(void);
virtual void GetSource(nsString& anOutputString);
virtual void AppendSource(nsString& anOutputString);
virtual void DebugDumpSource(nsOutputStream& out);
PRBool mLastAttribute;
PRBool mHasEqualWithoutValue;
protected:
nsAutoString mTextValue;
nsSlidingSubstring mTextKey;
};
/**
* Newline tokens contain, you guessed it, newlines.
* They consume newline (CR/LF) either alone or in pairs.
*
* @update gess 3/25/98
*/
class CNewlineToken: public CHTMLToken {
CTOKEN_IMPL_SIZEOF
public:
CNewlineToken();
virtual nsresult Consume(PRUnichar aChar,nsScanner& aScanner,PRInt32 aMode);
virtual const char* GetClassName(void);
virtual PRInt32 GetTokenType(void);
virtual const nsAReadableString& GetStringValue(void);
static void AllocNewline();
static void FreeNewline();
};
/**
* Script tokens contain sequences of javascript (or, gulp,
* any other script you care to send). We don't tokenize
* it here, nor validate it. We just wrap it up, and pass
* it along to the html parser, who sends it (later on)
* to the scripting engine.
*
* @update gess 3/25/98
*/
class CScriptToken: public CHTMLToken {
CTOKEN_IMPL_SIZEOF
public:
CScriptToken();
CScriptToken(const nsAReadableString& aString);
virtual const char* GetClassName(void);
virtual PRInt32 GetTokenType(void);
virtual const nsAReadableString& GetStringValue(void);
protected:
nsString mTextValue;
};
/**
* Style tokens contain sequences of css style. We don't
* tokenize it here, nor validate it. We just wrap it up,
* and pass it along to the html parser, who sends it
* (later on) to the style engine.
*
* @update gess 3/25/98
*/
class CStyleToken: public CHTMLToken {
CTOKEN_IMPL_SIZEOF
public:
CStyleToken();
CStyleToken(const nsAReadableString& aString);
virtual const char* GetClassName(void);
virtual PRInt32 GetTokenType(void);
virtual const nsAReadableString& GetStringValue(void);
protected:
nsString mTextValue;
};
/**
* Whitespace tokens are used where whitespace can be
* detected as distinct from text. This allows us to
* easily skip leading/trailing whitespace when desired.
*
* @update gess 3/25/98
*/
class CInstructionToken: public CHTMLToken {
CTOKEN_IMPL_SIZEOF
public:
CInstructionToken();
CInstructionToken(const nsAReadableString& aString);
virtual nsresult Consume(PRUnichar aChar,nsScanner& aScanner,PRInt32 aMode);
virtual const char* GetClassName(void);
virtual PRInt32 GetTokenType(void);
virtual const nsAReadableString& GetStringValue(void);
protected:
nsString mTextValue;
};
class CErrorToken : public CHTMLToken {
CTOKEN_IMPL_SIZEOF
public:
CErrorToken(nsParserError* aError=0);
~CErrorToken();
virtual const char* GetClassName(void);
virtual PRInt32 GetTokenType(void);
void SetError(nsParserError* aError); // CErrorToken takes ownership of aError
// The nsParserError object returned by GetError is still owned by CErrorToken.
// DO NOT use the delete operator on it. Should we change this so that a copy
// of nsParserError is returned which needs to be destroyed by the consumer?
const nsParserError* GetError(void);
virtual const nsAReadableString& GetStringValue(void);
protected:
nsString mTextValue;
nsParserError* mError;
};
/**
* This token is generated by the HTML and Expat tokenizers
* when they see the doctype declaration ("<!DOCTYPE ... >")
*
*/
class CDoctypeDeclToken: public CHTMLToken {
CTOKEN_IMPL_SIZEOF
public:
CDoctypeDeclToken(eHTMLTags aTag=eHTMLTag_unknown);
CDoctypeDeclToken(const nsAReadableString& aString,eHTMLTags aTag=eHTMLTag_unknown);
virtual nsresult Consume(PRUnichar aChar,nsScanner& aScanner,PRInt32 aMode);
virtual const char* GetClassName(void);
virtual PRInt32 GetTokenType(void);
virtual const nsAReadableString& GetStringValue(void);
virtual void SetStringValue(const nsAReadableString& aStr);
protected:
nsString mTextValue;
};
#endif

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

@ -0,0 +1,178 @@
/* -*- 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 Communicator client 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):
*/
#ifndef nsIContentSink_h___
#define nsIContentSink_h___
/**
* MODULE NOTES:
* @update gess 4/1/98
*
* This pure virtual interface is used as the "glue" that connects the parsing
* process to the content model construction process.
*
* The icontentsink interface is a very lightweight wrapper that represents the
* content-sink model building process. There is another one that you may care
* about more, which is the IHTMLContentSink interface. (See that file for details).
*/
#include "nsIParserNode.h"
#include "nsISupports.h"
#include "nsParserError.h"
class nsIParser;
#define NS_ICONTENT_SINK_IID \
{ 0xa6cf9052, 0x15b3, 0x11d2,{0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32}}
// The base value for the content ID counter.
// Values greater than or equal to this base value are used
// by each of the content sinks to assign unique values
// to the content objects created by them.
#define NS_CONTENT_ID_COUNTER_BASE 10000
class nsIContentSink : public nsISupports {
public:
NS_DEFINE_STATIC_IID_ACCESSOR(NS_ICONTENT_SINK_IID)
/**
* This method gets called when the parser begins the process
* of building the content model via the content sink.
*
* @update 5/7/98 gess
*/
NS_IMETHOD WillBuildModel(void)=0;
/**
* This method gets called when the parser concludes the process
* of building the content model via the content sink.
*
* @param aQualityLevel describes how well formed the doc was.
* 0=GOOD; 1=FAIR; 2=POOR;
* @update 5/7/98 gess
*/
NS_IMETHOD DidBuildModel(PRInt32 aQualityLevel)=0;
/**
* This method gets called when the parser gets i/o blocked,
* and wants to notify the sink that it may be a while before
* more data is available.
*
* @update 5/7/98 gess
*/
NS_IMETHOD WillInterrupt(void)=0;
/**
* This method gets called when the parser i/o gets unblocked,
* and we're about to start dumping content again to the sink.
*
* @update 5/7/98 gess
*/
NS_IMETHOD WillResume(void)=0;
/**
* This method gets called by the parser so that the content
* sink can retain a reference to the parser. The expectation
* is that the content sink will drop the reference when it
* gets the DidBuildModel notification i.e. when parsing is done.
*/
NS_IMETHOD SetParser(nsIParser* aParser)=0;
/**
* This method is used to open a generic container in the sink.
*
* @update 4/1/98 gess
* @param nsIParserNode reference to parser node interface
*/
NS_IMETHOD OpenContainer(const nsIParserNode& aNode) = 0;
/**
* This method gets called by the parser when a close
* container tag has been consumed and needs to be closed.
*
* @update 4/1/98 gess
* @param nsIParserNode reference to parser node interface
*/
NS_IMETHOD CloseContainer(const nsIParserNode& aNode) = 0;
/**
* This gets called by the parser when you want to add
* a leaf node to the current container in the content
* model.
*
* @update 4/1/98 gess
* @param nsIParserNode reference to parser node interface
*/
NS_IMETHOD AddLeaf(const nsIParserNode& aNode) = 0;
/**
* This gets called by the parser when you want to add
* a leaf node to the current container in the content
* model.
*
* @update 4/1/98 gess
* @param nsIParserNode reference to parser node interface
*/
NS_IMETHOD AddComment(const nsIParserNode& aNode) = 0;
/**
* This gets called by the parser when you want to add
* a leaf node to the current container in the content
* model.
*
* @update 4/1/98 gess
* @param nsIParserNode reference to parser node interface
*/
NS_IMETHOD AddProcessingInstruction(const nsIParserNode& aNode) = 0;
/**
* This method is called by the parser when it encounters
* a document type declaration.
*
* XXX Should the parser also part the internal subset?
*
* @param nsIParserNode reference to parser node interface
*/
NS_IMETHOD AddDocTypeDecl(const nsIParserNode& aNode, PRInt32 aMode)=0;
/**
* This gets called by the parser if it hits an unrecoverable
* error (in XML, if the document is not well-formed or valid).
*
* @param aErrorResult the error code
*/
NS_IMETHOD NotifyError(const nsParserError* aError)=0;
/**
* Flush all pending notifications so that the content model
* is in sync with the state of the sink.
*/
NS_IMETHOD FlushPendingNotifications()=0;
/**
* Set the document character set. This should be passed on to the
* document itself.
*/
NS_IMETHOD SetDocumentCharset(nsAWritableString& aCharset)=0;
};
#endif /* nsIContentSink_h___ */

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

@ -0,0 +1,209 @@
/* -*- 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):
*/
#ifndef nsIDTD_h___
#define nsIDTD_h___
/**
* MODULE NOTES:
* @update gess 7/20/98
*
* This interface defines standard interface for DTD's. Note that this isn't HTML specific.
* DTD's have several primary functions within the parser system:
* 1) To coordinate the consumption of an input stream via the parser
* 2) To serve as proxy to represent the containment rules of the underlying document
* 3) To offer autodetection services to the parser (mainly for doc conversion)
*
*/
#include "nsISupports.h"
#include "prtypes.h"
#include "nsITokenizer.h"
#define NS_IDTD_IID \
{ 0xa6cf9053, 0x15b3, 0x11d2,{0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32}}
enum eAutoDetectResult {
eUnknownDetect,
eValidDetect,
ePrimaryDetect,
eInvalidDetect
};
enum nsDTDMode {
eDTDMode_unknown=0,
eDTDMode_quirks, //pre 4.0 versions
eDTDMode_transitional,
eDTDMode_strict,
eDTDMode_autodetect
};
class nsIParser;
class CToken;
class nsIURI;
class nsString;
class nsIContentSink;
class CParserContext;
class nsIDTD : public nsISupports {
public:
static const nsIID& GetIID() { static nsIID iid = NS_IDTD_IID; return iid; }
virtual const nsIID& GetMostDerivedIID(void) const =0;
/**
* Call this method if you want the DTD to construct a clone of itself.
* @update gess7/23/98
* @param
* @return
*/
virtual nsresult CreateNewInstance(nsIDTD** aInstancePtrResult)=0;
/**
* 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 aContentType -- string representing type of doc to be converted (ie text/html)
* @return TRUE if this DTD can satisfy the request; FALSE otherwise.
*/
virtual eAutoDetectResult CanParse(CParserContext& aParserContext,nsString& aBuffer, PRInt32 aVersion)=0;
/**
* Called by the parser just before the parsing process begins
* @update gess5/18/98
* @param aFilename--string that contains name of file being parsed (if applicable)
* @return
*/
NS_IMETHOD WillBuildModel( const CParserContext& aParserContext,nsIContentSink* aSink=0)=0;
/**
* Called by the parser after the parsing process has concluded
* @update gess5/18/98
* @param anErrorCode - contains error code resulting from parse process
* @return
*/
NS_IMETHOD DidBuildModel(nsresult anErrorCode,PRBool aNotifySink,nsIParser* aParser,nsIContentSink* aSink=0)=0;
/**
* Called by the parser after the parsing process has concluded
* @update gess5/18/98
* @param anErrorCode - contains error code resulting from parse process
* @return
*/
NS_IMETHOD BuildModel(nsIParser* aParser,nsITokenizer* aTokenizer,nsITokenObserver* anObserver=0,nsIContentSink* aSink=0)=0;
/**
* Called during model building phase of parse process. Each token created during
* the parse phase is stored in a deque (in the parser) and are passed to this method
* so that the DTD can process the token. Ultimately, the DTD will transform given
* token into calls onto a contentsink.
* @update gess 3/25/98
* @param aToken -- token object to be put into content model
* @return error code (usually 0)
*/
NS_IMETHOD HandleToken(CToken* aToken,nsIParser* aParser)=0;
/**
*
* @update gess 12/20/99
* @param ptr-ref to (out) tokenizer
* @return nsresult
*/
NS_IMETHOD GetTokenizer(nsITokenizer*& aTokenizer)=0;
virtual nsTokenAllocator* GetTokenAllocator(void)=0;
/**
* If the parse process gets interrupted midway, this method is called by the
* parser prior to resuming the process.
* @update gess5/18/98
* @return ignored
*/
NS_IMETHOD WillResumeParse(void)=0;
/**
* If the parse process gets interrupted, this method is called by the parser
* to notify the DTD that interruption will occur.
* @update gess5/18/98
* @return ignored
*/
NS_IMETHOD WillInterruptParse(void)=0;
/**
* 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 CanContain(PRInt32 aParent,PRInt32 aChild) const =0;
/**
* 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 IsContainer(PRInt32 aTag) const=0;
/**
* 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(nsIParser* aParser=nsnull) = 0;
/* XXX Temporary measure, pending further work by RickG */
/**
* Give rest of world access to our tag enums, so that CanContain(), etc,
* become useful.
*/
NS_IMETHOD StringTagToIntTag(nsString &aTag, PRInt32* aIntTag) const =0;
NS_IMETHOD IntTagToStringTag(PRInt32 aIntTag, nsString& aTag) const =0;
NS_IMETHOD ConvertEntityToUnicode(const nsString& aEntity, PRInt32* aUnicode) const =0;
virtual PRBool IsBlockElement(PRInt32 aTagID,PRInt32 aParentID) const=0;
virtual PRBool IsInlineElement(PRInt32 aTagID,PRInt32 aParentID) const=0;
};
#endif /* nsIDTD_h___ */

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

@ -0,0 +1,75 @@
/* -*- 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) 1999 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s): Rick Gessner
*/
/**
* MODULE NOTES:
* @update rickg 03.23.2000 //removed unused NS_PARSER_SUBJECT and predecl of nsString
*
*/
#ifndef nsIElementObserver_h__
#define nsIElementObserver_h__
#include "nsISupports.h"
#include "prtypes.h"
#include "nsHTMLTags.h"
#include "nsVoidArray.h"
// {4672AA04-F6AE-11d2-B3B7-00805F8A6670}
#define NS_IELEMENTOBSERVER_IID \
{ 0x4672aa04, 0xf6ae, 0x11d2, { 0xb3, 0xb7, 0x0, 0x80, 0x5f, 0x8a, 0x66, 0x70 } }
class nsIElementObserver : public nsISupports {
public:
static const nsIID& GetIID() { static nsIID iid = NS_IELEMENTOBSERVER_IID; return iid; }
/*
* This method return the tag which the observer care about
*/
NS_IMETHOD_(const char*)GetTagNameAt(PRUint32 aTagIndex) = 0;
/*
* Subject call observer when the parser hit the tag
* @param aDocumentID- ID of the document
* @param aTag- the tag
* @param numOfAttributes - number of attributes
* @param nameArray - array of name.
* @param valueArray - array of value
*/
NS_IMETHOD Notify(PRUint32 aDocumentID, eHTMLTags aTag,
PRUint32 numOfAttributes, const PRUnichar* nameArray[],
const PRUnichar* valueArray[]) = 0;
NS_IMETHOD Notify(PRUint32 aDocumentID, const PRUnichar* aTag,
PRUint32 numOfAttributes, const PRUnichar* nameArray[],
const PRUnichar* valueArray[]) = 0;
NS_IMETHOD Notify(nsISupports* aDocumentID, const PRUnichar* aTag,
const nsStringArray* aKeys, const nsStringArray* aValues) = 0;
};
#endif /* nsIElementObserver_h__ */

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

@ -0,0 +1,61 @@
/* -*- 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 nra 2/24/99
*
*/
#ifndef __NSIEXPATTOKENIZER__
#define __NSIEXPATTOKENIZER__
#include "nsISupports.h"
#include "prtypes.h"
#include "xmlparse.h"
class CToken;
class nsScanner;
#define NS_IEXPATTOKENIZER_IID \
{0xf86a4380, 0xce17, 0x11d2, {0x80, 0x3f, 0x00, 0x60, 0x08, 0x98, 0x28, 0x77}}
class nsIExpatTokenizer : public nsITokenizer {
public:
/* Methods for setting callbacks on the expat parser */
virtual void SetElementHandler(XML_StartElementHandler start, XML_EndElementHandler end)=0;
virtual void SetCharacterDataHandler(XML_CharacterDataHandler handler)=0;
virtual void SetProcessingInstructionHandler(XML_ProcessingInstructionHandler handler)=0;
virtual void SetDefaultHandler(XML_DefaultHandler handler)=0;
virtual void SetUnparsedEntityDeclHandler(XML_UnparsedEntityDeclHandler handler)=0;
virtual void SetNotationDeclHandler(XML_NotationDeclHandler handler)=0;
virtual void SetExternalEntityRefHandler(XML_ExternalEntityRefHandler handler)=0;
virtual void SetUnknownEncodingHandler(XML_UnknownEncodingHandler handler, void *encodingHandlerData)=0;
virtual void FrontloadMisplacedContent(nsDeque& aDeque)=0;
};
#endif

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

@ -0,0 +1,267 @@
/* -*- 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 Communicator client 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):
*/
#ifndef nsIHTMLContentSink_h___
#define nsIHTMLContentSink_h___
/**
* MODULE NOTES:
* @update gess 4/1/98
*
* This file declares the concrete HTMLContentSink class.
* This class is used during the parsing process as the
* primary interface between the parser and the content
* model.
*
* After the tokenizer completes, the parser iterates over
* the known token list. As the parser identifies valid
* elements, it calls the contentsink interface to notify
* the content model that a new node or child node is being
* created and added to the content model.
*
* The HTMLContentSink interface assumes 4 underlying
* containers: HTML, HEAD, BODY and FRAMESET. Before
* accessing any these, the parser will call the appropriate
* OpennsIHTMLContentSink method: OpenHTML,OpenHead,OpenBody,OpenFrameSet;
* likewise, the ClosensIHTMLContentSink version will be called when the
* parser is done with a given section.
*
* IMPORTANT: The parser may Open each container more than
* once! This is due to the irregular nature of HTML files.
* For example, it is possible to encounter plain text at
* the start of an HTML document (that preceeds the HTML tag).
* Such text is treated as if it were part of the body.
* In such cases, the parser will Open the body, pass the text-
* node in and then Close the body. The body will likely be
* re-Opened later when the actual <BODY> tag has been seen.
*
* Containers within the body are Opened and Closed
* using the OpenContainer(...) and CloseContainer(...) calls.
* It is assumed that the document or contentSink is
* maintaining its state to manage where new content should
* be added to the underlying document.
*
* NOTE: OpenHTML() and OpenBody() may get called multiple times
* in the same document. That's fine, and it doesn't mean
* that we have multiple bodies or HTML's.
*
* NOTE: I haven't figured out how sub-documents (non-frames)
* are going to be handled. Stay tuned.
*/
#include "nsIParserNode.h"
#include "nsIContentSink.h"
#define NS_IHTML_CONTENT_SINK_IID \
{ 0xa6cf9051, 0x15b3, 0x11d2,{0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32}}
#ifdef XP_MAC
#define MAX_REFLOW_DEPTH 75 //setting to 75 to prevent layout from crashing on mac. Bug 55095.
#else
#define MAX_REFLOW_DEPTH 200 //windows and linux (etc) can do much deeper structures.
#endif
class nsIHTMLContentSink : public nsIContentSink {
public:
static const nsIID& GetIID() { static nsIID iid = NS_IHTML_CONTENT_SINK_IID; return iid; }
/**
* This method gets called by the parser when it encounters
* a title tag and wants to set the document title in the sink.
*
* @update 4/1/98 gess
* @param nsString reference to new title value
*/
NS_IMETHOD SetTitle(const nsString& aValue)=0;
/**
* This method is used to open the outer HTML container.
*
* @update 4/1/98 gess
* @param nsIParserNode reference to parser node interface
*/
NS_IMETHOD OpenHTML(const nsIParserNode& aNode)=0;
/**
* This method is used to close the outer HTML container.
*
* @update 4/1/98 gess
* @param nsIParserNode reference to parser node interface
*/
NS_IMETHOD CloseHTML(const nsIParserNode& aNode)=0;
/**
* This method is used to open the only HEAD container.
*
* @update 4/1/98 gess
* @param nsIParserNode reference to parser node interface
*/
NS_IMETHOD OpenHead(const nsIParserNode& aNode)=0;
/**
* This method is used to close the only HEAD container.
*
* @update 4/1/98 gess
* @param nsIParserNode reference to parser node interface
*/
NS_IMETHOD CloseHead(const nsIParserNode& aNode)=0;
/**
* This method is used to open the main BODY container.
*
* @update 4/1/98 gess
* @param nsIParserNode reference to parser node interface
*/
NS_IMETHOD OpenBody(const nsIParserNode& aNode)=0;
/**
* This method is used to close the main BODY container.
*
* @update 4/1/98 gess
* @param nsIParserNode reference to parser node interface
*/
NS_IMETHOD CloseBody(const nsIParserNode& aNode)=0;
/**
* This method is used to open a new FORM container.
*
* @update 4/1/98 gess
* @param nsIParserNode reference to parser node interface
*/
NS_IMETHOD OpenForm(const nsIParserNode& aNode)=0;
/**
* This method is used to close the outer FORM container.
*
* @update 4/1/98 gess
* @param nsIParserNode reference to parser node interface
*/
NS_IMETHOD CloseForm(const nsIParserNode& aNode)=0;
/**
* This method is used to open a new MAP container.
*
* @update 4/1/98 gess
* @param nsIParserNode reference to parser node interface
*/
NS_IMETHOD OpenMap(const nsIParserNode& aNode)=0;
/**
* This method is used to close the MAP container.
*
* @update 4/1/98 gess
* @param nsIParserNode reference to parser node interface
*/
NS_IMETHOD CloseMap(const nsIParserNode& aNode)=0;
/**
* This method is used to open the FRAMESET container.
*
* @update 4/1/98 gess
* @param nsIParserNode reference to parser node interface
*/
NS_IMETHOD OpenFrameset(const nsIParserNode& aNode)=0;
/**
* This method is used to close the FRAMESET container.
*
* @update 4/1/98 gess
* @param nsIParserNode reference to parser node interface
*/
NS_IMETHOD CloseFrameset(const nsIParserNode& aNode)=0;
/**
* This method tells the sink whether or not it is
* encoding an HTML fragment or the whole document.
* By default, the entire document is encoded.
*
* @update 03/14/99 gpk
* @param aFlag set to true if only encoding a fragment
*/
NS_IMETHOD DoFragment(PRBool aFlag)=0;
/**
* This gets called when handling illegal contents, especially
* in dealing with tables. This method creates a new context.
*
* @update 04/04/99 harishd
* @param aPosition - The position from where the new context begins.
*/
NS_IMETHOD BeginContext(PRInt32 aPosition)=0;
/**
* This method terminates any new context that got created by
* BeginContext and switches back to the main context.
*
* @update 04/04/99 harishd
* @param aPosition - Validates the end of a context.
*/
NS_IMETHOD EndContext(PRInt32 aPosition)=0;
/**
* Use this method to retrieve pref. for the tag.
*
* @update 04/11/01 harishd
* @param aTag - Check pref. for this tag.
*/
NS_IMETHOD GetPref(PRInt32 aTag,PRBool& aPref)=0;
/**
* This method is called when parser is about to begin
* synchronously processing a chunk of tokens.
*/
NS_IMETHOD WillProcessTokens(void)=0;
/**
* This method is called when parser has
* completed processing a chunk of tokens. The processing of the
* tokens may be interrupted by returning NS_ERROR_HTMLPARSER_INTERRUPTED from
* DidProcessAToken.
*/
NS_IMETHOD DidProcessTokens()=0;
/**
* This method is called when parser is about to
* process a single token
*/
NS_IMETHOD WillProcessAToken(void)=0;
/**
* This method is called when parser has completed
* the processing for a single token.
* @return NS_OK if processing should not be interrupted
* NS_ERROR_HTMLPARSER_INTERRUPTED if the parsing should be interrupted
*/
NS_IMETHOD DidProcessAToken(void)=0;
};
#if !defined(MOZ_DISABLE_DTD_DEBUG)
#include "nshtmlpars.h"
extern NS_HTMLPARS nsresult NS_NewHTMLNullSink(nsIContentSink** aInstancePtrResult);
#endif
#endif /* nsIHTMLContentSink_h___ */

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

@ -0,0 +1,44 @@
/* -*- 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 Communicator client 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):
*/
#ifndef nsIHTMLFragmentContentSink_h___
#define nsIHTMLFragmentContentSink_h___
#include "nsIHTMLContentSink.h"
class nsIDOMDocumentFragment;
#define NS_IHTML_FRAGMENT_CONTENT_SINK_IID \
{0xa6cf9102, 0x15b3, 0x11d2, \
{0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32}}
class nsIHTMLFragmentContentSink : public nsIHTMLContentSink {
public:
/**
* This method is used to obtain the fragment created by
* a fragment content sink. The value returned will be null
* if the content sink hasn't yet received parser notifications.
*
*/
NS_IMETHOD GetFragment(nsIDOMDocumentFragment** aFragment) = 0;
};
#endif

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

@ -0,0 +1,40 @@
/* -*- 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 Communicator client 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):
*/
#ifndef nsILoggingSink_h___
#define nsILoggingSink_h___
#include "nsIHTMLContentSink.h"
#include "nsString.h"
#include "prprf.h"
// IID for nsILoggingSink
#define NS_ILOGGING_SINK_IID \
{0xa6cf9061, 0x15b3, 0x11d2,{0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32}}
class nsILoggingSink : public nsIHTMLContentSink {
public:
NS_IMETHOD SetOutputStream(PRFileDesc *aStream,PRBool autoDelete=PR_FALSE) =0;
};
extern "C" nsresult NS_NewHTMLLoggingSink(nsIContentSink** aInstancePtrResult);
#endif /* nsILoggingSink_h___ */

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

@ -0,0 +1,392 @@
/* -*- 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):
*/
#ifndef NS_IPARSER___
#define NS_IPARSER___
/**
* MODULE NOTES:
* @update gess 4/1/98
*
* This class defines the iparser interface. This XPCOM
* inteface is all that parser clients ever need to see.
*
**/
#include "nsISupports.h"
#include "nsIStreamListener.h"
#include "nsIDTD.h"
#include "nsIInputStream.h"
#include "nsHashtable.h"
#define NS_IPARSER_IID \
{0x355cbba0, 0xbf7d, 0x11d1, \
{0xaa, 0xd9, 0x00, 0x80, 0x5f, 0x8a, 0x3e, 0x14}}
// {8B6A98A0-260E-11d4-8153-0010A4E0C706}
#define NS_IPARSER_BUNDLE_IID \
{ 0x8b6a98a0, 0x260e, 0x11d4, { 0x81, 0x53, 0x0, 0x10, 0xa4, 0xe0, 0xc7, 0x6 } };
// {41421C60-310A-11d4-816F-000064657374}
#define NS_IDEBUG_DUMP_CONTENT_IID \
{ 0x41421c60, 0x310a, 0x11d4, { 0x81, 0x6f, 0x0, 0x0, 0x64, 0x65, 0x73, 0x74 } };
class nsIContentSink;
class nsIRequestObserver;
class nsIParserFilter;
class nsString;
class nsIURI;
enum eParserCommands {
eViewNormal,
eViewSource,
eViewErrors
};
enum eCRCQuality {
eCRCGood = 0,
eCRCFair,
eCRCPoor
};
enum eParserDocType {
ePlainText = 0,
eXMLText,
eXHTMLText,
eHTML3Text,
eHTML4Text
};
typedef enum {
kCharsetUninitialized = 0,
kCharsetFromWeakDocTypeDefault,
kCharsetFromUserDefault ,
kCharsetFromDocTypeDefault,
kCharsetFromParentFrame,
kCharsetFromBookmarks,
kCharsetFromAutoDetection,
kCharsetFromMetaTag,
kCharsetFromByteOrderMark,
kCharsetFromCache,
kCharsetFromHTTPHeader,
kCharsetFromUserForced,
kCharsetFromOtherComponent,
kCharsetFromPreviousLoading
} nsCharsetSource;
enum eStreamState {eNone,eOnStart,eOnDataAvail,eOnStop};
class nsITagStack {
public:
virtual void Push(PRUnichar* aTag)=0;
virtual PRUnichar* Pop(void)=0;
virtual PRUnichar* TagAt(PRUint32 anIndex)=0;
virtual PRUint32 GetSize(void)=0;
};
/**
* FOR DEBUG PURPOSE ONLY
*
* Use this interface to query objects that contain content information.
* Ex. Parser can trigger dump content by querying the sink that has
* access to the content.
*
* @update harishd 05/25/00
*/
class nsIDebugDumpContent : public nsISupports {
public:
static const nsIID& GetIID() { static nsIID iid = NS_IDEBUG_DUMP_CONTENT_IID; return iid; }
NS_IMETHOD DumpContentModel()=0;
};
class nsISupportsParserBundle : public nsISupports {
public:
static const nsIID& GetIID() { static nsIID iid = NS_IPARSER_BUNDLE_IID; return iid; }
NS_IMETHOD GetDataFromBundle(const nsString& aKey,nsISupports** anObject)=0;
NS_IMETHOD SetDataIntoBundle(const nsString& aKey,nsISupports* anObject)=0;
};
/**
* This class defines the iparser interface. This XPCOM
* inteface is all that parser clients ever need to see.
*
* @update gess 3/25/98
*/
class nsIParser : public nsISupports {
public:
static const nsIID& GetIID() { static nsIID iid = NS_IPARSER_IID; return iid; }
/**
* Call this method if you have a DTD that you want to share with the parser.
* Registered DTD's get remembered until the system shuts down.
*
* @update gess 3/25/98
* @param aDTD -- ptr DTD that you're publishing the services of
*/
virtual void RegisterDTD(nsIDTD* aDTD)=0;
/**
* Select given content sink into parser for parser output
* @update gess5/11/98
* @param aSink is the new sink to be used by parser
* @return old sink, or NULL
*/
virtual nsIContentSink* SetContentSink(nsIContentSink* aSink)=0;
/**
* retrive the sink set into the parser
* @update gess5/11/98
* @param aSink is the new sink to be used by parser
* @return old sink, or NULL
*/
virtual nsIContentSink* GetContentSink(void)=0;
/**
* Call this method once you've created a parser, and want to instruct it
* about the command which caused the parser to be constructed. For example,
* this allows us to select a DTD which can do, say, view-source.
*
* @update gess 3/25/98
* @param aCommand -- ptrs to string that contains command
* @return nada
*/
virtual void GetCommand(nsString& aCommand)=0;
virtual void SetCommand(const char* aCommand)=0;
virtual void SetCommand(eParserCommands aParserCommand)=0;
/**
* Call this method once you've created a parser, and want to instruct it
* about what charset to load
*
* @update ftang 4/23/99
* @param aCharset- the charest of a document
* @param aCharsetSource- the soure of the chares
* @return nada
*/
virtual void SetDocumentCharset(nsString& aCharset, nsCharsetSource aSource)=0;
virtual void GetDocumentCharset(nsString& oCharset, nsCharsetSource& oSource)=0;
virtual nsIParserFilter* SetParserFilter(nsIParserFilter* aFilter) = 0;
/**
* Call this to get a newly constructed tagstack
* @update gess 5/05/99
* @param aTagStack is an out parm that will contain your result
* @return NS_OK if successful, or NS_HTMLPARSER_MEMORY_ERROR on error
*/
virtual nsresult CreateTagStack(nsITagStack** aTagStack)=0;
/**
* Get the DTD associated with this parser
* @update vidur 9/29/99
* @param aDTD out param that will contain the result
* @return NS_OK if successful, NS_ERROR_FAILURE for runtime error
*/
NS_IMETHOD GetDTD(nsIDTD** aDTD) = 0;
/******************************************************************************************
* Parse methods always begin with an input source, and perform conversions
* until you wind up being emitted to the given contentsink (which may or may not
* be a proxy for the NGLayout content model).
******************************************************************************************/
// Call this method to resume the parser from the blocked state..
virtual nsresult ContinueParsing() =0;
// Stops parsing temporarily.
virtual void BlockParser() =0;
// Open up the parser for tokenization, building up content
// model..etc. However, this method does not resume parsing
// automatically. It's the callers' responsibility to restart
// the parsing engine.
virtual void UnblockParser() =0;
virtual PRBool IsParserEnabled() =0;
virtual PRBool IsComplete() =0;
virtual nsresult Parse(nsIURI* aURL,nsIRequestObserver* aListener = nsnull,PRBool aEnableVerify=PR_FALSE, void* aKey=0,nsDTDMode aMode=eDTDMode_autodetect) = 0;
virtual nsresult Parse(nsIInputStream& aStream, const nsString& aMimeType,PRBool aEnableVerify=PR_FALSE, void* aKey=0,nsDTDMode aMode=eDTDMode_autodetect) = 0;
virtual nsresult Parse(const nsAReadableString& aSourceBuffer,void* aKey,const nsString& aContentType,PRBool aEnableVerify,PRBool aLastCall,nsDTDMode aMode=eDTDMode_autodetect) = 0;
virtual nsresult Terminate(void) = 0;
virtual nsresult ParseFragment(const nsAReadableString& aSourceBuffer,void* aKey,nsITagStack& aStack,PRUint32 anInsertPos,const nsString& aContentType,nsDTDMode aMode=eDTDMode_autodetect)=0;
/**
* This method gets called when the tokens have been consumed, and it's time
* to build the model via the content sink.
* @update gess5/11/98
* @return error code -- 0 if model building went well .
*/
virtual nsresult BuildModel(void)=0;
/**
* Retrieve the parse mode from the parser...
*
* @update gess 6/9/98
* @return ptr to scanner
*/
virtual nsDTDMode GetParseMode(void)=0;
/**
* Call this method to determine a DTD for a DOCTYPE
*
* @update harishd 05/01/00
* @param aDTD -- Carries the deduced ( from DOCTYPE ) DTD.
* @param aDocTypeStr -- A doctype for which a DTD is to be selected.
* @param aMimeType -- A mimetype for which a DTD is to be selected.
Note: aParseMode might be required.
* @param aCommand -- A command for which a DTD is to be selected.
* @param aParseMode -- Used with aMimeType to choose the correct DTD.
* @return NS_OK if succeeded else ERROR.
*/
NS_IMETHOD CreateCompatibleDTD(nsIDTD** aDTD,
nsString* aDocTypeStr,
eParserCommands aCommand,
const nsString* aMimeType=nsnull,
nsDTDMode aDTDMode=eDTDMode_unknown)=0;
/**
* Call this method to cancel any pending parsing events.
* Parsing events may be pending if all of the document's content
* has been passed to the parser but the parser has been interrupted
* because processing the tokens took too long.
*
* @update kmcclusk 05/18/01
* @return NS_OK if succeeded else ERROR.
*/
NS_IMETHOD CancelParsingEvents()=0;
};
/* ===========================================================*
Some useful constants...
* ===========================================================*/
#include "prtypes.h"
#include "nsError.h"
#define NS_ERROR_HTMLPARSER_EOF NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_HTMLPARSER,1000)
#define NS_ERROR_HTMLPARSER_UNKNOWN NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_HTMLPARSER,1001)
#define NS_ERROR_HTMLPARSER_CANTPROPAGATE NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_HTMLPARSER,1002)
#define NS_ERROR_HTMLPARSER_CONTEXTMISMATCH NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_HTMLPARSER,1003)
#define NS_ERROR_HTMLPARSER_BADFILENAME NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_HTMLPARSER,1004)
#define NS_ERROR_HTMLPARSER_BADURL NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_HTMLPARSER,1005)
#define NS_ERROR_HTMLPARSER_INVALIDPARSERCONTEXT NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_HTMLPARSER,1006)
#define NS_ERROR_HTMLPARSER_INTERRUPTED NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_HTMLPARSER,1007)
#define NS_ERROR_HTMLPARSER_BLOCK NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_HTMLPARSER,1008)
#define NS_ERROR_HTMLPARSER_BADTOKENIZER NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_HTMLPARSER,1009)
#define NS_ERROR_HTMLPARSER_BADATTRIBUTE NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_HTMLPARSER,1010)
#define NS_ERROR_HTMLPARSER_UNRESOLVEDDTD NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_HTMLPARSER,1011)
#define NS_ERROR_HTMLPARSER_MISPLACEDTABLECONTENT NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_HTMLPARSER,1012)
#define NS_ERROR_HTMLPARSER_BADDTD NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_HTMLPARSER,1013)
#define NS_ERROR_HTMLPARSER_BADCONTEXT NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_HTMLPARSER,1014)
#define NS_ERROR_HTMLPARSER_STOPPARSING NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_HTMLPARSER,1015)
#define NS_ERROR_HTMLPARSER_UNTERMINATEDSTRINGLITERAL NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_HTMLPARSER,1016)
#define NS_ERROR_HTMLPARSER_HIERARCHYTOODEEP NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_HTMLPARSER,1017)
#define NS_ERROR_HTMLPARSER_CONTINUE NS_OK
const PRUint32 kEOF = NS_ERROR_HTMLPARSER_EOF;
const PRUint32 kUnknownError = NS_ERROR_HTMLPARSER_UNKNOWN;
const PRUint32 kCantPropagate = NS_ERROR_HTMLPARSER_CANTPROPAGATE;
const PRUint32 kContextMismatch = NS_ERROR_HTMLPARSER_CONTEXTMISMATCH;
const PRUint32 kBadFilename = NS_ERROR_HTMLPARSER_BADFILENAME;
const PRUint32 kBadURL = NS_ERROR_HTMLPARSER_BADURL;
const PRUint32 kInvalidParserContext = NS_ERROR_HTMLPARSER_INVALIDPARSERCONTEXT;
const PRUint32 kBlocked = NS_ERROR_HTMLPARSER_BLOCK;
const PRUint32 kBadStringLiteral = NS_ERROR_HTMLPARSER_UNTERMINATEDSTRINGLITERAL;
const PRUint32 kHierarchyTooDeep = NS_ERROR_HTMLPARSER_HIERARCHYTOODEEP;
const PRUnichar kNewLine = '\n';
const PRUnichar kCR = '\r';
const PRUnichar kLF = '\n';
const PRUnichar kTab = '\t';
const PRUnichar kSpace = ' ';
const PRUnichar kQuote = '"';
const PRUnichar kApostrophe = '\'';
const PRUnichar kLessThan = '<';
const PRUnichar kGreaterThan = '>';
const PRUnichar kAmpersand = '&';
const PRUnichar kForwardSlash = '/';
const PRUnichar kBackSlash = '\\';
const PRUnichar kEqual = '=';
const PRUnichar kMinus = '-';
const PRUnichar kPlus = '+';
const PRUnichar kExclamation = '!';
const PRUnichar kSemicolon = ';';
const PRUnichar kHashsign = '#';
const PRUnichar kAsterisk = '*';
const PRUnichar kUnderbar = '_';
const PRUnichar kComma = ',';
const PRUnichar kLeftParen = '(';
const PRUnichar kRightParen = ')';
const PRUnichar kLeftBrace = '{';
const PRUnichar kRightBrace = '}';
const PRUnichar kQuestionMark = '?';
const PRUnichar kLeftSquareBracket = '[';
const PRUnichar kRightSquareBracket = ']';
const PRUnichar kNullCh = '\0';
#define kHTMLTextContentType "text/html"
#define kXMLTextContentType "text/xml"
#define kXMLApplicationContentType "application/xml"
#define kXHTMLApplicationContentType "application/xhtml+xml"
#define kXULTextContentType "application/vnd.mozilla.xul+xml"
#define kRDFTextContentType "text/rdf"
#define kXIFTextContentType "text/xif"
#define kPlainTextContentType "text/plain"
#define kViewSourceCommand "view-source"
#define kTextCSSContentType "text/css"
#define kApplicationJSContentType "application/x-javascript"
#define kTextJSContentType "text/javascript"
#define kSGMLTextContentType "text/sgml"
#define NS_IPARSER_FLAG_UNKNOWN_MODE 0x00000000
#define NS_IPARSER_FLAG_QUIRKS_MODE 0x00000002
#define NS_IPARSER_FLAG_STRICT_MODE 0x00000004
#define NS_IPARSER_FLAG_TRANSITIONAL_MODE 0x00000008
#define NS_IPARSER_FLAG_AUTO_DETECT_MODE 0x00000010
#define NS_IPARSER_FLAG_VIEW_NORMAL 0x00000020
#define NS_IPARSER_FLAG_VIEW_SOURCE 0x00000040
#define NS_IPARSER_FLAG_VIEW_ERRORS 0x00000080
#define NS_IPARSER_FLAG_PLAIN_TEXT 0x00000100
#define NS_IPARSER_FLAG_XML_TEXT 0x00000200
#define NS_IPARSER_FLAG_XHTML_TEXT 0x00000400
#define NS_IPARSER_FLAG_HTML3_TEXT 0x00000800
#define NS_IPARSER_FLAG_HTML4_TEXT 0x00001000
#endif

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

@ -0,0 +1,63 @@
/* -*- 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 jevering 6/17/98
*
* This interface is not yet used; it was intended to allow an observer object
* to "look at" the i/o stream coming into the parser before, during and after
* the parser saw it. The intention of this was to allow an observer to modify
* the stream at various stages.
*/
#ifndef IPARSERFILTER
#define IPARSERFILTER
#include "nsISupports.h"
class CToken;
#define NS_IPARSERFILTER_IID \
{0x14d6ff0, 0x0610, 0x11d2, \
{0x8c, 0x3f, 0x00, 0x80, 0x5f, 0x8a, 0x1d, 0xb7}}
class nsIParserFilter : public nsISupports {
public:
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IPARSERFILTER_IID)
NS_IMETHOD RawBuffer(const char * buffer, PRUint32 * buffer_length) = 0;
NS_IMETHOD WillAddToken(CToken & token) = 0;
NS_IMETHOD ProcessTokens( /* dont know what goes here yet */ void ) = 0;
NS_IMETHOD Finish() = 0;
};
#endif

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

@ -0,0 +1,180 @@
/* -*- 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
*
* This class is defines the basic interface between the
* parser and the content sink. The parser will iterate
* over the collection of tokens that it sees from the
* tokenizer, coverting each related "group" into one of
* these. This object gets passed to the sink, and is
* then immediately reused.
*
* If you want to hang onto one of these, you should
* make your own copy.
*
*/
#ifndef NS_IPARSERNODE__
#define NS_IPARSERNODE__
#include "nsISupports.h"
#include "prtypes.h"
#include "nsString.h"
#include "nsDebug.h"
//#define HEAP_ALLOCATED_NODES
//#define DEBUG_TRACK_NODES
class CToken;
// 6e59f160-2717-11d2-9246-00805f8a7ab6
#define NS_IPARSER_NODE_IID \
{0x6e59f160, 0x2717, 0x11d1, \
{0x92, 0x46, 0x00, 0x80, 0x5f, 0x8a, 0x7a, 0xb6}}
/**
* Parser nodes are the unit of exchange between the
* parser and the content sink. Nodes offer access to
* the current token, its attributes, and its skipped-
* content if applicable.
*
* @update gess 3/25/98
*/
class nsIParserNode { // XXX Should be nsAParserNode
public:
/**
* Retrieve the name of the node
* @update gess5/11/98
* @return string containing node name
*/
virtual const nsString& GetName() const =0; //to get name of tag
/**
* Retrieve the text from the given node
* @update gess5/11/98
* @return string containing node text
*/
virtual const nsAReadableString& GetText() const =0; //get plain text if available
/**
* Retrieve skipped context from node
* @update gess5/11/98
* @return string containing skipped content
*/
virtual const nsString& GetSkippedContent() const =0;
/**
* Retrieve the type of the parser node.
* @update gess5/11/98
* @return node type.
*/
virtual PRInt32 GetNodeType() const =0;
/**
* Retrieve token type of parser node
* @update gess5/11/98
* @return token type
*/
virtual PRInt32 GetTokenType() const =0;
/**
* Retrieve the number of attributes in this node.
* @update gess5/11/98
* @return count of attributes (may be 0)
*/
virtual PRInt32 GetAttributeCount(PRBool askToken=PR_FALSE) const =0;
/**
* Retrieve the key (of key/value pair) at given index
* @update gess5/11/98
* @param anIndex is the index of the key you want
* @return string containing key.
*/
virtual const nsAReadableString& GetKeyAt(PRUint32 anIndex) const =0;
/**
* Retrieve the value (of key/value pair) at given index
* @update gess5/11/98
* @param anIndex is the index of the value you want
* @return string containing value.
*/
virtual const nsString& GetValueAt(PRUint32 anIndex) const =0;
/**
* NOTE: When the node is an entity, this will translate the entity
* to it's unicode value, and store it in aString.
* @update gess5/11/98
* @param aString will contain the resulting unicode string value
* @return int (unicode char or unicode index from table)
*/
virtual PRInt32 TranslateToUnicodeStr(nsString& aString) const = 0;
virtual void AddAttribute(CToken* aToken)=0;
/**
* This getter retrieves the line number from the input source where
* the token occured. Lines are interpreted as occuring between \n characters.
* @update gess7/24/98
* @return int containing the line number the token was found on
*/
virtual PRInt32 GetSourceLineNumber(void) const =0;
/**
* This pair of methods allows us to set a generic bit (for arbitrary use)
* on each node stored in the context.
* @update gess 11May2000
*/
virtual PRBool GetGenericState(void) const =0;
virtual void SetGenericState(PRBool aState) =0;
/** Retrieve a string containing the tag and its attributes in "source" form
* @update rickg 06June2000
* @return void
*/
virtual void GetSource(nsString& aString)=0;
/** Release all the objects you're holding
* @update harishd 08/02/00
* @return void
*/
virtual nsresult ReleaseAll()=0;
/*
* Get and set the ID attribute atom for this node.
* See http://www.w3.org/TR/1998/REC-xml-19980210#sec-attribute-types
* for the definition of an ID attribute.
*
*/
virtual nsresult GetIDAttributeAtom(nsIAtom** aResult) const = 0;
virtual nsresult SetIDAttributeAtom(nsIAtom* aID) = 0;
};
#endif

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

@ -0,0 +1,54 @@
/* -*- 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 Communicator client 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):
*/
#ifndef nsIParserService_h__
#define nsIParserService_h__
#include "nsISupports.h"
#include "nsString.h"
#define NS_IPARSERSERVICE_IID \
{ 0xa6cf9111, 0x15b3, 0x11d2, \
{ 0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32 } }
class nsIParserService : public nsISupports {
public:
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IPARSERSERVICE_IID)
NS_IMETHOD HTMLAtomTagToId(nsIAtom* aAtom, PRInt32* aId) const=0;
NS_IMETHOD HTMLStringTagToId(const nsString &aTag, PRInt32* aId) const =0;
NS_IMETHOD HTMLIdToStringTag(PRInt32 aId, nsString& aTag) const =0;
NS_IMETHOD HTMLConvertEntityToUnicode(const nsString& aEntity,
PRInt32* aUnicode) const =0;
NS_IMETHOD HTMLConvertUnicodeToEntity(PRInt32 aUnicode,
nsCString& aEntity) const =0;
NS_IMETHOD IsContainer(PRInt32 aId, PRBool& aIsContainer) const =0;
NS_IMETHOD IsBlock(PRInt32 aId, PRBool& aIsBlock) const =0;
};
#endif // nsIParserService_h__

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

@ -0,0 +1,79 @@
/* -*- 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"
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:
NS_DEFINE_STATIC_IID_ACCESSOR(NS_ITOKENIZER_IID)
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

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

@ -0,0 +1,78 @@
/* -*- 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):
*/
#ifndef nsParserCIID_h__
#define nsParserCIID_h__
#include "nsISupports.h"
#include "nsIFactory.h"
#include "nsIComponentManager.h"
// {2ce606b0-bee6-11d1-aad9-00805f8a3e14}
#define NS_PARSER_CID \
{ 0x2ce606b0, 0xbee6, 0x11d1, { 0xaa, 0xd9, 0x0, 0x80, 0x5f, 0x8a, 0x3e, 0x14 } }
// XXX: This object should not be exposed outside of the parser.
// Remove when CNavDTD subclasses do not need access
#define NS_PARSER_NODE_IID \
{0x9039c670, 0x2717, 0x11d2, \
{0x92, 0x46, 0x00, 0x80, 0x5f, 0x8a, 0x7a, 0xb6}}
// {E6FD9941-899D-11d2-8EAE-00805F29F370}
#define NS_WELLFORMEDDTD_CID \
{ 0xe6fd9941, 0x899d, 0x11d2, { 0x8e, 0xae, 0x0, 0x80, 0x5f, 0x29, 0xf3, 0x70 } }
// {a6cf9107-15b3-11d2-932e-00805f8add32}
#define NS_CNAVDTD_CID \
{ 0xa6cf9107, 0x15b3, 0x11d2, { 0x93, 0x2e, 0x0, 0x80, 0x5f, 0x8a, 0xdd, 0x32 } }
// Class IID for the logging sink
#define NS_LOGGING_SINK_CID \
{0xa6cf9060, 0x15b3, 0x11d2,{0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32}}
// {a6cf910e-15b3-11d2-932e-00805f8add32}
#define NS_XIF_DTD_CID \
{ 0xa6cf910e, 0x15b3, 0x11d2, { 0x93, 0x2e, 0x0, 0x80, 0x5f, 0x8a, 0xdd, 0x32 } }
// {CCF5BED0-1AF8-11d4-812B-0010A4E0C706}
#define NS_COTHER_DTD_CID \
{ 0xccf5bed0, 0x1af8, 0x11d4, { 0x81, 0x2b, 0x0, 0x10, 0xa4, 0xe0, 0xc7, 0x6 } }
// {4611d482-960a-11d4-8eb0-b617661b6f7c}
#define NS_CTRANSITIONAL_DTD_CID \
{ 0x4611d482, 0x960a, 0x11d4, { 0x8e, 0xb0, 0xb6, 0x17, 0x66, 0x1b, 0x6f, 0x7c } }
// {8323FAD0-2102-11d4-8142-000064657374}
#define NS_VIEWSOURCE_DTD_CID \
{ 0x8323fad0, 0x2102, 0x11d4, { 0x81, 0x42, 0x0, 0x0, 0x64, 0x65, 0x73, 0x74 } }
// {a6cf910f-15b3-11d2-932e-00805f8add32}
#define NS_HTMLCONTENTSINKSTREAM_CID \
{ 0xa6cf910f, 0x15b3, 0x11d2, { 0x93, 0x2e, 0x0, 0x80, 0x5f, 0x8a, 0xdd, 0x32 } }
// {a6cf9112-15b3-11d2-932e-00805f8add32}
#define NS_PARSERSERVICE_CID \
{ 0xa6cf9112, 0x15b3, 0x11d2, { 0x93, 0x2e, 0x0, 0x80, 0x5f, 0x8a, 0xdd, 0x32 } }
#endif

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

@ -0,0 +1,49 @@
/* -*- 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 nra 3/3/99
*
* nsParserError structifies the notion of a parser error.
*/
#ifndef PARSERERROR__
#define PARSERERROR__
#include "prtypes.h"
#include "nsString.h"
typedef struct _nsParserError {
PRInt32 code;
PRInt32 lineNumber;
PRInt32 colNumber;
nsString description;
nsString sourceLine;
nsString sourceURL;
} nsParserError;
#endif

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

@ -0,0 +1,281 @@
/* -*- 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
*
* This class is defines the basic notion of a token
* within our system. All other tokens are derived from
* this one. It offers a few basic interfaces, but the
* most important is consume(). The consume() method gets
* called during the tokenization process when an instance
* of that particular token type gets detected in the
* input stream.
*
* CToken objects that are allocated from the heap _must_ be allocated
* using the nsTokenAllocator: the nsTokenAllocator object uses an
* arena to manage the tokens.
*
* The nsTokenAllocator object's arena implementation requires
* object size at destruction time to properly recycle the object;
* therefore, CToken::operator delete() is not public. Instead,
* heap-allocated tokens should be destroyed using the static
* Destroy() method, which accepts a token and the arena from which
* the token was allocated.
*
* Leaf classes (that are actually instantiated from the heap) must
* implement the SizeOf() method, which Destroy() uses to determine
* the size of the token in order to properly recycle it.
*/
#ifndef CTOKEN__
#define CTOKEN__
#include "prtypes.h"
#include "nsString.h"
#include "nsError.h"
#include "nsFileSpec.h"
#include "nsFixedSizeAllocator.h"
#define NS_HTMLTOKENS_NOT_AN_ENTITY \
NS_ERROR_GENERATE_SUCCESS(NS_ERROR_MODULE_HTMLPARSER,2000)
class nsScanner;
class nsTokenAllocator;
enum eContainerInfo {
eWellFormed,
eMalformed,
eFormUnknown
};
/**
* Implement the SizeOf() method; leaf classes derived from CToken
* must declare this.
*/
#define CTOKEN_IMPL_SIZEOF \
protected: \
virtual size_t SizeOf() const { return sizeof(*this); } \
public:
/**
* Token objects represent sequences of characters as they
* are consumed from the input stream (URL). While they're
* pretty general in nature, we use subclasses (found in
* nsHTMLTokens.h) to define <start>, </end>, <text>,
* <comment>, <&entity>, <newline>, and <whitespace> tokens.
*
* @update gess 3/25/98
*/
class CToken {
public:
enum eTokenOrigin {eSource,eResidualStyle};
protected:
// nsTokenAllocator should be the only class that tries to
// allocate tokens from the heap.
friend class nsTokenAllocator;
/**
*
* @update harishd 08/01/00
* @param aSize -
* @param aArena - Allocate memory from this pool.
*/
static void * operator new (size_t aSize,nsFixedSizeAllocator& anArena)
{
return anArena.Alloc(aSize);
}
/**
* Hide operator delete; clients should use Destroy() instead.
*/
static void operator delete (void*,size_t) {}
public:
/**
* destructor
* @update gess5/11/98
*/
virtual ~CToken();
/**
* Destroy a token.
*/
static void Destroy(CToken* aToken,nsFixedSizeAllocator& aArenaPool)
{
size_t sz = aToken->SizeOf();
aToken->~CToken();
aArenaPool.Free(aToken, sz);
}
/**
* Make a note on number of times you have been referenced
* @update harishd 08/02/00
*/
void AddRef() { mUseCount++; }
/**
* Free yourself if no one is holding you.
* @update harishd 08/02/00
*/
void Release(nsFixedSizeAllocator& aArenaPool) {
if(--mUseCount==0)
Destroy(this, aArenaPool);
}
/**
* Default constructor
* @update gess7/21/98
*/
CToken(PRInt32 aTag=0);
/**
* Retrieve string value of the token
* @update gess5/11/98
* @return reference to string containing string value
*/
virtual const nsAReadableString& GetStringValue(void) = 0;
/**
* Get string of full contents, suitable for debug dump.
* It should look exactly like the input source.
* @update gess5/11/98
* @return reference to string containing string value
*/
virtual void GetSource(nsString& anOutputString);
/** @update harishd 03/23/00
* @return reference to string containing string value
*/
virtual void AppendSource(nsString& anOutputString);
/**
* Sets the ordinal value of this token (not currently used)
* @update gess5/11/98
* @param value is the new ord value for this token
*/
virtual void SetTypeID(PRInt32 aValue);
/**
* Getter which retrieves the current ordinal value for this token
* @update gess5/11/98
* @return current ordinal value
*/
virtual PRInt32 GetTypeID(void);
/**
* Sets the # of attributes found for this token.
* @update gess5/11/98
* @param value is the attr count
*/
virtual void SetAttributeCount(PRInt16 aValue);
/**
* Getter which retrieves the current attribute count for this token
* @update gess5/11/98
* @return current attribute count
*/
virtual PRInt16 GetAttributeCount(void);
/**
* Causes token to consume data from given scanner.
* Note that behavior varies wildly between CToken subclasses.
* @update gess5/11/98
* @param aChar -- most recent char consumed
* @param aScanner -- input source where token should get data
* @return error code (0 means ok)
*/
virtual nsresult Consume(PRUnichar aChar,nsScanner& aScanner,PRInt32 aMode);
/**
* Causes token to dump itself in debug form to given output stream
* @update gess5/11/98
* @param out is the output stream where token should write itself
*/
virtual void DebugDumpToken(nsOutputStream& out);
/**
* Causes token to dump itself in source form to given output stream
* @update gess5/11/98
* @param out is the output stream where token should write itself
*/
virtual void DebugDumpSource(nsOutputStream& out);
/**
* Getter which retrieves type of token
* @update gess5/11/98
* @return int containing token type
*/
virtual PRInt32 GetTokenType(void);
/**
* Getter which retrieves the class name for this token
* This method is only used for debug purposes.
* @update gess5/11/98
* @return const char* containing class name
*/
virtual const char* GetClassName(void);
/**
* For tokens who care, this can tell us whether the token is
* well formed or not.
*
* @update gess 8/30/00
* @return PR_FALSE; subclasses MUST override if they care.
*/
virtual PRBool IsWellFormed(void) const {return PR_FALSE;}
/**
* perform self test.
* @update gess5/11/98
*/
virtual void SelfTest(void);
static int GetTokenCount();
eTokenOrigin mOrigin;
PRInt32 mNewlineCount;
protected:
/**
* Returns the size of the token object.
*/
virtual size_t SizeOf() const = 0;
PRInt32 mTypeID;
PRInt16 mAttrCount;
PRInt32 mUseCount;
};
#endif

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

@ -0,0 +1,48 @@
/* -*- 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 nshtmlpars_h___
#define nshtmlpars_h___
#include "nscore.h"
#include "nsError.h"
#ifdef _IMPL_NS_HTMLPARS
#define NS_HTMLPARS NS_EXPORT
#else
#define NS_HTMLPARS NS_IMPORT
#endif
#if defined(XP_MAC)
#define CLASS_EXPORT_HTMLPARS NS_HTMLPARS class
#else
#define CLASS_EXPORT_HTMLPARS class NS_HTMLPARS
#endif
#endif /* nshtmlpars_h___ */

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

@ -28,7 +28,6 @@
#include "nsDebug.h"
#include "nsIDTDDebug.h"
#include "CNavDTD.h"
#include "nsHTMLTokens.h"
#include "nsCRT.h"
@ -36,7 +35,6 @@
#include "nsIParser.h"
#include "nsIHTMLContentSink.h"
#include "nsScanner.h"
#include "nsIDTDDebug.h"
#include "prenv.h" //this is here for debug reasons...
#include "prtypes.h" //this is here for debug reasons...
#include "prio.h"
@ -54,7 +52,10 @@
#include "nsVoidArray.h"
#include "nsReadableUtils.h"
#include "prmem.h"
#if !defined(MOZ_DISABLE_DTD_DEBUG)
#include "nsLoggingSink.h"
#endif
static NS_DEFINE_IID(kIHTMLContentSinkIID, NS_IHTML_CONTENT_SINK_IID);
@ -171,9 +172,6 @@ CNavDTD::CNavDTD() : nsIDTD(),
mExpectedCRC32(0),
#endif
#ifdef NS_DEBUG
mDTDDebug(0),
#endif
mLineNumber(1)
{
NS_INIT_REFCNT();
@ -200,6 +198,8 @@ const nsIID& CNavDTD::GetMostDerivedIID(void)const {
}
#if !defined(MOZ_DISABLE_DTD_DEBUG)
nsLoggingSink* GetLoggingSink() {
//these are used when you want to generate a log file for contentsink construction...
@ -216,7 +216,6 @@ nsLoggingSink* GetLoggingSink() {
checkForPath=PR_FALSE;
}
#ifdef NS_DEBUG
if(gLogPath && (!theSink)) {
static nsLoggingSink gLoggingSink;
@ -234,11 +233,12 @@ nsLoggingSink* GetLoggingSink() {
gLoggingSink.SetOutputStream(theLogFile,PR_TRUE);
theSink=&gLoggingSink;
}
#endif
return theSink;
}
#endif
/**
* Default destructor
*
@ -259,18 +259,17 @@ CNavDTD::~CNavDTD(){
mTempContext=0;
}
#if !defined(MOZ_DISABLE_DTD_DEBUG)
if(mSink) {
nsLoggingSink *theLogSink=GetLoggingSink();
if(mSink==theLogSink) {
theLogSink->ReleaseProxySink();
}
NS_IF_RELEASE(mSink);
}
#ifdef NS_DEBUG
NS_IF_RELEASE(mDTDDebug);
#endif
NS_IF_RELEASE(mSink);
}
@ -297,39 +296,6 @@ nsresult CNavDTD::CreateNewInstance(nsIDTD** aInstancePtrResult){
return result;
}
/**
* Called by the parser to initiate dtd verification of the
* internal context stack.
* @update gess 7/23/98
* @param
* @return
*/
PRBool CNavDTD::Verify(nsString& aURLRef,nsIParser* aParser){
PRBool result=PR_TRUE;
/*
* Disable some DTD debugging code in the parser that
* breaks on some compilers because of some broken
* streams code in prstrm.cpp.
*/
#ifdef NS_DEBUG
if(!mDTDDebug){
nsresult rval = NS_NewDTDDebug(&mDTDDebug);
if (NS_OK != rval) {
fputs("Cannot create parser debugger.\n", stdout);
result=-PR_FALSE;
}
else mDTDDebug->SetVerificationDirectory(kVerificationDir);
}
if(mDTDDebug) {
// mDTDDebug->Verify(this,aParser,mBodyContext->GetCount(),mBodyContext->mStack,aURLRef);
}
#endif
return result;
}
/**
* This method is called to determine if the given DTD can parse
* a document in a given source-type.
@ -428,7 +394,7 @@ nsresult CNavDTD::WillBuildModel( const CParserContext& aParserContext,nsIConte
//a logging sink. If so, then we'll create one, and make it the
//proxy for the real sink we're given from the parser.
#ifdef NS_DEBUG
#if !defined(MOZ_DISABLE_DTD_DEBUG)
nsLoggingSink *theLogSink=GetLoggingSink();
if(theLogSink) {
theLogSink->SetProxySink(mSink);
@ -682,12 +648,6 @@ nsresult CNavDTD::DidBuildModel(nsresult anErrorCode,PRBool aNotifySink,nsIParse
while((theToken=(CToken*)mMisplacedContent.Pop())) {
IF_FREE(theToken, mTokenAllocator);
}
#ifdef NS_DEBUG
if(mDTDDebug) {
mDTDDebug->DumpVectorRecord();
}
#endif
}
} //if aparser
@ -943,12 +903,6 @@ nsresult CNavDTD::HandleToken(CToken* aToken,nsIParser* aParser){
else {
return NS_OK;
}
#ifdef NS_DEBUG
if (mDTDDebug) {
//mDTDDebug->Verify(this, mParser, mBodyContext->GetCount(), mBodyContext->mStack, mFilename);
}
#endif
}
}

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

@ -86,7 +86,6 @@
#include "nsISupports.h"
#include "nsIParser.h"
#include "nsHTMLTags.h"
#include "nshtmlpars.h"
#include "nsVoidArray.h"
#include "nsDeque.h"
#include "nsParserCIID.h"
@ -99,7 +98,6 @@
class nsIHTMLContentSink;
class nsIDTDDebug;
class nsIParserNode;
class nsParser;
class nsDTDContext;
@ -168,16 +166,6 @@ CLASS_EXPORT_HTMLPARS CNavDTD : public nsIDTD {
*/
virtual eAutoDetectResult CanParse(CParserContext& aParserContext,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
@ -511,10 +499,6 @@ protected:
nsAutoString mMimeType; //ok as an autostring; these are short.
nsNodeAllocator mNodeAllocator;
nsString mFilename;
#ifdef NS_DEBUG
nsIDTDDebug* mDTDDebug;
#endif
#ifdef ENABLE_CRC
PRUint32 mComputedCRC32;

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

@ -24,8 +24,7 @@
//#define RICKG_DEBUG
#include "nsDebug.h"
#include "nsIDTDDebug.h"
#include "nsDebug.h"
#include "COtherDTD.h"
#include "nsHTMLTokens.h"
#include "nsCRT.h"
@ -33,7 +32,6 @@
#include "nsIParser.h"
#include "nsIHTMLContentSink.h"
#include "nsScanner.h"
#include "nsIDTDDebug.h"
#include "prenv.h" //this is here for debug reasons...
#include "prtypes.h" //this is here for debug reasons...
#include "prio.h"
@ -132,8 +130,7 @@ NS_IMPL_RELEASE(COtherDTD)
COtherDTD::COtherDTD() : nsIDTD() {
NS_INIT_REFCNT();
mSink = 0;
mParser=0;
mDTDDebug=0;
mParser=0;
mLineNumber=1;
mHasOpenBody=PR_FALSE;
mHasOpenHead=0;
@ -199,7 +196,6 @@ COtherDTD::~COtherDTD(){
NS_IF_RELEASE(mTokenizer);
NS_IF_RELEASE(mSink);
NS_IF_RELEASE(mDTDDebug);
}
/**
@ -243,38 +239,6 @@ nsresult COtherDTD::CreateNewInstance(nsIDTD** aInstancePtrResult){
return result;
}
/**
* Called by the parser to initiate dtd verification of the
* internal context stack.
* @update gess 7/23/98
* @param
* @return
*/
PRBool COtherDTD::Verify(nsString& aURLRef,nsIParser* aParser){
PRBool result=PR_TRUE;
/*
* Disable some DTD debugging code in the parser that
* breaks on some compilers because of some broken
* streams code in prstrm.cpp.
*/
#if !defined(MOZ_DISABLE_DTD_DEBUG)
if(!mDTDDebug){
nsresult rval = NS_NewDTDDebug(&mDTDDebug);
if (NS_OK != rval) {
fputs("Cannot create parser debugger.\n", stdout);
result=-PR_FALSE;
}
else mDTDDebug->SetVerificationDirectory(kVerificationDir);
}
#endif
if(mDTDDebug) {
// mDTDDebug->Verify(this,aParser,mBodyContext->GetCount(),mBodyContext->mStack,aURLRef);
}
return result;
}
/**
* This method is called to determine if the given DTD can parse
* a document in a given source-type.

Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше