|
@@ -563,11 +563,13 @@ type
|
|
function GetCompString(const aValue: string; const ResValue: TCSSResCompValue): TCSSString; overload;
|
|
function GetCompString(const aValue: string; const ResValue: TCSSResCompValue): TCSSString; overload;
|
|
// low level functions to parse attribute components
|
|
// low level functions to parse attribute components
|
|
function ReadComp(var aComp: TCSSResCompValue): boolean; // true if parsing attribute can continue
|
|
function ReadComp(var aComp: TCSSResCompValue): boolean; // true if parsing attribute can continue
|
|
- function ReadNumber(var aComp: TCSSResCompValue): boolean;
|
|
|
|
- function ReadIdentifier(var aComp: TCSSResCompValue): boolean;
|
|
|
|
- procedure SkipToEndOfAttribute(var p: PCSSChar);
|
|
|
|
- function SkipString(var p: PCSSChar): boolean;
|
|
|
|
- function SkipBrackets(var p: PCSSChar; Lvl: integer = 1): boolean;
|
|
|
|
|
|
+ procedure ReadWordID(var aComp: TCSSResCompValue);
|
|
|
|
+ class function ReadValue(var aComp: TCSSResCompValue): boolean; // true if parsing attribute can continue, not using CSSRegistry
|
|
|
|
+ class function ReadNumber(var aComp: TCSSResCompValue): boolean;
|
|
|
|
+ class function ReadIdentifier(var aComp: TCSSResCompValue): boolean;
|
|
|
|
+ class procedure SkipToEndOfAttribute(var p: PCSSChar);
|
|
|
|
+ class function SkipString(var p: PCSSChar): boolean;
|
|
|
|
+ class function SkipBrackets(var p: PCSSChar; Lvl: integer = 1): boolean;
|
|
// registry
|
|
// registry
|
|
function GetAttributeID(const aName: TCSSString; AutoCreate: boolean = false): TCSSNumericalID; virtual;
|
|
function GetAttributeID(const aName: TCSSString; AutoCreate: boolean = false): TCSSNumericalID; virtual;
|
|
function GetAttributeDesc(AttrID: TCSSNumericalID): TCSSAttributeDesc; virtual;
|
|
function GetAttributeDesc(AttrID: TCSSNumericalID): TCSSAttributeDesc; virtual;
|
|
@@ -1630,6 +1632,34 @@ begin
|
|
end;
|
|
end;
|
|
|
|
|
|
function TCSSBaseResolver.ReadComp(var aComp: TCSSResCompValue): boolean;
|
|
function TCSSBaseResolver.ReadComp(var aComp: TCSSResCompValue): boolean;
|
|
|
|
+begin
|
|
|
|
+ Result:=ReadValue(aComp);
|
|
|
|
+ ReadWordID(aComp);
|
|
|
|
+end;
|
|
|
|
+
|
|
|
|
+procedure TCSSBaseResolver.ReadWordID(var aComp: TCSSResCompValue);
|
|
|
|
+var
|
|
|
|
+ Identifier: TCSSString;
|
|
|
|
+begin
|
|
|
|
+ case aComp.Kind of
|
|
|
|
+ rvkFunctionUnknown:
|
|
|
|
+ begin
|
|
|
|
+ SetString(Identifier,aComp.StartP,aComp.EndP-aComp.StartP);
|
|
|
|
+ aComp.FunctionID:=CSSRegistry.IndexOfAttrFunction(Identifier);
|
|
|
|
+ if aComp.FunctionID>CSSIDNone then
|
|
|
|
+ aComp.Kind:=rvkFunction;
|
|
|
|
+ end;
|
|
|
|
+ rvkKeywordUnknown:
|
|
|
|
+ begin
|
|
|
|
+ SetString(Identifier,aComp.StartP,aComp.EndP-aComp.StartP);
|
|
|
|
+ aComp.KeywordID:=CSSRegistry.IndexOfKeyword(Identifier);
|
|
|
|
+ if aComp.KeywordID>CSSIDNone then
|
|
|
|
+ aComp.Kind:=rvkKeyword;
|
|
|
|
+ end;
|
|
|
|
+ end;
|
|
|
|
+end;
|
|
|
|
+
|
|
|
|
+class function TCSSBaseResolver.ReadValue(var aComp: TCSSResCompValue): boolean;
|
|
var
|
|
var
|
|
c: TCSSChar;
|
|
c: TCSSChar;
|
|
p: PCSSChar;
|
|
p: PCSSChar;
|
|
@@ -1755,7 +1785,7 @@ begin
|
|
aComp.EndP:=p;
|
|
aComp.EndP:=p;
|
|
end;
|
|
end;
|
|
|
|
|
|
-function TCSSBaseResolver.ReadNumber(var aComp: TCSSResCompValue): boolean;
|
|
|
|
|
|
+class function TCSSBaseResolver.ReadNumber(var aComp: TCSSResCompValue): boolean;
|
|
var
|
|
var
|
|
Negative, HasNumber: Boolean;
|
|
Negative, HasNumber: Boolean;
|
|
Divisor: double;
|
|
Divisor: double;
|
|
@@ -1871,9 +1901,8 @@ begin
|
|
//writeln('TCSSBaseResolver.ReadNumber "',p,'" Value=',FloatToCSSStr(aComp.Float),' U=',U,' Kind=',aComp.Kind,' Result=',Result);
|
|
//writeln('TCSSBaseResolver.ReadNumber "',p,'" Value=',FloatToCSSStr(aComp.Float),' U=',U,' Kind=',aComp.Kind,' Result=',Result);
|
|
end;
|
|
end;
|
|
|
|
|
|
-function TCSSBaseResolver.ReadIdentifier(var aComp: TCSSResCompValue): boolean;
|
|
|
|
|
|
+class function TCSSBaseResolver.ReadIdentifier(var aComp: TCSSResCompValue): boolean;
|
|
var
|
|
var
|
|
- Identifier: TCSSString;
|
|
|
|
IsFunc: Boolean;
|
|
IsFunc: Boolean;
|
|
p: PCSSChar;
|
|
p: PCSSChar;
|
|
begin
|
|
begin
|
|
@@ -1884,34 +1913,21 @@ begin
|
|
repeat
|
|
repeat
|
|
inc(p);
|
|
inc(p);
|
|
until not (p^ in AlNumIden);
|
|
until not (p^ in AlNumIden);
|
|
- SetString(Identifier,aComp.StartP,p-aComp.StartP);
|
|
|
|
IsFunc:=p^='(';
|
|
IsFunc:=p^='(';
|
|
if IsFunc then
|
|
if IsFunc then
|
|
begin
|
|
begin
|
|
// function call
|
|
// function call
|
|
|
|
+ aComp.Kind:=rvkFunctionUnknown;
|
|
aComp.BracketOpen:=p;
|
|
aComp.BracketOpen:=p;
|
|
if not SkipBrackets(p) then
|
|
if not SkipBrackets(p) then
|
|
begin
|
|
begin
|
|
aComp.EndP:=p;
|
|
aComp.EndP:=p;
|
|
exit;
|
|
exit;
|
|
end;
|
|
end;
|
|
- end;
|
|
|
|
|
|
+ end else
|
|
|
|
+ aComp.Kind:=rvkKeywordUnknown;
|
|
aComp.EndP:=p;
|
|
aComp.EndP:=p;
|
|
|
|
|
|
- if IsFunc then
|
|
|
|
- begin
|
|
|
|
- aComp.FunctionID:=CSSRegistry.IndexOfAttrFunction(Identifier);
|
|
|
|
- if aComp.FunctionID>CSSIDNone then
|
|
|
|
- aComp.Kind:=rvkFunction
|
|
|
|
- else
|
|
|
|
- aComp.Kind:=rvkFunctionUnknown;
|
|
|
|
- end else begin
|
|
|
|
- aComp.KeywordID:=CSSRegistry.IndexOfKeyword(Identifier);
|
|
|
|
- if aComp.KeywordID>CSSIDNone then
|
|
|
|
- aComp.Kind:=rvkKeyword
|
|
|
|
- else
|
|
|
|
- aComp.Kind:=rvkKeywordUnknown;
|
|
|
|
- end;
|
|
|
|
Result:=true;
|
|
Result:=true;
|
|
end;
|
|
end;
|
|
|
|
|
|
@@ -2007,7 +2023,7 @@ begin
|
|
SetString(Result,Start,ResValue.EndP-Start);
|
|
SetString(Result,Start,ResValue.EndP-Start);
|
|
end;
|
|
end;
|
|
|
|
|
|
-procedure TCSSBaseResolver.SkipToEndOfAttribute(var p: PCSSChar);
|
|
|
|
|
|
+class procedure TCSSBaseResolver.SkipToEndOfAttribute(var p: PCSSChar);
|
|
begin
|
|
begin
|
|
repeat
|
|
repeat
|
|
case p^ of
|
|
case p^ of
|
|
@@ -2018,7 +2034,7 @@ begin
|
|
until false;
|
|
until false;
|
|
end;
|
|
end;
|
|
|
|
|
|
-function TCSSBaseResolver.SkipString(var p: PCSSChar): boolean;
|
|
|
|
|
|
+class function TCSSBaseResolver.SkipString(var p: PCSSChar): boolean;
|
|
var
|
|
var
|
|
Delim, c: TCSSChar;
|
|
Delim, c: TCSSChar;
|
|
begin
|
|
begin
|
|
@@ -2038,7 +2054,7 @@ begin
|
|
until false;
|
|
until false;
|
|
end;
|
|
end;
|
|
|
|
|
|
-function TCSSBaseResolver.SkipBrackets(var p: PCSSChar; Lvl: integer): boolean;
|
|
|
|
|
|
+class function TCSSBaseResolver.SkipBrackets(var p: PCSSChar; Lvl: integer): boolean;
|
|
const
|
|
const
|
|
CSSMaxBracketLvl = 10;
|
|
CSSMaxBracketLvl = 10;
|
|
var
|
|
var
|