Bug 1993351 - Set selection as dirty when unbinding from frame a=pascalc
Original Revision: https://phabricator.services.mozilla.com/D268527 Differential Revision: https://phabricator.services.mozilla.com/D269124
This commit is contained in:
committed by
rvandermeulen@mozilla.com
parent
2c2503b6e6
commit
6055a6e562
@@ -2488,6 +2488,12 @@ void TextControlState::UnbindFromFrame(nsTextControlFrame* aFrame) {
|
||||
DebugOnly<bool> ok = SetValue(value, ValueSetterOption::ByInternalAPI);
|
||||
// TODO Find something better to do if this fails...
|
||||
NS_WARNING_ASSERTION(ok, "SetValue() couldn't allocate memory");
|
||||
// And mark the selection as dirty to make sure the selection will be
|
||||
// restored properly in RestoreSelectionState. See bug 1993351.
|
||||
if (IsSelectionCached()) {
|
||||
SelectionProperties& props = GetSelectionProperties();
|
||||
props.SetIsDirty();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
<!DOCTYPE html>
|
||||
<meta charset="utf-8">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/resources/testdriver.js"></script>
|
||||
<script src="/resources/testdriver-vendor.js"></script>
|
||||
<script src="/resources/testdriver-actions.js"></script>
|
||||
<textarea id="t" style="white-space: nowrap">Hello</textarea>
|
||||
<script>
|
||||
promise_test(async () => {
|
||||
t.focus();
|
||||
if (navigator.userAgent.includes("Mac")) {
|
||||
// Meta+ArrowLeft
|
||||
await new test_driver.Actions()
|
||||
.keyDown("\uE03D")
|
||||
.keyDown("\uE058")
|
||||
.keyUp("\uE058")
|
||||
.keyUp("\uE03D")
|
||||
.send();
|
||||
} else {
|
||||
// Home
|
||||
await test_driver.send_keys(t, ["\uE011"]);
|
||||
}
|
||||
// And then Delete
|
||||
await test_driver.send_keys(t, ["\uE017"]);
|
||||
t.style.whiteSpace = "pre-line";
|
||||
await new Promise(setTimeout);
|
||||
assert_equals(t.selectionStart, 0, "selectionStart should remain 0");
|
||||
assert_equals(t.selectionEnd, 0, "selectionEnd should remain 0");
|
||||
}, "Changing white-space should not change selection");
|
||||
</script>
|
||||
Reference in New Issue
Block a user