Bug 47054
| Summary: | execCommand('FormatBlock') does not preserve inline styles of the replaced block elements | ||
|---|---|---|---|
| Product: | WebKit | Reporter: | Ryosuke Niwa <rniwa> |
| Component: | HTML Editing | Assignee: | joanne_pan2 |
| Status: | RESOLVED FIXED | ||
| Severity: | Normal | CC: | ahmad.saleem792, ayg, enrica, karlcow, tony, webkit-bug-importer |
| Priority: | P2 | Keywords: | BlinkMergeCandidate, InRadar |
| Version: | 528+ (Nightly build) | ||
| Hardware: | All | ||
| OS: | All | ||
Ryosuke Niwa
Reproduction steps:
1. Go to http://www.mozilla.org/editor/midasdemo/
2. Paste <div style="color: red;">hello</div> in HTML source mode
3. Chante the format to "h1" in WYSIWYG mode
Expected result:
<h1 style="color:red;">hello</h1> or <h1><span style="color:red;">hello</span></h1>
Actual result:
<h1>hello</h1>
| Attachments | ||
|---|---|---|
| Add attachment proposed patch, testcase, etc. |
Aryeh Gregor
This is handled in the spec by "record the values"/"restore the values":
http://aryeh.name/spec/editing/editing.html#the-formatblock-command
http://aryeh.name/spec/editing/editing.html#record-the-values
Basically, for each node in a node list, "record the values" records any inline style that's specified on that node or that it's inheriting from an ancestor. Then "restore the values" checks each node for whether it has the same value, and if not, sets it. I call them every time I move nodes around in a way that might change what styles they inherit.
Ahmad Saleem
Fixed in following commit - https://src.chromium.org/viewvc/blink?view=revision&revision=163137
Ahmad Saleem
I tried - https://github.com/WebKit/WebKit/pull/8536 to merge Blink patch but it is not suitable and we need to account for following comment from rniwa:
'''
I don't think the code change as currently proposed makes much sense. For one, there is mismatch between outerBlock vs blockNode. For another, we shouldn't be just copying style attribute. We need to get the computed style and apply that style to the block if we're failing to preserve the style in this command. e.g. using EditingStyle::prepareToApplyAt and ApplyStyleCommand.
'''
Karl Dubost
See the unofficial draft
https://w3c.github.io/editing/docs/execCommand/
https://w3c.github.io/editing/docs/execCommand/#the-formatblock-command
And
https://wpt.fyi/results/editing/run/formatblock.html%3F2001-3000?label=master&label=experimental&aligned&q=formatblock%20safari%3Afail%20chrome%3Apass
https://wpt.fyi/results/editing/run/formatblock.html%3F4001-5000?label=master&label=experimental&aligned&q=formatblock%20safari%3Afail%20chrome%3Apass
https://wpt.fyi/results/editing/other/formatblock-preserving-selection.tentative.html%3FstyleWithCSS%3Dfalse%26block%3Dh1?label=master&label=experimental&aligned&q=formatblock%20safari%3Afail%20chrome%3Apass
https://wpt.fyi/results/editing/other/formatblock-preserving-selection.tentative.html%3FstyleWithCSS%3Dtrue%26block%3Dh1?label=master&label=experimental&aligned&q=formatblock%20safari%3Afail%20chrome%3Apass
Radar WebKit Bug Importer
<rdar://problem/171199434>
joanne_pan2
Pull request: https://github.com/WebKit/WebKit/pull/59448
joanne_pan2
Progress is being tracked by: rdar://157657531
joanne_pan2
<rdar://problem/157657531>
Ahmad Saleem
(In reply to Ahmad Saleem from comment #2)
> Fixed in following commit -
> https://src.chromium.org/viewvc/blink?view=revision&revision=163137
This link is dead - replacement link - https://chromium.googlesource.com/chromium/src.git/+/8d5a72610a8b98fdd885f3a033e8734acba6c78c
EWS
Committed 308365@main (51dde913fc8d): <https://commits.webkit.org/308365@main>
Reviewed commits have been landed. Closing PR #59448 and removing active labels.