Make wxWebView::RunScript() const
This commit is contained in:
@@ -114,7 +114,7 @@ public:
|
|||||||
virtual wxString GetSelectedSource() const wxOVERRIDE;
|
virtual wxString GetSelectedSource() const wxOVERRIDE;
|
||||||
virtual void ClearSelection() wxOVERRIDE;
|
virtual void ClearSelection() wxOVERRIDE;
|
||||||
|
|
||||||
virtual bool RunScript(const wxString& javascript, wxString* output = NULL) wxOVERRIDE;
|
virtual bool RunScript(const wxString& javascript, wxString* output = NULL) const wxOVERRIDE;
|
||||||
|
|
||||||
//Virtual Filesystem Support
|
//Virtual Filesystem Support
|
||||||
virtual void RegisterHandler(wxSharedPtr<wxWebViewHandler> handler) wxOVERRIDE;
|
virtual void RegisterHandler(wxSharedPtr<wxWebViewHandler> handler) wxOVERRIDE;
|
||||||
@@ -161,7 +161,7 @@ private:
|
|||||||
bool CanExecuteEditingCommand(const gchar* command) const;
|
bool CanExecuteEditingCommand(const gchar* command) const;
|
||||||
void SetupWebExtensionServer();
|
void SetupWebExtensionServer();
|
||||||
GDBusProxy *GetExtensionProxy() const;
|
GDBusProxy *GetExtensionProxy() const;
|
||||||
bool RunScriptSync(const wxString& javascript, wxString* output = NULL);
|
bool RunScriptSync(const wxString& javascript, wxString* output = NULL) const;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
WebKitWebView *m_web_view;
|
WebKitWebView *m_web_view;
|
||||||
|
@@ -89,7 +89,7 @@ public:
|
|||||||
virtual void EnableAccessToDevTools(bool enable = true) wxOVERRIDE;
|
virtual void EnableAccessToDevTools(bool enable = true) wxOVERRIDE;
|
||||||
virtual bool IsAccessToDevToolsEnabled() const wxOVERRIDE;
|
virtual bool IsAccessToDevToolsEnabled() const wxOVERRIDE;
|
||||||
|
|
||||||
virtual bool RunScript(const wxString& javascript, wxString* output = NULL) wxOVERRIDE;
|
virtual bool RunScript(const wxString& javascript, wxString* output = NULL) const wxOVERRIDE;
|
||||||
|
|
||||||
virtual void RegisterHandler(wxSharedPtr<wxWebViewHandler> handler) wxOVERRIDE;
|
virtual void RegisterHandler(wxSharedPtr<wxWebViewHandler> handler) wxOVERRIDE;
|
||||||
|
|
||||||
@@ -107,7 +107,7 @@ private:
|
|||||||
|
|
||||||
void OnShow(wxShowEvent& event);
|
void OnShow(wxShowEvent& event);
|
||||||
|
|
||||||
bool RunScriptSync(const wxString& javascript, wxString* output = NULL);
|
bool RunScriptSync(const wxString& javascript, wxString* output = NULL) const;
|
||||||
|
|
||||||
wxDECLARE_DYNAMIC_CLASS(wxWebViewEdge);
|
wxDECLARE_DYNAMIC_CLASS(wxWebViewEdge);
|
||||||
};
|
};
|
||||||
|
@@ -131,7 +131,7 @@ public:
|
|||||||
virtual wxString GetSelectedSource() const wxOVERRIDE;
|
virtual wxString GetSelectedSource() const wxOVERRIDE;
|
||||||
virtual void ClearSelection() wxOVERRIDE;
|
virtual void ClearSelection() wxOVERRIDE;
|
||||||
|
|
||||||
virtual bool RunScript(const wxString& javascript, wxString* output = NULL) wxOVERRIDE;
|
virtual bool RunScript(const wxString& javascript, wxString* output = NULL) const wxOVERRIDE;
|
||||||
|
|
||||||
//Virtual Filesystem Support
|
//Virtual Filesystem Support
|
||||||
virtual void RegisterHandler(wxSharedPtr<wxWebViewHandler> handler) wxOVERRIDE;
|
virtual void RegisterHandler(wxSharedPtr<wxWebViewHandler> handler) wxOVERRIDE;
|
||||||
|
@@ -88,7 +88,7 @@ public:
|
|||||||
virtual void SetEditable(bool enable = true) wxOVERRIDE;
|
virtual void SetEditable(bool enable = true) wxOVERRIDE;
|
||||||
virtual bool IsEditable() const wxOVERRIDE;
|
virtual bool IsEditable() const wxOVERRIDE;
|
||||||
|
|
||||||
bool RunScript(const wxString& javascript, wxString* output = NULL) wxOVERRIDE;
|
bool RunScript(const wxString& javascript, wxString* output = NULL) const wxOVERRIDE;
|
||||||
|
|
||||||
//Virtual Filesystem Support
|
//Virtual Filesystem Support
|
||||||
virtual void RegisterHandler(wxSharedPtr<wxWebViewHandler> handler) wxOVERRIDE;
|
virtual void RegisterHandler(wxSharedPtr<wxWebViewHandler> handler) wxOVERRIDE;
|
||||||
@@ -107,7 +107,7 @@ private:
|
|||||||
WX_NSObject m_navigationDelegate;
|
WX_NSObject m_navigationDelegate;
|
||||||
WX_NSObject m_UIDelegate;
|
WX_NSObject m_UIDelegate;
|
||||||
|
|
||||||
bool RunScriptSync(const wxString& javascript, wxString* output = NULL);
|
bool RunScriptSync(const wxString& javascript, wxString* output = NULL) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
class WXDLLIMPEXP_WEBVIEW wxWebViewFactoryWebKit : public wxWebViewFactory
|
class WXDLLIMPEXP_WEBVIEW wxWebViewFactoryWebKit : public wxWebViewFactory
|
||||||
|
@@ -181,7 +181,7 @@ public:
|
|||||||
virtual void Print() = 0;
|
virtual void Print() = 0;
|
||||||
virtual void RegisterHandler(wxSharedPtr<wxWebViewHandler> handler) = 0;
|
virtual void RegisterHandler(wxSharedPtr<wxWebViewHandler> handler) = 0;
|
||||||
virtual void Reload(wxWebViewReloadFlags flags = wxWEBVIEW_RELOAD_DEFAULT) = 0;
|
virtual void Reload(wxWebViewReloadFlags flags = wxWEBVIEW_RELOAD_DEFAULT) = 0;
|
||||||
virtual bool RunScript(const wxString& javascript, wxString* output = NULL) = 0;
|
virtual bool RunScript(const wxString& javascript, wxString* output = NULL) const = 0;
|
||||||
virtual void SetEditable(bool enable = true) = 0;
|
virtual void SetEditable(bool enable = true) = 0;
|
||||||
void SetPage(const wxString& html, const wxString& baseUrl)
|
void SetPage(const wxString& html, const wxString& baseUrl)
|
||||||
{
|
{
|
||||||
@@ -250,7 +250,7 @@ protected:
|
|||||||
|
|
||||||
// Count the number of calls to RunScript() in order to prevent
|
// Count the number of calls to RunScript() in order to prevent
|
||||||
// the_same variable from being used twice in more than one call.
|
// the_same variable from being used twice in more than one call.
|
||||||
int m_runScriptCount;
|
mutable int m_runScriptCount;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static void InitFactoryMap();
|
static void InitFactoryMap();
|
||||||
|
@@ -660,7 +660,7 @@ public:
|
|||||||
version 3.1.1.
|
version 3.1.1.
|
||||||
@return @true if there is a result, @false if there is an error.
|
@return @true if there is a result, @false if there is an error.
|
||||||
*/
|
*/
|
||||||
virtual bool RunScript(const wxString& javascript, wxString* output = NULL) = 0;
|
virtual bool RunScript(const wxString& javascript, wxString* output = NULL) const = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Set the editable property of the web control. Enabling allows the user
|
Set the editable property of the web control. Enabling allows the user
|
||||||
|
@@ -112,7 +112,7 @@ void wxWebView::SetZoom(wxWebViewZoom zoom)
|
|||||||
bool wxWebView::QueryCommandEnabled(const wxString& command) const
|
bool wxWebView::QueryCommandEnabled(const wxString& command) const
|
||||||
{
|
{
|
||||||
wxString resultStr;
|
wxString resultStr;
|
||||||
const_cast<wxWebView*>(this)->RunScript(
|
RunScript(
|
||||||
wxString::Format("function f(){ return document.queryCommandEnabled('%s'); } f();", command), &resultStr);
|
wxString::Format("function f(){ return document.queryCommandEnabled('%s'); } f();", command), &resultStr);
|
||||||
return resultStr.IsSameAs("true", false);
|
return resultStr.IsSameAs("true", false);
|
||||||
}
|
}
|
||||||
@@ -125,14 +125,14 @@ void wxWebView::ExecCommand(const wxString& command)
|
|||||||
wxString wxWebView::GetPageSource() const
|
wxString wxWebView::GetPageSource() const
|
||||||
{
|
{
|
||||||
wxString text;
|
wxString text;
|
||||||
const_cast<wxWebView*>(this)->RunScript("document.documentElement.outerHTML;", &text);
|
RunScript("document.documentElement.outerHTML;", &text);
|
||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxString wxWebView::GetPageText() const
|
wxString wxWebView::GetPageText() const
|
||||||
{
|
{
|
||||||
wxString text;
|
wxString text;
|
||||||
const_cast<wxWebView*>(this)->RunScript("document.body.innerText;", &text);
|
RunScript("document.body.innerText;", &text);
|
||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -169,7 +169,7 @@ void wxWebView::Paste()
|
|||||||
wxString wxWebView::GetSelectedText() const
|
wxString wxWebView::GetSelectedText() const
|
||||||
{
|
{
|
||||||
wxString text;
|
wxString text;
|
||||||
const_cast<wxWebView*>(this)->RunScript("window.getSelection().toString();", &text);
|
RunScript("window.getSelection().toString();", &text);
|
||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -187,7 +187,7 @@ void wxWebView::DeleteSelection()
|
|||||||
bool wxWebView::HasSelection() const
|
bool wxWebView::HasSelection() const
|
||||||
{
|
{
|
||||||
wxString rangeCountStr;
|
wxString rangeCountStr;
|
||||||
const_cast<wxWebView*>(this)->RunScript("window.getSelection().rangeCount;", &rangeCountStr);
|
RunScript("window.getSelection().rangeCount;", &rangeCountStr);
|
||||||
return rangeCountStr != "0";
|
return rangeCountStr != "0";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -920,7 +920,7 @@ wxString wxWebViewWebKit::GetPageText() const
|
|||||||
wxConvUTF8);
|
wxConvUTF8);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxWebViewWebKit::RunScript(const wxString& javascript, wxString* output)
|
bool wxWebViewWebKit::RunScript(const wxString& javascript, wxString* output) const
|
||||||
{
|
{
|
||||||
wxCHECK_MSG( m_web_view, false,
|
wxCHECK_MSG( m_web_view, false,
|
||||||
wxS("wxWebView must be created before calling RunScript()") );
|
wxS("wxWebView must be created before calling RunScript()") );
|
||||||
|
@@ -1130,7 +1130,7 @@ static void wxgtk_run_javascript_cb(GObject *,
|
|||||||
} // extern "C"
|
} // extern "C"
|
||||||
|
|
||||||
// Run the given script synchronously and return its result in output.
|
// Run the given script synchronously and return its result in output.
|
||||||
bool wxWebViewWebKit::RunScriptSync(const wxString& javascript, wxString* output)
|
bool wxWebViewWebKit::RunScriptSync(const wxString& javascript, wxString* output) const
|
||||||
{
|
{
|
||||||
GAsyncResult *result = NULL;
|
GAsyncResult *result = NULL;
|
||||||
webkit_web_view_run_javascript(m_web_view,
|
webkit_web_view_run_javascript(m_web_view,
|
||||||
@@ -1193,7 +1193,7 @@ bool wxWebViewWebKit::RunScriptSync(const wxString& javascript, wxString* output
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxWebViewWebKit::RunScript(const wxString& javascript, wxString* output)
|
bool wxWebViewWebKit::RunScript(const wxString& javascript, wxString* output) const
|
||||||
{
|
{
|
||||||
wxJSScriptWrapper wrapJS(javascript, &m_runScriptCount);
|
wxJSScriptWrapper wrapJS(javascript, &m_runScriptCount);
|
||||||
|
|
||||||
|
@@ -651,7 +651,7 @@ void wxWebViewEdge::MSWSetBrowserExecutableDir(const wxString & path)
|
|||||||
wxWebViewEdgeImpl::ms_browserExecutableDir = path;
|
wxWebViewEdgeImpl::ms_browserExecutableDir = path;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxWebViewEdge::RunScriptSync(const wxString& javascript, wxString* output)
|
bool wxWebViewEdge::RunScriptSync(const wxString& javascript, wxString* output) const
|
||||||
{
|
{
|
||||||
bool scriptExecuted = false;
|
bool scriptExecuted = false;
|
||||||
|
|
||||||
@@ -687,7 +687,7 @@ bool wxWebViewEdge::RunScriptSync(const wxString& javascript, wxString* output)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxWebViewEdge::RunScript(const wxString& javascript, wxString* output)
|
bool wxWebViewEdge::RunScript(const wxString& javascript, wxString* output) const
|
||||||
{
|
{
|
||||||
wxJSScriptWrapper wrapJS(javascript, &m_runScriptCount);
|
wxJSScriptWrapper wrapJS(javascript, &m_runScriptCount);
|
||||||
|
|
||||||
|
@@ -1029,7 +1029,7 @@ bool CallEval(const wxString& code,
|
|||||||
return scriptAO.Invoke("eval", DISPATCH_METHOD, *varResult, 1, &varCode);
|
return scriptAO.Invoke("eval", DISPATCH_METHOD, *varResult, 1, &varCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxWebViewIE::RunScript(const wxString& javascript, wxString* output)
|
bool wxWebViewIE::RunScript(const wxString& javascript, wxString* output) const
|
||||||
{
|
{
|
||||||
wxCOMPtr<IHTMLDocument2> document(m_impl->GetDocument());
|
wxCOMPtr<IHTMLDocument2> document(m_impl->GetDocument());
|
||||||
if ( !document )
|
if ( !document )
|
||||||
|
@@ -302,7 +302,7 @@ bool wxWebViewWebKit::CanSetZoomType(wxWebViewZoomType type) const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxWebViewWebKit::RunScriptSync(const wxString& javascript, wxString* output)
|
bool wxWebViewWebKit::RunScriptSync(const wxString& javascript, wxString* output) const
|
||||||
{
|
{
|
||||||
__block bool scriptExecuted = false;
|
__block bool scriptExecuted = false;
|
||||||
__block wxString outputStr;
|
__block wxString outputStr;
|
||||||
@@ -345,7 +345,7 @@ bool wxWebViewWebKit::RunScriptSync(const wxString& javascript, wxString* output
|
|||||||
return scriptSuccess;
|
return scriptSuccess;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxWebViewWebKit::RunScript(const wxString& javascript, wxString* output)
|
bool wxWebViewWebKit::RunScript(const wxString& javascript, wxString* output) const
|
||||||
{
|
{
|
||||||
wxJSScriptWrapper wrapJS(javascript, &m_runScriptCount);
|
wxJSScriptWrapper wrapJS(javascript, &m_runScriptCount);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user