Make CallEval() simpler to use by taking a string in it
Don't force the caller to convert the string to wxVariant when we can perfectly well do it ourselves.
This commit is contained in:
@@ -880,10 +880,12 @@ bool wxWebViewIE::MSWSetModernEmulationLevel(bool modernLevel)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
bool CallEval(wxVariant varJavascript, wxAutomationObject& scriptAO,
|
bool CallEval(const wxString& code,
|
||||||
wxVariant* varResult)
|
wxAutomationObject& scriptAO,
|
||||||
|
wxVariant* varResult)
|
||||||
{
|
{
|
||||||
if ( !scriptAO.Invoke("eval", DISPATCH_METHOD, *varResult, 1, &varJavascript) )
|
wxVariant varCode(code);
|
||||||
|
if ( !scriptAO.Invoke("eval", DISPATCH_METHOD, *varResult, 1, &varCode) )
|
||||||
{
|
{
|
||||||
wxLogWarning(_("Can't run JavaScript"));
|
wxLogWarning(_("Can't run JavaScript"));
|
||||||
return false;
|
return false;
|
||||||
@@ -912,23 +914,20 @@ bool wxWebViewIE::RunScript(const wxString& javascript, wxString* output)
|
|||||||
wxJSScriptWrapper wrapJS(javascript, &m_runScriptCount);
|
wxJSScriptWrapper wrapJS(javascript, &m_runScriptCount);
|
||||||
|
|
||||||
wxAutomationObject scriptAO(scriptDispatch);
|
wxAutomationObject scriptAO(scriptDispatch);
|
||||||
wxVariant varJavascript(wrapJS.GetWrappedCode());
|
|
||||||
wxVariant varResult;
|
wxVariant varResult;
|
||||||
|
|
||||||
if ( !CallEval(varJavascript, scriptAO, &varResult) )
|
if ( !CallEval(wrapJS.GetWrappedCode(), scriptAO, &varResult) )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if ( varResult.IsType("bool") && varResult.GetBool() )
|
if ( varResult.IsType("bool") && varResult.GetBool() )
|
||||||
{
|
{
|
||||||
varJavascript = wrapJS.GetOutputCode();
|
if ( !CallEval(wrapJS.GetOutputCode(), scriptAO, &varResult) )
|
||||||
if ( !CallEval(varJavascript, scriptAO, &varResult) )
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if ( output != NULL )
|
if ( output != NULL )
|
||||||
*output = varResult.MakeString();
|
*output = varResult.MakeString();
|
||||||
|
|
||||||
varJavascript = wrapJS.GetCleanUpCode();
|
if ( !CallEval(wrapJS.GetCleanUpCode(), scriptAO, &varResult) )
|
||||||
if ( !CallEval(varJavascript, scriptAO, &varResult) )
|
|
||||||
return false;
|
return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user