fcl-css: added GetCSSPath

This commit is contained in:
mattias 2022-09-08 14:59:38 +02:00
parent a40a3ee34d
commit de586e55c0

View File

@ -364,6 +364,8 @@ Function StringToCSSString(const S : UTF8String) : UTF8String;
// Escapes non-identifier characters C to \C
Function StringToIdentifier(const S : UTF8String) : UTF8String;
Function GetCSSPath(El: TCSSElement): string;
Const
CSSUnitNames : Array[TCSSUnits] of string =
('','px','%','rem','em','pt','fr','vw','vh','deg');
@ -480,6 +482,23 @@ begin
SetLength(Result,iOut);
end;
function GetCSSPath(El: TCSSElement): string;
begin
if El=nil then
exit('nil');
Result:='';
while El<>nil do
begin
if Result<>'' then
Result:='.'+Result;
if El is TCSSIdentifierElement then
Result:=TCSSIdentifierElement(El).Name+Result
else
Result:=El.ClassName+Result;
El:=El.Parent;
end;
end;
{ TCSSListElement }
function TCSSListElement.GetAsString(aFormat: Boolean; const aIndent: String): UTF8String;