changeset 2045:cb195d76de8e

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.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Mon, 25 Nov 2019 04:47:43 +0000
parents b74b9afa31aa
children e8a34118a845
files win/browser.c win/dw.c win/edge.cpp
diffstat 3 files changed, 14 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- 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;
--- 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;
--- 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<IWebView2ExecuteScriptCompletedHandler>(
 				[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;