1
0
mirror of https://github.com/salvadordf/CEF4Delphi.git synced 2025-02-02 10:25:26 +02:00

Fixed IME support in OSR mode

- Added lots of conditional compiler directives to build CEF4DElphi in Linux using Lazarus/FPC
- Updated copyright year
This commit is contained in:
Salvador Díaz Fau 2019-01-08 19:15:25 +01:00
parent ea11d6cd46
commit 769aa4f384
219 changed files with 2231 additions and 334 deletions

View File

@ -10,7 +10,7 @@
// For more information about CEF4Delphi visit :
// https://www.briskbard.com/index.php?lang=en&pageid=cef
//
// Copyright © 2018 Salvador Diaz Fau. All rights reserved.
// Copyright © 2019 Salvador Diaz Fau. All rights reserved.
//
// ************************************************************************
// ************ vvvv Original license and comments below vvvv *************

View File

@ -10,7 +10,7 @@
// For more information about CEF4Delphi visit :
// https://www.briskbard.com/index.php?lang=en&pageid=cef
//
// Copyright © 2018 Salvador Diaz Fau. All rights reserved.
// Copyright © 2019 Salvador Diaz Fau. All rights reserved.
//
// ************************************************************************
// ************ vvvv Original license and comments below vvvv *************

View File

@ -10,7 +10,7 @@
// For more information about CEF4Delphi visit :
// https://www.briskbard.com/index.php?lang=en&pageid=cef
//
// Copyright © 2018 Salvador Diaz Fau. All rights reserved.
// Copyright © 2019 Salvador Diaz Fau. All rights reserved.
//
// ************************************************************************
// ************ vvvv Original license and comments below vvvv *************

View File

@ -10,7 +10,7 @@
// For more information about CEF4Delphi visit :
// https://www.briskbard.com/index.php?lang=en&pageid=cef
//
// Copyright © 2018 Salvador Diaz Fau. All rights reserved.
// Copyright © 2019 Salvador Diaz Fau. All rights reserved.
//
// ************************************************************************
// ************ vvvv Original license and comments below vvvv *************

View File

@ -10,7 +10,7 @@
// For more information about CEF4Delphi visit :
// https://www.briskbard.com/index.php?lang=en&pageid=cef
//
// Copyright © 2018 Salvador Diaz Fau. All rights reserved.
// Copyright © 2019 Salvador Diaz Fau. All rights reserved.
//
// ************************************************************************
// ************ vvvv Original license and comments below vvvv *************

View File

@ -10,7 +10,7 @@
// For more information about CEF4Delphi visit :
// https://www.briskbard.com/index.php?lang=en&pageid=cef
//
// Copyright © 2018 Salvador Diaz Fau. All rights reserved.
// Copyright © 2019 Salvador Diaz Fau. All rights reserved.
//
// ************************************************************************
// ************ vvvv Original license and comments below vvvv *************

View File

@ -10,7 +10,7 @@
// For more information about CEF4Delphi visit :
// https://www.briskbard.com/index.php?lang=en&pageid=cef
//
// Copyright © 2018 Salvador Diaz Fau. All rights reserved.
// Copyright © 2019 Salvador Diaz Fau. All rights reserved.
//
// ************************************************************************
// ************ vvvv Original license and comments below vvvv *************

View File

@ -10,7 +10,7 @@
// For more information about CEF4Delphi visit :
// https://www.briskbard.com/index.php?lang=en&pageid=cef
//
// Copyright © 2018 Salvador Diaz Fau. All rights reserved.
// Copyright © 2019 Salvador Diaz Fau. All rights reserved.
//
// ************************************************************************
// ************ vvvv Original license and comments below vvvv *************

View File

@ -10,7 +10,7 @@
// For more information about CEF4Delphi visit :
// https://www.briskbard.com/index.php?lang=en&pageid=cef
//
// Copyright © 2018 Salvador Diaz Fau. All rights reserved.
// Copyright © 2019 Salvador Diaz Fau. All rights reserved.
//
// ************************************************************************
// ************ vvvv Original license and comments below vvvv *************

View File

@ -10,7 +10,7 @@
// For more information about CEF4Delphi visit :
// https://www.briskbard.com/index.php?lang=en&pageid=cef
//
// Copyright © 2018 Salvador Diaz Fau. All rights reserved.
// Copyright © 2019 Salvador Diaz Fau. All rights reserved.
//
// ************************************************************************
// ************ vvvv Original license and comments below vvvv *************

View File

@ -10,7 +10,7 @@
// For more information about CEF4Delphi visit :
// https://www.briskbard.com/index.php?lang=en&pageid=cef
//
// Copyright © 2018 Salvador Diaz Fau. All rights reserved.
// Copyright © 2019 Salvador Diaz Fau. All rights reserved.
//
// ************************************************************************
// ************ vvvv Original license and comments below vvvv *************

View File

@ -10,7 +10,7 @@
// For more information about CEF4Delphi visit :
// https://www.briskbard.com/index.php?lang=en&pageid=cef
//
// Copyright © 2018 Salvador Diaz Fau. All rights reserved.
// Copyright © 2019 Salvador Diaz Fau. All rights reserved.
//
// ************************************************************************
// ************ vvvv Original license and comments below vvvv *************

View File

@ -10,7 +10,7 @@
// For more information about CEF4Delphi visit :
// https://www.briskbard.com/index.php?lang=en&pageid=cef
//
// Copyright © 2018 Salvador Diaz Fau. All rights reserved.
// Copyright © 2019 Salvador Diaz Fau. All rights reserved.
//
// ************************************************************************
// ************ vvvv Original license and comments below vvvv *************

View File

@ -10,7 +10,7 @@
// For more information about CEF4Delphi visit :
// https://www.briskbard.com/index.php?lang=en&pageid=cef
//
// Copyright © 2018 Salvador Diaz Fau. All rights reserved.
// Copyright © 2019 Salvador Diaz Fau. All rights reserved.
//
// ************************************************************************
// ************ vvvv Original license and comments below vvvv *************

View File

@ -10,7 +10,7 @@
// For more information about CEF4Delphi visit :
// https://www.briskbard.com/index.php?lang=en&pageid=cef
//
// Copyright © 2018 Salvador Diaz Fau. All rights reserved.
// Copyright © 2019 Salvador Diaz Fau. All rights reserved.
//
// ************************************************************************
// ************ vvvv Original license and comments below vvvv *************

View File

@ -10,7 +10,7 @@
// For more information about CEF4Delphi visit :
// https://www.briskbard.com/index.php?lang=en&pageid=cef
//
// Copyright © 2018 Salvador Diaz Fau. All rights reserved.
// Copyright © 2019 Salvador Diaz Fau. All rights reserved.
//
// ************************************************************************
// ************ vvvv Original license and comments below vvvv *************

View File

@ -10,7 +10,7 @@
// For more information about CEF4Delphi visit :
// https://www.briskbard.com/index.php?lang=en&pageid=cef
//
// Copyright © 2018 Salvador Diaz Fau. All rights reserved.
// Copyright © 2019 Salvador Diaz Fau. All rights reserved.
//
// ************************************************************************
// ************ vvvv Original license and comments below vvvv *************

View File

@ -10,7 +10,7 @@
// For more information about CEF4Delphi visit :
// https://www.briskbard.com/index.php?lang=en&pageid=cef
//
// Copyright © 2018 Salvador Diaz Fau. All rights reserved.
// Copyright © 2019 Salvador Diaz Fau. All rights reserved.
//
// ************************************************************************
// ************ vvvv Original license and comments below vvvv *************

View File

@ -10,7 +10,7 @@
// For more information about CEF4Delphi visit :
// https://www.briskbard.com/index.php?lang=en&pageid=cef
//
// Copyright © 2018 Salvador Diaz Fau. All rights reserved.
// Copyright © 2019 Salvador Diaz Fau. All rights reserved.
//
// ************************************************************************
// ************ vvvv Original license and comments below vvvv *************

View File

@ -10,7 +10,7 @@
// For more information about CEF4Delphi visit :
// https://www.briskbard.com/index.php?lang=en&pageid=cef
//
// Copyright © 2018 Salvador Diaz Fau. All rights reserved.
// Copyright © 2019 Salvador Diaz Fau. All rights reserved.
//
// ************************************************************************
// ************ vvvv Original license and comments below vvvv *************

View File

@ -10,7 +10,7 @@
// For more information about CEF4Delphi visit :
// https://www.briskbard.com/index.php?lang=en&pageid=cef
//
// Copyright © 2018 Salvador Diaz Fau. All rights reserved.
// Copyright © 2019 Salvador Diaz Fau. All rights reserved.
//
// ************************************************************************
// ************ vvvv Original license and comments below vvvv *************

View File

@ -10,7 +10,7 @@
// For more information about CEF4Delphi visit :
// https://www.briskbard.com/index.php?lang=en&pageid=cef
//
// Copyright © 2018 Salvador Diaz Fau. All rights reserved.
// Copyright © 2019 Salvador Diaz Fau. All rights reserved.
//
// ************************************************************************
// ************ vvvv Original license and comments below vvvv *************

View File

@ -10,7 +10,7 @@
// For more information about CEF4Delphi visit :
// https://www.briskbard.com/index.php?lang=en&pageid=cef
//
// Copyright © 2018 Salvador Diaz Fau. All rights reserved.
// Copyright © 2019 Salvador Diaz Fau. All rights reserved.
//
// ************************************************************************
// ************ vvvv Original license and comments below vvvv *************

View File

@ -10,7 +10,7 @@
// For more information about CEF4Delphi visit :
// https://www.briskbard.com/index.php?lang=en&pageid=cef
//
// Copyright © 2018 Salvador Diaz Fau. All rights reserved.
// Copyright © 2019 Salvador Diaz Fau. All rights reserved.
//
// ************************************************************************
// ************ vvvv Original license and comments below vvvv *************

View File

@ -10,7 +10,7 @@
// For more information about CEF4Delphi visit :
// https://www.briskbard.com/index.php?lang=en&pageid=cef
//
// Copyright © 2018 Salvador Diaz Fau. All rights reserved.
// Copyright © 2019 Salvador Diaz Fau. All rights reserved.
//
// ************************************************************************
// ************ vvvv Original license and comments below vvvv *************

View File

@ -10,7 +10,7 @@
// For more information about CEF4Delphi visit :
// https://www.briskbard.com/index.php?lang=en&pageid=cef
//
// Copyright © 2018 Salvador Diaz Fau. All rights reserved.
// Copyright © 2019 Salvador Diaz Fau. All rights reserved.
//
// ************************************************************************
// ************ vvvv Original license and comments below vvvv *************

View File

@ -10,7 +10,7 @@
// For more information about CEF4Delphi visit :
// https://www.briskbard.com/index.php?lang=en&pageid=cef
//
// Copyright © 2018 Salvador Diaz Fau. All rights reserved.
// Copyright © 2019 Salvador Diaz Fau. All rights reserved.
//
// ************************************************************************
// ************ vvvv Original license and comments below vvvv *************

View File

@ -10,7 +10,7 @@
// For more information about CEF4Delphi visit :
// https://www.briskbard.com/index.php?lang=en&pageid=cef
//
// Copyright © 2018 Salvador Diaz Fau. All rights reserved.
// Copyright © 2019 Salvador Diaz Fau. All rights reserved.
//
// ************************************************************************
// ************ vvvv Original license and comments below vvvv *************

View File

@ -10,7 +10,7 @@
// For more information about CEF4Delphi visit :
// https://www.briskbard.com/index.php?lang=en&pageid=cef
//
// Copyright © 2018 Salvador Diaz Fau. All rights reserved.
// Copyright © 2019 Salvador Diaz Fau. All rights reserved.
//
// ************************************************************************
// ************ vvvv Original license and comments below vvvv *************

View File

@ -10,7 +10,7 @@
// For more information about CEF4Delphi visit :
// https://www.briskbard.com/index.php?lang=en&pageid=cef
//
// Copyright © 2018 Salvador Diaz Fau. All rights reserved.
// Copyright © 2019 Salvador Diaz Fau. All rights reserved.
//
// ************************************************************************
// ************ vvvv Original license and comments below vvvv *************

View File

@ -10,7 +10,7 @@
// For more information about CEF4Delphi visit :
// https://www.briskbard.com/index.php?lang=en&pageid=cef
//
// Copyright © 2018 Salvador Diaz Fau. All rights reserved.
// Copyright © 2019 Salvador Diaz Fau. All rights reserved.
//
// ************************************************************************
// ************ vvvv Original license and comments below vvvv *************

View File

@ -10,7 +10,7 @@
// For more information about CEF4Delphi visit :
// https://www.briskbard.com/index.php?lang=en&pageid=cef
//
// Copyright © 2018 Salvador Diaz Fau. All rights reserved.
// Copyright © 2019 Salvador Diaz Fau. All rights reserved.
//
// ************************************************************************
// ************ vvvv Original license and comments below vvvv *************
@ -763,6 +763,7 @@ begin
chrmosr.ShutdownDragAndDrop;
if (FPopUpBitmap <> nil) then FreeAndNil(FPopUpBitmap);
if (FResizeCS <> nil) then FreeAndNil(FResizeCS);
end;
procedure TForm1.FormHide(Sender: TObject);

View File

@ -10,7 +10,7 @@
// For more information about CEF4Delphi visit :
// https://www.briskbard.com/index.php?lang=en&pageid=cef
//
// Copyright © 2018 Salvador Diaz Fau. All rights reserved.
// Copyright © 2019 Salvador Diaz Fau. All rights reserved.
//
// ************************************************************************
// ************ vvvv Original license and comments below vvvv *************

View File

@ -10,7 +10,7 @@
// For more information about CEF4Delphi visit :
// https://www.briskbard.com/index.php?lang=en&pageid=cef
//
// Copyright © 2018 Salvador Diaz Fau. All rights reserved.
// Copyright © 2019 Salvador Diaz Fau. All rights reserved.
//
// ************************************************************************
// ************ vvvv Original license and comments below vvvv *************

View File

