Bug 47615 - REGRESSION: Copied content loses formatting on paste to external apps
Summary: REGRESSION: Copied content loses formatting on paste to external apps
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: HTML Editing (show other bugs)
Version: 528+ (Nightly build)
Hardware: Macintosh Intel OS X 10.6
: P1 Critical
Assignee: Nobody
URL:
Keywords: InRadar, Regression
: 48115 54500 (view as bug list)
Depends on: 55107
Blocks:
  Show dependency treegraph
 
Reported: 2010-10-13 13:16 PDT by Jochen Sprenger
Modified: 2011-03-08 18:36 PST (History)
13 users (show)

See Also:


Attachments
Patch (102.38 KB, patch)
2011-02-23 14:16 PST, Enrica Casucci
darin: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jochen Sprenger 2010-10-13 13:16:43 PDT
If you highlight a passage on a webpage and copy it to a texteditor, the copied passage loses all formatting.
This allies to all the text as well as images (latter ones are completely ignored during paste).
This not only happens if you copy the highlighted part to your clipboard and paste it into a new document outside of webkit/Safari.
It happens as well if you highlight a portion of a webpage, click and hold the highlighted part and then drag it to an new document (in TextEdit for example).
Comment 1 Alexey Proskuryakov 2010-10-14 10:31:25 PDT
Could you please provide step by step instructions to reproduce this?

Here is what I tried, and didn't see any problems:
1. Open http://www.apple.com/safari/ in Safari 5.0.2.
2. Selected a paragraph starting with "It has innovative new features".
3. Pressed Cmd+C to copy it.
4. Launched TextEdit, which opened a blank document.
5. Pressed Cmd+V to paste.

All formatting was preserved.
Comment 2 Jochen Sprenger 2010-10-14 13:50:56 PDT
Maybe I was unclear in my initial posting. You are right, that formatting is preserved in Safari.
But if you launch WebKit, the formatting is gone.
So just go to http://nightly.webkit.org/ and download the latest nightly build (I just tested the current build r69728).
Install and launch it.
Then follow your very own steps and you’ll see that he formatting won’t transfer.

Please post back if you have additional questions.
And sorry for the typos in post #1.

