Truly independent web browser
LibWeb: Collect outdent's preceding siblings in tree order
Andreas Klingec7ee9d08341
diff --git a/Libraries/LibWeb/Editing/Internal/Algorithms.cpp b/Libraries/LibWeb/Editing/Internal/Algorithms.cppindex ba019acd66f..b4b1bf58a2a 100644--- a/Libraries/LibWeb/Editing/Internal/Algorithms.cpp+++ b/Libraries/LibWeb/Editing/Internal/Algorithms.cpp@@ -3294,8 +3294,10 @@ void outdent(GC::Ref<DOM::Node> node)// 5. Let preceding siblings be the precedings siblings of target, and let following siblings be the followings// siblings of target.+ // NB: Both lists are in tree order, like in the spec's reference implementation. Indenting a list relies on+ // this, since it looks for a new parent next to the first and last members of the list.Vector<GC::Ref<DOM::Node>> preceding_siblings;- for (auto* sibling = target->previous_sibling(); sibling; sibling = sibling->previous_sibling())+ for (auto* sibling = current_ancestor->first_child(); sibling != target.ptr(); sibling = sibling->next_sibling())preceding_siblings.append(*sibling);Vector<GC::Ref<DOM::Node>> following_siblings;for (auto* sibling = target->next_sibling(); sibling; sibling = sibling->next_sibling())diff --git a/Tests/LibWeb/Crash/Editing/execCommand-outdent-with-indented-preceding-sibling.html b/Tests/LibWeb/Crash/Editing/execCommand-outdent-with-indented-preceding-sibling.htmlnew file mode 100644index 00000000000..6c8e1496d77--- /dev/null+++ b/Tests/LibWeb/Crash/Editing/execCommand-outdent-with-indented-preceding-sibling.html@@ -0,0 +1,6 @@+<div id="editor" contenteditable><blockquote><blockquote>x</blockquote><br><div id="target">b</div></blockquote></div>+<script>+ editor.focus();+ getSelection().collapse(target.firstChild, 0);+ document.execCommand("outdent");+</script>diff --git a/Tests/LibWeb/Text/expected/wpt-import/editing/run/[email protected] b/Tests/LibWeb/Text/expected/wpt-import/editing/run/[email protected]index d28d2daf09f..aa13eeaf352 100644--- a/Tests/LibWeb/Text/expected/wpt-import/editing/run/[email protected]+++ b/Tests/LibWeb/Text/expected/wpt-import/editing/run/[email protected]@@ -2,8 +2,8 @@ Harness status: OKFound 550 tests-548 Pass-2 Fail+549 Pass+1 FailPass [["outdent",""]] "<blockquote>foo<ol><li>[bar]</ol>baz</blockquote><p>extra" queryCommandIndeterm("outdent") afterPass [["outdent",""]] "<blockquote>foo<ol><li>[bar]</ol>baz</blockquote><p>extra" queryCommandState("outdent") afterPass [["outdent",""]] "<blockquote>foo<ol><li>[bar]</ol>baz</blockquote><p>extra" queryCommandValue("outdent") after@@ -305,7 +305,7 @@ Pass [["outdent",""]] "<blockquote> <p>foo</p> <p>[bar]</p> <p>baz</p></blockquoPass [["outdent",""]] "<blockquote> <p>foo</p> <p>[bar]</p> <p>baz</p></blockquote>" queryCommandValue("outdent") afterPass [["outdent",""]] "<blockquote> <p>foo</p> <p>bar</p> <p>[baz]</p></blockquote>": execCommand("outdent", false, "") return valuePass [["outdent",""]] "<blockquote> <p>foo</p> <p>bar</p> <p>[baz]</p></blockquote>" checks for modifications to non-editable content-Fail [["outdent",""]] "<blockquote> <p>foo</p> <p>bar</p> <p>[baz]</p></blockquote>" compare innerHTML+Pass [["outdent",""]] "<blockquote> <p>foo</p> <p>bar</p> <p>[baz]</p></blockquote>" compare innerHTMLPass [["outdent",""]] "<blockquote> <p>foo</p> <p>bar</p> <p>[baz]</p></blockquote>" queryCommandIndeterm("outdent") beforePass [["outdent",""]] "<blockquote> <p>foo</p> <p>bar</p> <p>[baz]</p></blockquote>" queryCommandState("outdent") beforePass [["outdent",""]] "<blockquote> <p>foo</p> <p>bar</p> <p>[baz]</p></blockquote>" queryCommandValue("outdent") before