mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 22:01:30 +00:00
Backed out 4 changesets (bug 1734590) for failures on test_xmlserializer.js. CLOSED TREE
Backed out changeset e492f8fd3d53 (bug 1734590) Backed out changeset 0af985bb7569 (bug 1734590) Backed out changeset 3751b93ae994 (bug 1734590) Backed out changeset 45059121c015 (bug 1734590)
This commit is contained in:
parent
3e435a16d6
commit
e92f158606
@ -1545,12 +1545,12 @@ bool nsXMLContentSerializer::AppendWrapped_NonWhitespaceSequence(
|
||||
if (wrapPosition != NS_LINEBREAKER_NEED_MORE_TEXT) {
|
||||
foundWrapPosition = true;
|
||||
} else {
|
||||
wrapPosition = lineBreaker->Next(aSequenceStart,
|
||||
(aEnd - aSequenceStart),
|
||||
(aPos - aSequenceStart));
|
||||
MOZ_ASSERT(wrapPosition != NS_LINEBREAKER_NEED_MORE_TEXT,
|
||||
"Next() always treats end-of-text as a break");
|
||||
foundWrapPosition = true;
|
||||
wrapPosition = lineBreaker->DeprecatedNext(aSequenceStart,
|
||||
(aEnd - aSequenceStart),
|
||||
(aPos - aSequenceStart));
|
||||
if (wrapPosition != NS_LINEBREAKER_NEED_MORE_TEXT) {
|
||||
foundWrapPosition = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2576,7 +2576,11 @@ nsresult HTMLEditor::InsertWithQuotationsAsSubAction(
|
||||
|
||||
// Let the citer quote it for us:
|
||||
nsString quotedStuff;
|
||||
InternetCiter::GetCiteString(aQuotedText, quotedStuff);
|
||||
nsresult rv = InternetCiter::GetCiteString(aQuotedText, quotedStuff);
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_WARNING("InternetCiter::GetCiteString() failed");
|
||||
return rv;
|
||||
}
|
||||
|
||||
// It's best to put a blank line after the quoted text so that mails
|
||||
// written without thinking won't be so ugly.
|
||||
@ -2595,7 +2599,7 @@ nsresult HTMLEditor::InsertWithQuotationsAsSubAction(
|
||||
!ignoredError.Failed(),
|
||||
"OnStartToHandleTopLevelEditSubAction() failed, but ignored");
|
||||
|
||||
nsresult rv = EnsureNoPaddingBRElementForEmptyEditor();
|
||||
rv = EnsureNoPaddingBRElementForEmptyEditor();
|
||||
if (NS_WARN_IF(rv == NS_ERROR_EDITOR_DESTROYED)) {
|
||||
return NS_ERROR_EDITOR_DESTROYED;
|
||||
}
|
||||
@ -2989,8 +2993,12 @@ NS_IMETHODIMP HTMLEditor::Rewrap(bool aRespectNewlines) {
|
||||
nsString wrapped;
|
||||
uint32_t firstLineOffset = 0; // XXX need to reset this if there is a
|
||||
// selection
|
||||
InternetCiter::Rewrap(current, wrapWidth, firstLineOffset, aRespectNewlines,
|
||||
wrapped);
|
||||
rv = InternetCiter::Rewrap(current, wrapWidth, firstLineOffset,
|
||||
aRespectNewlines, wrapped);
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_WARNING("InternetCiter::Rewrap() failed");
|
||||
return EditorBase::ToGenericNSResult(rv);
|
||||
}
|
||||
|
||||
if (isCollapsed) {
|
||||
DebugOnly<nsresult> rvIgnored = SelectAllInternal();
|
||||
|
@ -23,8 +23,8 @@ namespace mozilla {
|
||||
* Mail citations using the Internet style: > This is a citation.
|
||||
*/
|
||||
|
||||
void InternetCiter::GetCiteString(const nsAString& aInString,
|
||||
nsAString& aOutString) {
|
||||
nsresult InternetCiter::GetCiteString(const nsAString& aInString,
|
||||
nsAString& aOutString) {
|
||||
aOutString.Truncate();
|
||||
char16_t uch = HTMLEditUtils::kNewLine;
|
||||
|
||||
@ -58,6 +58,7 @@ void InternetCiter::GetCiteString(const nsAString& aInString,
|
||||
if (uch != HTMLEditUtils::kNewLine) {
|
||||
aOutString += HTMLEditUtils::kNewLine;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
static void AddCite(nsAString& aOutString, int32_t citeLevel) {
|
||||
@ -85,9 +86,9 @@ static inline bool IsSpace(char16_t c) {
|
||||
(c == HTMLEditUtils::kCarridgeReturn) || (c == HTMLEditUtils::kNBSP));
|
||||
}
|
||||
|
||||
void InternetCiter::Rewrap(const nsAString& aInString, uint32_t aWrapCol,
|
||||
uint32_t aFirstLineOffset, bool aRespectNewlines,
|
||||
nsAString& aOutString) {
|
||||
nsresult InternetCiter::Rewrap(const nsAString& aInString, uint32_t aWrapCol,
|
||||
uint32_t aFirstLineOffset, bool aRespectNewlines,
|
||||
nsAString& aOutString) {
|
||||
// There shouldn't be returns in this string, only dom newlines.
|
||||
// Check to make sure:
|
||||
#ifdef DEBUG
|
||||
@ -97,7 +98,11 @@ void InternetCiter::Rewrap(const nsAString& aInString, uint32_t aWrapCol,
|
||||
|
||||
aOutString.Truncate();
|
||||
|
||||
mozilla::intl::LineBreaker* lineBreaker = nsContentUtils::LineBreaker();
|
||||
nsresult rv;
|
||||
|
||||
RefPtr<mozilla::intl::LineBreaker> lineBreaker =
|
||||
mozilla::intl::LineBreaker::Create();
|
||||
MOZ_ASSERT(lineBreaker);
|
||||
|
||||
// Loop over lines in the input string, rewrapping each one.
|
||||
uint32_t length;
|
||||
@ -227,23 +232,37 @@ void InternetCiter::Rewrap(const nsAString& aInString, uint32_t aWrapCol,
|
||||
continue; // continue inner loop, with outStringCol now at bol
|
||||
}
|
||||
|
||||
int32_t breakPt =
|
||||
lineBreaker->Prev(tString.get() + posInString, length - posInString,
|
||||
eol + 1 - posInString);
|
||||
if (breakPt == NS_LINEBREAKER_NEED_MORE_TEXT) {
|
||||
// if we couldn't find a breakpoint looking backwards,
|
||||
// and we're not starting a new line, then end this line
|
||||
// and loop around again:
|
||||
if (outStringCol > citeLevel + 1) {
|
||||
BreakLine(aOutString, outStringCol, citeLevel);
|
||||
continue; // continue inner loop, with outStringCol now at bol
|
||||
}
|
||||
int32_t breakPt = 0;
|
||||
// XXX Why this uses NS_ERROR_"BASE"?
|
||||
rv = NS_ERROR_BASE;
|
||||
if (lineBreaker) {
|
||||
breakPt =
|
||||
lineBreaker->Prev(tString.get() + posInString, length - posInString,
|
||||
eol + 1 - posInString);
|
||||
if (breakPt == NS_LINEBREAKER_NEED_MORE_TEXT) {
|
||||
// if we couldn't find a breakpoint looking backwards,
|
||||
// and we're not starting a new line, then end this line
|
||||
// and loop around again:
|
||||
if (outStringCol > citeLevel + 1) {
|
||||
BreakLine(aOutString, outStringCol, citeLevel);
|
||||
continue; // continue inner loop, with outStringCol now at bol
|
||||
}
|
||||
|
||||
// Else try looking forwards:
|
||||
breakPt = lineBreaker->Next(tString.get() + posInString,
|
||||
length - posInString, eol - posInString);
|
||||
MOZ_ASSERT(breakPt != NS_LINEBREAKER_NEED_MORE_TEXT,
|
||||
"Next() always treats end-of-text as a break");
|
||||
// Else try looking forwards:
|
||||
breakPt = lineBreaker->DeprecatedNext(tString.get() + posInString,
|
||||
length - posInString,
|
||||
eol - posInString);
|
||||
|
||||
rv = breakPt == NS_LINEBREAKER_NEED_MORE_TEXT ? NS_ERROR_BASE : NS_OK;
|
||||
} else {
|
||||
rv = NS_OK;
|
||||
}
|
||||
}
|
||||
// If rv is okay, then breakPt is the place to break.
|
||||
// If we get out here and rv is set, something went wrong with line
|
||||
// breaker. Just break the line, hard.
|
||||
if (NS_FAILED(rv)) {
|
||||
breakPt = eol;
|
||||
}
|
||||
|
||||
// Special case: maybe we should have wrapped last time.
|
||||
@ -281,6 +300,8 @@ void InternetCiter::Rewrap(const nsAString& aInString, uint32_t aWrapCol,
|
||||
}
|
||||
} // end inner loop within one line of aInString
|
||||
} // end outer loop over lines of aInString
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
} // namespace mozilla
|
||||
|
@ -16,11 +16,12 @@ namespace mozilla {
|
||||
*/
|
||||
class InternetCiter final {
|
||||
public:
|
||||
static void GetCiteString(const nsAString& aInString, nsAString& aOutString);
|
||||
static nsresult GetCiteString(const nsAString& aInString,
|
||||
nsAString& aOutString);
|
||||
|
||||
static void Rewrap(const nsAString& aInString, uint32_t aWrapCol,
|
||||
uint32_t aFirstLineOffset, bool aRespectNewlines,
|
||||
nsAString& aOutString);
|
||||
static nsresult Rewrap(const nsAString& aInString, uint32_t aWrapCol,
|
||||
uint32_t aFirstLineOffset, bool aRespectNewlines,
|
||||
nsAString& aOutString);
|
||||
};
|
||||
|
||||
} // namespace mozilla
|
||||
|
@ -579,7 +579,11 @@ nsresult TextEditor::InsertWithQuotationsAsSubAction(
|
||||
|
||||
// Let the citer quote it for us:
|
||||
nsString quotedStuff;
|
||||
InternetCiter::GetCiteString(aQuotedText, quotedStuff);
|
||||
nsresult rv = InternetCiter::GetCiteString(aQuotedText, quotedStuff);
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_WARNING("InternetCiter::GetCiteString() failed");
|
||||
return rv;
|
||||
}
|
||||
|
||||
// It's best to put a blank line after the quoted text so that mails
|
||||
// written without thinking won't be so ugly.
|
||||
@ -601,7 +605,7 @@ nsresult TextEditor::InsertWithQuotationsAsSubAction(
|
||||
// also in single line editor)?
|
||||
MaybeDoAutoPasswordMasking();
|
||||
|
||||
nsresult rv = InsertTextAsSubAction(quotedStuff, SelectionHandling::Delete);
|
||||
rv = InsertTextAsSubAction(quotedStuff, SelectionHandling::Delete);
|
||||
NS_WARNING_ASSERTION(NS_SUCCEEDED(rv),
|
||||
"EditorBase::InsertTextAsSubAction() failed");
|
||||
return rv;
|
||||
|
@ -964,6 +964,16 @@ int32_t LineBreaker::Next(const char16_t* aText, uint32_t aLen, uint32_t aPos) {
|
||||
return WordMove(aText, aLen, aPos, 1);
|
||||
}
|
||||
|
||||
int32_t LineBreaker::DeprecatedNext(const char16_t* aText, uint32_t aLen,
|
||||
uint32_t aPos) {
|
||||
NS_ASSERTION(aText, "aText shouldn't be null");
|
||||
NS_ASSERTION(aLen > aPos,
|
||||
"Bad position passed to nsJISx4051LineBreaker::Next");
|
||||
|
||||
int32_t nextPos = WordMove(aText, aLen, aPos, 1);
|
||||
return nextPos < int32_t(aLen) ? nextPos : NS_LINEBREAKER_NEED_MORE_TEXT;
|
||||
}
|
||||
|
||||
int32_t LineBreaker::Prev(const char16_t* aText, uint32_t aLen, uint32_t aPos) {
|
||||
NS_ASSERTION(aText, "aText shouldn't be null");
|
||||
NS_ASSERTION(aLen >= aPos && aPos > 0,
|
||||
|
@ -40,6 +40,14 @@ class LineBreaker {
|
||||
// NS_LINEBREAKER_NEED_MORE_TEXT.
|
||||
int32_t Next(const char16_t* aText, uint32_t aLen, uint32_t aPos);
|
||||
|
||||
// Similar to Next(), but doesn't treat the end of text a line break
|
||||
// opportunity. It returns NS_LINEBREAKER_NEED_MORE_TEXT when reaching the end
|
||||
// of text.
|
||||
///
|
||||
// XXX: Please do not add new callers to DeprecatedNext(). This method will be
|
||||
// removed.
|
||||
int32_t DeprecatedNext(const char16_t* aText, uint32_t aLen, uint32_t aPos);
|
||||
|
||||
// Bug 1733009: Please do not add new callers to Prev(). This method will be
|
||||
// removed.
|
||||
int32_t Prev(const char16_t* aText, uint32_t aLen, uint32_t aPos);
|
||||
|
Loading…
Reference in New Issue
Block a user