зеркало из https://github.com/mozilla/gecko-dev.git
Bug 456053 - Don't trim trailing space of quoted lines. r=masayuki
This commit is contained in:
Родитель
d30aa0e08b
Коммит
cadd291ee3
|
@ -1582,7 +1582,7 @@ nsPlainTextSerializer::Write(const nsAString& aStr)
|
||||||
// that does normal formatted text. The one for preformatted text calls
|
// that does normal formatted text. The one for preformatted text calls
|
||||||
// Output directly while the other code path goes through AddToLine.
|
// Output directly while the other code path goes through AddToLine.
|
||||||
if ((mPreFormattedMail && !mWrapColumn) || (IsInPre() && !mPreFormattedMail)
|
if ((mPreFormattedMail && !mWrapColumn) || (IsInPre() && !mPreFormattedMail)
|
||||||
|| (mSpanLevel > 0 && mEmptyLines >= 0 && str.First() == char16_t('>'))) {
|
|| (mSpanLevel > 0 && mEmptyLines >= 0 && IsQuotedLine(str))) {
|
||||||
// No intelligent wrapping.
|
// No intelligent wrapping.
|
||||||
|
|
||||||
// This mustn't be mixed with intelligent wrapping without clearing
|
// This mustn't be mixed with intelligent wrapping without clearing
|
||||||
|
@ -1657,10 +1657,11 @@ nsPlainTextSerializer::Write(const nsAString& aStr)
|
||||||
mCurrentLine.Truncate();
|
mCurrentLine.Truncate();
|
||||||
if (mFlags & nsIDocumentEncoder::OutputFormatFlowed) {
|
if (mFlags & nsIDocumentEncoder::OutputFormatFlowed) {
|
||||||
if ((outputLineBreak || !spacesOnly) && // bugs 261467,125928
|
if ((outputLineBreak || !spacesOnly) && // bugs 261467,125928
|
||||||
|
!IsQuotedLine(stringpart) &&
|
||||||
!stringpart.EqualsLiteral("-- ") &&
|
!stringpart.EqualsLiteral("-- ") &&
|
||||||
!stringpart.EqualsLiteral("- -- "))
|
!stringpart.EqualsLiteral("- -- "))
|
||||||
stringpart.Trim(" ", false, true, true);
|
stringpart.Trim(" ", false, true, true);
|
||||||
if (IsSpaceStuffable(stringpart.get()) && stringpart[0] != '>')
|
if (IsSpaceStuffable(stringpart.get()) && !IsQuotedLine(stringpart))
|
||||||
mCurrentLine.Append(char16_t(' '));
|
mCurrentLine.Append(char16_t(' '));
|
||||||
}
|
}
|
||||||
mCurrentLine.Append(stringpart);
|
mCurrentLine.Append(stringpart);
|
||||||
|
|
|
@ -110,6 +110,11 @@ private:
|
||||||
return mHeadLevel == 0;
|
return mHeadLevel == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline bool IsQuotedLine(const nsAString& aLine)
|
||||||
|
{
|
||||||
|
return !aLine.IsEmpty() && aLine.First() == char16_t('>');
|
||||||
|
}
|
||||||
|
|
||||||
// Stack handling functions
|
// Stack handling functions
|
||||||
bool GetLastBool(const nsTArray<bool>& aStack);
|
bool GetLastBool(const nsTArray<bool>& aStack);
|
||||||
void SetLastBool(nsTArray<bool>& aStack, bool aValue);
|
void SetLastBool(nsTArray<bool>& aStack, bool aValue);
|
||||||
|
|
|
@ -130,6 +130,43 @@ TestCJKWithDisallowLineBreaking()
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Test for ASCII with format=flowed; and quoted lines in preformatted span.
|
||||||
|
nsresult
|
||||||
|
TestPreformatFlowedQuotes()
|
||||||
|
{
|
||||||
|
nsString test;
|
||||||
|
nsString result;
|
||||||
|
|
||||||
|
test.AssignLiteral("<html><body>"
|
||||||
|
"<span style=\"white-space: pre-wrap;\">"
|
||||||
|
"> Firefox Firefox Firefox Firefox <br>"
|
||||||
|
"> Firefox Firefox Firefox Firefox<br>"
|
||||||
|
"><br>"
|
||||||
|
">> Firefox Firefox Firefox Firefox <br>"
|
||||||
|
">> Firefox Firefox Firefox Firefox<br>"
|
||||||
|
"</span></body></html>");
|
||||||
|
|
||||||
|
ConvertBufToPlainText(test, nsIDocumentEncoder::OutputFormatted |
|
||||||
|
nsIDocumentEncoder::OutputCRLineBreak |
|
||||||
|
nsIDocumentEncoder::OutputLFLineBreak |
|
||||||
|
nsIDocumentEncoder::OutputFormatFlowed);
|
||||||
|
|
||||||
|
// create result case
|
||||||
|
result.AssignLiteral("> Firefox Firefox Firefox Firefox \r\n"
|
||||||
|
"> Firefox Firefox Firefox Firefox\r\n"
|
||||||
|
">\r\n"
|
||||||
|
">> Firefox Firefox Firefox Firefox \r\n"
|
||||||
|
">> Firefox Firefox Firefox Firefox\r\n");
|
||||||
|
if (!test.Equals(result)) {
|
||||||
|
fail("Wrong HTML to ASCII text serialization with format=flowed; and quoted lines");
|
||||||
|
return NS_ERROR_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
passed("HTML to ASCII text serialization with format=flowed; and quoted lines");
|
||||||
|
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
TestPrettyPrintedHtml()
|
TestPrettyPrintedHtml()
|
||||||
{
|
{
|
||||||
|
@ -267,6 +304,9 @@ TestPlainTextSerializer()
|
||||||
rv = TestCJKWithDisallowLineBreaking();
|
rv = TestCJKWithDisallowLineBreaking();
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
|
rv = TestPreformatFlowedQuotes();
|
||||||
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
// Add new tests here...
|
// Add new tests here...
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче