Closed Bug 1802668 Opened 1 year ago Closed 1 year ago

HTMLEditor should not use existing `<strong>`, `<em>` and `<s>` as alternative container when styling node is a sibling of existing one

Categories

(Core :: DOM: Editor, defect, P2)

defect

Tracking

()

RESOLVED FIXED
109 Branch
Tracking Status
firefox109 --- fixed

People

(Reporter: masayuki, Assigned: masayuki)

References

Details

Attachments

(3 files)

The other browsers do not use existing <strong>, <em> and <s> as alternative container of styling text node when they are siblings. E.g., execCommand("bold") for ab[c]<strong>def</strong> becomes ab<strong>cdef</strong> in Gecko but becomes ab<b>c</b><strong>def</strong> in the others.

However, they are treated as conflict element at removing. E.g., execCommand("bold") for <strong>a[b]c</strong should make it <strong>a</strong>b<strong>c</strong> rather than <strong>a<b>b</b>c</strong> nor <strong>a</strong><b>b</b><strong>c</strong>.

I think that the tests were based on Gecko's behavior (and strikethrough.js
expects <s> as default container of execCommand("strikethrough") but all
browsers use <strike>, I guess that the original test author was confused).
Blink and WebKit don't use near these elements as existing container of
alternatives of <b>, <i> and <strike>. I think that this makes sense
because for example <b> represents bold style but <strong> represents
emphasize the text.

This patch makes the tests align to Blink/WebKit and most new expectations
are copied from Blink's result. Exception is, Blink/WebKit replaces rightmost
<s> when middle of it is unstyled only in some cases with <strike> or
<span>. This must be a leak of their implementation, and hard to follow it
because the simplest approach of partially removing style is, split the existing
element at 2 points and unwrap middle element children. I.e., it's not required
to touch the rightmost element.

Depends on D163184

The other browsers do not do this. From semantics point of view, stop reusing
them is better.

Depends on D163185

Pushed by masayuki@d-toybox.com:
https://hg.mozilla.org/integration/autoland/rev/669016166d0c
part 1: Make `bold`, `italic` and `strikethrough` tests treat `<strong>`, `<em>` and `<s>` as what browsers do r=m_kato
https://hg.mozilla.org/integration/autoland/rev/c0843589387e
part 2: Make `AutoInlineStyleSetter` stop using `<strong>`, `<em>` and `<strike>` as alternative container of `<b>`, `<i>` and `<strike>` r=m_kato
https://hg.mozilla.org/integration/autoland/rev/6330f1ee7002
part 3: Make `AutoInlineStyleSetter` remove similar element at setting style r=m_kato
Status: ASSIGNED → RESOLVED
Closed: 1 year ago
Resolution: --- → FIXED
Target Milestone: --- → 109 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: