Skip to content

Commit

Permalink
update to CEF 3.1750
Browse files Browse the repository at this point in the history
various fixes & cleanup
  • Loading branch information
dliw committed Aug 23, 2014
1 parent b7e6039 commit 5392eb4
Show file tree
Hide file tree
Showing 13 changed files with 251 additions and 202 deletions.
17 changes: 9 additions & 8 deletions Component/cef3lcl.pas
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,9 @@ TCustomChromium = class(TWinControl, IChromiumEvents)


FOptions: TChromiumOptions;
FUserStyleSheetLocation: ustring;
FDefaultEncoding: ustring;
FFontOptions: TChromiumFontOptions;
FBackgroundColor: TCefColor;

procedure GetSettings(var settings: TCefBrowserSettings);
procedure CreateBrowser;
Expand Down Expand Up @@ -323,8 +323,8 @@ TCustomChromium = class(TWinControl, IChromiumEvents)
property DefaultUrl: ustring read FDefaultUrl write FDefaultUrl;
property Options: TChromiumOptions read FOptions write FOptions;
property FontOptions: TChromiumFontOptions read FFontOptions;
property BackgroundColor: TCefColor read FBackgroundColor write FBackgroundColor;
property DefaultEncoding: ustring read FDefaultEncoding write FDefaultEncoding;
property UserStyleSheetLocation: ustring read FUserStyleSheetLocation write FUserStyleSheetLocation;
property BrowserId: Integer read FBrowserId;
property Browser: ICefBrowser read FBrowser;
property Handler: ICefClient read FHandler;
Expand Down Expand Up @@ -410,7 +410,7 @@ TChromium = class(TCustomChromium)
property Options;
property FontOptions;
property DefaultEncoding;
property UserStyleSheetLocation;
property BackgroundColor;
end;

procedure Register;
Expand Down Expand Up @@ -450,9 +450,9 @@ procedure Register;
RegisterComponents('Chromium', [TChromium]);
end;

{$IFNDEF CEF_MULTI_THREADED_MESSAGE_LOOP}
class procedure TLCLClientHandler.OnTimer(Sender : TObject);
begin
{$IFNDEF CEF_MULTI_THREADED_MESSAGE_LOOP}
If Looping then Exit;
If CefInstances > 0 then
begin
Expand All @@ -463,8 +463,8 @@ class procedure TLCLClientHandler.OnTimer(Sender : TObject);
Looping := False;
end;
end;
{$ENDIF}
end;
{$ENDIF}

constructor TLCLClientHandler.Create(const crm : IChromiumEvents);
begin
Expand Down Expand Up @@ -518,9 +518,11 @@ procedure TLCLClientHandler.Cleanup;

procedure TLCLClientHandler.StartTimer;
begin
{$IFNDEF CEF_MULTI_THREADED_MESSAGE_LOOP}
If not Assigned(Timer) then Exit;

Timer.Enabled := true;
{$ENDIF}
end;

{ TCustomChromium }
Expand All @@ -540,7 +542,6 @@ procedure TCustomChromium.GetSettings(var settings : TCefBrowserSettings);
settings.minimum_logical_font_size := FFontOptions.MinimumLogicalFontSize;
settings.remote_fonts := FFontOptions.RemoteFonts;
settings.default_encoding := CefString(FDefaultEncoding);
settings.user_style_sheet_location := CefString(FUserStyleSheetLocation);

settings.javascript := FOptions.Javascript;
settings.javascript_open_windows := FOptions.JavascriptOpenWindows;
Expand All @@ -557,12 +558,12 @@ procedure TCustomChromium.GetSettings(var settings : TCefBrowserSettings);
settings.image_shrink_standalone_to_fit := FOptions.ImageShrinkStandaloneToFit;
settings.text_area_resize := FOptions.TextAreaResize;
settings.tab_to_links := FOptions.TabToLinks;
settings.author_and_user_styles := FOptions.AuthorAndUserStyles;
settings.local_storage := FOptions.LocalStorage;
settings.databases := FOptions.Databases;
settings.application_cache := FOptions.ApplicationCache;
settings.webgl := FOptions.Webgl;
settings.accelerated_compositing := FOptions.AcceleratedCompositing;
settings.background_color := FBackgroundColor;
end;

