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".
Select All (command-a)
resulting editable content (in WebKit):
I've not tested IE yet.
I was using:
for my testing.
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:
For div's this isn't as apparent because the nesting is harmless.
*** Bug 39193 has been marked as a duplicate of this bug. ***
*** Bug 32232 has been marked as a duplicate of this bug. ***
Created attachment 64667 [details]
work in progress (works for very simple case with p tag)
(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.
Created attachment 64780 [details]
work in progress 2
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.
Created attachment 65045 [details]
needs more test conversion but ready for early review
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,
need to be rebaselined. All four tests should be converted to dump-as-markup tests first.
*** This bug has been marked as a duplicate of bug 26483 ***