RESOLVED FIXED 47615
REGRESSION: Copied content loses formatting on paste to external apps
https://bugs.webkit.org/show_bug.cgi?id=47615
Summary REGRESSION: Copied content loses formatting on paste to external apps
Jochen Sprenger
Reported 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).
Attachments
Patch (102.38 KB, patch)
2011-02-23 14:16 PST, Enrica Casucci
darin: review+
Alexey Proskuryakov
Comment 1 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.
Jochen Sprenger
Comment 2 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.
Alexey Proskuryakov
Comment 3 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.
Alexey Proskuryakov
Comment 4 2010-10-14 14:32:36 PDT
Ryosuke Niwa
Comment 5 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?
Alexey Proskuryakov
Comment 6 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.
Jochen Sprenger
Comment 7 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).
Hajime Morrita
Comment 8 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....
Tony Chang
Comment 9 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.
Alexey Proskuryakov
Comment 10 2010-10-22 10:45:35 PDT
*** Bug 48115 has been marked as a duplicate of this bug. ***
Alexey Proskuryakov
Comment 11 2011-02-18 16:10:56 PST
*** Bug 54500 has been marked as a duplicate of this bug. ***
Alexey Proskuryakov
Comment 12 2011-02-18 20:23:11 PST
Enrica Casucci
Comment 13 2011-02-23 14:16:41 PST
Darin Adler
Comment 14 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".
Enrica Casucci
Comment 15 2011-02-23 16:09:51 PST
James Robinson
Comment 16 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?
Geoffrey Garen
Comment 17 2011-02-23 18:13:34 PST
I rolled this out in http://trac.webkit.org/changeset/79513. Reopening.
Enrica Casucci
Comment 19 2011-03-07 14:16:14 PST
WebKit Review Bot
Comment 20 2011-03-07 14:44:43 PST
http://trac.webkit.org/changeset/80497 might have broken Chromium Mac Release
Enrica Casucci
Comment 21 2011-03-07 16:30:44 PST
Reopening because of the failures on the 32-bit builds.
Enrica Casucci
Comment 22 2011-03-08 18:36:39 PST
Note You need to log in before you can comment on or make changes to this bug.