Bug 62047 - copy-paste breaks lists
Summary: copy-paste breaks lists
Status: RESOLVED DUPLICATE of bug 62041
Alias: None
Product: WebKit
Classification: Unclassified
Component: HTML Editing (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-06-03 13:30 PDT by Ojan Vafai
Modified: 2011-06-03 14:10 PDT (History)
6 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ojan Vafai 2011-06-03 13:30:46 PDT
1. Load http://simple-rte.rniwa.com/?editor=%3Cdiv%3E%0A%3Cdiv%3E%0A%3Cul%20style%3D%22text-align%3Aright%3B%22%3E%3Cli%3EA%3C/li%3E%3C/ul%3E%0A%3Cdiv%3E%0A%20%20%20%20%3Cul%3E%0A%20%20%20%20%20%20%20%20%3Cli%3E%0A%20%20%20%20%20%20%20%20%20%20%20%20%3Ca%20href%3D%22%22%3EB%3C/a%3E%0A%20%20%20%20%20%20%20%20%20%20%20%20%3Cbr%3E%0A%20%20%20%20%20%20%20%20%20%20%20%20C%20%0A%20%20%20%20%20%20%20%20%3C/li%3E%0A%20%20%20%20%3C/ul%3E%0A%3C/div%3E%0A%3C/div%3E%0A%3C/div%3E&script=editor%28%29.focus%28%29%3B
2. Select all (e.g. cmd+a)
3. Copy
4. Paste

I'd expect the html contents to be unmodified. Instead, the HTML changes considerably and the visual formatting is totally different.

HTML before:
<div>
<div>
<ul style="text-align:right;"><li>A</li></ul>
<div>
    <ul>
        <li>
            <a href="">B</a>
            <br>
            C 
        </li>
    </ul>
</div>
</div>
</div>

HTML after:
<div>
<div>
<ul style="text-align:right;"><li><meta charset="utf-8"><ul style="text-align: right; "><li>A</li></ul><div><ul><li><a href="http://simple-rte.rniwa.com/?editor=%3Cdiv%20id%3D%22root%22%20style%3D%22word-wrap%3A%20break-word%3B%20-khtml-nbsp-mode%3A%20space%3B%20-khtml-line-break%3A%20after-white-space%3B%22%20contenteditable%3D%22%22%3E%0A%3Cdiv%20id%3D%22test%22%20class%3D%22editing%22%3E%0A%3Cul%20style%3D%22text-align%3Aright%3B%22%3E%3Cli%3E%3Cmeta%20charset%3D%22utf-8%22%3E%3Cul%20style%3D%22text-align%3A%20right%3B%20%22%3E%3Cli%3EA%3C/li%3E%3C/ul%3E%3Cdiv%3E%3Cul%3E%3Cli%3E%3Ca%20href%3D%22http%3A//simple-rte.rniwa.com/%3Feditor%3D%253Cul%253E%253Cli%253Ehello%253C/li%253E%253Cli%253Eworld%253C/li%253E%253C/ul%253E%253Cdiv%253EWebKit%253C/div%253E%26amp%3Bscript%3Deditor%2528%2529.focus%2528%2529%253B%22%3EB%3C/a%3E%26nbsp%3B%3Cbr%3EC%3C/li%3E%3C/ul%3E%3C/div%3E%3C/li%3E%3C/ul%3E%3Cdiv%3E%3Cul%3E%0A%20%20%20%20%3C/ul%3E%0A%3C/div%3E%0A%3C/div%3E%0A%3C/div%3E&amp;script=editor%28%29.focus%28%29%3B">B</a>&nbsp;<br>C</li></ul></div></li></ul><div><ul>
    </ul>
</div>
</div>
</div>

I see a few problems with this:
1. The structure of the list items has changed resulting in all the text being right aligned and some bullets being nested.
2. Why is there a meta tag??
3. Why do we resolve the href instead of leaving it as an empty string?
Comment 1 Tony Chang 2011-06-03 13:36:02 PDT
(In reply to comment #0)
> 3. Why do we resolve the href instead of leaving it as an empty string?

We resolve relative links at copy time.  Otherwise, the links might not work when you paste back the contents.

IIRC, there may be different behaviors with Safari because it uses the WebArchive format when copying HTML and the WebArchive format includes meta data like the base URL.
Comment 2 Ojan Vafai 2011-06-03 13:40:51 PDT
(In reply to comment #1)
> (In reply to comment #0)
> > 3. Why do we resolve the href instead of leaving it as an empty string?
> 
> We resolve relative links at copy time.  Otherwise, the links might not work when you paste back the contents.

Oh right. I forgot about this. I remember there being no good way to fix this. So, nevermind about this issue. Lets have this bug focus on (1) and (2).
Comment 3 Ryosuke Niwa 2011-06-03 13:42:45 PDT
Meta element shouldn't be there in ToT.  I recently added a logic to remove them
Comment 4 Ojan Vafai 2011-06-03 13:46:47 PDT
(In reply to comment #3)
> Meta element shouldn't be there in ToT.  I recently added a logic to remove them

Oh great. Sorry, I'm in Chrome beta.
Comment 5 Ryosuke Niwa 2011-06-03 14:02:30 PDT
What I get on ToT:
<div>
<div>
<ul style="text-align:right;"><ul style="text-align: right; "><li>A</li></ul><div><ul><li><a href="">B</a>&nbsp;<br>C</li></ul></div></ul><div><ul>
    </ul>
</div>
</div>
</div>
Comment 6 Ryosuke Niwa 2011-06-03 14:04:36 PDT
Why don't we merge this bug with 62041 since copying & pasting all is exactly what editing/pasteboard/paste-4039777-fix.html tests.
Comment 7 Ojan Vafai 2011-06-03 14:10:30 PDT
Ah, sorry, I didn't realize that the differences I was seeing were because I wasn't on tip of tree.

*** This bug has been marked as a duplicate of bug 62041 ***