Using CEF Browser I try to hook to the OnLoadEnd event in order to traverse the DOM tree.
For some strange reason I get the VisitDom called 2 times.
procedure TForm1.FormCreate(Sender: TObject);
begin
FBrowser := TChromium.Create(Self);
FBrowser.Parent := TWinControl(Self);
FBrowser.OnLoadEnd := BrowserOnLoadEnd;
FBrowser.Load('http://google.com');
end;
procedure VisitDom(const Document: ICefDomDocument);
begin
ShowMessage(Document.Document.Name);
end;
procedure TForm1.BrowserOnLoadEnd(Sender: TObject;
const Browser: ICefBrowser; const Frame: ICefFrame; HttpStatusCode: Integer;
out Result: Boolean);
var
Visitor: TCefFastDomVisitor;
begin
if HttpStatusCode = 200 then
begin
Visitor := TCefFastDomVisitor.Create(VisitDom);
FBrowser.Browser.MainFrame.VisitDom(Visitor);
end;
end;
Any idea why OnLoadEnd is called multiple times?