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: | Nobody <webkit-unassigned> |
Status: | NEW | ||
Severity: | Normal | CC: | ahmad.saleem792, ayg, enrica, tony |
Priority: | P2 | Keywords: | BlinkMergeCandidate |
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.
'''