From 659092bb3797dbdefe8ad9406060bfce8a6ef3fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Salvador=20D=C3=ADaz=20Fau?= Date: Mon, 2 Oct 2017 17:56:56 +0200 Subject: [PATCH] Removed unused interface and more pointer checks --- source/CEF4Delphi.dproj | 5 ++ source/CEF4Delphi.dsk | 126 +++++++++++++++++----------------- source/CEF4Delphi.res | Bin 708 -> 708 bytes source/CEF4Delphi.stat | 6 +- source/uCEFApplication.pas | 34 ++++----- source/uCEFBaseRefCounted.pas | 25 ++++++- source/uCEFInterfaces.pas | 4 +- source/uCEFMiscFunctions.pas | 9 ++- 8 files changed, 117 insertions(+), 92 deletions(-) diff --git a/source/CEF4Delphi.dproj b/source/CEF4Delphi.dproj index 0d1df392..1cc3fc47 100644 --- a/source/CEF4Delphi.dproj +++ b/source/CEF4Delphi.dproj @@ -63,6 +63,11 @@ rtl;vcl;$(DCC_UsePackage) + Winapi;System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;$(DCC_Namespace) + Debug + true + CompanyName=;FileDescription=$(MSBuildProjectName);FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProgramID=com.embarcadero.$(MSBuildProjectName);ProductName=$(MSBuildProjectName);ProductVersion=1.0.0.0;Comments= + 1033 DEBUG;$(DCC_Define) diff --git a/source/CEF4Delphi.dsk b/source/CEF4Delphi.dsk index 034091b7..2a591a59 100644 --- a/source/CEF4Delphi.dsk +++ b/source/CEF4Delphi.dsk @@ -1,14 +1,14 @@ [Closed Files] -File_0=TSourceModule,'C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\source\uCEFRequestContext.pas',0,1,44,76,80,0,0,, -File_1=TSourceModule,'C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\source\uCEFChromium.pas',0,1,2291,98,2320,0,0,,{1 -File_2=TSourceModule,'C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\source\uCEFResolveCallback.pas',0,1,123,63,135,0,0,, -File_3=TSourceModule,'C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\source\uCEFApplication.pas',0,1,38,39,60,0,0,, -File_4=TSourceModule,'C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\source\uCEFChromiumEvents.pas',0,1,30,31,62,0,0,, -File_5=TSourceModule,'C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\source\uCEFInterfaces.pas',0,1,1470,22,1499,0,0,, -File_6=TSourceModule,'C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\source\uCEFTask.pas',0,1,277,90,302,0,0,, -File_7=TSourceModule,'C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\source\uCEFBrowser.pas',0,1,43,86,50,0,0,, -File_8=TSourceModule,'C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\source\uCEFMiscFunctions.pas',0,1,428,62,454,0,0,, -File_9=TSourceModule,'C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\source\uCEFTypes.pas',0,1,1450,1,1480,0,0,, +File_0=TSourceModule,'C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\source\uCEFApplication.pas',0,1,40,62,65,0,0,,{1 +File_1=TSourceModule,'C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\source\uCEFInterfaces.pas',0,1,1783,3,117,0,0,, +File_2=TSourceModule,'C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\source\uCEFBaseRefCounted.pas',0,1,63,23,85,0,0,, +File_3=TSourceModule,'C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\source\uCEFMiscFunctions.pas',0,1,101,63,120,0,0,, +File_4=TSourceModule,'C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\source\uCEFWriteHandler.pas',0,1,289,29,312,0,0,, +File_5=TSourceModule,'C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\source\uCEFRequestContext.pas',0,1,44,76,80,0,0,, +File_6=TSourceModule,'C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\source\uCEFChromium.pas',0,1,2291,98,2320,0,0,,{1 +File_7=TSourceModule,'C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\source\uCEFResolveCallback.pas',0,1,123,63,135,0,0,, +File_8=TSourceModule,'C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\source\uCEFChromiumEvents.pas',0,1,30,31,62,0,0,, +File_9=TSourceModule,'C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\source\uCEFTask.pas',0,1,277,90,302,0,0,, [Modules] Module0=default.htm @@ -38,18 +38,18 @@ ClientHeight=9417 DockedToMainForm=1 BorlandEditorCodeExplorer=BorlandEditorCodeExplorer@EditWindow0 TopPanelSize=0 -LeftPanelSize=0 +LeftPanelSize=1898 +LeftPanelClients=PropertyInspector,DockSite3 +LeftPanelData=00000800010100000000A219000000000000016A0700000000000001000000005D0E000009000000446F636B53697465330100000000972300001100000050726F7065727479496E73706563746F72FFFFFFFF RightPanelSize=2000 -RightPanelClients=DockSite2 -RightPanelData=00000800010100000000A21900000000000001D00700000000000001000000009723000009000000446F636B5369746532FFFFFFFF +RightPanelClients=DockSite2,DockSite4 +RightPanelData=00000800010100000000A21900000000000001D00700000000000001000000004312000009000000446F636B536974653201000000009723000009000000446F636B5369746534FFFFFFFF BottomPanelSize=0 BottomPanelClients=DockSite1,MessageView BottomPanelData=0000080001020200000009000000446F636B53697465310F0000004D65737361676556696577466F726D1234000000000000022506000000000000FFFFFFFF BottomMiddlePanelSize=0 BottomMiddlePanelClients=DockSite0,GraphDrawingModel BottomMiddelPanelData=0000080001020200000009000000446F636B536974653010000000477261706844726177696E67566965779D1D00000000000002F306000000000000FFFFFFFF -TabDockLeftClients=PropertyInspector=0,DockSite3=1 -TabDockRightClients=DockSite4=0 [View0] CustomEditViewType=TWelcomePageView @@ -120,11 +120,11 @@ State=0 Left=0 Top=0 Width=2000 -Height=8935 +Height=4305 MaxLeft=-1 MaxTop=-1 ClientWidth=2000 -ClientHeight=8935 +ClientHeight=4305 TBDockHeight=5897 LRDockWidth=2352 Dockable=1 @@ -157,12 +157,12 @@ Docked=1 State=0 Left=0 Top=0 -Width=1875 -Height=6794 +Width=2000 +Height=4383 MaxLeft=-1 MaxTop=-1 -ClientWidth=1875 -ClientHeight=6794 +ClientWidth=2000 +ClientHeight=4383 TBDockHeight=7152 LRDockWidth=2000 Dockable=1 @@ -212,8 +212,8 @@ Create=1 Visible=0 Docked=1 State=0 -Left=-8 -Top=-30 +Left=-148 +Top=-132 Width=1844 Height=3139 MaxLeft=-1 @@ -266,22 +266,22 @@ StayOnTop=0 [PropertyInspector] PercentageSizes=1 Create=1 -Visible=0 +Visible=1 Docked=1 State=0 -Left=78 -Top=386 +Left=0 +Top=357 Width=1898 -Height=7220 +Height=5415 MaxLeft=-1 MaxTop=-1 -ClientWidth=1773 -ClientHeight=6794 +ClientWidth=1898 +ClientHeight=5415 TBDockHeight=7220 LRDockWidth=1898 Dockable=1 StayOnTop=0 -SplitPos=119 +SplitPos=111 [frmDesignPreview] PercentageSizes=1 @@ -292,11 +292,11 @@ State=0 Left=0 Top=0 Width=2000 -Height=6883 +Height=6939 MaxLeft=-1 MaxTop=-1 ClientWidth=2000 -ClientHeight=6883 +ClientHeight=6939 TBDockHeight=5964 LRDockWidth=2508 Dockable=1 @@ -308,8 +308,8 @@ Create=1 Visible=0 Docked=1 State=0 -Left=-946 -Top=5 +Left=-898 +Top=-132 Width=2844 Height=6200 MaxLeft=-1 @@ -327,8 +327,8 @@ Create=1 Visible=0 Docked=1 State=0 -Left=-8 -Top=287 +Left=-1026 +Top=-132 Width=273 Height=359 MaxLeft=-1 @@ -451,11 +451,11 @@ State=0 Left=0 Top=0 Width=2336 -Height=964 +Height=1200 MaxLeft=-1 MaxTop=-1 ClientWidth=2336 -ClientHeight=964 +ClientHeight=1200 TBDockHeight=2321 LRDockWidth=2820 Dockable=1 @@ -516,11 +516,11 @@ State=0 Left=0 Top=0 Width=2000 -Height=6883 +Height=6939 MaxLeft=-1 MaxTop=-1 ClientWidth=2000 -ClientHeight=6883 +ClientHeight=6939 TBDockHeight=4888 LRDockWidth=7148 Dockable=1 @@ -532,8 +532,8 @@ Create=1 Visible=0 Docked=1 State=0 -Left=249 -Top=709 +Left=0 +Top=0 Width=2859 Height=3206 MaxLeft=-1 @@ -579,12 +579,12 @@ Docked=1 State=0 Left=0 Top=0 -Width=1773 -Height=6794 +Width=1898 +Height=3554 MaxLeft=-1 MaxTop=-1 -ClientWidth=1773 -ClientHeight=6794 +ClientWidth=1898 +ClientHeight=3554 TBDockHeight=3677 LRDockWidth=1898 Dockable=1 @@ -599,11 +599,11 @@ State=0 Left=0 Top=0 Width=2000 -Height=6883 +Height=6939 MaxLeft=-1 MaxTop=-1 ClientWidth=2000 -ClientHeight=6883 +ClientHeight=6939 TBDockHeight=4888 LRDockWidth=5305 Dockable=1 @@ -664,7 +664,7 @@ Visible=0 Docked=1 State=0 Left=0 -Top=18 +Top=0 Width=3820 Height=1424 MaxLeft=-1 @@ -690,11 +690,11 @@ State=0 Left=0 Top=18 Width=2000 -Height=9215 +Height=4585 MaxLeft=-1 MaxTop=-1 ClientWidth=2000 -ClientHeight=9215 +ClientHeight=4585 TBDockHeight=7220 LRDockWidth=2000 Dockable=1 @@ -704,21 +704,21 @@ ActiveTabID=ProjectManager TabDockClients=ProjectManager,ModelViewTool,DataExplorerContainer,frmDesignPreview,TFileExplorerForm [DockSite3] -HostDockSite=LeftDockTabSet +HostDockSite=DockLeftPanel DockSiteType=1 PercentageSizes=1 Create=1 -Visible=0 +Visible=1 Docked=1 State=0 Left=0 -Top=0 +Top=18 Width=1898 -Height=7220 +Height=3554 MaxLeft=-1 MaxTop=-1 -ClientWidth=1773 -ClientHeight=6794 +ClientWidth=1898 +ClientHeight=3554 TBDockHeight=7220 LRDockWidth=1898 Dockable=1 @@ -728,21 +728,21 @@ ActiveTabID=StructureView TabDockClients=StructureView,ClassBrowserTool [DockSite4] -HostDockSite=RightTabDock +HostDockSite=DockRightPanel DockSiteType=1 PercentageSizes=1 Create=1 -Visible=0 +Visible=1 Docked=1 State=0 Left=0 -Top=0 +Top=449 Width=2000 -Height=7220 +Height=4383 MaxLeft=-1 MaxTop=-1 -ClientWidth=1875 -ClientHeight=6794 +ClientWidth=2000 +ClientHeight=4383 TBDockHeight=7220 LRDockWidth=2000 Dockable=1 diff --git a/source/CEF4Delphi.res b/source/CEF4Delphi.res index 985ad241082301fe8838561e1717b2ff8e363a4e..b9b013c2123fcf20e24680fc5ad3191fc452d216 100644 GIT binary patch delta 12 TcmX@YdW3bu0VWn^1_lNI95e$A delta 12 TcmX@YdW3bu0VWnk1_lNI94rG0 diff --git a/source/CEF4Delphi.stat b/source/CEF4Delphi.stat index 6d3c02c9..ed8a1cc9 100644 --- a/source/CEF4Delphi.stat +++ b/source/CEF4Delphi.stat @@ -1,9 +1,9 @@ [Stats] -EditorSecs=187302 +EditorSecs=188707 DesignerSecs=98 InspectorSecs=326 -CompileSecs=5907605 -OtherSecs=19482 +CompileSecs=6047120 +OtherSecs=19762 StartTime=22/01/2017 10:49:52 RealKeys=0 EffectiveKeys=0 diff --git a/source/uCEFApplication.pas b/source/uCEFApplication.pas index 4d2396f1..80c11a75 100644 --- a/source/uCEFApplication.pas +++ b/source/uCEFApplication.pas @@ -105,8 +105,7 @@ type FExternalMessagePump : boolean; FDeleteCache : boolean; FDeleteCookies : boolean; - FApp : TInternalApp; - FAppIntf : ICefApp; + FInternalApp : TInternalApp; FCustomCommandLines : TStringList; FCustomCommandLineValues : TStringList; FFlashEnabled : boolean; @@ -353,8 +352,7 @@ begin FExternalMessagePump := False; FDeleteCache := False; FDeleteCookies := False; - FApp := nil; - FAppIntf := nil; + FInternalApp := nil; FFlashEnabled := True; FEnableSpellingService := True; FEnableMediaStream := True; @@ -397,8 +395,7 @@ destructor TCefApplication.Destroy; begin ShutDown; - FAppIntf := nil; - FApp := nil; + FInternalApp := nil; if (FCustomCommandLines <> nil) then FreeAndNil(FCustomCommandLines); if (FCustomCommandLineValues <> nil) then FreeAndNil(FCustomCommandLineValues); @@ -425,17 +422,16 @@ begin Result := False; try - if (FApp = nil) then + if (FInternalApp = nil) then begin - FApp := TInternalApp.Create; - FApp.OnBeforeCommandLineProc := App_OnBeforeCommandLineProc; - FApp.OnRegCustomSchemes := App_OnRegCustomSchemes; - FApp.OnGetResourceBundleHandler := App_OnGetResourceBundleHandler; - FApp.OnGetBrowserProcessHandler := App_OnGetBrowserProcessHandler; - FApp.OnGetRenderProcessHandler := App_OnGetRenderProcessHandler; + FInternalApp := TInternalApp.Create; + FInternalApp.OnBeforeCommandLineProc := App_OnBeforeCommandLineProc; + FInternalApp.OnRegCustomSchemes := App_OnRegCustomSchemes; + FInternalApp.OnGetResourceBundleHandler := App_OnGetResourceBundleHandler; + FInternalApp.OnGetBrowserProcessHandler := App_OnGetBrowserProcessHandler; + FInternalApp.OnGetRenderProcessHandler := App_OnGetRenderProcessHandler; - FAppIntf := FApp as ICefApp; - Result := (FAppIntf <> nil); + Result := True; end; except on e : exception do @@ -672,10 +668,10 @@ function TCefApplication.ExecuteProcess : integer; var TempArgs : TCefMainArgs; begin - if (FApp <> nil) then + if (FInternalApp <> nil) then begin TempArgs.instance := HINSTANCE; - Result := cef_execute_process(@TempArgs, FApp.Wrap, FWindowsSandboxInfo); + Result := cef_execute_process(@TempArgs, FInternalApp.Wrap, FWindowsSandboxInfo); end else Result := 0; @@ -724,8 +720,8 @@ begin InitializeSettings(FAppSettings); - Result := (FApp <> nil) and - (cef_initialize(@HInstance, @FAppSettings, FApp.Wrap, FWindowsSandboxInfo) <> 0) and + Result := (FInternalApp <> nil) and + (cef_initialize(@HInstance, @FAppSettings, FInternalApp.Wrap, FWindowsSandboxInfo) <> 0) and InitializeCookies; except on e : exception do diff --git a/source/uCEFBaseRefCounted.pas b/source/uCEFBaseRefCounted.pas index f8a64eb1..c7caa0d8 100644 --- a/source/uCEFBaseRefCounted.pas +++ b/source/uCEFBaseRefCounted.pas @@ -79,18 +79,37 @@ uses uCEFTypes, uCEFMiscFunctions; procedure cef_base_add_ref(self: PCefBaseRefCounted); stdcall; +var + TempObject : TObject; begin - TCefBaseRefCountedOwn(CefGetObject(self))._AddRef; + TempObject := CefGetObject(self); + + if (TempObject <> nil) and (TempObject is TCefBaseRefCountedOwn) then + TCefBaseRefCountedOwn(TempObject)._AddRef; end; function cef_base_release(self: PCefBaseRefCounted): Integer; stdcall; +var + TempObject : TObject; begin - Result := TCefBaseRefCountedOwn(CefGetObject(self))._Release; + TempObject := CefGetObject(self); + + if (TempObject <> nil) and (TempObject is TCefBaseRefCountedOwn) then + Result := TCefBaseRefCountedOwn(TempObject)._Release + else + Result := 0; end; function cef_base_has_one_ref(self: PCefBaseRefCounted): Integer; stdcall; +var + TempObject : TObject; begin - Result := Ord(TCefBaseRefCountedOwn(CefGetObject(self)).FRefCount = 1); + TempObject := CefGetObject(self); + + if (TempObject <> nil) and (TempObject is TCefBaseRefCountedOwn) then + Result := Ord(TCefBaseRefCountedOwn(TempObject).FRefCount = 1) + else + Result := Ord(False); end; procedure cef_base_add_ref_owned(self: PCefBaseRefCounted); stdcall; diff --git a/source/uCEFInterfaces.pas b/source/uCEFInterfaces.pas index c66cb0ed..b9927115 100644 --- a/source/uCEFInterfaces.pas +++ b/source/uCEFInterfaces.pas @@ -1,4 +1,4 @@ -// ************************************************************************ +// ************************************************************************ // ***************************** CEF4Delphi ******************************* // ************************************************************************ // @@ -10,7 +10,7 @@ // For more information about CEF4Delphi visit : // https://www.briskbard.com/index.php?lang=en&pageid=cef // -// Copyright © 2017 Salvador Díaz Fau. All rights reserved. +// Copyright © 2017 Salvador Díaz Fau. All rights reserved. // // ************************************************************************ // ************ vvvv Original license and comments below vvvv ************* diff --git a/source/uCEFMiscFunctions.pas b/source/uCEFMiscFunctions.pas index 5732d07d..17d382b3 100644 --- a/source/uCEFMiscFunctions.pas +++ b/source/uCEFMiscFunctions.pas @@ -271,8 +271,13 @@ end; function CefGetObject(ptr: Pointer): TObject; {$IFDEF SUPPORTS_INLINE} inline; {$ENDIF} begin - Dec(PByte(ptr), SizeOf(Pointer)); - Result := TObject(PPointer(ptr)^); + if (ptr <> nil) then + begin + Dec(PByte(ptr), SizeOf(Pointer)); + Result := TObject(PPointer(ptr)^); + end + else + Result := nil; end; function CefGetData(const i: ICefBaseRefCounted): Pointer; {$IFDEF SUPPORTS_INLINE} inline; {$ENDIF}