Browse Source

inspector: styles

mattias 3 weeks ago
parent
commit
2ea722c3f1
1 changed files with 22 additions and 13 deletions
  1. 22 13
      demo/Inspector/fresnel.cssstyleinspector.pas

+ 22 - 13
demo/Inspector/fresnel.cssstyleinspector.pas

@@ -245,9 +245,10 @@ procedure TCSSStyleInspector.UpdateDeclaration(RuleDiv: TDiv; Row: integer;
 var
   KeyEl: TCSSElement;
   ResolvedKeyEl: TCSSResolvedIdentifierElement;
-  ValueTxt, KeyTxt: String;
+  ValueTxt, KeyTxt, ValueCaption: String;
   i, Index: Integer;
   DeclDiv: TDiv;
+  KeyData: TCSSAttributeKeyData;
 begin
   // add or update div
   if Row<RuleDiv.NodeCount-1 then // -1 for the footer
@@ -274,9 +275,10 @@ begin
       ValueTxt+=', ';
     ValueTxt+=DeclEl.Children[i].AsFormattedString;
   end;
+  ValueCaption:=ValueTxt;
   if DeclEl.IsImportant then
-    ValueTxt+=' !important';
-  ValueTxt+=';';
+    ValueCaption+=' !important';
+  ValueCaption+=';';
 
   Index:=0;
   if (DeclEl.KeyCount<>1) then
@@ -293,15 +295,21 @@ begin
         writeln('TCSSStyleInspector.AddDeclaration Unknown attribute: ',i,' "',ValueTxt,'"');
       end else begin
         // todo: check for validity
-        // todo: check if overriden
-        // todo: split shorthands
-        writeln('TCSSStyleInspector.AddDeclaration Known: ',i,' "',ValueTxt,'"');
-        UpdateLabel(DeclDiv,Index,DeclKeyLabelClass,KeyTxt);
-        inc(Index);
-        UpdateLabel(DeclDiv,Index,DeclColonLabelClass,':');
-        inc(Index);
-        UpdateLabel(DeclDiv,Index,DeclValueLabelClass,ValueTxt);
-        inc(Index);
+        KeyData:=TCSSAttributeKeyData(KeyEl.CustomData);
+        if KeyData.Invalid then
+        begin
+          // invalid value
+        end else begin
+          // todo: check if overriden
+          // todo: split shorthands
+          writeln('TCSSStyleInspector.AddDeclaration Known: ',i,' "',ValueTxt,'"');
+          UpdateLabel(DeclDiv,Index,DeclKeyLabelClass,KeyTxt);
+          inc(Index);
+          UpdateLabel(DeclDiv,Index,DeclColonLabelClass,':');
+          inc(Index);
+          UpdateLabel(DeclDiv,Index,DeclValueLabelClass,ValueTxt);
+          inc(Index);
+        end;
       end;
     end else begin
       // todo: unknown declaration
@@ -312,7 +320,7 @@ begin
   if Index=0 then
   begin
     // invalid declaration
-    UpdateLabel(DeclDiv,Index,SkippedClass,KeyTxt+': '+ValueTxt);
+    UpdateLabel(DeclDiv,Index,SkippedClass,KeyTxt+': '+ValueCaption);
     inc(Index);
   end;
 
@@ -389,6 +397,7 @@ begin
     +'.'+DeclDivClass+' { margin-left: 2ch; }'+LineEnding
     +'.'+DeclKeyLabelClass+' { color: cyan; }'+LineEnding
     +'.'+DeclColonLabelClass+' { margin-right: 1ch; }'+LineEnding
+    +'.'+SkippedClass+' { color: #aaa; }'+LineEnding
     ;
 end;