InsertOrderedList command applied to table cells inserts an extra BR before the table
authorjfernandez@igalia.com <jfernandez@igalia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 26 Jul 2017 09:48:37 +0000 (09:48 +0000)
committerjfernandez@igalia.com <jfernandez@igalia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 26 Jul 2017 09:48:37 +0000 (09:48 +0000)
https://bugs.webkit.org/show_bug.cgi?id=174593

Reviewed by Darin Adler.

Source/WebCore:

Don't add BR when pruning empty blocks if it's the start of a paragraph.

The function MoveParagraph is used for several operations and editing
commands, like 'insertOrderedList'. When moving paragraphs we check out
whether we should add a 'br' element to avoid undesired block collapse.

However, we shouldn't do this when destination is the start of a
paragraph.

Tests: editing/inserting/insert-list-in-table-cell-01.html
       editing/inserting/insert-list-in-table-cell-02.html
       editing/inserting/insert-list-in-table-cell-03.html
       editing/inserting/insert-list-in-table-cell-04.html
       editing/inserting/insert-list-in-table-cell-05.html
       editing/inserting/insert-list-in-table-cell-06.html
       editing/inserting/insert-list-in-table-cell-07.html
       editing/inserting/insert-list-in-table-cell-08.html

* editing/CompositeEditCommand.cpp:
(WebCore::CompositeEditCommand::moveParagraphs):

LayoutTests:

Tests to verify that the insertOrderedList command works as expected when applied
in table cells.

* editing/inserting/insert-list-in-table-cell-01.html: Added.
* editing/inserting/insert-list-in-table-cell-01-expected.txt: Added.
* editing/inserting/insert-list-in-table-cell-02.html: Added.
* editing/inserting/insert-list-in-table-cell-02-expected.txt: Added.
* editing/inserting/insert-list-in-table-cell-03.html: Added.
* editing/inserting/insert-list-in-table-cell-03-expected.txt: Added.
* editing/inserting/insert-list-in-table-cell-04.html: Added.
* editing/inserting/insert-list-in-table-cell-04-expected.txt: Added.
* editing/inserting/insert-list-in-table-cell-05.html: Added.
* editing/inserting/insert-list-in-table-cell-05-expected.txt: Added.
* editing/inserting/insert-list-in-table-cell-06.html: Added.
* editing/inserting/insert-list-in-table-cell-06-expected.txt: Added.
* editing/inserting/insert-list-in-table-cell-07.html: Added.
* editing/inserting/insert-list-in-table-cell-07-expected.txt: Added.
* editing/inserting/insert-list-in-table-cell-08.html: Added.
* editing/inserting/insert-list-in-table-cell-08-expected.txt: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@219914 268f45cc-cd09-0410-ab3c-d52691b4dbfc

19 files changed:
LayoutTests/ChangeLog
LayoutTests/editing/inserting/insert-list-in-table-cell-01-expected.txt [new file with mode: 0644]
LayoutTests/editing/inserting/insert-list-in-table-cell-01.html [new file with mode: 0644]
LayoutTests/editing/inserting/insert-list-in-table-cell-02-expected.txt [new file with mode: 0644]
LayoutTests/editing/inserting/insert-list-in-table-cell-02.html [new file with mode: 0644]
LayoutTests/editing/inserting/insert-list-in-table-cell-03-expected.txt [new file with mode: 0644]
LayoutTests/editing/inserting/insert-list-in-table-cell-03.html [new file with mode: 0644]
LayoutTests/editing/inserting/insert-list-in-table-cell-04-expected.txt [new file with mode: 0644]
LayoutTests/editing/inserting/insert-list-in-table-cell-04.html [new file with mode: 0644]
LayoutTests/editing/inserting/insert-list-in-table-cell-05-expected.txt [new file with mode: 0644]
LayoutTests/editing/inserting/insert-list-in-table-cell-05.html [new file with mode: 0644]
LayoutTests/editing/inserting/insert-list-in-table-cell-06-expected.txt [new file with mode: 0644]
LayoutTests/editing/inserting/insert-list-in-table-cell-06.html [new file with mode: 0644]
LayoutTests/editing/inserting/insert-list-in-table-cell-07-expected.txt [new file with mode: 0644]
LayoutTests/editing/inserting/insert-list-in-table-cell-07.html [new file with mode: 0644]
LayoutTests/editing/inserting/insert-list-in-table-cell-08-expected.txt [new file with mode: 0644]
LayoutTests/editing/inserting/insert-list-in-table-cell-08.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/editing/CompositeEditCommand.cpp

