<?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>26633</bug_id>
          
          <creation_ts>2009-06-22 17:46:43 -0700</creation_ts>
          <short_desc>Pasting a H2 into an H2 results in 2 H2&apos;s wrapping the content</short_desc>
          <delta_ts>2010-02-21 20:23:06 -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>PC</rep_platform>
          <op_sys>OS X 10.5</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>DUPLICATE</resolution>
          <dup_id>26937</dup_id>
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P3</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Venkat Karun">vkarun</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>eric</cc>
    
    <cc>jparent</cc>
    
    <cc>justin.garcia</cc>
    
    <cc>ojan</cc>
    
    <cc>tony</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>127520</commentid>
    <comment_count>0</comment_count>
    <who name="Venkat Karun">vkarun</who>
    <bug_when>2009-06-22 17:46:43 -0700</bug_when>
    <thetext>Assume we have a snippet like 
&lt;div contentEditable&gt;
  &lt;h2&gt;Heading 1&lt;/h2&gt;
  &lt;div&gt;line 1&lt;/div&gt;

  &lt;h2&gt;Heading 2&lt;/h2&gt;
  &lt;div&gt;line 2&lt;/div&gt;
&lt;/div&gt;

1) Place your cursor at the beginning of Header 2 and press enter to create a newline.
2) Go to the line created in the previous step and paste the entire section 1 (from Heading 1 to end of line 1). 

Expected result:
The content is pasted without being wrapped in an h2.

Actual result:
The pasted content is wrapped in the h2 created in step (1) and results in the following HTML.

&lt;h2&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size:16px;font-weight: normal;&quot;&gt;&lt;h2&gt;Heading 1&lt;/h2&gt;&lt;div&gt;line 1&lt;/div&gt;&lt;div&gt;line 2&lt;/div&gt;&lt;/span&gt;&lt;/h2&gt;

FF and IE seem to handle this quite gracefully.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>127521</commentid>
    <comment_count>1</comment_count>
      <attachid>31694</attachid>
    <who name="Venkat Karun">vkarun</who>
    <bug_when>2009-06-22 17:47:50 -0700</bug_when>
    <thetext>Created attachment 31694
Sample HTML for reproducing this bug</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>127540</commentid>
    <comment_count>2</comment_count>
    <who name="Ojan Vafai">ojan</who>
    <bug_when>2009-06-22 18:23:26 -0700</bug_when>
    <thetext>This is actually considerably more general. Anytime you copy-paste from one type of &quot;special&quot; block to another type of &quot;special&quot; block, they get nested. There are a number of block types that have this bug, e.g. pasting a pre into an h1 will also do this.

Also, simpler steps to reproduce:
1. select all the text inside an H1
2. copy
3. paste

You get an H1, nested inside a SPAN, nested inside an H1.

See http://trac.webkit.org/browser/trunk/WebCore/editing/markup.cpp#L739 for the full list of affected nodes.

It&apos;s not clear to me what the best behavior for this situation is. There are a bunch of edge cases that IE, Gecko and WebKit deal with very differently with these sorts of copy-pastes.

1. IE only copies the block if the whole line is selected, otherwise, it just copies the inline content (in this case, the plain text).
2. Gecko/WebKit copy the block if it&apos;s one of these specialAncestorBlocks, even if only one character in the block is selected.

Presumably the Gecko/WebKit behavior is to maintain the appearance of the old code while trying to maintain sane markup. There are cases here where Gecko ends up with strange markup as well. There are also cases where WebKit will convert the block into an inline span and transfer all the appropriate styling. 

Perhaps the latter is the correct thing to do and then to remove all the extraneous styles. Although, really the IE behavior is a lot simpler, but users can&apos;t wrap their heads around an H1 being different than bold+large-font-size, which is what leads to the Gecko/WebKit approach.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>131762</commentid>
    <comment_count>3</comment_count>
      <attachid>32750</attachid>
    <who name="Ryosuke Niwa">rniwa</who>
    <bug_when>2009-07-14 17:32:49 -0700</bug_when>
    <thetext>Created attachment 32750
