Changeset 36323 in webkit
- Timestamp:
- Sep 10, 2008 1:30:18 PM (16 years ago)
- Location:
- trunk/WebKit/gtk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebKit/gtk/ChangeLog
r36263 r36323 1 2008-09-10 Alp Toker <alp@nuanti.com> 2 3 Reviewed by Mark Rowe. 4 5 https://bugs.webkit.org/show_bug.cgi?id=17267 6 [GTK] Primary selection/clipboard support 7 8 Implement primary selection support (copying only, no paste yet). 9 10 * WebCoreSupport/EditorClientGtk.cpp: 11 (WebKit::clipboard_get_contents_cb): 12 (WebKit::clipboard_clear_contents_cb): 13 (WebKit::EditorClient::respondToChangedSelection): 14 1 15 2008-09-07 Cameron Zwarich <cwzwarich@uwaterloo.ca> 2 16 -
trunk/WebKit/gtk/WebCoreSupport/EditorClientGtk.cpp
r35958 r36323 21 21 #include "EditorClientGtk.h" 22 22 23 #include "CString.h" 23 24 #include "EditCommand.h" 24 25 #include "Editor.h" … … 30 31 #include "Page.h" 31 32 #include "PlatformKeyboardEvent.h" 33 #include "markup.h" 32 34 #include "webkitprivate.h" 33 35 … … 163 165 } 164 166 167 #if GTK_CHECK_VERSION(2,10,0) 168 static void clipboard_get_contents_cb(GtkClipboard* clipboard, GtkSelectionData* selection_data, guint info, gpointer data) 169 { 170 WebKitWebView* webView = reinterpret_cast<WebKitWebView*>(data); 171 Frame* frame = core(webView)->focusController()->focusedOrMainFrame(); 172 PassRefPtr<Range> selectedRange = frame->selection()->toRange(); 173 174 if (static_cast<gint>(info) == WEBKIT_WEB_VIEW_TARGET_INFO_HTML) { 175 String markup = createMarkup(selectedRange.get(), 0, AnnotateForInterchange); 176 gtk_selection_data_set(selection_data, selection_data->target, 8, 177 reinterpret_cast<const guchar*>(markup.utf8().data()), markup.utf8().length()); 178 } else { 179 String text = selectedRange->text(); 180 gtk_selection_data_set_text(selection_data, text.utf8().data(), text.utf8().length()); 181 } 182 } 183 184 static void clipboard_clear_contents_cb(GtkClipboard* clipboard, gpointer data) 185 { 186 WebKitWebView* webView = reinterpret_cast<WebKitWebView*>(data); 187 Frame* frame = core(webView)->focusController()->focusedOrMainFrame(); 188 189 // Collapse the selection without clearing it 190 frame->selection()->setBase(frame->selection()->extent(), frame->selection()->affinity()); 191 } 192 #endif 193 165 194 void EditorClient::respondToChangedSelection() 166 195 { 167 196 WebKitWebViewPrivate* priv = m_webView->priv; 168 169 197 Frame* targetFrame = core(m_webView)->focusController()->focusedOrMainFrame(); 170 if (!targetFrame || !targetFrame->editor()->hasComposition()) 198 199 if (!targetFrame) 171 200 return; 172 201 173 202 if (targetFrame->editor()->ignoreCompositionSelectionChange()) 203 return; 204 205 #if GTK_CHECK_VERSION(2,10,0) 206 GtkClipboard* clipboard = gtk_widget_get_clipboard(GTK_WIDGET(m_webView), GDK_SELECTION_PRIMARY); 207 if (targetFrame->selection()->isRange()) { 208 GtkTargetList* targetList = webkit_web_view_get_copy_target_list(m_webView); 209 gint targetCount; 210 GtkTargetEntry* targets = gtk_target_table_new_from_list(targetList, &targetCount); 211 gtk_clipboard_set_with_owner(clipboard, targets, targetCount, 212 clipboard_get_contents_cb, clipboard_clear_contents_cb, G_OBJECT(m_webView)); 213 gtk_target_table_free(targets, targetCount); 214 } else if (gtk_clipboard_get_owner(clipboard) == G_OBJECT(m_webView)) 215 gtk_clipboard_clear(clipboard); 216 #endif 217 218 if (!targetFrame->editor()->hasComposition()) 174 219 return; 175 220
Note: See TracChangeset
for help on using the changeset viewer.