Commit Graph

12 Commits

Author SHA1 Message Date
Maarten Bent
3d427a1af1 Fix wxWebView::RunScript() with string containing backslashes
Escape backslashes in wxJSScriptWrapper to allow strings with
backslashes in them to work again -- this was broken while implementing
support for returning values from JavaScript to C++.

See https://github.com/wxWidgets/wxWidgets/pull/741
2018-02-22 13:44:00 +01:00
Vadim Zeitlin
40b629641b Don't define "objElements" in JavaScript code unless we need it
This variable is only used when dumping object fields, so define it
there both as a micro-optimization and for clarity.
2017-10-22 23:38:04 +02:00
Vadim Zeitlin
d1c15bfe0e Reformat JavaScript code in wxJSScriptWrapper
No real changes, but just use string concatenation instead of line
continuation backslashes and also replace hard TABs with spaces.

Notice that the code is still completely unreadable as JavaScript, but
this shouldn't be a problem as nobody will see it there anyhow, so it's
quite enough to have it more readable in its string form in C++.
2017-10-22 23:38:02 +02:00
Vadim Zeitlin
3907524098 Remove unused wxJSScriptWrapper::GetOutputJSVariable() method
There doesn't seem to be any reason to keep it.
2017-10-22 23:38:00 +02:00
Vadim Zeitlin
eff7a2e07f Improve wxJSScriptWrapper methods comments
Explain more clearly what each of them does.
2017-10-22 23:37:58 +02:00
Vadim Zeitlin
6563f38496 Make wxJSScriptWrapper methods const
Do not mark as const their returned values, which is useless, and seems
to have been a result of some confusion about how "const" works in C++.
2017-10-22 23:37:56 +02:00
Vadim Zeitlin
836c874c88 Escape JavaScript code in wxJSScriptWrapper constructor
We can prepare the escaped code directly here, instead of waiting for
GetWrappedCode() call, this is more clear and safer as it avoids
escaping the code twice accidentally if GetWrappedCode() ends up being
called twice somehow.
2017-10-22 23:37:54 +02:00
Vadim Zeitlin
1b7bb46568 Don't use dollar sign in the JavaScript variable name neither
While it is allowed there, it is confusing and unnecessary.

Also improve the comment explaining why do we need this output variable
name at all and why does it need to be unique.
2017-10-22 23:37:52 +02:00
Vadim Zeitlin
71522731c6 Fix typos in wxJSScriptWrapper comments
No real changes.
2017-10-22 23:37:50 +02:00
Vadim Zeitlin
c45e674fa0 Don't use dollar sign in C++ identifiers in wxJSScriptWrapper
This is a non-standard extension in the first place and the variable
name didn't make any sense too, so rename it to be standard-conforming
and actually correspond to what it contains.
2017-10-22 23:37:48 +02:00
Vadim Zeitlin
148c590017 Get rid of unnecessary "explicit" in wxJSScriptWrapper
This ctor has more than one argument and so can't be used implicitly.
2017-10-22 23:37:46 +02:00
Jose Lorenzo
af8f7f33c3 Merge wxWebView JavaScript improvements branch
This is a squashed commit of the SOC2017_WEBVIEW_JS branch from
https://github.com/joseeloren/wxWidgets.git

Closes https://github.com/wxWidgets/wxWidgets/pull/538
2017-10-21 22:42:30 +02:00