Move RunScriptInternal() out of wxWebViewIE and rename

There is no need for this function to be a class member.
This commit is contained in:
Vadim Zeitlin 2017-10-22 00:17:28 +02:00
parent b66632fc6d
commit 408ee0523c
2 changed files with 5 additions and 7 deletions

View File

@ -200,9 +200,6 @@ private:
//Toggles control features see INTERNETFEATURELIST for values.
bool EnableControlFeature(long flag, bool enable = true);
bool RunScriptInternal(wxVariant varJavascript,
wxAutomationObject* scriptAO, wxVariant* varResult);
wxDECLARE_DYNAMIC_CLASS(wxWebViewIE);
};

View File

@ -879,7 +879,8 @@ bool wxWebViewIE::MSWSetModernEmulationLevel(bool modernLevel)
return false;
}
bool wxWebViewIE::RunScriptInternal(wxVariant varJavascript, wxAutomationObject* scriptAO,
static
bool CallEval(wxVariant varJavascript, wxAutomationObject* scriptAO,
wxVariant* varResult)
{
if ( !scriptAO->Invoke("eval", DISPATCH_METHOD, *varResult, 1, &varJavascript) )
@ -914,20 +915,20 @@ bool wxWebViewIE::RunScript(const wxString& javascript, wxString* output)
wxVariant varJavascript(wrapJS.GetWrappedCode());
wxVariant varResult;
if ( !RunScriptInternal(varJavascript, &scriptAO, &varResult) )
if ( !CallEval(varJavascript, &scriptAO, &varResult) )
return false;
if ( varResult.IsType("bool") && varResult.GetBool() )
{
varJavascript = wrapJS.GetOutputCode();
if ( !RunScriptInternal(varJavascript, &scriptAO, &varResult) )
if ( !CallEval(varJavascript, &scriptAO, &varResult) )
return false;
if ( output != NULL )
*output = varResult.MakeString();
varJavascript = wrapJS.GetCleanUpCode();
if ( !RunScriptInternal(varJavascript, &scriptAO, &varResult) )
if ( !CallEval(varJavascript, &scriptAO, &varResult) )
return false;
return true;
}