From 1db0e4c6e5232cc7d5bb57d2ab92535884421f39 Mon Sep 17 00:00:00 2001 From: Masayuki Nakano Date: Fri, 21 Oct 2022 06:05:00 +0000 Subject: [PATCH] Make `AutoEmptyBlockAncestorDeleter::GetNewCaretPosition` always return a valid point if succeeded The testcase is tricky. It creates 2 `Selection` ranges, one is collapsed at end of the ``, the other is collapsed in the new `

` element. The first one is ignored by delete handler since Gecko does not allow to edit outside `` for now. Then, deleting non-collapsed selection ranges tries to delete empty parent blocks at the remaining collapsed selection range in the `

`. At this time, it works with `nsIEditor::eNone`. Then, its `GetNewCaretPosition` does not return a valid point. Then, the `Run` does not remove the `Selection` range outside the ``. Therefore, `HTMLEditor::DeleteSelectionAndPrepareToCreateNode()` will see 2 ranges, then, hit the assertion. Although there are some other cases which meet 2 or more `Selection` ranges after deletion in `DeleteSelectionAndPrepareToCreateNode`, but for now, we should make `AutoEmptyBlockAncestorDeleter::Run` collapse `Selection` when it deletes empty ancestors. Differential Revision: https://phabricator.services.mozilla.com/D159581 bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1699256 gecko-commit: c3323ac610b4b181872b46030ff084d5f6d6023a gecko-reviewers: m_kato --- ...ection-ranges-and-one-is-outside-body.html | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 editing/crashtests/inserthorizontalrule-with-2-selection-ranges-and-one-is-outside-body.html diff --git a/editing/crashtests/inserthorizontalrule-with-2-selection-ranges-and-one-is-outside-body.html b/editing/crashtests/inserthorizontalrule-with-2-selection-ranges-and-one-is-outside-body.html new file mode 100644 index 00000000000000..d248c333d940ff --- /dev/null +++ b/editing/crashtests/inserthorizontalrule-with-2-selection-ranges-and-one-is-outside-body.html @@ -0,0 +1,19 @@ + + + + + + +