Bug 1542521 - Join blocks with empty elements in between r=masayuki
authorKagami Sascha Rosylight <saschanaz@outlook.com>
Wed, 18 Mar 2020 15:42:05 +0000
changeset 519417 9526f24bab2b9a3fa23f23227cf5c10169bfbb95
parent 519416 019ce96ad0f678285d537f5046c44896915b396e
child 519418 29444a6692c2dd8c6dcf9ed2719c19f663e436bf
push id110488
push userccoroiu@mozilla.com
push dateWed, 18 Mar 2020 15:52:23 +0000
treeherderautoland@9526f24bab2b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmasayuki
bugs1542521
milestone76.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1542521 - Join blocks with empty elements in between r=masayuki Differential Revision: https://phabricator.services.mozilla.com/D67076
editor/libeditor/HTMLEditSubActionHandler.cpp
testing/web-platform/meta/editing/run/delete.html.ini
testing/web-platform/meta/editing/run/forwarddelete.html.ini
testing/web-platform/tests/editing/data/delete.js
testing/web-platform/tests/editing/data/forwarddelete.js
--- a/editor/libeditor/HTMLEditSubActionHandler.cpp
+++ b/editor/libeditor/HTMLEditSubActionHandler.cpp
@@ -3211,19 +3211,23 @@ EditActionResult HTMLEditor::HandleDelet
             "DeleteElementsExceptTableRelatedElements() failed, but ignored");
         // If something visible is deleted, no need to join.  Visible means
         // all nodes except non-visible textnodes and breaks.
         // XXX Odd.  Why do we check the visibility after removing the node
         //     from the DOM tree?
         if (join && aSelectionWasCollapsed == SelectionWasCollapsed::Yes) {
           if (Text* text = content->GetAsText()) {
             join = !IsInVisibleTextFrames(*text);
-          } else {
-            join = content->IsHTMLElement(nsGkAtoms::br) &&
-                   !IsVisibleBRElement(content);
+          } else if (content->IsElement()) {
+            if (IsEmptyNode(*content->AsElement())) {
+              join = true;
+            } else {
+              join = content->IsHTMLElement(nsGkAtoms::br) &&
+                     !IsVisibleBRElement(content);
+            }
           }
         }
       }
     }
 
     // Check endpoints for possible text deletion.  We can assume that if
     // text node is found, we can delete to end or to begining as
     // appropriate, since the case where both sel endpoints in same text
--- a/testing/web-platform/meta/editing/run/delete.html.ini
+++ b/testing/web-platform/meta/editing/run/delete.html.ini
@@ -839,16 +839,28 @@
     expected: FAIL
 
   [[["delete",""\]\] "<b>[foo\]</b>" compare innerHTML]
     expected: FAIL
 
   [[["delete",""\]\] "<div><b>[foo\]</b></div>" compare innerHTML]
     expected: FAIL
 
+  [[["delete",""\]\] "<div><div><p>foo</p></div></div><div></div><div><div>[\]bar</div></div></div>" compare innerHTML]
+    expected: FAIL
+
+  [[["delete",""\]\] "<div>foo</div><div></div><div>[\]bar</div>" compare innerHTML]
+    expected: FAIL
+
+  [[["delete",""\]\] "<div>foo</div><span></span><div>[\]bar</div>" compare innerHTML]
+    expected: FAIL
+
+  [[["delete",""\]\] "<div>foo</div><!-- comment --><div>[\]bar</div>" compare innerHTML]
+    expected: FAIL
+
 
 [delete.html?1001-2000]
   [[["delete",""\]\] "<div style=white-space:pre-wrap>foo&nbsp; [\]bar</div>" compare innerHTML]
     expected: FAIL
 
   [[["delete",""\]\] "<div style=white-space:pre-line>foo &nbsp;[\]</div>" compare innerHTML]
     expected: FAIL
 
--- a/testing/web-platform/meta/editing/run/forwarddelete.html.ini
+++ b/testing/web-platform/meta/editing/run/forwarddelete.html.ini
@@ -229,70 +229,16 @@
     expected: FAIL
 
   [[["defaultparagraphseparator","div"\],["forwarddelete",""\]\] "foo[\]<!--abc--><div><div><p>bar</div></div>" compare innerHTML]
     expected: FAIL
 
   [[["defaultparagraphseparator","p"\],["forwarddelete",""\]\] "foo[\]<!--abc--><div><div><p>bar</div></div>" compare innerHTML]
     expected: FAIL
 
