<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>47054</bug_id>
          
          <creation_ts>2010-10-02 16:33:16 -0700</creation_ts>
          <short_desc>execCommand(&apos;FormatBlock&apos;) does not preserve inline styles of the replaced block elements</short_desc>
          <delta_ts>2026-02-27 13:57:24 -0800</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>HTML Editing</component>
          <version>528+ (Nightly build)</version>
          <rep_platform>All</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>BlinkMergeCandidate, InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Ryosuke Niwa">rniwa</reporter>
          <assigned_to>joanne_pan2</assigned_to>
          <cc>ahmad.saleem792</cc>
    
    <cc>ayg</cc>
    
    <cc>enrica</cc>
    
    <cc>karlcow</cc>
    
    <cc>tony</cc>
    
    <cc>webkit-bug-importer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>288728</commentid>
    <comment_count>0</comment_count>
    <who name="Ryosuke Niwa">rniwa</who>
    <bug_when>2010-10-02 16:33:16 -0700</bug_when>
    <thetext>Reproduction steps:
1. Go to http://www.mozilla.org/editor/midasdemo/
2. Paste &lt;div style=&quot;color: red;&quot;&gt;hello&lt;/div&gt; in HTML source mode
3. Chante the format to &quot;h1&quot; in WYSIWYG mode

Expected result:
&lt;h1 style=&quot;color:red;&quot;&gt;hello&lt;/h1&gt; or &lt;h1&gt;&lt;span style=&quot;color:red;&quot;&gt;hello&lt;/span&gt;&lt;/h1&gt;

Actual result:
&lt;h1&gt;hello&lt;/h1&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>453182</commentid>
    <comment_count>1</comment_count>
    <who name="Aryeh Gregor">ayg</who>
    <bug_when>2011-08-18 11:28:46 -0700</bug_when>
    <thetext>This is handled in the spec by &quot;record the values&quot;/&quot;restore the values&quot;:

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, &quot;record the values&quot; records any inline style that&apos;s specified on that node or that it&apos;s inheriting from an ancestor.  Then &quot;restore the values&quot; 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.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1920273</commentid>
    <comment_count>2</comment_count>
    <who name="Ahmad Saleem">ahmad.saleem792</who>
    <bug_when>2022-12-17 12:51:19 -0800</bug_when>
    <thetext>Fixed in following commit - https://src.chromium.org/viewvc/blink?view=revision&amp;revision=163137</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1925125</commentid>
    <comment_count>3</comment_count>
    <who name="Ahmad Saleem">ahmad.saleem792</who>
    <bug_when>2023-01-12 13:27:19 -0800</bug_when>
    <thetext>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:

&apos;&apos;&apos;
I don&apos;t think the code change as currently proposed makes much sense. For one, there is mismatch between outerBlock vs blockNode. For another, we shouldn&apos;t be just copying style attribute. We need to get the computed style and apply that style to the block if we&apos;re failing to preserve the style in this command. e.g. using EditingStyle::prepareToApplyAt and ApplyStyleCommand.
&apos;&apos;&apos;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2184652</commentid>
    <comment_count>4</comment_count>
    <who name="Karl Dubost">karlcow</who>
    <bug_when>2026-02-24 18:06:16 -0800</bug_when>
    <thetext>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&amp;label=experimental&amp;aligned&amp;q=formatblock%20safari%3Afail%20chrome%3Apass
https://wpt.fyi/results/editing/run/formatblock.html%3F4001-5000?label=master&amp;label=experimental&amp;aligned&amp;q=formatblock%20safari%3Afail%20chrome%3Apass
https://wpt.fyi/results/editing/other/formatblock-preserving-selection.tentative.html%3FstyleWithCSS%3Dfalse%26block%3Dh1?label=master&amp;label=experimental&amp;aligned&amp;q=formatblock%20safari%3Afail%20chrome%3Apass
https://wpt.fyi/results/editing/other/formatblock-preserving-selection.tentative.html%3FstyleWithCSS%3Dtrue%26block%3Dh1?label=master&amp;label=experimental&amp;aligned&amp;q=formatblock%20safari%3Afail%20chrome%3Apass</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2184933</commentid>
    <comment_count>5</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2026-02-25 13:38:42 -0800</bug_when>
    <thetext>&lt;rdar://problem/171199434&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2184934</commentid>
    <comment_count>6</comment_count>
    <who name="">joanne_pan2</who>
    <bug_when>2026-02-25 13:39:16 -0800</bug_when>
    <thetext>Pull request: https://github.com/WebKit/WebKit/pull/59448</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2184978</commentid>
    <comment_count>7</comment_count>
    <who name="">joanne_pan2</who>
    <bug_when>2026-02-25 15:17:17 -0800</bug_when>
    <thetext>Progress is being tracked by: rdar://157657531</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2184986</commentid>
    <comment_count>8</comment_count>
    <who name="">joanne_pan2</who>
    <bug_when>2026-02-25 16:07:34 -0800</bug_when>
    <thetext>&lt;rdar://problem/157657531&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2185031</commentid>
    <comment_count>9</comment_count>
    <who name="Ahmad Saleem">ahmad.saleem792</who>
    <bug_when>2026-02-25 17:40:03 -0800</bug_when>
    <thetext>(In reply to Ahmad Saleem from comment #2)
&gt; Fixed in following commit -
&gt; https://src.chromium.org/viewvc/blink?view=revision&amp;revision=163137

This link is dead - replacement link - https://chromium.googlesource.com/chromium/src.git/+/8d5a72610a8b98fdd885f3a033e8734acba6c78c</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2185658</commentid>
    <comment_count>10</comment_count>
    <who name="EWS">ews-feeder</who>
    <bug_when>2026-02-27 13:57:21 -0800</bug_when>
    <thetext>Committed 308365@main (51dde913fc8d): &lt;https://commits.webkit.org/308365@main&gt;

Reviewed commits have been landed. Closing PR #59448 and removing active labels.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>