@ -10,7 +10,7 @@
// For more information about CEF4Delphi visit :
// https://www.briskbard.com/index.php?lang=en&pageid=cef
//
// Copyright © 2018 Salvador Diaz Fau. All rights reserved.
// Copyright © 2019 Salvador Diaz Fau. All rights reserved.
//
// ************************************************************************
// ************ vvvv Original license and comments below vvvv *************

View File

@ -10,7 +10,7 @@
// For more information about CEF4Delphi visit :
// https://www.briskbard.com/index.php?lang=en&pageid=cef
//
// Copyright © 2018 Salvador Diaz Fau. All rights reserved.
// Copyright © 2019 Salvador Diaz Fau. All rights reserved.
//
// ************************************************************************
// ************ vvvv Original license and comments below vvvv *************

View File

@ -10,7 +10,7 @@
// For more information about CEF4Delphi visit :
// https://www.briskbard.com/index.php?lang=en&pageid=cef
//
// Copyright © 2018 Salvador Diaz Fau. All rights reserved.
// Copyright © 2019 Salvador Diaz Fau. All rights reserved.
//
// ************************************************************************
// ************ vvvv Original license and comments below vvvv *************

View File

@ -10,7 +10,7 @@
// For more information about CEF4Delphi visit :
// https://www.briskbard.com/index.php?lang=en&pageid=cef
//
// Copyright © 2018 Salvador Diaz Fau. All rights reserved.
// Copyright © 2019 Salvador Diaz Fau. All rights reserved.
//
// ************************************************************************
// ************ vvvv Original license and comments below vvvv *************

View File

@ -108,6 +108,9 @@ object OSRExternalPumpBrowserFrm: TOSRExternalPumpBrowserFrm
Top = 30
Width = 913
Height = 554
OnIMECancelComposition = Panel1IMECancelComposition
OnIMECommitText = Panel1IMECommitText
OnIMESetComposition = Panel1IMESetComposition
Align = alClient
Caption = 'Panel1'
TabOrder = 1
@ -134,6 +137,7 @@ object OSRExternalPumpBrowserFrm: TOSRExternalPumpBrowserFrm
OnPopupSize = chrmosrPopupSize
OnPaint = chrmosrPaint
OnCursorChange = chrmosrCursorChange
OnIMECompositionRangeChanged = chrmosrIMECompositionRangeChanged
Left = 24
Top = 56
end

View File

@ -10,7 +10,7 @@
// For more information about CEF4Delphi visit :
// https://www.briskbard.com/index.php?lang=en&pageid=cef
//
// Copyright © 2018 Salvador Diaz Fau. All rights reserved.
// Copyright © 2019 Salvador Diaz Fau. All rights reserved.
//
// ************************************************************************
// ************ vvvv Original license and comments below vvvv *************
@ -78,6 +78,9 @@ type
procedure Panel1MouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
procedure Panel1MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
procedure Panel1MouseLeave(Sender: TObject);
procedure Panel1IMECancelComposition(Sender: TObject);
procedure Panel1IMECommitText(Sender: TObject; const aText: ustring; const replacement_range: PCefRange; relative_cursor_pos: Integer);
procedure Panel1IMESetComposition(Sender: TObject; const aText: ustring; const underlines: TCefCompositionUnderlineDynArray; const replacement_range, selection_range: TCefRange);
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
@ -98,6 +101,7 @@ type
procedure chrmosrBeforeClose(Sender: TObject; const browser: ICefBrowser);
procedure chrmosrTooltip(Sender: TObject; const browser: ICefBrowser; var text: ustring; out Result: Boolean);
procedure chrmosrBeforePopup(Sender: TObject; const browser: ICefBrowser; const frame: ICefFrame; const targetUrl, targetFrameName: ustring; targetDisposition: TCefWindowOpenDisposition; userGesture: Boolean; const popupFeatures: TCefPopupFeatures; var windowInfo: TCefWindowInfo; var client: ICefClient; var settings: TCefBrowserSettings; var noJavascriptAccess: Boolean; var Result: Boolean);
procedure chrmosrIMECompositionRangeChanged(Sender: TObject; const browser: ICefBrowser; const selected_range: PCefRange; character_boundsCount: NativeUInt; const character_bounds: PCefRect);
procedure SnapshotBtnClick(Sender: TObject);
procedure SnapshotBtnEnter(Sender: TObject);
@ -665,6 +669,7 @@ begin
chrmosr.ShutdownDragAndDrop;
if (FPopUpBitmap <> nil) then FreeAndNil(FPopUpBitmap);
if (FResizeCS <> nil) then FreeAndNil(FResizeCS);
end;
procedure TOSRExternalPumpBrowserFrm.FormHide(Sender: TObject);
@ -685,6 +690,8 @@ begin
// opaque white background color
chrmosr.Options.BackgroundColor := CefColorSetARGB($FF, $FF, $FF, $FF);
Panel1.CreateIMEHandler;
if chrmosr.CreateBrowser(nil, '') then
chrmosr.InitializeDragAndDrop(Panel1)
else
@ -856,4 +863,66 @@ begin
if not(chrmosr.Initialized) then Timer1.Enabled := True;
end;
procedure TOSRExternalPumpBrowserFrm.Panel1IMECancelComposition(Sender: TObject);
begin
chrmosr.IMECancelComposition;
end;
procedure TOSRExternalPumpBrowserFrm.Panel1IMECommitText( Sender : TObject;
const aText : ustring;
const replacement_range : PCefRange;
relative_cursor_pos : Integer);
begin
chrmosr.IMECommitText(aText, replacement_range, relative_cursor_pos);
end;
procedure TOSRExternalPumpBrowserFrm.Panel1IMESetComposition( Sender : TObject;
const aText : ustring;
const underlines : TCefCompositionUnderlineDynArray;
const replacement_range : TCefRange;
const selection_range : TCefRange);
begin
chrmosr.IMESetComposition(aText, underlines, @replacement_range, @selection_range);
end;
procedure TOSRExternalPumpBrowserFrm.chrmosrIMECompositionRangeChanged( Sender : TObject;
const browser : ICefBrowser;
const selected_range : PCefRange;
character_boundsCount : NativeUInt;
const character_bounds : PCefRect);
var
TempDeviceBounds : TCefRectDynArray;
TempPRect : PCefRect;
i : NativeUInt;
begin
TempDeviceBounds := nil;
try
if (character_boundsCount > 0) then
begin
SetLength(TempDeviceBounds, character_boundsCount);
i := 0;
TempPRect := character_bounds;
while (i < character_boundsCount) do
begin
TempDeviceBounds[i] := TempPRect^;
LogicalToDevice(TempDeviceBounds[i], GlobalCEFApp.DeviceScaleFactor);
inc(TempPRect);
inc(i);
end;
end;
Panel1.ChangeCompositionRange(selected_range^, TempDeviceBounds);
finally
if (TempDeviceBounds <> nil) then
begin
Finalize(TempDeviceBounds);
TempDeviceBounds := nil;
end;
end;
end;
end.

View File

@ -10,7 +10,7 @@
// For more information about CEF4Delphi visit :
// https://www.briskbard.com/index.php?lang=en&pageid=cef
//
// Copyright © 2018 Salvador Diaz Fau. All rights reserved.
// Copyright © 2019 Salvador Diaz Fau. All rights reserved.
//
// ************************************************************************
// ************ vvvv Original license and comments below vvvv *************

View File

@ -10,7 +10,7 @@
// For more information about CEF4Delphi visit :
// https://www.briskbard.com/index.php?lang=en&pageid=cef
//
// Copyright © 2018 Salvador Diaz Fau. All rights reserved.
// Copyright © 2019 Salvador Diaz Fau. All rights reserved.
//
// ************************************************************************
// ************ vvvv Original license and comments below vvvv *************

View File

@ -10,7 +10,7 @@
// For more information about CEF4Delphi visit :
// https://www.briskbard.com/index.php?lang=en&pageid=cef
//
// Copyright © 2018 Salvador Diaz Fau. All rights reserved.
// Copyright © 2019 Salvador Diaz Fau. All rights reserved.
//
// ************************************************************************
// ************ vvvv Original license and comments below vvvv *************

View File

@ -10,7 +10,7 @@
// For more information about CEF4Delphi visit :
// https://www.briskbard.com/index.php?lang=en&pageid=cef
//
// Copyright © 2018 Salvador Diaz Fau. All rights reserved.
// Copyright © 2019 Salvador Diaz Fau. All rights reserved.
//
// ************************************************************************
// ************ vvvv Original license and comments below vvvv *************

View File

@ -10,7 +10,7 @@
// For more information about CEF4Delphi visit :
// https://www.briskbard.com/index.php?lang=en&pageid=cef
//
// Copyright © 2018 Salvador Diaz Fau. All rights reserved.
// Copyright © 2019 Salvador Diaz Fau. All rights reserved.
//
// ************************************************************************
// ************ vvvv Original license and comments below vvvv *************

View File

@ -10,7 +10,7 @@
// For more information about CEF4Delphi visit :
// https://www.briskbard.com/index.php?lang=en&pageid=cef
//
// Copyright © 2018 Salvador Diaz Fau. All rights reserved.
// Copyright © 2019 Salvador Diaz Fau. All rights reserved.
//
// ************************************************************************
// ************ vvvv Original license and comments below vvvv *************

View File

@ -10,7 +10,7 @@
// For more information about CEF4Delphi visit :
// https://www.briskbard.com/index.php?lang=en&pageid=cef
//
// Copyright © 2018 Salvador Diaz Fau. All rights reserved.
// Copyright © 2019 Salvador Diaz Fau. All rights reserved.
//
// ************************************************************************
// ************ vvvv Original license and comments below vvvv *************

View File

@ -10,7 +10,7 @@
// For more information about CEF4Delphi visit :
// https://www.briskbard.com/index.php?lang=en&pageid=cef
//
// Copyright © 2018 Salvador Diaz Fau. All rights reserved.
// Copyright © 2019 Salvador Diaz Fau. All rights reserved.
//
// ************************************************************************
// ************ vvvv Original license and comments below vvvv *************

View File

@ -10,7 +10,7 @@
// For more information about CEF4Delphi visit :
// https://www.briskbard.com/index.php?lang=en&pageid=cef
//
// Copyright © 2018 Salvador Diaz Fau. All rights reserved.
// Copyright © 2019 Salvador Diaz Fau. All rights reserved.
//
// ************************************************************************
// ************ vvvv Original license and comments below vvvv *************

View File

@ -10,7 +10,7 @@
// For more information about CEF4Delphi visit :
// https://www.briskbard.com/index.php?lang=en&pageid=cef
//
// Copyright © 2018 Salvador Diaz Fau. All rights reserved.
// Copyright © 2019 Salvador Diaz Fau. All rights reserved.
//
// ************************************************************************
// ************ vvvv Original license and comments below vvvv *************

View File

@ -10,7 +10,7 @@
// For more information about CEF4Delphi visit :
// https://www.briskbard.com/index.php?lang=en&pageid=cef
//
// Copyright © 2018 Salvador Diaz Fau. All rights reserved.
// Copyright © 2019 Salvador Diaz Fau. All rights reserved.
//
// ************************************************************************
// ************ vvvv Original license and comments below vvvv *************

View File

@ -10,7 +10,7 @@
// For more information about CEF4Delphi visit :
// https://www.briskbard.com/index.php?lang=en&pageid=cef
//
// Copyright © 2018 Salvador Diaz Fau. All rights reserved.
// Copyright © 2019 Salvador Diaz Fau. All rights reserved.
//
// ************************************************************************
// ************ vvvv Original license and comments below vvvv *************

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<CONFIG>
<ProjectOptions>
<Version Value="10"/>
<Version Value="11"/>
<PathDelim Value="\"/>
<General>
<Flags>
@ -24,9 +24,10 @@
<Version Value="2"/>
</PublishOptions>
<RunParams>
<local>
<FormatVersion Value="1"/>
</local>
<FormatVersion Value="2"/>
<Modes Count="1">
<Mode0 Name="default"/>
</Modes>
</RunParams>
<RequiredPackages Count="2">
<Item1>

View File