procedure TCustomChromium.CreateWnd;
Expand Down Expand Up @@ -711,8 +712,8 @@ constructor TCustomChromium.Create(TheOwner : TComponent);

FOptions := TChromiumOptions.Create;
FFontOptions := TChromiumFontOptions.Create;
FBackgroundColor := CefColorSetARGB(255, 255, 255, 255);

FUserStyleSheetLocation := '';
FDefaultEncoding := '';
FBrowserId := 0;
FBrowser := nil;
Expand Down
20 changes: 12 additions & 8 deletions Component/cef3osr.pas
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

Uses
Classes, SysUtils, fpTimer,
{$IFDEF DEBUG}LCLProc,{$ENDIF}
cef3types, cef3lib, cef3intf, cef3gui;

Type
Expand Down Expand Up @@ -115,9 +116,9 @@ TCustomChromiumOSR = class(TComponent, IChromiumEvents)
FOnRenderProcessTerminated: TOnRenderProcessTerminated;

FOptions: TChromiumOptions;
FUserStyleSheetLocation: ustring;
FDefaultEncoding: ustring;
FFontOptions: TChromiumFontOptions;
FBackgroundColor: TCefColor;

procedure GetSettings(var settings: TCefBrowserSettings);
procedure CreateBrowser;
Expand Down Expand Up @@ -325,7 +326,7 @@ TCustomChromiumOSR = class(TComponent, IChromiumEvents)
property Options: TChromiumOptions read FOptions write FOptions;
property FontOptions: TChromiumFontOptions read FFontOptions;
property DefaultEncoding: ustring read FDefaultEncoding write FDefaultEncoding;
property UserStyleSheetLocation: ustring read FUserStyleSheetLocation write FUserStyleSheetLocation;
property BackgroundColor: TCefColor read FBackgroundColor write FBackgroundColor;
property BrowserId: Integer read FBrowserId;
property Browser: ICefBrowser read FBrowser;
public
Expand Down Expand Up @@ -411,7 +412,7 @@ TChromiumOSR = class(TCustomChromiumOSR)
property Options;
property FontOptions;
property DefaultEncoding;
property UserStyleSheetLocation;
property BackgroundColor;
end;

procedure Register;
Expand Down Expand Up @@ -446,6 +447,7 @@ procedure Register;

class procedure TOSRClientHandler.OnTimer(Sender : TObject);
begin
{$IFNDEF CEF_MULTI_THREADED_MESSAGE_LOOP}
If Looping then Exit;
If CefInstances > 0 then
begin
Expand All @@ -456,6 +458,7 @@ class procedure TOSRClientHandler.OnTimer(Sender : TObject);
Looping := False;
end;
end;
{$ENDIF}
end;

constructor TOSRClientHandler.Create(const crm : IChromiumEvents);
Expand Down Expand Up @@ -510,9 +513,11 @@ procedure TOSRClientHandler.Cleanup;

procedure TOSRClientHandler.StartTimer;
begin
{$IFNDEF CEF_MULTI_THREADED_MESSAGE_LOOP}
If not Assigned(Timer) then Exit;

Timer.Enabled := True;
{$ENDIF}
end;

{ TCustomChromiumOSR }
Expand All @@ -532,7 +537,6 @@ procedure TCustomChromiumOSR.GetSettings(var settings : TCefBrowserSettings);
settings.minimum_logical_font_size := FFontOptions.MinimumLogicalFontSize;
settings.remote_fonts := FFontOptions.RemoteFonts;
settings.default_encoding := CefString(FDefaultEncoding);
settings.user_style_sheet_location := CefString(FUserStyleSheetLocation);

