Skip to content

Commit

Permalink
Bug 1949901 - Hide selection changes from web apps which are caused b…
Browse files Browse the repository at this point in the history
…y 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
  • Loading branch information
masayuki-nakano committed Feb 27, 2025
1 parent f087b2a commit 8caf547
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
4 changes: 4 additions & 0 deletions editor/libeditor/HTMLEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<script>
"use strict";

addEventListener("DOMContentLoaded", () => {
document.addEventListener("selectstart", () => {
window.find("A");
document.body.prepend(document.getElementById("br"));
});
document.querySelector("picture").addEventListener("focusin", () => {
document.body.prepend(document.getElementById("br"));
});
document.execCommand("selectAll");
}, {once: true});
</script>
</head>
<body>
A
<picture>
<keygen tabindex="-1" autofocus>
<q contenteditable>
A
<br id="br">
<table></table>
</q>
</picture>
</body>
</html>

0 comments on commit 8caf547

Please sign in to comment.