зеркало из https://github.com/mozilla/gecko-dev.git
Backed out changeset 18dde41563b1 (bug 1882818) for causing Bug 1884613. CLOSED TREE
This commit is contained in:
Родитель
8c82adbd7f
Коммит
2cb7fdd031
|
@ -4003,23 +4003,17 @@ nsresult HTMLEditor::HTMLWithContextInserter::FragmentFromPasteCreator::
|
|||
MoveStartAndEndAccordingToHTMLInfo(const nsAString& aInfoStr,
|
||||
nsCOMPtr<nsINode>* aOutStartNode,
|
||||
nsCOMPtr<nsINode>* aOutEndNode) {
|
||||
nsresult rvIgnored = NS_OK;
|
||||
const int32_t sep = aInfoStr.FindChar((char16_t)',');
|
||||
const int32_t startDepth = Substring(aInfoStr, 0, sep).ToInteger(&rvIgnored);
|
||||
NS_WARNING_ASSERTION(
|
||||
NS_SUCCEEDED(rvIgnored),
|
||||
"nsAString::ToInteger() for startDepth failed, but ignored");
|
||||
const int32_t endDepth =
|
||||
Substring(aInfoStr, sep + 1, aInfoStr.Length() - (sep + 1))
|
||||
.ToInteger(&rvIgnored);
|
||||
NS_WARNING_ASSERTION(
|
||||
NS_SUCCEEDED(rvIgnored),
|
||||
"nsAString::ToInteger() for endDepth failed, but ignored");
|
||||
if (!startDepth && !endDepth) {
|
||||
return NS_OK;
|
||||
}
|
||||
int32_t sep = aInfoStr.FindChar((char16_t)',');
|
||||
nsAutoString numstr1(Substring(aInfoStr, 0, sep));
|
||||
nsAutoString numstr2(
|
||||
Substring(aInfoStr, sep + 1, aInfoStr.Length() - (sep + 1)));
|
||||
|
||||
for ([[maybe_unused]] int32_t i : IntegerRange(std::max(startDepth, 0))) {
|
||||
// Move the start and end children.
|
||||
nsresult rvIgnored;
|
||||
int32_t num = numstr1.ToInteger(&rvIgnored);
|
||||
NS_WARNING_ASSERTION(NS_SUCCEEDED(rvIgnored),
|
||||
"nsAString::ToInteger() failed, but ignored");
|
||||
while (num--) {
|
||||
nsINode* tmp = (*aOutStartNode)->GetFirstChild();
|
||||
if (!tmp) {
|
||||
NS_WARNING("aOutStartNode did not have children");
|
||||
|
@ -4028,7 +4022,8 @@ nsresult HTMLEditor::HTMLWithContextInserter::FragmentFromPasteCreator::
|
|||
*aOutStartNode = tmp;
|
||||
}
|
||||
|
||||
for ([[maybe_unused]] int32_t i : IntegerRange(std::max(endDepth, 0))) {
|
||||
num = numstr2.ToInteger(&rvIgnored);
|
||||
while (num--) {
|
||||
nsINode* tmp = (*aOutEndNode)->GetLastChild();
|
||||
if (!tmp) {
|
||||
NS_WARNING("aOutEndNode did not have children");
|
||||
|
@ -4037,39 +4032,6 @@ nsresult HTMLEditor::HTMLWithContextInserter::FragmentFromPasteCreator::
|
|||
*aOutEndNode = tmp;
|
||||
}
|
||||
|
||||
// However, unless they are in common ancestor, we need to climbing up the
|
||||
// tree again because user must want to copy the parent blocks too.
|
||||
const nsINode* commonAncestor =
|
||||
nsContentUtils::GetClosestCommonInclusiveAncestor(*aOutStartNode,
|
||||
*aOutEndNode);
|
||||
if (NS_WARN_IF(!commonAncestor)) {
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
for ([[maybe_unused]] int32_t i : IntegerRange(std::max(startDepth, 0))) {
|
||||
if (*aOutStartNode == commonAncestor) {
|
||||
break;
|
||||
}
|
||||
nsINode* tmp = (*aOutStartNode)->GetParentNode();
|
||||
if (!tmp) {
|
||||
NS_WARNING("aOutStartNode did not have parent");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
*aOutStartNode = tmp;
|
||||
}
|
||||
|
||||
for ([[maybe_unused]] int32_t i : IntegerRange(std::max(endDepth, 0))) {
|
||||
if (*aOutEndNode == commonAncestor) {
|
||||
break;
|
||||
}
|
||||
nsINode* tmp = (*aOutEndNode)->GetParentNode();
|
||||
if (!tmp) {
|
||||
NS_WARNING("aOutEndNode did not have parent");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
*aOutEndNode = tmp;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -578,8 +578,6 @@ skip-if = ["xorigin"] # Testing internal API for comm-central
|
|||
|
||||
["test_paste_no_formatting.html"]
|
||||
|
||||
["test_paste_paragraphs_ending_with_invisible_br.html"]
|
||||
|
||||
["test_paste_redirect_focus_in_paste_event_listener.html"]
|
||||
|
||||
["test_pasting_in_root_element.xhtml"]
|
||||
|
|
|
@ -1,42 +0,0 @@
|
|||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<script src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script src="/tests/SimpleTest/EventUtils.js"></script>
|
||||
<link rel="stylesheet" href="/tests/SimpleTest/test.css">
|
||||
</head>
|
||||
<script>
|
||||
"use strict";
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
SimpleTest.waitForFocus(async () => {
|
||||
const editingHost = document.querySelector("div[contenteditable]");
|
||||
const div2 = editingHost.querySelector("div ~ div");
|
||||
const div3 = editingHost.querySelector("div ~ div ~ div");
|
||||
editingHost.focus();
|
||||
getSelection().setBaseAndExtent(div2, 0, div3.firstChild, div3.firstChild.length);
|
||||
const promisePaste = new Promise(resolve => {
|
||||
editingHost.addEventListener("input", resolve, {once: true});
|
||||
});
|
||||
synthesizeKey("c", { accelKey: true });
|
||||
document.execCommand("selectAll");
|
||||
synthesizeKey("v", { accelKey: true });
|
||||
await promisePaste;
|
||||
is(
|
||||
editingHost.innerHTML.trim(),
|
||||
"<div>def</div>\n<div>ghi</div>",
|
||||
"Copied 2 <div>s should be pasted as-is"
|
||||
);
|
||||
SimpleTest.finish();
|
||||
});
|
||||
</script>
|
||||
<body>
|
||||
<div contenteditable>
|
||||
<div>abc</div>
|
||||
<div>def</div>
|
||||
<div>ghi<br></div>
|
||||
<div>jkl</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
Загрузка…
Ссылка в новой задаче