1
0
mirror of https://github.com/salvadordf/CEF4Delphi.git synced 2025-06-12 22:07:39 +02:00

FPC compatibility with all missing MSWINDOWS features (Drag&Drop, OnBrowserCompMsg/OnWidgetCompMsg/OnRenderCompMsg) that VCL/FMX already had

Some Linux support (compiles and can load the libcef.so but still crashes when calling CreateBrowser)
This commit is contained in:
Andreas Hausladen
2019-11-10 18:23:39 +01:00
parent d897a1d815
commit eb0d04f1b5
25 changed files with 525 additions and 345 deletions

View File

@ -53,7 +53,7 @@ uses
{$IFDEF MSWINDOWS}WinApi.Windows, WinApi.ActiveX,{$ENDIF} System.IOUtils, System.Classes, System.SysUtils, System.UITypes, System.Math,
{$ELSE}
{$IFDEF MSWINDOWS}Windows, ActiveX,{$ENDIF} {$IFDEF DELPHI14_UP}IOUtils,{$ENDIF} Classes, SysUtils, Math,
{$IFDEF FPC}LCLType,{$IFNDEF MSWINDOWS}InterfaceBase,{$ENDIF}{$ENDIF}
{$IFDEF FPC}LCLType,{$IFNDEF MSWINDOWS}InterfaceBase, Forms,{$ENDIF}{$ENDIF}
{$ENDIF}
uCEFTypes, uCEFInterfaces, uCEFLibFunctions, uCEFResourceHandler,
uCEFRegisterCDMCallback, uCEFConstants;
@ -136,6 +136,8 @@ function PathIsURLAnsi(pszPath: LPCSTR): BOOL; stdcall; external SHLWAPIDLL name
function PathIsURLUnicode(pszPath: LPCWSTR): BOOL; stdcall; external SHLWAPIDLL name 'PathIsURLW';
{$IFNDEF DELPHI12_UP}
const
GWLP_WNDPROC = GWL_WNDPROC;
{$IFDEF WIN64}
function SetWindowLongPtr(hWnd: HWND; nIndex: Integer; dwNewLong: int64): int64; stdcall; external user32 name 'SetWindowLongPtrW';
{$ELSE}
@ -879,9 +881,10 @@ function SplitLongString(aSrcString : string) : string;
const
MAXLINELENGTH = 50;
begin
Result := '';
while (length(aSrcString) > 0) do
begin
if (length(Result) > 0) then
if (Result <> '') then
Result := Result + CRLF + copy(aSrcString, 1, MAXLINELENGTH)
else
Result := Result + copy(aSrcString, 1, MAXLINELENGTH);
@ -972,7 +975,7 @@ begin
if (length(aLocalesDirPath) > 0) then
TempDir := IncludeTrailingPathDelimiter(aLocalesDirPath)
else
TempDir := 'locales\';
TempDir := 'locales' + PathDelim;
TempList := TStringList.Create;
@ -1071,11 +1074,19 @@ begin
TempList := TStringList.Create;
TempList.Add(TempDir + CHROMEELF_DLL);
TempList.Add(TempDir + LIBCEF_DLL);
{$IFDEF MSWINDOWS}
TempList.Add(TempDir + 'd3dcompiler_47.dll');
TempList.Add(TempDir + 'libEGL.dll');
TempList.Add(TempDir + 'libGLESv2.dll');
TempList.Add(TempDir + 'swiftshader\libEGL.dll');
TempList.Add(TempDir + 'swiftshader\libGLESv2.dll');
{$ENDIF}
{$IFDEF LINUX}
TempList.Add(TempDir + 'libEGL.so');
TempList.Add(TempDir + 'libGLESv2.so');
TempList.Add(TempDir + 'swiftshader/libEGL.so');
TempList.Add(TempDir + 'swiftshader/libGLESv2.so');
{$ENDIF}
TempList.Add(TempDir + 'icudtl.dat');
if TempExists then
@ -1491,7 +1502,7 @@ begin
end;
function CustomAbsolutePath(const aPath : string; aMustExist : boolean) : string;
var
var
TempNewPath, TempOldPath : string;
begin
if (length(aPath) > 0) then
@ -1505,8 +1516,8 @@ begin
TempNewPath := TempOldPath;
if aMustExist and not(DirectoryExists(TempNewPath)) then
Result := ''
else
Result := ''
else
Result := TempNewPath;
end
else
@ -1515,7 +1526,12 @@ end;
function GetModulePath : string;
begin
{$IFDEF MSWINDOWS}
Result := IncludeTrailingPathDelimiter(ExtractFileDir(GetModuleName(HINSTANCE{$IFDEF FPC}(){$ENDIF})));
{$ELSE}
// DLL filename not supported
Result := IncludeTrailingPathDelimiter(ExtractFileDir(ParamStr(0)));
{$ENDIF MSWINDOWS}
end;
function CefParseUrl(const url: ustring; var parts: TUrlParts): Boolean;
@ -2080,8 +2096,8 @@ begin
try
if (aFileList <> nil) and
(length(aSrcDirectory) > 0) and
(length(aDstDirectory) > 0) and
DirectoryExists(aSrcDirectory) and
(length(aDstDirectory) > 0) and
DirectoryExists(aSrcDirectory) and
(DirectoryExists(aDstDirectory) or CreateDir(aDstDirectory)) then
begin
i := 0;
@ -2089,9 +2105,9 @@ begin
while (i < aFileList.Count) do
begin
TempSrcPath := IncludeTrailingPathDelimiter(aSrcDirectory) + aFileList[i];
TempDstPath := IncludeTrailingPathDelimiter(aDstDirectory) + aFileList[i];
TempSrcPath := IncludeTrailingPathDelimiter(aSrcDirectory) + aFileList[i];
TempDstPath := IncludeTrailingPathDelimiter(aDstDirectory) + aFileList[i];
if FileExists(TempSrcPath) and RenameFile(TempSrcPath, TempDstPath) then inc(TempCount);
inc(i);