1
0
mirror of https://github.com/salvadordf/CEF4Delphi.git synced 2024-11-24 08:02:15 +02:00

Added overloaded TCEFDomNode.GetElementAttributes(var attrList: TStrings);

This commit is contained in:
Salvador Díaz Fau 2018-06-12 21:34:53 +02:00
parent b701fc99e8
commit 8519c9b5d5
2 changed files with 54 additions and 3 deletions

View File

@ -51,6 +51,11 @@ unit uCEFDomNode;
interface
uses
{$IFDEF DELPHI16_UP}
{$IFDEF MSWINDOWS}WinApi.Windows,{$ENDIF} System.Classes, System.SysUtils,
{$ELSE}
{$IFDEF MSWINDOWS}Windows,{$ENDIF} Classes, SysUtils,
{$ENDIF}
uCEFBaseRefCounted, uCEFInterfaces, uCEFTypes;
type
@ -78,7 +83,8 @@ type
function HasElementAttributes: Boolean;
function HasElementAttribute(const attrName: ustring): Boolean;
function GetElementAttribute(const attrName: ustring): ustring;
procedure GetElementAttributes(const attrMap: ICefStringMap);
procedure GetElementAttributes(const attrMap: ICefStringMap); overload;
procedure GetElementAttributes(var attrList: TStrings); overload;
function SetElementAttribute(const attrName, value: ustring): Boolean;
function GetElementInnerText: ustring;
function GetElementBounds: TCefRect;
@ -90,7 +96,7 @@ type
implementation
uses
uCEFMiscFunctions, uCEFDomDocument;
uCEFMiscFunctions, uCEFDomDocument, uCEFStringMap;
function TCefDomNodeRef.GetAsMarkup: ustring;
begin
@ -115,6 +121,50 @@ begin
PCefDomNode(FData)^.get_element_attributes(PCefDomNode(FData), attrMap.Handle);
end;
procedure TCefDomNodeRef.GetElementAttributes(var attrList: TStrings);
var
TempStrMap : ICefStringMap;
i, j : NativeUInt;
TempKey, TempValue : ustring;
begin
TempStrMap := nil;
try
try
if (attrList <> nil) then
begin
TempStrMap := TCefStringMapOwn.Create;
PCefDomNode(FData)^.get_element_attributes(PCefDomNode(FData), TempStrMap.Handle);
i := 0;
j := TempStrMap.Size;
while (i < j) do
begin
TempKey := TempStrMap.Key[i];
TempValue := TempStrMap.Value[i];
if (length(TempKey) > 0) and (length(TempValue) > 0) then
attrList.Add(TempKey + attrList.NameValueSeparator + TempValue)
else
if (length(TempKey) > 0) then
attrList.Add(TempKey)
else
if (length(TempValue) > 0) then
attrList.Add(TempValue);
inc(i);
end;
end;
except
on e : exception do
if CustomExceptionHandler('TCefDomNodeRef.GetElementAttributes', e) then raise;
end;
finally
TempStrMap := nil;
end;
end;
function TCefDomNodeRef.GetElementInnerText: ustring;
begin
Result := CefStringFreeAndGet(PCefDomNode(FData)^.get_element_inner_text(PCefDomNode(FData)));

View File

@ -1061,7 +1061,8 @@ type
function HasElementAttributes: Boolean;
function HasElementAttribute(const attrName: ustring): Boolean;
function GetElementAttribute(const attrName: ustring): ustring;
procedure GetElementAttributes(const attrMap: ICefStringMap);
procedure GetElementAttributes(const attrMap: ICefStringMap); overload;
procedure GetElementAttributes(var attrList: TStrings); overload;
function SetElementAttribute(const attrName, value: ustring): Boolean;
function GetElementInnerText: ustring;
function GetElementBounds: TCefRect;