index c6a6e4e..e4c95b2 100644 (file)
@@ -1,3 +1,30 @@
+2017-07-26  Javier Fernandez  <jfernandez@igalia.com>
+
+        InsertOrderedList command applied to table cells inserts an extra BR before the table
+        https://bugs.webkit.org/show_bug.cgi?id=174593
+
+        Reviewed by Darin Adler.
+
+        Tests to verify that the insertOrderedList command works as expected when applied
+        in table cells.
+
+        * editing/inserting/insert-list-in-table-cell-01.html: Added.
+        * editing/inserting/insert-list-in-table-cell-01-expected.txt: Added.
+        * editing/inserting/insert-list-in-table-cell-02.html: Added.
+        * editing/inserting/insert-list-in-table-cell-02-expected.txt: Added.
+        * editing/inserting/insert-list-in-table-cell-03.html: Added.
+        * editing/inserting/insert-list-in-table-cell-03-expected.txt: Added.
+        * editing/inserting/insert-list-in-table-cell-04.html: Added.
+        * editing/inserting/insert-list-in-table-cell-04-expected.txt: Added.
+        * editing/inserting/insert-list-in-table-cell-05.html: Added.
+        * editing/inserting/insert-list-in-table-cell-05-expected.txt: Added.
+        * editing/inserting/insert-list-in-table-cell-06.html: Added.
+        * editing/inserting/insert-list-in-table-cell-06-expected.txt: Added.
+        * editing/inserting/insert-list-in-table-cell-07.html: Added.
+        * editing/inserting/insert-list-in-table-cell-07-expected.txt: Added.
+        * editing/inserting/insert-list-in-table-cell-08.html: Added.
+        * editing/inserting/insert-list-in-table-cell-08-expected.txt: Added.
+
 2017-07-26  Ms2ger  <Ms2ger@igalia.com>
 
         Fix an incorrect check in 2d.missingargs.html.
