diff --git a/mozilla/htmlparser/src/CNavDTD.cpp b/mozilla/htmlparser/src/CNavDTD.cpp
index 92344630664..0b0a9e3ffa2 100644
--- a/mozilla/htmlparser/src/CNavDTD.cpp
+++ b/mozilla/htmlparser/src/CNavDTD.cpp
@@ -33,6 +33,8 @@
#include "prio.h"
#include "plstr.h"
#include "nsDTDUtils.h"
+#include "nsTagHandler.h"
+
#ifdef XP_PC
#include //this is here for debug reasons...
#endif
@@ -94,6 +96,82 @@ static eHTMLTags gWhitespaceTags[]={
static CTokenRecycler gTokenRecycler;
+
+/***************************************************************
+ This the ITagHandler deque deallocator, needed by the
+ CTagHandlerRegister
+ ***************************************************************/
+class CTagHandlerDeallocator: public nsDequeFunctor{
+public:
+ virtual void* operator()(void* anObject) {
+ nsITagHandler* tagHandler =(nsITagHandler*)anObject;
+ delete tagHandler;
+ return 0;
+ }
+};
+
+/***************************************************************
+ This funtor will be called for each item in the TagHandler que to
+ check for a Tag name, and setting the current TagHandler when it is reached
+ ***************************************************************/
+class CTagFinder: public nsDequeFunctor{
+public:
+ CTagFinder(nsAutoString* aTagName) {
+ }
+
+ virtual ~CTagFinder() {
+ }
+
+ virtual void* operator()(void* anObject) {
+
+ mCurTagHandler = 0;
+ if( ((nsITagHandler*)anObject)->GetString()== mTagName){
+ mCurTagHandler = (nsITagHandler*)anObject;
+ return 0;
+ }
+ return(anObject);
+ }
+
+ nsAutoString* mTagName;
+ nsITagHandler* mCurTagHandler;
+};
+
+/***************************************************************
+ This a an object that will keep track of TagHandlers in
+ the DTD. Uses a factory pattern
+ ***************************************************************/
+class CTagHandlerRegister {
+
+
+public:
+ CTagHandlerRegister() : mDeallocator(), mTagHandlerDeque(mDeallocator) {
+ }
+
+ ~CTagHandlerRegister() {
+ }
+
+ void RegisterTagHandler(nsAutoString *aTagName,nsITagHandler *aTagHandler){
+ aTagHandler->SetString(aTagName);
+ mTagHandlerDeque.Push(aTagHandler);
+ }
+
+ nsITagHandler* FindTagHandler(nsAutoString* aTagName){
+ mTagHandlerDeque.Begin();
+
+ return 0;
+ }
+
+ CTagHandlerDeallocator mDeallocator;
+ nsDeque mTagHandlerDeque;
+
+};
+
+
+
+
+CTagHandlerRegister gTagHandlerRegister;
+
+
/************************************************************************
And now for the main class -- CNavDTD...
************************************************************************/
diff --git a/mozilla/htmlparser/src/nsDTDUtils.h b/mozilla/htmlparser/src/nsDTDUtils.h
index 21800671cdb..cfa876ba0b9 100644
--- a/mozilla/htmlparser/src/nsDTDUtils.h
+++ b/mozilla/htmlparser/src/nsDTDUtils.h
@@ -150,8 +150,10 @@ protected:
class nsITagHandler {
public:
- virtual PRBool HandleToken(CToken* aToken,nsIDTD* aDTD)=0;
- virtual PRBool HandleCapturedTokens(CToken* aToken,nsIDTD* aDTD)=0;
+ virtual void SetString(nsAutoString *aTheString)=0;
+ virtual nsAutoString* GetString()=0;
+ virtual PRBool HandleToken(CToken* aToken,nsIDTD* aDTD)=0;
+ virtual PRBool HandleCapturedTokens(CToken* aToken,nsIDTD* aDTD)=0;
};
diff --git a/mozilla/htmlparser/src/nsTagHandler.h b/mozilla/htmlparser/src/nsTagHandler.h
new file mode 100644
index 00000000000..078d13e47d1
--- /dev/null
+++ b/mozilla/htmlparser/src/nsTagHandler.h
@@ -0,0 +1,76 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/*
+ * The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "NPL"); you may not use this file except in
+ * compliance with the NPL. You may obtain a copy of the NPL at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the NPL is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
+ * for the specific language governing rights and limitations under the
+ * NPL.
+ *
+ * The Initial Developer of this code under the NPL is Netscape
+ * Communications Corporation. Portions created by Netscape are
+ * Copyright (C) 1998 Netscape Communications Corporation. All Rights
+ * Reserved.
+ */
+#ifndef NS_TAGHANDLER___
+#define NS_TAGHANDLER___
+
+
+#include "nsDTDUtils.h"
+#include "nsString.h"
+
+/**
+ * MODULE NOTES:
+ * @update DC 11/5/98
+ **/
+
+
+/**
+ * This class defines the object that can do special tag handling
+ *
+ * @update DC 11/5/98
+ */
+class nsTagHandler : public nsITagHandler {
+
+// MEMBERS
+public:
+ nsAutoString mTheTagName;
+
+
+// METHODS
+public:
+
+ /**
+ * Constructor
+ * @update dc 11/5/98
+ */
+ nsTagHandler() {}
+
+ ~nsTagHandler() {}
+
+ /**
+ * SetString
+ */
+ void SetString(nsAutoString *aTheString) {}
+
+ nsAutoString* GetString() {return 0;}
+
+ /**
+ * Handle this token prior to the DTD
+ * @update dc 11/5/98
+ */
+ virtual PRBool HandleToken(CToken* aToken,nsIDTD* aDTD) {return PR_FALSE;};
+
+ /**
+ * Handle this token prior to the DTD
+ * @update dc 11/5/98
+ * @return ptr to previously set contentsink (usually null)
+ */
+ virtual PRBool HandleCapturedTokens(CToken* aToken,nsIDTD* aDTD) {return PR_FALSE;};
+
+};
+
+#endif
diff --git a/mozilla/parser/htmlparser/src/CNavDTD.cpp b/mozilla/parser/htmlparser/src/CNavDTD.cpp
index 92344630664..0b0a9e3ffa2 100644
--- a/mozilla/parser/htmlparser/src/CNavDTD.cpp
+++ b/mozilla/parser/htmlparser/src/CNavDTD.cpp
@@ -33,6 +33,8 @@
#include "prio.h"
#include "plstr.h"
#include "nsDTDUtils.h"
+#include "nsTagHandler.h"
+
#ifdef XP_PC
#include //this is here for debug reasons...
#endif
@@ -94,6 +96,82 @@ static eHTMLTags gWhitespaceTags[]={
static CTokenRecycler gTokenRecycler;
+
+/***************************************************************
+ This the ITagHandler deque deallocator, needed by the
+ CTagHandlerRegister
+ ***************************************************************/
+class CTagHandlerDeallocator: public nsDequeFunctor{
+public:
+ virtual void* operator()(void* anObject) {
+ nsITagHandler* tagHandler =(nsITagHandler*)anObject;
+ delete tagHandler;
+ return 0;
+ }
+};
+
+/***************************************************************
+ This funtor will be called for each item in the TagHandler que to
+ check for a Tag name, and setting the current TagHandler when it is reached
+ ***************************************************************/
+class CTagFinder: public nsDequeFunctor{
+public:
+ CTagFinder(nsAutoString* aTagName) {
+ }
+
+ virtual ~CTagFinder() {
+ }
+
+ virtual void* operator()(void* anObject) {
+
+ mCurTagHandler = 0;
+ if( ((nsITagHandler*)anObject)->GetString()== mTagName){
+ mCurTagHandler = (nsITagHandler*)anObject;
+ return 0;
+ }
+ return(anObject);
+ }
+
+ nsAutoString* mTagName;
+ nsITagHandler* mCurTagHandler;
+};
+
+/***************************************************************
+ This a an object that will keep track of TagHandlers in
+ the DTD. Uses a factory pattern
+ ***************************************************************/
+class CTagHandlerRegister {
+
+
+public:
+ CTagHandlerRegister() : mDeallocator(), mTagHandlerDeque(mDeallocator) {
+ }
+
+ ~CTagHandlerRegister() {
+ }
+
+ void RegisterTagHandler(nsAutoString *aTagName,nsITagHandler *aTagHandler){
+ aTagHandler->SetString(aTagName);
+ mTagHandlerDeque.Push(aTagHandler);
+ }
+
+ nsITagHandler* FindTagHandler(nsAutoString* aTagName){
+ mTagHandlerDeque.Begin();
+
+ return 0;
+ }
+
+ CTagHandlerDeallocator mDeallocator;
+ nsDeque mTagHandlerDeque;
+
+};
+
+
+
+
+CTagHandlerRegister gTagHandlerRegister;
+
+
/************************************************************************
And now for the main class -- CNavDTD...
************************************************************************/
diff --git a/mozilla/parser/htmlparser/src/nsDTDUtils.h b/mozilla/parser/htmlparser/src/nsDTDUtils.h
index 21800671cdb..cfa876ba0b9 100644
--- a/mozilla/parser/htmlparser/src/nsDTDUtils.h
+++ b/mozilla/parser/htmlparser/src/nsDTDUtils.h
@@ -150,8 +150,10 @@ protected:
class nsITagHandler {
public:
- virtual PRBool HandleToken(CToken* aToken,nsIDTD* aDTD)=0;
- virtual PRBool HandleCapturedTokens(CToken* aToken,nsIDTD* aDTD)=0;
+ virtual void SetString(nsAutoString *aTheString)=0;
+ virtual nsAutoString* GetString()=0;
+ virtual PRBool HandleToken(CToken* aToken,nsIDTD* aDTD)=0;
+ virtual PRBool HandleCapturedTokens(CToken* aToken,nsIDTD* aDTD)=0;
};
diff --git a/mozilla/parser/htmlparser/src/nsTagHandler.h b/mozilla/parser/htmlparser/src/nsTagHandler.h
new file mode 100644
index 00000000000..078d13e47d1
--- /dev/null
+++ b/mozilla/parser/htmlparser/src/nsTagHandler.h
@@ -0,0 +1,76 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/*
+ * The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "NPL"); you may not use this file except in
+ * compliance with the NPL. You may obtain a copy of the NPL at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the NPL is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
+ * for the specific language governing rights and limitations under the
+ * NPL.
+ *
+ * The Initial Developer of this code under the NPL is Netscape
+ * Communications Corporation. Portions created by Netscape are
+ * Copyright (C) 1998 Netscape Communications Corporation. All Rights
+ * Reserved.
+ */
+#ifndef NS_TAGHANDLER___
+#define NS_TAGHANDLER___
+
+
+#include "nsDTDUtils.h"
+#include "nsString.h"
+
+/**
+ * MODULE NOTES:
+ * @update DC 11/5/98
+ **/
+
+
+/**
+ * This class defines the object that can do special tag handling
+ *
+ * @update DC 11/5/98
+ */
+class nsTagHandler : public nsITagHandler {
+
+// MEMBERS
+public:
+ nsAutoString mTheTagName;
+
+
+// METHODS
+public:
+
+ /**
+ * Constructor
+ * @update dc 11/5/98
+ */
+ nsTagHandler() {}
+
+ ~nsTagHandler() {}
+
+ /**
+ * SetString
+ */
+ void SetString(nsAutoString *aTheString) {}
+
+ nsAutoString* GetString() {return 0;}
+
+ /**
+ * Handle this token prior to the DTD
+ * @update dc 11/5/98
+ */
+ virtual PRBool HandleToken(CToken* aToken,nsIDTD* aDTD) {return PR_FALSE;};
+
+ /**
+ * Handle this token prior to the DTD
+ * @update dc 11/5/98
+ * @return ptr to previously set contentsink (usually null)
+ */
+ virtual PRBool HandleCapturedTokens(CToken* aToken,nsIDTD* aDTD) {return PR_FALSE;};
+
+};
+
+#endif