@ -2,17 +2,17 @@
<CONFIG>
<ProjectSession>
<PathDelim Value="\"/>
<Version Value="10"/>
<Version Value="11"/>
<BuildModes Active="Default"/>
<Units Count="19">
<Units Count="25">
<Unit0>
<Filename Value="SimpleLazOSRBrowser.lpr"/>
<IsPartOfProject Value="True"/>
<IsVisibleTab Value="True"/>
<EditorIndex Value="-1"/>
<WindowIndex Value="-1"/>
<TopLine Value="24"/>
<CursorPos X="46" Y="33"/>
<UsageCount Value="40"/>
<UsageCount Value="42"/>
<DefaultSyntaxHighlighter Value="Delphi"/>
</Unit0>
<Unit1>
@ -21,14 +21,14 @@
<ComponentName Value="Form1"/>
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
<EditorIndex Value="-1"/>
<TopLine Value="285"/>
<CursorPos Y="296"/>
<UsageCount Value="40"/>
<Bookmarks Count="2">
<Item0 Y="189" ID="1"/>
<Item1 X="5" Y="801" ID="2"/>
<TopLine Value="19"/>
<CursorPos X="63" Y="204"/>
<UsageCount Value="42"/>
<Bookmarks Count="1">
<Item0 X="40" Y="252" ID="4"/>
</Bookmarks>
<Loaded Value="True"/>
<LoadedDesigner Value="True"/>
<DefaultSyntaxHighlighter Value="Delphi"/>
</Unit1>
<Unit2>
@ -43,10 +43,11 @@
</Unit2>
<Unit3>
<Filename Value="..\..\source\uBufferPanel.pas"/>
<EditorIndex Value="-1"/>
<TopLine Value="95"/>
<CursorPos X="41" Y="126"/>
<EditorIndex Value="5"/>
<TopLine Value="32"/>
<CursorPos Y="284"/>
<UsageCount Value="17"/>
<Loaded Value="True"/>
</Unit3>
<Unit4>
<Filename Value="..\..\..\..\lcl\lcltype.pp"/>
@ -60,10 +61,11 @@
<Unit5>
<Filename Value="C:\lazarus\lcl\forms.pp"/>
<UnitName Value="Forms"/>
<EditorIndex Value="-1"/>
<TopLine Value="1549"/>
<CursorPos X="15" Y="1493"/>
<EditorIndex Value="1"/>
<TopLine Value="243"/>
<CursorPos X="43" Y="268"/>
<UsageCount Value="11"/>
<Loaded Value="True"/>
</Unit5>
<Unit6>
<Filename Value="C:\lazarus\lcl\graphics.pp"/>
@ -155,18 +157,187 @@
</Unit17>
<Unit18>
<Filename Value="..\..\source\uCEFApplication.pas"/>
<EditorIndex Value="-1"/>
<TopLine Value="1096"/>
<EditorIndex Value="6"/>
<TopLine Value="28"/>
<CursorPos X="59" Y="1103"/>
<UsageCount Value="10"/>
<Bookmarks Count="1">
<Item0 X="74" Y="1103" ID="1"/>
</Bookmarks>
<Loaded Value="True"/>
</Unit18>
<Unit19>
<Filename Value="..\..\source\uCEFChromium.pas"/>
<EditorIndex Value="7"/>
<TopLine Value="559"/>
<CursorPos Y="570"/>
<UsageCount Value="10"/>
<Loaded Value="True"/>
</Unit19>
<Unit20>
<Filename Value="..\..\source\uCEFOSRIMEHandler.pas"/>
<IsVisibleTab Value="True"/>
<EditorIndex Value="2"/>
<TopLine Value="97"/>
<CursorPos Y="651"/>
<UsageCount Value="10"/>
<Bookmarks Count="2">
<Item0 X="23" Y="177" ID="2"/>
<Item1 X="58" Y="279" ID="1"/>
</Bookmarks>
<Loaded Value="True"/>
</Unit20>
<Unit21>
<Filename Value="..\..\source\uCEFTypes.pas"/>
<EditorIndex Value="-1"/>
<TopLine Value="264"/>
<CursorPos X="35" Y="286"/>
<UsageCount Value="10"/>
</Unit21>
<Unit22>
<Filename Value="C:\lazarus\fpc\3.0.4\source\packages\winunits-base\src\imm.pas"/>
<EditorIndex Value="4"/>
<TopLine Value="286"/>
<CursorPos X="33" Y="323"/>
<UsageCount Value="10"/>
<Loaded Value="True"/>
</Unit22>
<Unit23>
<Filename Value="C:\lazarus\fpc\3.0.4\source\packages\winunits-base\src\imm_dyn.pas"/>
<EditorIndex Value="3"/>
<CursorPos X="23" Y="17"/>
<UsageCount Value="10"/>
<Loaded Value="True"/>
</Unit23>
<Unit24>
<Filename Value="C:\lazarus\fpc\3.0.4\source\packages\winunits-base\src\buildwinutilsbase.pp"/>
<EditorIndex Value="-1"/>
<CursorPos X="67" Y="17"/>
<UsageCount Value="10"/>
</Unit24>
</Units>
<General>
<ActiveWindowIndexAtStart Value="-1"/>
</General>
<JumpHistory HistoryIndex="-1"/>
<JumpHistory Count="30" HistoryIndex="29">
<Position1>
<Filename Value="..\..\source\uCEFOSRIMEHandler.pas"/>
<Caret Line="612" TopLine="591"/>
</Position1>
<Position2>
<Filename Value="..\..\source\uCEFOSRIMEHandler.pas"/>
<Caret Line="624" TopLine="620"/>
</Position2>
<Position3>
<Filename Value="..\..\source\uCEFOSRIMEHandler.pas"/>
<Caret Line="626" TopLine="620"/>
</Position3>
<Position4>
<Filename Value="..\..\source\uCEFOSRIMEHandler.pas"/>
<Caret Line="627" TopLine="620"/>
</Position4>
<Position5>
<Filename Value="..\..\source\uCEFOSRIMEHandler.pas"/>
<Caret Line="629" TopLine="620"/>
</Position5>
<Position6>
<Filename Value="..\..\source\uCEFOSRIMEHandler.pas"/>
<Caret Line="632" TopLine="620"/>
</Position6>
<Position7>
<Filename Value="..\..\source\uCEFOSRIMEHandler.pas"/>
<Caret Line="633" TopLine="620"/>
</Position7>
<Position8>
<Filename Value="..\..\source\uCEFOSRIMEHandler.pas"/>
<Caret Line="635" TopLine="620"/>
</Position8>
<Position9>
<Filename Value="..\..\source\uCEFOSRIMEHandler.pas"/>
<Caret Line="638" TopLine="620"/>
</Position9>
<Position10>
<Filename Value="..\..\source\uCEFOSRIMEHandler.pas"/>
<Caret Line="639" TopLine="620"/>
</Position10>
<Position11>
<Filename Value="..\..\source\uCEFOSRIMEHandler.pas"/>
<Caret Line="640" TopLine="620"/>
</Position11>
<Position12>
<Filename Value="..\..\source\uCEFOSRIMEHandler.pas"/>
<Caret Line="648" TopLine="635"/>
</Position12>
<Position13>
<Filename Value="..\..\source\uCEFOSRIMEHandler.pas"/>
<Caret Line="650" TopLine="635"/>
</Position13>
<Position14>
<Filename Value="..\..\source\uCEFOSRIMEHandler.pas"/>
<Caret Line="651" TopLine="635"/>
</Position14>
<Position15>
<Filename Value="..\..\source\uCEFOSRIMEHandler.pas"/>
<Caret Line="652" TopLine="635"/>
</Position15>
<Position16>
<Filename Value="..\..\source\uCEFOSRIMEHandler.pas"/>
<Caret Line="666" TopLine="653"/>
</Position16>
<Position17>
<Filename Value="..\..\source\uCEFOSRIMEHandler.pas"/>
<Caret Line="673" TopLine="653"/>
</Position17>
<Position18>
<Filename Value="..\..\source\uCEFOSRIMEHandler.pas"/>
<Caret Line="676" TopLine="667"/>
</Position18>
<Position19>
<Filename Value="..\..\source\uCEFOSRIMEHandler.pas"/>
<Caret Line="677" TopLine="667"/>
</Position19>
<Position20>
<Filename Value="..\..\source\uCEFOSRIMEHandler.pas"/>
<Caret Line="678" TopLine="667"/>
</Position20>
<Position21>
<Filename Value="..\..\source\uCEFOSRIMEHandler.pas"/>
<Caret Line="679" TopLine="667"/>
</Position21>
<Position22>
<Filename Value="..\..\source\uCEFOSRIMEHandler.pas"/>
<Caret Line="680" TopLine="667"/>
</Position22>
<Position23>
<Filename Value="..\..\source\uCEFOSRIMEHandler.pas"/>
<Caret Line="681" TopLine="667"/>
</Position23>
<Position24>
<Filename Value="..\..\source\uCEFOSRIMEHandler.pas"/>
<Caret Line="682" TopLine="667"/>
</Position24>
<Position25>
<Filename Value="..\..\source\uCEFOSRIMEHandler.pas"/>
<Caret Line="683" TopLine="667"/>
</Position25>
<Position26>
<Filename Value="..\..\source\uCEFOSRIMEHandler.pas"/>
<Caret Line="685" TopLine="667"/>
</Position26>
<Position27>
<Filename Value="usimplelazosrbrowser.pas"/>
<Caret Line="204" Column="63" TopLine="19"/>
</Position27>
<Position28>
<Filename Value="C:\lazarus\lcl\forms.pp"/>
<Caret Line="750" Column="3" TopLine="728"/>
</Position28>
<Position29>
<Filename Value="C:\lazarus\lcl\forms.pp"/>
<Caret Line="445" Column="50" TopLine="408"/>
</Position29>
<Position30>
<Filename Value="C:\lazarus\fpc\3.0.4\source\packages\winunits-base\src\imm_dyn.pas"/>
<Caret Line="17" Column="23"/>
</Position30>
</JumpHistory>
<RunParams>
<FormatVersion Value="2"/>
<Modes Count="0" ActiveMode="default"/>
</RunParams>
</ProjectSession>
</CONFIG>

View File

@ -16,7 +16,7 @@ object Form1: TForm1
OnHide = FormHide
OnShow = FormShow
Position = poScreenCenter
LCLVersion = '1.8.4.0'
LCLVersion = '2.0.0.3'
object NavControlPnl: TPanel
Left = 0
Height = 21
@ -90,6 +90,9 @@ object Form1: TForm1
Height = 544
Top = 21
Width = 800
OnIMECancelComposition = Panel1IMECancelComposition
OnIMECommitText = Panel1IMECommitText
OnIMESetComposition = Panel1IMESetComposition
Align = alClient
OnUTF8KeyPress = Panel1UTF8KeyPress
Caption = 'Panel1'
@ -119,6 +122,7 @@ object Form1: TForm1
OnPopupSize = chrmosrPopupSize
OnPaint = chrmosrPaint
OnCursorChange = chrmosrCursorChange
OnIMECompositionRangeChanged = chrmosrIMECompositionRangeChanged
left = 24
top = 56
end

View File

