зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1582215 - Make `HTMLEditor::DoInsertHTMLWithContext()` compute new insertion point before removing unnecessary `<li>` elements r=m_kato
When inserting `<li>` elements into `<ul>`, `<ol>` or `<li>` element, `HTMLEditor::DoInsertHTMLWithContext()` removes unnecessary empty `<li>` elements at insertion point. At this time, we've computed next insertion point with removed `<li>` element. Therefore, insertion point goes out from the DOM tree. This patch makes it compute new insertion point before removing each empty `<li>` element. Additionally, this patch adds some WPT data for testing this case. I verified that Chrome passes the new tests too. Differential Revision: https://phabricator.services.mozilla.com/D49394 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
97dc13cb94
Коммит
abdf9727f5
|
@ -495,9 +495,10 @@ nsresult HTMLEditor::DoInsertHTMLWithContext(
|
|||
pointToInsert.GetContainer()->GetParentNode(),
|
||||
"Insertion point is out of the DOM tree");
|
||||
if (pointToInsert.GetContainer()->GetParentNode()) {
|
||||
DeleteNodeWithTransaction(
|
||||
MOZ_KnownLive(*pointToInsert.GetContainer()));
|
||||
pointToInsert.Set(pointToInsert.GetContainer());
|
||||
AutoEditorDOMPointChildInvalidator lockOffset(pointToInsert);
|
||||
DeleteNodeWithTransaction(
|
||||
MOZ_KnownLive(*pointToInsert.GetChild()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -360,6 +360,26 @@ var browserTests = [
|
|||
"<ul><li>f<ul><li>abc</li></ul>{}o</li></ul>",
|
||||
[true],
|
||||
{"inserthtml":[false,false,"",false,false,""]}],
|
||||
["<ul id=\"old\"><li id=\"li0\">{}<br></ul>",
|
||||
[["inserthtml","<ul id=\"new\"><li id=\"li1\">abc</li><li id=\"li2\">def</li></ul>"]],
|
||||
"<ul id=\"old\"><li id=\"li1\">abc</li><li id=\"li2\">def</li></ul>",
|
||||
[true],
|
||||
{"inserthtml":[false,false,"",false,false,""]}],
|
||||
["<ol id=\"old\"><li id=\"li0\">{}<br></ol>",
|
||||
[["inserthtml","<ol id=\"new\"><li id=\"li1\">abc</li><li id=\"li2\">def</li></ol>"]],
|
||||
"<ol id=\"old\"><li id=\"li1\">abc</li><li id=\"li2\">def</li></ol>",
|
||||
[true],
|
||||
{"inserthtml":[false,false,"",false,false,""]}],
|
||||
["<ul id=\"old\"><li id=\"li0\">{}<br></ul>",
|
||||
[["inserthtml","<ol id=\"new\"><li id=\"li1\">abc</li><li id=\"li2\">def</li></ol>"]],
|
||||
"<ul id=\"old\"><li id=\"li1\">abc</li><li id=\"li2\">def</li></ul>",
|
||||
[true],
|
||||
{"inserthtml":[false,false,"",false,false,""]}],
|
||||
["<ol id=\"old\"><li id=\"li0\">{}<br></ol>",
|
||||
[["inserthtml","<ul id=\"new\"><li id=\"li1\">abc</li><li id=\"li2\">def</li></ul>"]],
|
||||
"<ol id=\"old\"><li id=\"li1\">abc</li><li id=\"li2\">def</li></ol>",
|
||||
[true],
|
||||
{"inserthtml":[false,false,"",false,false,""]}],
|
||||
["f[o]o",
|
||||
[["defaultparagraphseparator","div"],["inserthtml","<li>abc</li>"]],
|
||||
"f<div>abc</div>{}o",
|
||||
|
|
Загрузка…
Ссылка в новой задаче