From 8caf547b2d9b4bc6fc5d59b147589b4c53db5f5e Mon Sep 17 00:00:00 2001 From: Masayuki Nakano Date: Thu, 27 Feb 2025 08:07:10 +0000 Subject: [PATCH] Bug 1949901 - Hide selection changes from web apps which are caused by the hacks of `HTMLEditor` r=m_kato The hacks are only for specific web apps. Therefore, unless they require to know the selection changes, we don't need to expose that. Differential Revision: https://phabricator.services.mozilla.com/D239835 --- editor/libeditor/HTMLEditor.cpp | 4 +++ ...ll-and-move-editable-br-onselectstart.html | 31 +++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 testing/web-platform/tests/editing/crashtests/selectall-and-move-editable-br-onselectstart.html diff --git a/editor/libeditor/HTMLEditor.cpp b/editor/libeditor/HTMLEditor.cpp index 1ef51e23ffdf72..6f12787c6aa569 100644 --- a/editor/libeditor/HTMLEditor.cpp +++ b/editor/libeditor/HTMLEditor.cpp @@ -7760,6 +7760,10 @@ nsresult HTMLEditor::OnModifyDocument(const DocumentModifiedEvent& aRunner) { nsAutoScriptBlockerSuppressNodeRemoved scriptBlocker; if (!StaticPrefs::editor_white_space_normalization_blink_compatible()) { + // Selection changes caused by the hacks below should not be exposed because + // they should occur silently from web apps. + AutoHideSelectionChanges hideSelectionChangesCausedByTheHacks( + SelectionRef()); // When this is called, there is no toplevel edit sub-action. Then, // InsertNodeWithTransaction() or ReplaceTextWithTransaction() will set it. // Then, OnEndHandlingTopLevelEditSubActionInternal() will call diff --git a/testing/web-platform/tests/editing/crashtests/selectall-and-move-editable-br-onselectstart.html b/testing/web-platform/tests/editing/crashtests/selectall-and-move-editable-br-onselectstart.html new file mode 100644 index 00000000000000..bc25fdf7e01384 --- /dev/null +++ b/testing/web-platform/tests/editing/crashtests/selectall-and-move-editable-br-onselectstart.html @@ -0,0 +1,31 @@ + + + + + + + + A + + + + A +
+
+
+
+ +