settings.javascript := FOptions.Javascript;
settings.javascript_open_windows := FOptions.JavascriptOpenWindows;
Expand All @@ -549,12 +553,12 @@ procedure TCustomChromiumOSR.GetSettings(var settings : TCefBrowserSettings);
settings.image_shrink_standalone_to_fit := FOptions.ImageShrinkStandaloneToFit;
settings.text_area_resize := FOptions.TextAreaResize;
settings.tab_to_links := FOptions.TabToLinks;
settings.author_and_user_styles := FOptions.AuthorAndUserStyles;
settings.local_storage := FOptions.LocalStorage;
settings.databases := FOptions.Databases;
settings.application_cache := FOptions.ApplicationCache;
settings.webgl := FOptions.Webgl;
settings.accelerated_compositing := FOptions.AcceleratedCompositing;
settings.background_color := FBackgroundColor;
end;

procedure TCustomChromiumOSR.CreateBrowser;
Expand All @@ -565,8 +569,8 @@ procedure TCustomChromiumOSR.CreateBrowser;
If not (csDesigning in ComponentState) then
begin
FillChar(info, SizeOf(info), 0);
info.window_rendering_disabled := True;
// info.transparent_painting := ???;
info.window_rendering_disabled := Ord(True);
info.transparent_painting := Ord(True);

FillChar(settings, SizeOf(TCefBrowserSettings), 0);
settings.size := SizeOf(TCefBrowserSettings);
Expand Down Expand Up @@ -973,7 +977,7 @@ constructor TCustomChromiumOSR.Create(AOwner : TComponent);
FOptions := TChromiumOptions.Create;
FFontOptions := TChromiumFontOptions.Create;

FUserStyleSheetLocation := '';
FBackgroundColor := CefColorSetARGB(255, 255, 255, 255);
FDefaultEncoding := '';
FBrowserId := 0;
FBrowser := nil;
Expand Down
4 changes: 2 additions & 2 deletions Examples/GT2Minimal/minimal.lpr
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ procedure bclicked(widget : PGtkWidget; data : gpointer); cdecl;

CefLoadLibrary;

ExitCode := cef_execute_process(@MainArgs, nil);
ExitCode := cef_execute_process(@MainArgs, nil, nil);
If ExitCode >= 0 then Halt(ExitCode);

Settings.multi_threaded_message_loop := False;
Expand All @@ -73,7 +73,7 @@ procedure bclicked(widget : PGtkWidget; data : gpointer); cdecl;
Settings.uncaught_exception_stack_size := 20;
Settings.release_dcheck_enabled := TRUE;

cef_initialize(@MainArgs, @Settings, nil);
cef_initialize(@MainArgs, @Settings, nil, nil);

gtk_init(nil, nil);

Expand Down
5 changes: 3 additions & 2 deletions Examples/JavaScript/handler.pas
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,10 @@ function TMyHandler.Execute(const name : ustring; const obj : ICefv8Value;
const arguments : TCefv8ValueArray; var retval : ICefv8Value;
var exception : ustring) : Boolean;
begin
Result := False;
// return a value
retval := TCefv8ValueRef.NewString('TMyHandler');

Writeln('Execute');
Result := True;
end;

{ TCustomRenderProcessHandler }
Expand Down
2 changes: 1 addition & 1 deletion Examples/JavaScript/main.pas
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ procedure TMainform.Button2Click(Sender : TObject);
// JavaScript executes TMyHandler.Execute
procedure TMainform.Button3Click(Sender : TObject);
begin
Chromium.Browser.MainFrame.ExecuteJavaScript('cef.test.test_object().GetMessage();', 'about:blank', 0);
Chromium.Browser.MainFrame.ExecuteJavaScript('alert(cef.test.test_param);', 'about:blank', 0);
end;

procedure TMainform.ChromiumTitleChange(Sender : TObject; const Browser : ICefBrowser; const title : ustring);
Expand Down
4 changes: 2 additions & 2 deletions Examples/SubProcess/subprocess.lpr
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
{$IFDEF WINDOWS}
Args.instance := HINSTANCE();

Halt(cef_execute_process(@Args, nil));
Halt(cef_execute_process(@Args, nil, nil));
{$ELSE}
Args.argc := argc;
Args.argv := argv;

Halt(cef_execute_process(@Args, nil));
Halt(cef_execute_process(@Args, nil, nil));
{$ENDIF}
end.

Loading

0 comments on commit 5392eb4

Please sign in to comment.