@ -10,7 +10,7 @@
// For more information about CEF4Delphi visit :
// https://www.briskbard.com/index.php?lang=en&pageid=cef
//
// Copyright © 2018 Salvador Diaz Fau. All rights reserved.
// Copyright © 2019 Salvador Diaz Fau. All rights reserved.
//
// ************************************************************************
// ************ vvvv Original license and comments below vvvv *************
@ -43,8 +43,8 @@ interface
uses
Windows, LCLIntf, LCLType, LMessages, Messages, SysUtils, Variants, Classes, SyncObjs,
Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls,
uCEFChromium, uCEFTypes, uCEFInterfaces, uCEFConstants, uBufferPanel, Types;
Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls, Types,
uCEFChromium, uCEFTypes, uCEFInterfaces, uCEFConstants, uBufferPanel, uCEFChromiumEvents;
type
@ -66,6 +66,9 @@ type
procedure Panel1Enter(Sender: TObject);
procedure Panel1Exit(Sender: TObject);
procedure Panel1IMECancelComposition(Sender: TObject);
procedure Panel1IMECommitText(Sender: TObject; const aText: ustring; const replacement_range: PCefRange; relative_cursor_pos: integer);
procedure Panel1IMESetComposition(Sender: TObject; const aText: ustring; const underlines: TCefCompositionUnderlineDynArray; const replacement_range, selection_range: TCefRange);
procedure Panel1Resize(Sender: TObject);
procedure Panel1Click(Sender: TObject);
procedure Panel1MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
@ -96,6 +99,7 @@ type
procedure chrmosrBeforePopup(Sender: TObject; const browser: ICefBrowser; const frame: ICefFrame; const targetUrl, targetFrameName: ustring; targetDisposition: TCefWindowOpenDisposition; userGesture: Boolean; const popupFeatures: TCefPopupFeatures; var windowInfo: TCefWindowInfo; var client: ICefClient; var settings: TCefBrowserSettings; var noJavascriptAccess: Boolean; var Result: Boolean);
procedure chrmosrClose(Sender: TObject; const browser: ICefBrowser; out Result: Boolean);
procedure chrmosrBeforeClose(Sender: TObject; const browser: ICefBrowser);
procedure chrmosrIMECompositionRangeChanged(Sender: TObject; const browser: ICefBrowser; const selected_range: PCefRange; character_boundsCount: NativeUInt; const character_bounds: PCefRect);
procedure SnapshotBtnClick(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
@ -111,7 +115,10 @@ type
FPendingResize : boolean;
FCanClose : boolean;
FClosing : boolean;
FResizeCS : TCriticalSection;
FResizeCS : TCriticalSection;
FIMECS : TCriticalSection;
FDeviceBounds : TCefRectDynArray;
FSelectedRange : TCefRange;
FLastClickCount : integer;
FLastClickTime : integer;
@ -135,7 +142,8 @@ type
procedure WMSysKeyUp(var aMessage: TMessage); message WM_SYSKEYUP;
procedure BrowserCreatedMsg(var aMessage : TMessage); message CEF_AFTERCREATED;
procedure PendingResizeMsg(var aMessage : TMessage); message CEF_PENDINGRESIZE;
procedure PendingInvalidateMsg(var aMessage : TMessage); message CEF_PENDINGINVALIDATE;
procedure PendingInvalidateMsg(var aMessage : TMessage); message CEF_PENDINGINVALIDATE;
procedure RangeChangedMsg(var aMessage : TMessage); message CEF_IMERANGECHANGED;
public
{ Public declarations }
@ -169,6 +177,55 @@ begin
chrmosr.LoadURL(ComboBox1.Text);
end;
procedure TForm1.chrmosrIMECompositionRangeChanged( Sender : TObject;
const browser : ICefBrowser;
const selected_range : PCefRange;
character_boundsCount : NativeUInt;
const character_bounds : PCefRect);
var
TempPRect : PCefRect;
i : NativeUInt;
begin
try
FIMECS.Acquire;
// TChromium.OnIMECompositionRangeChanged is triggered in a different thread
// and all functions using a IMM context need to be executed in the same
// thread, in this case the main thread. We need to save the parameters and
// send a message to the form to execute Panel1.ChangeCompositionRange in
// the main thread.
if (FDeviceBounds <> nil) then
begin
Finalize(FDeviceBounds);
FDeviceBounds := nil;
end;
FSelectedRange := selected_range^;
if (character_boundsCount > 0) then
begin
SetLength(FDeviceBounds, character_boundsCount);
i := 0;
TempPRect := character_bounds;
while (i < character_boundsCount) do
begin
FDeviceBounds[i] := TempPRect^;
LogicalToDevice(FDeviceBounds[i], GlobalCEFApp.DeviceScaleFactor);
inc(TempPRect);
inc(i);
end;
end;
PostMessage(Handle, CEF_IMERANGECHANGED, 0, 0);
finally
FIMECS.Release;
end;
end;
procedure TForm1.GoBtnEnter(Sender: TObject);
begin
chrmosr.SendFocusEvent(False);
@ -614,7 +671,13 @@ begin
FPendingResize := False;
FCanClose := False;
FClosing := False;
FDeviceBounds := nil;
FSelectedRange.from := 0;
FSelectedRange.to_ := 0;
FResizeCS := TCriticalSection.Create;
FIMECS := TCriticalSection.Create;
InitializeLastClick;
end;
@ -623,7 +686,15 @@ procedure TForm1.FormDestroy(Sender: TObject);
begin
chrmosr.ShutdownDragAndDrop;
if (FPopUpBitmap <> nil) then FreeAndNil(FPopUpBitmap);
if (FPopUpBitmap <> nil) then FreeAndNil(FPopUpBitmap);
if (FResizeCS <> nil) then FreeAndNil(FResizeCS);
if (FIMECS <> nil) then FreeAndNil(FIMECS);
if (FDeviceBounds <> nil) then
begin
Finalize(FDeviceBounds);
FDeviceBounds := nil;
end;
end;
procedure TForm1.FormHide(Sender: TObject);
@ -644,6 +715,11 @@ begin
// opaque white background color
chrmosr.Options.BackgroundColor := CefColorSetARGB($FF, $FF, $FF, $FF);
// The IME handler needs to be created when Panel1 has a valid handle
// and before the browser creation.
// You can skip this if the user doesn't need an "Input Method Editor".
Panel1.CreateIMEHandler;
if chrmosr.CreateBrowser(nil, '') then
chrmosr.InitializeDragAndDrop(Panel1)
else
@ -752,6 +828,16 @@ begin
Panel1.Invalidate;
end;
procedure TForm1.RangeChangedMsg(var aMessage : TMessage);
begin
try
FIMECS.Acquire;
Panel1.ChangeCompositionRange(FSelectedRange, FDeviceBounds);
finally
FIMECS.Release;
end;
end;
procedure TForm1.DoResize;
begin
try
@ -800,6 +886,28 @@ begin
chrmosr.SendFocusEvent(False);
end;
procedure TForm1.Panel1IMECancelComposition(Sender: TObject);
begin
chrmosr.IMECancelComposition;
end;
procedure TForm1.Panel1IMECommitText( Sender : TObject;
const aText : ustring;
const replacement_range : PCefRange;
relative_cursor_pos : Integer);
begin
chrmosr.IMECommitText(aText, replacement_range, relative_cursor_pos);
end;
procedure TForm1.Panel1IMESetComposition( Sender : TObject;
const aText : ustring;
const underlines : TCefCompositionUnderlineDynArray;
const replacement_range : TCefRange;
const selection_range : TCefRange);
begin
chrmosr.IMESetComposition(aText, underlines, @replacement_range, @selection_range);
end;
procedure TForm1.Panel1KeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
var
TempKeyEvent : TCefKeyEvent;

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<CONFIG>
<ProjectOptions>
<Version Value="10"/>
<Version Value="11"/>
<PathDelim Value="\"/>
<General>
<SessionStorage Value="InProjectDir"/>
@ -18,9 +18,10 @@
<Version Value="2"/>
</PublishOptions>
<RunParams>
<local>
<FormatVersion Value="1"/>
</local>
<FormatVersion Value="2"/>
<Modes Count="1">
<Mode0 Name="default"/>
</Modes>
</RunParams>
<RequiredPackages Count="2">
<Item1>

View File

@ -2,16 +2,16 @@
<CONFIG>
<ProjectSession>
<PathDelim Value="\"/>
<Version Value="10"/>
<Version Value="11"/>
<BuildModes Active="Default"/>
<Units Count="49">
<Units Count="52">
<Unit0>
<Filename Value="SimpleLazarusBrowser.lpr"/>
<IsPartOfProject Value="True"/>
<EditorIndex Value="-1"/>
<TopLine Value="5"/>
<CursorPos X="43" Y="5"/>
<UsageCount Value="42"/>
<UsageCount Value="43"/>
</Unit0>
<Unit1>
<Filename Value="usimplelazarusbrowser.pas"/>
@ -20,11 +20,11 @@
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
<UnitName Value="uSimpleLazarusBrowser"/>
<IsVisibleTab Value="True"/>
<EditorIndex Value="-1"/>
<WindowIndex Value="-1"/>
<TopLine Value="26"/>
<CursorPos Y="168"/>
<UsageCount Value="42"/>
<CursorPos Y="40"/>
<UsageCount Value="43"/>
</Unit1>
<Unit2>
<Filename Value="..\..\source\uCEFChromium.pas"/>
@ -84,9 +84,13 @@
<Unit9>
<Filename Value="..\..\source\uBufferPanel.pas"/>
<EditorIndex Value="-1"/>
<TopLine Value="40"/>
<CursorPos X="36" Y="62"/>
<TopLine Value="418"/>
<CursorPos X="55" Y="426"/>
<UsageCount Value="10"/>
<Bookmarks Count="2">
<Item0 X="3" Y="265" ID="3"/>
<Item1 X="52" Y="413" ID="4"/>
</Bookmarks>
</Unit9>
<Unit10>
<Filename Value="..\..\source\uCEFServerComponent.pas"/>
@ -360,8 +364,8 @@
</Unit46>
<Unit47>
<Filename Value="..\..\source\cef.inc"/>
<IsVisibleTab Value="True"/>
<EditorIndex Value="-1"/>
<WindowIndex Value="-1"/>
<TopLine Value="136"/>
<UsageCount Value="10"/>
</Unit47>
@ -372,10 +376,39 @@
<CursorPos X="37" Y="147"/>
<UsageCount Value="10"/>
</Unit48>
<Unit49>
<Filename Value="..\..\source\uCEFOSRIMEHandler.pas"/>
<EditorIndex Value="-1"/>
<TopLine Value="116"/>
<CursorPos X="30" Y="116"/>
<UsageCount Value="10"/>
<Bookmarks Count="2">
<Item0 X="33" Y="176" ID="1"/>
<Item1 X="3" Y="138" ID="2"/>
</Bookmarks>
</Unit49>
<Unit50>
<Filename Value="C:\lazarus\fpc\3.0.4\source\packages\winunits-base\src\imm.pas"/>
<EditorIndex Value="-1"/>
<TopLine Value="529"/>
<CursorPos X="30" Y="551"/>
<UsageCount Value="10"/>
</Unit50>
<Unit51>
<Filename Value="C:\lazarus\fpc\3.0.4\source\packages\winunits-base\src\imm_dyn.pas"/>
<EditorIndex Value="-1"/>
<TopLine Value="104"/>
<CursorPos X="3" Y="133"/>
<UsageCount Value="10"/>
</Unit51>
</Units>
<General>
<ActiveWindowIndexAtStart Value="-1"/>
</General>
<JumpHistory HistoryIndex="-1"/>
<RunParams>
<FormatVersion Value="2"/>
<Modes Count="0" ActiveMode="default"/>
</RunParams>
</ProjectSession>
</CONFIG>

View File

@ -1,7 +1,7 @@
object Form1: TForm1
Left = 298
Height = 574
Top = 142
Top = 218
Width = 878
Caption = 'Initializing browser. Please wait...'
ClientHeight = 574
@ -10,7 +10,7 @@ object Form1: TForm1
OnCreate = FormCreate
OnShow = FormShow
Position = poScreenCenter
LCLVersion = '1.8.4.0'
LCLVersion = '2.0.0.3'
object AddressPnl: TPanel
Left = 0
Height = 23

View File

@ -10,7 +10,7 @@
// For more information about CEF4Delphi visit :
// https://www.briskbard.com/index.php?lang=en&pageid=cef
//
// Copyright © 2018 Salvador Diaz Fau. All rights reserved.
// Copyright © 2019 Salvador Diaz Fau. All rights reserved.
//
// ************************************************************************
// ************ vvvv Original license and comments below vvvv *************

View File

@ -107,6 +107,9 @@ object Form1: TForm1
Top = 30
Width = 988
Height = 638
OnIMECancelComposition = Panel1IMECancelComposition
OnIMECommitText = Panel1IMECommitText
OnIMESetComposition = Panel1IMESetComposition
Align = alClient
Caption = 'Panel1'
TabOrder = 1
@ -133,6 +136,7 @@ object Form1: TForm1
OnPopupSize = chrmosrPopupSize
OnPaint = chrmosrPaint
OnCursorChange = chrmosrCursorChange
OnIMECompositionRangeChanged = chrmosrIMECompositionRangeChanged
Left = 24
Top = 56
end

View File

@ -10,7 +10,7 @@
// For more information about CEF4Delphi visit :
// https://www.briskbard.com/index.php?lang=en&pageid=cef
//
// Copyright © 2018 Salvador Diaz Fau. All rights reserved.
// Copyright © 2019 Salvador Diaz Fau. All rights reserved.
//
// ************************************************************************
// ************ vvvv Original license and comments below vvvv *************
@ -45,7 +45,7 @@ uses
{$IFDEF DELPHI16_UP}
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes,
System.SyncObjs, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls,
Vcl.ExtCtrls, Vcl.AppEvnts,
Vcl.ExtCtrls, Vcl.AppEvnts, WinApi.imm,
{$ELSE}
Windows, Messages, SysUtils, Variants, Classes, SyncObjs,
Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls, AppEvnts,
@ -78,6 +78,9 @@ type
procedure Panel1MouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
procedure Panel1MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
procedure Panel1MouseLeave(Sender: TObject);
procedure Panel1IMECancelComposition(Sender: TObject);
procedure Panel1IMECommitText(Sender: TObject; const aText: ustring; const replacement_range: PCefRange; relative_cursor_pos: Integer);
procedure Panel1IMESetComposition(Sender: TObject; const aText: ustring; const underlines: TCefCompositionUnderlineDynArray; const replacement_range, selection_range: TCefRange);
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
@ -98,6 +101,7 @@ type
procedure chrmosrBeforePopup(Sender: TObject; const browser: ICefBrowser; const frame: ICefFrame; const targetUrl, targetFrameName: ustring; targetDisposition: TCefWindowOpenDisposition; userGesture: Boolean; const popupFeatures: TCefPopupFeatures; var windowInfo: TCefWindowInfo; var client: ICefClient; var settings: TCefBrowserSettings; var noJavascriptAccess: Boolean; var Result: Boolean);
procedure chrmosrClose(Sender: TObject; const browser: ICefBrowser; out Result: Boolean);
procedure chrmosrBeforeClose(Sender: TObject; const browser: ICefBrowser);
procedure chrmosrIMECompositionRangeChanged(Sender: TObject; const browser: ICefBrowser; const selected_range: PCefRange; character_boundsCount: NativeUInt; const character_bounds: PCefRect);
procedure SnapshotBtnClick(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
@ -113,6 +117,9 @@ type
FCanClose : boolean;
FClosing : boolean;
FResizeCS : TCriticalSection;
FIMECS : TCriticalSection;
FDeviceBounds : TCefRectDynArray;
FSelectedRange : TCefRange;
FLastClickCount : integer;
FLastClickTime : integer;
@ -133,6 +140,7 @@ type
procedure WMExitMenuLoop(var aMessage: TMessage); message WM_EXITMENULOOP;
procedure BrowserCreatedMsg(var aMessage : TMessage); message CEF_AFTERCREATED;
procedure PendingResizeMsg(var aMessage : TMessage); message CEF_PENDINGRESIZE;
procedure RangeChangedMsg(var aMessage : TMessage); message CEF_IMERANGECHANGED;
public
{ Public declarations }
@ -647,7 +655,13 @@ begin
FPendingResize := False;
FCanClose := False;
FClosing := False;
FDeviceBounds := nil;
FSelectedRange.from := 0;
FSelectedRange.to_ := 0;
FResizeCS := TCriticalSection.Create;
FIMECS := TCriticalSection.Create;
InitializeLastClick;
end;
@ -657,6 +671,14 @@ begin
chrmosr.ShutdownDragAndDrop;
if (FPopUpBitmap <> nil) then FreeAndNil(FPopUpBitmap);
if (FResizeCS <> nil) then FreeAndNil(FResizeCS);
if (FIMECS <> nil) then FreeAndNil(FIMECS);
if (FDeviceBounds <> nil) then
begin
Finalize(FDeviceBounds);
FDeviceBounds := nil;
end;
end;
procedure TForm1.FormHide(Sender: TObject);
@ -677,6 +699,11 @@ begin
// opaque white background color
chrmosr.Options.BackgroundColor := CefColorSetARGB($FF, $FF, $FF, $FF);
// The IME handler needs to be created when Panel1 has a valid handle
// and before the browser creation.
// You can skip this if the user doesn't need an "Input Method Editor".
Panel1.CreateIMEHandler;
if chrmosr.CreateBrowser(nil, '') then
chrmosr.InitializeDragAndDrop(Panel1)
else
@ -780,6 +807,16 @@ begin
DoResize;
end;
procedure TForm1.RangeChangedMsg(var aMessage : TMessage);
begin
try
FIMECS.Acquire;
Panel1.ChangeCompositionRange(FSelectedRange, FDeviceBounds);
finally
FIMECS.Release;
end;
end;
procedure TForm1.DoResize;
begin
try
@ -848,4 +885,75 @@ begin
if not(chrmosr.Initialized) then Timer1.Enabled := True;
end;
procedure TForm1.chrmosrIMECompositionRangeChanged( Sender : TObject;
const browser : ICefBrowser;
const selected_range : PCefRange;
character_boundsCount : NativeUInt;
const character_bounds : PCefRect);
var
TempPRect : PCefRect;
i : NativeUInt;
begin
try
FIMECS.Acquire;
// TChromium.OnIMECompositionRangeChanged is triggered in a different thread
// and all functions using a IMM context need to be executed in the same
// thread, in this case the main thread. We need to save the parameters and
// send a message to the form to execute Panel1.ChangeCompositionRange in
// the main thread.
if (FDeviceBounds <> nil) then
begin
Finalize(FDeviceBounds);
FDeviceBounds := nil;
end;
FSelectedRange := selected_range^;
if (character_boundsCount > 0) then
begin
SetLength(FDeviceBounds, character_boundsCount);
i := 0;
TempPRect := character_bounds;
while (i < character_boundsCount) do
begin
FDeviceBounds[i] := TempPRect^;
LogicalToDevice(FDeviceBounds[i], GlobalCEFApp.DeviceScaleFactor);
inc(TempPRect);
inc(i);
end;
end;
PostMessage(Handle, CEF_IMERANGECHANGED, 0, 0);
finally
FIMECS.Release;
end;
end;
procedure TForm1.Panel1IMECancelComposition(Sender: TObject);
begin
chrmosr.IMECancelComposition;
end;
procedure TForm1.Panel1IMECommitText( Sender : TObject;
const aText : ustring;
const replacement_range : PCefRange;
relative_cursor_pos : Integer);
begin
chrmosr.IMECommitText(aText, replacement_range, relative_cursor_pos);
end;
procedure TForm1.Panel1IMESetComposition( Sender : TObject;
const aText : ustring;
const underlines : TCefCompositionUnderlineDynArray;
const replacement_range : TCefRange;
const selection_range : TCefRange);
begin
chrmosr.IMESetComposition(aText, underlines, @replacement_range, @selection_range);
end;
end.

View File

@ -10,7 +10,7 @@
// For more information about CEF4Delphi visit :
// https://www.briskbard.com/index.php?lang=en&pageid=cef
//
// Copyright © 2018 Salvador Diaz Fau. All rights reserved.
// Copyright © 2019 Salvador Diaz Fau. All rights reserved.
//
// ************************************************************************
// ************ vvvv Original license and comments below vvvv *************

View File

@ -10,7 +10,7 @@
// For more information about CEF4Delphi visit :
// https://www.briskbard.com/index.php?lang=en&pageid=cef
//
// Copyright © 2018 Salvador Diaz Fau. All rights reserved.
// Copyright © 2019 Salvador Diaz Fau. All rights reserved.
//
// ************************************************************************
// ************ vvvv Original license and comments below vvvv *************

View File

@ -10,7 +10,7 @@
// For more information about CEF4Delphi visit :
// https://www.briskbard.com/index.php?lang=en&pageid=cef
//
// Copyright © 2018 Salvador Diaz Fau. All rights reserved.
// Copyright © 2019 Salvador Diaz Fau. All rights reserved.
//
// ************************************************************************
// ************ vvvv Original license and comments below vvvv *************

View File

@ -10,7 +10,7 @@
// For more information about CEF4Delphi visit :
// https://www.briskbard.com/index.php?lang=en&pageid=cef
//
// Copyright © 2018 Salvador Diaz Fau. All rights reserved.
// Copyright © 2019 Salvador Diaz Fau. All rights reserved.
//
// ************************************************************************
// ************ vvvv Original license and comments below vvvv *************

View File

@ -10,7 +10,7 @@
// For more information about CEF4Delphi visit :
// https://www.briskbard.com/index.php?lang=en&pageid=cef
//
// Copyright © 2018 Salvador Diaz Fau. All rights reserved.
// Copyright © 2019 Salvador Diaz Fau. All rights reserved.
//
// ************************************************************************
// ************ vvvv Original license and comments below vvvv *************

View File

@ -10,7 +10,7 @@
// For more information about CEF4Delphi visit :
// https://www.briskbard.com/index.php?lang=en&pageid=cef
//
// Copyright © 2018 Salvador Diaz Fau. All rights reserved.
// Copyright © 2019 Salvador Diaz Fau. All rights reserved.
//
// ************************************************************************
// ************ vvvv Original license and comments below vvvv *************

View File

@ -10,7 +10,7 @@
// For more information about CEF4Delphi visit :
// https://www.briskbard.com/index.php?lang=en&pageid=cef
//
// Copyright © 2018 Salvador Díaz Fau. All rights reserved.
// Copyright © 2019 Salvador Díaz Fau. All rights reserved.
//
// ************************************************************************
// ************ vvvv Original license and comments below vvvv *************

View File

@ -166,7 +166,8 @@ contains
uCEFWinControl in '..\source\uCEFWinControl.pas',
uCEFLinkedWindowParent in '..\source\uCEFLinkedWindowParent.pas',
uCEFUrlRequestClientEvents in '..\source\uCEFUrlRequestClientEvents.pas',
uCEFUrlRequestClientComponent in '..\source\uCEFUrlRequestClientComponent.pas';
uCEFUrlRequestClientComponent in '..\source\uCEFUrlRequestClientComponent.pas',
uCEFOSRIMEHandler in '..\source\uCEFOSRIMEHandler.pas';
end.

View File

@ -163,6 +163,7 @@ contains
uCEFWinControl in '..\source\uCEFWinControl.pas',
uCEFLinkedWindowParent in '..\source\uCEFLinkedWindowParent.pas',
uCEFUrlRequestClientEvents in '..\source\uCEFUrlRequestClientEvents.pas',
uCEFUrlRequestClientComponent in '..\source\uCEFUrlRequestClientComponent.pas';
uCEFUrlRequestClientComponent in '..\source\uCEFUrlRequestClientComponent.pas',
uCEFOSRIMEHandler in '..\source\uCEFOSRIMEHandler.pas';
end.

View File

@ -10,7 +10,7 @@
// For more information about CEF4Delphi visit :
// https://www.briskbard.com/index.php?lang=en&pageid=cef
//
// Copyright © 2018 Salvador Diaz Fau. All rights reserved.
// Copyright © 2019 Salvador Diaz Fau. All rights reserved.
//
// ************************************************************************
// ************ vvvv Original license and comments below vvvv *************

View File

@ -170,7 +170,8 @@ contains
uCEFWinControl in '..\source\uCEFWinControl.pas',
uCEFLinkedWindowParent in '..\source\uCEFLinkedWindowParent.pas',
uCEFUrlRequestClientEvents in '..\source\uCEFUrlRequestClientEvents.pas',
uCEFUrlRequestClientComponent in '..\source\uCEFUrlRequestClientComponent.pas';
uCEFUrlRequestClientComponent in '..\source\uCEFUrlRequestClientComponent.pas',
uCEFOSRIMEHandler in '..\source\uCEFOSRIMEHandler.pas';
end.

View File

@ -272,6 +272,7 @@
<DCCReference Include="..\source\uCEFLinkedWindowParent.pas"/>
<DCCReference Include="..\source\uCEFUrlRequestClientEvents.pas"/>
<DCCReference Include="..\source\uCEFUrlRequestClientComponent.pas"/>
<DCCReference Include="..\source\uCEFOSRIMEHandler.pas"/>
<BuildConfiguration Include="Base">
<Key>Base</Key>
</BuildConfiguration>

Binary file not shown.

View File

@ -10,7 +10,7 @@
// For more information about CEF4Delphi visit :
// https://www.briskbard.com/index.php?lang=en&pageid=cef
//
// Copyright © 2018 Salvador Diaz Fau. All rights reserved.
// Copyright © 2019 Salvador Diaz Fau. All rights reserved.
//
// ************************************************************************
// ************ vvvv Original license and comments below vvvv *************

View File

@ -10,7 +10,7 @@
// For more information about CEF4Delphi visit :
// https://www.briskbard.com/index.php?lang=en&pageid=cef
//
// Copyright © 2018 Salvador Diaz Fau. All rights reserved.
// Copyright © 2019 Salvador Diaz Fau. All rights reserved.
//
// ************************************************************************
// ************ vvvv Original license and comments below vvvv *************

View File

@ -21,7 +21,7 @@
</CompilerOptions>
<Description Value="CEF4Delphi"/>
<Version Major="1"/>
<Files Count="137">
<Files Count="138">
<Item1>
<Filename Value="..\source\uCEFAccessibilityHandler.pas"/>
<UnitName Value="uCEFAccessibilityHandler"/>
@ -578,6 +578,10 @@
<HasRegisterProc Value="True"/>
<UnitName Value="uCEFUrlRequestClientComponent"/>
</Item137>
<Item138>
<Filename Value="..\source\uCEFOSRIMEHandler.pas"/>
<UnitName Value="uCEFOSRIMEHandler"/>
</Item138>
</Files>
<RequiredPkgs Count="3">
<Item1>

View File

@ -0,0 +1,200 @@
<?xml version="1.0" encoding="UTF-8"?>
<CONFIG>
<ProjectSession>
<Version Value="10"/>
<Units Count="10">
<Unit0>
<Filename Value="../source/uCEFMiscFunctions.pas"/>
<IsVisibleTab Value="True"/>
<TopLine Value="1397"/>
<CursorPos Y="1412"/>
<UsageCount Value="11"/>
<Bookmarks Count="5">
<Item0 X="31" Y="209" ID="1"/>
<Item1 X="19" Y="1717" ID="2"/>
<Item2 X="45" Y="404" ID="3"/>
<Item3 X="71" Y="736" ID="4"/>
<Item4 X="25" Y="1270" ID="5"/>
</Bookmarks>
<Loaded Value="True"/>
</Unit0>
<Unit1>
<Filename Value="../source/uCEFImage.pas"/>
<EditorIndex Value="-1"/>
<TopLine Value="40"/>
<CursorPos X="41" Y="55"/>
<UsageCount Value="11"/>
</Unit1>
<Unit2>
<Filename Value="../source/uCEFv8Handler.pas"/>
<EditorIndex Value="-1"/>
<TopLine Value="41"/>
<CursorPos Y="56"/>
<UsageCount Value="11"/>
</Unit2>
<Unit3>
<Filename Value="/usr/share/fpcsrc/3.0.4/rtl/objpas/sysutils/datih.inc"/>
<EditorIndex Value="-1"/>
<TopLine Value="106"/>
<CursorPos X="11" Y="120"/>
<UsageCount Value="11"/>
</Unit3>
<Unit4>
<Filename Value="../../fpCEF3/cef3lib.pas"/>
<EditorIndex Value="1"/>
<TopLine Value="315"/>
<CursorPos X="3" Y="325"/>
<UsageCount Value="11"/>
<Loaded Value="True"/>
</Unit4>
<Unit5>
<Filename Value="../source/uCEFApplication.pas"/>
<EditorIndex Value="-1"/>
<TopLine Value="34"/>
<CursorPos X="46" Y="36"/>
<UsageCount Value="10"/>
</Unit5>
<Unit6>
<Filename Value="/usr/share/fpcsrc/3.0.4/rtl/objpas/typinfo.pp"/>
<EditorIndex Value="-1"/>
<UsageCount Value="10"/>
</Unit6>
<Unit7>
<Filename Value="/usr/share/fpcsrc/3.0.4/packages/fcl-db/src/dbase/dbf_wnix.inc"/>
<EditorIndex Value="-1"/>
<TopLine Value="170"/>
<CursorPos X="37" Y="185"/>
<UsageCount Value="10"/>
</Unit7>
<Unit8>
<Filename Value="/usr/share/fpcsrc/3.0.4/rtl/linux/ossysc.inc"/>
<EditorIndex Value="-1"/>
<TopLine Value="595"/>
<CursorPos X="10" Y="609"/>
<UsageCount Value="10"/>
</Unit8>
<Unit9>
<Filename Value="/usr/share/fpcsrc/3.0.4/rtl/bsd/system.pp"/>
<UnitName Value="System"/>
<EditorIndex Value="-1"/>
<TopLine Value="303"/>
<CursorPos X="22" Y="315"/>
<UsageCount Value="10"/>
</Unit9>
</Units>
<JumpHistory Count="28" HistoryIndex="27">
<Position1>
<Filename Value="../source/uCEFMiscFunctions.pas"/>
<Caret Line="56" Column="41" TopLine="42"/>
</Position1>
<Position2>
<Filename Value="../source/uCEFMiscFunctions.pas"/>
<Caret Line="56" Column="37" TopLine="42"/>
</Position2>
<Position3>
<Filename Value="../source/uCEFMiscFunctions.pas"/>
<Caret Line="733" Column="71" TopLine="719"/>
</Position3>
<Position4>
<Filename Value="../source/uCEFMiscFunctions.pas"/>
<Caret Line="55" Column="85" TopLine="41"/>
</Position4>
<Position5>
<Filename Value="../source/uCEFMiscFunctions.pas"/>
<Caret Line="64" Column="54" TopLine="42"/>
</Position5>
<Position6>
<Filename Value="../source/uCEFMiscFunctions.pas"/>
<Caret Line="731" Column="52" TopLine="719"/>
</Position6>
<Position7>
<Filename Value="../source/uCEFMiscFunctions.pas"/>
<Caret Line="55" Column="130" TopLine="42"/>
</Position7>
<Position8>
<Filename Value="../source/uCEFMiscFunctions.pas"/>
<Caret Line="1113" Column="16" TopLine="1099"/>
</Position8>
<Position9>
<Filename Value="../source/uCEFMiscFunctions.pas"/>
<Caret Line="727" Column="7" TopLine="718"/>
</Position9>
<Position10>
<Filename Value="../source/uCEFMiscFunctions.pas"/>
<Caret Line="1109" Column="19" TopLine="1099"/>
</Position10>
<Position11>
<Filename Value="../source/uCEFMiscFunctions.pas"/>
<Caret Line="163" Column="22" TopLine="148"/>
</Position11>
<Position12>
<Filename Value="../source/uCEFMiscFunctions.pas"/>
<Caret Line="1111" Column="19" TopLine="1101"/>
</Position12>
<Position13>
<Filename Value="../source/uCEFMiscFunctions.pas"/>
<Caret Line="419" Column="3" TopLine="401"/>
</Position13>
<Position14>
<Filename Value="../source/uCEFMiscFunctions.pas"/>
<Caret Line="1147" Column="10" TopLine="1128"/>
</Position14>
<Position15>
<Filename Value="../source/uCEFMiscFunctions.pas"/>
<Caret Line="13" Column="82"/>
</Position15>
<Position16>
<Filename Value="../source/uCEFMiscFunctions.pas"/>
<Caret Line="164" Column="16" TopLine="141"/>
</Position16>
<Position17>
<Filename Value="../source/uCEFMiscFunctions.pas"/>
<Caret Line="1256" Column="11" TopLine="1230"/>
</Position17>
<Position18>
<Filename Value="../source/uCEFMiscFunctions.pas"/>
<Caret Line="1269" Column="36" TopLine="1259"/>
</Position18>
<Position19>
<Filename Value="../source/uCEFMiscFunctions.pas"/>
<Caret Line="176" Column="12" TopLine="160"/>
</Position19>
<Position20>
<Filename Value="../source/uCEFMiscFunctions.pas"/>
<Caret Line="1270" Column="25" TopLine="1256"/>
</Position20>
<Position21>
<Filename Value="../source/uCEFMiscFunctions.pas"/>
<Caret Line="1287" Column="45" TopLine="1271"/>
</Position21>
<Position22>
<Filename Value="../source/uCEFMiscFunctions.pas"/>
<Caret Line="180" Column="18" TopLine="165"/>
</Position22>
<Position23>
<Filename Value="../source/uCEFMiscFunctions.pas"/>
<Caret Line="1329" Column="3" TopLine="1323"/>
</Position23>
<Position24>
<Filename Value="../source/uCEFMiscFunctions.pas"/>
<Caret Line="177" Column="22" TopLine="166"/>
</Position24>
<Position25>
<Filename Value="../source/uCEFMiscFunctions.pas"/>
<Caret Line="1321" Column="10" TopLine="1307"/>
</Position25>
<Position26>
<Filename Value="../source/uCEFMiscFunctions.pas"/>
<Caret Line="1411" Column="13" TopLine="1397"/>
</Position26>
<Position27>
<Filename Value="../source/uCEFMiscFunctions.pas"/>
<Caret Line="736" Column="71" TopLine="722"/>
</Position27>
<Position28>
<Filename Value="../source/uCEFMiscFunctions.pas"/>
<Caret Line="1411" Column="13" TopLine="1857"/>
</Position28>
</JumpHistory>
</ProjectSession>
</CONFIG>

View File

@ -46,7 +46,8 @@ uses
uCEFWriteHandler, uCEFX509Certificate, uCEFX509CertPrincipal, uCEFXmlReader,
uCEFZipReader, uCEFChromium, uBufferPanel, uCEFServer, uCEFServerComponent,
uCEFServerEvents, uCEFServerHandler, uCEFWinControl, uCEFLinkedWindowParent,
uCEFUrlRequestClientEvents, uCEFUrlRequestClientComponent, LazarusPackageIntf;
uCEFUrlRequestClientEvents, uCEFUrlRequestClientComponent,
uCEFOSRIMEHandler, LazarusPackageIntf;
implementation

View File

@ -10,7 +10,7 @@
// For more information about CEF4Delphi visit :
// https://www.briskbard.com/index.php?lang=en&pageid=cef
//
// Copyright © 2018 Salvador Diaz Fau. All rights reserved.
// Copyright © 2019 Salvador Diaz Fau. All rights reserved.
//
// ************************************************************************
// ************ vvvv Original license and comments below vvvv *************
@ -47,10 +47,10 @@ interface
uses
{$IFDEF DELPHI16_UP}
{$IFDEF MSWINDOWS}Winapi.Windows, Winapi.Messages, Vcl.ExtCtrls, Vcl.Controls, Vcl.Graphics,{$ENDIF}
{$IFDEF MSWINDOWS}Winapi.Windows, Winapi.Messages, Vcl.ExtCtrls, Vcl.Controls, Vcl.Graphics, WinApi.Imm,{$ENDIF}
System.Classes, System.SyncObjs, System.SysUtils,
{$ELSE}
{$IFDEF MSWINDOWS}Windows,{$ENDIF} Classes, Forms, Controls, Graphics,
{$IFDEF MSWINDOWS}Windows, imm, {$ENDIF} Classes, Forms, Controls, Graphics,
{$IFDEF FPC}
LCLProc, LCLType, LCLIntf, LResources, LMessages, InterfaceBase,
{$ELSE}
@ -58,15 +58,24 @@ uses
{$ENDIF}
ExtCtrls, SyncObjs, SysUtils,
{$ENDIF}
uCEFConstants;
{$IFDEF MSWINDOWS}uCEFOSRIMEHandler,{$ENDIF} uCEFConstants, uCEFTypes;
type
TOnIMECommitTextEvent = procedure(Sender: TObject; const aText : ustring; const replacement_range : PCefRange; relative_cursor_pos : integer) of object;
TOnIMESetCompositionEvent = procedure(Sender: TObject; const aText : ustring; const underlines : TCefCompositionUnderlineDynArray; const replacement_range, selection_range : TCefRange) of object;
{$IFNDEF FPC}{$IFDEF DELPHI16_UP}[ComponentPlatformsAttribute(pidWin32 or pidWin64)]{$ENDIF}{$ENDIF}
TBufferPanel = class(TCustomPanel)
protected
FMutex : THandle;
FBuffer : TBitmap;
FScanlineSize : integer;
FMutex : THandle;
FBuffer : TBitmap;
FScanlineSize : integer;
{$IFDEF MSWINDOWS}
FIMEHandler : TCEFOSRIMEHandler;
FOnIMECancelComposition : TNotifyEvent;
FOnIMECommitText : TOnIMECommitTextEvent;
FOnIMESetComposition : TOnIMESetCompositionEvent;
{$ENDIF}
procedure CreateSyncObj;
@ -81,8 +90,14 @@ type
function SaveBufferToFile(const aFilename : string) : boolean;
procedure Paint; override;
{$IFDEF MSWINDOWS}
procedure WndProc(var aMessage: TMessage); override;
procedure WMEraseBkgnd(var aMessage : TWMEraseBkgnd); message WM_ERASEBKGND;
procedure WMIMEStartComp(var aMessage: TMessage);
procedure WMIMEEndComp(var aMessage: TMessage);
procedure WMIMESetContext(var aMessage: TMessage);
procedure WMIMEComposition(var aMessage: TMessage);
{$ENDIF}
public
constructor Create(AOwner: TComponent); override;
@ -95,6 +110,8 @@ type
procedure BufferDraw(x, y : integer; const aBitmap : TBitmap);
function UpdateBufferDimensions(aWidth, aHeight : integer) : boolean;
function BufferIsResized(aUseMutex : boolean = True) : boolean;
procedure CreateIMEHandler;
procedure ChangeCompositionRange(const selection_range : TCefRange; const character_bounds : TCefRectDynArray);
property Buffer : TBitmap read FBuffer;
property ScanlineSize : integer read FScanlineSize;
@ -105,6 +122,12 @@ type
property DockManager;
published
{$IFDEF MSWINDOWS}
property OnIMECancelComposition : TNotifyEvent read FOnIMECancelComposition write FOnIMECancelComposition;
property OnIMECommitText : TOnIMECommitTextEvent read FOnIMECommitText write FOnIMECommitText;
property OnIMESetComposition : TOnIMESetCompositionEvent read FOnIMESetComposition write FOnIMESetComposition;
{$ENDIF}
property Align;
property Alignment;
property Anchors;
@ -210,6 +233,13 @@ begin
FMutex := 0;
FBuffer := nil;
{$IFDEF MSWINDOWS}
FIMEHandler := nil;
FOnIMECancelComposition := nil;
FOnIMECommitText := nil;
FOnIMESetComposition := nil;
{$ENDIF}
end;
destructor TBufferPanel.Destroy;
@ -217,6 +247,10 @@ begin
DestroyBuffer;
DestroySyncObj;
{$IFDEF MSWINDOWS}
if (FIMEHandler <> nil) then FreeAndNil(FIMEHandler);
{$ENDIF}
inherited Destroy;
end;
@ -225,20 +259,48 @@ begin
inherited AfterConstruction;
CreateSyncObj;
{$IFDEF MSWINDOWS}
{$IFNDEF FPC}
ImeMode := imDontCare;
ImeName := '';
{$ENDIF}
{$ENDIF}
end;
procedure TBufferPanel.CreateIMEHandler;
begin
{$IFDEF MSWINDOWS}
if (FIMEHandler = nil) and HandleAllocated then
FIMEHandler := TCEFOSRIMEHandler.Create(Handle);
{$ENDIF}
end;
procedure TBufferPanel.ChangeCompositionRange(const selection_range : TCefRange;
const character_bounds : TCefRectDynArray);
begin
{$IFDEF MSWINDOWS}
if (FIMEHandler <> nil) then
FIMEHandler.ChangeCompositionRange(selection_range, character_bounds);
{$ENDIF}
end;
procedure TBufferPanel.CreateSyncObj;
begin
{$IFDEF MSWINDOWS}
FMutex := CreateMutex(nil, False, nil);
{$ENDIF}
end;
procedure TBufferPanel.DestroySyncObj;
begin
{$IFDEF MSWINDOWS}
if (FMutex <> 0) then
begin
CloseHandle(FMutex);
FMutex := 0;
end;
{$ENDIF}
end;
procedure TBufferPanel.DestroyBuffer;
@ -279,17 +341,23 @@ end;
function TBufferPanel.InvalidatePanel : boolean;
begin
{$IFDEF MSWINDOWS}
Result := HandleAllocated and PostMessage(Handle, CM_INVALIDATE, 0, 0);
{$ENDIF}
end;
function TBufferPanel.BeginBufferDraw : boolean;
begin
{$IFDEF MSWINDOWS}
Result := (FMutex <> 0) and (WaitForSingleObject(FMutex, 5000) = WAIT_OBJECT_0);
{$ENDIF}
end;
procedure TBufferPanel.EndBufferDraw;
begin
{$IFDEF MSWINDOWS}
if (FMutex <> 0) then ReleaseMutex(FMutex);
{$ENDIF}
end;
function TBufferPanel.CopyBuffer : boolean;
@ -327,11 +395,130 @@ begin
end;
end;
{$IFDEF MSWINDOWS}
procedure TBufferPanel.WndProc(var aMessage: TMessage);
begin
case aMessage.Msg of
WM_IME_STARTCOMPOSITION : WMIMEStartComp(aMessage);
WM_IME_COMPOSITION : WMIMEComposition(aMessage);
WM_IME_ENDCOMPOSITION :
begin
WMIMEEndComp(aMessage);
inherited WndProc(aMessage);
end;
WM_IME_SETCONTEXT :
begin
aMessage.LParam := aMessage.LParam and not(ISC_SHOWUICOMPOSITIONWINDOW);
inherited WndProc(aMessage);
WMIMESetContext(aMessage);
end;
else inherited WndProc(aMessage);
end;
end;
procedure TBufferPanel.WMEraseBkgnd(var aMessage : TWMEraseBkgnd);
begin
aMessage.Result := 1;
end;
procedure TBufferPanel.WMIMEStartComp(var aMessage: TMessage);
begin
if (FIMEHandler <> nil) then
begin
{$IFNDEF FPC}
FInImeComposition := False;
{$ENDIF}
FIMEHandler.CreateImeWindow;
FIMEHandler.MoveImeWindow;
FIMEHandler.ResetComposition;
end;
end;
procedure TBufferPanel.WMIMEEndComp(var aMessage: TMessage);
begin
if assigned(FOnIMECancelComposition) then FOnIMECancelComposition(self);
if (FIMEHandler <> nil) then
begin
FIMEHandler.ResetComposition;
FIMEHandler.DestroyImeWindow;
end;
end;
procedure TBufferPanel.WMIMESetContext(var aMessage: TMessage);
begin
if (FIMEHandler <> nil) then
begin
FIMEHandler.CreateImeWindow;
FIMEHandler.MoveImeWindow;
end;
end;
procedure TBufferPanel.WMIMEComposition(var aMessage: TMessage);
var
TempText : ustring;
TempRange : TCefRange;
TempCompStart : integer;
TempUnderlines : TCefCompositionUnderlineDynArray;
TempSelection : TCefRange;
begin
TempText := '';
TempCompStart := 0;
TempUnderlines := nil;
try
if (FIMEHandler <> nil) then
begin
if FIMEHandler.GetResult(aMessage.LParam, TempText) then
begin
if assigned(FOnIMECommitText) then
begin
TempRange.from := high(Integer);
TempRange.to_ := high(Integer);
FOnIMECommitText(self, TempText, @TempRange, 0);
end;
FIMEHandler.ResetComposition;
end;
if FIMEHandler.GetComposition(aMessage.LParam, TempText, TempUnderlines, TempCompStart) then
begin
if assigned(FOnIMESetComposition) then
begin
TempRange.from := high(Integer);
TempRange.to_ := high(Integer);
TempSelection.from := TempCompStart;
TempSelection.to_ := TempCompStart + length(TempText);
FOnIMESetComposition(self, TempText, TempUnderlines, TempRange, TempSelection);
end;
FIMEHandler.UpdateCaretPosition(pred(TempCompStart));
end
else
begin
if assigned(FOnIMECancelComposition) then FOnIMECancelComposition(self);
FIMEHandler.ResetComposition;
FIMEHandler.DestroyImeWindow;
end;
end;
finally
if (TempUnderlines <> nil) then
begin
Finalize(TempUnderlines);
TempUnderlines := nil;
end;
end;
end;
{$ENDIF}
function TBufferPanel.GetBufferBits : pointer;
begin
if (FBuffer <> nil) then

View File

@ -10,7 +10,7 @@
// For more information about CEF4Delphi visit :
// https://www.briskbard.com/index.php?lang=en&pageid=cef
//
// Copyright © 2018 Salvador Diaz Fau. All rights reserved.
// Copyright © 2019 Salvador Diaz Fau. All rights reserved.
//
// ************************************************************************
// ************ vvvv Original license and comments below vvvv *************

View File

@ -10,7 +10,7 @@
// For more information about CEF4Delphi visit :
// https://www.briskbard.com/index.php?lang=en&pageid=cef
//
// Copyright © 2018 Salvador Diaz Fau. All rights reserved.
// Copyright © 2019 Salvador Diaz Fau. All rights reserved.
//
// ************************************************************************
// ************ vvvv Original license and comments below vvvv *************

View File

@ -10,7 +10,7 @@
// For more information about CEF4Delphi visit :
// https://www.briskbard.com/index.php?lang=en&pageid=cef
//
// Copyright © 2018 Salvador Diaz Fau. All rights reserved.
// Copyright © 2019 Salvador Diaz Fau. All rights reserved.
//
// ************************************************************************
// ************ vvvv Original license and comments below vvvv *************
@ -67,8 +67,13 @@ const
CEF_CHROMEELF_VERSION_RELEASE = 3578;
CEF_CHROMEELF_VERSION_BUILD = 80;
{$IFDEF MSWINDOWS}
LIBCEF_DLL = 'libcef.dll';
CHROMEELF_DLL = 'chrome_elf.dll';
{$ELSE}
LIBCEF_DLL = 'libcef.so';
CHROMEELF_DLL = '';
{$ENDIF}
type
TCefApplication = class
@ -271,7 +276,9 @@ type
function SingleExeProcessing : boolean;
function CheckCEFLibrary : boolean;
procedure RegisterWidevineCDM;
{$IFDEF MSWINDOWS}
function FindFlashDLL(var aFileName : string) : boolean;
{$ENDIF}
procedure ShowErrorMessageDlg(const aError : string); virtual;
function ParseProcessType : TCefProcessType;
@ -601,7 +608,9 @@ begin
FChromeVersionInfo.Release := CEF_CHROMEELF_VERSION_RELEASE;
FChromeVersionInfo.Build := CEF_CHROMEELF_VERSION_BUILD;
{$IFDEF MSWINDOWS}
if (FProcessType = ptBrowser) then GetDLLVersion(ChromeElfPath, FChromeVersionInfo);
{$ENDIF}
IsMultiThread := True;
@ -808,7 +817,9 @@ begin
else
FFrameworkDirPath := '';
{$IFDEF MSWINDOWS}
if (FProcessType = ptBrowser) then GetDLLVersion(ChromeElfPath, FChromeVersionInfo);
{$ENDIF}
end;
procedure TCefApplication.SetResourcesDirPath(const aValue : ustring);
@ -858,6 +869,9 @@ var
TempMachine : integer;
TempVersionInfo : TFileVersionInfo;
begin
{$IFNDEF MSWINDOWS}
Result := True;
{$ELSE}
Result := False;
if not(FCheckCEFFiles) or (FProcessType <> ptBrowser) then
@ -894,7 +908,6 @@ begin
CEF_SUPPORTED_VERSION_RELEASE,
CEF_SUPPORTED_VERSION_BUILD) then
begin
{$IFDEF MSWINDOWS}
if GetDLLHeaderMachine(LibCefPath, TempMachine) then
case TempMachine of
CEF_IMAGE_FILE_MACHINE_I386 :
@ -937,9 +950,6 @@ begin
end
else
Result := True;
{$ELSE}
Result := True;
{$ENDIF}
end
else
begin
@ -959,6 +969,7 @@ begin
if FSetCurrentDir then chdir(TempOldDir);
end;
{$ENDIF}
end;
function TCefApplication.StartMainProcess : boolean;
@ -1173,7 +1184,11 @@ begin
TempNewDir := TempOldDir + '(' + inttostr(i) + ')';
until not(DirectoryExists(TempNewDir));
{$IFDEF MSWINDOWS}
if MoveFileW(PWideChar(TempOldDir + chr(0)), PWideChar(TempNewDir + chr(0))) then
{$ELSE}
if RenameFile(TempOldDir, TempNewDir) then
{$ENDIF}
begin
TempThread := TCEFDirectoryDeleterThread.Create(TempNewDir);
{$IFDEF DELPHI14_UP}
@ -1216,6 +1231,7 @@ begin
end;
end;
{$IFDEF MSWINDOWS}
function TCefApplication.FindFlashDLL(var aFileName : string) : boolean;
var
TempSearchRec : TSearchRec;
@ -1249,6 +1265,7 @@ begin
if CustomExceptionHandler('TCefApplication.FindFlashDLL', e) then raise;
end;
end;
{$ENDIF}
procedure TCefApplication.ShowErrorMessageDlg(const aError : string);
begin
@ -1443,6 +1460,7 @@ var
begin
if (commandLine <> nil) and (FProcessType = ptBrowser) and (processType = '') then
begin
{$IFDEF MSWINDOWS}
if FindFlashDLL(TempFileName) and
GetDLLVersion(TempFileName, TempVersionInfo) then
begin
@ -1453,6 +1471,7 @@ begin
commandLine.AppendSwitchWithValue('--ppapi-flash-version', FileVersionInfoToString(TempVersionInfo));
end
else
{$ENDIF}
if FFlashEnabled then
begin
if FEnableGPU then commandLine.AppendSwitch('--enable-gpu-plugin');
@ -1779,9 +1798,14 @@ begin
if (FLibHandle = 0) then
begin
FStatus := asErrorLoadingLibrary;
FStatus := asErrorLoadingLibrary;
{$IFDEF MSWINDOWS}
TempString := 'Error loading libcef.dll' + CRLF + CRLF +
'Error code : 0x' + inttohex(GetLastError, 8);
{$ELSE}
TempString := 'Error loading the CEF binaries';
{$ENDIF}
ShowErrorMessageDlg(TempString);
exit;

View File

@ -10,7 +10,7 @@
// For more information about CEF4Delphi visit :
// https://www.briskbard.com/index.php?lang=en&pageid=cef
//
// Copyright © 2018 Salvador Diaz Fau. All rights reserved.
// Copyright © 2019 Salvador Diaz Fau. All rights reserved.
//
// ************************************************************************
// ************ vvvv Original license and comments below vvvv *************

View File

@ -10,7 +10,7 @@
// For more information about CEF4Delphi visit :
// https://www.briskbard.com/index.php?lang=en&pageid=cef
//
// Copyright © 2018 Salvador Diaz Fau. All rights reserved.
// Copyright © 2019 Salvador Diaz Fau. All rights reserved.
//
// ************************************************************************
// ************ vvvv Original license and comments below vvvv *************

View File

@ -10,7 +10,7 @@
// For more information about CEF4Delphi visit :
// https://www.briskbard.com/index.php?lang=en&pageid=cef
//
// Copyright © 2018 Salvador Diaz Fau. All rights reserved.
// Copyright © 2019 Salvador Diaz Fau. All rights reserved.
//
// ************************************************************************
// ************ vvvv Original license and comments below vvvv *************

View File

@ -10,7 +10,7 @@
// For more information about CEF4Delphi visit :
// https://www.briskbard.com/index.php?lang=en&pageid=cef
//
// Copyright © 2018 Salvador Diaz Fau. All rights reserved.
// Copyright © 2019 Salvador Diaz Fau. All rights reserved.
//
// ************************************************************************
// ************ vvvv Original license and comments below vvvv *************

View File

@ -10,7 +10,7 @@
// For more information about CEF4Delphi visit :
// https://www.briskbard.com/index.php?lang=en&pageid=cef
//
// Copyright © 2018 Salvador Diaz Fau. All rights reserved.
// Copyright © 2019 Salvador Diaz Fau. All rights reserved.
//
// ************************************************************************
// ************ vvvv Original license and comments below vvvv *************

View File

@ -10,7 +10,7 @@
// For more information about CEF4Delphi visit :
// https://www.briskbard.com/index.php?lang=en&pageid=cef
//
// Copyright © 2018 Salvador Diaz Fau. All rights reserved.
// Copyright © 2019 Salvador Diaz Fau. All rights reserved.
//
// ************************************************************************
// ************ vvvv Original license and comments below vvvv *************
@ -131,7 +131,7 @@ type
procedure NotifyMoveOrResizeStarted;
function GetWindowlessFrameRate : Integer;
procedure SetWindowlessFrameRate(frameRate: Integer);
procedure IMESetComposition(const text: ustring; underlinesCount : NativeUInt; const underlines : PCefCompositionUnderline; const replacement_range, selection_range : PCefRange);
procedure IMESetComposition(const text: ustring; const underlines : TCefCompositionUnderlineDynArray; const replacement_range, selection_range : PCefRange);
procedure IMECommitText(const text: ustring; const replacement_range : PCefRange; relative_cursor_pos : integer);
procedure IMEFinishComposingText(keep_selection : boolean);
procedure IMECancelComposition;
@ -577,20 +577,50 @@ begin
end;
procedure TCefBrowserHostRef.IMESetComposition(const text : ustring;
underlinesCount : NativeUInt;
const underlines : PCefCompositionUnderline;
const underlines : TCefCompositionUnderlineDynArray;
const replacement_range : PCefRange;
const selection_range : PCefRange);
var
TempString : TCefString;
TempString : TCefString;
TempCount, i : NativeUInt;
TempUnderlines : PCefCompositionUnderline;
TempItem : PCefCompositionUnderline;
begin
TempString := CefString(text);
PCefBrowserHost(FData)^.ime_set_composition(PCefBrowserHost(FData),
@TempString,
underlinesCount,
underlines,
replacement_range,
selection_range);
TempCount := 0;
TempUnderlines := nil;
try
TempString := CefString(text);
if (underlines <> nil) then
begin
TempCount := length(underlines);
GetMem(TempUnderlines, TempCount * SizeOf(TCefCompositionUnderline));
TempItem := TempUnderlines;
i := 0;
while (i < TempCount) do
begin
TempItem^.range := underlines[i].range;
TempItem^.color := underlines[i].color;
TempItem^.background_color := underlines[i].background_color;
TempItem^.thick := underlines[i].thick;
inc(i);
inc(TempItem);
end;
end;
PCefBrowserHost(FData)^.ime_set_composition(PCefBrowserHost(FData),
@TempString,
TempCount,
TempUnderlines,
replacement_range,
selection_range);
finally
if (TempUnderlines <> nil) then FreeMem(TempUnderlines);
end;
end;
procedure TCefBrowserHostRef.IMECommitText(const text: ustring; const replacement_range : PCefRange; relative_cursor_pos : integer);

View File

@ -10,7 +10,7 @@
// For more information about CEF4Delphi visit :
// https://www.briskbard.com/index.php?lang=en&pageid=cef
//
// Copyright © 2018 Salvador Diaz Fau. All rights reserved.
// Copyright © 2019 Salvador Diaz Fau. All rights reserved.
//
// ************************************************************************
// ************ vvvv Original license and comments below vvvv *************

View File

@ -10,7 +10,7 @@
// For more information about CEF4Delphi visit :
// https://www.briskbard.com/index.php?lang=en&pageid=cef
//
// Copyright © 2018 Salvador Diaz Fau. All rights reserved.
// Copyright © 2019 Salvador Diaz Fau. All rights reserved.
//
// ************************************************************************
// ************ vvvv Original license and comments below vvvv *************

View File

@ -10,7 +10,7 @@
// For more information about CEF4Delphi visit :
// https://www.briskbard.com/index.php?lang=en&pageid=cef
//
// Copyright © 2018 Salvador Diaz Fau. All rights reserved.
// Copyright © 2019 Salvador Diaz Fau. All rights reserved.
//
// ************************************************************************
// ************ vvvv Original license and comments below vvvv *************
@ -252,7 +252,7 @@ type
function GetZoomLevel : double;
function GetZoomPct : double;
function GetIsPopUp : boolean;
function GetWindowHandle : THandle;
function GetWindowHandle : TCefWindowHandle;
function GetWindowlessFrameRate : integer;
function GetFrameIsFocused : boolean;
function GetInitialized : boolean;
@ -331,8 +331,9 @@ type
function MustCreateJsDialogHandler : boolean; virtual;
function MustCreateDragHandler : boolean; virtual;
function MustCreateFindHandler : boolean; virtual;
{$IFDEF MSWINDOWS}
procedure PrefsAvailableMsg(var aMessage : TMessage);
{$ENDIF}
function GetParentForm : TCustomForm;
procedure ApplyZoomStep;
procedure DelayedDragging;
@ -342,10 +343,12 @@ type
procedure InitializeWindowInfo(aParentHandle : HWND; aParentRect : TRect; const aWindowName : ustring); virtual;
procedure InitializeDevToolsWindowInfo(aDevTools : TWinControl); virtual;
procedure FreeAndNilStub(var aStub : pointer);
procedure CreateStub(const aMethod : TWndMethod; var aStub : Pointer);
{$IFDEF MSWINDOWS}
procedure WndProc(var aMessage: TMessage);
{$IFNDEF FPC}
{$ENDIF}
{$IFNDEF FPC}
procedure CreateStub(const aMethod : TWndMethod; var aStub : Pointer);
procedure FreeAndNilStub(var aStub : pointer);
procedure BrowserCompWndProc(var aMessage: TMessage);
procedure WidgetCompWndProc(var aMessage: TMessage);
procedure RenderCompWndProc(var aMessage: TMessage);
@ -564,6 +567,11 @@ type
procedure DragSourceEndedAt(x, y: Integer; op: TCefDragOperation);
procedure DragSourceSystemDragEnded;
procedure IMESetComposition(const text: ustring; const underlines : TCefCompositionUnderlineDynArray; const replacement_range, selection_range : PCefRange);
procedure IMECommitText(const text: ustring; const replacement_range : PCefRange; relative_cursor_pos : integer);
procedure IMEFinishComposingText(keep_selection : boolean);
procedure IMECancelComposition;
property DefaultUrl : ustring read FDefaultUrl write FDefaultUrl;
property Options : TChromiumOptions read FOptions write FOptions;
@ -585,7 +593,7 @@ type
property CanGoBack : boolean read GetCanGoBack;
property CanGoForward : boolean read GetCanGoForward;
property IsPopUp : boolean read GetIsPopUp;
property WindowHandle : THandle read GetWindowHandle;
property WindowHandle : TCefWindowHandle read GetWindowHandle;
property BrowserHandle : THandle read FBrowserCompHWND;
property WidgetHandle : THandle read FWidgetCompHWND;
property RenderHandle : THandle read FRenderCompHWND;
@ -793,7 +801,7 @@ begin
FBrowserCompStub := nil;
FWidgetCompStub := nil;
FRenderCompStub := nil;
{$ENDIF}
{$ENDIF}
FBrowserCompHWND := 0;
FWidgetCompHWND := 0;
FRenderCompHWND := 0;
@ -893,6 +901,7 @@ begin
FBrowserId := 0;
end;
{$IFNDEF FPC}
procedure TChromium.CreateStub(const aMethod : TWndMethod; var aStub : Pointer);
begin
if (aStub = nil) then aStub := MakeObjectInstance(aMethod);
@ -906,6 +915,7 @@ begin
aStub := nil;
end;
end;
{$ENDIF}
procedure TChromium.DestroyClientHandler;
begin
@ -933,8 +943,10 @@ begin
if not(csDesigning in ComponentState) then
begin
{$IFDEF FPC}
{$IFDEF MSWINDOWS}
TempWndMethod := @WndProc;
FCompHandle := AllocateHWnd(TempWndMethod);
{$ENDIF}
{$ELSE}
FCompHandle := AllocateHWnd(WndProc);
{$ENDIF}
@ -1182,23 +1194,39 @@ procedure TChromium.InitializeWindowInfo( aParentHandle : HWND;
aParentRect : TRect;
const aWindowName : ustring);
begin
{$IFDEF MSWINDOWS}
if FIsOSR then
WindowInfoAsWindowless(FWindowInfo, FCompHandle, aWindowName)
else
WindowInfoAsChild(FWindowInfo, aParentHandle, aParentRect, aWindowName);
{$ELSE}
if FIsOSR then
WindowInfoAsWindowless(FWindowInfo, FCompHandle)
else
WindowInfoAsChild(FWindowInfo, aParentHandle, aParentRect);
{$ENDIF}
end;
procedure TChromium.InitializeDevToolsWindowInfo(aDevTools : TWinControl);
begin
{$IFDEF MSWINDOWS}
if (aDevTools <> nil) then
WindowInfoAsChild(FDevWindowInfo, aDevTools.Handle, aDevTools.ClientRect, aDevTools.Name)
else
WindowInfoAsPopUp(FDevWindowInfo, WindowHandle, DEVTOOLS_WINDOWNAME);
WindowInfoAsPopUp(FDevWindowInfo, WindowHandle, DEVTOOLS_WINDOWNAME);
{$ELSE}
if (aDevTools <> nil) then
WindowInfoAsChild(FDevWindowInfo, aDevTools.Handle, aDevTools.ClientRect)
else
WindowInfoAsPopUp(FDevWindowInfo, WindowHandle);
{$ENDIF}
end;
procedure TChromium.InitializeDragAndDrop(const aDropTargetCtrl : TWinControl);
{$IFNDEF FPC}
var
TempDropTarget : IDropTarget;
{$ENDIF}
begin
{$IFNDEF FPC}
if FIsOSR and
@ -1238,15 +1266,18 @@ end;
procedure TChromium.ShutdownDragAndDrop;
begin
{$IFDEF MSWINDOWS}
if FDragAndDropInitialized and (FDropTargetCtrl <> nil) then
begin
RevokeDragDrop(FDropTargetCtrl.Handle);
FDragAndDropInitialized := False;
end;
{$ENDIF}
end;
procedure TChromium.ToMouseEvent(grfKeyState : Longint; pt : TPoint; var aMouseEvent : TCefMouseEvent);
begin
{$IFDEF MSWINDOWS}
if (FDropTargetCtrl <> nil) then
begin
pt := FDropTargetCtrl.ScreenToClient(pt);
@ -1254,6 +1285,7 @@ begin
aMouseEvent.y := pt.y;
aMouseEvent.modifiers := GetCefMouseModifiers(grfKeyState);
end;
{$ENDIF}
end;
procedure TChromium.DragDropManager_OnDragEnter(Sender: TObject; const aDragData : ICefDragData; grfKeyState: Longint; pt: TPoint; var dwEffect: Longint);
@ -1263,6 +1295,7 @@ var
begin
if (GlobalCEFApp <> nil) then
begin
{$IFDEF MSWINDOWS}
ToMouseEvent(grfKeyState, pt, TempMouseEvent);
DropEffectToDragOperation(dwEffect, TempAllowedOps);
DeviceToLogical(TempMouseEvent, GlobalCEFApp.DeviceScaleFactor);
@ -1271,6 +1304,7 @@ begin
DragTargetDragOver(@TempMouseEvent, TempAllowedOps);
DragOperationToDropEffect(FDragOperations, dwEffect);
{$ENDIF}
end;
end;
@ -1281,6 +1315,7 @@ var
begin
if (GlobalCEFApp <> nil) then
begin
{$IFDEF MSWINDOWS}
ToMouseEvent(grfKeyState, pt, TempMouseEvent);
DropEffectToDragOperation(dwEffect, TempAllowedOps);
DeviceToLogical(TempMouseEvent, GlobalCEFApp.DeviceScaleFactor);
@ -1288,6 +1323,7 @@ begin
DragTargetDragOver(@TempMouseEvent, TempAllowedOps);
DragOperationToDropEffect(FDragOperations, dwEffect);
{$ENDIF}
end;
end;
@ -1303,6 +1339,7 @@ var
begin
if (GlobalCEFApp <> nil) then
begin
{$IFDEF MSWINDOWS}
ToMouseEvent(grfKeyState, pt, TempMouseEvent);
DropEffectToDragOperation(dwEffect, TempAllowedOps);
DeviceToLogical(TempMouseEvent, GlobalCEFApp.DeviceScaleFactor);
@ -1311,6 +1348,7 @@ begin
DragTargetDrop(@TempMouseEvent);
DragOperationToDropEffect(FDragOperations, dwEffect);
{$ENDIF}
end;
end;
@ -1688,7 +1726,7 @@ begin
Result := (FBrowser <> nil);
end;
function TChromium.GetWindowHandle : THandle;
function TChromium.GetWindowHandle : TCefWindowHandle;
begin
if Initialized then
Result := FBrowser.Host.WindowHandle
@ -2258,6 +2296,7 @@ var
begin
Result := False;
{$IFDEF MSWINDOWS}
if not(FIsOSR) then
begin
TempHWND := GetWindowHandle;
@ -2282,6 +2321,7 @@ begin
ReleaseDC(TempHWND, TempDC);
end;
end;
{$ENDIF}
end;
function TChromium.IsSameBrowser(const aBrowser : ICefBrowser) : boolean;
@ -2813,6 +2853,7 @@ var
TempPrefs : TStringList;
begin
Result := False;
{$IFDEF MSWINDOWS}
TempPrefs := nil;
try
@ -2833,6 +2874,7 @@ begin
SendCompMessage(CEF_PREFERENCES_SAVED, Ord(Result));
if (TempPrefs <> nil) then FreeAndNil(TempPrefs);
end;
{$ENDIF}
end;
procedure TChromium.doResolvedHostAvailable(result: TCefErrorCode; const resolvedIps: TStrings);
@ -2912,10 +2954,12 @@ begin
Result := assigned(FOnFindResult);
end;
{$IFDEF MSWINDOWS}
procedure TChromium.PrefsAvailableMsg(var aMessage : TMessage);
begin
if assigned(FOnPrefsAvailable) then FOnPrefsAvailable(self, (aMessage.WParam <> 0));
end;
{$ENDIF}
function TChromium.SendCompMessage(aMsg : cardinal; wParam : cardinal; lParam : integer) : boolean;
begin
@ -3035,14 +3079,17 @@ begin
{$IFDEF DELPHI16_UP}
WinApi.Windows.SetParent(GetWindow(aDevTools.Handle, GW_CHILD), 0);
{$ELSE}
{$IFDEF MSWINDOWS}
Windows.SetParent(GetWindow(aDevTools.Handle, GW_CHILD), 0);
{$ENDIF}
{$ENDIF}
end;
if (FBrowser <> nil) then FBrowser.Host.CloseDevTools;
end;
end;
{$IFDEF MSWINDOWS}
procedure TChromium.WndProc(var aMessage: TMessage);
begin
case aMessage.Msg of
@ -3052,6 +3099,7 @@ begin
else aMessage.Result := DefWindowProc(FCompHandle, aMessage.Msg, aMessage.WParam, aMessage.LParam);
end;
end;
{$ENDIF}
{$IFNDEF FPC}
procedure TChromium.BrowserCompWndProc(var aMessage: TMessage);
@ -3642,13 +3690,13 @@ begin
(browser.Identifier = FBrowserId) then
begin
FBrowserCompHWND := browser.Host.WindowHandle;
{$IFDEF MSWINDOWS}
if (FBrowserCompHWND <> 0) then
FWidgetCompHWND := FindWindowEx(FBrowserCompHWND, 0, 'Chrome_WidgetWin_0', '');
if (FWidgetCompHWND <> 0) then
FRenderCompHWND := FindWindowEx(FWidgetCompHWND, 0, 'Chrome_RenderWidgetHostHWND', 'Chrome Legacy Window');
{$ENDIF}
{$IFNDEF FPC}
if assigned(FOnBrowserCompMsg) and (FBrowserCompHWND <> 0) and (FOldBrowserCompWndPrc = nil) then
begin
@ -4043,6 +4091,33 @@ begin
if Initialized then FBrowser.Host.DragSourceSystemDragEnded;
end;
procedure TChromium.IMESetComposition(const text : ustring;
const underlines : TCefCompositionUnderlineDynArray;
const replacement_range : PCefRange;
const selection_range : PCefRange);
begin
if Initialized then
FBrowser.Host.IMESetComposition(text, underlines, replacement_range, selection_range);
end;
procedure TChromium.IMECommitText(const text : ustring;
const replacement_range : PCefRange;
relative_cursor_pos : integer);
begin
if Initialized then
FBrowser.Host.IMECommitText(text, replacement_range, relative_cursor_pos);
end;
procedure TChromium.IMEFinishComposingText(keep_selection : boolean);
begin
if Initialized then FBrowser.Host.IMEFinishComposingText(keep_selection);
end;
procedure TChromium.IMECancelComposition;
begin
if Initialized then FBrowser.Host.IMECancelComposition;
end;
{$IFDEF FPC}
procedure Register;
begin

View File

@ -10,7 +10,7 @@
// For more information about CEF4Delphi visit :
// https://www.briskbard.com/index.php?lang=en&pageid=cef
//
// Copyright © 2018 Salvador Diaz Fau. All rights reserved.
// Copyright © 2019 Salvador Diaz Fau. All rights reserved.
//
// ************************************************************************
// ************ vvvv Original license and comments below vvvv *************

View File

@ -10,7 +10,7 @@
// For more information about CEF4Delphi visit :
// https://www.briskbard.com/index.php?lang=en&pageid=cef
//
// Copyright © 2018 Salvador Diaz Fau. All rights reserved.
// Copyright © 2019 Salvador Diaz Fau. All rights reserved.
//
// ************************************************************************
// ************ vvvv Original license and comments below vvvv *************

View File

@ -10,7 +10,7 @@
// For more information about CEF4Delphi visit :
// https://www.briskbard.com/index.php?lang=en&pageid=cef
//
// Copyright © 2018 Salvador Diaz Fau. All rights reserved.
// Copyright © 2019 Salvador Diaz Fau. All rights reserved.
//
// ************************************************************************
// ************ vvvv Original license and comments below vvvv *************

View File

@ -10,7 +10,7 @@
// For more information about CEF4Delphi visit :
// https://www.briskbard.com/index.php?lang=en&pageid=cef
//
// Copyright © 2018 Salvador Diaz Fau. All rights reserved.
// Copyright © 2019 Salvador Diaz Fau. All rights reserved.
//
// ************************************************************************
// ************ vvvv Original license and comments below vvvv *************
@ -72,6 +72,7 @@ type
FUseSetFocus : boolean;
function GetBrowserInitialized : boolean;
{$IFDEF MSWINDOWS}
function GetChildWindowHandle : THandle; override;
procedure WndProc(var aMessage: TMessage); override;
@ -79,7 +80,7 @@ type
procedure OnCloseMsg(var aMessage : TMessage); message CEF_DOONCLOSE;
procedure OnBeforeCloseMsg(var aMessage : TMessage); message CEF_DOONBEFORECLOSE;
procedure OnAfterCreatedMsg(var aMessage : TMessage); message CEF_AFTERCREATED;
{$ENDIF}
procedure WebBrowser_OnClose(Sender: TObject; const browser: ICefBrowser; out Result: Boolean);
procedure WebBrowser_OnBeforeClose(Sender: TObject; const browser: ICefBrowser);
procedure WebBrowser_OnAfterCreated(Sender: TObject; const browser: ICefBrowser);
@ -139,6 +140,7 @@ begin
end;
end;
{$IFDEF MSWINDOWS}
function TChromiumWindow.GetChildWindowHandle : THandle;
begin
Result := 0;
@ -180,6 +182,7 @@ begin
else inherited WndProc(aMessage);
end;
end;
{$ENDIF}
function TChromiumWindow.GetBrowserInitialized : boolean;
begin
@ -188,25 +191,31 @@ end;
procedure TChromiumWindow.WebBrowser_OnClose(Sender: TObject; const browser: ICefBrowser; out Result: Boolean);
begin
Result := False;
{$IFDEF MSWINDOWS}
if assigned(FOnClose) then
begin
PostMessage(Handle, CEF_DOONCLOSE, 0, 0);
Result := True;
end
else
Result := False;
end;
{$ENDIF}
end;
procedure TChromiumWindow.WebBrowser_OnBeforeClose(Sender: TObject; const browser: ICefBrowser);
begin
{$IFDEF MSWINDOWS}
if assigned(FOnBeforeClose) then PostMessage(Handle, CEF_DOONBEFORECLOSE, 0, 0);
{$ENDIF}
end;
procedure TChromiumWindow.WebBrowser_OnAfterCreated(Sender: TObject; const browser: ICefBrowser);
begin
{$IFDEF MSWINDOWS}
PostMessage(Handle, CEF_AFTERCREATED, 0, 0);
{$ENDIF}
end;
{$IFDEF MSWINDOWS}
procedure TChromiumWindow.OnCloseMsg(var aMessage : TMessage);
begin
if assigned(FOnClose) then FOnClose(self);
@ -222,6 +231,7 @@ begin
UpdateSize;
if assigned(FOnAfterCreated) then FOnAfterCreated(self);
end;
{$ENDIF}
function TChromiumWindow.CreateBrowser : boolean;
begin

View File

@ -10,7 +10,7 @@
// For more information about CEF4Delphi visit :
// https://www.briskbard.com/index.php?lang=en&pageid=cef
//
// Copyright © 2018 Salvador Diaz Fau. All rights reserved.
// Copyright © 2019 Salvador Diaz Fau. All rights reserved.
//
// ************************************************************************
// ************ vvvv Original license and comments below vvvv *************

View File

@ -10,7 +10,7 @@
// For more information about CEF4Delphi visit :
// https://www.briskbard.com/index.php?lang=en&pageid=cef
//
// Copyright © 2018 Salvador Diaz Fau. All rights reserved.
// Copyright © 2019 Salvador Diaz Fau. All rights reserved.
//
// ************************************************************************
// ************ vvvv Original license and comments below vvvv *************

Some files were not shown because too many files have changed in this diff Show More