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_webkitctrl_load_status_callback(GtkWidget
* widget
, GParamSpec
*,
30 wxWebViewWebKit
*webKitCtrl
)
32 if (!webKitCtrl
->m_ready
) return;
34 wxString url
= webKitCtrl
->GetCurrentURL();
36 WebKitLoadStatus status
;
37 g_object_get(G_OBJECT(widget
), "load-status", &status
, NULL
);
39 wxString target
; // TODO: get target (if possible)
41 if (status
== WEBKIT_LOAD_FINISHED
)
43 webKitCtrl
->m_busy
= false;
44 wxWebNavigationEvent
thisEvent(wxEVT_COMMAND_WEB_VIEW_LOADED
,
48 if (webKitCtrl
&& webKitCtrl
->GetEventHandler())
49 webKitCtrl
->GetEventHandler()->ProcessEvent(thisEvent
);
51 else if (status
== WEBKIT_LOAD_COMMITTED
)
53 webKitCtrl
->m_busy
= true;
54 wxWebNavigationEvent
thisEvent(wxEVT_COMMAND_WEB_VIEW_NAVIGATED
,
58 if (webKitCtrl
&& webKitCtrl
->GetEventHandler())
59 webKitCtrl
->GetEventHandler()->ProcessEvent(thisEvent
);
64 wxgtk_webview_webkit_navigation(WebKitWebView
*,
65 WebKitWebFrame
*frame
,
66 WebKitNetworkRequest
*request
,
67 WebKitWebNavigationAction
*,
68 WebKitWebPolicyDecision
*policy_decision
,
69 wxWebViewWebKit
*webKitCtrl
)
71 webKitCtrl
->m_busy
= true;
73 const gchar
* uri
= webkit_network_request_get_uri(request
);
75 wxString target
= webkit_web_frame_get_name (frame
);
76 wxWebNavigationEvent
thisEvent(wxEVT_COMMAND_WEB_VIEW_NAVIGATING
,
78 wxString( uri
, wxConvUTF8
),
82 if (webKitCtrl
&& webKitCtrl
->GetEventHandler())
83 webKitCtrl
->GetEventHandler()->ProcessEvent(thisEvent
);
85 if (thisEvent
.IsVetoed())
87 webKitCtrl
->m_busy
= false;
88 webkit_web_policy_decision_ignore(policy_decision
);
98 wxgtk_webkitctrl_error (WebKitWebView
*,
102 wxWebViewWebKit
* webKitWindow
)
104 webKitWindow
->m_busy
= false;
105 wxWebNavigationError type
= wxWEB_NAV_ERR_OTHER
;
107 GError
* error
= (GError
*)web_error
;
108 wxString
description(error
->message
, wxConvUTF8
);
110 if (strcmp(g_quark_to_string(error
->domain
), "soup_http_error_quark") == 0)
114 case SOUP_STATUS_CANCELLED
:
115 type
= wxWEB_NAV_ERR_USER_CANCELLED
;
118 case SOUP_STATUS_CANT_RESOLVE
:
119 case SOUP_STATUS_NOT_FOUND
:
120 type
= wxWEB_NAV_ERR_NOT_FOUND
;
123 case SOUP_STATUS_CANT_RESOLVE_PROXY
:
124 case SOUP_STATUS_CANT_CONNECT
:
125 case SOUP_STATUS_CANT_CONNECT_PROXY
:
126 case SOUP_STATUS_SSL_FAILED
:
127 case SOUP_STATUS_IO_ERROR
:
128 type
= wxWEB_NAV_ERR_CONNECTION
;
131 case SOUP_STATUS_MALFORMED
:
132 //case SOUP_STATUS_TOO_MANY_REDIRECTS:
133 type
= wxWEB_NAV_ERR_REQUEST
;
136 //case SOUP_STATUS_NO_CONTENT:
137 //case SOUP_STATUS_RESET_CONTENT:
139 case SOUP_STATUS_BAD_REQUEST
:
140 type
= wxWEB_NAV_ERR_REQUEST
;
143 case SOUP_STATUS_UNAUTHORIZED
:
144 case SOUP_STATUS_FORBIDDEN
:
145 type
= wxWEB_NAV_ERR_AUTH
;
148 case SOUP_STATUS_METHOD_NOT_ALLOWED
:
149 case SOUP_STATUS_NOT_ACCEPTABLE
:
150 type
= wxWEB_NAV_ERR_SECURITY
;
153 case SOUP_STATUS_PROXY_AUTHENTICATION_REQUIRED
:
154 type
= wxWEB_NAV_ERR_AUTH
;
157 case SOUP_STATUS_REQUEST_TIMEOUT
:
158 type
= wxWEB_NAV_ERR_CONNECTION
;
161 //case SOUP_STATUS_PAYMENT_REQUIRED:
162 case SOUP_STATUS_REQUEST_ENTITY_TOO_LARGE
:
163 case SOUP_STATUS_REQUEST_URI_TOO_LONG
:
164 case SOUP_STATUS_UNSUPPORTED_MEDIA_TYPE
:
165 type
= wxWEB_NAV_ERR_REQUEST
;
168 case SOUP_STATUS_BAD_GATEWAY
:
169 case SOUP_STATUS_SERVICE_UNAVAILABLE
:
170 case SOUP_STATUS_GATEWAY_TIMEOUT
:
171 type
= wxWEB_NAV_ERR_CONNECTION
;
174 case SOUP_STATUS_HTTP_VERSION_NOT_SUPPORTED
:
175 type
= wxWEB_NAV_ERR_REQUEST
;
177 //case SOUP_STATUS_INSUFFICIENT_STORAGE:
178 //case SOUP_STATUS_NOT_EXTENDED:
181 else if (strcmp(g_quark_to_string(error
->domain
),
182 "webkit-network-error-quark") == 0)
186 //WEBKIT_NETWORK_ERROR_FAILED:
187 //WEBKIT_NETWORK_ERROR_TRANSPORT:
189 case WEBKIT_NETWORK_ERROR_UNKNOWN_PROTOCOL
:
190 type
= wxWEB_NAV_ERR_REQUEST
;
193 case WEBKIT_NETWORK_ERROR_CANCELLED
:
194 type
= wxWEB_NAV_ERR_USER_CANCELLED
;
197 case WEBKIT_NETWORK_ERROR_FILE_DOES_NOT_EXIST
:
198 type
= wxWEB_NAV_ERR_NOT_FOUND
;
202 else if (strcmp(g_quark_to_string(error
->domain
),
203 "webkit-policy-error-quark") == 0)
207 //case WEBKIT_POLICY_ERROR_FAILED:
208 //case WEBKIT_POLICY_ERROR_CANNOT_SHOW_MIME_TYPE:
209 //case WEBKIT_POLICY_ERROR_CANNOT_SHOW_URL:
210 //case WEBKIT_POLICY_ERROR_FRAME_LOAD_INTERRUPTED_BY_POLICY_CHANGE:
211 case WEBKIT_POLICY_ERROR_CANNOT_USE_RESTRICTED_PORT
:
212 type
= wxWEB_NAV_ERR_SECURITY
;
217 webkit_plugin_error_quark
220 printf("Error domain %s\n", g_quark_to_string(error->domain));
224 wxWebNavigationEvent
thisEvent(wxEVT_COMMAND_WEB_VIEW_ERROR
,
225 webKitWindow
->GetId(),
229 thisEvent
.SetString(description
);
230 thisEvent
.SetInt(type
);
232 if (webKitWindow
&& webKitWindow
->GetEventHandler())
234 webKitWindow
->GetEventHandler()->ProcessEvent(thisEvent
);
241 wxgtk_webkitctrl_new_window(WebKitWebView
*,
242 WebKitWebFrame
*frame
,
243 WebKitNetworkRequest
*request
,
244 WebKitWebNavigationAction
*,
245 WebKitWebPolicyDecision
*policy_decision
,
246 wxWebViewWebKit
*webKitCtrl
)
248 const gchar
* uri
= webkit_network_request_get_uri(request
);
250 wxString target
= webkit_web_frame_get_name (frame
);
251 wxWebNavigationEvent
thisEvent(wxEVT_COMMAND_WEB_VIEW_NEWWINDOW
,
253 wxString( uri
, wxConvUTF8
),
257 if (webKitCtrl
&& webKitCtrl
->GetEventHandler())
258 webKitCtrl
->GetEventHandler()->ProcessEvent(thisEvent
);
260 if (thisEvent
.IsVetoed())
262 webkit_web_policy_decision_ignore(policy_decision
);
266 webkit_web_policy_decision_use(policy_decision
);
273 //-----------------------------------------------------------------------------
275 //-----------------------------------------------------------------------------
277 //IMPLEMENT_DYNAMIC_CLASS(wxWebViewWebKit, wxControl)
279 bool wxWebViewWebKit::Create(wxWindow
*parent
,
285 const wxString
& name
)
290 if (!PreCreation( parent
, pos
, size
) ||
291 !CreateBase( parent
, id
, pos
, size
, style
, wxDefaultValidator
, name
))
293 wxFAIL_MSG( wxT("wxWebViewWebKit creation failed") );
297 GtkWidget
*scrolled_window
= gtk_scrolled_window_new (NULL
, NULL
);
298 web_view
= webkit_web_view_new ();
299 g_object_ref(web_view
); // TODO: check memory management
301 m_widget
= scrolled_window
;
302 g_object_ref(m_widget
); // TODO: check memory management
304 /* Place the WebKitWebView in the GtkScrolledWindow */
305 gtk_container_add (GTK_CONTAINER (scrolled_window
), web_view
);
306 gtk_widget_show(m_widget
);
307 gtk_widget_show(web_view
);
309 g_signal_connect_after(web_view
, "notify::load-status",
310 G_CALLBACK(wxgtk_webkitctrl_load_status_callback
),
312 g_signal_connect_after(web_view
, "navigation-policy-decision-requested",
313 G_CALLBACK(wxgtk_webview_webkit_navigation
),
315 g_signal_connect_after(web_view
, "load-error",
316 G_CALLBACK(wxgtk_webkitctrl_error
),
319 g_signal_connect_after(web_view
, "new-window-policy-decision-requested",
320 G_CALLBACK(wxgtk_webkitctrl_new_window
), this);
322 m_parent
->DoAddChild( this );
327 webkit_web_view_load_uri (WEBKIT_WEB_VIEW (web_view
), url
);
329 //Get the initial history limit so we can enable and disable it later
330 WebKitWebBackForwardList
* history
;
331 history
= webkit_web_view_get_back_forward_list(WEBKIT_WEB_VIEW(web_view
));
332 m_historyLimit
= webkit_web_back_forward_list_get_limit(history
);
339 bool wxWebViewWebKit::Enable( bool enable
)
341 if (!wxControl::Enable(enable
))
344 gtk_widget_set_sensitive(GTK_BIN(m_widget
)->child
, enable
);
347 // GTKFixSensitivity();
353 wxWebViewWebKit::GTKGetWindow(wxArrayGdkWindows
& WXUNUSED(windows
)) const
355 GdkWindow
* window
= gtk_widget_get_parent_window(m_widget
);
359 void wxWebViewWebKit::ZoomIn()
361 webkit_web_view_zoom_in (WEBKIT_WEB_VIEW(web_view
));
364 void wxWebViewWebKit::ZoomOut()
366 webkit_web_view_zoom_out (WEBKIT_WEB_VIEW(web_view
));
369 void wxWebViewWebKit::SetWebkitZoom(float level
)
371 webkit_web_view_set_zoom_level (WEBKIT_WEB_VIEW(web_view
), level
);
374 float wxWebViewWebKit::GetWebkitZoom()
376 return webkit_web_view_get_zoom_level (WEBKIT_WEB_VIEW(web_view
));
379 void wxWebViewWebKit::Stop()
381 webkit_web_view_stop_loading (WEBKIT_WEB_VIEW(web_view
));
384 void wxWebViewWebKit::Reload(wxWebViewReloadFlags flags
)
386 if (flags
& wxWEB_VIEW_RELOAD_NO_CACHE
)
388 webkit_web_view_reload_bypass_cache (WEBKIT_WEB_VIEW(web_view
));
392 webkit_web_view_reload (WEBKIT_WEB_VIEW(web_view
));
396 void wxWebViewWebKit::LoadUrl(const wxString
& url
)
398 webkit_web_view_load_uri(WEBKIT_WEB_VIEW(web_view
), wxGTK_CONV(url
));
402 void wxWebViewWebKit::GoBack()
404 webkit_web_view_go_back (WEBKIT_WEB_VIEW(web_view
));
407 void wxWebViewWebKit::GoForward()
409 webkit_web_view_go_forward (WEBKIT_WEB_VIEW(web_view
));
413 bool wxWebViewWebKit::CanGoBack()
415 return webkit_web_view_can_go_back (WEBKIT_WEB_VIEW(web_view
));
419 bool wxWebViewWebKit::CanGoForward()
421 return webkit_web_view_can_go_forward (WEBKIT_WEB_VIEW(web_view
));
424 void wxWebViewWebKit::ClearHistory()
426 WebKitWebBackForwardList
* history
;
427 history
= webkit_web_view_get_back_forward_list(WEBKIT_WEB_VIEW(web_view
));
428 webkit_web_back_forward_list_clear(history
);
431 void wxWebViewWebKit::EnableHistory(bool enable
)
433 WebKitWebBackForwardList
* history
;
434 history
= webkit_web_view_get_back_forward_list(WEBKIT_WEB_VIEW(web_view
));
437 webkit_web_back_forward_list_set_limit(history
, m_historyLimit
);
441 webkit_web_back_forward_list_set_limit(history
, 0);
445 wxVector
<wxSharedPtr
<wxWebHistoryItem
> > wxWebViewWebKit::GetBackwardHistory()
447 wxVector
<wxSharedPtr
<wxWebHistoryItem
> > backhist
;
448 WebKitWebBackForwardList
* history
;
449 history
= webkit_web_view_get_back_forward_list(WEBKIT_WEB_VIEW(web_view
));
450 GList
* list
= webkit_web_back_forward_list_get_back_list_with_limit(history
,
452 //We need to iterate in reverse to get the order we desire
453 for(int i
= g_list_length(list
) - 1; i
>= 0 ; i
--)
455 WebKitWebHistoryItem
* gtkitem
= (WebKitWebHistoryItem
*)g_list_nth_data(list
, i
);
456 wxSharedPtr
<wxWebHistoryItem
> item(new wxWebHistoryItem(
457 webkit_web_history_item_get_uri(gtkitem
),
458 webkit_web_history_item_get_title(gtkitem
)));
459 backhist
.push_back(item
);
460 m_historyMap
[item
] = gtkitem
;
465 wxVector
<wxSharedPtr
<wxWebHistoryItem
> > wxWebViewWebKit::GetForwardHistory()
467 wxVector
<wxSharedPtr
<wxWebHistoryItem
> > forwardhist
;
468 WebKitWebBackForwardList
* history
;
469 history
= webkit_web_view_get_back_forward_list(WEBKIT_WEB_VIEW(web_view
));
470 GList
* list
= webkit_web_back_forward_list_get_forward_list_with_limit(history
,
472 for(guint i
= 0; i
< g_list_length(list
); i
++)
474 WebKitWebHistoryItem
* gtkitem
= (WebKitWebHistoryItem
*)g_list_nth_data(list
, i
);
475 wxSharedPtr
<wxWebHistoryItem
> item(new wxWebHistoryItem(
476 webkit_web_history_item_get_uri(gtkitem
),
477 webkit_web_history_item_get_title(gtkitem
)));
478 forwardhist
.push_back(item
);
479 m_historyMap
[item
] = gtkitem
;
484 void wxWebViewWebKit::LoadHistoryItem(wxSharedPtr
<wxWebHistoryItem
> item
)
486 WebKitWebHistoryItem
* gtkitem
= m_historyMap
[item
];
489 WebKitWebBackForwardList
* history
;
490 history
= webkit_web_view_get_back_forward_list(WEBKIT_WEB_VIEW(web_view
));
491 webkit_web_back_forward_list_go_to_item(history
, gtkitem
);
495 bool wxWebViewWebKit::CanCut()
497 return webkit_web_view_can_cut_clipboard(WEBKIT_WEB_VIEW(web_view
));
500 bool wxWebViewWebKit::CanCopy()
502 return webkit_web_view_can_copy_clipboard(WEBKIT_WEB_VIEW(web_view
));
505 bool wxWebViewWebKit::CanPaste()
507 return webkit_web_view_can_paste_clipboard(WEBKIT_WEB_VIEW(web_view
));
510 void wxWebViewWebKit::Cut()
512 webkit_web_view_cut_clipboard(WEBKIT_WEB_VIEW(web_view
));
515 void wxWebViewWebKit::Copy()
517 webkit_web_view_copy_clipboard(WEBKIT_WEB_VIEW(web_view
));
520 void wxWebViewWebKit::Paste()
522 webkit_web_view_paste_clipboard(WEBKIT_WEB_VIEW(web_view
));
525 bool wxWebViewWebKit::CanUndo()
527 return webkit_web_view_can_undo(WEBKIT_WEB_VIEW(web_view
));
530 bool wxWebViewWebKit::CanRedo()
532 return webkit_web_view_can_redo(WEBKIT_WEB_VIEW(web_view
));
535 void wxWebViewWebKit::Undo()
537 webkit_web_view_undo(WEBKIT_WEB_VIEW(web_view
));
540 void wxWebViewWebKit::Redo()
542 webkit_web_view_redo(WEBKIT_WEB_VIEW(web_view
));
545 wxString
wxWebViewWebKit::GetCurrentURL()
547 // FIXME: check which encoding the web kit control uses instead of
548 // assuming UTF8 (here and elsewhere too)
549 return wxString::FromUTF8(webkit_web_view_get_uri(
550 WEBKIT_WEB_VIEW(web_view
)));
554 wxString
wxWebViewWebKit::GetCurrentTitle()
556 return wxString::FromUTF8(webkit_web_view_get_title(
557 WEBKIT_WEB_VIEW(web_view
)));
561 wxString
wxWebViewWebKit::GetPageSource()
563 WebKitWebFrame
* frame
= webkit_web_view_get_main_frame(
564 WEBKIT_WEB_VIEW(web_view
));
565 WebKitWebDataSource
* src
= webkit_web_frame_get_data_source (frame
);
567 // TODO: check encoding with
569 // webkit_web_data_source_get_encoding(WebKitWebDataSource *data_source);
570 return wxString(webkit_web_data_source_get_data (src
)->str
, wxConvUTF8
);
574 wxWebViewZoom
wxWebViewWebKit::GetZoom()
576 float zoom
= GetWebkitZoom();
578 // arbitrary way to map float zoom to our common zoom enum
581 return wxWEB_VIEW_ZOOM_TINY
;
583 else if (zoom
> 0.65 && zoom
<= 0.90)
585 return wxWEB_VIEW_ZOOM_SMALL
;
587 else if (zoom
> 0.90 && zoom
<= 1.15)
589 return wxWEB_VIEW_ZOOM_MEDIUM
;
591 else if (zoom
> 1.15 && zoom
<= 1.45)
593 return wxWEB_VIEW_ZOOM_LARGE
;
595 else if (zoom
> 1.45)
597 return wxWEB_VIEW_ZOOM_LARGEST
;
600 // to shut up compilers, this can never be reached logically
602 return wxWEB_VIEW_ZOOM_MEDIUM
;
606 void wxWebViewWebKit::SetZoom(wxWebViewZoom zoom
)
608 // arbitrary way to map our common zoom enum to float zoom
611 case wxWEB_VIEW_ZOOM_TINY
:
615 case wxWEB_VIEW_ZOOM_SMALL
:
619 case wxWEB_VIEW_ZOOM_MEDIUM
:
623 case wxWEB_VIEW_ZOOM_LARGE
:
627 case wxWEB_VIEW_ZOOM_LARGEST
:
636 void wxWebViewWebKit::SetZoomType(wxWebViewZoomType type
)
638 webkit_web_view_set_full_content_zoom(WEBKIT_WEB_VIEW(web_view
),
639 (type
== wxWEB_VIEW_ZOOM_TYPE_LAYOUT
?
643 wxWebViewZoomType
wxWebViewWebKit::GetZoomType() const
645 gboolean fczoom
= webkit_web_view_get_full_content_zoom(
646 WEBKIT_WEB_VIEW(web_view
));
648 if (fczoom
) return wxWEB_VIEW_ZOOM_TYPE_LAYOUT
;
649 else return wxWEB_VIEW_ZOOM_TYPE_TEXT
;
652 bool wxWebViewWebKit::CanSetZoomType(wxWebViewZoomType
) const
654 // this port supports all zoom types
658 void wxWebViewWebKit::SetPage(const wxString
& html
, const wxString
& baseUri
)
660 webkit_web_view_load_string (WEBKIT_WEB_VIEW(web_view
),
661 html
.mb_str(wxConvUTF8
),
664 baseUri
.mb_str(wxConvUTF8
));
667 void wxWebViewWebKit::Print()
669 WebKitWebFrame
* frame
= webkit_web_view_get_main_frame(
670 WEBKIT_WEB_VIEW(web_view
));
671 webkit_web_frame_print (frame
);
673 // GtkPrintOperationResult webkit_web_frame_print_full
674 // (WebKitWebFrame *frame,
675 // GtkPrintOperation *operation,
676 // GtkPrintOperationAction action,
682 bool wxWebViewWebKit::IsBusy()
686 // This code looks nice but returns true after a page was cancelled
688 WebKitLoadStatus status = webkit_web_view_get_load_status
689 (WEBKIT_WEB_VIEW(web_view));
692 #if WEBKIT_CHECK_VERSION(1,1,16)
693 // WEBKIT_LOAD_FAILED is new in webkit 1.1.16
694 if (status == WEBKIT_LOAD_FAILED)
699 if (status == WEBKIT_LOAD_FINISHED)
708 void wxWebViewWebKit::SetEditable(bool enable
)
710 webkit_web_view_set_editable(WEBKIT_WEB_VIEW(web_view
), enable
);
713 bool wxWebViewWebKit::IsEditable()
715 return webkit_web_view_get_editable(WEBKIT_WEB_VIEW(web_view
));
718 void wxWebViewWebKit::DeleteSelection()
720 webkit_web_view_delete_selection(WEBKIT_WEB_VIEW(web_view
));
723 bool wxWebViewWebKit::HasSelection()
725 return webkit_web_view_has_selection(WEBKIT_WEB_VIEW(web_view
));
728 void wxWebViewWebKit::SelectAll()
730 webkit_web_view_select_all(WEBKIT_WEB_VIEW(web_view
));
733 wxString
wxWebViewWebKit::GetSelectedText()
735 WebKitDOMDocument
* doc
;
736 WebKitDOMDOMWindow
* win
;
737 WebKitDOMDOMSelection
* sel
;
738 WebKitDOMRange
* range
;
740 doc
= webkit_web_view_get_dom_document(WEBKIT_WEB_VIEW(web_view
));
741 win
= webkit_dom_document_get_default_view(WEBKIT_DOM_DOCUMENT(doc
));
742 sel
= webkit_dom_dom_window_get_selection(WEBKIT_DOM_DOM_WINDOW(win
));
743 range
= webkit_dom_dom_selection_get_range_at(WEBKIT_DOM_DOM_SELECTION(sel
),
745 return wxString(webkit_dom_range_get_text(WEBKIT_DOM_RANGE(range
)),
749 wxString
wxWebViewWebKit::GetSelectedSource()
751 WebKitDOMDocument
* doc
;
752 WebKitDOMDOMWindow
* win
;
753 WebKitDOMDOMSelection
* sel
;
754 WebKitDOMRange
* range
;
755 WebKitDOMElement
* div
;
756 WebKitDOMDocumentFragment
* clone
;
757 WebKitDOMHTMLElement
* html
;
759 doc
= webkit_web_view_get_dom_document(WEBKIT_WEB_VIEW(web_view
));
760 win
= webkit_dom_document_get_default_view(WEBKIT_DOM_DOCUMENT(doc
));
761 sel
= webkit_dom_dom_window_get_selection(WEBKIT_DOM_DOM_WINDOW(win
));
762 range
= webkit_dom_dom_selection_get_range_at(WEBKIT_DOM_DOM_SELECTION(sel
),
764 div
= webkit_dom_document_create_element(WEBKIT_DOM_DOCUMENT(doc
), "div", NULL
);
766 clone
= webkit_dom_range_clone_contents(WEBKIT_DOM_RANGE(range
), NULL
);
767 webkit_dom_node_append_child(&div
->parent_instance
, &clone
->parent_instance
, NULL
);
768 html
= (WebKitDOMHTMLElement
*)div
;
770 return wxString(webkit_dom_html_element_get_inner_html(WEBKIT_DOM_HTML_ELEMENT(html
)),
774 void wxWebViewWebKit::ClearSelection()
776 WebKitDOMDocument
* doc
;
777 WebKitDOMDOMWindow
* win
;
778 WebKitDOMDOMSelection
* sel
;
780 doc
= webkit_web_view_get_dom_document(WEBKIT_WEB_VIEW(web_view
));
781 win
= webkit_dom_document_get_default_view(WEBKIT_DOM_DOCUMENT(doc
));
782 sel
= webkit_dom_dom_window_get_selection(WEBKIT_DOM_DOM_WINDOW(win
));
783 webkit_dom_dom_selection_remove_all_ranges(WEBKIT_DOM_DOM_SELECTION(sel
));
787 wxString
wxWebViewWebKit::GetPageText()
789 WebKitDOMDocument
* doc
;
790 WebKitDOMHTMLElement
* body
;
792 doc
= webkit_web_view_get_dom_document(WEBKIT_WEB_VIEW(web_view
));
793 body
= webkit_dom_document_get_body(WEBKIT_DOM_DOCUMENT(doc
));
794 return wxString(webkit_dom_html_element_get_inner_text(WEBKIT_DOM_HTML_ELEMENT(body
)),
798 void wxWebViewWebKit::RunScript(const wxString
& javascript
)
800 webkit_web_view_execute_script(WEBKIT_WEB_VIEW(web_view
),
801 javascript
.mb_str(wxConvUTF8
));
806 wxWebViewWebKit::GetClassDefaultAttributes(wxWindowVariant
WXUNUSED(variant
))
808 return GetDefaultAttributesFromGTKWidget(webkit_web_view_new
);
812 #endif // wxHAVE_WEB_BACKEND_GTK_WEBKIT