Make wxWebView::RunScript() const

This commit is contained in:
Tobias Taschner 2021-02-05 22:17:35 +01:00
parent e88b55bfe1
commit d17e8978a6
No known key found for this signature in database
GPG Key ID: AE6ECD71294F87FD
12 changed files with 24 additions and 24 deletions

View File

@ -114,7 +114,7 @@ public:
virtual wxString GetSelectedSource() const 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 void RegisterHandler(wxSharedPtr<wxWebViewHandler> handler) wxOVERRIDE;
@ -161,7 +161,7 @@ private:
bool CanExecuteEditingCommand(const gchar* command) const;
void SetupWebExtensionServer();
GDBusProxy *GetExtensionProxy() const;
bool RunScriptSync(const wxString& javascript, wxString* output = NULL);
bool RunScriptSync(const wxString& javascript, wxString* output = NULL) const;
#endif
WebKitWebView *m_web_view;

View File

@ -89,7 +89,7 @@ public:
virtual void EnableAccessToDevTools(bool enable = true) 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;
@ -107,7 +107,7 @@ private:
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);
};

View File

@ -131,7 +131,7 @@ public:
virtual wxString GetSelectedSource() const 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 void RegisterHandler(wxSharedPtr<wxWebViewHandler> handler) wxOVERRIDE;

View File

@ -88,7 +88,7 @@ public:
virtual void SetEditable(bool enable = true) 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 void RegisterHandler(wxSharedPtr<wxWebViewHandler> handler) wxOVERRIDE;
@ -107,7 +107,7 @@ private:
WX_NSObject m_navigationDelegate;
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

View File

@ -181,7 +181,7 @@ public:
virtual void Print() = 0;
virtual void RegisterHandler(wxSharedPtr<wxWebViewHandler> handler) = 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;
void SetPage(const wxString& html, const wxString& baseUrl)
{
@ -250,7 +250,7 @@ protected:
// Count the number of calls to RunScript() in order to prevent
// the_same variable from being used twice in more than one call.
int m_runScriptCount;
mutable int m_runScriptCount;
private:
static void InitFactoryMap();

View File

@ -660,7 +660,7 @@ public:
version 3.1.1.
@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

View File

@ -112,7 +112,7 @@ void wxWebView::SetZoom(wxWebViewZoom zoom)
bool wxWebView::QueryCommandEnabled(const wxString& command) const
{
wxString resultStr;
const_cast<wxWebView*>(this)->RunScript(
RunScript(
wxString::Format("function f(){ return document.queryCommandEnabled('%s'); } f();", command), &resultStr);
return resultStr.IsSameAs("true", false);
}
@ -125,14 +125,14 @@ void wxWebView::ExecCommand(const wxString& command)
wxString wxWebView::GetPageSource() const
{
wxString text;
const_cast<wxWebView*>(this)->RunScript("document.documentElement.outerHTML;", &text);
RunScript("document.documentElement.outerHTML;", &text);
return text;
}
wxString wxWebView::GetPageText() const
{
wxString text;
const_cast<wxWebView*>(this)->RunScript("document.body.innerText;", &text);
RunScript("document.body.innerText;", &text);
return text;
}
@ -169,7 +169,7 @@ void wxWebView::Paste()
wxString wxWebView::GetSelectedText() const
{
wxString text;
const_cast<wxWebView*>(this)->RunScript("window.getSelection().toString();", &text);
RunScript("window.getSelection().toString();", &text);
return text;
}
@ -187,7 +187,7 @@ void wxWebView::DeleteSelection()
bool wxWebView::HasSelection() const
{
wxString rangeCountStr;
const_cast<wxWebView*>(this)->RunScript("window.getSelection().rangeCount;", &rangeCountStr);
RunScript("window.getSelection().rangeCount;", &rangeCountStr);
return rangeCountStr != "0";
}

View File

@ -920,7 +920,7 @@ wxString wxWebViewWebKit::GetPageText() const
wxConvUTF8);
}
bool wxWebViewWebKit::RunScript(const wxString& javascript, wxString* output)
bool wxWebViewWebKit::RunScript(const wxString& javascript, wxString* output) const
{
wxCHECK_MSG( m_web_view, false,
wxS("wxWebView must be created before calling RunScript()") );

View File

@ -1130,7 +1130,7 @@ static void wxgtk_run_javascript_cb(GObject *,
} // extern "C"
// 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;
webkit_web_view_run_javascript(m_web_view,
@ -1193,7 +1193,7 @@ bool wxWebViewWebKit::RunScriptSync(const wxString& javascript, wxString* output
return true;
}
bool wxWebViewWebKit::RunScript(const wxString& javascript, wxString* output)
bool wxWebViewWebKit::RunScript(const wxString& javascript, wxString* output) const
{
wxJSScriptWrapper wrapJS(javascript, &m_runScriptCount);
@ -1240,7 +1240,7 @@ long wxWebViewWebKit::Find(const wxString& text, int flags)
{
WebKitFindController* findctrl = webkit_web_view_get_find_controller(m_web_view);
bool newSearch = false;
if(text != m_findText ||
if(text != m_findText ||
(flags & wxWEBVIEW_FIND_MATCH_CASE) != (m_findFlags & wxWEBVIEW_FIND_MATCH_CASE))
{
newSearch = true;

View File

@ -651,7 +651,7 @@ void wxWebViewEdge::MSWSetBrowserExecutableDir(const wxString & 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;
@ -687,7 +687,7 @@ bool wxWebViewEdge::RunScriptSync(const wxString& javascript, wxString* output)
return true;
}
bool wxWebViewEdge::RunScript(const wxString& javascript, wxString* output)
bool wxWebViewEdge::RunScript(const wxString& javascript, wxString* output) const
{
wxJSScriptWrapper wrapJS(javascript, &m_runScriptCount);

View File

@ -1029,7 +1029,7 @@ bool CallEval(const wxString& code,
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());
if ( !document )

View File

@ -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 wxString outputStr;
@ -345,7 +345,7 @@ bool wxWebViewWebKit::RunScriptSync(const wxString& javascript, wxString* output
return scriptSuccess;
}
bool wxWebViewWebKit::RunScript(const wxString& javascript, wxString* output)
bool wxWebViewWebKit::RunScript(const wxString& javascript, wxString* output) const
{
wxJSScriptWrapper wrapJS(javascript, &m_runScriptCount);