зеркало из https://github.com/mozilla/gecko-dev.git
68790 - Remove nsHTMLContentSinkStream dependency. Not in use anymore
r=heikki sr=jst
This commit is contained in:
Родитель
ebd847e390
Коммит
fa9d1080cf
|
@ -2063,87 +2063,6 @@ nsRange::CreateContextualFragment(const nsAReadableString& aFragment,
|
|||
return result;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsRange::IsValidFragment(const nsAReadableString& aFragment, PRBool* aReturn)
|
||||
{
|
||||
nsresult result = NS_OK;
|
||||
nsCOMPtr<nsIParser> parser;
|
||||
nsITagStack* tagStack;
|
||||
|
||||
if (!mIsPositioned) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
// Create a new parser for this entire operation
|
||||
result = nsComponentManager::CreateInstance(kCParserCID,
|
||||
nsnull,
|
||||
NS_GET_IID(nsIParser),
|
||||
(void **)getter_AddRefs(parser));
|
||||
if (NS_SUCCEEDED(result)) {
|
||||
result = parser->CreateTagStack(&tagStack);
|
||||
|
||||
if (NS_SUCCEEDED(result)) {
|
||||
nsCOMPtr<nsIDOMNode> parent;
|
||||
nsCOMPtr<nsIContent> content(do_QueryInterface(mStartParent, &result));
|
||||
|
||||
if (NS_SUCCEEDED(result)) {
|
||||
nsCOMPtr<nsIDocument> document;
|
||||
|
||||
result = content->GetDocument(*getter_AddRefs(document));
|
||||
|
||||
if (NS_SUCCEEDED(result)) {
|
||||
nsCOMPtr<nsIDOMDocument> domDocument(do_QueryInterface(document, &result));
|
||||
|
||||
if (NS_SUCCEEDED(result)) {
|
||||
parent = mStartParent;
|
||||
while (parent &&
|
||||
(parent != domDocument) &&
|
||||
NS_SUCCEEDED(result)) {
|
||||
nsCOMPtr<nsIDOMNode> temp;
|
||||
nsAutoString tagName;
|
||||
PRUnichar* name = nsnull;
|
||||
|
||||
parent->GetNodeName(tagName);
|
||||
// XXX Wish we didn't have to allocate here
|
||||
name = tagName.ToNewUnicode();
|
||||
if (name) {
|
||||
tagStack->Push(name);
|
||||
temp = parent;
|
||||
result = temp->GetParentNode(getter_AddRefs(parent));
|
||||
}
|
||||
else {
|
||||
result = NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
}
|
||||
|
||||
if (NS_SUCCEEDED(result)) {
|
||||
nsAutoString contentType;
|
||||
|
||||
document->GetContentType(contentType);
|
||||
*aReturn = parser->IsValidFragment(aFragment,
|
||||
*tagStack,
|
||||
0, contentType);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// XXX Ick! Delete strings we allocated above.
|
||||
PRUnichar* str = nsnull;
|
||||
str = tagStack->Pop();
|
||||
while (str) {
|
||||
nsCRT::free(str);
|
||||
str = tagStack->Pop();
|
||||
}
|
||||
|
||||
// XXX Double Ick! Deleting something that someone else newed.
|
||||
delete tagStack;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsRange::GetHasGeneratedBefore(PRBool *aBool)
|
||||
{
|
||||
|
|
|
@ -98,8 +98,6 @@ public:
|
|||
/*BEGIN nsIDOMNSRange interface implementations*/
|
||||
NS_IMETHOD CreateContextualFragment(const nsAReadableString& aFragment,
|
||||
nsIDOMDocumentFragment** aReturn);
|
||||
NS_IMETHOD IsValidFragment(const nsAReadableString& aFragment, PRBool* aReturn);
|
||||
|
||||
NS_IMETHOD IsPointInRange(nsIDOMNode* aParent, PRInt32 aOffset,
|
||||
PRBool* aResult);
|
||||
NS_IMETHOD ComparePoint(nsIDOMNode* aParent, PRInt32 aOffset,
|
||||
|
|
|
@ -48,7 +48,6 @@ interface NSRange {
|
|||
/* IID: { 0xa6cf90f2, 0x15b3, 0x11d2, \
|
||||
{ 0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32 } } */
|
||||
DocumentFragment createContextualFragment(in DOMString fragment);
|
||||
boolean isValidFragment(in DOMString fragment);
|
||||
|
||||
// Is the point contained in the range?
|
||||
boolean isPointInRange(in Node parent, in long offset);
|
||||
|
|
|
@ -834,7 +834,6 @@ enum nsDOMProp {
|
|||
NS_DOM_PROP_NSRANGE_CREATECONTEXTUALFRAGMENT,
|
||||
NS_DOM_PROP_NSRANGE_INTERSECTSNODE,
|
||||
NS_DOM_PROP_NSRANGE_ISPOINTINRANGE,
|
||||
NS_DOM_PROP_NSRANGE_ISVALIDFRAGMENT,
|
||||
NS_DOM_PROP_NSRANGE_NSDETACH,
|
||||
NS_DOM_PROP_NSUIEVENT_CANCELBUBBLE,
|
||||
NS_DOM_PROP_NSUIEVENT_GETPREVENTDEFAULT,
|
||||
|
|
|
@ -832,7 +832,6 @@
|
|||
"nsrange.createcontextualfragment", \
|
||||
"nsrange.intersectsnode", \
|
||||
"nsrange.ispointinrange", \
|
||||
"nsrange.isvalidfragment", \
|
||||
"nsrange.nsdetach", \
|
||||
"nsuievent.cancelbubble", \
|
||||
"nsuievent.getpreventdefault", \
|
||||
|
|
|
@ -47,8 +47,6 @@ public:
|
|||
|
||||
NS_IMETHOD CreateContextualFragment(const nsAReadableString& aFragment, nsIDOMDocumentFragment** aReturn)=0;
|
||||
|
||||
NS_IMETHOD IsValidFragment(const nsAReadableString& aFragment, PRBool* aReturn)=0;
|
||||
|
||||
NS_IMETHOD IsPointInRange(nsIDOMNode* aParent, PRInt32 aOffset, PRBool* aReturn)=0;
|
||||
|
||||
NS_IMETHOD ComparePoint(nsIDOMNode* aParent, PRInt32 aOffset, PRInt16* aReturn)=0;
|
||||
|
@ -63,7 +61,6 @@ public:
|
|||
|
||||
#define NS_DECL_IDOMNSRANGE \
|
||||
NS_IMETHOD CreateContextualFragment(const nsAReadableString& aFragment, nsIDOMDocumentFragment** aReturn); \
|
||||
NS_IMETHOD IsValidFragment(const nsAReadableString& aFragment, PRBool* aReturn); \
|
||||
NS_IMETHOD IsPointInRange(nsIDOMNode* aParent, PRInt32 aOffset, PRBool* aReturn); \
|
||||
NS_IMETHOD ComparePoint(nsIDOMNode* aParent, PRInt32 aOffset, PRInt16* aReturn); \
|
||||
NS_IMETHOD IntersectsNode(nsIDOMNode* aN, PRBool* aReturn); \
|
||||
|
@ -74,7 +71,6 @@ public:
|
|||
|
||||
#define NS_FORWARD_IDOMNSRANGE(_to) \
|
||||
NS_IMETHOD CreateContextualFragment(const nsAReadableString& aFragment, nsIDOMDocumentFragment** aReturn) { return _to CreateContextualFragment(aFragment, aReturn); } \
|
||||
NS_IMETHOD IsValidFragment(const nsAReadableString& aFragment, PRBool* aReturn) { return _to IsValidFragment(aFragment, aReturn); } \
|
||||
NS_IMETHOD IsPointInRange(nsIDOMNode* aParent, PRInt32 aOffset, PRBool* aReturn) { return _to IsPointInRange(aParent, aOffset, aReturn); } \
|
||||
NS_IMETHOD ComparePoint(nsIDOMNode* aParent, PRInt32 aOffset, PRInt16* aReturn) { return _to ComparePoint(aParent, aOffset, aReturn); } \
|
||||
NS_IMETHOD IntersectsNode(nsIDOMNode* aN, PRBool* aReturn) { return _to IntersectsNode(aN, aReturn); } \
|
||||
|
|
|
@ -1082,53 +1082,6 @@ NSRangeCreateContextualFragment(JSContext *cx, JSObject *obj, uintN argc, jsval
|
|||
}
|
||||
|
||||
|
||||
//
|
||||
// Native method IsValidFragment
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
NSRangeIsValidFragment(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
nsIDOMRange *privateThis = (nsIDOMRange*)nsJSUtils::nsGetNativeThis(cx, obj);
|
||||
nsCOMPtr<nsIDOMNSRange> nativeThis;
|
||||
nsresult result = NS_OK;
|
||||
if (NS_OK != privateThis->QueryInterface(kINSRangeIID, getter_AddRefs(nativeThis))) {
|
||||
return nsJSUtils::nsReportError(cx, obj, NS_ERROR_DOM_WRONG_TYPE_ERR);
|
||||
}
|
||||
|
||||
PRBool nativeRet;
|
||||
nsAutoString b0;
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
if (!nativeThis) {
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
{
|
||||
*rval = JSVAL_NULL;
|
||||
nsIScriptSecurityManager *secMan = nsJSUtils::nsGetSecurityManager(cx, obj);
|
||||
if (!secMan)
|
||||
return PR_FALSE;
|
||||
result = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_NSRANGE_ISVALIDFRAGMENT, PR_FALSE);
|
||||
if (NS_FAILED(result)) {
|
||||
return nsJSUtils::nsReportError(cx, obj, result);
|
||||
}
|
||||
if (argc < 1) {
|
||||
return nsJSUtils::nsReportError(cx, obj, NS_ERROR_DOM_TOO_FEW_PARAMETERS_ERR);
|
||||
}
|
||||
|
||||
nsJSUtils::nsConvertJSValToString(b0, cx, argv[0]);
|
||||
|
||||
result = nativeThis->IsValidFragment(b0, &nativeRet);
|
||||
if (NS_FAILED(result)) {
|
||||
return nsJSUtils::nsReportError(cx, obj, result);
|
||||
}
|
||||
|
||||
*rval = BOOLEAN_TO_JSVAL(nativeRet);
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Native method IsPointInRange
|
||||
//
|
||||
|
@ -1433,7 +1386,6 @@ static JSFunctionSpec RangeMethods[] =
|
|||
{"detach", RangeDetach, 0},
|
||||
{"toString", RangeToString, 0},
|
||||
{"createContextualFragment", NSRangeCreateContextualFragment, 1},
|
||||
{"isValidFragment", NSRangeIsValidFragment, 1},
|
||||
{"isPointInRange", NSRangeIsPointInRange, 2},
|
||||
{"comparePoint", NSRangeComparePoint, 2},
|
||||
{"intersectsNode", NSRangeIntersectsNode, 1},
|
||||
|
|
|
@ -6,7 +6,6 @@ nshtmlpars.h
|
|||
nsIContentSink.h
|
||||
nsIHTMLContentSink.h
|
||||
nsIHTMLFragmentContentSink.h
|
||||
nsHTMLContentSinkStream.h
|
||||
nsITokenizer.h
|
||||
nsHTMLTokens.h
|
||||
nsIParserNode.h
|
||||
|
|
|
@ -72,7 +72,6 @@ CPPSRCS = \
|
|||
nsScanner.cpp \
|
||||
nsToken.cpp \
|
||||
nsTokenHandler.cpp \
|
||||
nsHTMLContentSinkStream.cpp \
|
||||
nsValidDTD.cpp \
|
||||
nsWellFormedDTD.cpp \
|
||||
nsViewSourceHTML.cpp \
|
||||
|
@ -94,7 +93,6 @@ EXPORTS = \
|
|||
nsITokenizer.h \
|
||||
nsIExpatTokenizer.h \
|
||||
nsIHTMLContentSink.h \
|
||||
nsHTMLContentSinkStream.h \
|
||||
nsIHTMLFragmentContentSink.h \
|
||||
nsHTMLEntities.h \
|
||||
nsHTMLEntityList.h \
|
||||
|
|
|
@ -49,7 +49,6 @@ CPPSRCS= \
|
|||
nsScanner.cpp \
|
||||
nsToken.cpp \
|
||||
nsTokenHandler.cpp \
|
||||
nsHTMLContentSinkStream.cpp \
|
||||
nsValidDTD.cpp \
|
||||
nsWellFormedDTD.cpp \
|
||||
nsViewSourceHTML.cpp \
|
||||
|
@ -77,7 +76,6 @@ CPP_OBJS= \
|
|||
.\$(OBJDIR)\nsScanner.obj \
|
||||
.\$(OBJDIR)\nsToken.obj \
|
||||
.\$(OBJDIR)\nsTokenHandler.obj \
|
||||
.\$(OBJDIR)\nsHTMLContentSinkStream.obj \
|
||||
.\$(OBJDIR)\nsValidDTD.obj \
|
||||
.\$(OBJDIR)\nsWellFormedDTD.obj \
|
||||
.\$(OBJDIR)\nsViewSourceHTML.obj \
|
||||
|
@ -92,7 +90,6 @@ EXPORTS= \
|
|||
nsIContentSink.h \
|
||||
nsIHTMLContentSink.h \
|
||||
nsILoggingSink.h \
|
||||
nsHTMLContentSinkStream.h \
|
||||
nsIHTMLFragmentContentSink.h \
|
||||
nsHTMLEntities.h \
|
||||
nsHTMLEntityList.h \
|
||||
|
|
|
@ -240,7 +240,6 @@ class nsIParser : public nsISupports {
|
|||
|
||||
virtual nsresult Terminate(void) = 0;
|
||||
|
||||
virtual PRBool IsValidFragment(const nsAReadableString& aSourceBuffer,nsITagStack& aStack,PRUint32 anInsertPos,const nsString& aContentType,nsDTDMode aMode=eDTDMode_autodetect)=0;
|
||||
virtual nsresult ParseFragment(const nsAReadableString& aSourceBuffer,void* aKey,nsITagStack& aStack,PRUint32 anInsertPos,const nsString& aContentType,nsDTDMode aMode=eDTDMode_autodetect)=0;
|
||||
|
||||
/**
|
||||
|
|
|
@ -37,7 +37,6 @@
|
|||
#include "nshtmlpars.h"
|
||||
#include "nsWellFormedDTD.h"
|
||||
#include "nsViewSourceHTML.h"
|
||||
#include "nsHTMLContentSinkStream.h" //this is here so we can get a null sink, which really should be gotten from nsICOntentSink.h
|
||||
#include "nsIStringStream.h"
|
||||
#include "nsIChannel.h"
|
||||
#include "nsIProgressEventSink.h"
|
||||
|
@ -1736,62 +1735,6 @@ aMimeType,PRBool aVerifyEnabled,PRBool aLastCall,nsDTDMode aMode){
|
|||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Call this method to test whether a given fragment is valid within a given context-stack.
|
||||
* @update gess 04/01/99
|
||||
* @param aSourceBuffer contains the content blob you're trying to insert
|
||||
* @param aInsertPos tells us where in the context stack you're trying to do the insertion
|
||||
* @param aMimeType tells us what kind of stuff you're inserting
|
||||
* @return TRUE if valid, otherwise FALSE
|
||||
*/
|
||||
PRBool nsParser::IsValidFragment(const nsAReadableString& aSourceBuffer,nsITagStack& aStack,PRUint32 anInsertPos,const nsString& aMimeType,nsDTDMode aMode){
|
||||
|
||||
/************************************************************************************
|
||||
This method works like this:
|
||||
1. Convert aStack to a markup string
|
||||
2. Append a "sentinel" tag to markup string so we know where new content is inserted
|
||||
3. Append new context to markup stack
|
||||
4. Call the normal parse() methods for a string, using an HTMLContentSink.
|
||||
The output of this call is stored in an outputstring
|
||||
5. Scan the output string looking for markup inside our sentinel. If non-empty
|
||||
then we have to assume that the fragment is valid (at least in part)
|
||||
************************************************************************************/
|
||||
|
||||
nsAutoString theContext;
|
||||
PRUint32 theCount=aStack.GetSize();
|
||||
PRUint32 theIndex=0;
|
||||
while(theIndex++<theCount){
|
||||
theContext.AppendWithConversion("<");
|
||||
theContext.Append(aStack.TagAt(theCount-theIndex));
|
||||
theContext.AppendWithConversion(">");
|
||||
}
|
||||
theContext.AppendWithConversion("<endnote>"); //XXXHack! I'll make this better later.
|
||||
nsAutoString theBuffer(theContext);
|
||||
theBuffer.Append(aSourceBuffer);
|
||||
|
||||
PRBool result=PR_FALSE;
|
||||
if(theBuffer.Length()){
|
||||
//now it's time to try to build the model from this fragment
|
||||
|
||||
nsString theOutput;
|
||||
nsIHTMLContentSink* theSink=0;
|
||||
nsresult theResult=NS_New_HTML_ContentSinkStream(&theSink,&theOutput,0);
|
||||
SetContentSink(theSink);
|
||||
theResult=Parse(theBuffer,(void*)&theBuffer,aMimeType,PR_FALSE,PR_TRUE);
|
||||
theOutput.StripWhitespace();
|
||||
if(NS_OK==theResult){
|
||||
theOutput.Cut(0,theContext.Length());
|
||||
PRInt32 aPos=theOutput.RFind("</endnote>");
|
||||
if(-1<aPos)
|
||||
theOutput.Truncate(aPos);
|
||||
result=PRBool(0<theOutput.Length());
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @update gess 04/01/99
|
||||
|
|
|
@ -200,7 +200,6 @@ class nsParser : public nsIParser,
|
|||
*/
|
||||
virtual nsresult Parse(const nsAReadableString& aSourceBuffer,void* aKey,const nsString& aContentType,PRBool aEnableVerify=PR_FALSE,PRBool aLastCall=PR_FALSE,nsDTDMode aMode=eDTDMode_autodetect);
|
||||
|
||||
virtual PRBool IsValidFragment(const nsAReadableString& aSourceBuffer,nsITagStack& aStack,PRUint32 anInsertPos,const nsString& aContentType,nsDTDMode aMode=eDTDMode_autodetect);
|
||||
virtual nsresult ParseFragment(const nsAReadableString& aSourceBuffer,void* aKey,nsITagStack& aStack,PRUint32 anInsertPos,const nsString& aContentType,nsDTDMode aMode=eDTDMode_autodetect);
|
||||
|
||||
|
||||
|
|
|
@ -34,7 +34,6 @@
|
|||
#include "COtherDTD.h"
|
||||
#include "COtherDTD.h"
|
||||
#include "nsViewSourceHTML.h"
|
||||
#include "nsHTMLContentSinkStream.h"
|
||||
#include "nsHTMLEntities.h"
|
||||
#include "nsHTMLTokenizer.h"
|
||||
#include "nsXMLTokenizer.h"
|
||||
|
@ -156,7 +155,6 @@ static NS_DEFINE_CID(kNavDTDCID, NS_CNAVDTD_CID);
|
|||
static NS_DEFINE_CID(kCOtherDTDCID, NS_COTHER_DTD_CID);
|
||||
static NS_DEFINE_CID(kCTransitionalDTDCID, NS_CTRANSITIONAL_DTD_CID);
|
||||
static NS_DEFINE_CID(kViewSourceDTDCID, NS_VIEWSOURCE_DTD_CID);
|
||||
static NS_DEFINE_CID(kHTMLContentSinkStreamCID, NS_HTMLCONTENTSINKSTREAM_CID);
|
||||
static NS_DEFINE_CID(kParserServiceCID, NS_PARSERSERVICE_CID);
|
||||
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsParser)
|
||||
|
@ -166,7 +164,6 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(CNavDTD)
|
|||
NS_GENERIC_FACTORY_CONSTRUCTOR(COtherDTD)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(CTransitionalDTD)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(CViewSourceHTML)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsHTMLContentSinkStream)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsParserService)
|
||||
|
||||
static nsModuleComponentInfo gComponents[] = {
|
||||
|
@ -178,8 +175,6 @@ static nsModuleComponentInfo gComponents[] = {
|
|||
{ "Transitional DTD", NS_CTRANSITIONAL_DTD_CID, NULL,
|
||||
CTransitionalDTDConstructor },
|
||||
{ "ViewSource DTD", NS_VIEWSOURCE_DTD_CID, NULL, CViewSourceHTMLConstructor },
|
||||
{ "HTML Content Sink Stream", NS_HTMLCONTENTSINKSTREAM_CID, NULL,
|
||||
nsHTMLContentSinkStreamConstructor },
|
||||
{ "ParserService", NS_PARSERSERVICE_CID, NULL, nsParserServiceConstructor }
|
||||
};
|
||||
#define NUM_COMPONENTS (sizeof(gComponents) / sizeof(gComponents[0]))
|
||||
|
|
|
@ -6,7 +6,6 @@ nshtmlpars.h
|
|||
nsIContentSink.h
|
||||
nsIHTMLContentSink.h
|
||||
nsIHTMLFragmentContentSink.h
|
||||
nsHTMLContentSinkStream.h
|
||||
nsITokenizer.h
|
||||
nsHTMLTokens.h
|
||||
nsIParserNode.h
|
||||
|
|
|
@ -72,7 +72,6 @@ CPPSRCS = \
|
|||
nsScanner.cpp \
|
||||
nsToken.cpp \
|
||||
nsTokenHandler.cpp \
|
||||
nsHTMLContentSinkStream.cpp \
|
||||
nsValidDTD.cpp \
|
||||
nsWellFormedDTD.cpp \
|
||||
nsViewSourceHTML.cpp \
|
||||
|
@ -94,7 +93,6 @@ EXPORTS = \
|
|||
nsITokenizer.h \
|
||||
nsIExpatTokenizer.h \
|
||||
nsIHTMLContentSink.h \
|
||||
nsHTMLContentSinkStream.h \
|
||||
nsIHTMLFragmentContentSink.h \
|
||||
nsHTMLEntities.h \
|
||||
nsHTMLEntityList.h \
|
||||
|
|
|
@ -49,7 +49,6 @@ CPPSRCS= \
|
|||
nsScanner.cpp \
|
||||
nsToken.cpp \
|
||||
nsTokenHandler.cpp \
|
||||
nsHTMLContentSinkStream.cpp \
|
||||
nsValidDTD.cpp \
|
||||
nsWellFormedDTD.cpp \
|
||||
nsViewSourceHTML.cpp \
|
||||
|
@ -77,7 +76,6 @@ CPP_OBJS= \
|
|||
.\$(OBJDIR)\nsScanner.obj \
|
||||
.\$(OBJDIR)\nsToken.obj \
|
||||
.\$(OBJDIR)\nsTokenHandler.obj \
|
||||
.\$(OBJDIR)\nsHTMLContentSinkStream.obj \
|
||||
.\$(OBJDIR)\nsValidDTD.obj \
|
||||
.\$(OBJDIR)\nsWellFormedDTD.obj \
|
||||
.\$(OBJDIR)\nsViewSourceHTML.obj \
|
||||
|
@ -92,7 +90,6 @@ EXPORTS= \
|
|||
nsIContentSink.h \
|
||||
nsIHTMLContentSink.h \
|
||||
nsILoggingSink.h \
|
||||
nsHTMLContentSinkStream.h \
|
||||
nsIHTMLFragmentContentSink.h \
|
||||
nsHTMLEntities.h \
|
||||
nsHTMLEntityList.h \
|
||||
|
|
|
@ -240,7 +240,6 @@ class nsIParser : public nsISupports {
|
|||
|
||||
virtual nsresult Terminate(void) = 0;
|
||||
|
||||
virtual PRBool IsValidFragment(const nsAReadableString& aSourceBuffer,nsITagStack& aStack,PRUint32 anInsertPos,const nsString& aContentType,nsDTDMode aMode=eDTDMode_autodetect)=0;
|
||||
virtual nsresult ParseFragment(const nsAReadableString& aSourceBuffer,void* aKey,nsITagStack& aStack,PRUint32 anInsertPos,const nsString& aContentType,nsDTDMode aMode=eDTDMode_autodetect)=0;
|
||||
|
||||
/**
|
||||
|
|
|
@ -37,7 +37,6 @@
|
|||
#include "nshtmlpars.h"
|
||||
#include "nsWellFormedDTD.h"
|
||||
#include "nsViewSourceHTML.h"
|
||||
#include "nsHTMLContentSinkStream.h" //this is here so we can get a null sink, which really should be gotten from nsICOntentSink.h
|
||||
#include "nsIStringStream.h"
|
||||
#include "nsIChannel.h"
|
||||
#include "nsIProgressEventSink.h"
|
||||
|
@ -1736,62 +1735,6 @@ aMimeType,PRBool aVerifyEnabled,PRBool aLastCall,nsDTDMode aMode){
|
|||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Call this method to test whether a given fragment is valid within a given context-stack.
|
||||
* @update gess 04/01/99
|
||||
* @param aSourceBuffer contains the content blob you're trying to insert
|
||||
* @param aInsertPos tells us where in the context stack you're trying to do the insertion
|
||||
* @param aMimeType tells us what kind of stuff you're inserting
|
||||
* @return TRUE if valid, otherwise FALSE
|
||||
*/
|
||||
PRBool nsParser::IsValidFragment(const nsAReadableString& aSourceBuffer,nsITagStack& aStack,PRUint32 anInsertPos,const nsString& aMimeType,nsDTDMode aMode){
|
||||
|
||||
/************************************************************************************
|
||||
This method works like this:
|
||||
1. Convert aStack to a markup string
|
||||
2. Append a "sentinel" tag to markup string so we know where new content is inserted
|
||||
3. Append new context to markup stack
|
||||
4. Call the normal parse() methods for a string, using an HTMLContentSink.
|
||||
The output of this call is stored in an outputstring
|
||||
5. Scan the output string looking for markup inside our sentinel. If non-empty
|
||||
then we have to assume that the fragment is valid (at least in part)
|
||||
************************************************************************************/
|
||||
|
||||
nsAutoString theContext;
|
||||
PRUint32 theCount=aStack.GetSize();
|
||||
PRUint32 theIndex=0;
|
||||
while(theIndex++<theCount){
|
||||
theContext.AppendWithConversion("<");
|
||||
theContext.Append(aStack.TagAt(theCount-theIndex));
|
||||
theContext.AppendWithConversion(">");
|
||||
}
|
||||
theContext.AppendWithConversion("<endnote>"); //XXXHack! I'll make this better later.
|
||||
nsAutoString theBuffer(theContext);
|
||||
theBuffer.Append(aSourceBuffer);
|
||||
|
||||
PRBool result=PR_FALSE;
|
||||
if(theBuffer.Length()){
|
||||
//now it's time to try to build the model from this fragment
|
||||
|
||||
nsString theOutput;
|
||||
nsIHTMLContentSink* theSink=0;
|
||||
nsresult theResult=NS_New_HTML_ContentSinkStream(&theSink,&theOutput,0);
|
||||
SetContentSink(theSink);
|
||||
theResult=Parse(theBuffer,(void*)&theBuffer,aMimeType,PR_FALSE,PR_TRUE);
|
||||
theOutput.StripWhitespace();
|
||||
if(NS_OK==theResult){
|
||||
theOutput.Cut(0,theContext.Length());
|
||||
PRInt32 aPos=theOutput.RFind("</endnote>");
|
||||
if(-1<aPos)
|
||||
theOutput.Truncate(aPos);
|
||||
result=PRBool(0<theOutput.Length());
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @update gess 04/01/99
|
||||
|
|
|
@ -200,7 +200,6 @@ class nsParser : public nsIParser,
|
|||
*/
|
||||
virtual nsresult Parse(const nsAReadableString& aSourceBuffer,void* aKey,const nsString& aContentType,PRBool aEnableVerify=PR_FALSE,PRBool aLastCall=PR_FALSE,nsDTDMode aMode=eDTDMode_autodetect);
|
||||
|
||||
virtual PRBool IsValidFragment(const nsAReadableString& aSourceBuffer,nsITagStack& aStack,PRUint32 anInsertPos,const nsString& aContentType,nsDTDMode aMode=eDTDMode_autodetect);
|
||||
virtual nsresult ParseFragment(const nsAReadableString& aSourceBuffer,void* aKey,nsITagStack& aStack,PRUint32 anInsertPos,const nsString& aContentType,nsDTDMode aMode=eDTDMode_autodetect);
|
||||
|
||||
|
||||
|
|
|
@ -34,7 +34,6 @@
|
|||
#include "COtherDTD.h"
|
||||
#include "COtherDTD.h"
|
||||
#include "nsViewSourceHTML.h"
|
||||
#include "nsHTMLContentSinkStream.h"
|
||||
#include "nsHTMLEntities.h"
|
||||
#include "nsHTMLTokenizer.h"
|
||||
#include "nsXMLTokenizer.h"
|
||||
|
@ -156,7 +155,6 @@ static NS_DEFINE_CID(kNavDTDCID, NS_CNAVDTD_CID);
|
|||
static NS_DEFINE_CID(kCOtherDTDCID, NS_COTHER_DTD_CID);
|
||||
static NS_DEFINE_CID(kCTransitionalDTDCID, NS_CTRANSITIONAL_DTD_CID);
|
||||
static NS_DEFINE_CID(kViewSourceDTDCID, NS_VIEWSOURCE_DTD_CID);
|
||||
static NS_DEFINE_CID(kHTMLContentSinkStreamCID, NS_HTMLCONTENTSINKSTREAM_CID);
|
||||
static NS_DEFINE_CID(kParserServiceCID, NS_PARSERSERVICE_CID);
|
||||
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsParser)
|
||||
|
@ -166,7 +164,6 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(CNavDTD)
|
|||
NS_GENERIC_FACTORY_CONSTRUCTOR(COtherDTD)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(CTransitionalDTD)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(CViewSourceHTML)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsHTMLContentSinkStream)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsParserService)
|
||||
|
||||
static nsModuleComponentInfo gComponents[] = {
|
||||
|
@ -178,8 +175,6 @@ static nsModuleComponentInfo gComponents[] = {
|
|||
{ "Transitional DTD", NS_CTRANSITIONAL_DTD_CID, NULL,
|
||||
CTransitionalDTDConstructor },
|
||||
{ "ViewSource DTD", NS_VIEWSOURCE_DTD_CID, NULL, CViewSourceHTMLConstructor },
|
||||
{ "HTML Content Sink Stream", NS_HTMLCONTENTSINKSTREAM_CID, NULL,
|
||||
nsHTMLContentSinkStreamConstructor },
|
||||
{ "ParserService", NS_PARSERSERVICE_CID, NULL, nsParserServiceConstructor }
|
||||
};
|
||||
#define NUM_COMPONENTS (sizeof(gComponents) / sizeof(gComponents[0]))
|
||||
|
|
|
@ -1160,12 +1160,6 @@ nsLoggingSink_CID = { /* a6cf910d-15b3-11d2-932e-00805f8add32 */
|
|||
0x11d2,
|
||||
{0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32}
|
||||
};
|
||||
nsHTMLContentSinkStream_CID = { /* a6cf910f-15b3-11d2-932e-00805f8add32 */
|
||||
0xa6cf910f,
|
||||
0x15b3,
|
||||
0x11d2,
|
||||
{0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32}
|
||||
};
|
||||
nsIParserService = { /* a6cf9111-15b3-11d2-932e-00805f8add32 */
|
||||
0xa6cf9111,
|
||||
0x15b3,
|
||||
|
|
Загрузка…
Ссылка в новой задаче