gecko-dev/editor
Masayuki Nakano 398b556e90 Bug 1877513 - Make HTMLEditor deletes only preceding lines of right child block if the range starts from start of a line r=m_kato
Currently, the editor of Gecko always unwraps first line of the right child
block after deleting selected range when the range starts in a parent block
and ends in a child block.  This behavior is almost same as the other browsers,
but the other browsers deletes only preceding lines of the right child block
(i.e., without unwrapping the first line of the right child block) if the range
starts from start of a preceding line, for example, when deleting
`<div>abc<br>[def<p>g]hi<br>jkl`, Gecko moves "hi" to the parent `<div>`,
but the other browsers keeps it in the child `<p>`.

For emulating this special handling, we need to touch 2 paths.

One is `Backspace` when selection is collapsed at start of the child block.  In
this case, only when the preceding line is empty, i.e., there are 2 line breaks
(either `<br>` or `\n` in `white-space: pre-*`), the following break should
be deleted, but the child block should not be touched.

The other is, deleting when selection is not collapsed or `Delete` when
selection is collapsed at immediately before the child block.  In the latter
case, `HTMLEditor::HandleDeleteSelection` extends `Selection` using
`nsFrameSelection`.  Then, handle it with same path as deleting non-collapsed
range.

The former is handled with `HandleDeleteLineBreak` and
`ComputeRangeToDeleteLineBreak`.  The latter is handled with
`HandleDeleteNonCollapsedRange` and `ComputeRangeToDeleteNonCollapsedRange`.
The new handlers use the `ComputeRangeToDelete*`.  Therefore, `beforeinput`
reports exactly same range from `getTargetRanges`.  However, existing paths
do not use same approach and this patch makes `HandleDeleteNonCollapsedRange`
fall it back to `HandleDeleteNonCollapsedRange`.  Therefore, some `if` checks
in `HandleDeleteNonCollapsedRange` are ugly, but I have no better idea to
implement this smarter.

Differential Revision: https://phabricator.services.mozilla.com/D207690
2024-04-27 00:36:26 +00:00
..
composer Bug 1864896: Autofix unused function arguments (editor). r=masayuki 2024-03-01 18:28:33 +00:00
docs Bug 1842986 - Remove dom.forms.inputmode pref r=emilio 2023-09-15 16:49:21 +00:00
libeditor Bug 1877513 - Make HTMLEditor deletes only preceding lines of right child block if the range starts from start of a line r=m_kato 2024-04-27 00:36:26 +00:00
reftests Bug 1879538 - cleanup unnecessary and redundant reftest conditions. r=aryx,jgilbert 2024-02-22 23:04:45 +00:00
spellchecker Bug 1864896: Autofix unused function arguments (editor). r=masayuki 2024-03-01 18:28:33 +00:00
txmgr Bug 1856795 - Remove redundant member init r=emilio 2023-10-15 15:29:02 +00:00
AsyncSpellCheckTestHelper.sys.mjs Bug 1864896: Autofix unused function arguments (editor). r=masayuki 2024-03-01 18:28:33 +00:00
moz.build
nsIDocumentStateListener.idl
nsIEditActionListener.idl Bug 1859245 - part 3: Make JoinNodesTransaction and SplitNodeTransaction handle only the new direction mode r=m_kato 2023-10-27 01:57:29 +00:00
nsIEditor.idl Bug 1764895 - part 3: Get rid of nsIEditor.setShouldTxnSetSelection r=m_kato DONTBUILD 2023-12-14 00:41:20 +00:00
nsIEditorMailSupport.idl Bug 1839814 - Move nsIEditor.wrapWidth to nsIEditorMailSupport r=m_kato 2023-06-27 05:47:55 +00:00
nsIEditorSpellCheck.idl
nsIHTMLAbsPosEditor.idl
nsIHTMLEditor.idl Bug 1851951 - Make HTMLEditor refer computed display instead of the HTML default style at considering block or inline element r=m_kato 2023-09-27 03:01:26 +00:00
nsIHTMLInlineTableEditor.idl
nsIHTMLObjectResizer.idl
nsITableEditor.idl