1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/gtk/webview_webkit.cpp
3 // Purpose: GTK WebKit backend for web view component
4 // Author: Marianne Gagnon, Robert Roebling
6 // Copyright: (c) 2010 Marianne Gagnon, 1998 Robert Roebling
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
10 // For compilers that support precompilation, includes "wx.h".
11 #include "wx/wxprec.h"
13 #if wxUSE_WEBVIEW_WEBKIT
15 #include "wx/stockitem.h"
16 #include "wx/gtk/webview_webkit.h"
17 #include "wx/gtk/control.h"
18 #include "wx/gtk/private.h"
19 #include "webkit/webkit.h"
21 // ----------------------------------------------------------------------------
23 // ----------------------------------------------------------------------------
29 wxgtk_webview_webkit_load_status(GtkWidget
* widget
,
31 wxWebViewWebKit
*webKitCtrl
)
33 if (!webKitCtrl
->m_ready
) return;
35 wxString url
= webKitCtrl
->GetCurrentURL();
37 WebKitLoadStatus status
;
38 g_object_get(G_OBJECT(widget
), "load-status", &status
, NULL
);
40 wxString target
; // TODO: get target (if possible)
42 if (status
== WEBKIT_LOAD_FINISHED
)
44 webKitCtrl
->m_busy
= false;
45 wxWebNavigationEvent
thisEvent(wxEVT_COMMAND_WEB_VIEW_LOADED
,
49 if (webKitCtrl
&& webKitCtrl
->GetEventHandler())
50 webKitCtrl
->GetEventHandler()->ProcessEvent(thisEvent
);
52 else if (status
== WEBKIT_LOAD_COMMITTED
)
54 webKitCtrl
->m_busy
= true;
55 wxWebNavigationEvent
thisEvent(wxEVT_COMMAND_WEB_VIEW_NAVIGATED
,
59 if (webKitCtrl
&& webKitCtrl
->GetEventHandler())
60 webKitCtrl
->GetEventHandler()->ProcessEvent(thisEvent
);
65 wxgtk_webview_webkit_navigation(WebKitWebView
*,
66 WebKitWebFrame
*frame
,
67 WebKitNetworkRequest
*request
,
68 WebKitWebNavigationAction
*,
69 WebKitWebPolicyDecision
*policy_decision
,
70 wxWebViewWebKit
*webKitCtrl
)
72 webKitCtrl
->m_busy
= true;
74 const gchar
* uri
= webkit_network_request_get_uri(request
);
76 wxString target
= webkit_web_frame_get_name (frame
);
77 wxWebNavigationEvent
thisEvent(wxEVT_COMMAND_WEB_VIEW_NAVIGATING
,
79 wxString( uri
, wxConvUTF8
),
83 if (webKitCtrl
&& webKitCtrl
->GetEventHandler())
84 webKitCtrl
->GetEventHandler()->ProcessEvent(thisEvent
);
86 if (thisEvent
.IsVetoed())
88 webKitCtrl
->m_busy
= false;
89 webkit_web_policy_decision_ignore(policy_decision
);
99 wxgtk_webview_webkit_error(WebKitWebView
*,
103 wxWebViewWebKit
* webKitWindow
)
105 webKitWindow
->m_busy
= false;
106 wxWebNavigationError type
= wxWEB_NAV_ERR_OTHER
;
108 GError
* error
= (GError
*)web_error
;
109 wxString
description(error
->message
, wxConvUTF8
);
111 if (strcmp(g_quark_to_string(error
->domain
), "soup_http_error_quark") == 0)
115 case SOUP_STATUS_CANCELLED
:
116 type
= wxWEB_NAV_ERR_USER_CANCELLED
;
119 case SOUP_STATUS_CANT_RESOLVE
:
120 case SOUP_STATUS_NOT_FOUND
:
121 type
= wxWEB_NAV_ERR_NOT_FOUND
;
124 case SOUP_STATUS_CANT_RESOLVE_PROXY
:
125 case SOUP_STATUS_CANT_CONNECT
:
126 case SOUP_STATUS_CANT_CONNECT_PROXY
:
127 case SOUP_STATUS_SSL_FAILED
:
128 case SOUP_STATUS_IO_ERROR
:
129 type
= wxWEB_NAV_ERR_CONNECTION
;
132 case SOUP_STATUS_MALFORMED
:
133 //case SOUP_STATUS_TOO_MANY_REDIRECTS:
134 type
= wxWEB_NAV_ERR_REQUEST
;
137 //case SOUP_STATUS_NO_CONTENT:
138 //case SOUP_STATUS_RESET_CONTENT:
140 case SOUP_STATUS_BAD_REQUEST
:
141 type
= wxWEB_NAV_ERR_REQUEST
;
144 case SOUP_STATUS_UNAUTHORIZED
:
145 case SOUP_STATUS_FORBIDDEN
:
146 type
= wxWEB_NAV_ERR_AUTH
;
149 case SOUP_STATUS_METHOD_NOT_ALLOWED
:
150 case SOUP_STATUS_NOT_ACCEPTABLE
:
151 type
= wxWEB_NAV_ERR_SECURITY
;
154 case SOUP_STATUS_PROXY_AUTHENTICATION_REQUIRED
:
155 type
= wxWEB_NAV_ERR_AUTH
;
158 case SOUP_STATUS_REQUEST_TIMEOUT
:
159 type
= wxWEB_NAV_ERR_CONNECTION
;
162 //case SOUP_STATUS_PAYMENT_REQUIRED:
163 case SOUP_STATUS_REQUEST_ENTITY_TOO_LARGE
:
164 case SOUP_STATUS_REQUEST_URI_TOO_LONG
:
165 case SOUP_STATUS_UNSUPPORTED_MEDIA_TYPE
:
166 type
= wxWEB_NAV_ERR_REQUEST
;
169 case SOUP_STATUS_BAD_GATEWAY
:
170 case SOUP_STATUS_SERVICE_UNAVAILABLE
:
171 case SOUP_STATUS_GATEWAY_TIMEOUT
:
172 type
= wxWEB_NAV_ERR_CONNECTION
;
175 case SOUP_STATUS_HTTP_VERSION_NOT_SUPPORTED
:
176 type
= wxWEB_NAV_ERR_REQUEST
;
178 //case SOUP_STATUS_INSUFFICIENT_STORAGE:
179 //case SOUP_STATUS_NOT_EXTENDED:
182 else if (strcmp(g_quark_to_string(error
->domain
),
183 "webkit-network-error-quark") == 0)
187 //WEBKIT_NETWORK_ERROR_FAILED:
188 //WEBKIT_NETWORK_ERROR_TRANSPORT:
190 case WEBKIT_NETWORK_ERROR_UNKNOWN_PROTOCOL
:
191 type
= wxWEB_NAV_ERR_REQUEST
;
194 case WEBKIT_NETWORK_ERROR_CANCELLED
:
195 type
= wxWEB_NAV_ERR_USER_CANCELLED
;
198 case WEBKIT_NETWORK_ERROR_FILE_DOES_NOT_EXIST
:
199 type
= wxWEB_NAV_ERR_NOT_FOUND
;
203 else if (strcmp(g_quark_to_string(error
->domain
),
204 "webkit-policy-error-quark") == 0)
208 //case WEBKIT_POLICY_ERROR_FAILED:
209 //case WEBKIT_POLICY_ERROR_CANNOT_SHOW_MIME_TYPE:
210 //case WEBKIT_POLICY_ERROR_CANNOT_SHOW_URL:
211 //case WEBKIT_POLICY_ERROR_FRAME_LOAD_INTERRUPTED_BY_POLICY_CHANGE:
212 case WEBKIT_POLICY_ERROR_CANNOT_USE_RESTRICTED_PORT
:
213 type
= wxWEB_NAV_ERR_SECURITY
;
218 webkit_plugin_error_quark
221 printf("Error domain %s\n", g_quark_to_string(error->domain));
225 wxWebNavigationEvent
thisEvent(wxEVT_COMMAND_WEB_VIEW_ERROR
,
226 webKitWindow
->GetId(),
230 thisEvent
.SetString(description
);
231 thisEvent
.SetInt(type
);
233 if (webKitWindow
&& webKitWindow
->GetEventHandler())
235 webKitWindow
->GetEventHandler()->ProcessEvent(thisEvent
);
242 wxgtk_webview_webkit_new_window(WebKitWebView
*,
243 WebKitWebFrame
*frame
,
244 WebKitNetworkRequest
*request
,
245 WebKitWebNavigationAction
*,
246 WebKitWebPolicyDecision
*policy_decision
,
247 wxWebViewWebKit
*webKitCtrl
)
249 const gchar
* uri
= webkit_network_request_get_uri(request
);
251 wxString target
= webkit_web_frame_get_name (frame
);
252 wxWebNavigationEvent
thisEvent(wxEVT_COMMAND_WEB_VIEW_NEWWINDOW
,
254 wxString( uri
, wxConvUTF8
),
258 if (webKitCtrl
&& webKitCtrl
->GetEventHandler())
259 webKitCtrl
->GetEventHandler()->ProcessEvent(thisEvent
);
261 if (thisEvent
.IsVetoed())
263 webkit_web_policy_decision_ignore(policy_decision
);
267 webkit_web_policy_decision_use(policy_decision
);
274 //-----------------------------------------------------------------------------
276 //-----------------------------------------------------------------------------
278 //IMPLEMENT_DYNAMIC_CLASS(wxWebViewWebKit, wxControl)
280 bool wxWebViewWebKit::Create(wxWindow
*parent
,
286 const wxString
& name
)
291 if (!PreCreation( parent
, pos
, size
) ||
292 !CreateBase( parent
, id
, pos
, size
, style
, wxDefaultValidator
, name
))
294 wxFAIL_MSG( wxT("wxWebViewWebKit creation failed") );
298 GtkWidget
*scrolled_window
= gtk_scrolled_window_new (NULL
, NULL
);
299 web_view
= webkit_web_view_new ();
300 g_object_ref(web_view
); // TODO: check memory management
302 m_widget
= scrolled_window
;
303 g_object_ref(m_widget
); // TODO: check memory management
305 /* Place the WebKitWebView in the GtkScrolledWindow */
306 gtk_container_add (GTK_CONTAINER (scrolled_window
), web_view
);
307 gtk_widget_show(m_widget
);
308 gtk_widget_show(web_view
);
310 g_signal_connect_after(web_view
, "notify::load-status",
311 G_CALLBACK(wxgtk_webview_webkit_load_status
),
313 g_signal_connect_after(web_view
, "navigation-policy-decision-requested",
314 G_CALLBACK(wxgtk_webview_webkit_navigation
),
316 g_signal_connect_after(web_view
, "load-error",
317 G_CALLBACK(wxgtk_webview_webkit_error
),
320 g_signal_connect_after(web_view
, "new-window-policy-decision-requested",
321 G_CALLBACK(wxgtk_webview_webkit_new_window
), this);
323 m_parent
->DoAddChild( this );
328 webkit_web_view_load_uri (WEBKIT_WEB_VIEW (web_view
), url
);
330 //Get the initial history limit so we can enable and disable it later
331 WebKitWebBackForwardList
* history
;
332 history
= webkit_web_view_get_back_forward_list(WEBKIT_WEB_VIEW(web_view
));
333 m_historyLimit
= webkit_web_back_forward_list_get_limit(history
);
340 bool wxWebViewWebKit::Enable( bool enable
)
342 if (!wxControl::Enable(enable
))
345 gtk_widget_set_sensitive(GTK_BIN(m_widget
)->child
, enable
);
348 // GTKFixSensitivity();
354 wxWebViewWebKit::GTKGetWindow(wxArrayGdkWindows
& WXUNUSED(windows
)) const
356 GdkWindow
* window
= gtk_widget_get_parent_window(m_widget
);
360 void wxWebViewWebKit::ZoomIn()
362 webkit_web_view_zoom_in (WEBKIT_WEB_VIEW(web_view
));
365 void wxWebViewWebKit::ZoomOut()
367 webkit_web_view_zoom_out (WEBKIT_WEB_VIEW(web_view
));
370 void wxWebViewWebKit::SetWebkitZoom(float level
)
372 webkit_web_view_set_zoom_level (WEBKIT_WEB_VIEW(web_view
), level
);
375 float wxWebViewWebKit::GetWebkitZoom()
377 return webkit_web_view_get_zoom_level (WEBKIT_WEB_VIEW(web_view
));
380 void wxWebViewWebKit::Stop()
382 webkit_web_view_stop_loading (WEBKIT_WEB_VIEW(web_view
));
385 void wxWebViewWebKit::Reload(wxWebViewReloadFlags flags
)
387 if (flags
& wxWEB_VIEW_RELOAD_NO_CACHE
)
389 webkit_web_view_reload_bypass_cache (WEBKIT_WEB_VIEW(web_view
));
393 webkit_web_view_reload (WEBKIT_WEB_VIEW(web_view
));
397 void wxWebViewWebKit::LoadUrl(const wxString
& url
)
399 webkit_web_view_load_uri(WEBKIT_WEB_VIEW(web_view
), wxGTK_CONV(url
));
403 void wxWebViewWebKit::GoBack()
405 webkit_web_view_go_back (WEBKIT_WEB_VIEW(web_view
));
408 void wxWebViewWebKit::GoForward()
410 webkit_web_view_go_forward (WEBKIT_WEB_VIEW(web_view
));
414 bool wxWebViewWebKit::CanGoBack()
416 return webkit_web_view_can_go_back (WEBKIT_WEB_VIEW(web_view
));
420 bool wxWebViewWebKit::CanGoForward()
422 return webkit_web_view_can_go_forward (WEBKIT_WEB_VIEW(web_view
));
425 void wxWebViewWebKit::ClearHistory()
427 WebKitWebBackForwardList
* history
;
428 history
= webkit_web_view_get_back_forward_list(WEBKIT_WEB_VIEW(web_view
));
429 webkit_web_back_forward_list_clear(history
);
432 void wxWebViewWebKit::EnableHistory(bool enable
)
434 WebKitWebBackForwardList
* history
;
435 history
= webkit_web_view_get_back_forward_list(WEBKIT_WEB_VIEW(web_view
));
438 webkit_web_back_forward_list_set_limit(history
, m_historyLimit
);
442 webkit_web_back_forward_list_set_limit(history
, 0);
446 wxVector
<wxSharedPtr
<wxWebHistoryItem
> > wxWebViewWebKit::GetBackwardHistory()
448 wxVector
<wxSharedPtr
<wxWebHistoryItem
> > backhist
;
449 WebKitWebBackForwardList
* history
;
450 history
= webkit_web_view_get_back_forward_list(WEBKIT_WEB_VIEW(web_view
));
451 GList
* list
= webkit_web_back_forward_list_get_back_list_with_limit(history
,
453 //We need to iterate in reverse to get the order we desire
454 for(int i
= g_list_length(list
) - 1; i
>= 0 ; i
--)
456 WebKitWebHistoryItem
* gtkitem
= (WebKitWebHistoryItem
*)g_list_nth_data(list
, i
);
457 wxSharedPtr
<wxWebHistoryItem
> item(new wxWebHistoryItem(
458 webkit_web_history_item_get_uri(gtkitem
),
459 webkit_web_history_item_get_title(gtkitem
)));
460 backhist
.push_back(item
);
461 m_historyMap
[item
] = gtkitem
;
466 wxVector
<wxSharedPtr
<wxWebHistoryItem
> > wxWebViewWebKit::GetForwardHistory()
468 wxVector
<wxSharedPtr
<wxWebHistoryItem
> > forwardhist
;
469 WebKitWebBackForwardList
* history
;
470 history
= webkit_web_view_get_back_forward_list(WEBKIT_WEB_VIEW(web_view
));
471 GList
* list
= webkit_web_back_forward_list_get_forward_list_with_limit(history
,
473 for(guint i
= 0; i
< g_list_length(list
); i
++)
475 WebKitWebHistoryItem
* gtkitem
= (WebKitWebHistoryItem
*)g_list_nth_data(list
, i
);
476 wxSharedPtr
<wxWebHistoryItem
> item(new wxWebHistoryItem(
477 webkit_web_history_item_get_uri(gtkitem
),
478 webkit_web_history_item_get_title(gtkitem
)));
479 forwardhist
.push_back(item
);
480 m_historyMap
[item
] = gtkitem
;
485 void wxWebViewWebKit::LoadHistoryItem(wxSharedPtr
<wxWebHistoryItem
> item
)
487 WebKitWebHistoryItem
* gtkitem
= m_historyMap
[item
];
490 WebKitWebBackForwardList
* history
;
491 history
= webkit_web_view_get_back_forward_list(WEBKIT_WEB_VIEW(web_view
));
492 webkit_web_back_forward_list_go_to_item(history
, gtkitem
);
496 bool wxWebViewWebKit::CanCut()
498 return webkit_web_view_can_cut_clipboard(WEBKIT_WEB_VIEW(web_view
));
501 bool wxWebViewWebKit::CanCopy()
503 return webkit_web_view_can_copy_clipboard(WEBKIT_WEB_VIEW(web_view
));
506 bool wxWebViewWebKit::CanPaste()
508 return webkit_web_view_can_paste_clipboard(WEBKIT_WEB_VIEW(web_view
));
511 void wxWebViewWebKit::Cut()
513 webkit_web_view_cut_clipboard(WEBKIT_WEB_VIEW(web_view
));
516 void wxWebViewWebKit::Copy()
518 webkit_web_view_copy_clipboard(WEBKIT_WEB_VIEW(web_view
));
521 void wxWebViewWebKit::Paste()
523 webkit_web_view_paste_clipboard(WEBKIT_WEB_VIEW(web_view
));
526 bool wxWebViewWebKit::CanUndo()
528 return webkit_web_view_can_undo(WEBKIT_WEB_VIEW(web_view
));
531 bool wxWebViewWebKit::CanRedo()
533 return webkit_web_view_can_redo(WEBKIT_WEB_VIEW(web_view
));
536 void wxWebViewWebKit::Undo()
538 webkit_web_view_undo(WEBKIT_WEB_VIEW(web_view
));
541 void wxWebViewWebKit::Redo()
543 webkit_web_view_redo(WEBKIT_WEB_VIEW(web_view
));
546 wxString
wxWebViewWebKit::GetCurrentURL()
548 // FIXME: check which encoding the web kit control uses instead of
549 // assuming UTF8 (here and elsewhere too)
550 return wxString::FromUTF8(webkit_web_view_get_uri(
551 WEBKIT_WEB_VIEW(web_view
)));
555 wxString
wxWebViewWebKit::GetCurrentTitle()
557 return wxString::FromUTF8(webkit_web_view_get_title(
558 WEBKIT_WEB_VIEW(web_view
)));
562 wxString
wxWebViewWebKit::GetPageSource()
564 WebKitWebFrame
* frame
= webkit_web_view_get_main_frame(
565 WEBKIT_WEB_VIEW(web_view
));
566 WebKitWebDataSource
* src
= webkit_web_frame_get_data_source (frame
);
568 // TODO: check encoding with
570 // webkit_web_data_source_get_encoding(WebKitWebDataSource *data_source);
571 return wxString(webkit_web_data_source_get_data (src
)->str
, wxConvUTF8
);
575 wxWebViewZoom
wxWebViewWebKit::GetZoom()
577 float zoom
= GetWebkitZoom();
579 // arbitrary way to map float zoom to our common zoom enum
582 return wxWEB_VIEW_ZOOM_TINY
;
584 else if (zoom
> 0.65 && zoom
<= 0.90)
586 return wxWEB_VIEW_ZOOM_SMALL
;
588 else if (zoom
> 0.90 && zoom
<= 1.15)
590 return wxWEB_VIEW_ZOOM_MEDIUM
;
592 else if (zoom
> 1.15 && zoom
<= 1.45)
594 return wxWEB_VIEW_ZOOM_LARGE
;
596 else if (zoom
> 1.45)
598 return wxWEB_VIEW_ZOOM_LARGEST
;
601 // to shut up compilers, this can never be reached logically
603 return wxWEB_VIEW_ZOOM_MEDIUM
;
607 void wxWebViewWebKit::SetZoom(wxWebViewZoom zoom
)
609 // arbitrary way to map our common zoom enum to float zoom
612 case wxWEB_VIEW_ZOOM_TINY
:
616 case wxWEB_VIEW_ZOOM_SMALL
:
620 case wxWEB_VIEW_ZOOM_MEDIUM
:
624 case wxWEB_VIEW_ZOOM_LARGE
:
628 case wxWEB_VIEW_ZOOM_LARGEST
:
637 void wxWebViewWebKit::SetZoomType(wxWebViewZoomType type
)
639 webkit_web_view_set_full_content_zoom(WEBKIT_WEB_VIEW(web_view
),
640 (type
== wxWEB_VIEW_ZOOM_TYPE_LAYOUT
?
644 wxWebViewZoomType
wxWebViewWebKit::GetZoomType() const
646 gboolean fczoom
= webkit_web_view_get_full_content_zoom(
647 WEBKIT_WEB_VIEW(web_view
));
649 if (fczoom
) return wxWEB_VIEW_ZOOM_TYPE_LAYOUT
;
650 else return wxWEB_VIEW_ZOOM_TYPE_TEXT
;
653 bool wxWebViewWebKit::CanSetZoomType(wxWebViewZoomType
) const
655 // this port supports all zoom types
659 void wxWebViewWebKit::SetPage(const wxString
& html
, const wxString
& baseUri
)
661 webkit_web_view_load_string (WEBKIT_WEB_VIEW(web_view
),
662 html
.mb_str(wxConvUTF8
),
665 baseUri
.mb_str(wxConvUTF8
));
668 void wxWebViewWebKit::Print()
670 WebKitWebFrame
* frame
= webkit_web_view_get_main_frame(
671 WEBKIT_WEB_VIEW(web_view
));
672 webkit_web_frame_print (frame
);
674 // GtkPrintOperationResult webkit_web_frame_print_full
675 // (WebKitWebFrame *frame,
676 // GtkPrintOperation *operation,
677 // GtkPrintOperationAction action,
683 bool wxWebViewWebKit::IsBusy()
687 // This code looks nice but returns true after a page was cancelled
689 WebKitLoadStatus status = webkit_web_view_get_load_status
690 (WEBKIT_WEB_VIEW(web_view));
693 #if WEBKIT_CHECK_VERSION(1,1,16)
694 // WEBKIT_LOAD_FAILED is new in webkit 1.1.16
695 if (status == WEBKIT_LOAD_FAILED)
700 if (status == WEBKIT_LOAD_FINISHED)
709 void wxWebViewWebKit::SetEditable(bool enable
)
711 webkit_web_view_set_editable(WEBKIT_WEB_VIEW(web_view
), enable
);
714 bool wxWebViewWebKit::IsEditable()
716 return webkit_web_view_get_editable(WEBKIT_WEB_VIEW(web_view
));
719 void wxWebViewWebKit::DeleteSelection()
721 webkit_web_view_delete_selection(WEBKIT_WEB_VIEW(web_view
));
724 bool wxWebViewWebKit::HasSelection()
726 return webkit_web_view_has_selection(WEBKIT_WEB_VIEW(web_view
));
729 void wxWebViewWebKit::SelectAll()
731 webkit_web_view_select_all(WEBKIT_WEB_VIEW(web_view
));
734 wxString
wxWebViewWebKit::GetSelectedText()
736 WebKitDOMDocument
* doc
;
737 WebKitDOMDOMWindow
* win
;
738 WebKitDOMDOMSelection
* sel
;
739 WebKitDOMRange
* range
;
741 doc
= webkit_web_view_get_dom_document(WEBKIT_WEB_VIEW(web_view
));
742 win
= webkit_dom_document_get_default_view(WEBKIT_DOM_DOCUMENT(doc
));
743 sel
= webkit_dom_dom_window_get_selection(WEBKIT_DOM_DOM_WINDOW(win
));
744 range
= webkit_dom_dom_selection_get_range_at(WEBKIT_DOM_DOM_SELECTION(sel
),
746 return wxString(webkit_dom_range_get_text(WEBKIT_DOM_RANGE(range
)),
750 wxString
wxWebViewWebKit::GetSelectedSource()
752 WebKitDOMDocument
* doc
;
753 WebKitDOMDOMWindow
* win
;
754 WebKitDOMDOMSelection
* sel
;
755 WebKitDOMRange
* range
;
756 WebKitDOMElement
* div
;
757 WebKitDOMDocumentFragment
* clone
;
758 WebKitDOMHTMLElement
* html
;
760 doc
= webkit_web_view_get_dom_document(WEBKIT_WEB_VIEW(web_view
));
761 win
= webkit_dom_document_get_default_view(WEBKIT_DOM_DOCUMENT(doc
));
762 sel
= webkit_dom_dom_window_get_selection(WEBKIT_DOM_DOM_WINDOW(win
));
763 range
= webkit_dom_dom_selection_get_range_at(WEBKIT_DOM_DOM_SELECTION(sel
),
765 div
= webkit_dom_document_create_element(WEBKIT_DOM_DOCUMENT(doc
), "div", NULL
);
767 clone
= webkit_dom_range_clone_contents(WEBKIT_DOM_RANGE(range
), NULL
);
768 webkit_dom_node_append_child(&div
->parent_instance
, &clone
->parent_instance
, NULL
);
769 html
= (WebKitDOMHTMLElement
*)div
;
771 return wxString(webkit_dom_html_element_get_inner_html(WEBKIT_DOM_HTML_ELEMENT(html
)),
775 void wxWebViewWebKit::ClearSelection()
777 WebKitDOMDocument
* doc
;
778 WebKitDOMDOMWindow
* win
;
779 WebKitDOMDOMSelection
* sel
;
781 doc
= webkit_web_view_get_dom_document(WEBKIT_WEB_VIEW(web_view
));
782 win
= webkit_dom_document_get_default_view(WEBKIT_DOM_DOCUMENT(doc
));
783 sel
= webkit_dom_dom_window_get_selection(WEBKIT_DOM_DOM_WINDOW(win
));
784 webkit_dom_dom_selection_remove_all_ranges(WEBKIT_DOM_DOM_SELECTION(sel
));
788 wxString
wxWebViewWebKit::GetPageText()
790 WebKitDOMDocument
* doc
;
791 WebKitDOMHTMLElement
* body
;
793 doc
= webkit_web_view_get_dom_document(WEBKIT_WEB_VIEW(web_view
));
794 body
= webkit_dom_document_get_body(WEBKIT_DOM_DOCUMENT(doc
));
795 return wxString(webkit_dom_html_element_get_inner_text(WEBKIT_DOM_HTML_ELEMENT(body
)),
799 void wxWebViewWebKit::RunScript(const wxString
& javascript
)
801 webkit_web_view_execute_script(WEBKIT_WEB_VIEW(web_view
),
802 javascript
.mb_str(wxConvUTF8
));
807 wxWebViewWebKit::GetClassDefaultAttributes(wxWindowVariant
WXUNUSED(variant
))
809 return GetDefaultAttributesFromGTKWidget(webkit_web_view_new
);
813 #endif // wxHAVE_WEB_BACKEND_GTK_WEBKIT