Backed out changeset 78bd7cfde7b6 (bug 1793876) for causing wpt failures in /editing/other/editing-div-outside-body.html?designMode

This commit is contained in:
Sandor Molnar 2022-12-20 12:14:01 +02:00
parent b495137121
commit 356a0e8699
3 changed files with 3 additions and 71 deletions

View file

@ -6577,18 +6577,14 @@ Element* HTMLEditor::ComputeEditingHostInternal(
// avoiding deleting or creating unexpected elements outside the <body>.
// However, this is incompatible with Chrome so that we should stop
// doing this with adding safety checks more.
if (!document->GetBodyElement()) {
return nullptr;
}
if (nsContentUtils::ContentIsFlattenedTreeDescendantOf(
if (document->GetBodyElement() &&
nsContentUtils::ContentIsFlattenedTreeDescendantOf(
aCandidiateEditingHost, document->GetBodyElement())) {
return const_cast<Element*>(aCandidiateEditingHost);
}
// XXX If aContent is an editing host and has no parent node, we reach here,
// but returing the <body> which is not connected to aContent is odd.
return HTMLEditUtils::IsSimplyEditableNode(*document->GetBodyElement())
? document->GetBodyElement()
: nullptr;
return document->GetBodyElement();
};
if (IsInDesignMode()) {

View file

@ -1,21 +0,0 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<script>
document.addEventListener("DOMContentLoaded", () => {
getSelection().collapse(document.querySelector("style"), 1);
document.execCommand("selectAll");
document.execCommand("forwardDelete");
});
</script>
</head>
<body>
<audio>
<data contenteditable>
<style>
</style>
</data>
</audio>
</body>
</html>

View file

@ -1,43 +0,0 @@
<!doctype html>
<html class="test-wait">
<head>
<meta charset="utf-8">
<script>
document.addEventListener("DOMContentLoaded", () => {
document.querySelector("g").appendChild(document.querySelector("tref"));
});
function onBegin() {
try {
document.querySelector("canvas").toBlob(() => {
document.execCommand("selectAll");
document.execCommand("insertHTML");
try {
getSelection().collapse(document.querySelector("li"), 0);
} catch (e) {
} finally {
document.documentElement.removeAttribute("class");
}
}, "");
} catch (e) {}
}
</script>
</head>
<body>
<canvas>
<option>
<svg>
<g/>
<tref>
<set onbegin="onBegin()"/>
</tref>
</svg>
</option>
<audio>
<label contenteditable="true">
<li id="d">a</li>
</label>
</audio>
</canvas>
</body>
</html>