Bug 1357206 part 1. Move conversion of the new textarea/input value to DOM linebreaks to before we check whether the new value matches the old value. r=ehsan

Otherwise we end up calling into editor code and doing a bunch of work even though the value hasn't actually changed, when a value with \r in it is set repeatedly.
This commit is contained in:
Boris Zbarsky 2017-05-01 13:26:11 -04:00
parent 12bc4392d8
commit 107496cc39

View File

@ -2523,19 +2523,19 @@ nsTextEditorState::SetValue(const nsAString& aValue, uint32_t aFlags)
AutoWeakFrame weakFrame(mBoundFrame);
// \r is an illegal character in the dom, but people use them,
// so convert windows and mac platform linebreaks to \n:
if (newValue.FindChar(char16_t('\r')) != -1) {
if (!nsContentUtils::PlatformToDOMLineBreaks(newValue, fallible)) {
return false;
}
}
// this is necessary to avoid infinite recursion
if (!currentValue.Equals(newValue))
{
ValueSetter valueSetter(mEditor);
// \r is an illegal character in the dom, but people use them,
// so convert windows and mac platform linebreaks to \n:
if (newValue.FindChar(char16_t('\r')) != -1) {
if (!nsContentUtils::PlatformToDOMLineBreaks(newValue, fallible)) {
return false;
}
}
nsCOMPtr<nsIDOMDocument> domDoc;
mEditor->GetDocument(getter_AddRefs(domDoc));
if (!domDoc) {