Bug 16311 - [Gtk] Copy rich text to clipboard as text/plain and text/html
Summary: [Gtk] Copy rich text to clipboard as text/plain and text/html
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKitGTK (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Enhancement
Assignee: Nobody
URL:
Keywords: Gtk
Depends on:
Blocks:
 
Reported: 2007-12-05 12:40 PST by Luca Bruno
Modified: 2007-12-22 15:13 PST (History)
1 user (show)

See Also:


Attachments
patch (9.52 KB, patch)
2007-12-07 04:32 PST, Luca Bruno
alp: review-
Details | Formatted Diff | Diff
cleaner patch (11.06 KB, patch)
2007-12-07 08:19 PST, Luca Bruno
no flags Details | Formatted Diff | Diff
do not use webkit enum (11.46 KB, patch)
2007-12-07 10:54 PST, Luca Bruno
no flags Details | Formatted Diff | Diff
PasteboardHelper and use the right clipboard (22.46 KB, patch)
2007-12-18 06:32 PST, Luca Bruno
no flags Details | Formatted Diff | Diff
coding style issues (22.45 KB, patch)
2007-12-20 04:23 PST, Luca Bruno
alp: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Luca Bruno 2007-12-05 12:40:52 PST
We can paste text/html and text/plain to editable contents such as rich text, but we can't copy from.
Comment 1 Luca Bruno 2007-12-07 04:32:38 PST
Created attachment 17769 [details]
patch

Add targets for plain text and text/html, then complete the implementation of copying text from the page. Adding targets meant adding new API, hopefully this is not wrong.

Please consider reviewing deeply the PasteboardGtk.cpp file which has a new struct.
Comment 2 Alp Toker 2007-12-07 05:18:49 PST
Comment on attachment 17769 [details]
patch

Hey Luca,

Unfortunately this patch is going to need some re-designing.

nothing in platform/gtk should use anything from WebKit/gtk. WebKit/gtk should be built on top of platform, never the other way round.

This means that we shouldn't need to add webkit_web_view_get_target_list() as public API either. It should remain totally internal, just like GtkTextView.

(The feature itself works well and this'll be a great feature to have.)
Comment 3 Luca Bruno 2007-12-07 08:19:55 PST
Created attachment 17770 [details]
cleaner patch

Diffs:
- Use a class instead of a struct in the C++ context, which would be useful for future enhancements like URIs and GtkTextBuffer data
- Create target entries inside Pasteboard
- Do not use API except for WebKitWebViewTargetInfo enum
Comment 4 Luca Bruno 2007-12-07 10:54:25 PST
Created attachment 17773 [details]
do not use webkit enum

Diffs:
- Define webkit target info enum
- Use the right GdkAtom

Pasteboard in in mac is used for DnD not for Pasteboard, therefore they can pass their PasteboardHelper from webkit. Instead, there's no way to do this for the Pasteboard.
Comment 5 Alp Toker 2007-12-10 10:23:32 PST
GtkTextBuffer has:

GtkTargetList*      gtk_text_buffer_get_copy_target_list
                                                        (GtkTextBuffer *buffer);
GtkTargetList*      gtk_text_buffer_get_paste_target_list
                                                        (GtkTextBuffer *buffer);

Is there a reason why this patch adds only one? webkit_web_view_get_target_list()

Just wondering, have not studied the case in detail.
Comment 6 Luca Bruno 2007-12-10 12:32:41 PST
Didn't think we need two different target lists. I just thought the copy target was the same as the paste target. As i see the text buffer has two target lists with the same contents.
Comment 7 Luca Bruno 2007-12-18 06:32:21 PST
Created attachment 17972 [details]
PasteboardHelper and use the right clipboard

Well i created a PasteboardHelper (please check the license) and a target list for both copy and paste operations.
Comment 8 Alp Toker 2007-12-19 16:35:59 PST
Mitch has offered to look into this one for clipboard API correctness. There are some minor coding style issues like whitespace before braces from a quick glance.
Comment 9 Luca Bruno 2007-12-20 04:23:01 PST
Created attachment 18005 [details]
coding style issues
Comment 10 Alp Toker 2007-12-22 15:08:45 PST
Comment on attachment 18005 [details]
coding style issues

r=me (thanks to Xan and Mitch for looking into this one too)

Will land with the discussed documentation and whitespace fixes.
Comment 11 Alp Toker 2007-12-22 15:13:04 PST
Landed in r28963.