Closed Bug 2003973 Opened 29 days ago Closed 21 days ago

Make `HTMLEditor` handle `Selection` in replaced element and void element stricter

Categories

(Core :: DOM: Editor, defect)

defect

Tracking

()

RESOLVED FIXED
148 Branch
Tracking Status
firefox148 --- fixed

People

(Reporter: masayuki, Assigned: masayuki)

References

(Blocks 2 open bugs, Regressed 1 open bug)

Details

Attachments

(1 file)

Although it's non-realistic edge cases though, we should handle the cases stricter than now. E.g., we do special handling only for <select> in some cases.

Currently, we do something special only for <select>, <option>
and <optgroup>. However, we should treat replaced elements and
void elements more consistently.

This patch adds new HTMLEditUtils methods to check them easier and
stricter and get the root node of them because DOM API can make invalid
tree even in a void element.

Then, we should handle insertions before the replaced or the void
element if selection range is collapsed in it. However, deletion should
not be handled for that if the range is completely in such element.
Additionally, if range boundary is in such element, we should adjust
the range not to include such element since it's not fully selected
so that shouldn't be deleted nor replaced. These rules are basically
compatible with Chrome.

Finally, if such element is completely hidden, such elements should be
deleted silently with deleting surrounding content if collapsed next to
one. However, this does not work well with a Backspace key press even
after applying this patch.

Finally, some tests of editing-around-select-element.tentative.html
start failing. The reason is, this patch makes the surrounding block
boundary of <select> with adjusting the selection range and that makes
<select> moved into another parent. At this time, the <select>
gets style="white-space: nowrap". I'm not sure where did this but
not a critical failures. Therefore, this patch contains this
regression.

Pushed by masayuki@d-toybox.com: https://github.com/mozilla-firefox/firefox/commit/bd3adf283792 https://hg.mozilla.org/integration/autoland/rev/d1207d4661e5 Make `HTMLEditor` check whether selection is in a replaced or a void element stricter r=m_kato
Created web-platform-tests PR https://github.com/web-platform-tests/wpt/pull/56710 for changes under testing/web-platform/tests
Status: ASSIGNED → RESOLVED
Closed: 21 days ago
Resolution: --- → FIXED
Target Milestone: --- → 148 Branch
Upstream PR merged by moz-wptsync-bot
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: