# HG changeset patch # User bsmith@81767d24-ef19-dc11-ae90-00e081727c95 # Date 1574657263 0 # Node ID cb195d76de8e793fa85e28cd13b17026af475445 # Parent b74b9afa31aa6ca9450fa8334fb8679b8776db21 Win: Make HTML_RESULT event match other platforms and disable dev tools when not DEBUG. When javascript_run() does not have a result other platforms return a NULL pointer, but Edge Chromium returns a string "null"; this change checks for "null" and makes it a NULL pointer instead. This may cause problems when a "null" string result is the expected result. Additionally disable developer tools for the HTML widget when DEBUG is not defined when compiling. diff -r b74b9afa31aa -r cb195d76de8e win/browser.c --- a/win/browser.c Mon Nov 25 03:16:45 2019 +0000 +++ b/win/browser.c Mon Nov 25 04:47:43 2019 +0000 @@ -1586,11 +1586,14 @@ if (myscript) { HRESULT hr; + void* params[2]; VariantInit(&result); hr = htmlWindow2->lpVtbl->execScript(htmlWindow2, myscript, L"javascript", &result); + params[0] = (void*)(result.vt == VT_BSTR ? WideToUTF8(result.bstrVal) : NULL); + params[1] = DW_INT_TO_POINTER((hr == S_OK ? DW_ERROR_NONE : DW_ERROR_UNKNOWN)); /* Pass the result back for event handling */ - _wndproc(hwnd, WM_USER+100, (WPARAM)(result.vt == VT_BSTR ? WideToUTF8(result.bstrVal) : NULL), (LPARAM)scriptdata); + _wndproc(hwnd, WM_USER+100, (WPARAM)params, (LPARAM)scriptdata); VariantClear(&result); SysFreeString(myscript); retval = DW_ERROR_NONE; diff -r b74b9afa31aa -r cb195d76de8e win/dw.c --- a/win/dw.c Mon Nov 25 03:16:45 2019 +0000 +++ b/win/dw.c Mon Nov 25 04:47:43 2019 +0000 @@ -2389,8 +2389,9 @@ if(hWnd == tmp->window) { int (DWSIGNAL *htmlresultfunc)(HWND, int, char *, void *, void *) = tmp->signalfunction; - - return htmlresultfunc(tmp->window, mp1 ? DW_ERROR_NONE : DW_ERROR_UNKNOWN, (char *)mp1, (void *)mp2, tmp->data); + void** params = (void**)mp1; + + return htmlresultfunc(tmp->window, DW_POINTER_TO_INT(params[1]), (char *)params[0], (void *)mp2, tmp->data); } } break; diff -r b74b9afa31aa -r cb195d76de8e win/edge.cpp --- a/win/edge.cpp Mon Nov 25 03:16:45 2019 +0000 +++ b/win/edge.cpp Mon Nov 25 04:47:43 2019 +0000 @@ -97,6 +97,9 @@ Settings->put_IsScriptEnabled(TRUE); Settings->put_AreDefaultScriptDialogsEnabled(TRUE); Settings->put_IsWebMessageEnabled(TRUE); +#ifndef DEBUG + Settings->put_AreDevToolsEnabled(FALSE); +#endif // Resize WebView to fit the bounds of the parent window WebView->DoSize(); @@ -290,7 +293,10 @@ Callback( [thishwnd, scriptdata](HRESULT error, PCWSTR result) -> HRESULT { - _wndproc(thishwnd, WM_USER + 100, (error == S_OK ? (WPARAM)WideToUTF8((LPWSTR)result) : NULL), (LPARAM)scriptdata); + if (result && _wcsicmp(result, L"null") == 0) + result = NULL; + void *params[2] = { (void *)(result ? WideToUTF8((LPWSTR)result) : NULL), DW_INT_TO_POINTER((error == S_OK ? DW_ERROR_NONE : DW_ERROR_UNKNOWN)) }; + _wndproc(thishwnd, WM_USER + 100, (WPARAM)params, (LPARAM)scriptdata); return S_OK; }).Get()); return DW_ERROR_NONE;