Backed out changeset b9fa2c214287 (bug 1680548) for multiple mochitest failures

This commit is contained in:
Bogdan Tara
2020-12-05 10:52:56 +02:00
parent ff3887e067
commit 12c0cd7a20
3 changed files with 24 additions and 40 deletions

View File

@@ -2069,6 +2069,17 @@ void TextControlState::SetSelectionRange(
bool changed = false;
nsresult rv = NS_OK; // For the ScrollSelectionIntoView() return value.
if (IsSelectionCached()) {
nsAutoString value;
// XXXbz is "false" the right thing to pass here? Hard to tell, given the
// various mismatches between our impl and the spec.
GetValue(value, false);
uint32_t length = value.Length();
if (aStart > length) {
aStart = length;
}
if (aEnd > length) {
aEnd = length;
}
SelectionProperties& props = GetSelectionProperties();
changed = props.GetStart() != aStart || props.GetEnd() != aEnd ||
props.GetDirection() != aDirection;
@@ -2891,7 +2902,6 @@ bool TextControlState::SetValueWithoutTextEditor(
aHandlingSetValue.GetSetValueFlags()));
SelectionProperties& props = GetSelectionProperties();
props.SetMaxLength(aHandlingSetValue.GetSettingValue().Length());
if (aHandlingSetValue.GetSetValueFlags() &
eSetValue_MoveCursorToEndIfValueChanged) {
props.SetStart(aHandlingSetValue.GetSettingValue().Length());
@@ -2902,6 +2912,13 @@ bool TextControlState::SetValueWithoutTextEditor(
props.SetStart(0);
props.SetEnd(0);
props.SetDirection(nsITextControlFrame::eForward);
} else {
// Make sure our cached selection position is not outside the new
// value.
props.SetStart(std::min(
props.GetStart(), aHandlingSetValue.GetSettingValue().Length()));
props.SetEnd(std::min(props.GetEnd(),
aHandlingSetValue.GetSettingValue().Length()));
}
}