-  [[["forwarddelete",""\]\] "<div><div><p>foo[\]</div></div><!--abc-->bar" compare innerHTML]
-    expected: FAIL
-
-  [[["forwarddelete",""\]\] "<div><div><p>foo[\]</div><!--abc--></div>bar" compare innerHTML]
-    expected: FAIL
-
-  [[["forwarddelete",""\]\] "<div><div><p>foo[\]</p><!--abc--></div></div>bar" compare innerHTML]
-    expected: FAIL
-
-  [[["forwarddelete",""\]\] "<div><div><p>foo[\]<!--abc--></div></div>bar" compare innerHTML]
-    expected: FAIL
-
-  [[["defaultparagraphseparator","div"\],["forwarddelete",""\]\] "<div><div><p>foo[\]<!--abc--></p></div></div><div><div><div>bar</div></div></div>" compare innerHTML]
-    expected: FAIL
-
-  [[["defaultparagraphseparator","p"\],["forwarddelete",""\]\] "<div><div><p>foo[\]<!--abc--></p></div></div><div><div><div>bar</div></div></div>" compare innerHTML]
-    expected: FAIL
-
-  [[["defaultparagraphseparator","div"\],["forwarddelete",""\]\] "<div><div><p>foo[\]</p><!--abc--></div></div><div><div><div>bar</div></div></div>" compare innerHTML]
-    expected: FAIL
-
-  [[["defaultparagraphseparator","p"\],["forwarddelete",""\]\] "<div><div><p>foo[\]</p><!--abc--></div></div><div><div><div>bar</div></div></div>" compare innerHTML]
-    expected: FAIL
-
-  [[["defaultparagraphseparator","div"\],["forwarddelete",""\]\] "<div><div><p>foo[\]</p></div><!--abc--></div><div><div><div>bar</div></div></div>" compare innerHTML]
-    expected: FAIL
-
-  [[["defaultparagraphseparator","p"\],["forwarddelete",""\]\] "<div><div><p>foo[\]</p></div><!--abc--></div><div><div><div>bar</div></div></div>" compare innerHTML]
-    expected: FAIL
-
-  [[["defaultparagraphseparator","div"\],["forwarddelete",""\]\] "<div><div><p>foo[\]</p></div></div><!--abc--><div><div><div>bar</div></div></div>" compare innerHTML]
-    expected: FAIL
-
-  [[["defaultparagraphseparator","p"\],["forwarddelete",""\]\] "<div><div><p>foo[\]</p></div></div><!--abc--><div><div><div>bar</div></div></div>" compare innerHTML]
-    expected: FAIL
-
-  [[["defaultparagraphseparator","div"\],["forwarddelete",""\]\] "<div><div><p>foo[\]</p></div></div><div><!--abc--><div><div>bar</div></div></div>" compare innerHTML]
-    expected: FAIL
-
-  [[["defaultparagraphseparator","p"\],["forwarddelete",""\]\] "<div><div><p>foo[\]</p></div></div><div><!--abc--><div><div>bar</div></div></div>" compare innerHTML]
-    expected: FAIL
-
-  [[["defaultparagraphseparator","div"\],["forwarddelete",""\]\] "<div><div><p>foo[\]</p></div></div><div><div><!--abc--><div>bar</div></div></div>" compare innerHTML]
-    expected: FAIL
-
-  [[["defaultparagraphseparator","p"\],["forwarddelete",""\]\] "<div><div><p>foo[\]</p></div></div><div><div><!--abc--><div>bar</div></div></div>" compare innerHTML]
-    expected: FAIL
-
-  [[["defaultparagraphseparator","div"\],["forwarddelete",""\]\] "<div><div><p>foo[\]</p></div></div><div><div><div><!--abc-->bar</div></div></div>" compare innerHTML]
-    expected: FAIL
-
-  [[["defaultparagraphseparator","p"\],["forwarddelete",""\]\] "<div><div><p>foo[\]</p></div></div><div><div><div><!--abc-->bar</div></div></div>" compare innerHTML]
-    expected: FAIL
-
   [[["stylewithcss","true"\],["defaultparagraphseparator","div"\],["forwarddelete",""\]\] "<p style=color:blue>foo[\]<p>bar" compare innerHTML]
     expected: FAIL
 
   [[["stylewithcss","false"\],["defaultparagraphseparator","div"\],["forwarddelete",""\]\] "<p style=color:blue>foo[\]<p>bar" compare innerHTML]
     expected: FAIL
 
   [[["stylewithcss","true"\],["defaultparagraphseparator","p"\],["forwarddelete",""\]\] "<p style=color:blue>foo[\]<p>bar" compare innerHTML]
     expected: FAIL
