+bool wxWebViewWebKit::HasSelection() const
+{
+ 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() const
+{
+ 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() const
+{
+ 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<wxWebViewHistoryItem> > wxWebViewWebKit::GetBackwardHistory()
+{
+ wxVector<wxSharedPtr<wxWebViewHistoryItem> > 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]);
+ wxWebViewHistoryItem* wxitem = new wxWebViewHistoryItem(url, title);
+ wxitem->m_histItem = item;
+ wxSharedPtr<wxWebViewHistoryItem> itemptr(wxitem);
+ backhist.push_back(itemptr);
+ }
+ return backhist;
+}
+
+wxVector<wxSharedPtr<wxWebViewHistoryItem> > wxWebViewWebKit::GetForwardHistory()
+{
+ wxVector<wxSharedPtr<wxWebViewHistoryItem> > 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]);
+ wxWebViewHistoryItem* wxitem = new wxWebViewHistoryItem(url, title);
+ wxitem->m_histItem = item;
+ wxSharedPtr<wxWebViewHistoryItem> itemptr(wxitem);
+ forwardhist.push_back(itemptr);
+ }
+ return forwardhist;
+}
+
+void wxWebViewWebKit::LoadHistoryItem(wxSharedPtr<wxWebViewHistoryItem> item)
+{
+ [m_webView goToBackForwardItem:item->m_histItem];
+}
+
+bool wxWebViewWebKit::CanUndo() const
+{
+ return [[m_webView undoManager] canUndo];
+}
+
+bool wxWebViewWebKit::CanRedo() const
+{
+ return [[m_webView undoManager] canRedo];
+}
+
+void wxWebViewWebKit::Undo()
+{
+ [[m_webView undoManager] undo];
+}
+
+void wxWebViewWebKit::Redo()
+{
+ [[m_webView undoManager] redo];
+}
+
+void wxWebViewWebKit::RegisterHandler(wxSharedPtr<wxWebViewHandler> handler)
+{
+ g_stringHandlerMap[handler->GetName()] = handler;
+}
+