demonstrates the same bug but also in Firefox</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>131764</commentid>
    <comment_count>4</comment_count>
      <attachid>32750</attachid>
    <who name="Ryosuke Niwa">rniwa</who>
    <bug_when>2009-07-14 17:34:11 -0700</bug_when>
    <thetext>Comment on attachment 32750
demonstrates the same bug but also in Firefox

sorry, wrong bug.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>192339</commentid>
    <comment_count>5</comment_count>
    <who name="Tony Chang">tony</who>
    <bug_when>2010-02-21 20:23:06 -0800</bug_when>
    <thetext>I think this is fixed by http://trac.webkit.org/changeset/54933 from bug 26937.  The extra span is now removed and the styles are propagated to the child nodes.  In this case, there&apos;s nothing to propagate so when I try the test case in ToT Safari, I get:

&lt;div contenteditable=&quot;&quot;&gt; &lt;h2&gt;Heading 1&lt;/h2&gt; &lt;div&gt;line 1&lt;/div&gt; &lt;h2&gt;Heading 2&lt;/h2&gt;&lt;div&gt;&lt;h2&gt;Heading 1&lt;/h2&gt;&lt;div&gt;line 1&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt; &lt;div&gt;line 2&lt;/div&gt; &lt;/div&gt;

Which seems fine to me.

Please comment if you see otherwise and I will investigate some more.

*** This bug has been marked as a duplicate of bug 26937 ***</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>31694</attachid>
            <date>2009-06-22 17:47:50 -0700</date>
            <delta_ts>2009-06-22 17:47:50 -0700</delta_ts>
            <desc>Sample HTML for reproducing this bug</desc>
            <filename>webkit_h2_paste.html</filename>
            <type>text/html</type>
            <size>205</size>
            <attacher name="Venkat Karun">vkarun</attacher>
            
              <data encoding="base64">PGh0bWw+Cjxib2R5Pgo8ZGl2IGNvbnRlbnRFZGl0YWJsZSBzdHlsZT0iYm9yZGVyOiAycHggc29s
aWQgI2U4ZThlOCI+CjxoMj5IZWFkaW5nIDE8L2gyPgo8ZGl2PmxpbmUgMTwvZGl2Pgo8ZGl2Pmxp
bmUgMjwvZGl2PgoKPGgyPkhlYWRpbmcgMjwvaDI+CjxkaXY+bGluZSAzPC9kaXY+CjxkaXY+bGlu
ZSA0PC9kaXY+CjwvZGl2PgoKPC9ib2R5Pgo8L2h0bWw+Cg==
</data>

          </attachment>
          <attachment
              isobsolete="1"
              ispatch="0"
              isprivate="0"
          >
            <attachid>32750</attachid>
            <date>2009-07-14 17:32:49 -0700</date>
            <delta_ts>2009-07-14 17:34:11 -0700</delta_ts>
            <desc>demonstrates the same bug but also in Firefox</desc>
            <filename>noneditable-style-change.html</filename>
            <type>text/html</type>
            <size>872</size>
            <attacher name="Ryosuke Niwa">rniwa</attacher>
            
              <data encoding="base64">PGh0bWw+Cjxib2R5Pgo8ZGl2IGlkPSJlIj4KPGRpdiBzdHlsZT0idGV4dC1kZWNvcmF0aW9uOiB1
bmRlcmxpbmU7IiBjb250ZW50ZWRpdGFibGU9ImZhbHNlIj48ZGl2IGlkPSJ0ZXN0IiBzdHlsZT0i
dGV4dC1kZWNvcmF0aW9uOiB1bmRlcmxpbmU7IiBjb250ZW50ZWRpdGFibGU9InRydWUiPnRleHQ8
L2Rpdj48L2Rpdj4KPC9kaXY+Cgo8dWw+CjxsaT5CZWZvcmU6PHNwYW4gaWQ9ImMxIj48L3NwYW4+
PC9saT4KPGxpPkFmdGVyOjxzcGFuIGlkPSJjMiI+PC9zcGFuPjwvbGk+CjwvdWw+Cgo8c2NyaXB0
IHR5cGU9InRleHQvamF2YXNjcmlwdCI+CgppZiAod2luZG93Lmxhe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