Auto merge of #25485 - teapotd:textinput-maxlength-del, r=nox

Allow deletions from overflowed textinput

Allow deletions from textinput when the length is greater than the max length.

---
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix #25420
- [X] There are tests for these changes
This commit is contained in:
bors-servo 2020-01-16 10:49:42 -05:00 committed by GitHub
commit 5c202ed392
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 6 deletions

View file

@ -161,6 +161,28 @@ fn test_single_line_textinput_with_max_length_doesnt_allow_appending_characters_
assert_eq!(textinput.get_content(), "atooe");
}
#[test]
fn test_single_line_textinput_with_max_length_allows_deletion_when_replacing_a_selection() {
let mut textinput = TextInput::new(
Lines::Single,
DOMString::from("abcde"),
DummyClipboardContext::new(""),
Some(UTF16CodeUnits(1)),
None,
SelectionDirection::None,
);
textinput.adjust_horizontal(UTF8Bytes::one(), Direction::Forward, Selection::NotSelected);
textinput.adjust_horizontal(UTF8Bytes(2), Direction::Forward, Selection::Selected);
// Selection is now "abcde"
// --
textinput.replace_selection(DOMString::from("only deletion should be applied"));
assert_eq!(textinput.get_content(), "ade");
}
#[test]
fn test_single_line_textinput_with_max_length_multibyte() {
let mut textinput = TextInput::new(