From 6ee8676f317c1d94446c9782e94443ead532813f Mon Sep 17 00:00:00 2001 From: Mirko Brodesser Date: Mon, 9 Sep 2019 09:04:25 +0000 Subject: [PATCH] Bug 1579355: part 7) Add explanatory comment to `aSoftLineBreak`. r=hsivonen Differential Revision: https://phabricator.services.mozilla.com/D44964 --HG-- extra : moz-landing-system : lando --- dom/base/nsPlainTextSerializer.cpp | 10 +++++----- dom/base/nsPlainTextSerializer.h | 6 +++++- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/dom/base/nsPlainTextSerializer.cpp b/dom/base/nsPlainTextSerializer.cpp index 6689d81ddd57..dffcb1f5fd78 100644 --- a/dom/base/nsPlainTextSerializer.cpp +++ b/dom/base/nsPlainTextSerializer.cpp @@ -1360,10 +1360,10 @@ static bool IsSignatureSeparator(const nsAString& aString) { * specific variables. Also adds an indentation and prefix if there is one * specified. Strips ending spaces from the line if it isn't preformatted. */ -void nsPlainTextSerializer::EndLine(bool aSoftlinebreak, bool aBreakBySpace) { +void nsPlainTextSerializer::EndLine(bool aSoftLineBreak, bool aBreakBySpace) { uint32_t currentlinelength = mCurrentLine.mContent.mValue.Length(); - if (aSoftlinebreak && 0 == currentlinelength) { + if (aSoftLineBreak && 0 == currentlinelength) { // No meaning return; } @@ -1375,11 +1375,11 @@ void nsPlainTextSerializer::EndLine(bool aSoftlinebreak, bool aBreakBySpace) { * signed messages according to the OpenPGP standard (RFC 2440). */ if (!mSettings.HasFlag(nsIDocumentEncoder::OutputPreformatted) && - (aSoftlinebreak || !IsSignatureSeparator(mCurrentLine.mContent.mValue))) { + (aSoftLineBreak || !IsSignatureSeparator(mCurrentLine.mContent.mValue))) { mCurrentLine.mContent.mValue.Trim(" ", false, true, false); } - if (aSoftlinebreak && + if (aSoftLineBreak && mSettings.HasFlag(nsIDocumentEncoder::OutputFormatFlowed) && (mCurrentLine.mIndentation.mWidth == 0)) { // Add the soft part of the soft linebreak (RFC 2646 4.1) @@ -1396,7 +1396,7 @@ void nsPlainTextSerializer::EndLine(bool aSoftlinebreak, bool aBreakBySpace) { } } - if (aSoftlinebreak) { + if (aSoftLineBreak) { mEmptyLines = 0; } else { // Hard break diff --git a/dom/base/nsPlainTextSerializer.h b/dom/base/nsPlainTextSerializer.h index df6e1514a7db..5c8776bb4800 100644 --- a/dom/base/nsPlainTextSerializer.h +++ b/dom/base/nsPlainTextSerializer.h @@ -88,7 +88,11 @@ class nsPlainTextSerializer final : public nsIContentSerializer { nsresult GetAttributeValue(nsAtom* aName, nsString& aValueRet) const; void AddToLine(const char16_t* aStringToAdd, int32_t aLength); - void EndLine(bool softlinebreak, bool aBreakBySpace = false); + + // @param aSoftLineBreak A soft line break is a space followed by a linebreak + // (cf. https://www.ietf.org/rfc/rfc3676.txt, section 4.2). + void EndLine(bool aSoftLineBreak, bool aBreakBySpace = false); + void EnsureVerticalSpace(int32_t noOfRows); void Write(const nsAString& aString);