mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 969773 - Restore Selection/Controller state when disconnecting the editor. r=ehsan
This commit is contained in:
parent
73bca3faa9
commit
48a4213ce5
@ -232,6 +232,21 @@ nsEditorEventListener::Disconnect()
|
||||
return;
|
||||
}
|
||||
UninstallFromEditor();
|
||||
|
||||
nsIFocusManager* fm = nsFocusManager::GetFocusManager();
|
||||
if (fm) {
|
||||
nsCOMPtr<nsIDOMElement> domFocus;
|
||||
fm->GetFocusedElement(getter_AddRefs(domFocus));
|
||||
nsCOMPtr<nsINode> focusedElement = do_QueryInterface(domFocus);
|
||||
mozilla::dom::Element* root = mEditor->GetRoot();
|
||||
if (focusedElement && root &&
|
||||
nsContentUtils::ContentIsDescendantOf(focusedElement, root)) {
|
||||
// Reset the Selection ancestor limiter and SelectionController state
|
||||
// that nsEditor::InitializeSelection set up.
|
||||
mEditor->FinalizeSelection();
|
||||
}
|
||||
}
|
||||
|
||||
mEditor = nullptr;
|
||||
}
|
||||
|
||||
|
24
editor/reftests/969773-ref.html
Normal file
24
editor/reftests/969773-ref.html
Normal file
@ -0,0 +1,24 @@
|
||||
<!DOCTYPE html>
|
||||
<html class="reftest-wait">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Contenteditable Selection Test Case</title>
|
||||
<script>
|
||||
function runTests() {
|
||||
var text = document.getElementById("text");
|
||||
|
||||
text.focus();
|
||||
|
||||
setTimeout(function () {
|
||||
document.body.offsetHeight;
|
||||
document.documentElement.removeAttribute('class');
|
||||
}, 0);
|
||||
}
|
||||
document.addEventListener('MozReftestInvalidate', runTests, false);
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<div>This is a contenteditable.</div>
|
||||
<div id="text" tabindex="0">This is focusable text</div>
|
||||
</body>
|
||||
</html>
|
29
editor/reftests/969773.html
Normal file
29
editor/reftests/969773.html
Normal file
@ -0,0 +1,29 @@
|
||||
<!DOCTYPE html>
|
||||
<html class="reftest-wait">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Contenteditable Selection Test Case</title>
|
||||
<script>
|
||||
function runTests() {
|
||||
var editable = document.getElementById("editable");
|
||||
var text = document.getElementById("text");
|
||||
|
||||
editable.focus();
|
||||
|
||||
setTimeout(function () {
|
||||
editable.setAttribute("contenteditable", "false");
|
||||
text.focus();
|
||||
setTimeout(function () {
|
||||
document.body.offsetHeight;
|
||||
document.documentElement.removeAttribute('class');
|
||||
}, 0);
|
||||
}, 0);
|
||||
}
|
||||
document.addEventListener('MozReftestInvalidate', runTests, false);
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="editable" contenteditable="true" tabindex="0" spellcheck="false">This is a contenteditable.</div>
|
||||
<div id="text" tabindex="0">This is focusable text</div>
|
||||
</body>
|
||||
</html>
|
@ -125,3 +125,4 @@ needs-focus == spellcheck-contenteditable-focused-reframe.html spellcheck-conten
|
||||
== spellcheck-contenteditable-attr-dynamic-override-inherit.html spellcheck-contenteditable-disabled-ref.html
|
||||
== spellcheck-contenteditable-property-dynamic-override.html spellcheck-contenteditable-disabled-ref.html
|
||||
== spellcheck-contenteditable-property-dynamic-override-inherit.html spellcheck-contenteditable-disabled-ref.html
|
||||
needs-focus == 969773.html 969773-ref.html
|
||||
|
Loading…
Reference in New Issue
Block a user