<?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>107967</bug_id>
          
          <creation_ts>2013-01-25 11:26:41 -0800</creation_ts>
          <short_desc>Deleting a button and typing text afterwards applies wrong styling to the typed text</short_desc>
          <delta_ts>2022-11-17 12:22:41 -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>420+</version>
          <rep_platform>PC</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>NEW</bug_status>
          <resolution></resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Andrew fedoniouk">andrew.fedoniouk</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>ahmad.saleem792</cc>
    
    <cc>arpitabahuguna</cc>
    
    <cc>rniwa</cc>
    
    <cc>wesley</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>816781</commentid>
    <comment_count>0</comment_count>
      <attachid>184779</attachid>
    <who name="Andrew fedoniouk">andrew.fedoniouk</who>
    <bug_when>2013-01-25 11:26:41 -0800</bug_when>
    <thetext>Created attachment 184779
Minimal example to reproduce the issue.

Minimal reproducible markup:

&lt;div contenteditable&gt;
  &lt;div&gt;The &lt;input type=button value=button&gt;&lt;/div&gt;
&lt;/div&gt;

Steps to reproduce:

1. Position caret after the button.
2. Hit {BACKSPACE} to delete the button.
3. Without moving the caret type something at caret location.

Note: the text typed is incorrectly wrapped into &amp;lt;span style=&quot;white-space:pre;font:...&quot;&gt; and its container gets text-align:center style. Use attached document to reproduce it.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>861379</commentid>
    <comment_count>1</comment_count>
    <who name="Wesley B">wesley</who>
    <bug_when>2013-03-22 05:45:28 -0700</bug_when>
    <thetext>I second this. It is something I have been trying to deal with for quite a long time now. 

Additionally, any font styles that the button had will be copied over into the span tag that will appear. So for example, if your button had white text and you remove that button, any text you will type afterwards will be white as well.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>924785</commentid>
    <comment_count>2</comment_count>
    <who name="Arpita Bahuguna">arpitabahuguna</who>
    <bug_when>2013-09-04 23:00:20 -0700</bug_when>
    <thetext>This has already been fixed in Chrome: http://src.chromium.org/viewvc/blink/trunk/Source/core/editing/DeleteSelectionCommand.cpp?r1=154066&amp;r2=154067&amp;

Probably we need to merge these changes.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>924788</commentid>
    <comment_count>3</comment_count>
    <who name="Ryosuke Niwa">rniwa</who>
    <bug_when>2013-09-04 23:04:48 -0700</bug_when>
    <thetext>The fix in Blink is wrong.

There is nothing wrong for an anchor element to be an input element. EditingStyle::create needs to be aware of non-legacy Position and obtain the style at the parent of the input element in such a case.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1904226</commentid>
    <comment_count>4</comment_count>
    <who name="Ahmad Saleem">ahmad.saleem792</who>
    <bug_when>2022-10-08 00:13:18 -0700</bug_when>
    <thetext>I think Safari Technology Preview 154 have this fix:

https://github.com/WebKit/WebKit/commit/c75ccbd4e966b91f06494b79f42403fe3a0bcafb</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1904400</commentid>
    <comment_count>5</comment_count>
    <who name="Ryosuke Niwa">rniwa</who>
    <bug_when>2022-10-09 17:18:19 -0700</bug_when>
    <thetext>The bug still reproduces in STP.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1913258</commentid>
    <comment_count>6</comment_count>
    <who name="Ahmad Saleem">ahmad.saleem792</who>
    <bug_when>2022-11-17 12:22:41 -0800</bug_when>
    <thetext>I tried to fix this bug in below PR:

Link - https://github.com/WebKit/WebKit/pull/5995

But after discussions with rniwa, I am going to close it and document approach here:

__________

1) Doing 1-1 Blink merge works and it compile but it is not desirable result because of Comment 03 as highlighted.

2) While trying to do it as per rniwa guidance in PR, we get following test failures:

editing/deleting/maintain-style-after-delete.html
editing/execCommand/underline-selection-containing-image.html, editing/style/5084241.html
editing/style/background-color-retained.html
editing/style/style-3681552-fix-002.html 

____

1) maintain-style-after-delete.html - we lose font color and span of caret color and this behavior matches with Firefox Nightly 109.

Link - https://jsfiddle.net/3Lbw76a4/show

2) underline-selection-containing-image.html - we get new Console Error message &quot;CONSOLE MESSAGE: TypeError: null is not an object (evaluating &apos;document.querySelector(&quot;U&quot;).textContent&apos;)&quot; - losing styling as intended and get similar behavior to chrome in test case.

Link - https://jsfiddle.net/76n3rjf8/ (Look at console error of Chrome)

3) editing/style/5084241.html - We match with Firefox here and loss &quot;Red&quot; font color from the first line of text here.

4) background-color-retained.html - We match with Firefox here and loss &quot;background&quot; color from the text after deletion.

Link - https://jsfiddle.net/Lzx97c5u/

5) style-3681552-fix-002.html - We don&apos;t match any browser after this change and we loss italic styling of &quot;xxx&quot; and it can be interop issue. Although, Chrome does not have this test anymore based on search from source.chromium.org.

_______

These are findings based on PR and any failure into it.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>184779</attachid>
            <date>2013-01-25 11:26:41 -0800</date>
            <delta_ts>2013-01-25 11:26:41 -0800</delta_ts>
            <desc>Minimal example to reproduce the issue.</desc>
            <filename>webkit-bug.htm</filename>
            <type>text/html</type>
            <size>420</size>
            <attacher name="Andrew fedoniouk">andrew.fedoniouk</attacher>
            
              <data encoding="base64">PGh0bWw+DQo8Ym9keT4NCg0KPGRpdiBjb250ZW50ZWRpdGFibGU+DQogIDxkaXY+VGhlIDxpbnB1
dCB0eXBlPWJ1dHRvbiB2YWx1ZT1idXR0b24+PC9kaXY+DQo8L2Rpdj4NCjxvbD4NCiAgPGxpPlBv
c2l0aW9uIGNhcmV0IGFmdGVyIHRoZSBidXR0b24uPC9saT4NCiAgPGxpPkhpdCB7QkFDS1NQQUNF
fSB0byBkZWxldGUgdGhlIGJ1dHRvbi48L2xpPg0KICA8bGk+VHlwZSBzb21ldGhpbmcgYXQgY2Fy
ZXQgbG9jYXRpb248L2xpPg0KICA8bGk+Tm90ZTogdGhlIHRleHQgdHlwZWQgaXMgaW5jb3JyZWN0
bHkgd3JhcHBlZCBpbnRvICZsdDtzcGFuIHN0eWxlPSJ3aGl0ZS1zcGFjZTpwcmU7Zm9udDouLi4i
PiBhbmQgaXRzIGNvbnRhaW5lciBnZXRzIHRleHQtYWxpZ246Y2VudGVyIHN0eWxlLg0KPC9vbD4N
Cg0KPC9ib2R5Pg0KPC9odG1sPg0K
</data>

          </attachment>
      

    </bug>

</bugzilla>