зеркало из https://github.com/mozilla/pjs.git
New tag handling code added
This commit is contained in:
Родитель
70a3daee6f
Коммит
dad4716664
|
@ -33,6 +33,8 @@
|
|||
#include "prio.h"
|
||||
#include "plstr.h"
|
||||
#include "nsDTDUtils.h"
|
||||
#include "nsTagHandler.h"
|
||||
|
||||
#ifdef XP_PC
|
||||
#include <direct.h> //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...
|
||||
************************************************************************/
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -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
|
|
@ -33,6 +33,8 @@
|
|||
#include "prio.h"
|
||||
#include "plstr.h"
|
||||
#include "nsDTDUtils.h"
|
||||
#include "nsTagHandler.h"
|
||||
|
||||
#ifdef XP_PC
|
||||
#include <direct.h> //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...
|
||||
************************************************************************/
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -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
|
Загрузка…
Ссылка в новой задаче