Bladeren bron

inspector: mark overwritten attributes

mattias 11 uur geleden
bovenliggende
commit
1de4a30c65
1 gewijzigde bestanden met toevoegingen van 26 en 7 verwijderingen
  1. 26 7
      src/base/fresnel.cssstyleinspector.pas

+ 26 - 7
src/base/fresnel.cssstyleinspector.pas

@@ -1,7 +1,7 @@
 {
   ToDo:
-    - all
-    - shorthands
+    - "all: initial"
+    - text-decoration
     - mark overwritten
     - color box
     - edit value
@@ -63,6 +63,7 @@ type
     FLock: integer;
     FInspectNeeded: boolean;
     FTarget: TFresnelElement;
+    FUsedAttributes: array of boolean; // TCSSNumericalID
     procedure OnTargetCSSApplied(Event: TAbstractEvent);
     procedure SetTarget(const AValue: TFresnelElement);
   protected
@@ -93,7 +94,8 @@ type
       DeclValueLabelClass = 'CSSStyleInspValue';
       DeclSemicolonLabelClass = 'CSSStyleInspSemicolon';
       DeclLonghandDivClass = 'CSSStyleInspLonghand';
-      SkippedClass = 'CSSStyleInspSkipped';
+      InvalidClass = 'CSSStyleInspInvalid';
+      OverwrittenClass = 'CSSStyleInspOverwritten';
       BoxModelDivClass = 'CSSStyleInspBoxModel';
       //
       ElementStyleCaption = 'Element.Style';
@@ -119,7 +121,6 @@ var
   w, h: TFresnelLength;
 begin
   R:=UsedContentBox;
-  writeln('AAA3 TCSSInspDropArrow.Render ',R.ToString);
 
   h:=Min(R.Width,R.Height);
   w:=h*0.66;
@@ -357,6 +358,7 @@ var
   aStyleSheet: TCSSResolver.TStyleSheet;
   RuleOrigin, Selectors: TCSSString;
   aSelector: TCSSElement;
+  TargetResolver: TCSSResolver;
 begin
   if csDestroying in ComponentState then
     exit;
@@ -382,6 +384,11 @@ begin
   try
     VP.Resolver.Compute(Target,Target.StyleElement,Rules,aTargetValues);
 
+    TargetResolver:=Target.Resolver;
+    FUsedAttributes:=[];
+    SetLength(FUsedAttributes,TargetResolver.CustomAttributeCount+TargetResolver.CSSRegistry.AttributeCount);
+    For i:=0 to length(FUsedAttributes)-1 do FUsedAttributes[i]:=false;
+
     Row:=0;
 
     // Element.Style aka inline style
@@ -559,7 +566,7 @@ begin
       ValueCaption+=' !important';
     ValueCaption+=';';
 
-    UpdateLabel(DeclDiv,Index,SkippedClass,KeyTxt+': '+ValueCaption);
+    UpdateLabel(DeclDiv,Index,InvalidClass,KeyTxt+': '+ValueCaption);
     inc(Index);
   end;
 
@@ -581,6 +588,7 @@ var
   KeyTxt: TCSSString;
   AttrIDs: TCSSNumericalIDArray;
   Values: TCSSStringArray;
+  Used: Boolean;
 begin
   Result:=false;
   if (DeclEl.KeyCount<>1) then
@@ -601,6 +609,11 @@ begin
     exit;
   Result:=true;
 
+  Used:=FUsedAttributes[Desc.Index];
+  FUsedAttributes[Desc.Index]:=true;
+  if Used then
+    DeclDiv.AddCSSClass(OverwrittenClass);
+
   KeyTxt:=KeyEl.AsFormattedString;
 
   ValueTxt:='';
@@ -658,10 +671,16 @@ var
   LHDiv: TDiv;
   SubIndex: Integer;
   Desc: TCSSAttributeDesc;
+  Used: Boolean;
 begin
   Desc:=Target.Resolver.GetAttributeDesc(AttrID);
 
+  Used:=FUsedAttributes[Desc.Index];
+  FUsedAttributes[Desc.Index]:=true;
+
   LHDiv:=TDiv(UpdateElement(DeclDiv,Index,TDiv,DeclLonghandDivClass));
+  if Used then
+    LHDiv.AddCSSClass(OverwrittenClass);
   SubIndex:=0;
   UpdateLabel(LHDiv,SubIndex,DeclKeyLabelClass,Desc.Name);
   inc(SubIndex);
@@ -713,7 +732,6 @@ end;
 procedure TCSSStyleInspector.UpdateArrow(DeclDiv: TDiv; Index: integer;
   const aClass: string);
 begin
-  writeln('AAA2 TCSSStyleInspector.UpdateArrow ');
   UpdateElement(DeclDiv,Index,TCSSInspDropArrow,aClass);
 end;
 
@@ -766,7 +784,8 @@ begin
     +'.'+DeclValueLabelClass+' { color: #d8e; }'+LineEnding
     //+'.'+DeclSemicolonLabelClass+' { font-weight: bold; }'+LineEnding
     +'.'+DeclLonghandDivClass+' { margin-left: 2ch; }'+LineEnding
-    +'.'+SkippedClass+' { color: #aaa; }'+LineEnding
+    +'.'+InvalidClass+' { color: #aaa; }'+LineEnding
+    +'.'+OverwrittenClass+' { color: #aaa; margin-left: 4ch; }'+LineEnding
     +'.'+BoxModelDivClass+' { color: #fff; font-size: 10px; background-color: #222; padding: 6px; height: 12em; }'+LineEnding
     ;
 end;