diff --git a/include/wx/gtk/webview_webkit.h b/include/wx/gtk/webview_webkit.h index 02aabd4eb9..ed375d3a39 100644 --- a/include/wx/gtk/webview_webkit.h +++ b/include/wx/gtk/webview_webkit.h @@ -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 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; diff --git a/include/wx/msw/webview_edge.h b/include/wx/msw/webview_edge.h index 01972b1e73..be7eeeac2a 100644 --- a/include/wx/msw/webview_edge.h +++ b/include/wx/msw/webview_edge.h @@ -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 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); }; diff --git a/include/wx/msw/webview_ie.h b/include/wx/msw/webview_ie.h index 019ac97dbf..072b8aeb5a 100644 --- a/include/wx/msw/webview_ie.h +++ b/include/wx/msw/webview_ie.h @@ -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 handler) wxOVERRIDE; diff --git a/include/wx/osx/webview_webkit.h b/include/wx/osx/webview_webkit.h index 6c9fa701f8..1c92faac73 100644 --- a/include/wx/osx/webview_webkit.h +++ b/include/wx/osx/webview_webkit.h @@ -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 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 diff --git a/include/wx/webview.h b/include/wx/webview.h index 740991a7bc..9a0997ab36 100644 --- a/include/wx/webview.h +++ b/include/wx/webview.h @@ -181,7 +181,7 @@ public: virtual void Print() = 0; virtual void RegisterHandler(wxSharedPtr 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(); diff --git a/interface/wx/webview.h b/interface/wx/webview.h index 1e46ebad43..98482df6d5 100644 --- a/interface/wx/webview.h +++ b/interface/wx/webview.h @@ -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 diff --git a/src/common/webview.cpp b/src/common/webview.cpp index 21d5a40c92..d88771feb8 100644 --- a/src/common/webview.cpp +++ b/src/common/webview.cpp @@ -112,7 +112,7 @@ void wxWebView::SetZoom(wxWebViewZoom zoom) bool wxWebView::QueryCommandEnabled(const wxString& command) const { wxString resultStr; - const_cast(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(this)->RunScript("document.documentElement.outerHTML;", &text); + RunScript("document.documentElement.outerHTML;", &text); return text; } wxString wxWebView::GetPageText() const { wxString text; - const_cast(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(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(this)->RunScript("window.getSelection().rangeCount;", &rangeCountStr); + RunScript("window.getSelection().rangeCount;", &rangeCountStr); return rangeCountStr != "0"; } diff --git a/src/gtk/webview_webkit.cpp b/src/gtk/webview_webkit.cpp index 6765ecec70..28a73acb45 100644 --- a/src/gtk/webview_webkit.cpp +++ b/src/gtk/webview_webkit.cpp @@ -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()") ); diff --git a/src/gtk/webview_webkit2.cpp b/src/gtk/webview_webkit2.cpp index 6106610e92..8ee773b060 100644 --- a/src/gtk/webview_webkit2.cpp +++ b/src/gtk/webview_webkit2.cpp @@ -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; diff --git a/src/msw/webview_edge.cpp b/src/msw/webview_edge.cpp index cce02e5f21..06b1f1126a 100644 --- a/src/msw/webview_edge.cpp +++ b/src/msw/webview_edge.cpp @@ -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); diff --git a/src/msw/webview_ie.cpp b/src/msw/webview_ie.cpp index 565d377bf3..a008166b6a 100644 --- a/src/msw/webview_ie.cpp +++ b/src/msw/webview_ie.cpp @@ -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 document(m_impl->GetDocument()); if ( !document ) diff --git a/src/osx/webview_webkit.mm b/src/osx/webview_webkit.mm index 3a0b485220..5350081e78 100644 --- a/src/osx/webview_webkit.mm +++ b/src/osx/webview_webkit.mm @@ -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);