2017-01-27 16:37:51 +01:00
|
|
|
unit uCEFDomVisitor;
|
|
|
|
|
2018-05-12 14:50:54 +02:00
|
|
|
{$IFDEF FPC}
|
|
|
|
{$MODE OBJFPC}{$H+}
|
|
|
|
{$ENDIF}
|
|
|
|
|
2017-02-05 20:56:46 +01:00
|
|
|
{$I cef.inc}
|
|
|
|
|
2022-02-19 18:56:41 +01:00
|
|
|
{$IFNDEF TARGET_64BITS}{$ALIGN ON}{$ENDIF}
|
|
|
|
{$MINENUMSIZE 4}
|
|
|
|
|
2017-01-27 16:37:51 +01:00
|
|
|
interface
|
|
|
|
|
|
|
|
uses
|
2020-06-20 16:10:29 +02:00
|
|
|
uCEFBaseRefCounted, uCEFInterfaces, uCEFTypes;
|
2017-01-27 16:37:51 +01:00
|
|
|
|
|
|
|
type
|
2017-03-16 19:09:42 +01:00
|
|
|
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
|
2017-07-18 17:50:28 +02:00
|
|
|
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;
|
|
|
|
|
2017-07-18 17:50:28 +02:00
|
|
|
TCefFastDomVisitor2 = class(TCefDomVisitorOwn)
|
|
|
|
protected
|
|
|
|
FProc : TCefDomVisitorProc2;
|
|
|
|
FBrowser : ICefBrowser;
|
2019-06-16 10:31:13 +02:00
|
|
|
FFrame : ICefFrame;
|
2017-07-18 17:50:28 +02:00
|
|
|
|
|
|
|
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;
|
2017-07-18 17:50:28 +02:00
|
|
|
destructor Destroy; override;
|
|
|
|
end;
|
|
|
|
|
2020-06-20 16:10:29 +02:00
|
|
|
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
|
2020-06-20 16:10:29 +02:00
|
|
|
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));
|
|
|
|
|
2018-05-12 14:50:54 +02:00
|
|
|
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-07-18 17:50:28 +02:00
|
|
|
|
2017-01-27 16:37:51 +01:00
|
|
|
FProc := proc;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TCefFastDomVisitor.visit(const document: ICefDomDocument);
|
|
|
|
begin
|
|
|
|
FProc(document);
|
|
|
|
end;
|
|
|
|
|
2017-07-18 17:50:28 +02:00
|
|
|
|
|
|
|
// TCefFastDomVisitor2
|
|
|
|
|
2019-06-16 10:31:13 +02:00
|
|
|
constructor TCefFastDomVisitor2.Create(const browser: ICefBrowser; const frame: ICefFrame; const proc: TCefDomVisitorProc2);
|
2017-07-18 17:50:28 +02:00
|
|
|
begin
|
|
|
|
inherited Create;
|
|
|
|
|
|
|
|
FBrowser := browser;
|
2019-06-16 10:31:13 +02:00
|
|
|
FFrame := frame;
|
2017-07-18 17:50:28 +02:00
|
|
|
FProc := proc;
|
|
|
|
end;
|
|
|
|
|
|
|
|
destructor TCefFastDomVisitor2.Destroy;
|
|
|
|
begin
|
|
|
|
FBrowser := nil;
|
2019-06-16 10:31:13 +02:00
|
|
|
FFrame := nil;
|
2017-07-18 17:50:28 +02:00
|
|
|
|
|
|
|
inherited Destroy;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TCefFastDomVisitor2.visit(const document: ICefDomDocument);
|
|
|
|
begin
|
2019-06-16 10:31:13 +02:00
|
|
|
FProc(FBrowser, FFrame, document);
|
2017-07-18 17:50:28 +02:00
|
|
|
end;
|
|
|
|
|
2020-06-20 16:10:29 +02:00
|
|
|
|
|
|
|
// 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.
|