From ad0c3c42b0ea9a429a8e2c72e4c5e8a488cebbda Mon Sep 17 00:00:00 2001 From: "mrbkap%gmail.com" Date: Thu, 16 Jun 2005 18:20:59 +0000 Subject: [PATCH] bug 296284:
can cause the plaintext serializer to delete extra newlines before inlines after blocks. r=peterv sr=jst a=asa git-svn-id: svn://10.0.0.236/trunk@174711 18797224-902f-48f8-a5cc-f745e15eee43 --- .../base/src/nsPlainTextSerializer.cpp | 9 ++++ .../htmlparser/tests/outsinks/Makefile.in | 2 + .../htmlparser/tests/outsinks/TestOutSinks.pl | 7 +++ .../htmlparser/tests/outsinks/mischtml.html | 50 +++++++++++++++++++ .../htmlparser/tests/outsinks/mischtml.out | 11 ++++ 5 files changed, 79 insertions(+) create mode 100644 mozilla/parser/htmlparser/tests/outsinks/mischtml.html create mode 100644 mozilla/parser/htmlparser/tests/outsinks/mischtml.out diff --git a/mozilla/content/base/src/nsPlainTextSerializer.cpp b/mozilla/content/base/src/nsPlainTextSerializer.cpp index fa8ca88aca1..6c0f5c2690e 100644 --- a/mozilla/content/base/src/nsPlainTextSerializer.cpp +++ b/mozilla/content/base/src/nsPlainTextSerializer.cpp @@ -635,6 +635,10 @@ nsPlainTextSerializer::DoOpenContainer(const nsIParserNode* aNode, PRInt32 aTag) return NS_OK; } + // Reset this so that
doesn't affect the whitespace + // above random
s below it.
+  mHasWrittenCiteBlockquote = mHasWrittenCiteBlockquote && aTag == eHTMLTag_pre;
+
   PRBool isInCiteBlockquote = PR_FALSE;
 
   // XXX special-case 
so that we don't add additional @@ -1121,6 +1125,11 @@ nsPlainTextSerializer::DoAddLeaf(const nsIParserNode *aNode, PRInt32 aTag, if (!DoOutput()) { return NS_OK; } + + if (aTag != eHTMLTag_whitespace && aTag != eHTMLTag_newline) { + // Make sure to reset this, since it's no longer true. + mHasWrittenCiteBlockquote = PR_FALSE; + } if (mLineBreakDue) EnsureVerticalSpace(mFloatingLines); diff --git a/mozilla/parser/htmlparser/tests/outsinks/Makefile.in b/mozilla/parser/htmlparser/tests/outsinks/Makefile.in index 61fa5c2f800..79cea11ea7a 100644 --- a/mozilla/parser/htmlparser/tests/outsinks/Makefile.in +++ b/mozilla/parser/htmlparser/tests/outsinks/Makefile.in @@ -82,6 +82,8 @@ TEST_FILES = \ xifdthtml.out \ simplemail.html \ simplemail.out \ + mischtml.html \ + mischtml.out \ $(NULL) include $(topsrcdir)/config/rules.mk diff --git a/mozilla/parser/htmlparser/tests/outsinks/TestOutSinks.pl b/mozilla/parser/htmlparser/tests/outsinks/TestOutSinks.pl index 974fc72b333..e5af0f82ffe 100755 --- a/mozilla/parser/htmlparser/tests/outsinks/TestOutSinks.pl +++ b/mozilla/parser/htmlparser/tests/outsinks/TestOutSinks.pl @@ -92,6 +92,13 @@ if ($status != 0) { $errmsg = "$errmsg mailquote.out"; } +print "Testing misc. HTML output with format=flowed ...\n"; +$status = system("./TestOutput -i text/html -o text/plain -f 2 -w 50 -c OutTestData/mischtml.out OutTestData/mischtml.html"); +if ($status != 0) { + print "Misc. HTML with format=flowed test failed.\n"; + $errmsg = "$errmsg mischtml.out"; +} + print "Testing format=flowed output ...\n"; $status = system("./TestOutput -i text/html -o text/plain -f 66 -w 50 -c OutTestData/simplemail.out OutTestData/simplemail.html"); if ($status != 0) { diff --git a/mozilla/parser/htmlparser/tests/outsinks/mischtml.html b/mozilla/parser/htmlparser/tests/outsinks/mischtml.html new file mode 100644 index 00000000000..573f701660c --- /dev/null +++ b/mozilla/parser/htmlparser/tests/outsinks/mischtml.html @@ -0,0 +1,50 @@ + + + +
Here is some text that was cited from another source
+
+Here is some discussion of said text +
And here is some
+preformatted text
+ +
Here is some more text
+
And here is some more
+preformatted text
+ + + diff --git a/mozilla/parser/htmlparser/tests/outsinks/mischtml.out b/mozilla/parser/htmlparser/tests/outsinks/mischtml.out new file mode 100644 index 00000000000..a766ed19175 --- /dev/null +++ b/mozilla/parser/htmlparser/tests/outsinks/mischtml.out @@ -0,0 +1,11 @@ +> Here is some text that was cited from another source + +*Here is some discussion of said text* + +And here is some +preformatted text + +> Here is some more text +And here is some more +preformatted text +