diff --git a/mozilla/htmlparser/src/nsHTMLContentSinkStream.cpp b/mozilla/htmlparser/src/nsHTMLContentSinkStream.cpp index f3029bd40d3..aa0c66baa8e 100644 --- a/mozilla/htmlparser/src/nsHTMLContentSinkStream.cpp +++ b/mozilla/htmlparser/src/nsHTMLContentSinkStream.cpp @@ -590,15 +590,14 @@ nsHTMLContentSinkStream::OpenHTML(const nsIParserNode& aNode) { eHTMLTags tag = (eHTMLTags)aNode.GetNodeType(); if (tag == eHTMLTag_html) -#ifdef BUG_20246_IS_FIXED - AddStartTag(aNode); -#else /* BUG_20246_IS_FIXED */ { + // See bug 20246: the html tag doesn't have "html" in its text, + // so AddStartTag will do the wrong thing Write(kLessThan); - Write("html"); + nsAutoCString tagname (nsHTMLTags::GetStringValue(tag)); + Write(tagname); Write(kGreaterThan); } -#endif /* BUG_20246_IS_FIXED */ return NS_OK; } @@ -997,7 +996,8 @@ nsHTMLContentSinkStream::AddLeaf(const nsIParserNode& aNode){ EncodeToBuffer(entity); Write('&'); Write(mBuffer); - Write(';'); + // Don't write the semicolon; + // rely on the DTD to include it if one is wanted. mColPos += entity.Length() + 2; } else if (type == eHTMLTag_text) diff --git a/mozilla/htmlparser/src/nsXIFDTD.cpp b/mozilla/htmlparser/src/nsXIFDTD.cpp index df2fcf56c72..10222cf66cc 100644 --- a/mozilla/htmlparser/src/nsXIFDTD.cpp +++ b/mozilla/htmlparser/src/nsXIFDTD.cpp @@ -226,90 +226,6 @@ NS_IMPL_RELEASE(nsXIFDTD) -/** - * - * - * @update gpk 06/18/98 - * @param - * @return - */ -static -PRInt32 XIFDispatchTokenHandler(CToken* aToken,nsIDTD* aDTD) -{ - eHTMLTokenTypes theType = (eHTMLTokenTypes)aToken->GetTokenType(); - nsXIFDTD* theDTD=(nsXIFDTD*)aDTD; - - nsString& name = aToken->GetStringValueXXX(); - eXIFTags type = eXIFTag_userdefined; - - if((eToken_start==theType) || (eToken_end==theType)) { - type=DetermineXIFTagType(name); - if (type != eXIFTag_userdefined) - aToken->SetTypeID(type); - } - - PRInt32 result=0; - - if(aDTD) { - switch(theType) { - case eToken_start: - result=theDTD->HandleStartToken(aToken); break; - case eToken_end: - result=theDTD->HandleEndToken(aToken); break; - case eToken_comment: - result=theDTD->HandleCommentToken(aToken); break; - case eToken_entity: - result=theDTD->HandleEntityToken(aToken); break; - case eToken_whitespace: - result=theDTD->HandleWhiteSpaceToken(aToken); break; - case eToken_newline: - result=theDTD->HandleWhiteSpaceToken(aToken); break; - case eToken_text: - result=theDTD->HandleTextToken(aToken); break; - case eToken_attribute: - result=theDTD->HandleAttributeToken(aToken); break; - default: - result=0; - }//switch - }//if - return result; -} - -/** - * init the set of default token handlers... - * - * @update gpk 06/18/98 - * @param - * @return - */ -void nsXIFDTD::InitializeDefaultTokenHandlers() { - AddTokenHandler(new CTokenHandler(XIFDispatchTokenHandler,eToken_start)); - - AddTokenHandler(new CTokenHandler(XIFDispatchTokenHandler,eToken_end)); - AddTokenHandler(new CTokenHandler(XIFDispatchTokenHandler,eToken_comment)); - AddTokenHandler(new CTokenHandler(XIFDispatchTokenHandler,eToken_entity)); - - AddTokenHandler(new CTokenHandler(XIFDispatchTokenHandler,eToken_whitespace)); - AddTokenHandler(new CTokenHandler(XIFDispatchTokenHandler,eToken_newline)); - AddTokenHandler(new CTokenHandler(XIFDispatchTokenHandler,eToken_text)); - - AddTokenHandler(new CTokenHandler(XIFDispatchTokenHandler,eToken_attribute)); -// AddTokenHandler(new CTokenHandler(XIFDispatchTokenHandler,eToken_script)); - AddTokenHandler(new CTokenHandler(XIFDispatchTokenHandler,eToken_style)); - AddTokenHandler(new CTokenHandler(XIFDispatchTokenHandler,eToken_skippedcontent)); -} - -class nsXIfTokenDeallocator: public nsDequeFunctor{ -public: - virtual void* operator()(void* anObject) { - CToken* aToken = (CToken*)anObject; - delete aToken; - return 0; - } -}; - - - /** * Default constructor * @@ -322,7 +238,6 @@ nsXIFDTD::nsXIFDTD() : nsIDTD(){ mParser=0; mTokenizer=0; nsCRT::zero(mContextStack,sizeof(mContextStack)); - nsCRT::zero(mTokenHandlers,sizeof(mTokenHandlers)); mHTMLStackPos = 0; memset(mHTMLTagStack,0,sizeof(mHTMLTagStack)); @@ -330,7 +245,6 @@ nsXIFDTD::nsXIFDTD() : nsIDTD(){ mHasOpenForm=PR_FALSE; mHasOpenMap=PR_FALSE; - InitializeDefaultTokenHandlers(); mContextStackPos=0; mContextStack[mContextStackPos++]=eXIFTag_unknown; mDTDDebug=nsnull; @@ -349,7 +263,6 @@ nsXIFDTD::nsXIFDTD() : nsIDTD(){ * @return */ nsXIFDTD::~nsXIFDTD(){ - DeleteTokenHandlers(); NS_IF_RELEASE(mSink); } @@ -525,12 +438,35 @@ nsresult nsXIFDTD::HandleToken(CToken* aToken,nsIParser* aParser) { if(aToken) { CHTMLToken* theToken= (CHTMLToken*)(aToken); eHTMLTokenTypes theType=eHTMLTokenTypes(theToken->GetTokenType()); - CTokenHandler* aHandler=GetTokenHandler(theType); + + eXIFTags type = eXIFTag_userdefined; - if(aHandler) { - result=(*aHandler)(theToken,this); + if((eToken_start==theType) || (eToken_end==theType)) { + nsString& name = aToken->GetStringValueXXX(); + type=DetermineXIFTagType(name); + if (type != eXIFTag_userdefined) + aToken->SetTypeID(type); } + switch(theType) { + case eToken_start: + result=HandleStartToken(aToken); break; + case eToken_end: + result=HandleEndToken(aToken); break; + case eToken_comment: + result=HandleCommentToken(aToken); break; + case eToken_whitespace: + result=HandleWhiteSpaceToken(aToken); break; + case eToken_newline: + result=HandleWhiteSpaceToken(aToken); break; + case eToken_text: + result=HandleTextToken(aToken); break; + case eToken_attribute: + result=HandleAttributeToken(aToken); break; + default: + result=NS_OK; + }//switch + }//if return result; } @@ -781,28 +717,6 @@ nsresult nsXIFDTD::HandleEndToken(CToken* aToken) { return result; } -/** - * This method gets called when an entity token has been - * encountered in the parse process. - * - * @update gpk 06/18/98 - * @param aToken -- next (start) token to be handled - * @return PR_TRUE if all went well; PR_FALSE if error occured - */ -nsresult nsXIFDTD::HandleEntityToken(CToken* aToken) { - NS_PRECONDITION(0!=aToken,kNullToken); - - CEntityToken* et = (CEntityToken*)(aToken); - nsresult result=NS_OK; - eXIFTags tokenTagType=(eXIFTags)et->GetTypeID(); - - if(PR_FALSE==CanOmit(GetTopNode(),tokenTagType)) { - nsCParserNode aNode((CHTMLToken*)aToken); - result=AddLeaf(aNode); - } - return result; -} - /** * This method gets called when a comment token has been * encountered in the parse process. After making sure @@ -839,63 +753,6 @@ nsresult nsXIFDTD::HandleAttributeToken(CToken* aToken) { -/** - * Finds a tag handler for the given tag type, given in string. - * - * @update gpk 06/18/98 - * @param aString contains name of tag to be handled - * @return valid tag handler (if found) or null - */ -void nsXIFDTD::DeleteTokenHandlers(void) { - int i=0; - for(i=eToken_unknown;i0) && (aTypeGetTokenType(); - if(type=0;i--){ - if(mContextStack[i]==aTag) - return i; - } - return kNotFound; -} - - - /** * Begin Support for converting from XIF to HTML * @@ -1523,24 +1216,6 @@ nsresult nsXIFDTD::AddLeaf(const nsIParserNode& aNode) return result; } -/** - * This method gets called to create a valid context stack - * for the given child. We compare the current stack to the - * default needs of the child, and push new guys onto the - * stack until the child can be properly placed. - * - * @update gpk 06/18/98 - * @param aChildTag is the child for whom we need to - * create a new context vector - * @return true if we succeeded, otherwise false - */ -nsresult nsXIFDTD::CreateContextStackFor(eXIFTags aChildTag) -{ - mContextStack[++mContextStackPos] = aChildTag; - return NS_OK; -} - - /** * * @update gess12/28/98 @@ -1772,10 +1447,10 @@ void nsXIFDTD::ProcessEncodeTag(const nsIParserNode& aNode) void nsXIFDTD::ProcessEntityTag(const nsIParserNode& aNode) { - nsString value; + nsAutoString value; - if (GetAttribute(aNode,nsString("value"),value)) - { + if (GetAttribute(aNode,nsString("value"),value)) { + value+=';'; CEntityToken* entity = new CEntityToken(value); nsCParserNode node((CToken*)entity); mSink->AddLeaf(node); diff --git a/mozilla/htmlparser/src/nsXIFDTD.h b/mozilla/htmlparser/src/nsXIFDTD.h index 2eb7b655988..62a65b98e8d 100644 --- a/mozilla/htmlparser/src/nsXIFDTD.h +++ b/mozilla/htmlparser/src/nsXIFDTD.h @@ -290,49 +290,17 @@ class nsXIFDTD : public nsIDTD { */ virtual void SetVerification(PRBool aEnable); - /** - * This method gets called to determine whether a given - * tag can contain newlines. Most do not. - * - * @update gpk 06/18/98 - * @param aTag -- tag to test for containership - * @return PR_TRUE if given tag can contain other tags - */ - virtual PRBool CanOmit(eXIFTags aParent,eXIFTags aChild)const; - - /** - * This method gets called to determine whether a given - * tag can contain newlines. Most do not. - * - * @update gpk 06/18/98 - * @param aParent -- tag type of parent - * @param aChild -- tag type of child - * @return PR_TRUE if given tag can contain other tags - */ - virtual PRBool CanOmitEndTag(eXIFTags aParent,eXIFTags aChild)const; /** * This method gets called to determine whether a given * tag is itself a container * - * @update gpk 06/18/98 + * @update gess 12/1/99 * @param aTag -- tag to test for containership * @return PR_TRUE if given tag can contain other tags */ - virtual PRBool IsXIFContainer(eXIFTags aTag) const; virtual PRBool IsHTMLContainer(eHTMLTags aTag) const; - /** - * This method does two things: 1st, help construct - * our own internal model of the content-stack; and - * 2nd, pass this message on to the sink. - * @update gpk 06/18/98 - * @param aNode -- next node to be added to model - * @return TRUE if ok, FALSE if error - */ - virtual eXIFTags GetDefaultParentTagFor(eXIFTags aTag) const; - - /** * This method gets called at various times by the parser * whenever we want to verify a valid context stack. This @@ -345,47 +313,6 @@ class nsXIFDTD : public nsIDTD { */ virtual PRBool VerifyContextVector(void) const; - - /** - * - * @update gpk 06/18/98 - * @param - * @return - */ - virtual nsresult DidOpenContainer(eXIFTags aTag,PRBool anExplicitOpen); - - /** - * Ask parser if a given container is open ANYWHERE on stack - * @update gpk 06/18/98 - * @param id of container you want to test for - * @return TRUE if the given container type is open -- otherwise FALSE - */ - virtual PRBool HasOpenContainer(eXIFTags aContainer) const; - - - /** - * Retrieve the tag type of the topmost item on context vector stack - * @update gpk 06/18/98 - * @return tag type (may be unknown) - */ - virtual eXIFTags GetTopNode() const; - - /** - * Finds the topmost occurance of given tag within context vector stack. - * @update gpk 06/18/98 - * @param tag to be found - * @return index of topmost tag occurance -- may be -1 (kNotFound). - */ - virtual PRInt32 GetTopmostIndexOf(eXIFTags aTag) const; - - /** - * - * @update gpk 06/18/98 - * @param - * @return - */ - virtual nsresult DidCloseContainer(eXIFTags aTag,PRBool anExplicitClosure); - /** * This method gets called when a start token has been consumed and needs * to be handled (possibly added to content model via sink). @@ -489,15 +416,6 @@ private: */ nsresult AddLeaf(const nsIParserNode& aNode); - /** - * Attempt forward and/or backward propagation for the given - * child within the current context vector stack. - * @update gpk 06/18/98 - * @param type of child to be propagated. - * @return TRUE if succeeds, otherwise FALSE - */ - nsresult CreateContextStackFor(eXIFTags aChildTag); - /** * * @update gess12/28/98 @@ -560,8 +478,6 @@ protected: nsParser* mParser; nsIHTMLContentSink* mSink; - CTokenHandler* mTokenHandlers[eToken_last]; - PRBool mLeafBits[100]; eXIFTags mContextStack[100]; PRInt32 mContextStackPos; diff --git a/mozilla/htmlparser/tests/outsinks/TestOutSinks b/mozilla/htmlparser/tests/outsinks/TestOutSinks index 6887f90ef08..de72adb0e6d 100755 --- a/mozilla/htmlparser/tests/outsinks/TestOutSinks +++ b/mozilla/htmlparser/tests/outsinks/TestOutSinks @@ -55,7 +55,7 @@ if ($status != 0) then set errmsg = ($errmsg "plainnowrap.out") endif -echo "Testing wrapped but unformatted plaintext ..." +echo "Testing wrapped and formatted plaintext ..." TestOutput -i text/html -o text/plain -f 32 -w 50 -c OutTestData/plainwrap.out OutTestData/plain.html if ($status != 0) then echo "Wrapped plaintext test failed." @@ -84,7 +84,7 @@ if ($status != 0) then endif echo "Testing HTML Table to Text ..." -TestOutput -i text/html -o text/plain -c OutTestData/htmltable.out OutTestData/htmltable.html +TestOutput -i text/html -o text/plain -f 2 -c OutTestData/htmltable.out OutTestData/htmltable.html if ($status != 0) then echo "HTML Table to Plain text failed." set errmsg = ($errmsg "htmltable.out") diff --git a/mozilla/htmlparser/tests/outsinks/htmltable.out b/mozilla/htmlparser/tests/outsinks/htmltable.out index 7d17268018c..0f758545c9c 100644 --- a/mozilla/htmlparser/tests/outsinks/htmltable.out +++ b/mozilla/htmlparser/tests/outsinks/htmltable.out @@ -2,4 +2,5 @@ Below is a table. Row 1 Col 1 Row 1 Col 2 Row 1 Col 3 Row 2 Col 1 Row 2 Col 2 Row 2 Col 3 Row 3 Col 1 Row 3 Col 2 Row 3 Col 3 + Here is after table. diff --git a/mozilla/parser/htmlparser/src/nsHTMLContentSinkStream.cpp b/mozilla/parser/htmlparser/src/nsHTMLContentSinkStream.cpp index f3029bd40d3..aa0c66baa8e 100644 --- a/mozilla/parser/htmlparser/src/nsHTMLContentSinkStream.cpp +++ b/mozilla/parser/htmlparser/src/nsHTMLContentSinkStream.cpp @@ -590,15 +590,14 @@ nsHTMLContentSinkStream::OpenHTML(const nsIParserNode& aNode) { eHTMLTags tag = (eHTMLTags)aNode.GetNodeType(); if (tag == eHTMLTag_html) -#ifdef BUG_20246_IS_FIXED - AddStartTag(aNode); -#else /* BUG_20246_IS_FIXED */ { + // See bug 20246: the html tag doesn't have "html" in its text, + // so AddStartTag will do the wrong thing Write(kLessThan); - Write("html"); + nsAutoCString tagname (nsHTMLTags::GetStringValue(tag)); + Write(tagname); Write(kGreaterThan); } -#endif /* BUG_20246_IS_FIXED */ return NS_OK; } @@ -997,7 +996,8 @@ nsHTMLContentSinkStream::AddLeaf(const nsIParserNode& aNode){ EncodeToBuffer(entity); Write('&'); Write(mBuffer); - Write(';'); + // Don't write the semicolon; + // rely on the DTD to include it if one is wanted. mColPos += entity.Length() + 2; } else if (type == eHTMLTag_text) diff --git a/mozilla/parser/htmlparser/src/nsXIFDTD.cpp b/mozilla/parser/htmlparser/src/nsXIFDTD.cpp index df2fcf56c72..10222cf66cc 100644 --- a/mozilla/parser/htmlparser/src/nsXIFDTD.cpp +++ b/mozilla/parser/htmlparser/src/nsXIFDTD.cpp @@ -226,90 +226,6 @@ NS_IMPL_RELEASE(nsXIFDTD) -/** - * - * - * @update gpk 06/18/98 - * @param - * @return - */ -static -PRInt32 XIFDispatchTokenHandler(CToken* aToken,nsIDTD* aDTD) -{ - eHTMLTokenTypes theType = (eHTMLTokenTypes)aToken->GetTokenType(); - nsXIFDTD* theDTD=(nsXIFDTD*)aDTD; - - nsString& name = aToken->GetStringValueXXX(); - eXIFTags type = eXIFTag_userdefined; - - if((eToken_start==theType) || (eToken_end==theType)) { - type=DetermineXIFTagType(name); - if (type != eXIFTag_userdefined) - aToken->SetTypeID(type); - } - - PRInt32 result=0; - - if(aDTD) { - switch(theType) { - case eToken_start: - result=theDTD->HandleStartToken(aToken); break; - case eToken_end: - result=theDTD->HandleEndToken(aToken); break; - case eToken_comment: - result=theDTD->HandleCommentToken(aToken); break; - case eToken_entity: - result=theDTD->HandleEntityToken(aToken); break; - case eToken_whitespace: - result=theDTD->HandleWhiteSpaceToken(aToken); break; - case eToken_newline: - result=theDTD->HandleWhiteSpaceToken(aToken); break; - case eToken_text: - result=theDTD->HandleTextToken(aToken); break; - case eToken_attribute: - result=theDTD->HandleAttributeToken(aToken); break; - default: - result=0; - }//switch - }//if - return result; -} - -/** - * init the set of default token handlers... - * - * @update gpk 06/18/98 - * @param - * @return - */ -void nsXIFDTD::InitializeDefaultTokenHandlers() { - AddTokenHandler(new CTokenHandler(XIFDispatchTokenHandler,eToken_start)); - - AddTokenHandler(new CTokenHandler(XIFDispatchTokenHandler,eToken_end)); - AddTokenHandler(new CTokenHandler(XIFDispatchTokenHandler,eToken_comment)); - AddTokenHandler(new CTokenHandler(XIFDispatchTokenHandler,eToken_entity)); - - AddTokenHandler(new CTokenHandler(XIFDispatchTokenHandler,eToken_whitespace)); - AddTokenHandler(new CTokenHandler(XIFDispatchTokenHandler,eToken_newline)); - AddTokenHandler(new CTokenHandler(XIFDispatchTokenHandler,eToken_text)); - - AddTokenHandler(new CTokenHandler(XIFDispatchTokenHandler,eToken_attribute)); -// AddTokenHandler(new CTokenHandler(XIFDispatchTokenHandler,eToken_script)); - AddTokenHandler(new CTokenHandler(XIFDispatchTokenHandler,eToken_style)); - AddTokenHandler(new CTokenHandler(XIFDispatchTokenHandler,eToken_skippedcontent)); -} - -class nsXIfTokenDeallocator: public nsDequeFunctor{ -public: - virtual void* operator()(void* anObject) { - CToken* aToken = (CToken*)anObject; - delete aToken; - return 0; - } -}; - - - /** * Default constructor * @@ -322,7 +238,6 @@ nsXIFDTD::nsXIFDTD() : nsIDTD(){ mParser=0; mTokenizer=0; nsCRT::zero(mContextStack,sizeof(mContextStack)); - nsCRT::zero(mTokenHandlers,sizeof(mTokenHandlers)); mHTMLStackPos = 0; memset(mHTMLTagStack,0,sizeof(mHTMLTagStack)); @@ -330,7 +245,6 @@ nsXIFDTD::nsXIFDTD() : nsIDTD(){ mHasOpenForm=PR_FALSE; mHasOpenMap=PR_FALSE; - InitializeDefaultTokenHandlers(); mContextStackPos=0; mContextStack[mContextStackPos++]=eXIFTag_unknown; mDTDDebug=nsnull; @@ -349,7 +263,6 @@ nsXIFDTD::nsXIFDTD() : nsIDTD(){ * @return */ nsXIFDTD::~nsXIFDTD(){ - DeleteTokenHandlers(); NS_IF_RELEASE(mSink); } @@ -525,12 +438,35 @@ nsresult nsXIFDTD::HandleToken(CToken* aToken,nsIParser* aParser) { if(aToken) { CHTMLToken* theToken= (CHTMLToken*)(aToken); eHTMLTokenTypes theType=eHTMLTokenTypes(theToken->GetTokenType()); - CTokenHandler* aHandler=GetTokenHandler(theType); + + eXIFTags type = eXIFTag_userdefined; - if(aHandler) { - result=(*aHandler)(theToken,this); + if((eToken_start==theType) || (eToken_end==theType)) { + nsString& name = aToken->GetStringValueXXX(); + type=DetermineXIFTagType(name); + if (type != eXIFTag_userdefined) + aToken->SetTypeID(type); } + switch(theType) { + case eToken_start: + result=HandleStartToken(aToken); break; + case eToken_end: + result=HandleEndToken(aToken); break; + case eToken_comment: + result=HandleCommentToken(aToken); break; + case eToken_whitespace: + result=HandleWhiteSpaceToken(aToken); break; + case eToken_newline: + result=HandleWhiteSpaceToken(aToken); break; + case eToken_text: + result=HandleTextToken(aToken); break; + case eToken_attribute: + result=HandleAttributeToken(aToken); break; + default: + result=NS_OK; + }//switch + }//if return result; } @@ -781,28 +717,6 @@ nsresult nsXIFDTD::HandleEndToken(CToken* aToken) { return result; } -/** - * This method gets called when an entity token has been - * encountered in the parse process. - * - * @update gpk 06/18/98 - * @param aToken -- next (start) token to be handled - * @return PR_TRUE if all went well; PR_FALSE if error occured - */ -nsresult nsXIFDTD::HandleEntityToken(CToken* aToken) { - NS_PRECONDITION(0!=aToken,kNullToken); - - CEntityToken* et = (CEntityToken*)(aToken); - nsresult result=NS_OK; - eXIFTags tokenTagType=(eXIFTags)et->GetTypeID(); - - if(PR_FALSE==CanOmit(GetTopNode(),tokenTagType)) { - nsCParserNode aNode((CHTMLToken*)aToken); - result=AddLeaf(aNode); - } - return result; -} - /** * This method gets called when a comment token has been * encountered in the parse process. After making sure @@ -839,63 +753,6 @@ nsresult nsXIFDTD::HandleAttributeToken(CToken* aToken) { -/** - * Finds a tag handler for the given tag type, given in string. - * - * @update gpk 06/18/98 - * @param aString contains name of tag to be handled - * @return valid tag handler (if found) or null - */ -void nsXIFDTD::DeleteTokenHandlers(void) { - int i=0; - for(i=eToken_unknown;i0) && (aTypeGetTokenType(); - if(type=0;i--){ - if(mContextStack[i]==aTag) - return i; - } - return kNotFound; -} - - - /** * Begin Support for converting from XIF to HTML * @@ -1523,24 +1216,6 @@ nsresult nsXIFDTD::AddLeaf(const nsIParserNode& aNode) return result; } -/** - * This method gets called to create a valid context stack - * for the given child. We compare the current stack to the - * default needs of the child, and push new guys onto the - * stack until the child can be properly placed. - * - * @update gpk 06/18/98 - * @param aChildTag is the child for whom we need to - * create a new context vector - * @return true if we succeeded, otherwise false - */ -nsresult nsXIFDTD::CreateContextStackFor(eXIFTags aChildTag) -{ - mContextStack[++mContextStackPos] = aChildTag; - return NS_OK; -} - - /** * * @update gess12/28/98 @@ -1772,10 +1447,10 @@ void nsXIFDTD::ProcessEncodeTag(const nsIParserNode& aNode) void nsXIFDTD::ProcessEntityTag(const nsIParserNode& aNode) { - nsString value; + nsAutoString value; - if (GetAttribute(aNode,nsString("value"),value)) - { + if (GetAttribute(aNode,nsString("value"),value)) { + value+=';'; CEntityToken* entity = new CEntityToken(value); nsCParserNode node((CToken*)entity); mSink->AddLeaf(node); diff --git a/mozilla/parser/htmlparser/src/nsXIFDTD.h b/mozilla/parser/htmlparser/src/nsXIFDTD.h index 2eb7b655988..62a65b98e8d 100644 --- a/mozilla/parser/htmlparser/src/nsXIFDTD.h +++ b/mozilla/parser/htmlparser/src/nsXIFDTD.h @@ -290,49 +290,17 @@ class nsXIFDTD : public nsIDTD { */ virtual void SetVerification(PRBool aEnable); - /** - * This method gets called to determine whether a given - * tag can contain newlines. Most do not. - * - * @update gpk 06/18/98 - * @param aTag -- tag to test for containership - * @return PR_TRUE if given tag can contain other tags - */ - virtual PRBool CanOmit(eXIFTags aParent,eXIFTags aChild)const; - - /** - * This method gets called to determine whether a given - * tag can contain newlines. Most do not. - * - * @update gpk 06/18/98 - * @param aParent -- tag type of parent - * @param aChild -- tag type of child - * @return PR_TRUE if given tag can contain other tags - */ - virtual PRBool CanOmitEndTag(eXIFTags aParent,eXIFTags aChild)const; /** * This method gets called to determine whether a given * tag is itself a container * - * @update gpk 06/18/98 + * @update gess 12/1/99 * @param aTag -- tag to test for containership * @return PR_TRUE if given tag can contain other tags */ - virtual PRBool IsXIFContainer(eXIFTags aTag) const; virtual PRBool IsHTMLContainer(eHTMLTags aTag) const; - /** - * This method does two things: 1st, help construct - * our own internal model of the content-stack; and - * 2nd, pass this message on to the sink. - * @update gpk 06/18/98 - * @param aNode -- next node to be added to model - * @return TRUE if ok, FALSE if error - */ - virtual eXIFTags GetDefaultParentTagFor(eXIFTags aTag) const; - - /** * This method gets called at various times by the parser * whenever we want to verify a valid context stack. This @@ -345,47 +313,6 @@ class nsXIFDTD : public nsIDTD { */ virtual PRBool VerifyContextVector(void) const; - - /** - * - * @update gpk 06/18/98 - * @param - * @return - */ - virtual nsresult DidOpenContainer(eXIFTags aTag,PRBool anExplicitOpen); - - /** - * Ask parser if a given container is open ANYWHERE on stack - * @update gpk 06/18/98 - * @param id of container you want to test for - * @return TRUE if the given container type is open -- otherwise FALSE - */ - virtual PRBool HasOpenContainer(eXIFTags aContainer) const; - - - /** - * Retrieve the tag type of the topmost item on context vector stack - * @update gpk 06/18/98 - * @return tag type (may be unknown) - */ - virtual eXIFTags GetTopNode() const; - - /** - * Finds the topmost occurance of given tag within context vector stack. - * @update gpk 06/18/98 - * @param tag to be found - * @return index of topmost tag occurance -- may be -1 (kNotFound). - */ - virtual PRInt32 GetTopmostIndexOf(eXIFTags aTag) const; - - /** - * - * @update gpk 06/18/98 - * @param - * @return - */ - virtual nsresult DidCloseContainer(eXIFTags aTag,PRBool anExplicitClosure); - /** * This method gets called when a start token has been consumed and needs * to be handled (possibly added to content model via sink). @@ -489,15 +416,6 @@ private: */ nsresult AddLeaf(const nsIParserNode& aNode); - /** - * Attempt forward and/or backward propagation for the given - * child within the current context vector stack. - * @update gpk 06/18/98 - * @param type of child to be propagated. - * @return TRUE if succeeds, otherwise FALSE - */ - nsresult CreateContextStackFor(eXIFTags aChildTag); - /** * * @update gess12/28/98 @@ -560,8 +478,6 @@ protected: nsParser* mParser; nsIHTMLContentSink* mSink; - CTokenHandler* mTokenHandlers[eToken_last]; - PRBool mLeafBits[100]; eXIFTags mContextStack[100]; PRInt32 mContextStackPos; diff --git a/mozilla/parser/htmlparser/tests/outsinks/TestOutSinks b/mozilla/parser/htmlparser/tests/outsinks/TestOutSinks index 6887f90ef08..de72adb0e6d 100755 --- a/mozilla/parser/htmlparser/tests/outsinks/TestOutSinks +++ b/mozilla/parser/htmlparser/tests/outsinks/TestOutSinks @@ -55,7 +55,7 @@ if ($status != 0) then set errmsg = ($errmsg "plainnowrap.out") endif -echo "Testing wrapped but unformatted plaintext ..." +echo "Testing wrapped and formatted plaintext ..." TestOutput -i text/html -o text/plain -f 32 -w 50 -c OutTestData/plainwrap.out OutTestData/plain.html if ($status != 0) then echo "Wrapped plaintext test failed." @@ -84,7 +84,7 @@ if ($status != 0) then endif echo "Testing HTML Table to Text ..." -TestOutput -i text/html -o text/plain -c OutTestData/htmltable.out OutTestData/htmltable.html +TestOutput -i text/html -o text/plain -f 2 -c OutTestData/htmltable.out OutTestData/htmltable.html if ($status != 0) then echo "HTML Table to Plain text failed." set errmsg = ($errmsg "htmltable.out") diff --git a/mozilla/parser/htmlparser/tests/outsinks/htmltable.out b/mozilla/parser/htmlparser/tests/outsinks/htmltable.out index 7d17268018c..0f758545c9c 100644 --- a/mozilla/parser/htmlparser/tests/outsinks/htmltable.out +++ b/mozilla/parser/htmlparser/tests/outsinks/htmltable.out @@ -2,4 +2,5 @@ Below is a table. Row 1 Col 1 Row 1 Col 2 Row 1 Col 3 Row 2 Col 1 Row 2 Col 2 Row 2 Col 3 Row 3 Col 1 Row 3 Col 2 Row 3 Col 3 + Here is after table.