@@ -1084,70 +1030,16 @@
     expected: FAIL
 
   [[["defaultparagraphseparator","div"\],["forwarddelete",""\]\] "foo[\]<!--abc--><div><div><p>bar</div></div>" compare innerHTML]
     expected: FAIL
 
   [[["defaultparagraphseparator","p"\],["forwarddelete",""\]\] "foo[\]<!--abc--><div><div><p>bar</div></div>" compare innerHTML]
     expected: FAIL
 
-  [[["forwarddelete",""\]\] "<div><div><p>foo[\]</div></div><!--abc-->bar" compare innerHTML]
-    expected: FAIL
-
-  [[["forwarddelete",""\]\] "<div><div><p>foo[\]</div><!--abc--></div>bar" compare innerHTML]
-    expected: FAIL
-
-  [[["forwarddelete",""\]\] "<div><div><p>foo[\]</p><!--abc--></div></div>bar" compare innerHTML]
-    expected: FAIL
-
-  [[["forwarddelete",""\]\] "<div><div><p>foo[\]<!--abc--></div></div>bar" compare innerHTML]
-    expected: FAIL
-
-  [[["defaultparagraphseparator","div"\],["forwarddelete",""\]\] "<div><div><p>foo[\]<!--abc--></p></div></div><div><div><div>bar</div></div></div>" compare innerHTML]
-    expected: FAIL
-
-  [[["defaultparagraphseparator","p"\],["forwarddelete",""\]\] "<div><div><p>foo[\]<!--abc--></p></div></div><div><div><div>bar</div></div></div>" compare innerHTML]
-    expected: FAIL
-
-  [[["defaultparagraphseparator","div"\],["forwarddelete",""\]\] "<div><div><p>foo[\]</p><!--abc--></div></div><div><div><div>bar</div></div></div>" compare innerHTML]
-    expected: FAIL
-
-  [[["defaultparagraphseparator","p"\],["forwarddelete",""\]\] "<div><div><p>foo[\]</p><!--abc--></div></div><div><div><div>bar</div></div></div>" compare innerHTML]
-    expected: FAIL
-
-  [[["defaultparagraphseparator","div"\],["forwarddelete",""\]\] "<div><div><p>foo[\]</p></div><!--abc--></div><div><div><div>bar</div></div></div>" compare innerHTML]
-    expected: FAIL
-
-  [[["defaultparagraphseparator","p"\],["forwarddelete",""\]\] "<div><div><p>foo[\]</p></div><!--abc--></div><div><div><div>bar</div></div></div>" compare innerHTML]
-    expected: FAIL
-
-  [[["defaultparagraphseparator","div"\],["forwarddelete",""\]\] "<div><div><p>foo[\]</p></div></div><!--abc--><div><div><div>bar</div></div></div>" compare innerHTML]
-    expected: FAIL
-
-  [[["defaultparagraphseparator","p"\],["forwarddelete",""\]\] "<div><div><p>foo[\]</p></div></div><!--abc--><div><div><div>bar</div></div></div>" compare innerHTML]
-    expected: FAIL
-
-  [[["defaultparagraphseparator","div"\],["forwarddelete",""\]\] "<div><div><p>foo[\]</p></div></div><div><!--abc--><div><div>bar</div></div></div>" compare innerHTML]
-    expected: FAIL
-
-  [[["defaultparagraphseparator","p"\],["forwarddelete",""\]\] "<div><div><p>foo[\]</p></div></div><div><!--abc--><div><div>bar</div></div></div>" compare innerHTML]
-    expected: FAIL
-
-  [[["defaultparagraphseparator","div"\],["forwarddelete",""\]\] "<div><div><p>foo[\]</p></div></div><div><div><!--abc--><div>bar</div></div></div>" compare innerHTML]
-    expected: FAIL
-
-  [[["defaultparagraphseparator","p"\],["forwarddelete",""\]\] "<div><div><p>foo[\]</p></div></div><div><div><!--abc--><div>bar</div></div></div>" compare innerHTML]
-    expected: FAIL
-
-  [[["defaultparagraphseparator","div"\],["forwarddelete",""\]\] "<div><div><p>foo[\]</p></div></div><div><div><div><!--abc-->bar</div></div></div>" compare innerHTML]
-    expected: FAIL
-
-  [[["defaultparagraphseparator","p"\],["forwarddelete",""\]\] "<div><div><p>foo[\]</p></div></div><div><div><div><!--abc-->bar</div></div></div>" compare innerHTML]
-    expected: FAIL
-
   [[["stylewithcss","true"\],["defaultparagraphseparator","div"\],["forwarddelete",""\]\] "<p style=color:blue>foo[\]<p>bar" compare innerHTML]
     expected: FAIL
 
   [[["stylewithcss","false"\],["defaultparagraphseparator","div"\],["forwarddelete",""\]\] "<p style=color:blue>foo[\]<p>bar" compare innerHTML]
     expected: FAIL
 
   [[["stylewithcss","true"\],["defaultparagraphseparator","p"\],["forwarddelete",""\]\] "<p style=color:blue>foo[\]<p>bar" compare innerHTML]
     expected: FAIL
