RESOLVED DUPLICATE of bug 26483 24009
WebKit nests block elements when pasting paragraphs
https://bugs.webkit.org/show_bug.cgi?id=24009
Summary WebKit nests block elements when pasting paragraphs
Eric Seidel (no email)
Reported 2009-02-18 13:59:04 PST
Safari can create invalid HTML when pasting paragraphs I'm not sure I know what the "right" behavior is here, but our current behavior seems "wrong". editable content: <p>test</p> Select All (command-a) Copy Paste resulting editable content (in WebKit): <p><p>test</p></p> FF: <p>test</p> I've not tested IE yet. I was using: http://www.mozilla.org/editor/midasdemo/ for my testing.
Attachments
work in progress (works for very simple case with p tag) (3.99 KB, patch)
2010-08-17 20:53 PDT, Ryosuke Niwa
no flags
work in progress 2 (9.14 KB, patch)
2010-08-18 15:03 PDT, Ryosuke Niwa
no flags
needs more test conversion but ready for early review (19.31 KB, patch)
2010-08-21 20:45 PDT, Ryosuke Niwa
no flags
Tony Chang
Comment 1 2010-02-01 22:39:39 PST
The original test case doesn't repro for me, but if I change the editable content to <p>first</p><p><br></p>, I'm able to repro. Also, this isn't specific to <p> tags, any block tag will cause this. E.g., <blockquote>first</blockquote><blockquote><br/></blockquote> + select all + copy + paste will result in nested blockquotes: <blockquote><blockquote>first</blockquote><div><br></div></blockquote> For div's this isn't as apparent because the nesting is harmless.
Tony Chang
Comment 2 2010-05-27 23:52:02 PDT
*** Bug 39193 has been marked as a duplicate of this bug. ***
Ryosuke Niwa
Comment 3 2010-08-17 20:03:18 PDT
*** Bug 32232 has been marked as a duplicate of this bug. ***
Ryosuke Niwa
Comment 4 2010-08-17 20:53:52 PDT
Created attachment 64667 [details] work in progress (works for very simple case with p tag)
Tony Chang
Comment 5 2010-08-18 09:30:23 PDT
(In reply to comment #4) > Created an attachment (id=64667) [details] > work in progress (works for very simple case with p tag) This sounds similar to https://bugs.webkit.org/show_bug.cgi?id=39866, which is a generalization of https://bugs.webkit.org/show_bug.cgi?id=25002. See Ojan's comment on 39866.
Ryosuke Niwa
Comment 6 2010-08-18 15:03:48 PDT
Created attachment 64780 [details] work in progress 2
Ryosuke Niwa
Comment 7 2010-08-18 15:11:09 PDT
areIdenticalElements is copied from ApplyStyleCommand, I'll be sharing it between ApplyStyleCommand and ReplaceSelectionCommand in my final patch. This patch currently requires 3 rebaselines: editing/pasteboard/4242293-1.html, editing/pasteboard/copy-paste-bidi.html, and editing/selection/replace-selection-crash.html. The first two tests need to be converted to dumpAsMarkup or dumpAsText tests first. But changes are good as far as I looked at the render tree. This patch does not fix the bug 26483 because of the bug 34564. We could work-around the issue by handling style spans before pasting. But the correct thing to do is not to wrap everything with style-spans. It shouldn't be too hard to push styles to each element in the fragment and have ReplaceSelectionCommand remove all redundant styles at the pasting stage. But we should probably do that in a separate patch.
Ryosuke Niwa
Comment 8 2010-08-21 20:45:37 PDT
Created attachment 65045 [details] needs more test conversion but ready for early review
Ryosuke Niwa
Comment 9 2010-08-21 20:53:12 PDT
My new approach changes the behavior of WebKit so that it doesn't merge the inserted paragraph and the paragraph in the destination when the inserted content starts with the same block element as the destination. For this change, editing/pasteboard/8145-3.html editing/pasteboard/interchange-newline-2.html editing/pasteboard/merge-after-delete.html editing/pasteboard/merge-end-list.html need to be rebaselined. All four tests should be converted to dump-as-markup tests first.
Ryosuke Niwa
Comment 10 2011-08-16 19:56:34 PDT
*** This bug has been marked as a duplicate of bug 26483 ***
Note You need to log in before you can comment on or make changes to this bug.