Преглед изворни кода

TFresnelCSSAttribute: added fcaBackground

mattias пре 1 година
родитељ
комит
6759755127
1 измењених фајлова са 26 додато и 2 уклоњено
  1. 26 2
      src/base/fresnel.dom.pas

+ 26 - 2
src/base/fresnel.dom.pas

@@ -120,7 +120,7 @@ type
     fcaPaddingRight,
     fcaPaddingBottom,
     fcaVisibility,
-    // todo: fcaBackground shorthand
+    fcaBackground, // shorthand for background-[attachment,clip,color,image,origin,position,repeat,size]
     fcaBackgroundColor,
     fcaColor     // text color
     );
@@ -204,6 +204,7 @@ const
     'padding-right',
     'padding-bottom',
     'visibility',
+    'background',
     'background-color',
     'color'
     );
@@ -423,6 +424,7 @@ type
     function CheckCSSFontVariant(const AValue: string): boolean; virtual;
     function CheckOrSetCSSPadding(const AValue: string; Check: boolean): boolean; virtual;
     function CheckCSSVisibility(const AValue: string): boolean; virtual;
+    function CheckOrSetCSSBackground(const AValue: string; Check: boolean): boolean; virtual;
     function CheckCSSBackgroundColor(const AValue: string): boolean; virtual;
     function CheckCSSColor(const AValue: string): boolean; virtual;
     function GetComputedCSSValue(AttrID: TCSSNumericalID): TCSSString;
@@ -1502,7 +1504,7 @@ begin
   if FCSSAttributes[Attr]=AValue then exit;
   FCSSAttributes[Attr]:=AValue;
   case AValue of
-  'inherit','initial','unset': exit;
+  'inherit','initial','unset','revert','revert-layer': exit;
   end;
 
   // set shorthand attributes
@@ -1523,6 +1525,7 @@ begin
   fcaMarginBlock: CheckOrSetCSSMarginBlock(AValue,false);
   fcaMarginInline: CheckOrSetCSSMarginInline(AValue,false);
   fcaPadding: CheckOrSetCSSPadding(AValue,false);
+  fcaBackground: CheckOrSetCSSBackground(AValue,false);
   end;
 end;
 
@@ -2541,6 +2544,26 @@ begin
   end;
 end;
 
+function TFresnelElement.CheckOrSetCSSBackground(const AValue: string;
+  Check: boolean): boolean;
+var
+  p: Integer;
+  s: String;
+begin
+  Result:=false;
+  p:=1;
+  s:=CSSReadNextValue(AValue,p);
+  if CheckCSSBackgroundColor(s) then
+  begin
+    if not Check then
+      SetCSSElAttribute(fcaBackgroundColor,s);
+  end else begin
+    CSSInvalidValueWarning(20240527102124,fcaBackground,s);
+    exit;
+  end;
+  Result:=true;
+end;
+
 function TFresnelElement.CheckCSSBackgroundColor(const AValue: string): boolean;
 var
   aColor: TFPColor;
@@ -3657,6 +3680,7 @@ begin
     fcaPaddingRight,
     fcaPaddingBottom: Result:=CheckCSSLength(Attr,s,[flcNoNegative]);
     fcaVisibility: Result:=CheckCSSVisibility(s);
+    fcaBackground: Result:=CheckOrSetCSSBackground(s,true);
     fcaBackgroundColor: Result:=CheckCSSBackgroundColor(s);
     fcaColor: Result:=CheckCSSColor(s);
     end;