+bool wxWebViewWebKit::HasSelection()
+{
+ DOMRange* range = [m_webView selectedDOMRange];
+ if(!range)
+ {
+ return false;
+ }
+ else
+ {
+ return true;
+ }
+}
+
+void wxWebViewWebKit::ClearSelection()
+{
+ //We use javascript as selection isn't exposed at the moment in webkit
+ RunScript("window.getSelection().removeAllRanges();");
+}
+
+void wxWebViewWebKit::SelectAll()
+{
+ RunScript("window.getSelection().selectAllChildren(document.body);");
+}
+
+wxString wxWebViewWebKit::GetSelectedSource()
+{
+ wxString script = ("var range = window.getSelection().getRangeAt(0);"
+ "var element = document.createElement('div');"
+ "element.appendChild(range.cloneContents());"
+ "return element.innerHTML;");
+ id result = [[m_webView windowScriptObject]
+ evaluateWebScript:wxNSStringWithWxString(script)];
+ return wxStringWithNSString([result stringValue]);
+}
+
+wxString wxWebViewWebKit::GetPageText()
+{
+ id result = [[m_webView windowScriptObject]
+ evaluateWebScript:@"document.body.textContent"];
+ return wxStringWithNSString([result stringValue]);
+}
+
+void wxWebViewWebKit::EnableHistory(bool enable)
+{
+ if ( !m_webView )
+ return;
+
+ [m_webView setMaintainsBackForwardList:enable];
+}
+
+void wxWebViewWebKit::ClearHistory()
+{
+ [m_webView setMaintainsBackForwardList:NO];
+ [m_webView setMaintainsBackForwardList:YES];
+}
+
+wxVector<wxSharedPtr<wxWebHistoryItem> > wxWebViewWebKit::GetBackwardHistory()
+{
+ wxVector<wxSharedPtr<wxWebHistoryItem> > backhist;
+ WebBackForwardList* history = [m_webView backForwardList];
+ int count = [history backListCount];
+ for(int i = -count; i < 0; i++)
+ {
+ WebHistoryItem* item = [history itemAtIndex:i];
+ wxString url = wxStringWithNSString([item URLString]);
+ wxString title = wxStringWithNSString([item title]);
+ wxWebHistoryItem* wxitem = new wxWebHistoryItem(url, title);
+ wxitem->m_histItem = item;
+ wxSharedPtr<wxWebHistoryItem> itemptr(wxitem);
+ backhist.push_back(itemptr);
+ }
+ return backhist;
+}
+
+wxVector<wxSharedPtr<wxWebHistoryItem> > wxWebViewWebKit::GetForwardHistory()
+{
+ wxVector<wxSharedPtr<wxWebHistoryItem> > forwardhist;
+ WebBackForwardList* history = [m_webView backForwardList];
+ int count = [history forwardListCount];
+ for(int i = 1; i <= count; i++)
+ {
+ WebHistoryItem* item = [history itemAtIndex:i];
+ wxString url = wxStringWithNSString([item URLString]);
+ wxString title = wxStringWithNSString([item title]);
+ wxWebHistoryItem* wxitem = new wxWebHistoryItem(url, title);
+ wxitem->m_histItem = item;
+ wxSharedPtr<wxWebHistoryItem> itemptr(wxitem);
+ forwardhist.push_back(itemptr);
+ }
+ return forwardhist;
+}
+
+void wxWebViewWebKit::LoadHistoryItem(wxSharedPtr<wxWebHistoryItem> item)
+{
+ [m_webView goToBackForwardItem:item->m_histItem];
+}
+
+bool wxWebViewWebKit::CanUndo()
+{
+ return [[m_webView undoManager] canUndo];
+}
+
+bool wxWebViewWebKit::CanRedo()
+{
+ return [[m_webView undoManager] canRedo];
+}
+
+void wxWebViewWebKit::Undo()
+{
+ [[m_webView undoManager] undo];
+}
+
+void wxWebViewWebKit::Redo()
+{
+ [[m_webView undoManager] redo];
+}
+
+void wxWebViewWebKit::RegisterHandler(wxSharedPtr<wxWebHandler> handler)
+{
+ g_stringHandlerMap[handler->GetName()] = handler;
+}
+