Title: [269136] trunk
Revision
269136
Author
[email protected]
Date
2020-10-28 20:53:02 -0700 (Wed, 28 Oct 2020)

Log Message

REGRESSION(r267329): Crash in VisibleSelection::toNormalizedRange()
https://bugs.webkit.org/show_bug.cgi?id=218276

Reviewed by Wenson Hsieh.

Source/WebCore:

The crash was a symptom of the issue that m_extent or m_base could be null but not the other
when canonicalizing a non-null Position with VisiblePosition will make it null.

Fixed the bug by making sure base and extent's nullness match.

Test: editing/selection/delete-selection-with-disconnected-extent.html

* editing/VisibleSelection.cpp:
(WebCore::VisibleSelection::setBaseAndExtentToDeepEquivalents):

LayoutTests:

Added a regression test and rebaselined the test now that we got the pre-r267329 behavior back.

* editing/execCommand/insert-list-nested-with-orphaned-expected.txt: Reverted the rebaseline in r267329.
* editing/selection/delete-selection-with-disconnected-extent-expected.txt: Added.
* editing/selection/delete-selection-with-disconnected-extent.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (269135 => 269136)


--- trunk/LayoutTests/ChangeLog	2020-10-29 02:58:43 UTC (rev 269135)
+++ trunk/LayoutTests/ChangeLog	2020-10-29 03:53:02 UTC (rev 269136)
@@ -1,3 +1,16 @@
+2020-10-28  Ryosuke Niwa  <[email protected]>
+
+        REGRESSION(r267329): Crash in VisibleSelection::toNormalizedRange()
+        https://bugs.webkit.org/show_bug.cgi?id=218276
+
+        Reviewed by Wenson Hsieh.
+
+        Added a regression test and rebaselined the test now that we got the pre-r267329 behavior back.
+
+        * editing/execCommand/insert-list-nested-with-orphaned-expected.txt: Reverted the rebaseline in r267329.
+        * editing/selection/delete-selection-with-disconnected-extent-expected.txt: Added.
+        * editing/selection/delete-selection-with-disconnected-extent.html: Added.
+
 2020-10-28  Carlos Alberto Lopez Perez  <[email protected]>
 
         [GTK][WPE] Rebaseline of tests and gardening of failures.

Modified: trunk/LayoutTests/editing/execCommand/insert-list-nested-with-orphaned-expected.txt (269135 => 269136)


--- trunk/LayoutTests/editing/execCommand/insert-list-nested-with-orphaned-expected.txt	2020-10-29 02:58:43 UTC (rev 269135)
+++ trunk/LayoutTests/editing/execCommand/insert-list-nested-with-orphaned-expected.txt	2020-10-29 03:53:02 UTC (rev 269136)
@@ -17,7 +17,7 @@
         "
 |     <ol>
 |       <li>
-|         "because of you"
+|         "<#selection-caret>because of you"
 |   "
     "
 | "

Added: trunk/LayoutTests/editing/selection/delete-selection-with-disconnected-extent-expected.txt (0 => 269136)


--- trunk/LayoutTests/editing/selection/delete-selection-with-disconnected-extent-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/editing/selection/delete-selection-with-disconnected-extent-expected.txt	2020-10-29 03:53:02 UTC (rev 269136)
@@ -0,0 +1,3 @@
+This tests invoking deletion after attempting to extend selection to a disconnected node. WebKit should not crash.
+
+PASS.

Added: trunk/LayoutTests/editing/selection/delete-selection-with-disconnected-extent.html (0 => 269136)


--- trunk/LayoutTests/editing/selection/delete-selection-with-disconnected-extent.html	                        (rev 0)
+++ trunk/LayoutTests/editing/selection/delete-selection-with-disconnected-extent.html	2020-10-29 03:53:02 UTC (rev 269136)
@@ -0,0 +1,15 @@
+<!DOCTYPE html>
+<script>
+function runTest() {
+    if (window.testRunner)
+        testRunner.dumpAsText();
+
+    document.querySelector('input').setRangeText('aa', 0, 1, 'end');
+    getSelection().extend(document.createElement('select'));
+    document.execCommand('delete', false);
+
+    document.body.innerHTML = `<p>This tests invoking deletion after attempting to extend selection to a disconnected node. WebKit should not crash.</p>PASS.`;
+}
+</script>
+<body _onload_=runTest()>
+<input>

Modified: trunk/Source/WebCore/ChangeLog (269135 => 269136)


--- trunk/Source/WebCore/ChangeLog	2020-10-29 02:58:43 UTC (rev 269135)
+++ trunk/Source/WebCore/ChangeLog	2020-10-29 03:53:02 UTC (rev 269136)
@@ -1,3 +1,20 @@
+2020-10-28  Ryosuke Niwa  <[email protected]>
+
+        REGRESSION(r267329): Crash in VisibleSelection::toNormalizedRange()
+        https://bugs.webkit.org/show_bug.cgi?id=218276
+
+        Reviewed by Wenson Hsieh.
+
+        The crash was a symptom of the issue that m_extent or m_base could be null but not the other
+        when canonicalizing a non-null Position with VisiblePosition will make it null.
+
+        Fixed the bug by making sure base and extent's nullness match.
+
+        Test: editing/selection/delete-selection-with-disconnected-extent.html
+
+        * editing/VisibleSelection.cpp:
+        (WebCore::VisibleSelection::setBaseAndExtentToDeepEquivalents):
+
 2020-10-28  Chris Dumez  <[email protected]>
 
         Web Audio broken on iOS 14 after switching app

Modified: trunk/Source/WebCore/editing/VisibleSelection.cpp (269135 => 269136)


--- trunk/Source/WebCore/editing/VisibleSelection.cpp	2020-10-29 02:58:43 UTC (rev 269135)
+++ trunk/Source/WebCore/editing/VisibleSelection.cpp	2020-10-29 03:53:02 UTC (rev 269136)
@@ -232,6 +232,12 @@
         m_extent = m_base;
     else
         m_extent = VisiblePosition(m_focus, m_affinity).deepEquivalent();
+    if (m_base.isNull() != m_extent.isNull()) {
+        if (m_base.isNull())
+            m_base = m_extent;
+        else
+            m_extent = m_base;
+    }
 }
 
 void VisibleSelection::adjustSelectionRespectingGranularity(TextGranularity granularity)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to