(In reply to comment #1)
> Could you please provide step by step instructions to reproduce this?
> 
> Here is what I tried, and didn't see any problems:
> 1. Open http://www.apple.com/safari/ in Safari 5.0.2.
> 2. Selected a paragraph starting with "It has innovative new features".
> 3. Pressed Cmd+C to copy it.
> 4. Launched TextEdit, which opened a blank document.
> 5. Pressed Cmd+V to paste.
> 
> All formatting was preserved.
Comment 3 Alexey Proskuryakov 2010-10-14 14:31:56 PDT
Thank you, I can reproduce this with a nightly build. Should have tried right away, but this didn't sound like a typical WebKit bug, so I asked for clarification instead.
Comment 4 Alexey Proskuryakov 2010-10-14 14:32:36 PDT
<rdar://problem/8553404>
Comment 5 Ryosuke Niwa 2010-10-14 15:03:51 PDT
(In reply to comment #1)
> Here is what I tried, and didn't see any problems:
> 1. Open http://www.apple.com/safari/ in Safari 5.0.2.
> 2. Selected a paragraph starting with "It has innovative new features".
> 3. Pressed Cmd+C to copy it.
> 4. Launched TextEdit, which opened a blank document.
> 5. Pressed Cmd+V to paste.

This seems to be some bug with clipboard.  We DO preserve the style when I paste it on http://www.mozilla.org/editor/midasdemo/

Alexey & Enrica:
do we use WebKit2 for nightly yet?
Comment 6 Alexey Proskuryakov 2010-10-14 15:08:42 PDT
> do we use WebKit2 for nightly yet?

No. There is no way to use it with nightlies in Safari 5.0.2.
Comment 7 Jochen Sprenger 2010-10-14 15:19:06 PDT
> This seems to be some bug with clipboard.  We DO preserve the style when I paste it on http://www.mozilla.org/editor/midasdemo/
>

I don’t know what you mean with mozilla, but using WebKit you also loose formatting when you drag text out of the browser and into a textdocument.
As far as I know during drag&drop the clipboard is not involved.
(At least the dragged part ain’t in your clipboard after dropping).
Comment 8 Hajime Morrita 2010-10-15 04:21:10 PDT
I've just play with this a bit.
I wonder why other apps can read NSHTMLPboardTypes from the pboard regardless
WebKit doesn't write with that type.
It looks WebKit just provides
WebArchivePboardType, NSRTFDPboardType, NSRTFPboardType, NSStringPboardType....
Comment 9 Tony Chang 2010-10-15 11:16:22 PDT
(In reply to comment #8)
> I've just play with this a bit.
> I wonder why other apps can read NSHTMLPboardTypes from the pboard regardless
> WebKit doesn't write with that type.
> It looks WebKit just provides
> WebArchivePboardType, NSRTFDPboardType, NSRTFPboardType, NSStringPboardType....

WebKit doesn't write text/html to the pasteboard because it broke MS Office 2004.
http://trac.webkit.org/changeset/6793
https://bugs.webkit.org/show_bug.cgi?id=19893

However, WebArchivePboardType should include the information necessary to paste HTML.
Comment 10 Alexey Proskuryakov 2010-10-22 10:45:35 PDT
*** Bug 48115 has been marked as a duplicate of this bug. ***
Comment 11 Alexey Proskuryakov 2011-02-18 16:10:56 PST
*** Bug 54500 has been marked as a duplicate of this bug. ***
Comment 12 Alexey Proskuryakov 2011-02-18 20:23:11 PST
> <rdar://problem/8553404>

Now tracked as <rdar://problem/9001214>
Comment 13 Enrica Casucci 2011-02-23 14:16:41 PST
Created attachment 83549 [details]
Patch
Comment 14 Darin Adler 2011-02-23 14:28:16 PST
Comment on attachment 83549 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=83549&action=review

OK to land this as-is, but over time we should make this use coding style closer to the rest of WebKit.

> Source/WebCore/platform/mac/PasteboardMac.mm:153
> +        // In WebKit2 we are using a different way to create the NSAttributedString from the DOMrange that doesn't require access to the WebView.

Typo: "DOM range" instead of "DOMrange".
Comment 15 Enrica Casucci 2011-02-23 16:09:51 PST
http://trac.webkit.org/changeset/79502
Comment 16 James Robinson 2011-02-23 17:05:26 PST
This doesn't seem to compile on my Snow Leopard box or the Leopard builder on build.webkit.org (the SL builder hasn't cycled yet):


/usr/local/home/jamesr/WebKit/Source/WebCore/platform/mac/HTMLConverter.mm:41:41: error: Foundation/NSURL_NSURLExtras.h: No such file or directory
cc1objplus: warnings being treated as errors
/usr/local/home/jamesr/WebKit/Source/WebCore/platform/mac/HTMLConverter.mm: In function ‘NSFileWrapper* fileWrapperForURL(WebCore::DocumentLoader*, NSURL*)’:
/usr/local/home/jamesr/WebKit/Source/WebCore/platform/mac/HTMLConverter.mm:785: warning: ‘NSURL’ may not respond to ‘-_web_suggestedFilenameWithMIMEType:’
/usr/local/home/jamesr/WebKit/Source/WebCore/platform/mac/HTMLConverter.mm:785: warning: (Messages without a matching method signature
/usr/local/home/jamesr/WebKit/Source/WebCore/platform/mac/HTMLConverter.mm:785: warning: will be assumed to return ‘id’ and accept
/usr/local/home/jamesr/WebKit/Source/WebCore/platform/mac/HTMLConverter.mm:785: warning: ‘...’ as arguments.)


is someone working on fixing it or should I roll this out for now?
Comment 17 Geoffrey Garen 2011-02-23 18:13:34 PST
I rolled this out in http://trac.webkit.org/changeset/79513. Reopening.
Comment 19 Enrica Casucci 2011-03-07 14:16:14 PST
Landed with build fix. http://trac.webkit.org/changeset/80497
Comment 20 WebKit Review Bot 2011-03-07 14:44:43 PST
http://trac.webkit.org/changeset/80497 might have broken Chromium Mac Release
Comment 21 Enrica Casucci 2011-03-07 16:30:44 PST
Reopening because of the failures on the 32-bit builds.
Comment 22 Enrica Casucci 2011-03-08 18:36:39 PST
http://trac.webkit.org/changeset/80615