From 4682fe3a193f408e85d94576a91d183b9f56074e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Salvador=20D=C3=ADaz=20Fau?= Date: Fri, 22 Mar 2019 13:12:44 +0100 Subject: [PATCH] Update to CEF 73.1.12 - Added context menu option in JSDemo to get the vertical scroll position. - Now TChromium uses the same keyboard events for the browser and the DevTools. - Fixed a MiniBrowser issue with the F12 keyboard shortcut. Now you can press F12 to hide and show the DevTools correctly. --- demos/JavaScript/JSEval/uJSEval.pas | 30 ++++++++++++++++++++++------- demos/MiniBrowser/MiniBrowser.dpr | 3 +++ demos/MiniBrowser/uMiniBrowser.pas | 6 ++---- source/uCEFApplication.pas | 2 +- source/uCEFChromium.pas | 9 ++++++++- 5 files changed, 37 insertions(+), 13 deletions(-) diff --git a/demos/JavaScript/JSEval/uJSEval.pas b/demos/JavaScript/JSEval/uJSEval.pas index b9d03248..4dbede06 100644 --- a/demos/JavaScript/JSEval/uJSEval.pas +++ b/demos/JavaScript/JSEval/uJSEval.pas @@ -50,15 +50,18 @@ uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Menus, Controls, Forms, Dialogs, StdCtrls, ExtCtrls, Types, ComCtrls, ClipBrd, EncdDecd, {$ENDIF} - uCEFChromium, uCEFWindowParent, uCEFInterfaces, uCEFApplication, uCEFTypes, uCEFConstants; + uCEFChromium, uCEFWindowParent, uCEFInterfaces, uCEFApplication, uCEFTypes, uCEFConstants, + uCEFWinControl; const MINIBROWSER_SHOWTEXTVIEWER = WM_APP + $101; MINIBROWSER_EVALJSCODE = WM_APP + $102; MINIBROWSER_JSBINPARAM = WM_APP + $103; + MINIBROWSER_GETSCROLLPOS = WM_APP + $104; - MINIBROWSER_CONTEXTMENU_EVALJSCODE = MENU_ID_USER_FIRST + 1; - MINIBROWSER_CONTEXTMENU_JSBINPARAM = MENU_ID_USER_FIRST + 2; + MINIBROWSER_CONTEXTMENU_EVALJSCODE = MENU_ID_USER_FIRST + 1; + MINIBROWSER_CONTEXTMENU_JSBINPARAM = MENU_ID_USER_FIRST + 2; + MINIBROWSER_CONTEXTMENU_GETSCROLLPOS = MENU_ID_USER_FIRST + 3; EVAL_JS = 'JSContextEvalDemo'; BINARY_PARAM_JS = 'JSBinaryParameter'; @@ -112,6 +115,7 @@ type procedure BrowserDestroyMsg(var aMessage : TMessage); message CEF_DESTROY; procedure ShowTextViewerMsg(var aMessage : TMessage); message MINIBROWSER_SHOWTEXTVIEWER; procedure EvalJSCodeMsg(var aMessage : TMessage); message MINIBROWSER_EVALJSCODE; + procedure GetScrollPosMsg(var aMessage : TMessage); message MINIBROWSER_GETSCROLLPOS; procedure EvalJSBinParamMsg(var aMessage : TMessage); message MINIBROWSER_JSBINPARAM; procedure WMMove(var aMessage : TWMMove); message WM_MOVE; procedure WMMoving(var aMessage : TMessage); message WM_MOVING; @@ -194,8 +198,9 @@ procedure TJSEvalFrm.Chromium1BeforeContextMenu(Sender : TObject; const params : ICefContextMenuParams; const model : ICefMenuModel); begin - model.AddItem(MINIBROWSER_CONTEXTMENU_EVALJSCODE, 'Evaluate JavaScript code...'); - model.AddItem(MINIBROWSER_CONTEXTMENU_JSBINPARAM, 'Send JPEG image...'); + model.AddItem(MINIBROWSER_CONTEXTMENU_EVALJSCODE, 'Evaluate JavaScript code...'); + model.AddItem(MINIBROWSER_CONTEXTMENU_GETSCROLLPOS, 'Get vertical scroll position...'); + model.AddItem(MINIBROWSER_CONTEXTMENU_JSBINPARAM, 'Send JPEG image...'); end; procedure TJSEvalFrm.Chromium1BeforePopup(Sender: TObject; @@ -228,8 +233,9 @@ begin Result := False; case commandId of - MINIBROWSER_CONTEXTMENU_EVALJSCODE : PostMessage(Handle, MINIBROWSER_EVALJSCODE, 0, 0); - MINIBROWSER_CONTEXTMENU_JSBINPARAM : PostMessage(Handle, MINIBROWSER_JSBINPARAM, 0, 0); + MINIBROWSER_CONTEXTMENU_EVALJSCODE : PostMessage(Handle, MINIBROWSER_EVALJSCODE, 0, 0); + MINIBROWSER_CONTEXTMENU_JSBINPARAM : PostMessage(Handle, MINIBROWSER_JSBINPARAM, 0, 0); + MINIBROWSER_CONTEXTMENU_GETSCROLLPOS : PostMessage(Handle, MINIBROWSER_GETSCROLLPOS, 0, 0); end; end; @@ -326,6 +332,16 @@ begin end; end; +procedure TJSEvalFrm.GetScrollPosMsg(var aMessage : TMessage); +var + TempMsg : ICefProcessMessage; +begin + TempMsg := TCefProcessMessageRef.New(EVAL_JS); + + if TempMsg.ArgumentList.SetString(0, 'window.pageYOffset') then + Chromium1.SendProcessMessage(PID_RENDERER, TempMsg); +end; + procedure TJSEvalFrm.EvalJSBinParamMsg(var aMessage : TMessage); var TempMsg : ICefProcessMessage; diff --git a/demos/MiniBrowser/MiniBrowser.dpr b/demos/MiniBrowser/MiniBrowser.dpr index 17067cc6..30fd1a76 100644 --- a/demos/MiniBrowser/MiniBrowser.dpr +++ b/demos/MiniBrowser/MiniBrowser.dpr @@ -65,6 +65,9 @@ begin GlobalCEFApp.LogFile := 'debug.log'; GlobalCEFApp.LogSeverity := LOGSEVERITY_INFO; + GlobalCEFApp.EnableMediaStream := False; + GlobalCEFApp.EnableSpeechInput := False; + if GlobalCEFApp.StartMainProcess then begin Application.Initialize; diff --git a/demos/MiniBrowser/uMiniBrowser.pas b/demos/MiniBrowser/uMiniBrowser.pas index 664b4cfd..63d28a7c 100644 --- a/demos/MiniBrowser/uMiniBrowser.pas +++ b/demos/MiniBrowser/uMiniBrowser.pas @@ -573,8 +573,6 @@ var begin Result := False; - if not(Chromium1.IsSameBrowser(browser)) then exit; - if (event <> nil) and (osEvent <> nil) then case osEvent.Message of WM_KEYUP : @@ -728,8 +726,7 @@ procedure TMiniBrowserFrm.Chromium1PreKeyEvent(Sender: TObject; begin Result := False; - if Chromium1.IsSameBrowser(browser) and - (event <> nil) and + if (event <> nil) and (event.kind in [KEYEVENT_KEYDOWN, KEYEVENT_KEYUP]) and (event.windows_key_code = VK_F12) then isKeyboardShortcut := True; @@ -940,6 +937,7 @@ end; procedure TMiniBrowserFrm.HideDevToolsMsg(var aMessage : TMessage); begin HideDevTools; + Chromium1.SetFocus(True); end; procedure TMiniBrowserFrm.Inczoom1Click(Sender: TObject); diff --git a/source/uCEFApplication.pas b/source/uCEFApplication.pas index a17adbec..34028fae 100644 --- a/source/uCEFApplication.pas +++ b/source/uCEFApplication.pas @@ -62,7 +62,7 @@ uses const CEF_SUPPORTED_VERSION_MAJOR = 73; CEF_SUPPORTED_VERSION_MINOR = 1; - CEF_SUPPORTED_VERSION_RELEASE = 11; + CEF_SUPPORTED_VERSION_RELEASE = 12; CEF_SUPPORTED_VERSION_BUILD = 0; CEF_CHROMEELF_VERSION_MAJOR = 73; diff --git a/source/uCEFChromium.pas b/source/uCEFChromium.pas index 1564c7b1..cb5fafec 100644 --- a/source/uCEFChromium.pas +++ b/source/uCEFChromium.pas @@ -3122,7 +3122,14 @@ begin InitializeSettings(FDevBrowserSettings); InitializeDevToolsWindowInfo(aDevTools); - TempClient := TCefClientOwn.Create; + TempClient := TCustomClientHandler.Create(Self, False, False, + False, False, + MustCreateKeyboardHandler, + False, False, + False, False, + False, False, + False, False, + False); if (inspectElementAt.x <> low(integer)) and (inspectElementAt.y <> low(integer)) then