Implement GetSelectedSource for the OSX WebKit backend.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/SOC2011_WEBVIEW@68572 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Steve Lamerton 2011-08-06 13:32:40 +00:00
parent 835165d576
commit 94ec73c74c
2 changed files with 12 additions and 1 deletions

View File

@ -108,7 +108,7 @@ public:
virtual bool HasSelection();
virtual void SelectAll();
virtual wxString GetSelectedText();
virtual wxString GetSelectedSource() { return ""; }
virtual wxString GetSelectedSource();
virtual void ClearSelection();
void RunScript(const wxString& javascript);

View File

@ -925,6 +925,17 @@ 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]