--- a/testing/web-platform/tests/editing/data/delete.js
+++ b/testing/web-platform/tests/editing/data/delete.js
@@ -2469,10 +2469,30 @@ var browserTests = [
     [["delete",""]],
     "<b>{}<br></b>",
     [true],
     {"delete":[false,false,"",false,false,""]}],
 ["<div><b>[foo]</b></div>",
     [["delete",""]],
     "<div><b>{}<br></b></div>",
     [true],
+    {"delete":[false,false,"",false,false,""]}],
+["<div><div><p>foo</p></div></div><div></div><div><div>[]bar</div></div></div>",
+    [["delete",""]],
+    "<div><div><p>foobar</p></div></div>",
+    [true],
+    {"delete":[false,false,"",false,false,""]}],
+["<div>foo</div><div></div><div>[]bar</div>",
+    [["delete",""]],
+    "<div>foobar</div>",
+    [true],
+    {"delete":[false,false,"",false,false,""]}],
+["<div>foo</div><span></span><div>[]bar</div>",
+    [["delete",""]],
+    "<div>foobar</div>",
+    [true],
+    {"delete":[false,false,"",false,false,""]}],
+["<div>foo</div><!-- comment --><div>[]bar</div>",
+    [["delete",""]],
+    "<div>foobar</div>",
+    [true],
     {"delete":[false,false,"",false,false,""]}]
 ]
--- a/testing/web-platform/tests/editing/data/forwarddelete.js
+++ b/testing/web-platform/tests/editing/data/forwarddelete.js
@@ -2354,10 +2354,30 @@ var browserTests = [
     [["forwarddelete",""]],
     "<b>{}<br></b>",
     [true],
     {"forwarddelete":[false,false,"",false,false,""]}],
 ["<div><b>[foo]</b></div>",
     [["forwarddelete",""]],
     "<div><b>{}<br></b></div>",
     [true],
+    {"forwarddelete":[false,false,"",false,false,""]}],
+["<div><div><p>foo[]</p></div></div><div></div><div><div>bar</div></div></div>",
+    [["forwarddelete",""]],
+    "<div><div><p>foobar</p></div></div>",
+    [true],
+    {"forwarddelete":[false,false,"",false,false,""]}],
+["<div>foo[]</div><div></div><div>bar</div>",
+    [["forwarddelete",""]],
+    "<div>foobar</div>",
+    [true],
+    {"forwarddelete":[false,false,"",false,false,""]}],
+["<div>foo[]</div><span></span><div>bar</div>",
+    [["forwarddelete",""]],
+    "<div>foobar</div>",
+    [true],
+    {"forwarddelete":[false,false,"",false,false,""]}],
+["<div>foo[]</div><!-- comment --><div>bar</div>",
+    [["forwarddelete",""]],
+    "<div>foobar</div>",
+    [true],
     {"forwarddelete":[false,false,"",false,false,""]}]
 ]