WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED DUPLICATE of
bug 26937
26633
Pasting a H2 into an H2 results in 2 H2's wrapping the content
https://bugs.webkit.org/show_bug.cgi?id=26633
Summary
Pasting a H2 into an H2 results in 2 H2's wrapping the content
Venkat Karun
Reported
2009-06-22 17:46:43 PDT
Assume we have a snippet like <div contentEditable> <h2>Heading 1</h2> <div>line 1</div> <h2>Heading 2</h2> <div>line 2</div> </div> 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. <h2><span class="Apple-style-span" style="font-size:16px;font-weight: normal;"><h2>Heading 1</h2><div>line 1</div><div>line 2</div></span></h2> FF and IE seem to handle this quite gracefully.
Attachments
Sample HTML for reproducing this bug
(205 bytes, text/html)
2009-06-22 17:47 PDT
,
Venkat Karun
no flags
Details
demonstrates the same bug but also in Firefox
(872 bytes, text/html)
2009-07-14 17:32 PDT
,
Ryosuke Niwa
no flags
Details
Show Obsolete
(1)
View All
Add attachment
proposed patch, testcase, etc.
Venkat Karun
Comment 1
2009-06-22 17:47:50 PDT
Created
attachment 31694
[details]
Sample HTML for reproducing this bug
Ojan Vafai
Comment 2
2009-06-22 18:23:26 PDT
This is actually considerably more general. Anytime you copy-paste from one type of "special" block to another type of "special" 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'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'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't wrap their heads around an H1 being different than bold+large-font-size, which is what leads to the Gecko/WebKit approach.
Ryosuke Niwa
Comment 3
2009-07-14 17:32:49 PDT
Created
attachment 32750
[details]
demonstrates the same bug but also in Firefox
Ryosuke Niwa
Comment 4
2009-07-14 17:34:11 PDT
Comment on
attachment 32750
[details]
demonstrates the same bug but also in Firefox sorry, wrong bug.
Tony Chang
Comment 5
2010-02-21 20:23:06 PST
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's nothing to propagate so when I try the test case in ToT Safari, I get: <div contenteditable=""> <h2>Heading 1</h2> <div>line 1</div> <h2>Heading 2</h2><div><h2>Heading 1</h2><div>line 1</div></div><div><br></div> <div>line 2</div> </div> 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
***
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug