CEF4Delphi/source/uCEFDomVisitor.pas

159 lines
3.4 KiB
ObjectPascal
Raw Normal View History

2017-01-27 16:37:51 +01:00
unit uCEFDomVisitor;
{$IFDEF FPC}
{$MODE OBJFPC}{$H+}
{$ENDIF}
2017-02-05 20:56:46 +01:00
{$I cef.inc}
{$IFNDEF TARGET_64BITS}{$ALIGN ON}{$ENDIF}
{$MINENUMSIZE 4}
2017-01-27 16:37:51 +01:00
interface
uses
uCEFBaseRefCounted, uCEFInterfaces, uCEFTypes;
2017-01-27 16:37:51 +01:00
type
TCefDomVisitorOwn = class(TCefBaseRefCountedOwn, ICefDomVisitor)
2017-01-27 16:37:51 +01:00
protected
procedure visit(const document: ICefDomDocument); virtual;
public
constructor Create; virtual;
end;
TCefFastDomVisitor = class(TCefDomVisitorOwn)
protected
FProc : TCefDomVisitorProc;
2017-01-27 16:37:51 +01:00
procedure visit(const document: ICefDomDocument); override;
public
constructor Create(const proc: TCefDomVisitorProc); reintroduce; virtual;
end;
TCefFastDomVisitor2 = class(TCefDomVisitorOwn)
protected
FProc : TCefDomVisitorProc2;
FBrowser : ICefBrowser;
2019-06-16 10:31:13 +02:00
FFrame : ICefFrame;
procedure visit(const document: ICefDomDocument); override;
public
2019-06-16 10:31:13 +02:00
constructor Create(const browser: ICefBrowser; const frame: ICefFrame; const proc: TCefDomVisitorProc2); reintroduce; virtual;
destructor Destroy; override;
end;
TCefFastDomVisitor3 = class(TCefDomVisitorOwn)
protected
FProc : TCefDomVisitorProc3;
FBrowser : ICefBrowser;
FFrame : ICefFrame;
FValue : ustring;
procedure visit(const document: ICefDomDocument); override;
public
constructor Create(const browser: ICefBrowser; const frame: ICefFrame; const proc: TCefDomVisitorProc3; const aValue : ustring); reintroduce; virtual;
destructor Destroy; override;
end;
2017-01-27 16:37:51 +01:00
implementation
uses
uCEFMiscFunctions, uCEFLibFunctions, uCEFDomDocument;
2017-01-27 16:37:51 +01:00
procedure cef_dom_visitor_visite(self: PCefDomVisitor; document: PCefDomDocument); stdcall;
2018-03-29 20:02:04 +02:00
var
TempObject : TObject;
2017-01-27 16:37:51 +01:00
begin
2018-03-29 20:02:04 +02:00
TempObject := CefGetObject(self);
if (TempObject <> nil) and (TempObject is TCefDomVisitorOwn) then
TCefDomVisitorOwn(TempObject).visit(TCefDomDocumentRef.UnWrap(document));
2017-01-27 16:37:51 +01:00
end;
// TCefDomVisitorOwn
constructor TCefDomVisitorOwn.Create;
begin
inherited CreateData(SizeOf(TCefDomVisitor));
PCefDomVisitor(FData)^.visit := {$IFDEF FPC}@{$ENDIF}cef_dom_visitor_visite;
2017-01-27 16:37:51 +01:00
end;
procedure TCefDomVisitorOwn.visit(const document: ICefDomDocument);
begin
end;
// TCefFastDomVisitor
constructor TCefFastDomVisitor.Create(const proc: TCefDomVisitorProc);
begin
inherited Create;
2017-01-27 16:37:51 +01:00
FProc := proc;
end;
procedure TCefFastDomVisitor.visit(const document: ICefDomDocument);
begin
FProc(document);
end;
// TCefFastDomVisitor2
2019-06-16 10:31:13 +02:00
constructor TCefFastDomVisitor2.Create(const browser: ICefBrowser; const frame: ICefFrame; const proc: TCefDomVisitorProc2);
begin
inherited Create;
FBrowser := browser;
2019-06-16 10:31:13 +02:00
FFrame := frame;
FProc := proc;
end;
destructor TCefFastDomVisitor2.Destroy;
begin
FBrowser := nil;
2019-06-16 10:31:13 +02:00
FFrame := nil;
inherited Destroy;
end;
procedure TCefFastDomVisitor2.visit(const document: ICefDomDocument);
begin
2019-06-16 10:31:13 +02:00
FProc(FBrowser, FFrame, document);
end;
// TCefFastDomVisitor3
constructor TCefFastDomVisitor3.Create(const browser: ICefBrowser; const frame: ICefFrame; const proc: TCefDomVisitorProc3; const aValue : ustring);
begin
inherited Create;
FBrowser := browser;
FFrame := frame;
FProc := proc;
FValue := aValue;
end;
destructor TCefFastDomVisitor3.Destroy;
begin
FBrowser := nil;
FFrame := nil;
inherited Destroy;
end;
procedure TCefFastDomVisitor3.visit(const document: ICefDomDocument);
begin
FProc(FBrowser, FFrame, document, FValue);
end;
2017-01-27 16:37:51 +01:00
end.