github web-platform-tests/wpt merge_pr_45926

latest releases: merge_pr_49470, epochs/three_hourly/2024-12-03_06H, epochs/six_hourly/2024-12-03_06H...
9 months ago

Make HTMLEditor deletes only preceding lines of right child block if the range starts from start of a line

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

bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1877513
gecko-commit: 6358e2178e1cc230231dfafae781311fe035a64c
gecko-reviewers: m_kato

Don't miss a new wpt release

NewReleases is sending notifications on new releases.