diff --git a/LayoutTests/editing/inserting/insert-list-in-table-cell-01-expected.txt b/LayoutTests/editing/inserting/insert-list-in-table-cell-01-expected.txt
new file mode 100644 (file)
index 0000000..658af88
--- /dev/null
@@ -0,0 +1,36 @@
+Insert list items in a single table cell:
+
+Before:
+| <table>
+|   border="1"
+|   <tbody>
+|     <tr>
+|       <td>
+|         id="element"
+|         "<#selection-anchor>fsdf<#selection-focus>"
+|       <td>
+|         "fsdf"
+|     <tr>
+|       <td>
+|         "gghfg"
+|       <td>
+|         "fsfg"
+
+After:
+| <table>
+|   border="1"
+|   <tbody>
+|     <tr>
+|       <td>
+|         id="element"
+|         <ol>
+|           <li>
+|             "<#selection-anchor>fsdf<#selection-focus>"
+|             <br>
+|       <td>
+|         "fsdf"
+|     <tr>
+|       <td>
+|         "gghfg"
+|       <td>
+|         "fsfg"
diff --git a/LayoutTests/editing/inserting/insert-list-in-table-cell-01.html b/LayoutTests/editing/inserting/insert-list-in-table-cell-01.html
new file mode 100644 (file)
index 0000000..378af96
--- /dev/null
@@ -0,0 +1,14 @@
+<!DOCTYPE html>
+<div id="container" contenteditable="true"><table border="1"><tr><td id="element">fsdf</td><td>fsdf</td></tr><tr><td>gghfg</td><td>fsfg</td></tr></table></div>
+<script src="../editing.js"></script>
+<script src="../../resources/dump-as-markup.js"></script>
+<script>
+    Markup.description('Insert list items in a single table cell:');
+
+    var e = document.getElementById("element");
+    setSelectionCommand(e, 0, e, 1);
+    Markup.dump('container', 'Before');
+
+    document.execCommand("insertOrderedList");
+    Markup.dump('container', 'After');
+</script>
diff --git a/LayoutTests/editing/inserting/insert-list-in-table-cell-02-expected.txt b/LayoutTests/editing/inserting/insert-list-in-table-cell-02-expected.txt
new file mode 100644 (file)
index 0000000..598e9a6
--- /dev/null
@@ -0,0 +1,40 @@
+Insert list items in all the cells of a table row:
+
+Before:
+| <table>
+|   border="1"
+|   <tbody>
+|     <tr>
+|       id="element"
+|       <td>
+|         "<#selection-anchor>fsdf"
+|       <td>
+|         "fsdf"
+|     <tr>
+|       <td>
+|         <#selection-focus>
+|         "gghfg"
+|       <td>
+|         "fsfg"
+
+After:
+| <table>
+|   border="1"
+|   <tbody>
+|     <tr>
+|       id="element"
+|       <td>
+|         <ol>
+|           <li>
+|             "<#selection-anchor>fsdf"
+|             <br>
+|       <td>
+|         <ol>
+|           <li>
+|             "fsdf<#selection-focus>"
+|             <br>
+|     <tr>
+|       <td>
+|         "gghfg"
+|       <td>
+|         "fsfg"
diff --git a/LayoutTests/editing/inserting/insert-list-in-table-cell-02.html b/LayoutTests/editing/inserting/insert-list-in-table-cell-02.html
new file mode 100644 (file)
index 0000000..dc87ffb
--- /dev/null
@@ -0,0 +1,14 @@
+<!DOCTYPE html>
+<div id="container" contenteditable="true"><table border="1"><tr id="element"><td>fsdf</td><td>fsdf</td></tr><tr><td>gghfg</td><td>fsfg</td></tr></table></div>
+<script src="../editing.js"></script>
+<script src="../../resources/dump-as-markup.js"></script>
+<script>
+    Markup.description('Insert list items in all the cells of a table row:');
+
+    var e = document.getElementById("element");
+    setSelectionCommand(e, 0, e, 2);
+    Markup.dump('container', 'Before');
+
+    document.execCommand("insertOrderedList");
+    Markup.dump('container', 'After');
+</script>
diff --git a/LayoutTests/editing/inserting/insert-list-in-table-cell-03-expected.txt b/LayoutTests/editing/inserting/insert-list-in-table-cell-03-expected.txt
new file mode 100644 (file)
index 0000000..14d9761
--- /dev/null
@@ -0,0 +1,45 @@
+Insert list items in all the cells of a table:
+
+Before:
+| <table>
+|   border="1"
+|   <tbody>
+|     id="element"
+|     <tr>
+|       <td>
+|         "<#selection-anchor>fsdf"
+|       <td>
+|         "fsdf"
+|     <tr>
+|       <td>
+|         "gghfg"
+|       <td>
+|         "fsfg"
+
+After:
+| <table>
+|   border="1"
+|   <tbody>
+|     id="element"
+|     <tr>
+|       <td>
+|         <ol>
+|           <li>
+|             "<#selection-anchor>fsdf"
+|             <br>
+|       <td>
+|         <ol>
+|           <li>
+|             "fsdf"
+|             <br>
+|     <tr>
+|       <td>
+|         <ol>
+|           <li>
+|             "gghfg"
+|             <br>
+|       <td>
+|         <ol>
+|           <li>
+|             "fsfg<#selection-focus>"
+|             <br>
diff --git a/LayoutTests/editing/inserting/insert-list-in-table-cell-03.html b/LayoutTests/editing/inserting/insert-list-in-table-cell-03.html
new file mode 100644 (file)
index 0000000..2a36d56
--- /dev/null
@@ -0,0 +1,13 @@
+<!DOCTYPE html>
+<div id="container" contenteditable="true"><table border="1"><tbody id="element"><tr><td>fsdf</td><td>fsdf</td></tr><tr><td>gghfg</td><td>fsfg</td></tr></tbody></table></div>
+<script src="../../resources/dump-as-markup.js"></script>
+<script>
+    Markup.description('Insert list items in all the cells of a table:');
+
+    var e = document.getElementById("element");
+    window.getSelection().selectAllChildren(e);
+    Markup.dump('container', 'Before');
+
+    document.execCommand("insertOrderedList");
+    Markup.dump('container', 'After');
+</script>
diff --git a/LayoutTests/editing/inserting/insert-list-in-table-cell-04-expected.txt b/LayoutTests/editing/inserting/insert-list-in-table-cell-04-expected.txt
new file mode 100644 (file)
index 0000000..814179b
--- /dev/null
@@ -0,0 +1,37 @@
+Insert a list item in a table:
+
+Before:
+| <table>
+|   border="1"
+|   id="element"
+|   <tbody>
+|     <tr>
+|       <td>
+|         "fsdf"
+|       <td>
+|         "fsdf"
+|     <tr>
+|       <td>
+|         "gghfg"
+|       <td>
+|         "fsfg"
+
+After:
+| <ol>
+|   <li>
+|     <#selection-anchor>
+|     <table>
+|       border="1"
+|       id="element"
+|       <tbody>
+|         <tr>
+|           <td>
+|             "fsdf"
+|           <td>
+|             "fsdf"
+|         <tr>
+|           <td>
+|             "gghfg"
+|           <td>
+|             "fsfg"
+|     <#selection-focus>
diff --git a/LayoutTests/editing/inserting/insert-list-in-table-cell-04.html b/LayoutTests/editing/inserting/insert-list-in-table-cell-04.html
new file mode 100644 (file)
index 0000000..b2aeffb
--- /dev/null
@@ -0,0 +1,14 @@
+<!DOCTYPE html>
+<div id="container" contenteditable="true"><table border="1" id="element"><tr><td>fsdf</td><td>fsdf</td></tr><tr><td>gghfg</td><td>fsfg</td></tr></table></div>
+<script src="../editing.js"></script>
+<script src="../../resources/dump-as-markup.js"></script>
+<script>
+    Markup.description('Insert a list item in a table:');
+
+    var e = document.getElementById("element");
+    setSelectionCommand(e, 0, e, 2);
+    Markup.dump('container', 'Before');
+
+    document.execCommand("insertOrderedList");
+    Markup.dump('container', 'After');
+</script>
diff --git a/LayoutTests/editing/inserting/insert-list-in-table-cell-05-expected.txt b/LayoutTests/editing/inserting/insert-list-in-table-cell-05-expected.txt
new file mode 100644 (file)
index 0000000..14b5985
--- /dev/null
@@ -0,0 +1,34 @@
+Exec insertOrderedList twice in a single cell of a table row removes the previously inserted list item:
+
+Before:
+| <table>
+|   border="1"
+|   <tbody>
+|     <tr>
+|       <td>
+|         id="element"
+|         "<#selection-anchor>fsdf<#selection-focus>"
+|       <td>
+|         "fsdf"
+|     <tr>
+|       <td>
+|         "gghfg"
+|       <td>
+|         "fsfg"
+
+After:
+| <table>
+|   border="1"
+|   <tbody>
+|     <tr>
+|       <td>
+|         id="element"
+|         "<#selection-anchor>fsdf<#selection-focus>"
+|         <br>
+|       <td>
+|         "fsdf"
+|     <tr>
+|       <td>
+|         "gghfg"
+|       <td>
+|         "fsfg"
diff --git a/LayoutTests/editing/inserting/insert-list-in-table-cell-05.html b/LayoutTests/editing/inserting/insert-list-in-table-cell-05.html
new file mode 100644 (file)
index 0000000..4bbf243
--- /dev/null
@@ -0,0 +1,15 @@
+<!DOCTYPE html>
+<div id="container" contenteditable="true"><table border="1"><tr><td id="element">fsdf</td><td>fsdf</td></tr><tr><td>gghfg</td><td>fsfg</td></tr></table></div>
+<script src="../editing.js"></script>
+<script src="../../resources/dump-as-markup.js"></script>
+<script>
+    Markup.description('Exec insertOrderedList twice in a single cell of a table row removes the previously inserted list item:');
+
+    var e = document.getElementById("element");
+    setSelectionCommand(e, 0, e, 1);
+    Markup.dump('container', 'Before');
+
+    document.execCommand("insertOrderedList");
+    document.execCommand("insertOrderedList");
+    Markup.dump('container', 'After');
+</script>
diff --git a/LayoutTests/editing/inserting/insert-list-in-table-cell-06-expected.txt b/LayoutTests/editing/inserting/insert-list-in-table-cell-06-expected.txt
new file mode 100644 (file)
index 0000000..bd281a6
--- /dev/null
@@ -0,0 +1,36 @@
+Exec insertOrderedList twice in all the cells of a table row removes the previously inserted list items:
+
+Before:
+| <table>
+|   border="1"
+|   <tbody>
+|     <tr>
+|       id="element"
+|       <td>
+|         "<#selection-anchor>fsdf"
+|       <td>
+|         "fsdf"
+|     <tr>
+|       <td>
+|         <#selection-focus>
+|         "gghfg"
+|       <td>
+|         "fsfg"
+
+After:
+| <table>
+|   border="1"
+|   <tbody>
+|     <tr>
+|       id="element"
+|       <td>
+|         "<#selection-anchor>fsdf"
+|         <br>
+|       <td>
+|         "fsdf<#selection-focus>"
+|         <br>
+|     <tr>
+|       <td>
+|         "gghfg"
+|       <td>
+|         "fsfg"
diff --git a/LayoutTests/editing/inserting/insert-list-in-table-cell-06.html b/LayoutTests/editing/inserting/insert-list-in-table-cell-06.html
new file mode 100644 (file)
index 0000000..57886fc
--- /dev/null
@@ -0,0 +1,15 @@
+<!DOCTYPE html>
+<div id="container" contenteditable="true"><table border="1"><tr id="element"><td>fsdf</td><td>fsdf</td></tr><tr><td>gghfg</td><td>fsfg</td></tr></table></div>
+<script src="../editing.js"></script>
+<script src="../../resources/dump-as-markup.js"></script>
+<script>
+    Markup.description('Exec insertOrderedList twice in all the cells of a table row removes the previously inserted list items:');
+
+    var e = document.getElementById("element");
+    setSelectionCommand(e, 0, e, 2);
+    Markup.dump('container', 'Before');
+
+    document.execCommand("insertOrderedList");
+    document.execCommand("insertOrderedList");
+    Markup.dump('container', 'After');
+</script>
diff --git a/LayoutTests/editing/inserting/insert-list-in-table-cell-07-expected.txt b/LayoutTests/editing/inserting/insert-list-in-table-cell-07-expected.txt
new file mode 100644 (file)
index 0000000..88ca40a
--- /dev/null
@@ -0,0 +1,39 @@
+Exec insertOrderedList twice in all the cells of a table removes the previously inserted list items:
+
+Before:
+| <table>
+|   border="1"
+|   <tbody>
+|     id="element"
+|     <tr>
+|       <td>
+|         "<#selection-anchor>fsdf"
+|       <td>
+|         "fsdf"
+|     <tr>
+|       <td>
+|         "gghfg"
+|       <td>
+|         "fsfg"
+|   <tbody>
+
+After:
+| <table>
+|   border="1"
+|   <tbody>
+|     id="element"
+|     <tr>
+|       <td>
+|         "<#selection-anchor>fsdf"
+|         <br>
+|       <td>
+|         "fsdf"
+|         <br>
+|     <tr>
+|       <td>
+|         "gghfg"
+|         <br>
+|       <td>
+|         "fsfg<#selection-focus>"
+|         <br>
+|   <tbody>
diff --git a/LayoutTests/editing/inserting/insert-list-in-table-cell-07.html b/LayoutTests/editing/inserting/insert-list-in-table-cell-07.html
new file mode 100644 (file)
index 0000000..2219002
--- /dev/null
@@ -0,0 +1,14 @@
+<!DOCTYPE html>
+<div id="container" contenteditable="true"><table border="1"><tbody id="element"><tr><td>fsdf</td><td>fsdf</td></tr><tr><td>gghfg</td><td>fsfg</td></tr><tbody></table></div>
+<script src="../../resources/dump-as-markup.js"></script>
+<script>
+    Markup.description('Exec insertOrderedList twice in all the cells of a table removes the previously inserted list items:');
+
+    var e = document.getElementById("element");
+    window.getSelection().selectAllChildren(e);
+    Markup.dump('container', 'Before');
+
+    document.execCommand("insertOrderedList");
+    document.execCommand("insertOrderedList");
+    Markup.dump('container', 'After');
+</script>
diff --git a/LayoutTests/editing/inserting/insert-list-in-table-cell-08-expected.txt b/LayoutTests/editing/inserting/insert-list-in-table-cell-08-expected.txt
new file mode 100644 (file)
index 0000000..7331379
--- /dev/null
@@ -0,0 +1,33 @@
+Exec insertOrderedList twice in a table removes the previously inserted list item:
+
+Before:
+| <table>
+|   border="1"
+|   id="element"
+|   <tbody>
+|     <tr>
+|       <td>
+|         "fsdf"
+|       <td>
+|         "fsdf"
+|     <tr>
+|       <td>
+|         "gghfg"
+|       <td>
+|         "fsfg"
+
+After:
+| <table>
+|   border="1"
+|   id="element"
+|   <tbody>
+|     <tr>
+|       <td>
+|         "fsdf"
+|       <td>
+|         "fsdf"
+|     <tr>
+|       <td>
+|         "gghfg"
+|       <td>
+|         "fsfg<#selection-focus>"
diff --git a/LayoutTests/editing/inserting/insert-list-in-table-cell-08.html b/LayoutTests/editing/inserting/insert-list-in-table-cell-08.html
new file mode 100644 (file)
index 0000000..2e6302f
--- /dev/null
@@ -0,0 +1,15 @@
+<!DOCTYPE html>
+<div id="container" contenteditable="true"><table border="1" id="element"><tr><td>fsdf</td><td>fsdf</td></tr><tr><td>gghfg</td><td>fsfg</td></tr></table></div>
+<script src="../editing.js"></script>
+<script src="../../resources/dump-as-markup.js"></script>
+<script>
+    Markup.description('Exec insertOrderedList twice in a table removes the previously inserted list item:');
+
+    var e = document.getElementById("element");
+    setSelectionCommand(e, 0, e, 2);
+    Markup.dump('container', 'Before');
+
+    document.execCommand("insertOrderedList");
+    document.execCommand("insertOrderedList");
+    Markup.dump('container', 'After');
+</script>
index 0d2849a..b97321d 100644 (file)
@@ -1,3 +1,31 @@
+2017-07-26  Javier Fernandez  <jfernandez@igalia.com>
+
+        InsertOrderedList command applied to table cells inserts an extra BR before the table
+        https://bugs.webkit.org/show_bug.cgi?id=174593
+
+        Reviewed by Darin Adler.
+
+        Don't add BR when pruning empty blocks if it's the start of a paragraph.
+
+        The function MoveParagraph is used for several operations and editing
+        commands, like 'insertOrderedList'. When moving paragraphs we check out
+        whether we should add a 'br' element to avoid undesired block collapse.
+
+        However, we shouldn't do this when destination is the start of a
+        paragraph.
+
+        Tests: editing/inserting/insert-list-in-table-cell-01.html
+               editing/inserting/insert-list-in-table-cell-02.html
+               editing/inserting/insert-list-in-table-cell-03.html
+               editing/inserting/insert-list-in-table-cell-04.html
+               editing/inserting/insert-list-in-table-cell-05.html
+               editing/inserting/insert-list-in-table-cell-06.html
+               editing/inserting/insert-list-in-table-cell-07.html
+               editing/inserting/insert-list-in-table-cell-08.html
+
+        * editing/CompositeEditCommand.cpp:
+        (WebCore::CompositeEditCommand::moveParagraphs):
+
 2017-07-26  Zan Dobersek  <zdobersek@igalia.com>
 
         [WPE] WebGL2 support
index 68574c4..d6fd73c 100644 (file)
@@ -1477,7 +1477,7 @@ void CompositeEditCommand::moveParagraphs(const VisiblePosition& startOfParagrap
     // Must recononicalize these two VisiblePositions after the pruning above.
     beforeParagraph = VisiblePosition(beforeParagraph.deepEquivalent());
     afterParagraph = VisiblePosition(afterParagraph.deepEquivalent());
-    if (beforeParagraph.isNotNull() && (!isEndOfParagraph(beforeParagraph) || beforeParagraph == afterParagraph)) {
+    if (beforeParagraph.isNotNull() && ((!isStartOfParagraph(beforeParagraph) && !isEndOfParagraph(beforeParagraph)) || beforeParagraph == afterParagraph)) {
         // FIXME: Trim text between beforeParagraph and afterParagraph if they aren't equal.
         insertNodeAt(HTMLBRElement::create(document()), beforeParagraph.deepEquivalent());
         // Need an updateLayout here in case inserting the br has split a text node.