mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-17 21:41:35 +02:00
* fixed crash when reading properties which values are one char
* fixed crash when property values are empty git-svn-id: trunk@17848 -
This commit is contained in:
parent
e966b41e53
commit
332993241d
@ -1,12 +1,12 @@
|
|||||||
{$IFDEF CSS_INTERFACE}
|
{$IFDEF CSS_INTERFACE}
|
||||||
TCSSGroup = class
|
TCSSGroup = class
|
||||||
end;
|
end;
|
||||||
|
|
||||||
TCSSFontStyle = (cfsNormal, cfsItalic, cfsOblique, cfsInherit);
|
TCSSFontStyle = (cfsNormal, cfsItalic, cfsOblique, cfsInherit);
|
||||||
TCSSFontWeight = (cfwNormal, cfwBold, cfwBolder, cfwLighter, cfw100, cfw200,
|
TCSSFontWeight = (cfwNormal, cfwBold, cfwBolder, cfwLighter, cfw100, cfw200,
|
||||||
cfw300, cfw400 , cfw500, cfw600, cfw700, cfw800, cfw900);
|
cfw300, cfw400 , cfw500, cfw600, cfw700, cfw800, cfw900);
|
||||||
TCSSFontVariant = (cfvNormal, cfvSmallCaps, cfvInherit);
|
TCSSFontVariant = (cfvNormal, cfvSmallCaps, cfvInherit);
|
||||||
|
|
||||||
TCSSBorderStyle = (cbsNone, cbsHidden, cbsDotted, cbsDashed, cbsSolid, cbsDouble,
|
TCSSBorderStyle = (cbsNone, cbsHidden, cbsDotted, cbsDashed, cbsSolid, cbsDouble,
|
||||||
cbsGroove, cbsRidge, cbsInset, cbsOutset);
|
cbsGroove, cbsRidge, cbsInset, cbsOutset);
|
||||||
|
|
||||||
@ -25,7 +25,7 @@
|
|||||||
//proprety Variant: TCSSFontVariant
|
//proprety Variant: TCSSFontVariant
|
||||||
property Weight: TCSSFontWeight read FWeight write FWeight;
|
property Weight: TCSSFontWeight read FWeight write FWeight;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TCSSBorder }
|
{ TCSSBorder }
|
||||||
|
|
||||||
TCSSBorder = class
|
TCSSBorder = class
|
||||||
@ -36,7 +36,7 @@
|
|||||||
property Color: TColor read FColor write FColor;
|
property Color: TColor read FColor write FColor;
|
||||||
property Style: TCSSBorderStyle read FStyle write FStyle;
|
property Style: TCSSBorderStyle read FStyle write FStyle;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TCSSProps }
|
{ TCSSProps }
|
||||||
|
|
||||||
TCSSProps = class
|
TCSSProps = class
|
||||||
@ -64,7 +64,7 @@
|
|||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
procedure ReadCommands(ACommands: TStrings);
|
procedure ReadCommands(ACommands: TStrings);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TCSSGlobalProps }
|
{ TCSSGlobalProps }
|
||||||
|
|
||||||
TCSSGlobalProps = class
|
TCSSGlobalProps = class
|
||||||
@ -74,7 +74,7 @@
|
|||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
function GetElement(AElementID: String; ClassID: String = ''; CreateIfNotExist: Boolean = False): TCSSProps;
|
function GetElement(AElementID: String; ClassID: String = ''; CreateIfNotExist: Boolean = False): TCSSProps;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{$ELSE implementation}
|
{$ELSE implementation}
|
||||||
type
|
type
|
||||||
|
|
||||||
@ -519,7 +519,7 @@ begin
|
|||||||
Result.Delimiter := ',';
|
Result.Delimiter := ',';
|
||||||
Result.DelimitedText := Elements;
|
Result.DelimitedText := Elements;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
for i := 0 to Result.Count-1 do begin
|
for i := 0 to Result.Count-1 do begin
|
||||||
Element := LowerCase(Result[i]);
|
Element := LowerCase(Result[i]);
|
||||||
ElementClass := '';
|
ElementClass := '';
|
||||||
@ -558,7 +558,8 @@ var
|
|||||||
begin
|
begin
|
||||||
Result := TStringList.Create;
|
Result := TStringList.Create;
|
||||||
Start := Pos(':', ACommand)+1;
|
Start := Pos(':', ACommand)+1;
|
||||||
|
ACommand := ACommand + ' ';
|
||||||
|
|
||||||
|
|
||||||
WantArg := True;
|
WantArg := True;
|
||||||
Quote := #0;
|
Quote := #0;
|
||||||
@ -683,7 +684,7 @@ begin
|
|||||||
EatWhiteSpace;
|
EatWhiteSpace;
|
||||||
|
|
||||||
AStatement := '';
|
AStatement := '';
|
||||||
|
|
||||||
FStart := FStream.Position;
|
FStart := FStream.Position;
|
||||||
while not EOF do
|
while not EOF do
|
||||||
begin
|
begin
|
||||||
@ -757,9 +758,15 @@ begin
|
|||||||
Command := LowerCase(GetCommandName(ACommand));
|
Command := LowerCase(GetCommandName(ACommand));
|
||||||
|
|
||||||
if Command = 'color' then
|
if Command = 'color' then
|
||||||
Color := ColorFromString(Args[0])
|
if Args.Count > 0 then
|
||||||
|
Color := ColorFromString(Args[0])
|
||||||
|
else
|
||||||
|
Color := clDefault
|
||||||
else if Command = 'background-color' then
|
else if Command = 'background-color' then
|
||||||
BGColor := ColorFromString(Args[0])
|
if Args.Count > 0 then
|
||||||
|
BGColor := ColorFromString(Args[0])
|
||||||
|
else
|
||||||
|
BGColor := clDefault
|
||||||
else if Command = 'background' then
|
else if Command = 'background' then
|
||||||
begin
|
begin
|
||||||
if Args.Count > 0 then BGColor := ColorFromString(Args[0]);
|
if Args.Count > 0 then BGColor := ColorFromString(Args[0]);
|
||||||
@ -776,7 +783,7 @@ begin
|
|||||||
Font.Style := CSSFontStyleFromName(Args[0])
|
Font.Style := CSSFontStyleFromName(Args[0])
|
||||||
else if Command = 'font-weight' then
|
else if Command = 'font-weight' then
|
||||||
Font.Weight := FontWeightFromString(Args[0]);
|
Font.Weight := FontWeightFromString(Args[0]);
|
||||||
|
|
||||||
Args.Free;
|
Args.Free;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -811,19 +818,19 @@ var
|
|||||||
ElementName := Lowercase(aElement+'.'+ClassId)
|
ElementName := Lowercase(aElement+'.'+ClassId)
|
||||||
else
|
else
|
||||||
ElementName := lowercase(aElement);
|
ElementName := lowercase(aElement);
|
||||||
|
|
||||||
ElementIndex := FElements.IndexOf(ElementName);
|
ElementIndex := FElements.IndexOf(ElementName);
|
||||||
|
|
||||||
if ElementIndex>=0 then begin
|
if ElementIndex>=0 then begin
|
||||||
result := TCSSProps(FElements.Objects[ElementIndex]);
|
result := TCSSProps(FElements.Objects[ElementIndex]);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
end;
|
end;
|
||||||
begin
|
begin
|
||||||
Result := nil;
|
Result := nil;
|
||||||
if (ClassID = '') and (AElementID = '') then
|
if (ClassID = '') and (AElementID = '') then
|
||||||
exit;
|
exit;
|
||||||
|
|
||||||
LookForElement(aElementID);
|
LookForElement(aElementID);
|
||||||
if (Result=nil) and not CreateIfNotExist then
|
if (Result=nil) and not CreateIfNotExist then
|
||||||
LookForelement('*');
|
LookForelement('*');
|
||||||
|
Loading…
Reference in New Issue
Block a user