Issue #2107 - Clean up caret when destroying editor.

Editor changes caret visibility during drag and drop. But when destroying
editor, we don't restore caret state. So we should restore it when destroying
editor.

Co-authored-by: Makoto Kato <m_kato@ga2.so-net.ne.jp>
This commit is contained in:
Job Bautista 2023-02-09 20:51:34 +08:00 committed by roytam1
commit cc6b0f11e7
5 changed files with 66 additions and 0 deletions

View file

@ -238,6 +238,8 @@ EditorEventListener::Disconnect()
void
EditorEventListener::UninstallFromEditor()
{
CleanupDragDropCaret();
nsCOMPtr<EventTarget> piTarget = mEditorBase->GetDOMEventTarget();
if (!piTarget) {
return;

View file

@ -0,0 +1,24 @@
<!DOCTYPE HTML>
<html class="reftest-wait">
<head>
<script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<style>
input, input:active { border: none; }
</style>
</head>
<body>
<input id="input1">
<div id=div1 style="height: 100px;">
<textarea id="textarea1" style="display: none;"></textarea>
</div>
<script>
SimpleTest.waitForFocus(() => {
let input1 = document.getElementById('input1');
input1.focus();
synthesizeKey("A");
document.documentElement.removeAttribute("class");
});
</script>
</body>
</html>

View file

@ -0,0 +1,37 @@
<!DOCTYPE HTML>
<html class="reftest-wait">
<head>
<script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<style>
input, input:active { border: none; }
</style>
</head>
<body>
<input id="input1" value="aaaaaaaaaaaaaaaaaaaa">
<div id=div1 style="height: 100px;">
<textarea id="textarea1"></textarea>
</div>
<script>
SimpleTest.waitForFocus(() => {
let div1 = document.getElementById('div1');
let textarea1 = document.getElementById('textarea1');
div1.addEventListener("drop", e => {
e.preventDefault();
textarea1.style = "display: none;";
SimpleTest.executeSoon(() => {
synthesizeKey("A");
document.documentElement.removeAttribute("class");
});
});
let input1 = document.getElementById('input1');
input1.focus();
input1.setSelectionRange(0, input1.value.length);
synthesizeDrop(input1, textarea1, [[{type: "text/plain", data: "foo"}]]);
});
</script>
</body>
</html>

View file

@ -179,6 +179,8 @@ support-files =
bug1263357-4-ref.html
bug1263357-5.html
bug1263357-5-ref.html
bug1496118.html
bug1496118-ref.html
input-maxlength-valid-before-change.html
input-maxlength-valid-change.html
input-maxlength-invalid-change.html

View file

@ -186,6 +186,7 @@ var tests = [
[ 'bug1263357-3.html' , 'bug1263357-3-ref.html'] ,
[ 'bug1263357-4.html' , 'bug1263357-4-ref.html'] ,
[ 'bug1263357-5.html' , 'bug1263357-5-ref.html'] ,
[ 'bug1496118.html' , 'bug1496118-ref.html' ] ,
function() {SpecialPowers.pushPrefEnv({'clear': [['layout.accessiblecaret.enabled']]}, nextTest);} ,
];