Closed Bug 1802831 Opened 2 years ago Closed 2 years ago

`text-decoration` should be updated if the element changes it

Categories

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

enhancement

Tracking

()

RESOLVED FIXED
109 Branch
Tracking Status
firefox109 --- fixed

People

(Reporter: masayuki, Assigned: masayuki)

References

Details

Attachments

(1 file)

In the case, execCommand("strikethrough") for foo<u>[bar]</u>baz in the CSS mode,

  • Blink: foo<span style="text-decoration-line:underline line-through">bar</span>baz
  • WebKit foo<u style="text-decoration:underline line-through">bar</u>baz
  • Gecko: foo<span style="text-decoration:line-through"><u>bar</u></span>baz

Gecko has some specific path for <span> element in the CSS mode. Therefore, aligning to Blink must be reasonable since it reduces the number of element.

There is another case: foo<ins>[bar]</ins>baz in the CSS mode,

  • Blink: foo<ins style="text-decoration-line:line-through">bar</ins>baz
  • WebKit: foo<ins style="text-decoration:underline line-through">bar</ins>baz
  • Gecko: foo<span style="text-decoration:line-through"><ins>bar</ins></span>baz

I think Blink's result is reasonable because underline is the default style of <ins>.

Gecko wraps selection (and parent elements if entirely selected in them) in
new <span> element and set text-decoration. However, the other browsers
tries to reuse selected or parent element which already has text-decoration
style. The other browsers' behavior is more reasonable from point of view of:

  • smaller footprint
  • minimizing to update the DOM tree

And aligning the behavior makes it easier to check the compatibility between
browsers and us avoid from new test failures aligning other behaviors to the
other browsers.

If there is an element specifying text-decoration, its text-decoration
declaration should be updated first.

If found element is <i>, <s> or <strike>, it should be replaced with new
<span> because these elements just represents the visual style and we should
not use such elements in the CSS mode (bug 1802736). At this time, unless
the element has text-decoration rules in its style attribute value, we
the new text-decoration style should have the value represented by the
removing element (i.e., underline for <i>, line-through for the others).

However, if found element is <ins> or <del>, we should set its
text-decoration and unless it already has text-decoration rules, we need
to append corresponding style (underline for <ins> and line-through for
<del>) too.

When setting the values or removing a value from text-decoration declaration,
the value should be normalized to represent only text-decoration-line for
compatibility with the other browsers and keeping the implementation simpler.
And also the value should be built as the following order:

  1. underline
  2. overline
  3. line-though

rather than updating current value with complicated code. Then, the tests can
compare with one expectation.

Depends on D163188

Pushed by masayuki@d-toybox.com:
https://hg.mozilla.org/integration/autoland/rev/4e4cf4947e57
Make `AutoInlineStyleSetter` align setting `text-decoration` style behavior in the CSS mode to the other browsers r=m_kato
Created web-platform-tests PR https://github.com/web-platform-tests/wpt/pull/37308 for changes under testing/web-platform/tests
Status: ASSIGNED → RESOLVED
Closed: 2 years 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: